Expand description
Kernel-certified linear algebra: turn an exact solve into a KERNEL-CHECKED PROOF TERM.
crate::linalg solves A·x = b exactly over ℚ and re-checks the residual. This module goes
one level deeper: it emits, for each row, an honest kernel proof term of type Eq Int lhsᵢ rhsᵢ,
where the row identity Σⱼ Aᵢⱼ·xⱼ = bᵢ has been cleared of denominators to an INTEGER identity
bdᵢ · (Σⱼ Anᵢⱼ · Xnⱼ) = Da_i · Dx · bnᵢand proven by the ring-axiom oracle crate::arith::prove_int_eq, then RE-CHECKED by the
kernel’s own infer_type. This is the same trust path the kernel’s Gödel/Chaitin theorems ride:
the oracle is untrusted search, the kernel is the judge. A false identity is unprovable (the
oracle returns None) and a forged proof fails the type-check — fail-closed. The current arith
oracle is i64-wide, so systems whose cleared integers exceed i64 return None (an honest limit,
not a wrong answer; a BigInt oracle would lift it).
Structs§
- System
Cert - The complete certificate that a linear system
A·x = bhas a UNIQUE exact solution: the exactx, a kernel proof ofAᵢ·x = bᵢfor every row, and a kernel proof thatdet A ≠ 0(so the solution is unique, not merely one of many). Every term is re-checked by the kernel. This is the full “prove, not just run” object for a linear system.Noneiff singular or past the i64 width.
Functions§
- certify_
system - Solve and produce the complete unique-solution certificate.
- prove_
dot - Prove the dot-product identity
Σₖ psₖ·qsₖ = ras ONE kernel-checked term (typeEq Int lhs rhs). Clears denominators tord·Σₖ (Pnₖ·Qnₖ) = Dp·Dq·rn— structure preserved — proves it with the untrusted oracle, then RE-CHECKS with the kernel.Noneif false or past i64. This one identity underlies every certificate below: a solve is a row·x = b, a factorization entry is Lrow·Ucol = (PA)ᵢⱼ, an inverse entry is Arow·(A⁻¹col) = Iᵢⱼ. - prove_
inverse - Invert
Aand PROVE it in the kernel: every entry ofA·A⁻¹ = Iis a dot-product proofAᵢ·(A⁻¹)ⱼ = Iᵢⱼ(the off-diagonal= 0identities are proven too).Noneiff singular / past i64. - prove_
lu - Factor
Aand PROVE the factorization in the kernel: every entry ofP·A = L·Uis a dot-product proofLᵢ·Uⱼ = (PA)ᵢⱼ. Returns the exact factorization and an n×n grid of kernel-checked terms. - prove_
nonzero - Prove
r ≠ 0in the kernel by EXHIBITING its inverse: a kernel-checked proof ofr·(1/r) = 1. A value with a multiplicative inverse is nonzero, so this certifies nonsingularity when applied to a determinant.Noneiffr == 0— correctly unprovable, since0has no inverse. - prove_
solution - Prove
A·x = bfor a GIVEN candidatex, one kernel-checked proof term per row (each is the row dot-product identityAᵢ·x = bᵢ).Noneif any row is false (fail-closed) or past i64. - prove_
solve - Solve
A·x = bexactly and hand back the exactxtogether with a kernel-checked proof that it solves the system (one proof term per row).Noneiff singular or beyond the i64 oracle width. - ring_
context - A kernel context of its own carrying the ring/field/order axioms the oracle proves against: a copy-on-write clone of the standard library’s one registration.