Algorithmic counting sparsification on native machines #
Implements the depth-first counting-sparsification search
(Cslib.Complexity.CountingSparsify.search) for Lemma 6.3, Proposition 6.4, and Appendix A
[OAI26k] on the native multi-tape Turing machines, parallel to the decision sparsifier
Cslib.Complexity.Sparsify.search
(CslibFrontier/Computability/Complexity/FineGrained/Sparsification.lean). In Lemma 6.3 (Section
6.4,
printed p. 43), "The input count is the sum of the leaf counts", obtained in Appendix A (printed
p. 44) by "repeatedly splitting a formula into two cases. Both children use the same n variables,
and every satisfying assignment of the parent satisfies exactly one child."
Given a formula φ : CNF ℕ with n = φ.numVars occurring variables, the search maintains a state
(n, (stk, acc)) (CountingSparsify.State, with n in unary and acc in binary capped at
2 ^ n):
- Starting from
init k φ = (φ.distinctVars.length, ([root k φ], 0))(whereroot k φiscountingNormalize φifφhas clause width at mostkand[[]]otherwise), each step (CountingSparsify.step) inspects the top formulaψofstk. - If
ψis sparse (isSparse (countingThreshold M) K ψ = true), it popsψ, runs a leaf model counterg : CNF ℕ → ℕonψ, weights the result byleafWeight n ψ (g ψ) = 2 ^ (n - ψ.distinctVars.length) * g ψto account for then - ψ.numVarsdeclared variables ofφnot occurring inψ(CNF.modelCountOn_eq_mul_modelCount), and adds the weighted count intoacccapped at2 ^ n. - If
ψis not sparse (using the heavy-heart branching condition of Appendix A.1, equation (A.1), p. 44, with the unnumbered threshold schedulecountingThreshold M j = M ^ j), it pushes the two disjoint counting childrencountingNext (countingThreshold M) K ψ falseandcountingNext (countingThreshold M) K ψ true(Appendix A.1, equation (A.2), pp. 44–45).
To mirror Sparsify, this module packages the quantitative tree depth (w.length ≤ L_coeff * N)
and fixed-parameter leaf-count (W.card ≤ 2 ^ (N / B + 1)) hypotheses into CountingTreeBound, a
library adaptation of Appendix A.2–A.3 (Lemmas A.2–A.3, pp. 46–47). The module
CslibFrontier.Computability.Complexity.FineGrained.CountingTreeBound supplies this hypothesis from
an explicit integer parameter budget. Under CountingTreeBound, running step M K g for
Sparsify.rounds B φ = 2 ^ (n / B + 2) steps (the round count shared with Sparsify) visits
every leaf of the counting-sparsification tree and returns φ.modelCount
(CountingSparsify.search_eq_modelCount). Given a total leaf routine g
with hg : ComputableInO g encCNF encNat t t and a global bound ht holding for every
ψ : CNF ℕ ((t ψ : ℝ) ≤ c * (2 ^ (δ * ψ.length) * (|encCNF ψ| + 1) ^ e) + c),
CountingSparsify.exists_computableInO_search yields a combined time-and-space certificate
ComputableInO (search M K k B g) encCNF encNat T T with the fixed-parameter library-adaptation
transfer bound T φ ≤ C₀ * (2 ^ ((1 / B + occBound K M * δ) * n) * (|encCNF φ| + 1) ^ E) + C₀.
The independent-space extension CountingSparsify.exists_computableInO_search_polySpace instead
starts from one total certificate ComputableInO g encCNF encNat t s, with separate quantitative
promises for sparse width-≤ k leaf inputs. It preserves this exponential time envelope and gives
polynomial workspace in the full encCNF length. Initialization, every traversal prefix including
the terminal state, the binary clock, retained declared variables, and the final output are charged.
All parameters M, K, k, B, and L_coeff are fixed before the machine is chosen; runtime
parameter uniformity and the native subexponential counting endpoint remain separate obligations.
Main definitions #
Cslib.Complexity.CountingSparsify.State,Cslib.Complexity.CountingSparsify.leafWeight,Cslib.Complexity.CountingSparsify.leafUpdate,Cslib.Complexity.CountingSparsify.step,Cslib.Complexity.CountingSparsify.root,Cslib.Complexity.CountingSparsify.init,Cslib.Complexity.CountingSparsify.search: the counting-sparsification search, which runs forCslib.Complexity.Sparsify.roundsrounds.Cslib.Complexity.CountingSparsify.occBound: the sparse leaf clause-density bound2 * ∑ j ∈ Finset.range K, countingThreshold M j.Cslib.Complexity.CountingSparsify.CountingTreeBound: the fixed-parameter depth and leaf-count hypotheses forcountingRule(a library adaptation of Appendix A.2–A.3).
Main results #
Cslib.Complexity.CountingSparsify.search_eq_modelCount,Cslib.Complexity.CountingSparsify.search_eq_ite_modelCount: the search computesφ.modelCounton formulas of width≤ k(and0otherwise).Cslib.Complexity.CountingSparsify.search_eq_ite_modelCount_of_normalized: correctness only requires the leaf counter to be exact on normalized sparse formulas within the search's support and clause-count bounds.Cslib.Complexity.CountingSparsify.searchDeclaredWith_eq_ite_modelCountOn_of_normalized: the same invariant-restricted correctness contract for declared-variable counting, with either occurring-variable or declared-variable leaf counts. These are semantic extensions; native totality and resource certificates remain separate requirements.Cslib.Complexity.CountingSparsify.acceptCount_search_error_leandCslib.Complexity.CountingSparsify.acceptCount_search_pos_error_le: shared-seed error bounds for exact model counting and for detecting satisfiability by testing the result for positivity.Cslib.Complexity.CountingSparsify.searchDeclaredWith_pos_iff_of_normalized: search positivity is a satisfiability test when the leaf routine only detects satisfiability.Cslib.Complexity.CountingSparsify.exists_computableInO_search: nativeComputableInO ... T Ttime-and-space transfer certificate forCountingSparsify.search.Cslib.Complexity.CountingSparsify.exists_computableInO_search_polySpace: the same time envelope with independent polynomial workspace, from separately promised leaf time and workspace.Cslib.Complexity.CountingSparsify.stepWith,Cslib.Complexity.CountingSparsify.iterate_stepWith_fst,Cslib.Complexity.CountingSparsify.iterate_stepWith_countingThreshold: the step with a captured runtime context, which keeps the context and agrees withstepat the context's base.
References #
- OpenAI, The Exponential Time Hypothesis is False, Section 6.4, Lemma 6.3 and Proposition 6.4 (pp. 43–44) and Appendix A (pp. 44–47).
- [MITHGBD+26], v2, §2.2, Corollary 2.3.
The counting-sparsification search #
The states of the counting-sparsification search: the declared variable count n (in unary),
a stack of formulas, and a binary accumulator capped at 2 ^ n.
Weight a leaf's occurring-variable model count c by 2 ^ (n - ψ.numVars) for the unused
declared variables.
Update the search state when the top of the stack is a sparse leaf with occurring-variable
count c, popping the leaf and adding its weighted count (capped at 2 ^ s.1).
One step of the depth-first search of the counting-sparsification tree, for threshold base M
and width K: a sparse formula on top of the stack is popped and weighted by leafWeight applied
to the leaf counter g; any other formula on top is replaced by its two counting children
(countingNext).
The root of the counting-sparsification search: the nontautological normal form
(countingNormalize) of a formula of width k, and the unsatisfiable formula [[]] otherwise.
The initial state of the counting-sparsification search on φ.
The counting-sparsification search: run step M K g for rounds B φ rounds from
init k φ, and report the accumulated model count.
Agreement with the depth-first tree search #
The list-level counting branching rule for width K and thresholds countingThreshold M.
The root #
The root as a state of the list-level counting branching rule.
The states of the tree #
The bound 2 ∑_{j < K} countingThreshold M j on the occurrences of a variable in a sparse
formula.
Every state reached along a node word of length at most h has at most φ.length + 1 + K * h
clauses.
Sparse leaves are small. The sparse states of the counting-sparsification tree have at most
occBound K M * φ.numVars + 1 clauses.
Every state of the tree has clause width at most k (for every φ : CNF ℕ and every k : ℕ,
including k = 0).
The run of the search #
The fixed-parameter quantitative depth and leaf-count hypotheses for the
counting-sparsification tree (a library adaptation of Appendix A.2–A.3, Lemmas A.2–A.3, pp. 46–47
[OAI26k]): from any CountingNormalized K root formula ψ whose
occurring variables lie in a finite set declared of size N = declared.card, every leaf word of
rule hM hK has length at most L_coeff * N, and any finset of leaf words has cardinality at
most 2 ^ (N / B + 1). countingTreeBound_of_budget proves them with
L_coeff = countingDepthCoeff K M for 2 ≤ M and 1 ≤ B under an integer parameter budget, and
countingTreeBound_countingThresholdBase proves them, with the same L_coeff, at
M = countingThresholdBase K B for every 1 ≤ B.
The run of the counting-sparsification search. Under CountingTreeBound, after
rounds B φ rounds the stack is empty and the accumulator records the capped sum of leafWeight
over the leaf words of rootState hkK φ. At every round i, the stack holds at most
L_coeff * φ.numVars + 1 nodes of depth at most L_coeff * φ.numVars, and the accumulator is at
most 2 ^ φ.numVars.
Correctness from the invariants of sparse leaves. The counter need only be exact on
normalized sparse formulas of width at most k, supported on the input's variables, with at most
occBound K M * φ.numVars + 1 clauses. Its values outside this domain do not affect the result.
The additive 1 includes the normalized contradiction [[]] when the input has no variables.
The search computes the model count (occurring-variable support promise). If g computes
ψ.modelCount on sparse formulas ψ of width at most k whose occurring variables lie in
φ.vars.toFinset, then search M K k B g φ returns φ.modelCount on formulas of width at most k
and 0 otherwise.
The search computes the model count. If g computes ψ.modelCount on sparse formulas ψ
of width at most k, then search M K k B g φ returns φ.modelCount on formulas of width at most
k and 0 otherwise.
The search computes φ.modelCount on formulas of width at most k.
Polynomial-time parts #
Popping a sparse leaf and adding its weighted count is polynomial-time.
Encoded state sizes #
A bound on the length of the encoded formulas in the counting-sparsification tree.
A bound on the length of the encoded states of the counting-sparsification search.
The encoded-node bound is polynomial in any input size that polynomially bounds both the encoded formula length and the tree-depth coefficient.
nodeBound is polynomial in the encoded length of the formula at fixed depth coefficient.
stateBound is polynomial in the encoded length of the formula.
Packaged all-prefix invariants of CountingSparsify.step.
Under CountingTreeBound M K B L_coeff hM hK, for every round i : ℕ:
- the retained variable count
.1isφ.distinctVars.lengthand the encoded state has length at moststateBound K L_coeff φ(withφ.numVars + 1 ≤ stateBound K L_coeff φ); - whenever the stack is nonempty and its top formula
ψis(countingThreshold M, K)-sparse,ψhas clause width≤ k, variable support contained inφ.vars.toFinset,ψ.numVars ≤ φ.numVars,ψ.length ≤ occBound K M * φ.numVars + 1, and(encCNF ψ).length ≤ nodeBound K L_coeff φ.
The counting-sparsification search detects satisfiability by testing its output for
positivity. With a shared seed, its error fraction is at most
2 ^ (φ.numVars / B + 1) * ε when each leaf routine has error fraction at most ε.
The leaf contract includes the root's variable support, the leaf clause bound, and the
encoded-length bound, so a shared seed can cover lengths that depend on the leaf encoding.
For a valid declared input the same positivity test applies to searchDeclaredWith by
searchDeclaredWith_eq_ite_mul.
Counting sparsification on a shared uniform seed returns the exact model count except
with probability at most 2 ^ (φ.numVars / B + 1) * ε. Each leaf reads a prefix of its
own prescribed width and returns the count over its occurring variables. The search supplies
the multiplicities for variables omitted from the leaf.
Independent time and workspace of the counting-sparsification search #
The time and space of the counting-sparsification search. Given a total leaf routine g
with hg : ComputableInO g encCNF encNat t t whose time and space t ψ satisfy the global bound
ht (O(2 ^ (δ * ψ.length) * (|encCNF ψ| + 1) ^ e)) for every ψ : CNF ℕ, and whose output is at
most 2 ^ ψ.numVars on sparse width-≤ k formulas, search M K k B g has a combined
time-and-space certificate ComputableInO (search M K k B g) encCNF encNat T T with the
fixed-parameter transfer bound
T φ ≤ C₀ * (2 ^ ((1 / B + occBound K M * δ) * φ.numVars) * (|encCNF φ| + 1) ^ E) + C₀ (a library
adaptation of the leaf-to-root runtime assembly, without an independent polynomial-space
certificate).
Independent polynomial workspace for counting sparsification. A single total leaf machine
with separate time t and workspace s gives a single total machine for the existing search.
Only sparse width-≤ k inputs need satisfy the quantitative leaf promises ht, hs, and hg_le.
The workspace includes all traversal prefixes and the terminal state, the full encoded formulas,
initialization, binary loop clock, retained declared-variable count, and output accumulator.
The parameters M, K, k, B, and L_coeff, and all leaf-bound constants are fixed before the
machine is chosen. Polynomial workspace is measured in the full encCNF length, independently
of the exponential number of rounds and leaf time. This resource transfer does not construct a
leaf counter or provide a uniform machine for runtime choices of these parameters.
Captured runtime context and declared-variable wrapper #
One step of the depth-first search of the counting-sparsification tree carrying an unchanged
runtime context p : P, using threshold family θ p and context-aware leaf counter g
(returning the occurring-variable count ψ.modelCount on sparse leaves).
Runtime-context counting-sparsification search (occurring-variable count): run
stepWith (fun q => countingThreshold (MOf q)) K g for rounds (BOf p) φ steps from
(p, init k φ) and return the accumulated occurring-variable count.
Declared-variable counting-sparsification wrapper: guards width ≤ k and variable support
⊆ Finset.range (NOf p), runs searchWith MOf BOf K k g p φ (retaining State.1 = φ.numVars),
and shifts left by NOf p - φ.distinctVars.length (= * 2 ^ (NOf p - φ.numVars)). Returns
φ.modelCountOn (Finset.range (NOf p)) on valid inputs (including 2 ^ NOf p on the empty formula
[]) and 0 otherwise.
The declared search detects satisfiability if the leaf routine returns a positive value exactly on satisfiable normalized sparse leaves within the declared support and clause bound. An invalid width or support fails the test. This gives the semantic step for using a leaf decision routine toward the decision transfer in [MITHardnessGroup2026SH, v2, §2.2, Corollary 2.3], tracked in #8457.
Declared-variable correctness from normalized bounded leaves. The occurring-variable
counter need only be exact on normalized sparse width-≤ k formulas supported on the declared
range and having at most occBound K (MOf p) * NOf p + 1 clauses.
Declared-variable correctness on valid inputs, from the invariants of sparse leaves.
Correctness of searchDeclaredWith under CountingTreeBound.
If g (p, ψ) = ψ.modelCount on sparse formulas ψ of width ≤ k whose occurring variables lie in
Finset.range (NOf p), then searchDeclaredWith returns φ.modelCountOn (Finset.range (NOf p))
when validDeclaredInput k (NOf p) φ = true and 0 otherwise.
Correctness of searchDeclaredWith on valid inputs under CountingTreeBound.
Normalize a declared-variable leaf counter that is exact only on normalized bounded leaves, then recover the original declared-variable count. The input guard returns zero on invalid inputs.
Declared-variable correctness on valid inputs after normalizing a counter whose correctness is restricted to normalized bounded sparse leaves.
Correctness of searchDeclaredWith composed with normalizeDeclaredLeaf.
When a leaf provider h : P × CNF ℕ → ℕ returns the declared-range count
ψ.modelCountOn (Finset.range (NOf p)) on sparse width-≤ k leaves with
ψ.vars.toFinset ⊆ Finset.range (NOf p), normalizing h via normalizeDeclaredLeaf NOf h makes
searchDeclaredWith compute φ.modelCountOn (Finset.range (NOf p)) on valid inputs and 0
otherwise.
Correctness of searchDeclaredWith composed with normalizeDeclaredLeaf on valid
inputs.