Documentation

Complexity.Computability.GenericRAM.Native.ExhaustiveCountFallback

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:

  1. Streaming sparse š”½ā‚‚ polynomial system counter (countSystemExhaustive): iterates over all 0 ≤ idx < 2 ^ n via Cslib.GenericRAM.BooleanFold.run without materializing enumList n, retaining only ((n, sys), Z) with Z ≤ idx ≤ 2 ^ n, and increments Z whenever Cslib.Complexity.evalSystem vanishes on (lowBits n idx).getD v false (defaulting variable indices v ≄ n to false). On canonical equations with variables < n, this equals Cslib.BitString.commonZeroCount.
  2. Streaming declared-variable CNF model counter (countCNFExhaustive): iterates over all 0 ≤ idx < 2 ^ n via Cslib.GenericRAM.BooleanFold.run, evaluating φ : CNF ā„• on (lowBits n idx).getD v false (defaulting variables v ≄ n to false), and equals CNF.modelCountOn φ (Finset.range n) (hence 2 ^ (n - φ.numVars) * φ.modelCount whenever every occurring variable of φ is < n).
  3. Finite-threshold guard-fallback combinator and constant absorption: combines a polynomial guard ok : α → Bool, a fast certificate c_fast, and an exhaustive fallback certificate c_exhaust via NativeCertificate.branch (evaluating only the selected branch), preserves polynomial workspace, and absorbs the O(poly(|x|) * 2 ^ μ(x)) fallback runtime into a pure additive polynomial C * (|ei x| + 1) ^ d (and into C' * (|ei x| + 1) ^ e * 2 ^ E(x) for any nonnegative exponent E(x)) whenever ok x = false → μ x < Nā‚€.

Main definitions #

Main results #

References #

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

    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

          Project a sparse equation eq : List (List ā„•) onto Finset (Finset (Fin n)) by intersecting each monomial with {0, …, n - 1}.

          Instances For
            @[simp]

            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.

            Prefix invariant Z ≤ j ≤ 2 ^ n for countSystemPrefix along the 2 ^ n traversal.

            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.

            @[simp]

            An empty list of equations has 2 ^ n common zeros (§5.5, p. 38).

            A system containing the contradictory constant equation [[]] (1 = 0) has 0 common zeros (§5.5, p. 38).

            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
                @[simp]

                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 φ.

                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.

                @[simp]

                An empty formula [] has 2 ^ n satisfying assignments on n declared variables (§6.4, p. 43), including n = 0.

                A formula containing an empty clause [] has 0 satisfying assignments (§6.4, p. 43).

                3. Finite-Threshold Guard-Fallback Combinator & Constant Absorption (§5.5 & §6.4) #

                theorem Cslib.GenericRAM.ExhaustiveCountFallback.ite_eq_of_agrees {α β : Type} {ok : α → Bool} {f_fast f_exhaust f : α → β} (hfast : āˆ€ (x : α), ok x = true → f_fast x = f x) (hex : āˆ€ (x : α), ok x = false → f_exhaust x = f x) (x : α) :
                (if ok x = true then f_fast x else f_exhaust x) = f x

                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.

                noncomputable def Cslib.GenericRAM.ExhaustiveCountFallback.guardedBranchOfPolyTime {α β : Type} {ei : α ↪ List Bool} {eo : β ↪ List Bool} {ok : α → Bool} {f_fast f_exhaust : α → β} (hok : Turing.MultiTapeTM.ComputableInPolyTime ok ei Turing.MultiTapeTM.encBool) (c_fast : NativeCertificate f_fast ei eo) (c_exhaust : NativeCertificate f_exhaust ei eo) :
                NativeCertificate (fun (x : α) => if ok x = true then f_fast x else f_exhaust x) ei eo

                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
                  def Cslib.GenericRAM.ExhaustiveCountFallback.guardedTargetCertificate {α β : Type} {ei : α ↪ List Bool} {eo : β ↪ List Bool} {ok : α → Bool} {f_fast f_exhaust f : α → β} (c_ok : NativeCertificate ok ei Turing.MultiTapeTM.encBool) (c_fast : NativeCertificate f_fast ei eo) (c_exhaust : NativeCertificate f_exhaust ei eo) (hfast : āˆ€ (x : α), ok x = true → f_fast x = f x) (hex : āˆ€ (x : α), ok x = false → f_exhaust x = f x) :

                  Build a NativeCertificate directly for a target specification f : α → β via NativeCertificate.branch, charging only c_ok and the selected branch.

                  Instances For
                    @[simp]
                    theorem Cslib.GenericRAM.ExhaustiveCountFallback.guardedTargetCertificate_time {α β : Type} {ei : α ↪ List Bool} {eo : β ↪ List Bool} {ok : α → Bool} {f_fast f_exhaust f : α → β} (c_ok : NativeCertificate ok ei Turing.MultiTapeTM.encBool) (c_fast : NativeCertificate f_fast ei eo) (c_exhaust : NativeCertificate f_exhaust ei eo) (hfast : āˆ€ (x : α), ok x = true → f_fast x = f x) (hex : āˆ€ (x : α), ok x = false → f_exhaust x = f x) (x : α) :
                    (guardedTargetCertificate c_ok c_fast c_exhaust hfast hex).time x = c_ok.time x + if ok x = true then c_fast.time x else c_exhaust.time x
                    @[simp]
                    theorem Cslib.GenericRAM.ExhaustiveCountFallback.guardedTargetCertificate_space {α β : Type} {ei : α ↪ List Bool} {eo : β ↪ List Bool} {ok : α → Bool} {f_fast f_exhaust f : α → β} (c_ok : NativeCertificate ok ei Turing.MultiTapeTM.encBool) (c_fast : NativeCertificate f_fast ei eo) (c_exhaust : NativeCertificate f_exhaust ei eo) (hfast : āˆ€ (x : α), ok x = true → f_fast x = f x) (hex : āˆ€ (x : α), ok x = false → f_exhaust x = f x) (x : α) :
                    (guardedTargetCertificate c_ok c_fast c_exhaust hfast hex).space x = c_ok.space x + if ok x = true then c_fast.space x else c_exhaust.space x
                    noncomputable def Cslib.GenericRAM.ExhaustiveCountFallback.guardedTargetOfPolyTime {α β : Type} {ei : α ↪ List Bool} {eo : β ↪ List Bool} {ok : α → Bool} {f_fast f_exhaust f : α → β} (hok : Turing.MultiTapeTM.ComputableInPolyTime ok ei Turing.MultiTapeTM.encBool) (c_fast : NativeCertificate f_fast ei eo) (c_exhaust : NativeCertificate f_exhaust ei eo) (hfast : āˆ€ (x : α), ok x = true → f_fast x = f x) (hex : āˆ€ (x : α), ok x = false → f_exhaust x = f x) :

                    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
                      theorem Cslib.GenericRAM.ExhaustiveCountFallback.polyBounded_branch_space {α β : Type} {ei : α ↪ List Bool} {eo : β ↪ List Bool} {ok : α → Bool} {f_fast f_exhaust : α → β} (c_ok : NativeCertificate ok ei Turing.MultiTapeTM.encBool) (c_fast : NativeCertificate f_fast ei eo) (c_exhaust : NativeCertificate f_exhaust ei eo) (hok : Turing.MultiTapeTM.PolyBounded (fun (x : α) => (ei x).length) c_ok.space) (hfast : Turing.MultiTapeTM.PolyBounded (fun (x : α) => (ei x).length) c_fast.space) (hex : Turing.MultiTapeTM.PolyBounded (fun (x : α) => (ei x).length) c_exhaust.space) :
                      Turing.MultiTapeTM.PolyBounded (fun (x : α) => (ei x).length) (c_ok.branch c_fast c_exhaust).space

                      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).

                      theorem Cslib.GenericRAM.ExhaustiveCountFallback.exists_branch_time_le_of_finite_threshold {α β : Type} {ei : α ↪ List Bool} {eo : β ↪ List Bool} {ok : α → Bool} {f_fast f_exhaust : α → β} {μ P_ex Q_ex : α → ā„•} {Nā‚€ : ā„•} (c_ok : NativeCertificate ok ei Turing.MultiTapeTM.encBool) (c_fast : NativeCertificate f_fast ei eo) (c_exhaust : NativeCertificate f_exhaust ei eo) (hok : c_ok.IsPolynomial) (hs_fast : Turing.MultiTapeTM.PolyBounded (fun (x : α) => (ei x).length) c_fast.space) (hs_ex : Turing.MultiTapeTM.PolyBounded (fun (x : α) => (ei x).length) c_exhaust.space) (hthresh : āˆ€ (x : α), ok x = false → μ x < Nā‚€) (hP : Turing.MultiTapeTM.PolyBounded (fun (x : α) => (ei x).length) P_ex) (hQ : Turing.MultiTapeTM.PolyBounded (fun (x : α) => (ei x).length) Q_ex) (ht_ex : āˆ€ (x : α), ok x = false → c_exhaust.time x ≤ (2 ^ μ x + 1) * P_ex x + Q_ex x) :
                      Turing.MultiTapeTM.PolyBounded (fun (x : α) => (ei x).length) (c_ok.branch c_fast c_exhaust).space ∧ ∃ (C : ā„•) (d : ā„•), āˆ€ (x : α), (c_ok.branch c_fast c_exhaust).time x ≤ (if ok x = true then c_fast.time x else 0) + C * ((ei x).length + 1) ^ d

                      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.

                      theorem Cslib.GenericRAM.ExhaustiveCountFallback.computableInO_of_guarded_fallback {α β : Type} {ei : α ↪ List Bool} {eo : β ↪ List Bool} {ok : α → Bool} {f_fast f_exhaust f : α → β} {μ P_ex Q_ex T_fast : α → ā„•} {Nā‚€ : ā„•} (hok : Turing.MultiTapeTM.ComputableInPolyTime ok ei Turing.MultiTapeTM.encBool) (c_fast : NativeCertificate f_fast ei eo) (c_exhaust : NativeCertificate f_exhaust ei eo) (hfast_eq : āˆ€ (x : α), ok x = true → f_fast x = f x) (hex_eq : āˆ€ (x : α), ok x = false → f_exhaust x = f x) (hs_fast : Turing.MultiTapeTM.PolyBounded (fun (x : α) => (ei x).length) c_fast.space) (hs_ex : Turing.MultiTapeTM.PolyBounded (fun (x : α) => (ei x).length) c_exhaust.space) (hthresh : āˆ€ (x : α), ok x = false → μ x < Nā‚€) (hP : Turing.MultiTapeTM.PolyBounded (fun (x : α) => (ei x).length) P_ex) (hQ : Turing.MultiTapeTM.PolyBounded (fun (x : α) => (ei x).length) Q_ex) (ht_fast : āˆ€ (x : α), ok x = true → c_fast.time x ≤ T_fast x) (ht_ex : āˆ€ (x : α), ok x = false → c_exhaust.time x ≤ (2 ^ μ x + 1) * P_ex x + Q_ex x) :
                      ∃ (C : ā„•) (d : ā„•) (S : α → ā„•), Turing.MultiTapeTM.PolyBounded (fun (x : α) => (ei x).length) S ∧ Turing.MultiTapeTM.ComputableInO f ei eo (fun (x : α) => T_fast x + C * ((ei x).length + 1) ^ d) S

                      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.

                      theorem Cslib.GenericRAM.ExhaustiveCountFallback.exists_nat_exp_bound_of_guarded_fallback {α β : Type} {ei : α ↪ List Bool} {eo : β ↪ List Bool} {ok : α → Bool} {f_fast f_exhaust f : α → β} {μ P_ex Q_ex E : α → ā„•} {Nā‚€ C_f d_f : ā„•} (hok : Turing.MultiTapeTM.ComputableInPolyTime ok ei Turing.MultiTapeTM.encBool) (c_fast : NativeCertificate f_fast ei eo) (c_exhaust : NativeCertificate f_exhaust ei eo) (hfast_eq : āˆ€ (x : α), ok x = true → f_fast x = f x) (hex_eq : āˆ€ (x : α), ok x = false → f_exhaust x = f x) (hs_fast : Turing.MultiTapeTM.PolyBounded (fun (x : α) => (ei x).length) c_fast.space) (hs_ex : Turing.MultiTapeTM.PolyBounded (fun (x : α) => (ei x).length) c_exhaust.space) (hthresh : āˆ€ (x : α), ok x = false → μ x < Nā‚€) (hP : Turing.MultiTapeTM.PolyBounded (fun (x : α) => (ei x).length) P_ex) (hQ : Turing.MultiTapeTM.PolyBounded (fun (x : α) => (ei x).length) Q_ex) (ht_fast : āˆ€ (x : α), ok x = true → c_fast.time x ≤ C_f * ((ei x).length + 1) ^ d_f * 2 ^ E x) (ht_ex : āˆ€ (x : α), ok x = false → c_exhaust.time x ≤ (2 ^ μ x + 1) * P_ex x + Q_ex x) :
                      ∃ (C' : ā„•) (e : ā„•) (S : α → ā„•), Turing.MultiTapeTM.PolyBounded (fun (x : α) => (ei x).length) S ∧ (āˆ€ (x : α), (guardedTargetOfPolyTime hok c_fast c_exhaust hfast_eq hex_eq).time x ≤ C' * ((ei x).length + 1) ^ e * 2 ^ E x) ∧ Turing.MultiTapeTM.ComputableInO f ei eo (fun (x : α) => ((ei x).length + 1) ^ e * 2 ^ E x) S

                      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.

                      theorem Cslib.GenericRAM.ExhaustiveCountFallback.exists_real_exp_bound_of_guarded_fallback {α β : Type} {ei : α ↪ List Bool} {eo : β ↪ List Bool} {ok : α → Bool} {f_fast f_exhaust f : α → β} {μ P_ex Q_ex : α → ā„•} {E : α → ā„} {Nā‚€ C_f d_f : ā„•} (hok : Turing.MultiTapeTM.ComputableInPolyTime ok ei Turing.MultiTapeTM.encBool) (c_fast : NativeCertificate f_fast ei eo) (c_exhaust : NativeCertificate f_exhaust ei eo) (hfast_eq : āˆ€ (x : α), ok x = true → f_fast x = f x) (hex_eq : āˆ€ (x : α), ok x = false → f_exhaust x = f x) (hs_fast : Turing.MultiTapeTM.PolyBounded (fun (x : α) => (ei x).length) c_fast.space) (hs_ex : Turing.MultiTapeTM.PolyBounded (fun (x : α) => (ei x).length) c_exhaust.space) (hthresh : āˆ€ (x : α), ok x = false → μ x < Nā‚€) (hP : Turing.MultiTapeTM.PolyBounded (fun (x : α) => (ei x).length) P_ex) (hQ : Turing.MultiTapeTM.PolyBounded (fun (x : α) => (ei x).length) Q_ex) (hE : āˆ€ (x : α), 0 ≤ E x) (ht_fast : āˆ€ (x : α), ok x = true → ↑(c_fast.time x) ≤ ↑C_f * (↑(ei x).length + 1) ^ d_f * 2 ^ E x) (ht_ex : āˆ€ (x : α), ok x = false → c_exhaust.time x ≤ (2 ^ μ x + 1) * P_ex x + Q_ex x) :
                      ∃ (C' : ā„•) (e : ā„•) (S : α → ā„•), Turing.MultiTapeTM.PolyBounded (fun (x : α) => (ei x).length) S ∧ (āˆ€ (x : α), ↑((guardedTargetOfPolyTime hok c_fast c_exhaust hfast_eq hex_eq).time x) ≤ ↑C' * (↑(ei x).length + 1) ^ e * 2 ^ E x) ∧ Turing.MultiTapeTM.ComputableInO f ei eo (fun (x : α) => ((ei x).length + 1) ^ e * ⌈2 ^ E xāŒ‰ā‚Š) S

                      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āŒ‰ā‚Š.