Documentation

CslibFrontier.Computability.Complexity.Classes.CountingSimulation.Count

Exact counting before decision-class comparisons #

The counting simulation computes a natural number, not merely a verdict. This module exposes its exact padded acceptance counts and their joint deterministic time/workspace bounds. Polynomial-time comparisons are postprocessing of that count and its clock; decision-class containments are derived in CountingSimulation.Containments.

NetworkFamilies is the network-construction interface for all finite-state binary-choice machines. The explicit block networks discharge it. A contraction algorithm is still a hypothesis of the generic results here. Counts of padded choice strings are distinguished from native terminal-path counts: halted choice replays ignore remaining bits, while a terminal path is counted once. The latter is the convention of SharpTIME; its binary replay forces a unique zero continuation after each halt. The resulting exact counting theorem computes SharpTIME functions in binary within the same time scale and polynomial workspace.

Main definitions #

Main results #

def Cslib.Complexity.CountingSimulation.NetworkFamilies {N : Type} (encN : N ↪ List Bool) (value : N → ℕ) (Admissible : ℕ → ℕ → N → Prop) :

Network families for all machines: for every finite-state fair-coin machine, a network family (Cslib.Complexity.CountingSimulation.NetworkFamily) for its accept count Turing.MultiTapePTM.acceptCount. This is the hypothesis supplied by the block-counting step of #1833.

theorem Cslib.Complexity.CountingSimulation.exists_computableInTimeAndSpace_countWith {N : Type} {encN : N ↪ List Bool} {value : N → ℕ} {Admissible : ℕ → ℕ → N → Prop} {α : Type} {enc : α ↪ List Bool} {T : ℕ → ℕ} (hnet : NetworkFamilies encN value Admissible) (A : ContractionAlgorithm encN value Admissible) (hT : TimeConstructible T) (hTn : ∀ (n : ℕ), max n 2 ≤ T n) {k : ℕ} {State : Type} [Finite State] (M : Turing.MultiTapePTM k Bool State) {c : ℕ} (hc : 1 ≤ c) {β : Type} {encOut : β ↪ List Bool} {rule : ℕ × ℕ → β} (hrule : Turing.MultiTapeTM.ComputableInPolyTime rule (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encNat) encOut) :
∃ (C : ℕ) (d : ℕ), Turing.MultiTapeTM.ComputableInTimeAndSpace (fun (a : α) => rule (paddedTime (c * T (enc a).length), M.acceptCount (enc a) (paddedTime (c * T (enc a).length)))) enc encOut (fun (a : α) => 2 ^ (C * T (enc a).length / (Nat.log 2 (T (enc a).length)).sqrt)) fun (a : α) => T (enc a).length ^ d

Polynomial-time postprocessing of the exact accepting count, with the padded clock in unary, preserves the counting simulation's time scale and polynomial workspace.

theorem Cslib.Complexity.CountingSimulation.exists_computableInTimeAndSpace_acceptCount {N : Type} {encN : N ↪ List Bool} {value : N → ℕ} {Admissible : ℕ → ℕ → N → Prop} {α : Type} {enc : α ↪ List Bool} {T : ℕ → ℕ} (hnet : NetworkFamilies encN value Admissible) (A : ContractionAlgorithm encN value Admissible) (hT : TimeConstructible T) (hTn : ∀ (n : ℕ), max n 2 ≤ T n) {k : ℕ} {State : Type} [Finite State] (M : Turing.MultiTapePTM k Bool State) {c : ℕ} (hc : 1 ≤ c) :
∃ (C : ℕ) (d : ℕ), Turing.MultiTapeTM.ComputableInTimeAndSpace (fun (a : α) => M.acceptCount (enc a) (paddedTime (c * T (enc a).length))) enc Turing.MultiTapeTM.encNat (fun (a : α) => 2 ^ (C * T (enc a).length / (Nat.log 2 (T (enc a).length)).sqrt)) fun (a : α) => T (enc a).length ^ d

The accepting choice strings at the padded clock are counted exactly, with binary output, by one deterministic machine carrying both the subexponential time and polynomial-space bounds.

theorem Cslib.Complexity.CountingSimulation.exists_computableInTimeAndSpace_of_mem_SharpTIME {N : Type} {encN : N ↪ List Bool} {value : N → ℕ} {Admissible : ℕ → ℕ → N → Prop} {α : Type} {enc : α ↪ List Bool} {T : ℕ → ℕ} (hnet : NetworkFamilies encN value Admissible) (A : ContractionAlgorithm encN value Admissible) (hT : TimeConstructible T) (hTn : ∀ (n : ℕ), max n 2 ≤ T n) {f : α → ℕ} (hf : f ∈ SharpTIME enc T) :
∃ (C : ℕ) (d : ℕ), Turing.MultiTapeTM.ComputableInTimeAndSpace f enc Turing.MultiTapeTM.encNat (fun (a : α) => 2 ^ (C * T (enc a).length / (Nat.log 2 (T (enc a).length)).sqrt)) fun (a : α) => T (enc a).length ^ d

Exact terminal-path counting inherits the counting simulation's subexponential time and polynomial workspace. The binary replay chooses transition occurrences parsimoniously and forces zero padding after a native halt, so no post-halting multiplicity is introduced.

theorem Cslib.Complexity.CountingSimulation.SharpTIME_subset_iUnion_FTIME {N : Type} {encN : N ↪ List Bool} {value : N → ℕ} {Admissible : ℕ → ℕ → N → Prop} {α : Type} {enc : α ↪ List Bool} {T : ℕ → ℕ} (hnet : NetworkFamilies encN value Admissible) (A : ContractionAlgorithm encN value Admissible) (hT : TimeConstructible T) (hTn : ∀ (n : ℕ), max n 2 ≤ T n) :
SharpTIME enc T ⊆ ⋃ (C : ℕ), FTIME enc Turing.MultiTapeTM.encNat fun (n : ℕ) => 2 ^ (C * T n / (Nat.log 2 (T n)).sqrt)

The functional counting counterpart of the decision-class simulations: every terminal-path counter in #TIME(T) has binary output in FTIME(2^(C T / √log T)) for some constant C.