Documentation

CslibFrontier.Computability.Complexity.Classes.CountingSimulation.Assembly

The deterministic counting simulation, assembled from its interfaces #

This module assembles the deterministic simulation of #1833 from the two interfaces of Cslib.Complexity.CountingSimulation.NetworkFamily and Cslib.Complexity.CountingSimulation.ContractionAlgorithm. It is conditional: every result here assumes a network family and a contraction algorithm, which are proved separately.

On an input x with clock t, the simulation (Cslib.Complexity.CountingSimulation.simulate) visits the scheduleCount heads t movement schedules one at a time, contracts the network of each modulo 2 ^ (paddedTime t + 1), and adds the residues modulo the same power of two (Cslib.Complexity.CountingSimulation.modSum). Since the count is at most 2 ^ (paddedTime t), the residue of the sum is the count itself (Cslib.Complexity.CountingSimulation.simulate_eq).

Its cost is the number of schedules times the cost of one network, and its workspace that of one network and an accumulator (Cslib.Complexity.CountingSimulation.exists_computableInO_simulate). With the clock t = c * T n of a time-constructible T n ≥ max n 2, the schedules number 3 ^ O(T / log T), so the total time is 2 ^ O(T / √(log T)) in the natural-number scale of Nat.exists_three_pow_mul_le_two_pow_div_sqrt_log_two, and the space is polynomial in T (Cslib.Complexity.CountingSimulation.exists_computableInO_count). The counting core first returns the exact count and its padded clock (Cslib.Complexity.CountingSimulation.exists_computableInO_countPair). Polynomial-time postprocessing, including the comparisons deciding acceptance, is derived from that core by Cslib.Complexity.CountingSimulation.exists_computableInO_countWith.

Main definitions #

Main results #

The algorithm and its correctness #

def Cslib.Complexity.CountingSimulation.scheduleResidue {N : Type} {encN : N ↪ List Bool} {value : N → ℕ} {Admissible : ℕ → ℕ → N → Prop} {count : List Bool → ℕ → ℕ} (F : NetworkFamily encN value Admissible count) (p : (List Bool × ℕ) × ℕ) :

The value of the network of the schedule p.2 for the input p.1.1 and the clock p.1.2, modulo 2 ^ (paddedTime p.1.2 + 1).

def Cslib.Complexity.CountingSimulation.simulate {N : Type} {encN : N ↪ List Bool} {value : N → ℕ} {Admissible : ℕ → ℕ → N → Prop} {count : List Bool → ℕ → ℕ} (F : NetworkFamily encN value Admissible count) (p : List Bool × ℕ) :

The simulation on the input p.1 with the clock p.2: when |p.1| ≤ p.2 and 2 ≤ p.2, the residues of the networks of all schedules, summed one at a time modulo 2 ^ (paddedTime p.2 + 1); otherwise 0.

theorem Cslib.Complexity.CountingSimulation.simulate_eq {N : Type} {encN : N ↪ List Bool} {value : N → ℕ} {Admissible : ℕ → ℕ → N → Prop} {count : List Bool → ℕ → ℕ} (F : NetworkFamily encN value Admissible count) {x : List Bool} {t : ℕ} (hx : x.length ≤ t) (ht : 2 ≤ t) (hcount : count x (paddedTime t) ≤ 2 ^ paddedTime t) :
simulate F (x, t) = count x (paddedTime t)

The simulation computes the count: when |x| ≤ t and 2 ≤ t, and the count at the padded time is at most 2 ^ paddedTime t, the residue of the sum of the network values modulo 2 ^ (paddedTime t + 1) is the count itself.

Polynomial-time parameters #

Resource bounds #

theorem Cslib.Complexity.CountingSimulation.exists_computableInO_simulate {N : Type} {encN : N ↪ List Bool} {value : N → ℕ} {Admissible : ℕ → ℕ → N → Prop} {count : List Bool → ℕ → ℕ} (F : NetworkFamily encN value Admissible count) (A : ContractionAlgorithm encN value Admissible) :

