Documentation

CslibFrontier.Computability.Probabilistic.Time

Explicit-time intrinsically halting probabilistic realizations #

Cslib.Probability.ComputesInTimeOn input output t program asserts that one finite-control fair-coin machine realizes program across all inputs a within t a steps and has actually reached a halting state (final.tapes.state = none) on every supported execution at step t a.

Requiring actual halting rather than clock-cutoff fuel makes monotonicity in the step schedule (ComputesInTimeOn.mono) hold unconditionally for arbitrary functions t₁ ≤ t₂, without requiring t₂ to be computable, and makes sequential monadic composition (ComputesInTimeOn.bind) incur an explicit machine-independent step bound 2 * t₁ a + t₂' a + 4. Together with the clock compiler of CslibFrontier.Computability.Probabilistic.PPT.Clock, uniform strict polynomial time (IsPPTOn and IsPPT) is equivalent to ComputesInTimeOn / ComputesInTime under a polynomially bounded step schedule (isPPTOn_iff_exists_polyBounded_computesInTimeOn, isPPT_iff_exists_polyBounded_computesInTime).

Main definitions #

Main results #

References #

def Cslib.Probability.ComputesInTimeOn {α β : Type} (input : α ↪ List Bool) (output : β ↪ List Bool) (t : α → ℕ) (program : α → ProbComp β) :

One finite fair-coin machine realizes the encoded program within t a steps on every input a and has halted on every supported configuration at step t a.

def Cslib.Probability.ComputesInTime {β : Type} (output : β ↪ List Bool) (t : ℕ → ℕ → ℕ) (program : ℕ → List Bool → ProbComp β) :

Uniform halting fair-coin realization on a unary security parameter and auxiliary bit string, indexed by (n, aux.length).

theorem Cslib.Probability.ComputesInTimeOn.mono {α γ : Type} {input : α ↪ List Bool} {output : γ ↪ List Bool} {t₁ t₂ : α → ℕ} {program : α → ProbComp γ} (h : ComputesInTimeOn input output t₁ program) (hle : ∀ (a : α), t₁ a ≤ t₂ a) :
ComputesInTimeOn input output t₂ program

Enlarging the step schedule preserves halting realization, without requiring the larger schedule to be computable.

theorem Cslib.Probability.ComputesInTimeOn.congr {α γ : Type} {input : α ↪ List Bool} {output : γ ↪ List Bool} {t : α → ℕ} {program program' : α → ProbComp γ} (h : ComputesInTimeOn input output t program) (heq : ∀ (a : α), (program a).eval = (program' a).eval) :
ComputesInTimeOn input output t program'

Distributional equality preserves the realizing machine and step schedule.

theorem Cslib.Probability.ComputesInTimeOn.length_le {α γ : Type} {input : α ↪ List Bool} {output : γ ↪ List Bool} {t : α → ℕ} {program : α → ProbComp γ} (h : ComputesInTimeOn input output t program) (a : α) {result : γ} (hresult : result ∈ (program a).eval.support) :
(output result).length ≤ t a

Every supported encoded output has length at most the step budget t a.

Sampling one fair bit takes 1 step on any input encoding.

