Documentation

CslibFrontier.Computability.Probabilistic.Internal.Oracle.Time

Internal machine constructions for explicit oracle time #

The quantitative halting contracts ComputesOracleInTimeOn and ComputesOracleInTime are re-exported by Oracle.Time; their closed/open lifts, buffered sequential machine composition oComp, halting conversions and joint-state proofs stay in this implementation module.

Private machine-level helpers #

Basic properties of ComputesOracleInTimeOn #

theorem Cslib.Probability.ComputesOracleInTimeOn.finite_operations {Operation α γ : Type} [DecidableEq Operation] {input : α ↪ List Bool} {output : γ ↪ List Bool} {t : α → ℕ} {program : α → WordOracleComp Operation γ} (h : ComputesOracleInTimeOn input output t program) :
Finite Operation

Finiteness of the operation channel type is part of the certificate.

theorem Cslib.Probability.ComputesOracleInTimeOn.mono {Operation α γ : Type} [DecidableEq Operation] {input : α ↪ List Bool} {output : γ ↪ List Bool} {t₁ t₂ : α → ℕ} {program : α → WordOracleComp Operation γ} (h : ComputesOracleInTimeOn input output t₁ program) (hle : ∀ (a : α), t₁ a ≤ t₂ a) :
ComputesOracleInTimeOn input output t₂ program

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

theorem Cslib.Probability.ComputesOracleInTimeOn.congr {Operation α γ : Type} [DecidableEq Operation] {input : α ↪ List Bool} {output : γ ↪ List Bool} {t : α → ℕ} {program program' : α → WordOracleComp Operation γ} (h : ComputesOracleInTimeOn input output t program) (heq : ∀ (a : α) (State : Type) (oracle : Operation × List Bool → StateT State PMF (List Bool)) (s : State), ProbOracleComp.runWith oracle (program a) s = ProbOracleComp.runWith oracle (program' a) s) :
ComputesOracleInTimeOn input output t program'

Equality of the complete joint output/state semantics preserves halting oracle realization.

theorem Cslib.Probability.ComputesOracleInTimeOn.length_le {Operation α γ : Type} [DecidableEq Operation] {input : α ↪ List Bool} {output : γ ↪ List Bool} {t : α → ℕ} {program : α → WordOracleComp Operation γ} (h : ComputesOracleInTimeOn input output t program) (a : α) {State : Type} (oracle : Operation × List Bool → StateT State PMF (List Bool)) (s s' : State) {result : γ} (hresult : (result, s') ∈ (ProbOracleComp.runWith oracle (program a) s).support) :
(output result).length ≤ t a

Every supported encoded output has length at most t a, regardless of oracle reply lengths.

theorem Cslib.Probability.ComputesOracleInTimeOn.query_bounds {Operation α γ : Type} [DecidableEq Operation] {input : α ↪ List Bool} {output : γ ↪ List Bool} {t : α → ℕ} {program : α → WordOracleComp Operation γ} (h : ComputesOracleInTimeOn input output t program) (a : α) :
ProbOracleComp.IsQueryBounded (program a) (t a) ∧ ProbOracleComp.QueriesSatisfy (fun (request : Operation × List Bool) => request.2.length ≤ t a) (program a)

Instrumenting the private oracle state with a transcript shows that program a makes at most t a external queries on every path, each of payload length at most t a.

theorem Cslib.Probability.ComputesOracleInTimeOn.isQueryBounded {Operation α γ : Type} [DecidableEq Operation] {input : α ↪ List Bool} {output : γ ↪ List Bool} {t : α → ℕ} {program : α → WordOracleComp Operation γ} (h : ComputesOracleInTimeOn input output t program) (a : α) :

Every execution path of program a makes at most t a external queries.

