Staged Gauss–Jordan elimination and matrix rank #
This file computes the rank of a matrix over a field by Gauss–Jordan elimination without row
swaps, one stage per column. Stage j looks for the first row that is zero on the columns before
j and nonzero at j (Matrix.GaussJordan.pivotRow). If there is one, it subtracts multiples of
that row from every other row to clear column j (Matrix.GaussJordan.stage); otherwise it leaves
the matrix unchanged. Rows are never swapped, so every stage is a fixed function of the matrix.
Each stage multiplies on the left by an invertible matrix, so it preserves the rank. After all c
stages, every nonzero row owns at least one column where it is nonzero and every other row is zero
(Matrix.GaussJordan.exists_pivot_of_reduce_ne_zero); distinct rows own distinct columns, since an
owned column has only one nonzero entry. The rank is therefore the number of nonzero rows
(Matrix.GaussJordan.rank_eq_card_reduce_ne_zero). A row may own several columns: !![1, 1] is
already reduced and has rank 1. The rows of the output are not sorted into row echelon form, so
Matrix.IsPivotedBy does not apply directly.
Over ZMod 2 a stage needs no division: the pivot entry is 1, and the stage adds the pivot row
to every other row with a 1 in column j (Matrix.GaussJordan.stage_apply_zmod_two). Each entry
of a stage is then an XOR of ANDs of entries and pivot indicators, and the pivot is a prefix
condition on column j (Matrix.GaussJordan.pivotRow_eq_some_iff). A Boolean circuit with
unbounded fan-in AND and OR gates can evaluate one stage in constant depth; the full reduction
chains c stages, so it has polynomial size and depth O(c).
Main definitions #
Matrix.GaussJordan.IsFreeBefore A k i: rowiis zero on the columns beforek.Matrix.GaussJordan.eliminate A j p: clear columnjwith pivot rowp.Matrix.GaussJordan.pivotRow A j: the first row that is zero before columnjand nonzero atj, if any (the minimum ofMatrix.GaussJordan.pivotCandidates A j).Matrix.GaussJordan.stage A j: one elimination stage at columnj.Matrix.GaussJordan.reduce A: the stages for columns0, …, c - 1, in order.
Main results #
Matrix.GaussJordan.rank_stage,Matrix.GaussJordan.rank_reduce: the stages preserve rank.Matrix.GaussJordan.exists_pivot_of_reduce_ne_zero: every nonzero row ofreduce Aowns a column where every other row is zero.Matrix.GaussJordan.rank_eq_card_reduce_ne_zero: the rank ofAis the number of nonzero rows ofreduce A.Matrix.GaussJordan.pivotRow_eq_some_iff,Matrix.GaussJordan.pivotRow_eq_none_iff: the pivot row as a prefix condition.Matrix.GaussJordan.stage_apply_zmod_two: the division-free form of a stage overZMod 2.
References #
Gauss–Jordan elimination is standard. Computing a GF(2) rank this way is the constructivity step of the rank property in Razborov and Rudich, §3.2.
Elimination with a fixed pivot row #
Elimination with a pivot row that is zero in column l leaves column l unchanged.
Elimination preserves the rank. It is left multiplication by 1 - D, where D is supported
on column p off row p; then D * D = 0, so 1 + D inverts 1 - D.
The stages #
The pivot row for column j: the first row that is zero on the columns before j and nonzero
at j, or none if there is no such row.
One stage of Gauss–Jordan elimination at column j: if column j has a pivot row, clear
column j in every other row; otherwise leave the matrix unchanged.
The stages for the columns 0, …, k - 1, in order; indices from c on are skipped.
Gauss–Jordan elimination: the stages for all columns, in order.
The pivot row is the first candidate: it is free before j and nonzero at j, and every
earlier row that is free before j is zero at j.
Column j has no pivot row exactly when every row that is free before j is zero at j.
Rank #
Gauss–Jordan elimination preserves the rank.
Every nonzero row of reduce A owns a column: it is nonzero there and every other row is zero
there. Distinct rows own distinct columns, but one row may own several.
Rank by Gauss–Jordan elimination: the rank of A is the number of nonzero rows of
reduce A. Each nonzero row owns a column where every other row is zero
(exists_pivot_of_reduce_ne_zero), and these give a diagonal submatrix of full size.
Over ZMod 2 a stage needs no division. The pivot entry is 1, and the stage adds the pivot
row p to every other row i with A i j = 1. Each entry is a sum of products of entries and
pivot indicators, which a Boolean circuit evaluates with XOR and AND gates.