A polynomial-space controller for an ordered bitstring fold #
A fixed-width binary counter and an accumulator suffice. The existing
initialized controller preserves the input, and SpaceIter supplies the
machine and its space account. No list of all candidates is stored.
Four fields: completion flag, answer flag, cursor, accumulator.
Equations
- Complexity.SpaceIter.BitstringFold.pack done answer cursor acc = Complexity.pair done (Complexity.pair answer (Complexity.pair cursor acc))
Instances For
The saved verdict, read by a total pair projection.
Instances For
The fixed-width candidate counter.
Equations
Instances For
The accumulator, which may be empty without emptying the encoded state.
Equations
Instances For
def
Complexity.SpaceIter.BitstringFold.step
(update : List Bool → List Bool → List Bool → List Bool)
(accept : List Bool → List Bool → Bool)
(x s : List Bool)
:
Process the current candidate, or publish the saved verdict after completion.
Equations
- One or more equations did not get rendered due to their size.
Instances For
def
Complexity.SpaceIter.BitstringFold.initial
(seed : List Bool → List Bool)
(accept : List Bool → List Bool → Bool)
(w : Polynomial ℕ)
(x : List Bool)
:
Begin with the zero candidate and the supplied seed.
Equations
- Complexity.SpaceIter.BitstringFold.initial seed accept w x = Complexity.SpaceIter.BitstringFold.pack [false] [accept x (seed x)] (Complexity.polyRuler w x) (seed x)
Instances For
def
Complexity.SpaceIter.BitstringFold.controller
(seed : List Bool → List Bool)
(update : List Bool → List Bool → List Bool → List Bool)
(accept : List Bool → List Bool → Bool)
(w : Polynomial ℕ)
:
Preserve the original input while initializing once and then folding.
Equations
- One or more equations did not get rendered due to their size.
Instances For
theorem
Complexity.SpaceIter.BitstringFold.orbit
(seed : List Bool → List Bool)
(update : List Bool → List Bool → List Bool → List Bool)
(accept : List Bool → List Bool → Bool)
(w : Polynomial ℕ)
(x : List Bool)
(i : ℕ)
:
i ≤ 2 ^ Polynomial.eval x.length w →
(step update accept x)^[i] (initial seed accept w x) = pack [decide (i = 2 ^ Polynomial.eval x.length w)]
[accept x (bitstringFoldPrefix (update x) (seed x) (Polynomial.eval x.length w) i)] (bumpBits^[i] (polyRuler w x))
(bitstringFoldPrefix (update x) (seed x) (Polynomial.eval x.length w) i)
The ordinary orbit computes each prefix, raising its flag exactly at the endpoint.
theorem
Complexity.SpaceIter.BitstringFold.orbit_final
(seed : List Bool → List Bool)
(update : List Bool → List Bool → List Bool → List Bool)
(accept : List Bool → List Bool → Bool)
(w : Polynomial ℕ)
(x : List Bool)
:
(step update accept x)^[2 ^ Polynomial.eval x.length w + 1] (initial seed accept w x) = pack [accept x (bitstringFold (update x) (seed x) (Polynomial.eval x.length w))]
[accept x (bitstringFold (update x) (seed x) (Polynomial.eval x.length w))]
(bumpBits^[2 ^ Polynomial.eval x.length w] (polyRuler w x))
(bitstringFold (update x) (seed x) (Polynomial.eval x.length w))
theorem
Complexity.SpaceIter.BitstringFold.step_mem_FP
{update : List Bool → List Bool → List Bool → List Bool}
{accept : List Bool → List Bool → Bool}
(hu : (fun (z : List Bool) => update (pairFst z) (pairFst (pairSnd z)) (pairSnd (pairSnd z))) ∈ FP)
(ha : (fun (z : List Bool) => [accept (pairFst z) (pairSnd z)]) ∈ FP)
{x s : List Bool → List Bool}
(hx : x ∈ FP)
(hs : s ∈ FP)
:
theorem
Complexity.SpaceIter.BitstringFold.controller_mem_FP
{seed : List Bool → List Bool}
{update : List Bool → List Bool → List Bool → List Bool}
{accept : List Bool → List Bool → Bool}
(w : Polynomial ℕ)
(hs : seed ∈ FP)
(hu : (fun (z : List Bool) => update (pairFst z) (pairFst (pairSnd z)) (pairSnd (pairSnd z))) ∈ FP)
(ha : (fun (z : List Bool) => [accept (pairFst z) (pairSnd z)]) ∈ FP)
:
theorem
Complexity.SpaceIter.BitstringFold.mem_PSPACE_internal
{seed : List Bool → List Bool}
{update : List Bool → List Bool → List Bool → List Bool}
{accept : List Bool → List Bool → Bool}
(w v : Polynomial ℕ)
(hs : seed ∈ FP)
(hu : (fun (z : List Bool) => update (pairFst z) (pairFst (pairSnd z)) (pairSnd (pairSnd z))) ∈ FP)
(ha : (fun (z : List Bool) => [accept (pairFst z) (pairSnd z)]) ∈ FP)
(hbound :
∀ (x : List Bool),
∀ i ≤ 2 ^ Polynomial.eval x.length w,
(bitstringFoldPrefix (update x) (seed x) (Polynomial.eval x.length w) i).length ≤ Polynomial.eval x.length v)
: