Proofs: Determinant by Gaussian elimination
These are the human proofs of Determinant by Gaussian elimination, at full length.
Elimination returns the determinant full
This proof shows: correctness, termination.
Let be the input, an matrix over a field , and let be the working matrix. Indices start at , as in the pseudocode. For , let be the submatrix of the working matrix in rows and columns ; is the matrix, with determinant .
Claim. DET-ELIM stops and returns .
Termination. Line L2 runs over values, and the loops of lines L3, L7 and L9 have at most steps each. Line L4 may stop the algorithm earlier.
Lemma. Let be a square matrix of size whose first column is , and let be without its first row and first column. Then .
Proof. In the Leibniz formula , the factor for column is unless . The permutations with are the permutations of , with the same sign and the same remaining factors, so the sum is .
Invariant. At the start of the iteration of line L2 with index :
Initialization. For , and is the whole working matrix, which equals .
Maintenance. Assume at the start of iteration .
If line L3 finds no index with , then the first column of is zero, so (the determinant is linear in that column). By , , and line L4 returns , which is correct.
Otherwise line L5 swaps rows and of when . Both rows meet , so this swaps two rows of , which negates . Line L5 also negates , so the product does not change. Now .
For each , lines L8 and L9 subtract times row from row , in the columns . Consider the matrix that this step would give if it also updated column . Adding a multiple of one row to another row does not change a determinant, so . In the first column is , because . By the lemma, , where is without its first row and column. The matrix is exactly the new , since line L9 updates all columns of the rows and line L9 never needs column again. Line L6 multiplied by . So after the iteration,
which is for .
End. If line L4 never returns, the loop ends with . Then is empty with determinant , so gives , and line L10 returns .
Remark. The proof also shows that is, up to the sign for swaps, the product of the pivots, and that each pivot after step is the quotient of two leading principal minors of the row-permuted input. This is the fact that bounds the sizes of the numbers over .