Documentation

CslibFrontier.Computability.PolyTime.CNF.SparseCNFLeafCounter

Native sparse k-CNF leaf model counter and occurring-support normalization #

Implements the deterministic sparse k-CNF model-counting algorithm of Section 6.3 (equation (6.4), printed p. 43) of OpenAI, The Exponential Time Hypothesis is False on native multi-tape Turing machines, parameterized over a sparse 𝔽₂ polynomial-system counter:

Main definitions #

Main results #

References #

1. Guards, Compiled-System Invariant, and Core Definitions #

Boolean check for whether ψ contains an empty clause [].

Guard characterizing inputs (N, B, ψ) entering the Section 6.3 parity-test fast path.

Sparsity, canonicality, degree, and variable-range invariant for compiled 𝔽₂ systems.

Evaluates polyCounter (N, compileParitySystemBounded k ψ rows) when rows.length ≀ 6 * N.

Deterministic Section 6.3 fast path: initial Tanner rows via initialTestsRows, 3 * N rounds of greedyParityRows, and one final compiledRowCounter call capped at 2 ^ N.

def Cslib.Complexity.SparseCNFLeafCounter.sparseCNFDeclaredCounter {P : Type u_1} (NOf BOf : P β†’ β„•) (k Nβ‚€ : β„•) (polyCounter : β„• Γ— List (List (List β„•)) β†’ β„•) (x : P Γ— Logic.PL.CNF β„•) :

Section 6.3 declared-range sparse k-CNF model counter. Returns 0 if invalid, 2 ^ N on [], 0 if [] ∈ ψ, countCNFExhaustive (N, ψ) if N < Nβ‚€, sparseCNFFastPath k N B polyCounter ψ if ψ.length ≀ B * N, and 0 otherwise.

def Cslib.Complexity.SparseCNFLeafCounter.sparseCNFLeafCounter {P : Type u_1} (NOf BOf : P β†’ β„•) (k Nβ‚€ : β„•) (polyCounter : β„• Γ— List (List (List β„•)) β†’ β„•) (x : P Γ— Logic.PL.CNF β„•) :

Normalized Section 6.3 sparse k-CNF leaf provider. Returns ψ.modelCount on valid sparse or below-threshold inputs, as well as empty formulas and formulas containing an empty clause. The supplied polyCounter must be exact on the compiled sparse systems required by sparseCNFLeafCounter_eq_modelCount.

theorem Cslib.Complexity.SparseCNFLeafCounter.isCompiledSparseSystem_compileParitySystemBounded {k N maxEqs W : β„•} {ψ : Logic.PL.CNF β„•} (hw : βˆ€ c ∈ ψ, List.length c ≀ k) (hsub : ψ.vars.toFinset βŠ† Finset.range N) {rows : List (List Bool)} (hlen : rows.length ≀ maxEqs) (hwt : βˆ€ r ∈ rows, List.count true r ≀ W) :
IsCompiledSparseSystem k N maxEqs (W * 2 ^ k) (compileParitySystemBounded k ψ rows)

Every compileParitySystemBounded k ψ rows on a width-≀ k formula with variables < N, rows.length ≀ maxEqs, and row Hamming weights ≀ W satisfies IsCompiledSparseSystem.

Semantic bridge to equationToFinset and CNF.parityRowSystem: on a width-≀ k formula ψ with variables < N (1 ≀ N), commonZeroCount on compileParitySystemBounded k ψ rows equals both numPassing and commonZeroCount on (relabel ... ψ).parityRowSystem.

theorem Cslib.Complexity.SparseCNFLeafCounter.sparseCNFDeclaredCounter_le_two_pow {P : Type u_1} (NOf BOf : P β†’ β„•) (k Nβ‚€ : β„•) (polyCounter : β„• Γ— List (List (List β„•)) β†’ β„•) (x : P Γ— Logic.PL.CNF β„•) :
sparseCNFDeclaredCounter NOf BOf k Nβ‚€ polyCounter x ≀ 2 ^ NOf x.1

Unconditional upper bound: sparseCNFDeclaredCounter never exceeds 2 ^ NOf x.1.

theorem Cslib.Complexity.SparseCNFLeafCounter.sparseCNFDeclaredCounter_eq_modelCountOn {P : Type u_1} {NOf BOf : P β†’ β„•} {k Nβ‚€ : β„•} {polyCounter : β„• Γ— List (List (List β„•)) β†’ β„•} {p : P} {ψ : Logic.PL.CNF β„•} (hw : βˆ€ c ∈ ψ, List.length c ≀ k) (hsub : ψ.vars.toFinset βŠ† Finset.range (NOf p)) (hdom : List.length ψ ≀ BOf p * NOf p ∨ ψ = [] ∨ [] ∈ ψ ∨ NOf p < Nβ‚€) (hpoly : Nβ‚€ ≀ NOf p β†’ βˆ€ (sys : List (List (List β„•))), IsCompiledSparseSystem k (NOf p) (6 * NOf p) (BitString.initialRowWeightBound (BOf p) (List.length ψ) * 2 ^ k) sys β†’ polyCounter (NOf p, sys) = BitString.commonZeroCount Finset.univ fun (i : Fin sys.length) => GenericRAM.ExhaustiveCountFallback.equationToFinset (NOf p) sys[i]) :
sparseCNFDeclaredCounter NOf BOf k Nβ‚€ polyCounter (p, ψ) = ψ.modelCountOn (Finset.range (NOf p))

