Verified GF(2) row reduction #
LeanQEC lists "row reduction itself is not formalized" as its most concrete remaining engineering gap: "A verified row-reduction routine would close this remaining preprocessor step." This module supplies that step, turning the row simplification of a parity-check matrix into a machine-checked algorithm, so that the preprocessing no longer requires trusting an external script.
Invariants #
The state of the reduction is a list of pivot rows PivRow n = Vec n × Fin n,
a row vector together with the column at which it pivots. IsReduced D requires:
- (R1) every row takes the value 1 at its own pivot column
- (R2) every row takes the value 0 at the pivot column of every other row.
(R2) is symmetric: it does not presuppose an order on the rows, so the result is independent of the elimination order. This is what makes all the correctness proofs below go through.
Main results #
reduceAgainst_apply_piv: the reduced vector is 0 at every pivot column.add_reduceAgainst_mem:v + reduceAgainst D vlies in the row space ofD.spanL_rowReduce: the row space is unchanged, so the code is not modified.isReduced_rowReduce: the output satisfiesIsReduced.
A pivot row: a row vector together with the column at which it pivots, that is, its leading nonzero entry.
Equations
- QECCertificates.PivRow n = (QECCertificates.Vec n × Fin n)
Instances For
The row part of a list of pivot rows.
Equations
- QECCertificates.rowList D = List.map (fun (x : QECCertificates.PivRow n) => x.1) D
Instances For
The mutual-reduction invariant: (R1) every row is 1 at its own pivot column, and (R2) every row is 0 at the pivot column of every other row.
Equations
Instances For
Reduction: clearing a row at every pivot column #
Eliminate v at its pivot column using each row of D. Over GF(2) the coefficient is exactly
the component of v at that column.
Equations
- QECCertificates.reduceAgainst D v = List.foldl (fun (w : QECCertificates.Vec n) (ri : QECCertificates.PivRow n) => w + w ri.2 • ri.1) v D
Instances For
Where the reduced part lands: v + reduceAgainst D v is a linear combination of the row
vectors of D.
Choosing a pivot and inserting #
Insertion preserves the mutual-reduction invariant: it requires w to be 0 at every pivot
column of D and 1 at the new pivot column.
The main loop #
Insert the rows of rest one by one, starting from the accumulated state D.
Equations
- QECCertificates.rowReduceFrom D [] = D
- QECCertificates.rowReduceFrom D (v :: rest) = QECCertificates.rowReduceFrom (QECCertificates.step D v) rest
Instances For
Verified row reduction: reduce a list of rows to a mutually reduced set of pivot rows.