Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Probabilistic.Replay.WithOracle

Saved-coin replay with external oracle channels #

The controller reads a saved coin into its finite control before executing the source instruction. This separates consuming the coin from a possible oracle call: a query cannot consume a second coin or reset the external handler's state. Communication channels retain their original meaning.

The controller uses a last work tape for the supplied bits. Preparing that tape and the ordinary input is a separate obligation in a full-input complexity certificate.

Main definitions #

Main results #

References #

An original oracle-preserving controller for the existing MultiTapePTM.runConfigFromCoins. It reuses the clock's auxiliary-tape operations and the common machine simulation rule.

@[reducible, inline]

An optional saved coin and the source state. none means the next phase reads the coin tape.

def Turing.MultiTapePTM.ReplayWithOracle.advance {k : ℕ} {State Oracle : Type} (next : Option (Control State)) (move : SignType) :
MultiTapeMachine.Action (k + 1) Bool (Control State) Oracle

Change replay control and move only the saved-coin head, leaving all channels untouched.

def Turing.MultiTapePTM.ReplayWithOracle.execute {k : ℕ} {State Oracle : Type} :
MultiTapeMachine.Action k Bool State Oracle → MultiTapeMachine.Action (k + 1) Bool (Control State) Oracle

Extend a source instruction to the saved-coin tape and return to the read phase. The instruction's query buffers and answer-head moves are retained verbatim.

def Turing.MultiTapePTM.replayWithOracle {k : ℕ} {State Oracle : Type} (machine : MultiTapePTM k Bool State Oracle) :

Replay each supplied bit in two phases: read and advance the coin tape, then execute one source instruction. The controller ignores its own private random bits.

theorem Turing.MultiTapePTM.ReplayWithOracle.run_two {k : ℕ} {State Oracle : Type} {input : List Bool} [DecidableEq Oracle] {Query : Type} {spec : Cslib.OracleSpec Query} (machine : MultiTapePTM k Bool State Oracle) (query : Oracle → List Bool → Cslib.OracleComp spec (List Bool)) (cfg : MultiTapeMachine.Config k Bool State Oracle input) (tape : ℤ → Option Bool) (position : ℤ) (bit : Bool) (hcell : tape position = some bit) :
machine.replayWithOracle.runConfigFrom (pure false) query 2 (MultiTapeMachine.AuxiliaryTape.config cfg tape position none) = (fun (final : MultiTapeMachine.Config k Bool State Oracle input) => MultiTapeMachine.AuxiliaryTape.config final tape (position + 1) none) <$> machine.runConfigFrom (pure bit) query 1 cfg

Two controller instructions consume one saved bit and perform exactly its source instruction, including any adaptive oracle query and reply. This is equality of programs, not just marginals.

theorem Turing.MultiTapePTM.ReplayWithOracle.run_stop {k : ℕ} {State Oracle : Type} {input : List Bool} [DecidableEq Oracle] {Query : Type} {spec : Cslib.OracleSpec Query} (machine : MultiTapePTM k Bool State Oracle) (query : Oracle → List Bool → Cslib.OracleComp spec (List Bool)) (cfg : MultiTapeMachine.Config k Bool State Oracle input) (tape : ℤ → Option Bool) (position : ℤ) (hcell : tape position = none) :

A blank saved-coin cell halts replay in one instruction, without calling an oracle.

theorem Turing.MultiTapePTM.ReplayWithOracle.run_coins {k : ℕ} {State Oracle : Type} {input : List Bool} [DecidableEq Oracle] {Query : Type} {spec : Cslib.OracleSpec Query} (machine : MultiTapePTM k Bool State Oracle) (query : Oracle → List Bool → Cslib.OracleComp spec (List Bool)) (cfg : MultiTapeMachine.Config k Bool State Oracle input) (coins : List Bool) (tape : ℤ → Option Bool) (position : ℤ) (hcoins : ∀ i < coins.length, tape (position + ↑i) = coins[i]?) (hstop : tape (position + ↑coins.length) = none) :
machine.replayWithOracle.runConfigFrom (pure false) query (2 * coins.length + 1) (MultiTapeMachine.AuxiliaryTape.config cfg tape position none) = (fun (final : MultiTapeMachine.Config k Bool State Oracle input) => MultiTapeMachine.AuxiliaryTape.stopped final tape (position + ↑coins.length)) <$> machine.runConfigFromCoins query coins cfg

Replay a stored sequence in 2 * coins.length + 1 transitions, including the final stop. The equality retains source tapes, heads, output, channels and oracle effects. The final controller is halted, so the source finite control is discarded.

theorem Turing.MultiTapePTM.ReplayWithOracle.run_coins_add {k : ℕ} {State Oracle : Type} {input : List Bool} [DecidableEq Oracle] {Query : Type} {spec : Cslib.OracleSpec Query} (machine : MultiTapePTM k Bool State Oracle) (query : Oracle → List Bool → Cslib.OracleComp spec (List Bool)) (cfg : MultiTapeMachine.Config k Bool State Oracle input) (coins : List Bool) (tape : ℤ → Option Bool) (position : ℤ) (padding : ℕ) (hcoins : ∀ i < coins.length, tape (position + ↑i) = coins[i]?) (hstop : tape (position + ↑coins.length) = none) :
machine.replayWithOracle.runConfigFrom (pure false) query (2 * coins.length + 1 + padding) (MultiTapeMachine.AuxiliaryTape.config cfg tape position none) = (fun (final : MultiTapeMachine.Config k Bool State Oracle input) => MultiTapeMachine.AuxiliaryTape.stopped final tape (position + ↑coins.length)) <$> machine.runConfigFromCoins query coins cfg

Padding after the saved-coin tape ends cannot change the data or cause another oracle call.

theorem Turing.MultiTapePTM.ReplayWithOracle.run_interpret_coin_independent {k : ℕ} {State Oracle : Type} {input : List Bool} [DecidableEq Oracle] {Query Store : Type} {spec : Cslib.OracleSpec Query} (machine : MultiTapePTM k Bool State Oracle) (coin : Cslib.OracleComp spec Bool) (query : Oracle → List Bool → Cslib.OracleComp spec (List Bool)) (oracle : (q : Query) → StateT Store PMF (spec q)) (coinLaw : PMF Bool) (hcoin : ∀ (s : Store), (Cslib.OracleComp.interpret oracle coin).run s = PMF.map (fun (bit : Bool) => (bit, s)) coinLaw) (fuel : ℕ) (cfg : MultiTapeMachine.Config (k + 1) Bool (Control State) Oracle input) (s : Store) :
(Cslib.OracleComp.interpret oracle (machine.replayWithOracle.runConfigFrom coin query fuel cfg)).run s = (Cslib.OracleComp.interpret oracle (machine.replayWithOracle.runConfigFrom (pure false) query fuel cfg)).run s

The controller's fresh private samples are ignored, so any stateless coin law agrees with constant private coins, retaining the full external state. The saved source coins are unchanged.