Expand description
Linear algebra over GF(p) — the mod-p generalization of the GF(2) parity cut (crate::xorsat).
A system of congruences Σ aᵢ·xᵢ ≡ c (mod p) is decided in polynomial time by Gaussian
elimination with modular inverses, and it is certified: an inconsistent system yields a
re-checkable linear-dependency refutation — a combination of the original equations whose left side
cancels to 0 while the right side is some nonzero residue, i.e. 0 ≡ r ≢ 0 (mod p). A consistent
system yields a satisfying assignment over GF(p).
This matters because the parity cut only speaks GF(2). The mod-p counting principles (Count_p:
“partition a set whose size is not a multiple of p into p-blocks”) are resolution-hard, and a
polynomial-calculus proof over the wrong characteristic cannot refute them either — but Gaussian
elimination over the right GF(p) decides them instantly. A genuinely new invariant, the parity
crush carried to every prime.
Structs§
- Modp
Equation - A congruence
Σ (a·x) ≡ rhs (mod p). Coefficients andrhsare reduced modp.pmust be prime (so every nonzero element is invertible, via Fermat). - Modp
Recovery - A mod-
mlinear system recovered from an opaque Boolean CNF: the one-hot groups (each aℤ/mvariable, with the boolean var ids listed in value order) plus the congruences fitted to the forbidden-combination clauses. The recovered system is equisatisfiable to the source CNF, so the modular verdict carries back — over the prime fieldsolvewhenmodulusis prime, over the composite ringcrate::modm::solveotherwise. Seerecover_from_cnf. - Solution
SpaceP - The complete solution space of a
GF(p)linear systemA x = b, in symmetry-broken form: one particular solutionx₀plus a basis of the kernel (null space). Every solution isx₀ +aGF(p)combination of the kernel basis, so allp^{n−rank}solutions are generated from this compressed witness. The kernel is the translation symmetry of the solution coset — theGF(p)analogue ofcrate::gf2::SolutionSpace, and the substrate of the affine SAT-side break: a variable the kernel never moves is forced to a single value.
Enums§
- Modp
Outcome - The outcome of solving a mod-
plinear system.
Functions§
- cycle_
system - The canonical scalable mod-
pobstruction: a cycle of differencesxᵢ − x_{i+1} ≡ 1 (mod p)around ann-cycle. Summing allnequations telescopes the left side to0and the right ton, so the system is inconsistent exactly whennis not a multiple ofp— the mod-pcounting fact. For evennwithp > 2 ∤ nit is satisfiable overGF(2)yet refuted overGF(p): a family the parity cut cannot see. (x − yis writtenx + (p−1)y.) - gl_
order_ p |GL(n,p)|overGF(p)via the orbit–stabilizer (ordered-basis) factorizationΠ_{i=0}^{n-1}(pⁿ − pⁱ).GL(n,p)acts simply transitively on ordered bases ofGF(p)ⁿ, so each factorpⁿ − pⁱcounts the vectors outside the i-dimensional span built so far — the same symmetry break as overGF(2), now across the field. Thep = 2case isgf2::gl_order.- invertibility_
density_ p - The invertibility density over
GF(p):Π_{j=1}^n (1 − p⁻ʲ) = |GL(n,p)| / p^{n²}. As the field grows the density → 1 (fewer linear collisions);p = 2is the densest-collision regime, the smallest constantφ(½) ≈ 0.28879. - is_
invertible_ modp - Is an
n×nmatrix overGF(p)invertible? Gaussian elimination with modular pivots: full rankn.pmust be prime. - is_
prime - is_
refutation - Re-check a refutation: the chosen combination of equations has every variable coefficient
≡ 0and a nonzero right-hand side modp— a solver-free certificate of inconsistency. - recover_
from_ cnf - Lift an opaque Boolean CNF onto
ℤ/m. Recognize the canonical one-hot encoding of a mod-mlinear system — each variable a group ofmbits with an at-least-one clause and the full pairwise at-most-one, plus all-negative “forbidden combination” clauses pinning the congruences — and recover the system overℤ/m. The modulusmis the group size; it may be prime (a field) or composite (a ring), and [fit_congruence] handles both. ReturnsNone(declining, never guessing) unless every clause fits the pattern and every forbidden set is exactly the complement of a single congruence: then the recovered system is equisatisfiable to the CNF, so the modular solver’s verdict transfers (UNSAT certificate carries; a SAT model is re-checked against the clauses by the caller). Them = 2case is the parity cut; this is that cut generalized to every modulus — the obstruction GF(2) is blind to, decided in polynomial time where resolution (CDCL, Z3, Kissat) needs2^Ω(n). - satisfies
- Re-check a satisfying assignment: every congruence holds mod
p. - solve
- Decide a mod-
plinear system by Gaussian elimination overGF(p). Returns a satisfying assignment, or an inconsistency-witnessing combination of the original equations.pmust be prime. - solve_
space - Solve a
GF(p)system for its entire solution space via Gaussian elimination to reduced row echelon form, returning the symmetry-brokenSolutionSpaceP(particular solution + kernel basis), orNoneiff the system is inconsistent. Generalizessolve, which returns just one witness, to the full coset — theGF(p)analogue ofcrate::gf2::solve_gf2.pmust be prime.