Documentation

CslibFrontier.Computability.Complexity.FineGrained.CountingPowerSearch

Native search with an input-dependent counting budget #

For a fixed width and inverse saving denominator, one deterministic multitape search computes the disjoint sparse-leaf sum over the original declared variables. The certificate charges the encoded input, including the unary declared size, and the supplied leaf computation. Its round factor uses the power saving from [MITHardnessGroup2026SH, Lemma 2.2, §2.2]. A size-based power saving transfers to the occurring variable count for both counting and decision after polynomial-time dense relabeling. For bounded-error decision, majority amplification supplies sufficiently accurate leaf verifiers for a shared-seed search.

Main results #

References #

Cap a seeded leaf counter at the number of assignments to its occurring variables. The cap fits every answer, including on erroneous seeds. Correct answers stay correct, and the native clock retains its exponent power.

The bit length bound for each active leaf formula is polynomial in the full encoded input, including its unary declared variable count.

theorem Cslib.Complexity.CountingSparsify.exists_computableInO_searchDeclared_powerBudget {C : Type} (encC : C ↪ List Bool) {k d : ℕ} (hk : 2 ≤ k) (hd : 1 ≤ d) {g t s : (C × ℕ) × Logic.PL.CNF ℕ → ℕ} {R Q : C × ℕ × Logic.PL.CNF ℕ → ℕ} (hcounter : Turing.MultiTapeTM.ComputableInO g (Turing.MultiTapeTM.encPair (Turing.MultiTapeTM.encPair encC Turing.MultiTapeTM.encUnary) encCNF) Turing.MultiTapeTM.encNat t s) (hcorrect : ∀ (p : C × ℕ) (ψ : Logic.PL.CNF ℕ), match p with | (fst, declared) => have M := Logic.PL.ClauseSet.Sparsification.countingThresholdBase k (Logic.PL.ClauseSet.Sparsification.countingPowerBudget d declared); (∀ c ∈ ψ, List.length c ≤ k) → Logic.PL.CNF.Sparsification.isSparse (Logic.PL.CNF.Sparsification.countingThreshold M) k ψ = true → ψ.vars.toFinset ⊆ Finset.range declared → List.length ψ ≤ occBound k M * declared + 1 → g (p, ψ) = ψ.modelCount) (hresources : ∀ (x : C × ℕ × Logic.PL.CNF ℕ) (ψ : Logic.PL.CNF ℕ), match x with | (context, declared, formula) => have M := Logic.PL.ClauseSet.Sparsification.countingThresholdBase k (Logic.PL.ClauseSet.Sparsification.countingPowerBudget d declared); (∀ c ∈ ψ, List.length c ≤ k) → Logic.PL.CNF.Sparsification.isSparse (Logic.PL.CNF.Sparsification.countingThreshold M) k ψ = true → ψ.vars.toFinset ⊆ Finset.range declared → List.length ψ ≤ occBound k M * declared + 1 → (encCNF ψ).length ≤ nodeBound k (Logic.PL.ClauseSet.Sparsification.countingDepthCoeff k M) formula → t ((context, declared), ψ) ≤ R x ∧ s ((context, declared), ψ) ≤ Q x) :
have encInput := Turing.MultiTapeTM.encPair encC (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary encCNF); ∃ (count : C × ℕ × Logic.PL.CNF ℕ → ℕ) (T : C × ℕ × Logic.PL.CNF ℕ → ℕ) (S : C × ℕ × Logic.PL.CNF ℕ → ℕ) (c : ℕ) (e : ℕ), Turing.MultiTapeTM.ComputableInO count encInput Turing.MultiTapeTM.encNat T S ∧ (Turing.MultiTapeTM.PolyBounded (fun (x : C × ℕ × Logic.PL.CNF ℕ) => (encInput x).length) Q → Turing.MultiTapeTM.PolyBounded (fun (x : C × ℕ × Logic.PL.CNF ℕ) => (encInput x).length) S) ∧ (∀ (x : C × ℕ × Logic.PL.CNF ℕ), match x with | (fst, declared, formula) => count x = if Logic.PL.CNF.validDeclaredInput k declared formula = true then formula.modelCountOn (Finset.range declared) else 0) ∧ ∀ (x : C × ℕ × Logic.PL.CNF ℕ), match x with | (fst, declared, snd) => ↑(T x) ≤ 6 * 2 ^ (3 * (↑declared + 1) ^ (1 - (↑d)⁻¹)) * (↑c * (↑(encInput x).length + 1) ^ e + ↑(R x))