Exactness of sparseCNFDeclaredCounter (Β§6.3, Lemmas 6.1–6.2).

theorem Cslib.Complexity.SparseCNFLeafCounter.sparseCNFDeclaredCounter_exhaustive_eq_modelCountOn {P : Type u_1} {NOf BOf : P β†’ β„•} {k Nβ‚€ : β„•} {p : P} {ψ : Logic.PL.CNF β„•} (hw : βˆ€ c ∈ ψ, List.length c ≀ k) (hsub : ψ.vars.toFinset βŠ† Finset.range (NOf p)) (hdom : List.length ψ ≀ BOf p * NOf p ∨ ψ = [] ∨ [] ∈ ψ ∨ NOf p < Nβ‚€) :

Instantiation of sparseCNFDeclaredCounter with countSystemExhaustive computes ψ.modelCountOn (Finset.range (NOf p)) unconditionally on every valid sparse formula.

3. Normalized Leaf Provider (sparseCNFLeafCounter) #

theorem Cslib.Complexity.SparseCNFLeafCounter.sparseCNFLeafCounter_le_two_pow_numVars {P : Type u_1} (NOf BOf : P β†’ β„•) (k Nβ‚€ : β„•) (polyCounter : β„• Γ— List (List (List β„•)) β†’ β„•) (x : P Γ— Logic.PL.CNF β„•) :
sparseCNFLeafCounter NOf BOf k Nβ‚€ polyCounter x ≀ 2 ^ x.2.numVars

Unconditional leaf-accumulator bound: sparseCNFLeafCounter never exceeds 2 ^ ψ.numVars on any input (p, ψ), regardless of polyCounter.

theorem Cslib.Complexity.SparseCNFLeafCounter.sparseCNFLeafCounter_eq_modelCount {P : Type u_1} {NOf BOf : P β†’ β„•} {k Nβ‚€ : β„•} {polyCounter : β„• Γ— List (List (List β„•)) β†’ β„•} {p : P} {ψ : Logic.PL.CNF β„•} (hw : βˆ€ c ∈ ψ, List.length c ≀ k) (hsub : ψ.vars.toFinset βŠ† Finset.range (NOf p)) (hdom : List.length ψ ≀ BOf p * NOf p ∨ ψ = [] ∨ [] ∈ ψ ∨ NOf p < Nβ‚€) (hpoly : Nβ‚€ ≀ NOf p β†’ βˆ€ (sys : List (List (List β„•))), IsCompiledSparseSystem k (NOf p) (6 * NOf p) (BitString.initialRowWeightBound (BOf p) (List.length ψ) * 2 ^ k) sys β†’ polyCounter (NOf p, sys) = BitString.commonZeroCount Finset.univ fun (i : Fin sys.length) => GenericRAM.ExhaustiveCountFallback.equationToFinset (NOf p) sys[i]) :
sparseCNFLeafCounter NOf BOf k Nβ‚€ polyCounter (p, ψ) = ψ.modelCount

Exactness of sparseCNFLeafCounter: returns ψ.modelCount on every valid width-≀ k sparse leaf ψ with variables in Finset.range (NOf p).

theorem Cslib.Complexity.SparseCNFLeafCounter.sparseCNFLeafCounter_exhaustive_eq_modelCount {P : Type u_1} {NOf BOf : P β†’ β„•} {k Nβ‚€ : β„•} {p : P} {ψ : Logic.PL.CNF β„•} (hw : βˆ€ c ∈ ψ, List.length c ≀ k) (hsub : ψ.vars.toFinset βŠ† Finset.range (NOf p)) (hdom : List.length ψ ≀ BOf p * NOf p ∨ ψ = [] ∨ [] ∈ ψ ∨ NOf p < Nβ‚€) :

Instantiation of sparseCNFLeafCounter with countSystemExhaustive computes ψ.modelCount.

4. Native Machine Certificates and Split Time / Polynomial-Space Bounds #

def Cslib.Complexity.SparseCNFLeafCounter.sparseCNFTimeBound {P : Type} (encP : P β†ͺ List Bool) (NOf BOf : P β†’ β„•) (k Nβ‚€ : β„•) (poly qInit : β„• β†’ β„•) (R : P Γ— Logic.PL.CNF β„• β†’ β„•) (x : P Γ— Logic.PL.CNF β„•) :

Split Section 6.3 runtime upper bound: poly L outside entersSparseFastPath, and initial Tanner search plus (3 * N + 1) * ((2 * m) ^ P + 1) candidate system evaluations inside.

Hypothesis bounding cPoly.time (NOf x.1, sys) ≀ R x on every compiled sparse system of at most 6 * NOf x.1 equations and polynomial encoded length produced on the Section 6.3 fast path.

Explicit certificate-level workspace and split-time bounds for sparseCNFDeclaredCertificate.

Right-Shift Normalization Certificate #

Native resource certificate for normalizeDeclaredLeaf NOf h, composing cLeaf with ComputableInPolyTime.binary_shiftRight on NOf x.1 - x.2.distinctVars.length.

Certificate-level workspace and split-time bounds for sparseCNFLeafCertificate.