theorem Cslib.Probability.ComputesInTimeOn.bind {α β γ : Type} {input : α ↪ List Bool} {middle : β ↪ List Bool} {output : γ ↪ List Bool} {t₁ : α → ℕ} {first : α → ProbComp β} {second : β → ProbComp γ} {t₂ : β → ℕ} {t₂' : α → ℕ} (hfirst : ComputesInTimeOn input middle t₁ first) (hsecond : ComputesInTimeOn middle output t₂ second) (ht₂ : ∀ (a : α), ∀ b ∈ (first a).eval.support, t₂ b ≤ t₂' a) :
ComputesInTimeOn input output (fun (a : α) => 2 * t₁ a + t₂' a + 4) fun (a : α) => do let b ← first a second b

Sequence two halting probabilistic realizations, charging 2 * t₁ a + t₂' a + 4 steps where t₂' a upper-bounds t₂ across supported intermediate outputs of first a.

theorem Cslib.Probability.ComputesInTimeOn.isPPTOn {α γ : Type} {input : α ↪ List Bool} {output : γ ↪ List Bool} {t : α → ℕ} {program : α → ProbComp γ} (ht : Turing.MultiTapeTM.PolyBounded (fun (a : α) => (input a).length) t) (h : ComputesInTimeOn input output t program) :
IsPPTOn input output program

A polynomially bounded halting schedule gives a uniform strict PPT certificate.

theorem Cslib.Probability.computesInTimeOn_iff_encoded {α β : Type} {input : α ↪ List Bool} {output : β ↪ List Bool} {t : α → ℕ} {program : α → ProbComp β} :
ComputesInTimeOn input output t program ↔ ComputesInTimeOn input Turing.MultiTapeTM.encBits t fun (a : α) => ⇑output <$> program a

A program returning its declared encoding has the same explicit-time halting certificates.

theorem Turing.MultiTapeTM.ComputableInTimeAndSpace.computesInTimeOn {α β : Type} {input : α ↪ List Bool} {output : β ↪ List Bool} {f : α → β} {t s : α → ℕ} (h : ComputableInTimeAndSpace f input output t s) :
Cslib.Probability.ComputesInTimeOn input output t fun (a : α) => pure (f a)

Lift a plain deterministic time-and-space computation to a fair-coin halting realization with the exact same step bound t.

theorem Cslib.Probability.ComputesInTimeOn.preprocess {α β γ : Type} {input : α ↪ List Bool} {middle : β ↪ List Bool} {output : γ ↪ List Bool} {tp : β → ℕ} {tf sf : α → ℕ} {program : β → ProbComp γ} {prepare : α → β} (hprogram : ComputesInTimeOn middle output tp program) (hprepare : Turing.MultiTapeTM.ComputableInTimeAndSpace prepare input middle tf sf) :
ComputesInTimeOn input output (fun (a : α) => 2 * tf a + tp (prepare a) + 4) fun (a : α) => program (prepare a)

Deterministically prepare the input of an explicit-time halting probabilistic program.

theorem Cslib.Probability.ComputesInTimeOn.map {α β γ : Type} {input : α ↪ List Bool} {middle : β ↪ List Bool} {output : γ ↪ List Bool} {tp tf' : α → ℕ} {tf sf : β → ℕ} {program : α → ProbComp β} {f : β → γ} (hprogram : ComputesInTimeOn input middle tp program) (hf : Turing.MultiTapeTM.ComputableInTimeAndSpace f middle output tf sf) (htf : ∀ (a : α), ∀ b ∈ (program a).eval.support, tf b ≤ tf' a) :
ComputesInTimeOn input output (fun (a : α) => 2 * tp a + tf' a + 4) fun (a : α) => f <$> program a

Deterministically postprocess every sampled result of an explicit-time halting program.

theorem Cslib.Probability.ComputesInTimeOn.map_ofLength {α β γ : Type} {input : α ↪ List Bool} {middle : β ↪ List Bool} {output : γ ↪ List Bool} {tp : α → ℕ} {tf sf : ℕ → ℕ} {program : α → ProbComp β} {f : β → γ} (hprogram : ComputesInTimeOn input middle tp program) (hf : Turing.MultiTapeTM.ComputableInTimeAndSpaceOfLength f middle output tf sf) (hmono : Monotone tf) :
ComputesInTimeOn input output (fun (a : α) => 2 * tp a + tf (tp a) + 4) fun (a : α) => f <$> program a

Postprocess with a deterministic length-indexed bound under a monotone step function, using hprogram.length_le to bound the intermediate encoded word length by tp a.

theorem Cslib.Probability.isPPTOn_iff_exists_polyBounded_computesInTimeOn {α β : Type} {input : α ↪ List Bool} {output : β ↪ List Bool} {program : α → ProbComp β} :
IsPPTOn input output program ↔ ∃ (t : α → ℕ), Turing.MultiTapeTM.PolyBounded (fun (a : α) => (input a).length) t ∧ ComputesInTimeOn input output t program

Uniform strict PPT is equivalent to halting realization under a polynomially bounded step schedule. The forward direction compiles the clocked witness via IsPPTOn.exists_halting_machine; the backward direction pads the halting schedule via ComputesInTimeOn.mono.

theorem Cslib.Probability.ComputesInTime.on {β : Type} {output : β ↪ List Bool} {t : ℕ → ℕ → ℕ} {program : ℕ → List Bool → ProbComp β} (h : ComputesInTime output t program) :
ComputesInTimeOn (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits) output (fun (input : ℕ × List Bool) => t input.1 input.2.length) fun (input : ℕ × List Bool) => program input.1 input.2

Expose the underlying ComputesInTimeOn certificate on encPair encUnary encBits.

theorem Cslib.Probability.ComputesInTime.mono {β : Type} {output : β ↪ List Bool} {t₁ t₂ : ℕ → ℕ → ℕ} {program : ℕ → List Bool → ProbComp β} (h : ComputesInTime output t₁ program) (hle : ∀ (n m : ℕ), t₁ n m ≤ t₂ n m) :
ComputesInTime output t₂ program

Enlarging a parameterized step schedule preserves halting realization unconditionally.

theorem Cslib.Probability.ComputesInTime.congr {β : Type} {output : β ↪ List Bool} {t : ℕ → ℕ → ℕ} {program program' : ℕ → List Bool → ProbComp β} (h : ComputesInTime output t program) (heq : ∀ (n : ℕ) (aux : List Bool), (program n aux).eval = (program' n aux).eval) :
ComputesInTime output t program'

Distributional equality preserves parameterized halting realization.

theorem Cslib.Probability.ComputesInTime.length_le {β : Type} {output : β ↪ List Bool} {t : ℕ → ℕ → ℕ} {program : ℕ → List Bool → ProbComp β} (h : ComputesInTime output t program) (n : ℕ) (aux : List Bool) {result : β} (hresult : result ∈ (program n aux).eval.support) :
(output result).length ≤ t n aux.length

Every supported encoded output on (n, aux) has length at most t n aux.length.

theorem Cslib.Probability.ComputesInTime.isPPT {β : Type} {output : β ↪ List Bool} {t : ℕ → ℕ → ℕ} {program : ℕ → List Bool → ProbComp β} (ht : Turing.MultiTapeTM.PolyBounded (fun (p : ℕ × ℕ) => p.1 + p.2) (Function.uncurry t)) (h : ComputesInTime output t program) :
IsPPT output program

A polynomially bounded parameterized halting schedule gives IsPPT.

theorem Cslib.Probability.isPPT_iff_exists_polyBounded_computesInTime {β : Type} {output : β ↪ List Bool} {program : ℕ → List Bool → ProbComp β} :
IsPPT output program ↔ ∃ (t : ℕ → ℕ → ℕ), Turing.MultiTapeTM.PolyBounded (fun (p : ℕ × ℕ) => p.1 + p.2) (Function.uncurry t) ∧ ComputesInTime output t program

Parameterized uniform strict PPT is equivalent to ComputesInTime under a polynomially bounded schedule in n + aux.length.