Streaming polynomial-space exhaustive counting and finite-threshold fallback absorption #
This module formalizes the streaming polynomial-space $2^n$ exhaustive counting fallbacks and their constant-factor time absorption from §5.5 (Proof of Theorem 2.2, p. 39) and §6.4 (Proof of Proposition 6.4, pp. 43ā44) of OpenAI, The Exponential Time Hypothesis is False:
- Streaming sparse
š½āpolynomial system counter (countSystemExhaustive): iterates over all0 ⤠idx < 2 ^ nviaCslib.GenericRAM.BooleanFold.runwithout materializingenumList n, retaining only((n, sys), Z)withZ ⤠idx ⤠2 ^ n, and incrementsZwheneverCslib.Complexity.evalSystemvanishes on(lowBits n idx).getD v false(defaulting variable indicesv ā„ ntofalse). On canonical equations with variables< n, this equalsCslib.BitString.commonZeroCount. - Streaming declared-variable
CNFmodel counter (countCNFExhaustive): iterates over all0 ⤠idx < 2 ^ nviaCslib.GenericRAM.BooleanFold.run, evaluatingĻ : CNF āon(lowBits n idx).getD v false(defaulting variablesv ā„ ntofalse), and equalsCNF.modelCountOn Ļ (Finset.range n)(hence2 ^ (n - Ļ.numVars) * Ļ.modelCountwhenever every occurring variable ofĻis< n). - Finite-threshold guard-fallback combinator and constant absorption: combines a polynomial
guard
ok : α ā Bool, a fast certificatec_fast, and an exhaustive fallback certificatec_exhaustviaNativeCertificate.branch(evaluating only the selected branch), preserves polynomial workspace, and absorbs theO(poly(|x|) * 2 ^ μ(x))fallback runtime into a pure additive polynomialC * (|ei x| + 1) ^ d(and intoC' * (|ei x| + 1) ^ e * 2 ^ E(x)for any nonnegative exponentE(x)) wheneverok x = false ā μ x < Nā.
Main definitions #
Cslib.GenericRAM.ExhaustiveCountFallback.countStep,Cslib.GenericRAM.ExhaustiveCountFallback.countPredicateCertificate: streaming step body and genericNativeCertificatefor countingn-bit words satisfying a polynomial-time predicate alongBooleanFold.Cslib.GenericRAM.ExhaustiveCountFallback.countSystemPrefix,Cslib.GenericRAM.ExhaustiveCountFallback.countSystemExhaustive,Cslib.GenericRAM.ExhaustiveCountFallback.equationToFinset,Cslib.GenericRAM.ExhaustiveCountFallback.countSystemExhaustiveCertificate: streaming sparseš½āsystem counter, prefix state,Fin nmonomial-family projection, andNativeCertificate.Cslib.GenericRAM.ExhaustiveCountFallback.countCNFPrefix,Cslib.GenericRAM.ExhaustiveCountFallback.countCNFExhaustive,Cslib.GenericRAM.ExhaustiveCountFallback.countCNFExhaustiveCertificate: streaming declared-variableCNF āmodel counter, prefix state, andNativeCertificate.Cslib.GenericRAM.ExhaustiveCountFallback.guardedBranchOfPolyTime,Cslib.GenericRAM.ExhaustiveCountFallback.guardedTargetCertificate,Cslib.GenericRAM.ExhaustiveCountFallback.guardedTargetOfPolyTime: native guard-fallback certificate constructors viaNativeCertificate.branch.
Main results #
Cslib.GenericRAM.ExhaustiveCountFallback.countSystemPrefix_invariant,Cslib.GenericRAM.ExhaustiveCountFallback.countSystemExhaustive_eq_card_filter,Cslib.GenericRAM.ExhaustiveCountFallback.countSystemExhaustive_eq_commonZeroCount,Cslib.GenericRAM.ExhaustiveCountFallback.countSystemExhaustive_nil,Cslib.GenericRAM.ExhaustiveCountFallback.countSystemExhaustive_eq_zero_of_nil_mem: prefix bounds,BitString nfilter equality, andcommonZeroCountbridge forcountSystemExhaustive.Cslib.GenericRAM.ExhaustiveCountFallback.computableInPolyTime_evalSystem_word,Cslib.GenericRAM.ExhaustiveCountFallback.polyBounded_countSystemExhaustive_space,Cslib.GenericRAM.ExhaustiveCountFallback.exists_countSystemExhaustive_time_le,Cslib.GenericRAM.ExhaustiveCountFallback.computableInO_countSystemExhaustive: polynomial-space andO(poly(|x|) * 2 ^ n)-time bounds forcountSystemExhaustive.Cslib.GenericRAM.ExhaustiveCountFallback.countCNFPrefix_invariant,Cslib.GenericRAM.ExhaustiveCountFallback.countCNFExhaustive_eq_card_filter,Cslib.GenericRAM.ExhaustiveCountFallback.countCNFExhaustive_eq_modelCountOn_range,Cslib.GenericRAM.ExhaustiveCountFallback.countCNFExhaustive_eq_mul_modelCount,Cslib.GenericRAM.ExhaustiveCountFallback.countCNFExhaustive_nil,Cslib.GenericRAM.ExhaustiveCountFallback.countCNFExhaustive_eq_zero_of_nil_mem: prefix bounds andCNF.modelCountOn/CNF.modelCountbridges forcountCNFExhaustive.Cslib.GenericRAM.ExhaustiveCountFallback.computableInPolyTime_evalCNF_word,Cslib.GenericRAM.ExhaustiveCountFallback.polyBounded_countCNFExhaustive_space,Cslib.GenericRAM.ExhaustiveCountFallback.exists_countCNFExhaustive_time_le,Cslib.GenericRAM.ExhaustiveCountFallback.computableInO_countCNFExhaustive: polynomial-space andO(poly(|x|) * 2 ^ n)-time bounds forcountCNFExhaustive.Cslib.GenericRAM.ExhaustiveCountFallback.ite_eq_of_agrees,Cslib.GenericRAM.ExhaustiveCountFallback.polyBounded_branch_space,Cslib.GenericRAM.ExhaustiveCountFallback.exists_branch_time_le_of_finite_threshold,Cslib.GenericRAM.ExhaustiveCountFallback.computableInO_of_guarded_fallback,Cslib.GenericRAM.ExhaustiveCountFallback.exists_nat_exp_bound_of_guarded_fallback,Cslib.GenericRAM.ExhaustiveCountFallback.exists_real_exp_bound_of_guarded_fallback: pointwise agreement, polynomial workspace preservation, and finite-threshold fallback absorption.
References #
- OpenAI, The Exponential Time Hypothesis is False, §5.5 (pp. 38ā39) and §6.4 (pp. 43ā44)
Streaming Boolean-Cube Predicate Counter Infrastructure #
One streaming BooleanFold callback step for counting n-bit words satisfying pred: retains
the captured input s.2.1 = (n, payload) and increments the binary counter s.2.2 when
pred payload word holds on the current decoded n-bit word s.1.2.
Instances For
If evaluating pred on (payload, word) is polynomial-time, then one streaming countStep
callback is polynomial-time.
Generic NativeCertificate for counting n-bit assignments satisfying pred via
BooleanFold.certificate without materializing enumList n.
Instances For
1. Streaming Sparse š½ā Polynomial System Counter (§5.5, pp. 38ā39) #
Prefix state after visiting the first j assignments 0 ⤠idx < j of the streaming sparse š½ā
system counter on (n, sys). Variable indices v ā„ n default to false via List.getD.
Instances For
Streaming polynomial-space $2^n$ sparse š½ā polynomial system counter (§5.5, p. 39):
iterates over 0 ⤠idx < 2 ^ n via BooleanFold.run without materializing enumList n, keeping
live state ((n, sys), Z) and incrementing Z whenever every equation in sys evaluates to
false (0 ā š½ā) under (lowBits n idx).getD v false (variables v ā„ n default to false).
Instances For
At every prefix j, the retained payload in countSystemPrefix x j equals x = (n, sys).
At every prefix j, the running count Z equals the number of indices idx < j whose decoded
n-bit word satisfies evalSystem.
Unconditional prefix count bound Z ⤠j for countSystemPrefix.
countSystemExhaustive (n, sys) equals the cardinality of the BitString n assignments whose
decoded word (List.ofFn Ļ).getD v false satisfies evalSystem sys.
Semantic bridge to Cslib.BitString.commonZeroCount: when every equation in sys is
canonical (IsCanonicalEquation) and all occurring variable indices satisfy v < n,
countSystemExhaustive (n, sys) equals commonZeroCount of the projected Fin n equations.
Evaluating a sparse š½ā polynomial system sys on (word.getD v false) is polynomial-time in
the pair encoding (encList (encList (encList encNat)), encBits).
Native resource certificate for countSystemExhaustive over (encUnary, encSys) ā encNat.
Instances For
countSystemExhaustiveCertificate uses polynomial workspace in the encoded input length.
countSystemExhaustiveCertificate runs in (2 ^ n + 1) * P_ex x + Q_ex x steps for
polynomially bounded P_ex, Q_ex.
countSystemExhaustive is computable in O((|x| + 1) ^ d * 2 ^ n) time and polynomial
workspace.
2. Streaming Declared-Variable CNF Model Counter (§6.4, pp. 43ā44) #
Prefix state after visiting the first j assignments 0 ⤠idx < j of the streaming
declared-variable CNF ā model counter on (n, Ļ). Variable indices v ā„ n default to false
via (lowBits n idx).getD v false.
Instances For
Streaming polynomial-space $2^n$ declared-variable CNF model counter (§6.4, pp. 43ā44):
iterates over 0 ⤠idx < 2 ^ n via BooleanFold.run without materializing enumList n, keeping
live state ((n, Ļ), Z) and incrementing Z when Ļ.eval (fun v => (lowBits n idx).getD v false)
is true. Variable indices v ā„ n default to false; to interpret countCNFExhaustive (n, Ļ) as
the satisfying-assignment count on n declared variables, require ā v ā Ļ.vars, v < n.
Instances For
At every prefix j, the retained payload in countCNFPrefix x j equals x = (n, Ļ).
At every prefix j, the running count Z equals the number of indices idx < j whose decoded
n-bit word satisfies Ļ.
Unconditional prefix count bound Z ⤠j for countCNFPrefix.
Prefix invariant Z ⤠j ⤠2 ^ n for countCNFPrefix along the 2 ^ n traversal.
countCNFExhaustive (n, Ļ) equals the cardinality of the BitString n assignments whose
decoded word (List.ofFn Ļ).getD v false satisfies Ļ.
Exact agreement with CNF.modelCountOn Ļ (Finset.range n): both countCNFExhaustive (n, Ļ)
and CNF.modelCountOn Ļ (Finset.range n) range over n-bit assignments on {0, ā¦, n - 1} and
extend variables v ā„ n by false.
When all occurring variables of Ļ satisfy v < n, countCNFExhaustive (n, Ļ) equals
2 ^ (n - Ļ.numVars) * Ļ.modelCount, doubling for each unused declared variable < n.
A formula containing an empty clause [] has 0 satisfying assignments (§6.4, p. 43).
Evaluating Ļ : CNF ā on (word.getD v false) is polynomial-time in (encCNF, encBits).
Native resource certificate for countCNFExhaustive over (encUnary, encCNF) ā encNat.
Instances For
countCNFExhaustiveCertificate uses polynomial workspace in the encoded input length.
countCNFExhaustiveCertificate runs in (2 ^ n + 1) * P_ex x + Q_ex x steps for polynomially
bounded P_ex, Q_ex.
countCNFExhaustive is computable in O((|x| + 1) ^ d * 2 ^ n) time and polynomial workspace.
3. Finite-Threshold Guard-Fallback Combinator & Constant Absorption (§5.5 & §6.4) #
Pointwise agreement of if ok x then f_fast x else f_exhaust x with a target specification f
whenever f_fast agrees with f on ok x = true and f_exhaust agrees with f on
ok x = false.
Build the selected-branch NativeCertificate for
fun x => if ok x then f_fast x else f_exhaust x from a ComputableInPolyTime guard ok,
evaluating only the selected branch.
Instances For
Build a NativeCertificate directly for a target specification f : α ā β via
NativeCertificate.branch, charging only c_ok and the selected branch.
Instances For
Build a NativeCertificate for target f from a ComputableInPolyTime guard ok, a fast
certificate c_fast, and an exhaustive fallback certificate c_exhaust.
Instances For
Polynomial workspace preservation: NativeCertificate.branch has polynomial workspace
whenever the guard, fast branch, and exhaustive fallback each have polynomial workspace (without
assuming either branch runs in polynomial time).
Finite-threshold fallback time absorption on NativeCertificate.branch (§5.5 p. 39,
§6.4 p. 44): if ok x = false ā μ x < Nā for a constant threshold Nā and c_exhaust.time x ⤠(2 ^ μ x + 1) * P_ex x + Q_ex x with PolyBounded P_ex, Q_ex, then the guarded branch preserves
polynomial workspace and bounds total time by (if ok x then c_fast.time x else 0) + C * (|ei x| + 1) ^ d.
Combined ComputableInO theorem under a ComputableInPolyTime guard: when ok x = false ā μ x < Nā, the guarded machine computes f in polynomial workspace and time
T_fast x + C * (|ei x| + 1) ^ d.
Natural-exponent constant absorption: for any E : α ā ā, if the fast branch satisfies
ok x = true ā c_fast.time x ⤠C_f * (|ei x| + 1) ^ d_f * 2 ^ E x and ok x = false ā μ x < Nā,
then the finite exhaustive-fallback cases are absorbed into C' * (|ei x| + 1) ^ e * 2 ^ E x.
Real-exponent subexponential constant absorption (§5.5 p. 39, §6.4 p. 44): for any
nonnegative real exponent E : α ā ā (ā x, 0 ⤠E x, including subexponential exponents such as
A * Ļ (μ x)), if ok x = true ā (c_fast.time x : ā) ⤠C_f * (|ei x| + 1) ^ d_f * 2 ^ E x and
ok x = false ā μ x < Nā, then the combined guarded certificate has polynomial workspace, satisfies
(cert.time x : ā) ⤠C' * (|ei x| + 1) ^ e * (2 : ā) ^ E x for all x, and runs in
ComputableInO time (|ei x| + 1) ^ e * ā(2 : ā) ^ E xāā.