Documentation

Complexity.Computability.Complexity.Classes.Oracle.Replay

Deterministic replay of Boolean oracle replies #

One transcript bit is assigned to every native instruction. A query installs that bit as its one-symbol reply; a local instruction ignores it. Thus replay requires no external oracle and is polynomial-time in the input and transcript lengths, including the construction of adaptive requests. The canonical transcript records the actual oracle reply at query instructions and false elsewhere. Replaying it recovers the complete coin-fixed configuration and output.

The replay* declarations here replay supplied oracle replies with the coin fixed to false. The saved-coin controller Turing.MultiTapePTM.replay in Complexity/Computability/Machines/Turing/MultiTape/Probabilistic/Replay.lean instead replays supplied random coins for a closed machine using an additional work tape.

Main definitions #

Main results #

References #

def Turing.MultiTapePTM.replyStep {k : ℕ} {Control Operation : Type} [DecidableEq Operation] (machine : MultiTapePTM k Bool Control Operation) (cfg : MultiTapeMachine.FiniteConfig k Bool Control Operation) (bit : Bool) :

Execute one native instruction, using bit only if that instruction makes a query.

Instances For
    def Turing.MultiTapePTM.replayFrom {k : ℕ} {Control Operation : Type} [DecidableEq Operation] (machine : MultiTapePTM k Bool Control Operation) (cfg : MultiTapeMachine.FiniteConfig k Bool Control Operation) (answers : List Bool) :

    Replay assigns one bit to every native instruction, including local and halted ones.

    Instances For
      def Turing.MultiTapePTM.replayConfig {k : ℕ} {Control Operation : Type} [DecidableEq Operation] (machine : MultiTapePTM k Bool Control Operation) (input answers : List Bool) :

      Replay the given instruction-indexed replies from the initial configuration.

      Instances For
        def Turing.MultiTapePTM.replayPrefix {k : ℕ} {Control Operation : Type} [DecidableEq Operation] (machine : MultiTapePTM k Bool Control Operation) (input answers : List Bool) (index : ℕ) :

        The configuration immediately before instruction index, or after the whole transcript if index exceeds its length.

        Instances For
          def Turing.MultiTapePTM.replayOutput {k : ℕ} {Control Operation : Type} [DecidableEq Operation] (machine : MultiTapePTM k Bool Control Operation) (input answers : List Bool) :

          The output tape after replaying the entire transcript.

          Instances For
            theorem Turing.MultiTapePTM.replyStep_pendingRequest {k : ℕ} {Control Operation : Type} [DecidableEq Operation] (machine : MultiTapePTM k Bool Control Operation) (g : List Bool → Bool) (cfg : MultiTapeMachine.FiniteConfig k Bool Control Operation) :
            machine.replyStep cfg (g (machine.pendingRequest cfg)) = machine.answerStep (fun (q : Operation × List Bool) => [g q.2]) cfg

            Supplying the answer to the pending request recovers an instruction against that oracle.

            theorem Turing.MultiTapePTM.replyStep_of_pendingQuery_eq_none {k : ℕ} {Control Operation : Type} [DecidableEq Operation] (machine : MultiTapePTM k Bool Control Operation) {cfg : MultiTapeMachine.FiniteConfig k Bool Control Operation} (h : machine.pendingQuery cfg = none) (bit : Bool) :
            machine.replyStep cfg bit = machine.localStep cfg

            A local instruction ignores its transcript bit.

            theorem Turing.MultiTapePTM.replayFrom_append {k : ℕ} {Control Operation : Type} [DecidableEq Operation] (machine : MultiTapePTM k Bool Control Operation) (cfg : MultiTapeMachine.FiniteConfig k Bool Control Operation) (first second : List Bool) :
            machine.replayFrom cfg (first ++ second) = machine.replayFrom (machine.replayFrom cfg first) second

            Replaying concatenated transcripts is sequential replay.

            theorem Turing.MultiTapePTM.replayPrefix_succ {k : ℕ} {Control Operation : Type} [DecidableEq Operation] (machine : MultiTapePTM k Bool Control Operation) (input answers : List Bool) (index : ℕ) (hindex : index < answers.length) :
            machine.replayPrefix input answers (index + 1) = machine.replyStep (machine.replayPrefix input answers index) answers[index]

            Advancing a transcript prefix executes its next bit, whenever that bit is present.

            theorem Turing.MultiTapePTM.length_pendingRequest_replayPrefix_le {k : ℕ} {Control Operation : Type} [DecidableEq Operation] (machine : MultiTapePTM k Bool Control Operation) (input answers : List Bool) (index : ℕ) :
            (machine.pendingRequest (machine.replayPrefix input answers index)).length ≤ min index answers.length

            A prefix query has at most min index answers.length symbols.

            theorem Turing.MultiTapePTM.replyStep_pt {k : ℕ} {Control Operation : Type} [DecidableEq Operation] (machine : MultiTapePTM k Bool Control Operation) [Finite Control] [Fintype Operation] :

            The next replay instruction is polynomial-time, uniformly in its reply bit.

            Deterministic oracle replay is polynomial-time in the encoded input and transcript.

            Prefix replay is jointly polynomial-time in input, transcript and unary instruction index.

            theorem Turing.MultiTapePTM.replayOutput_pt {k : ℕ} {Control Operation : Type} [DecidableEq Operation] (machine : MultiTapePTM k Bool Control Operation) [Finite Control] [Finite Operation] :

            The replayed output is polynomial-time.

            The next query in a guessed-reply execution is uniformly polynomial-time.

            Whether the next guessed-reply instruction is a query is uniformly polynomial-time.

            def Turing.MultiTapePTM.oracleRepliesFrom {k : ℕ} {Control Operation : Type} [DecidableEq Operation] (machine : MultiTapePTM k Bool Control Operation) (g : List Bool → Bool) :
            MultiTapeMachine.FiniteConfig k Bool Control Operation → ℕ → List Bool

            The instruction-indexed transcript of an oracle execution. Local and halted instructions receive the canonical padding bit false.

            Instances For
              def Turing.MultiTapePTM.oracleReplies {k : ℕ} {Control Operation : Type} [DecidableEq Operation] (machine : MultiTapePTM k Bool Control Operation) (g : List Bool → Bool) (fuel : ℕ) (input : List Bool) :

              The canonical transcript of a clocked execution from the initial configuration.

              Instances For
                theorem Turing.MultiTapePTM.length_oracleReplies {k : ℕ} {Control Operation : Type} [DecidableEq Operation] (machine : MultiTapePTM k Bool Control Operation) (g : List Bool → Bool) (fuel : ℕ) (input : List Bool) :
                (machine.oracleReplies g fuel input).length = fuel

                The initial canonical transcript has exactly the clock length.

                theorem Turing.MultiTapePTM.replayConfig_oracleReplies {k : ℕ} {Control Operation : Type} [DecidableEq Operation] (machine : MultiTapePTM k Bool Control Operation) (g : List Bool → Bool) (fuel : ℕ) (input : List Bool) :
                machine.replayConfig input (machine.oracleReplies g fuel input) = (machine.answerStep fun (q : Operation × List Bool) => [g q.2])^[fuel] (MultiTapeMachine.FiniteConfig.init machine.initial input)

                The canonical transcript replays the coin-fixed oracle run from its initial configuration.

                theorem Turing.MultiTapePTM.getD_oracleReplies {k : ℕ} {Control Operation : Type} [DecidableEq Operation] (machine : MultiTapePTM k Bool Control Operation) (g : List Bool → Bool) (fuel : ℕ) (input : List Bool) (index : ℕ) (hindex : index < fuel) :
                (machine.oracleReplies g fuel input).getD index false = have current := machine.replayPrefix input (machine.oracleReplies g fuel input) index; if (machine.pendingQuery current).isSome = true then g (machine.pendingRequest current) else false

                Canonical transcript bits agree with the queries seen by replay of their own prefix.

                theorem Turing.MultiTapePTM.replayOutput_oracleReplies {k : ℕ} {Control Operation : Type} [DecidableEq Operation] (machine : MultiTapePTM k Bool Control Operation) (g : List Bool → Bool) (fuel : ℕ) (input : List Bool) :
                machine.replayOutput input (machine.oracleReplies g fuel input) = Cslib.OracleComp.interpret (fun (q : Operation × List Bool) => [g q.2]) (machine.run (pure false) (fun (op : Operation) (word : List Bool) => Cslib.OracleComp.query (op, word)) fuel input)

                Replayed canonical outputs agree exactly with interpretation of the clocked oracle program.