QPBT definitions: Algebra / RowEchelon
DefinitionQPBT_QPBT_Algebra_RowEchelonqpbt
This bundle defines row-echelon data used to identify canonical coordinate complements. It gives reduced row echelon form, prefix pivot counts, and the intrinsic complement of the row span.
Principal definitions:
MIPStarRE.QPBT.IsReducedRowEchelon: defines reduced row echelon form for a matrix.- Prefix pivot counting identifies the rank contributed by initial columns.
- Canonical complement data identifies the nonpivot coordinate set.
Formalization Credit. This Lean declaration is part of the Quantum Pauli basis test formalization by Ruixuan Deng. The source code was generated by AI agents; Ruixuan Deng is the responsible maintainer.
Mathematical Source. The mathematical source is Ji, Natarajan, Vidick, Wright, and Yuen, MIP*=RE, arXiv:2001.04383v3.
Definition code
-- Generated from QPBT/Algebra/RowEchelon.lean by skeleton subtraction.
import Definitions.Def_LIDT_MIPStarRE_LDT_Basic_AxisParallelLine
import Definitions.Def_LIDT_MIPStarRE_LDT_Basic_DiagonalLine
import Definitions.Def_LIDT_MIPStarRE_LDT_Basic_LinePolynomials
import Definitions.Def_LIDT_MIPStarRE_LDT_Basic_LowDegreePolynomial
import Definitions.Def_LIDT_MIPStarRE_LDT_Basic_OpFamily
import Definitions.Def_LIDT_MIPStarRE_LDT_Basic_ParametersBase
import Definitions.Def_LIDT_MIPStarRE_LDT_Basic_ParametersFiniteAnswers
import Definitions.Def_LIDT_MIPStarRE_LDT_Basic_QuantumState
import Definitions.Def_LIDT_MIPStarRE_LDT_CommutativityPoints_Defs
import Definitions.Def_LIDT_MIPStarRE_LDT_ExpansionHypercubeGraph_Defs_Core
import Definitions.Def_LIDT_MIPStarRE_LDT_GlobalVariance_Defs_Core
import Definitions.Def_LIDT_MIPStarRE_LDT_MakingMeasurementsProjective_Defs
import Definitions.Def_LIDT_MIPStarRE_LDT_Pasting_Defs_Families
import Definitions.Def_LIDT_MIPStarRE_LDT_Pasting_Defs_Interpolation
import Definitions.Def_LIDT_MIPStarRE_LDT_Tactic_AvgCongr
import Definitions.Def_LIDT_MIPStarRE_LDT_Test_StrategyCore
import Definitions.Def_QPBT_QPBT_Algebra_Subspaces
import Mathlib
namespace MIPStarRE.QPBT
end MIPStarRE.QPBT
/-!
# Reduced row echelon form and the canonical complement
For matrices with independent rows, reduced row echelon form consists of ordered
pivot columns, an identity matrix in those columns, and zeros before each pivot.
This module compares its nonpivot indices with the intrinsic prefix-rank
definition of `canonicalComplement`.
Independent input rows have such a matrix with the same row span and an
invertible change of row basis. The pivot index set depends only on that span.
An explicit row combination gives the complementary-subspace decomposition.
The canonical complement has the asserted cardinality and independence, and
for register subspaces it consists of the remaining standard basis vectors.
The arbitrary-field and zero-dimensional cases are extensions of the paper's
ambient convention of a finite field and positive ambient dimension. The results
include an executable decomposition once an RREF matrix is supplied, but do not
provide an executable elimination algorithm or a complexity theorem for finding it.
## References
* `references/qpbt-paper/04_preliminaries.tex:219-222`, ambient convention.
* `references/qpbt-paper/04_preliminaries.tex:303-373`,
Definition `def:canonical-complement` and Lemma `lem:canonical-complement`.
* `audits/2026-09-21_issue-676-canonical-complement-alignment.md`, issue
Dengnifer/MIPStarRE-QPBT-bak#676.
-/
@[expose] public section
open scoped BigOperators
namespace MIPStarRE.QPBT
variable {K : Type*} [Field K] {m n : ℕ}
/-- Conventional reduced row echelon form for a matrix with no zero rows.
The order embedding lists the leading columns from left to right. This is
Lean-only linear algebra supporting paper `def:canonical-complement`; no rank
formula or complement identity is part of the predicate. -/
structure IsReducedRowEchelon (B : Matrix (Fin m) (Fin n) K)
(pivot : Fin m ↪o Fin n) : Prop where
pivot_entry : ∀ i j, B i (pivot j) = if i = j then 1 else 0
zero_before : ∀ i j, j < pivot i → B i j = 0
/-- The rank of the first `k` columns is the number of pivots in those columns.
Rows whose pivots lie beyond the prefix restrict to zero, and the remaining
rows are independent on their pivot columns. -/
lemma IsReducedRowEchelon.prefixRank_eq_card
{B : Matrix (Fin m) (Fin n) K} {pivot : Fin m ↪o Fin n}
(hB : _root_.MIPStarRE.QPBT.IsReducedRowEchelon B pivot) {k : ℕ} (hk : k ≤ n) :
_root_.MIPStarRE.QPBT.prefixRank (Submodule.span K (Set.range B.row)) k hk =
(Finset.univ.filter fun i => (pivot i).val < k).card := by
classical
let s := Finset.univ.filter fun i => (pivot i).val < k
let b : s → Fin k → K := fun i => _root_.MIPStarRE.QPBT.prefixMap k n hk (B.row i.val)
have hb : LinearIndependent K b := by
apply Fintype.linearIndependent_iff.mpr
intro c hc i
have hi := congrFun hc
⟨(pivot i.val).val, (Finset.mem_filter.mp i.property).2⟩
simp only [Finset.sum_apply, Pi.smul_apply, smul_eq_mul] at hi
change (∑ j : s, c j * B j.val (pivot i.val)) = 0 at hi
simpa [hB.pivot_entry, ← Subtype.ext_iff] using hi
have hspan :
Submodule.span K (Set.range (fun i => _root_.MIPStarRE.QPBT.prefixMap k n hk (B.row i))) =
Submodule.span K (Set.range b) := by
apply le_antisymm
· apply Submodule.span_le.mpr
rintro _ ⟨i, rfl⟩
by_cases hi : (pivot i).val < k
· exact Submodule.subset_span ⟨⟨i, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hi⟩⟩,
rfl⟩
· have hz : _root_.MIPStarRE.QPBT.prefixMap k n hk (B.row i) = 0 := by
funext j
apply hB.zero_before
change j.val < (pivot i).val
exact lt_of_lt_of_le j.isLt (Nat.le_of_not_lt hi)
change _root_.MIPStarRE.QPBT.prefixMap k n hk (B.row i) ∈ _
rw [hz]
exact Submodule.zero_mem _
· apply Submodule.span_mono
rintro _ ⟨i, rfl⟩
exact ⟨i.val, rfl⟩
rw [_root_.MIPStarRE.QPBT.prefixRank, Submodule.map_span, ← Set.range_comp]
change Module.finrank K
(Submodule.span K (Set.range (fun i => _root_.MIPStarRE.QPBT.prefixMap k n hk (B.row i)))) = s.card
rw [hspan, finrank_span_eq_card hb]
exact Fintype.card_coe s
/-- The intrinsic canonical complement of the row span of an RREF matrix is
exactly its nonpivot index set. This identifies the index sets underlying paper
`def:canonical-complement`, independently of an elimination algorithm. -/
theorem IsReducedRowEchelon.canonicalComplement_eq_nonpivot_indices
{B : Matrix (Fin m) (Fin n) K} {pivot : Fin m ↪o Fin n}
(hB : _root_.MIPStarRE.QPBT.IsReducedRowEchelon B pivot) :
_root_.MIPStarRE.QPBT.canonicalComplement (Submodule.span K (Set.range B.row)) =
(Finset.univ.image pivot)ᶜ := by
classical
ext j
simp only [_root_.MIPStarRE.QPBT.canonicalComplement, Finset.mem_filter, Finset.mem_univ, true_and,
hB.prefixRank_eq_card, Finset.mem_compl, Finset.mem_image]
constructor
· intro hcard hpivot
obtain ⟨i, hi⟩ := hpivot
have hsub : (Finset.univ.filter fun a => (pivot a).val < j.val) ⊆
(Finset.univ.filter fun a => (pivot a).val < j.val + 1) := by
intro a ha
simp only [Finset.mem_filter, Finset.mem_univ, true_and] at ha ⊢
omega
have heq := Finset.eq_of_subset_of_card_le hsub hcard.le
have hi' : i ∈ Finset.univ.filter fun a => (pivot a).val < j.val + 1 := by
simp [hi]
rw [← heq] at hi'
simp [hi] at hi'
· intro hpivot
congr 1
ext i
simp only [Finset.mem_filter, Finset.mem_univ, true_and]
have hne : (pivot i).val ≠ j.val := by
intro h
exact hpivot ⟨i, Fin.ext h⟩
omega
end MIPStarRE.QPBT
Source