Documentation

HexGramSchmidt.Int.Canonical

Gram row-span invariant for no-pivot Bareiss #

Row-vector interpretation of the trailing block during a no-pivot Bareiss pass over a Gram matrix. Each active trailing row carries an explicit integer coefficient vector coeff i such that the represented row is Matrix.vecMul (coeff i) b, supported at coordinates ≤ i.val, and each matrix entry in that trailing row is its inner product against the corresponding original row.

Instances For

    The initial no-pivot Gram state satisfies the row-coefficient invariant with each row represented by the standard basis vector eᵢ.

    Equations
    Instances For
      def Hex.GramSchmidt.Int.bareissGramRowInvariantStepCoeff {n m : Nat} {b : Matrix Int n m} {state : Matrix.BareissState n} (hinv : BareissGramRowInvariant b state) (hnext : state.step + 1 < n) (i : Fin n) (_hi : state.step + 1 i) :

      Coefficient witness produced by one regular Bareiss step on the row at index i. The functional shape mirrors the row update on the matrix side.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        structure Hex.GramSchmidt.Int.BareissGramRegularStepQuotient {n m : Nat} {b : Matrix Int n m} {state : Matrix.BareissState n} (hinv : BareissGramRowInvariant b state) (hnext : state.step + 1 < n) (i : Fin n) (_hi : state.step + 1 i) :

        Coefficient-level exact-division provenance for one regular Gram-row Bareiss step. The quotient vector is kept separate from bareissGramRowInvariantStepCoeff so later row-entry proofs can consume the integer divisibility witness before projecting back to the existing exact-div coefficient API.

        Instances For
          theorem Hex.GramSchmidt.Int.bareissGramRowInvariantStepCoeff_support {n m : Nat} {b : Matrix Int n m} {state : Matrix.BareissState n} (hinv : BareissGramRowInvariant b state) (hnext : state.step + 1 < n) (i : Fin n) (hi : state.step + 1 i) (a : Fin n) :
          i < a(bareissGramRowInvariantStepCoeff hinv hnext i hi)[a] = 0

          Canonical coefficient vector and canonicity predicate #

          Canonical row-coefficient vector for the initial no-pivot Gram trajectory.

          Base case: each row carries the standard basis vector e_i. Inductive step (regular branch, active row): apply the fraction-free Bareiss row update via exactDiv. Processed rows, singular branches, and done branches preserve the previous vector unchanged — mirroring the row-invariant evolution in bareissGramRowInvariant_noPivotLoop_initialAux.

          Defined as a pure function of b and fuel (no BareissGramRowInvariant argument), so the canonical coefficient is fixed by the matrix and step count alone. Non-canonical row-coefficient witnesses are ruled out by the IsCanonicalAt predicate consumed by StepWitness.

          Equations
          Instances For
            @[simp]

            The canonical coefficient at fuel = 0 is the standard basis vector.

            @[simp]

            Recursion equation: regular-branch active-row case. With the branch hypotheses in context, simp [*]/simp_all rewrites bareissGramCanonicalCoeff at fuel + 1 to its explicit Bareiss exact-division update.

            @[simp]

            Recursion equation: regular-branch processed-row case. An already-processed row (i ≤ step) keeps its previous coefficient vector, so the canonical coefficient at fuel + 1 collapses to the one at fuel.

            @[simp]

            Recursion equation: singular branch (zero diagonal). A zero pivot skips the update, so the canonical coefficient at fuel + 1 collapses to the one at fuel.

            @[simp]

            Recursion equation: done branch (no further work possible). Once the loop can take no further step (¬ step + 1 < n), the canonical coefficient at fuel + 1 collapses to the one at fuel.

            A BareissGramRowInvariant on noPivotLoop fuel (noPivotInitialState …) is canonical at fuel when every row's coefficient vector matches bareissGramCanonicalCoeff. This is the soundness gate consumed by StepWitness: non-canonical witnesses (which can shift coefficients by a kernel vector while keeping entry_eq_dot satisfied) cannot invoke the witness's quotient identity.

            The SPEC counterexample at rows (1,1), (1,0), (-1,-1) (#6505) produces two distinct BareissGramRowInvariant instances at the same loop state whose coefficient vectors differ by the kernel vector. Both satisfy entry_eq_dot, but only one (the canonical one) yields an integer Bareiss-step quotient.

            Equations
            Instances For

              The base-case row invariant at fuel = 0 carries the standard basis vectors and is therefore canonical.

              theorem Hex.GramSchmidt.Int.bareissGramRowInvariant_coeff_transport {n m : Nat} {b : Matrix Int n m} {st1 st2 : Matrix.BareissState n} (h : st1 = st2) (x : BareissGramRowInvariant b st2) (i : Fin n) :
              ( x).coeff i = x.coeff i

              Transport along an equation of BareissStates preserves the coeff field of a BareissGramRowInvariant. The field's type Fin n → Vector Int n does not depend on the state index, so transport is the identity at that projection. Used to discharge canonicity proofs after transporting an explicit intermediate state back to the noPivotLoop fuel initial form.

              def Hex.GramSchmidt.Int.bareissGramRowInvariant_regular_step {n m : Nat} {b : Matrix Int n m} {state : Matrix.BareissState n} (hnext : state.step + 1 < n) (_hp : state.matrix[state.step][state.step] 0) (hinv : BareissGramRowInvariant b state) (hentry : ∀ (i j : Fin n) (hi : state.step + 1 i), (state.matrix.stepMatrix state.step state.matrix[state.step][state.step] state.prevPivot)[i][j] = (Matrix.vecMul (bareissGramRowInvariantStepCoeff hinv hnext i hi) b).dotProduct (b.row j)) :
              BareissGramRowInvariant b { step := state.step + 1, matrix := state.matrix.stepMatrix state.step state.matrix[state.step][state.step] state.prevPivot, prevPivot := state.matrix[state.step][state.step], rowSwaps := state.rowSwaps, singularStep := none }

              One regular no-pivot Bareiss step preserves the Gram row-coefficient invariant, provided the later loop proof supplies the exact-division entry relation for the fraction-free updated row combinations.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For

                The coefficient vectors produced by bareissGramRowInvariant_regular_step from a canonical input invariant match bareissGramCanonicalCoeff at the next-step fuel index. Used to propagate canonicity through one regular Bareiss step inside bareissGramRowInvariant_noPivotLoop_initialAux.

                @[reducible, inline]

                Per-step quotient package for the initial no-pivot Gram trajectory, restricted to canonical row-coefficient witnesses via IsCanonicalAt.

                StepWitness.Cell is an alias for BareissGramRegularStepQuotient whose canonicity gate (h_canon) prevents non-canonical BareissGramRowInvariant witnesses — which can shift coefficients by a kernel vector while still satisfying entry_eq_dot — from supplying integer quotients. The kernel-shift counterexample (SPEC #6505: rows (1,1), (1,0), (-1,-1) at row 2 step 1) shows the restriction is necessary: distinct non-canonical witnesses produce numerators differing by 1, which is not divisible by prevPivot = 2.

                Equations
                Instances For
                  @[reducible, inline]

                  Quotient provenance for the initial no-pivot Gram trajectory, restricted to canonical BareissGramRowInvariant witnesses via IsCanonicalAt. The provider supplies, at every reachable regular Bareiss step, an integer quotient q : Fin n → Int realising the Bareiss-row-update divisibility on the canonical coefficient vectors.

                  Concrete providers are constructed in HexGramSchmidtMathlib, where the Bareiss-Desnanot proof infrastructure on PSD Gram minors is available; the Mathlib-free layer only consumes this abstraction.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For