theorem Cslib.Probability.ComputesOracleInTimeOn.queriesSatisfy_length_le {Operation α γ : Type} [DecidableEq Operation] {input : α ↪ List Bool} {output : γ ↪ List Bool} {t : α → ℕ} {program : α → WordOracleComp Operation γ} (h : ComputesOracleInTimeOn input output t program) (a : α) :
ProbOracleComp.QueriesSatisfy (fun (request : Operation × List Bool) => request.2.length ≤ t a) (program a)

Every external query issued by program a has payload length at most t a.

theorem Cslib.Probability.ComputesOracleInTimeOn.computesOracleInTimeAndQueriesOn {Operation α γ : Type} [DecidableEq Operation] {input : α ↪ List Bool} {output : γ ↪ List Bool} {t : α → ℕ} {program : α → WordOracleComp Operation γ} (h : ComputesOracleInTimeOn input output t program) :
ComputesOracleInTimeAndQueriesOn input output t t program

A step-t oracle realization automatically satisfies the (t, t) time-and-query bound.

theorem Cslib.Probability.ComputesOracleInTimeOn.uniform_bool {Operation α : Type} [DecidableEq Operation] [Finite Operation] (input : α ↪ List Bool) :

Sampling one private fair bit takes 1 step and leaves every external oracle untouched.

One bounded-prefix external query (op, q) reading at most limit reply bits runs in 4 * q.length + 2 * limit + 6 steps.

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

Sequence a closed halting probabilistic computation ProbOracleComp.sample (first a) before any halting oracle continuation second, in 2 * t₁ a + t₂' a + 4 steps.