For unary declared variable counts, a fixed power budget gives a native counter from a certified leaf counter exact on sparse, supported leaves. The time bound holds on all inputs: a polynomial-time guard rejects invalid formulas before incurring traversal costs. Workspace is polynomial whenever the leaf workspace allowance is polynomial.

theorem Cslib.Complexity.CountingSparsify.exists_computableInO_seededSearch_powerBudget {k d : ℕ} (hk : 2 ≤ k) (hd : 1 ≤ d) {width : DeclaredCNF → ℕ} {V : DeclaredCNF × List Bool → Bool} {Tw Sw : DeclaredCNF → ℕ} {Tv Sv : DeclaredCNF × List Bool → ℕ} (hwidth : Turing.MultiTapeTM.ComputableInO width encDeclaredCNF Turing.MultiTapeTM.encUnary Tw Sw) (hV : Turing.MultiTapeTM.ComputableInO V (Turing.MultiTapeTM.encPair encDeclaredCNF Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBool Tv Sv) {R Q : DeclaredCNF × List Bool → ℕ} (hresources : ∀ (seed : List Bool) (a : DeclaredCNF) (ψ : Logic.PL.CNF ℕ), have M := Logic.PL.ClauseSet.Sparsification.countingThresholdBase k (Logic.PL.ClauseSet.Sparsification.countingPowerBudget d a.numVars); have leaf := { numVars := a.numVars, formula := ψ }; have leafSize := ((Turing.MultiTapeTM.encPair encDeclaredCNF Turing.MultiTapeTM.encBits) (leaf, seed)).length; have query := (leaf, List.take (width leaf) seed); (∀ c ∈ ψ, List.length c ≤ k) → Logic.PL.CNF.Sparsification.isSparse (Logic.PL.CNF.Sparsification.countingThreshold M) k ψ = true → ψ.vars.toFinset ⊆ Finset.range a.numVars → List.length ψ ≤ occBound k M * a.numVars + 1 → (encCNF ψ).length ≤ nodeBound k (Logic.PL.ClauseSet.Sparsification.countingDepthCoeff k M) a.formula → 20 * leafSize + Tw leaf + Tv query ≤ R (a, seed) ∧ 20 * leafSize + Sw leaf + Sv query ≤ Q (a, seed)) :
have encInput := Turing.MultiTapeTM.encPair encDeclaredCNF Turing.MultiTapeTM.encBits; ∃ (verify : DeclaredCNF × List Bool → Bool) (T : DeclaredCNF × List Bool → ℕ) (S : DeclaredCNF × List Bool → ℕ) (c : ℕ) (e : ℕ), Turing.MultiTapeTM.ComputableInO verify encInput Turing.MultiTapeTM.encBool T S ∧ (∀ (p : DeclaredCNF × List Bool), ↑(T p) ≤ 6 * 2 ^ (3 * (↑p.1.numVars + 1) ^ (1 - (↑d)⁻¹)) * (↑c * (↑(encInput p).length + 1) ^ e + ↑(R p))) ∧ (∀ (p : DeclaredCNF × List Bool), Logic.PL.CNF.validDeclaredInput k p.1.numVars p.1.formula = false → verify p = false) ∧ ∀ (a : DeclaredCNF) (n : ℕ) (ε : ℝ), 0 ≤ ε → Logic.PL.CNF.validDeclaredInput k a.numVars a.formula = true → (∀ (ψ : Logic.PL.CNF ℕ), have M := Logic.PL.ClauseSet.Sparsification.countingThresholdBase k (Logic.PL.ClauseSet.Sparsification.countingPowerBudget d a.numVars); have leaf := { numVars := a.numVars, formula := ψ }; Logic.PL.CNF.Sparsification.CountingNormalized k ψ → (∀ c ∈ ψ, List.length c ≤ k) → Logic.PL.CNF.Sparsification.isSparse (Logic.PL.CNF.Sparsification.countingThreshold M) k ψ = true → ψ.vars.toFinset ⊆ Finset.range a.numVars → List.length ψ ≤ occBound k M * a.numVars + 1 → (encCNF ψ).length ≤ nodeBound k (Logic.PL.ClauseSet.Sparsification.countingDepthCoeff k M) a.formula → width leaf ≤ n ∧ ↑(acceptCount (fun (p : DeclaredCNF × List Bool) => V p != decide (0 < p.1.formula.modelCount)) leaf (width leaf)) ≤ ε * 2 ^ width leaf) → ↑(acceptCount (fun (p : DeclaredCNF × List Bool) => verify p != decide (0 < p.1.formula.modelCount)) a n) ≤ 2 ^ (a.formula.numVars / Logic.PL.ClauseSet.Sparsification.countingPowerBudget d a.numVars + 1) * (ε * 2 ^ n)

Compile a declared-variable verifier with a shared seed into the power-budget search. The machine truncates the shared seed to the width requested by each leaf and tests the search output for positivity. The clock includes the framed seed length and the allowance for computing a leaf width and running the leaf verifier. Invalid declared formulas are rejected, and on valid formulas the error fraction is bounded by the leaf error times the leaf-count bound.

theorem Cslib.Complexity.CountingSparsify.exists_computableInO_seededCount_powerBudget {k d : ℕ} (hk : 2 ≤ k) (hd : 1 ≤ d) {width : DeclaredCNF → ℕ} {V : DeclaredCNF × List Bool → ℕ} {Tw Sw : DeclaredCNF → ℕ} {Tv Sv : DeclaredCNF × List Bool → ℕ} (hwidth : Turing.MultiTapeTM.ComputableInO width encDeclaredCNF Turing.MultiTapeTM.encUnary Tw Sw) (hV : Turing.MultiTapeTM.ComputableInO V (Turing.MultiTapeTM.encPair encDeclaredCNF Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encNat Tv Sv) (hcap : ∀ (p : DeclaredCNF × List Bool), V p ≤ 2 ^ p.1.formula.numVars) {R Q : DeclaredCNF × List Bool → ℕ} (hresources : ∀ (seed : List Bool) (a : DeclaredCNF) (ψ : Logic.PL.CNF ℕ), have M := Logic.PL.ClauseSet.Sparsification.countingThresholdBase k (Logic.PL.ClauseSet.Sparsification.countingPowerBudget d a.numVars); have leaf := { numVars := a.numVars, formula := ψ }; have leafSize := ((Turing.MultiTapeTM.encPair encDeclaredCNF Turing.MultiTapeTM.encBits) (leaf, seed)).length; have query := (leaf, List.take (width leaf) seed); (∀ c ∈ ψ, List.length c ≤ k) → Logic.PL.CNF.Sparsification.isSparse (Logic.PL.CNF.Sparsification.countingThreshold M) k ψ = true → ψ.vars.toFinset ⊆ Finset.range a.numVars → List.length ψ ≤ occBound k M * a.numVars + 1 → (encCNF ψ).length ≤ nodeBound k (Logic.PL.ClauseSet.Sparsification.countingDepthCoeff k M) a.formula → 20 * leafSize + Tw leaf + Tv query ≤ R (a, seed) ∧ 20 * leafSize + Sw leaf + Sv query ≤ Q (a, seed)) :
have encInput := Turing.MultiTapeTM.encPair encDeclaredCNF Turing.MultiTapeTM.encBits; ∃ (verify : DeclaredCNF × List Bool → ℕ) (T : DeclaredCNF × List Bool → ℕ) (S : DeclaredCNF × List Bool → ℕ) (c : ℕ) (e : ℕ), Turing.MultiTapeTM.ComputableInO verify encInput Turing.MultiTapeTM.encNat T S ∧ (∀ (p : DeclaredCNF × List Bool), ↑(T p) ≤ 6 * 2 ^ (3 * (↑p.1.numVars + 1) ^ (1 - (↑d)⁻¹)) * (↑c * (↑(encInput p).length + 1) ^ e + ↑(R p))) ∧ (∀ (p : DeclaredCNF × List Bool), Logic.PL.CNF.validDeclaredInput k p.1.numVars p.1.formula = false → verify p = 0) ∧ ∀ (a : DeclaredCNF) (n : ℕ) (ε : ℝ), 0 ≤ ε → Logic.PL.CNF.validDeclaredInput k a.numVars a.formula = true → (∀ (ψ : Logic.PL.CNF ℕ), have M := Logic.PL.ClauseSet.Sparsification.countingThresholdBase k (Logic.PL.ClauseSet.Sparsification.countingPowerBudget d a.numVars); have leaf := { numVars := a.numVars, formula := ψ }; Logic.PL.CNF.Sparsification.CountingNormalized k ψ → (∀ c ∈ ψ, List.length c ≤ k) → Logic.PL.CNF.Sparsification.isSparse (Logic.PL.CNF.Sparsification.countingThreshold M) k ψ = true → ψ.vars.toFinset ⊆ Finset.range a.numVars → List.length ψ ≤ occBound k M * a.numVars + 1 → (encCNF ψ).length ≤ nodeBound k (Logic.PL.ClauseSet.Sparsification.countingDepthCoeff k M) a.formula → width leaf ≤ n ∧ ↑(acceptCount (fun (p : DeclaredCNF × List Bool) => V p != p.1.formula.modelCount) leaf (width leaf)) ≤ ε * 2 ^ width leaf) → ↑(acceptCount (fun (p : DeclaredCNF × List Bool) => verify p != p.1.formula.modelCountOn (Finset.range p.1.numVars)) a n) ≤ 2 ^ (a.formula.numVars / Logic.PL.ClauseSet.Sparsification.countingPowerBudget d a.numVars + 1) * (ε * 2 ^ n)

Run the native power-budget search with shared-seed verifiers for occurring-variable counts. Leaf values must fit their occurring-variable count bounds, including on incorrect answers. The search returns a declared-variable count, or zero on an invalid formula. The error on valid formulas is at most the per-leaf error times the leaf-count bound.

theorem Cslib.Complexity.CountingSparsify.solvesWithErrorInPowerExpTime_of_powerBudgetLeaves {k d : ℕ} (hk : 2 ≤ k) (hd : 1 ≤ d) {width : DeclaredCNF → ℕ} {V : DeclaredCNF × List Bool → Bool} {Tw Sw : DeclaredCNF → ℕ} {Tv Sv : DeclaredCNF × List Bool → ℕ} (hwidth : Turing.MultiTapeTM.ComputableInO width encDeclaredCNF Turing.MultiTapeTM.encUnary Tw Sw) (hV : Turing.MultiTapeTM.ComputableInO V (Turing.MultiTapeTM.encPair encDeclaredCNF Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBool Tv Sv) {p : ℝ} (hp : p < 1) (A e : ℕ) :
have encInput := Turing.MultiTapeTM.encPair encDeclaredCNF Turing.MultiTapeTM.encBits; have rate := fun (a : DeclaredCNF) => 2 ^ (↑A * (↑a.numVars + 1) ^ p); have admissible := fun (a : DeclaredCNF) (ψ : Logic.PL.CNF ℕ) => have M := Logic.PL.ClauseSet.Sparsification.countingThresholdBase k (Logic.PL.ClauseSet.Sparsification.countingPowerBudget d a.numVars); (∀ c ∈ ψ, List.length c ≤ k) ∧ Logic.PL.CNF.Sparsification.isSparse (Logic.PL.CNF.Sparsification.countingThreshold M) k ψ = true ∧ ψ.vars.toFinset ⊆ Finset.range a.numVars ∧ List.length ψ ≤ occBound k M * a.numVars + 1 ∧ (encCNF ψ).length ≤ nodeBound k (Logic.PL.ClauseSet.Sparsification.countingDepthCoeff k M) a.formula; (∀ (a : DeclaredCNF) (ψ : Logic.PL.CNF ℕ) (seed : List Bool), admissible a ψ → have leaf := { numVars := a.numVars, formula := ψ }; have cost := 20 * (encInput (leaf, seed)).length; have query := (leaf, List.take (width leaf) seed); have bound := rate a * (↑(encInput (a, seed)).length + 1) ^ e; ↑(cost + Tw leaf + Tv query) ≤ bound ∧ ↑(cost + Sw leaf + Sv query) ≤ bound) → (∀ (a : DeclaredCNF) (ψ : Logic.PL.CNF ℕ), Logic.PL.CNF.Sparsification.CountingNormalized k ψ → admissible a ψ → have leaf := { numVars := a.numVars, formula := ψ }; ↑(width leaf) ≤ rate a * (↑(encDeclaredCNF a).length + 1) ^ e ∧ ↑(acceptCount (fun (x : DeclaredCNF × List Bool) => V x != decide (0 < x.1.formula.modelCount)) leaf (width leaf)) ≤ 1 / 3 / 2 ^ (a.numVars / Logic.PL.ClauseSet.Sparsification.countingPowerBudget d a.numVars + 1) * 2 ^ width leaf) → ∃ (q : ℝ), 0 < q ∧ q < 1 ∧ SolvesWithErrorInPowerExpTime (PromiseProblem.ofSet {a : DeclaredCNF | Logic.PL.CNF.validDeclaredInput k a.numVars a.formula = true ∧ a.formula.Satisfiable}) encDeclaredCNF ErrorModel.bounded DeclaredCNF.numVars q

The shared-seed assembly step of [MITHardnessGroup2026SH, v2, §7, Theorem 7.1(a)]. Given leaf verifiers with a power-saving clock, a common bound on their seed widths, and error at most one third of the reciprocal leaf-count bound, the native sparsifier decides declared width-k satisfiability with bounded error. The leaf error allowance depends on the declared variable count. The unary seed allocation and the full seeded search both run with a fixed power saving in that count.

theorem Cslib.Complexity.CountingSparsify.computesWithErrorInPowerExpTime_of_powerBudgetLeaves {k d : ℕ} (hk : 2 ≤ k) (hd : 1 ≤ d) {width : DeclaredCNF → ℕ} {V : DeclaredCNF × List Bool → ℕ} {Tw Sw : DeclaredCNF → ℕ} {Tv Sv : DeclaredCNF × List Bool → ℕ} (hwidth : Turing.MultiTapeTM.ComputableInO width encDeclaredCNF Turing.MultiTapeTM.encUnary Tw Sw) (hV : Turing.MultiTapeTM.ComputableInO V (Turing.MultiTapeTM.encPair encDeclaredCNF Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encNat Tv Sv) (hcap : ∀ (p : DeclaredCNF × List Bool), V p ≤ 2 ^ p.1.formula.numVars) {p : ℝ} (hp : p < 1) (A e : ℕ) :
have encInput := Turing.MultiTapeTM.encPair encDeclaredCNF Turing.MultiTapeTM.encBits; have rate := fun (a : DeclaredCNF) => 2 ^ (↑A * (↑a.numVars + 1) ^ p); have admissible := fun (a : DeclaredCNF) (ψ : Logic.PL.CNF ℕ) => have M := Logic.PL.ClauseSet.Sparsification.countingThresholdBase k (Logic.PL.ClauseSet.Sparsification.countingPowerBudget d a.numVars); (∀ c ∈ ψ, List.length c ≤ k) ∧ Logic.PL.CNF.Sparsification.isSparse (Logic.PL.CNF.Sparsification.countingThreshold M) k ψ = true ∧ ψ.vars.toFinset ⊆ Finset.range a.numVars ∧ List.length ψ ≤ occBound k M * a.numVars + 1 ∧ (encCNF ψ).length ≤ nodeBound k (Logic.PL.ClauseSet.Sparsification.countingDepthCoeff k M) a.formula; (∀ (a : DeclaredCNF) (ψ : Logic.PL.CNF ℕ) (seed : List Bool), admissible a ψ → have leaf := { numVars := a.numVars, formula := ψ }; have cost := 20 * (encInput (leaf, seed)).length; have query := (leaf, List.take (width leaf) seed); have bound := rate a * (↑(encInput (a, seed)).length + 1) ^ e; ↑(cost + Tw leaf + Tv query) ≤ bound ∧ ↑(cost + Sw leaf + Sv query) ≤ bound) → (∀ (a : DeclaredCNF) (ψ : Logic.PL.CNF ℕ), Logic.PL.CNF.Sparsification.CountingNormalized k ψ → admissible a ψ → have leaf := { numVars := a.numVars, formula := ψ }; ↑(width leaf) ≤ rate a * (↑(encDeclaredCNF a).length + 1) ^ e ∧ ↑(acceptCount (fun (x : DeclaredCNF × List Bool) => V x != x.1.formula.modelCount) leaf (width leaf)) ≤ 1 / 3 / 2 ^ (a.numVars / Logic.PL.ClauseSet.Sparsification.countingPowerBudget d a.numVars + 1) * 2 ^ width leaf) → ∃ (q : ℝ), 0 < q ∧ q < 1 ∧ ComputesWithErrorInPowerExpTime (fun (a : DeclaredCNF) => if Logic.PL.CNF.validDeclaredInput k a.numVars a.formula = true then a.formula.modelCountOn (Finset.range a.numVars) else 0) encDeclaredCNF Turing.MultiTapeTM.encNat (1 / 3) DeclaredCNF.numVars q

Assemble bounded-error leaf counters into a solver for declared-variable model counts. The same shared seed supplies all leaf prefixes. The clock and seed-width bounds give a fixed power saving in declared variables, and the accuracy bound on each leaf gives error at most one third for the final count. Invalid declared formulas have output zero.

The contrapositive size-to-variable counting step of [MITHardnessGroup2026SH, v2, §2.2, Corollary 2.3], extended to fixed widths k ≥ 2. A power saving in variables plus clauses yields a power saving in occurring variables.

Polynomial-time dense relabeling preserves clause width and model count. The polynomial factor charges the original encoded length, including large labels and repeated clauses.

theorem Cslib.Complexity.DecidableInPowerExpTime.KSAT_numVars_of_size {k : ℕ} (hk : 2 ≤ k) {p : ℝ} (hp : 0 < p) (hp1 : p < 1) (h : DecidableInPowerExpTime (KSAT k) encCNF (fun (φ : Logic.PL.CNF ℕ) => φ.numVars + List.length φ) p) :

The contrapositive size-to-variable decision step of [MITHardnessGroup2026SH, v2, §2.2, Corollary 2.3], for fixed widths k ≥ 2. A solver with a fixed power saving in occurring variables plus clauses yields a solver with a fixed power saving in occurring variables. The polynomial factor charges the original encoded length.

The randomized size-to-variable decision transfer in [MITHardnessGroup2026SH, v2, §7, Theorem 7.1(a)] for fixed widths k ≥ 2. Dense relabeling preserves satisfiability and width. On the sparse leaves, amplification uses a number of repetitions linear in the declared variable count, which preserves the power saving. Every leaf reads a prefix of a single shared seed, and a union bound controls the total error. The time bound charges the original encoded length.

The size-to-variable step for bounded-error exact counting in [MITHardnessGroup2026SH, v2, §7, Theorem 7.1(a)], for fixed widths k ≥ 2. On each sparse leaf, amplification makes the error small enough that a shared random seed gives all counts correctly with probability at least 2 / 3. The disjoint leaf contributions sum to the original count.

The paper counts all declared variables, including unused ones (v2, footnote 2). Here SharpKSAT counts assignments to the occurring variables, and CNF.numVars measures their number. Dense relabeling preserves clause width and model count. The declared range initially consists of exactly those relabeled variables and is kept fixed for every leaf, including when its support shrinks. The polynomial factor charges the original encoded length.