Time and space of the simulation (conditional on the interfaces). For a constant k, the simulation on an input x with clock t runs within time k * (|x| + t + 1) ^ k * scheduleCount heads t * 2 ^ (k * t / √⌊log₂ t⌋) and space k * (|x| + t + 1) ^ k: it contracts one network per schedule, keeping one network, its contraction workspace and an accumulator.

theorem Cslib.Complexity.CountingSimulation.exists_computableInO_countPair {N : Type} {encN : N ↪ List Bool} {value : N → ℕ} {Admissible : ℕ → ℕ → N → Prop} {count : List Bool → ℕ → ℕ} (F : NetworkFamily encN value Admissible count) (A : ContractionAlgorithm encN value Admissible) (hcount : ∀ (x : List Bool) (τ : ℕ), count x τ ≤ 2 ^ τ) {T : ℕ → ℕ} (hT : TimeConstructible T) (hTn : ∀ (n : ℕ), max n 2 ≤ T n) {c : ℕ} (hc : 1 ≤ c) :

Exact counting within time 2 ^ O(T / √(log T)) and polynomial space (conditional on both interfaces). The result contains the padded clock in unary and the exact count in binary. No decision rule or postprocessing function is part of this theorem.

theorem Cslib.Complexity.CountingSimulation.exists_computableInO_countWith {N : Type} {encN : N ↪ List Bool} {value : N → ℕ} {Admissible : ℕ → ℕ → N → Prop} {count : List Bool → ℕ → ℕ} (F : NetworkFamily encN value Admissible count) (A : ContractionAlgorithm encN value Admissible) (hcount : ∀ (x : List Bool) (τ : ℕ), count x τ ≤ 2 ^ τ) {T : ℕ → ℕ} (hT : TimeConstructible T) (hTn : ∀ (n : ℕ), max n 2 ≤ T n) {c : ℕ} (hc : 1 ≤ c) {β : Type} {encβ : β ↪ List Bool} {rule : ℕ × ℕ → β} (hrule : Turing.MultiTapeTM.ComputableInPolyTime rule (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encNat) encβ) :
∃ (C : ℕ) (d : ℕ), Turing.MultiTapeTM.ComputableInO (fun (x : List Bool) => rule (paddedTime (c * T x.length), count x (paddedTime (c * T x.length)))) Turing.MultiTapeTM.encBits encβ (fun (x : List Bool) => 2 ^ (C * T x.length / (Nat.log 2 (T x.length)).sqrt)) fun (x : List Bool) => T x.length ^ d

Any polynomial-time function of the exact count and its padded clock has the same subexponential time and polynomial-space scale. This is postprocessing of exists_computableInO_countPair, rather than an additional counting algorithm.

theorem Cslib.Complexity.CountingSimulation.exists_computableInO_count {N : Type} {encN : N ↪ List Bool} {value : N → ℕ} {Admissible : ℕ → ℕ → N → Prop} {count : List Bool → ℕ → ℕ} (F : NetworkFamily encN value Admissible count) (A : ContractionAlgorithm encN value Admissible) (hcount : ∀ (x : List Bool) (τ : ℕ), count x τ ≤ 2 ^ τ) {T : ℕ → ℕ} (hT : TimeConstructible T) (hTn : ∀ (n : ℕ), max n 2 ≤ T n) {c : ℕ} (hc : 1 ≤ c) :
∃ (C : ℕ) (d : ℕ), Turing.MultiTapeTM.ComputableInO (fun (x : List Bool) => count x (paddedTime (c * T x.length))) Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encNat (fun (x : List Bool) => 2 ^ (C * T x.length / (Nat.log 2 (T x.length)).sqrt)) fun (x : List Bool) => T x.length ^ d

The exact count at the padded clock, with binary output, inherits the counting core's subexponential time and polynomial workspace.