Documentation

CslibFrontier.Foundations.LinearAlgebra.LinearSolve

Linear system solving and prescribed-entry kernel vectors by elimination #

Building on the spanning kernel family Cslib.LinearAlgebra.kernelBasis from CslibFrontier.Foundations.LinearAlgebra.KernelVector, this module defines two total elimination functions over any field with decidable equality:

Related and distinct: Matrix.solveVec in CslibFrontier.Foundations.LinearAlgebra.Matrix.Bareiss is noncomputable and takes explicit pivot row and column lists as arguments (with its only certified algorithm, ratSolve, specialized to ℚ). Here no pivot selections are supplied, and every operation unfolds to a fixed arithmetic expression over the field matching the circuit bounds in CslibFrontier.Computability.Circuit.LinearSolve.

Main definitions #

Main results #

def Cslib.LinearAlgebra.kernelPivotAt {F : Type u_1} [Field F] [DecidableEq F] {n r : ℕ} (A : Matrix (Fin r) (Fin n) F) (j : Fin n) :
Fin n → F

The first member of kernelBasis A whose entry j is nonzero, or zero if there is none.

def Cslib.LinearAlgebra.kernelVecAt {F : Type u_1} [Field F] [DecidableEq F] {n r : ℕ} (A : Matrix (Fin r) (Fin n) F) (j : Fin n) :
Fin n → F

A kernel vector with a prescribed entry equal to one. The first member of kernelBasis A whose entry j is nonzero, scaled so that this entry is one; zero if every kernel vector has entry j equal to zero.

theorem Cslib.LinearAlgebra.mulVec_kernelVecAt {F : Type u_1} [Field F] [DecidableEq F] {n r : ℕ} (A : Matrix (Fin r) (Fin n) F) (j : Fin n) :
A.mulVec (kernelVecAt A j) = 0

kernelVecAt A j lies in the kernel of A.

theorem Cslib.LinearAlgebra.kernelVecAt_apply_self_eq_one_iff {F : Type u_1} [Field F] [DecidableEq F] {n r : ℕ} (A : Matrix (Fin r) (Fin n) F) (j : Fin n) :
kernelVecAt A j j = 1 ↔ ∃ (v : Fin n → F), A.mulVec v = 0 ∧ v j ≠ 0

Entry j of kernelVecAt A j is one exactly when some kernel vector of A has a nonzero entry j.

theorem Cslib.LinearAlgebra.kernelVecAt_eq_zero {F : Type u_1} [Field F] [DecidableEq F] {n r : ℕ} (A : Matrix (Fin r) (Fin n) F) (j : Fin n) (h : ∀ (v : Fin n → F), A.mulVec v = 0 → v j = 0) :

When every kernel vector of A has entry j equal to zero, kernelVecAt A j is zero.

def Cslib.LinearAlgebra.vecMulSolveMatrix {F : Type u_1} {n r : ℕ} (M : Matrix (Fin r) (Fin n) F) (b : Fin n → F) :
Matrix (Fin n) (Fin (r + 1)) F

The matrix whose kernel vectors (x₀, w) are the solutions of x₀ • b + w ᵥ* M = 0: its column 0 is b and its column k + 1 is row k of M.

def Cslib.LinearAlgebra.vecMulSolve {F : Type u_1} [Field F] [DecidableEq F] {n r : ℕ} (M : Matrix (Fin r) (Fin n) F) (b : Fin n → F) :
Fin r → F

Solving w ᵥ* M = b by elimination. The output is a solution whenever there is one (vecMul_vecMulSolve) and 0 otherwise (vecMulSolve_eq_zero).

theorem Cslib.LinearAlgebra.vecMul_vecMulSolve {F : Type u_1} [Field F] [DecidableEq F] {n r : ℕ} (M : Matrix (Fin r) (Fin n) F) (b : Fin n → F) (h : ∃ (w : Fin r → F), Matrix.vecMul w M = b) :

vecMulSolve M b solves w ᵥ* M = b whenever a solution exists.

theorem Cslib.LinearAlgebra.vecMul_vecMulSolve_iff {F : Type u_1} [Field F] [DecidableEq F] {n r : ℕ} (M : Matrix (Fin r) (Fin n) F) (b : Fin n → F) :
Matrix.vecMul (vecMulSolve M b) M = b ↔ ∃ (w : Fin r → F), Matrix.vecMul w M = b

vecMulSolve M b solves w ᵥ* M = b if and only if a solution exists.

theorem Cslib.LinearAlgebra.vecMulSolve_eq_zero {F : Type u_1} [Field F] [DecidableEq F] {n r : ℕ} (M : Matrix (Fin r) (Fin n) F) (b : Fin n → F) (h : ¬∃ (w : Fin r → F), Matrix.vecMul w M = b) :

When w ᵥ* M = b has no solution, vecMulSolve M b is zero.