theorem Cslib.Probability.ComputesOracleInTimeOn.bind_sample_right {Operation α β γ : Type} [DecidableEq Operation] {input : α ↪ List Bool} {middle : β ↪ List Bool} {output : γ ↪ List Bool} {t₁ : α → ℕ} {first : α → WordOracleComp Operation β} {second : β → ProbComp γ} {t₂ : β → ℕ} {t₂' : α → ℕ} (hfirst : ComputesOracleInTimeOn input middle t₁ first) (hsecond : ComputesInTimeOn middle output t₂ second) (ht₂ : ∀ (a : α) (State : Type) (oracle : Operation × List Bool → StateT State PMF (List Bool)) (s s' : State) (b : β), (b, s') ∈ (ProbOracleComp.runWith oracle (first a) s).support → t₂ b ≤ t₂' a) :
ComputesOracleInTimeOn input output (fun (a : α) => 2 * t₁ a + t₂' a + 4) fun (a : α) => do let b ← first a ProbOracleComp.sample (second b)

Sequence a halting oracle computation first a before a closed halting continuation ProbOracleComp.sample (second b), in 2 * t₁ a + t₂' a + 4 steps.

theorem Cslib.Probability.ComputesOracleInTimeOn.isOraclePPTOn {Operation α γ : Type} [DecidableEq Operation] {input : α ↪ List Bool} {output : γ ↪ List Bool} {t : α → ℕ} {program : α → WordOracleComp Operation γ} (ht : Turing.MultiTapeTM.PolyBounded (fun (a : α) => (input a).length) t) (h : ComputesOracleInTimeOn input output t program) :
IsOraclePPTOn input output program

A polynomially bounded halting oracle schedule gives a strict IsOraclePPTOn certificate.

theorem Cslib.Probability.computesOracleInTimeOn_iff_encoded {Operation α β : Type} [DecidableEq Operation] {input : α ↪ List Bool} {output : β ↪ List Bool} {t : α → ℕ} {program : α → WordOracleComp Operation β} :
ComputesOracleInTimeOn input output t program ↔ ComputesOracleInTimeOn input Turing.MultiTapeTM.encBits t fun (a : α) => ⇑output <$> program a

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

theorem Cslib.Probability.ComputesInTimeOn.computesOracleInTimeOn {Operation α β : Type} [DecidableEq Operation] [Finite Operation] {input : α ↪ List Bool} {output : β ↪ List Bool} {t : α → ℕ} {program : α → ProbComp β} (h : ComputesInTimeOn input output t program) :
ComputesOracleInTimeOn input output t fun (a : α) => ProbOracleComp.sample (program a)

Lift a closed halting realization to an open oracle realization via ProbOracleComp.sample, preserving the exact step schedule t.

theorem Cslib.Probability.ComputesOracleInTimeOn.computesInTimeOn {α β : Type} {input : α ↪ List Bool} {output : β ↪ List Bool} {t : α → ℕ} {program : α → ProbComp β} (h : ComputesOracleInTimeOn input output t fun (a : α) => ProbOracleComp.sample (program a)) :
ComputesInTimeOn input output t program

A sampled closed program certified without external channels (Operation := Empty) is a closed halting realization with the exact same step schedule t.

theorem Turing.MultiTapeTM.ComputableInTimeAndSpace.computesOracleInTimeOn {Operation α β : Type} [DecidableEq Operation] [Finite Operation] {input : α ↪ List Bool} {output : β ↪ List Bool} {f : α → β} {t s : α → ℕ} (h : ComputableInTimeAndSpace f input output t s) :
Cslib.Probability.ComputesOracleInTimeOn input output t fun (a : α) => pure (f a)

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

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

Deterministically prepare the input of a halting oracle program in 2 * tf a + tp (prepare a) + 4 steps.

theorem Cslib.Probability.ComputesOracleInTimeOn.map {Operation α β γ : Type} [DecidableEq Operation] {input : α ↪ List Bool} {middle : β ↪ List Bool} {output : γ ↪ List Bool} {tp tf' : α → ℕ} {tf sf : β → ℕ} {program : α → WordOracleComp Operation β} {f : β → γ} (hprogram : ComputesOracleInTimeOn input middle tp program) (hf : Turing.MultiTapeTM.ComputableInTimeAndSpace f middle output tf sf) (htf : ∀ (a : α) (State : Type) (oracle : Operation × List Bool → StateT State PMF (List Bool)) (s s' : State) (b : β), (b, s') ∈ (ProbOracleComp.runWith oracle (program a) s).support → tf b ≤ tf' a) :
ComputesOracleInTimeOn input output (fun (a : α) => 2 * tp a + tf' a + 4) fun (a : α) => f <$> program a

Deterministically postprocess every result of a halting oracle program in 2 * tp a + tf' a + 4 steps.

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

Postprocess a halting oracle program with a deterministic length-indexed bound under a monotone step function, using hprogram.length_le to bound intermediate encoded words by tp a.

theorem Cslib.Probability.ComputesOracleInTimeOn.query_take {Operation α : Type} [DecidableEq Operation] [Finite Operation] (op : Operation) {input : α ↪ List Bool} {request : α → List Bool} {limit tf sf : α → ℕ} (hprepare : Turing.MultiTapeTM.ComputableInTimeAndSpace (fun (a : α) => (request a, limit a)) input (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encUnary) tf sf) :
ComputesOracleInTimeOn input Turing.MultiTapeTM.encBits (fun (a : α) => 2 * tf a + (4 * (request a).length + 2 * limit a + 6) + 4) fun (a : α) => List.take (limit a) <$> ProbOracleComp.query (op, request a)

Issue one bounded-prefix external query (op, request a) reading at most limit a reply bits, given a plain deterministic computation preparing (request a, limit a).

theorem Cslib.Probability.isOraclePPTOn_iff_exists_polyBounded_computesOracleInTimeOn {Operation α β : Type} [DecidableEq Operation] {input : α ↪ List Bool} {output : β ↪ List Bool} {program : α → WordOracleComp Operation β} :
IsOraclePPTOn input output program ↔ ∃ (t : α → ℕ), Turing.MultiTapeTM.PolyBounded (fun (a : α) => (input a).length) t ∧ ComputesOracleInTimeOn input output t program

Uniform strict oracle PPT is equivalent to halting oracle realization under a polynomially bounded step schedule. The forward direction normalizes any IsOraclePPTOn witness via IsOraclePPTOn.oraclePhase; the backward direction pads via ComputesOracleInTimeOn.mono.

Joint (t, q) properties and parameterized API #

theorem Cslib.Probability.ComputesOracleInTimeAndQueriesOn.mono {Operation α γ : Type} [DecidableEq Operation] {input : α ↪ List Bool} {output : γ ↪ List Bool} {t₁ t₂ q₁ q₂ : α → ℕ} {program : α → WordOracleComp Operation γ} (h : ComputesOracleInTimeAndQueriesOn input output t₁ q₁ program) (ht : ∀ (a : α), t₁ a ≤ t₂ a) (hq : ∀ (a : α), q₁ a ≤ q₂ a) :
ComputesOracleInTimeAndQueriesOn input output t₂ q₂ program

Monotonicity in both the step schedule and the query budget.

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

Deterministic preprocessing updates the step bound while preserving the query budget.

theorem Cslib.Probability.ComputesOracleInTimeAndQueriesOn.map {Operation α β γ : Type} [DecidableEq Operation] {input : α ↪ List Bool} {middle : β ↪ List Bool} {output : γ ↪ List Bool} {tp qp tf' : α → ℕ} {tf sf : β → ℕ} {program : α → WordOracleComp Operation β} {f : β → γ} (hprogram : ComputesOracleInTimeAndQueriesOn input middle tp qp program) (hf : Turing.MultiTapeTM.ComputableInTimeAndSpace f middle output tf sf) (htf : ∀ (a : α) (State : Type) (oracle : Operation × List Bool → StateT State PMF (List Bool)) (s s' : State) (b : β), (b, s') ∈ (ProbOracleComp.runWith oracle (program a) s).support → tf b ≤ tf' a) :
ComputesOracleInTimeAndQueriesOn input output (fun (a : α) => 2 * tp a + tf' a + 4) qp fun (a : α) => f <$> program a

Deterministic postprocessing updates the step bound while preserving the query budget q a.

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

Closed private sampling followed by an oracle continuation preserves the continuation's query budget bound q₂' a.

theorem Cslib.Probability.ComputesOracleInTimeAndQueriesOn.bind_sample_right {Operation α β γ : Type} [DecidableEq Operation] {input : α ↪ List Bool} {middle : β ↪ List Bool} {output : γ ↪ List Bool} {t₁ q₁ : α → ℕ} {first : α → WordOracleComp Operation β} {second : β → ProbComp γ} {t₂ : β → ℕ} {t₂' : α → ℕ} (hfirst : ComputesOracleInTimeAndQueriesOn input middle t₁ q₁ first) (hsecond : ComputesInTimeOn middle output t₂ second) (ht₂ : ∀ (a : α) (State : Type) (oracle : Operation × List Bool → StateT State PMF (List Bool)) (s s' : State) (b : β), (b, s') ∈ (ProbOracleComp.runWith oracle (first a) s).support → t₂ b ≤ t₂' a) :
ComputesOracleInTimeAndQueriesOn input output (fun (a : α) => 2 * t₁ a + t₂' a + 4) q₁ fun (a : α) => do let b ← first a ProbOracleComp.sample (second b)

An oracle computation followed by closed private postprocessing preserves the oracle computation's query budget q₁ a.

theorem Cslib.Probability.ComputesOracleInTime.on {Operation β : Type} [DecidableEq Operation] {output : β ↪ List Bool} {t : ℕ → ℕ → ℕ} {program : ℕ → List Bool → WordOracleComp Operation β} (h : ComputesOracleInTime output t program) :
ComputesOracleInTimeOn (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 ComputesOracleInTimeOn certificate on encPair encUnary encBits.

theorem Cslib.Probability.ComputesOracleInTime.mono {Operation β : Type} [DecidableEq Operation] {output : β ↪ List Bool} {t₁ t₂ : ℕ → ℕ → ℕ} {program : ℕ → List Bool → WordOracleComp Operation β} (h : ComputesOracleInTime output t₁ program) (hle : ∀ (n m : ℕ), t₁ n m ≤ t₂ n m) :
ComputesOracleInTime output t₂ program

Enlarging a parameterized step schedule preserves halting oracle realization unconditionally.

theorem Cslib.Probability.ComputesOracleInTime.congr {Operation β : Type} [DecidableEq Operation] {output : β ↪ List Bool} {t : ℕ → ℕ → ℕ} {program program' : ℕ → List Bool → WordOracleComp Operation β} (h : ComputesOracleInTime output t program) (heq : ∀ (n : ℕ) (aux : List Bool) (State : Type) (oracle : Operation × List Bool → StateT State PMF (List Bool)) (s : State), ProbOracleComp.runWith oracle (program n aux) s = ProbOracleComp.runWith oracle (program' n aux) s) :
ComputesOracleInTime output t program'

Equality of the complete joint output/state semantics preserves parameterized halting realization.

theorem Cslib.Probability.ComputesOracleInTime.isQueryBounded {Operation β : Type} [DecidableEq Operation] {output : β ↪ List Bool} {t : ℕ → ℕ → ℕ} {program : ℕ → List Bool → WordOracleComp Operation β} (h : ComputesOracleInTime output t program) (n : ℕ) (aux : List Bool) :
ProbOracleComp.IsQueryBounded (program n aux) (t n aux.length)

Every execution path of program n aux makes at most t n aux.length external queries.

theorem Cslib.Probability.ComputesOracleInTime.length_le {Operation β : Type} [DecidableEq Operation] {output : β ↪ List Bool} {t : ℕ → ℕ → ℕ} {program : ℕ → List Bool → WordOracleComp Operation β} (h : ComputesOracleInTime output t program) (n : ℕ) (aux : List Bool) {State : Type} (oracle : Operation × List Bool → StateT State PMF (List Bool)) (s s' : State) {result : β} (hresult : (result, s') ∈ (ProbOracleComp.runWith oracle (program n aux) s).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.ComputesOracleInTime.isOraclePPT {Operation β : Type} [DecidableEq Operation] {output : β ↪ List Bool} {t : ℕ → ℕ → ℕ} {program : ℕ → List Bool → WordOracleComp Operation β} (ht : Turing.MultiTapeTM.PolyBounded (fun (p : ℕ × ℕ) => p.1 + p.2) (Function.uncurry t)) (h : ComputesOracleInTime output t program) :
IsOraclePPT output program

A polynomially bounded parameterized halting oracle schedule gives IsOraclePPT.

theorem Cslib.Probability.isOraclePPT_iff_exists_polyBounded_computesOracleInTime {Operation β : Type} [DecidableEq Operation] {output : β ↪ List Bool} {program : ℕ → List Bool → WordOracleComp Operation β} :
IsOraclePPT output program ↔ ∃ (t : ℕ → ℕ → ℕ), Turing.MultiTapeTM.PolyBounded (fun (p : ℕ × ℕ) => p.1 + p.2) (Function.uncurry t) ∧ ComputesOracleInTime output t program

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

theorem Cslib.Probability.isOraclePPT_iff_exists_polyBounded_computesOracleInTimeAndQueries {Operation β : Type} [DecidableEq Operation] {output : β ↪ List Bool} {program : ℕ → List Bool → WordOracleComp Operation β} :
IsOraclePPT output program ↔ ∃ (t : ℕ → ℕ → ℕ) (q : ℕ → ℕ → ℕ), Turing.MultiTapeTM.PolyBounded (fun (p : ℕ × ℕ) => p.1 + p.2) (Function.uncurry t) ∧ Turing.MultiTapeTM.PolyBounded (fun (p : ℕ × ℕ) => p.1 + p.2) (Function.uncurry q) ∧ ComputesOracleInTimeAndQueries output t q program

Parameterized uniform strict oracle PPT is equivalent to ComputesOracleInTimeAndQueries under polynomially bounded time and query schedules.