Documentation

CslibFrontier.Computability.Probabilistic.Internal.Oracle.BinaryIteration

Binary-counter exponential iteration on fair-coin multitape machines #

Cslib.Probability.IsPPTOn.iterate_spec clocks bounded adaptive loops in polynomial time when the iteration count is computed in unary (encUnary). Exponential-time randomized algorithms such as Schöning's k-SAT walk instead repeat a polynomial-time step an exponential number of times while reusing polynomial workspace across restarts.

When the iteration count count : α → ℕ is computable in polynomial time in binary (encNat), (encNat (count a)).length is polynomial in (input a).length even when count a itself is exponential. Pairing a binary countdown counter with a polynomially bounded state and running clean phases inside Turing.MultiTapePTM.repeatUntilBlank produces one finite-control MultiTapePTM whose runs:

Main results #

Closed bridges and opaque two-phase composition #

Binary-counter exponential iteration #

theorem Cslib.Probability.IsPPTOn.exists_multiTapePTM_iterateWith_binary {α σ : Type} {input : α ↪ List Bool} {stateEncoding : σ ↪ List Bool} {initial : α → σ} {count : α → ℕ} {step : α → σ → ProbComp σ} (hcount : Turing.MultiTapeTM.ComputableInPolyTime count input Turing.MultiTapeTM.encNat) (hinitial : Turing.MultiTapeTM.ComputableInPolyTime initial input stateEncoding) (hstep : IsPPTOn (Turing.MultiTapeTM.encPair input stateEncoding) stateEncoding fun (pair : α × σ) => step pair.1 pair.2) (invariant : α → ℕ → σ → Prop) (hbase : ∀ (a : α), invariant a 0 (initial a)) (hpreserve : ∀ (a : α) (i : ℕ) (state : σ), i < count a → invariant a i state → ∀ next ∈ (step a state).eval.support, invariant a (i + 1) next) {size : α → ℕ} (hsize : Turing.MultiTapeTM.PolyBounded (fun (a : α) => (input a).length) size) (hbound : ∀ (a : α) (i : ℕ) (state : σ), i ≤ count a → invariant a i state → (stateEncoding state).length ≤ size a) :
(∃ (K : ℕ) (Control : Type) (_ : Finite Control) (machine : Turing.MultiTapePTM K Bool Control) (C : ℕ) (E : ℕ), ∀ (a : α), have T := C * ((count a + 1) * ((input a).length + 1) ^ E); have S := C * ((input a).length + 1) ^ E; (∀ final ∈ (machine.runClosedConfigFrom T (Turing.MultiTapeMachine.initialConfig machine (input a))).eval.support, final.tapes.state = none) ∧ (machine.runClosed T (input a)).eval = PMF.map (⇑stateEncoding) (ProbComp.eval (OracleComp.iterate (count a) (step a) (initial a))) ∧ machine.toNTM.RunsInSpace (input a) S) ∧ ∀ (a : α), ∀ state ∈ (ProbComp.eval (OracleComp.iterate (count a) (step a) (initial a))).support, invariant a (count a) state

Captured-input binary-counter iteration in polynomial workspace. The loop step may capture the original input a : α.

theorem Cslib.Probability.IsPPTOn.exists_multiTapePTM_iterate_binary {α σ : Type} {input : α ↪ List Bool} {stateEncoding : σ ↪ List Bool} {initial : α → σ} {count : α → ℕ} {step : σ → ProbComp σ} (hcount : Turing.MultiTapeTM.ComputableInPolyTime count input Turing.MultiTapeTM.encNat) (hinitial : Turing.MultiTapeTM.ComputableInPolyTime initial input stateEncoding) (hstep : IsPPTOn stateEncoding stateEncoding step) (invariant : α → ℕ → σ → Prop) (hbase : ∀ (a : α), invariant a 0 (initial a)) (hpreserve : ∀ (a : α) (i : ℕ) (state : σ), i < count a → invariant a i state → ∀ next ∈ (step state).eval.support, invariant a (i + 1) next) {size : α → ℕ} (hsize : Turing.MultiTapeTM.PolyBounded (fun (a : α) => (input a).length) size) (hbound : ∀ (a : α) (i : ℕ) (state : σ), i ≤ count a → invariant a i state → (stateEncoding state).length ≤ size a) :
(∃ (K : ℕ) (Control : Type) (_ : Finite Control) (machine : Turing.MultiTapePTM K Bool Control) (C : ℕ) (E : ℕ), ∀ (a : α), have T := C * ((count a + 1) * ((input a).length + 1) ^ E); have S := C * ((input a).length + 1) ^ E; (∀ final ∈ (machine.runClosedConfigFrom T (Turing.MultiTapeMachine.initialConfig machine (input a))).eval.support, final.tapes.state = none) ∧ (machine.runClosed T (input a)).eval = PMF.map (⇑stateEncoding) (ProbComp.eval (OracleComp.iterate (count a) step (initial a))) ∧ machine.toNTM.RunsInSpace (input a) S) ∧ ∀ (a : α), ∀ state ∈ (ProbComp.eval (OracleComp.iterate (count a) step (initial a))).support, invariant a (count a) state

Closed binary-counter iteration in polynomial workspace. If count : α → ℕ is computable in polynomial time in binary (encNat), initial is computable in polynomial time, step is strict PPT, and an invariant bounds the encoded size of every reachable state by a polynomial in |input a|, then one finite-control fair-coin MultiTapePTM halts on every branch within C * ((count a + 1) * ((input a).length + 1) ^ E) steps, realizes OracleComp.iterate (count a) step (initial a) under stateEncoding, and runs in polynomial workspace C * ((input a).length + 1) ^ E independent of count a.