Documentation

Complexitylib.Circuits.Encoding.Machine.Core.Internal.Execution

Execution seams for the streaming circuit evaluator #

The evaluator has three semantically named work tapes, while Cfg exposes work tapes through Fin 3. This file packages that representation boundary once. Later phase proofs can state exact configurations using named tape arguments and reduce one machine step to the corresponding named CoreAction, without reopening the finite-index projection plumbing.

Work-tape family assembled from the evaluator's three named tapes.

Equations
  • One or more equations did not get rendered due to their size.
Instances For

    Symbols read from the evaluator's three named work tapes.

    Equations
    Instances For

      Exact evaluator configuration with named work-tape arguments.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        @[simp]
        theorem Complexity.CircuitCode.Machine.Internal.coreWork_codeIdx (code wires counter : Tape) :
        coreWork code wires counter codeIdx = code

        Project the code tape from a named evaluator work family.

        @[simp]
        theorem Complexity.CircuitCode.Machine.Internal.coreWork_wiresIdx (code wires counter : Tape) :
        coreWork code wires counter wiresIdx = wires

        Project the wire tape from a named evaluator work family.

        @[simp]
        theorem Complexity.CircuitCode.Machine.Internal.coreWork_counterIdx (code wires counter : Tape) :
        coreWork code wires counter counterIdx = counter

        Project the counter tape from a named evaluator work family.

        @[simp]
        theorem Complexity.CircuitCode.Machine.Internal.coreHeads_codeIdx (code wires counter : Tape) :
        coreHeads code wires counter codeIdx = code.read

        Project the code-head symbol from the named evaluator heads.

        @[simp]
        theorem Complexity.CircuitCode.Machine.Internal.coreHeads_wiresIdx (code wires counter : Tape) :
        coreHeads code wires counter wiresIdx = wires.read

        Project the wire-head symbol from the named evaluator heads.

        @[simp]
        theorem Complexity.CircuitCode.Machine.Internal.coreHeads_counterIdx (code wires counter : Tape) :
        coreHeads code wires counter counterIdx = counter.read

        Project the counter-head symbol from the named evaluator heads.

        Reassembling all three named tapes recovers an arbitrary evaluator work family.

        Reassembling the named fields of a configuration recovers the original configuration.

        theorem Complexity.CircuitCode.Machine.Internal.outputWriteBool_frame (value : Bool) (output : Tape) (hhead : output.head = 1) (hinvariant : output.StartInvariant) :
        (output.write (Γ.ofBool value)).head = 1 (output.write (Γ.ofBool value)).StartInvariant (output.write (Γ.ofBool value)).cells 1 = Γ.ofBool value

        Writing a Boolean verdict at output cell one preserves its parked head and left-marker invariant and records the exact verdict cell.

        theorem Complexity.CircuitCode.Machine.Internal.outputWriteZero_frame (output : Tape) (hhead : output.head = 1) (hinvariant : output.StartInvariant) :

        Zero-verdict specialization of outputWriteBool_frame, matching every controller rejection action.

        theorem Complexity.CircuitCode.Machine.Internal.binaryCursor_of_hasUnaryPrefix {counter : Tape} {count : } (hcounter : counter.HasUnaryPrefix count) (hcounter0 : counter.cells 0 = Γ.start) :
        BinaryCursor counter (List.replicate count true) count

        A unary-prefix counter with its canonical left marker is the corresponding binary cursor over true bits at its append frontier.

        theorem Complexity.CircuitCode.Machine.Internal.hasUnaryCounter_of_binaryCursor {counter : Tape} {count : } (hcounter : BinaryCursor counter (List.replicate count true) 0) :
        counter.HasUnaryCounter count

        A rewound binary cursor of true bits is the public unary-counter shape.

        theorem Complexity.CircuitCode.Machine.Internal.coreCfg_step (phase : CorePhase) (input code wires counter output : Tape) (hphase : phase CorePhase.done) :
        evalFamilyCoreTM.step (coreCfg phase input code wires counter output) = have action := coreAction phase (coreHeads code wires counter) output.read; some (coreCfg action.next (input.move (TM.idleDir input.read)) (code.writeAndMove action.code.write.toΓ action.code.dir) (wires.writeAndMove action.wires.write.toΓ action.wires.dir) (counter.writeAndMove action.counter.write.toΓ action.counter.dir) (output.writeAndMove action.output.write.toΓ action.output.dir))

        One evaluator step on a named configuration applies the four named tape actions directly. This is the representation seam used by every phase proof.

        theorem Complexity.CircuitCode.Machine.Internal.coreCfg_step_reject (phase : CorePhase) (input code wires counter output : Tape) (hphase : phase CorePhase.done) (haction : coreAction phase (coreHeads code wires counter) output.read = CoreAction.reject (coreHeads code wires counter) output.read) (hinput : input.read Γ.start) (hcode : code.read Γ.start) (hwires : wires.read Γ.start) (hcounter : counter.read Γ.start) (houtput : output.read Γ.start) :
        evalFamilyCoreTM.step (coreCfg phase input code wires counter output) = some (coreCfg CorePhase.done input code wires counter (output.write Γ.zero))

        Any controller branch selecting CoreAction.reject halts in one step, writes zero at the current output head, and preserves the named work tapes.

        theorem Complexity.CircuitCode.Machine.Internal.rewindCode_step_cursor {bits : List Bool} {position : } (input code wires counter output : Tape) (hcode : BinaryCursor code bits position) (hinput : input.read Γ.start) (hwires : wires.read Γ.start) (hcounter : counter.read Γ.start) (houtput : output.read Γ.start) :
        evalFamilyCoreTM.step (coreCfg CorePhase.rewindCode input code wires counter output) = some (coreCfg CorePhase.rewindCode input (code.move Dir3.left) wires counter output)

        In the code-rewind phase, an off-marker code cursor takes one ordinary left step while every framed tape remains unchanged.

        theorem Complexity.CircuitCode.Machine.Internal.rewindCode_step_marker {bits : List Bool} (input code wires counter output : Tape) (hcode : BinaryAtMarker code bits) (hinput : input.read Γ.start) (hwires : wires.read Γ.start) (hcounter : counter.read Γ.start) (houtput : output.read Γ.start) :
        evalFamilyCoreTM.step (coreCfg CorePhase.rewindCode input code wires counter output) = some (coreCfg CorePhase.rewindWires input (code.move Dir3.right) wires counter output)

        On the left marker, the code rewind bounces to the first code bit and hands control to the wire-rewind phase.

        theorem Complexity.CircuitCode.Machine.Internal.rewindCode_run {bits : List Bool} {position : } (input code wires counter output : Tape) (hcode : BinaryCursor code bits position) (hinput : input.read Γ.start) (hwires : wires.read Γ.start) (hcounter : counter.read Γ.start) (houtput : output.read Γ.start) :
        ∃ (code' : Tape), evalFamilyCoreTM.reachesIn (position + 2) (coreCfg CorePhase.rewindCode input code wires counter output) (coreCfg CorePhase.rewindWires input code' wires counter output) BinaryCursor code' bits 0

        Rewinding a code cursor takes exactly position + 2 steps and enters the wire-rewind phase with the code head on its first bit.

        theorem Complexity.CircuitCode.Machine.Internal.rewindWires_step_cursor {bits : List Bool} {position : } (input code wires counter output : Tape) (hwires : BinaryCursor wires bits position) (hinput : input.read Γ.start) (hcode : code.read Γ.start) (hcounter : counter.read Γ.start) (houtput : output.read Γ.start) :
        evalFamilyCoreTM.step (coreCfg CorePhase.rewindWires input code wires counter output) = some (coreCfg CorePhase.rewindWires input code (wires.move Dir3.left) counter output)

        In the wire-rewind phase, an off-marker wire cursor takes one ordinary left step while every framed tape remains unchanged.

        theorem Complexity.CircuitCode.Machine.Internal.rewindWires_step_marker {bits : List Bool} (input code wires counter output : Tape) (hwires : BinaryAtMarker wires bits) (hinput : input.read Γ.start) (hcode : code.read Γ.start) (hcounter : counter.read Γ.start) (houtput : output.read Γ.start) :
        evalFamilyCoreTM.step (coreCfg CorePhase.rewindWires input code wires counter output) = some (coreCfg CorePhase.familyTag input code (wires.move Dir3.right) counter output)

        On the left marker, the wire rewind bounces to the first wire and enters the family-tag phase.

        theorem Complexity.CircuitCode.Machine.Internal.rewindWires_run {bits : List Bool} {position : } (input code wires counter output : Tape) (hwires : BinaryCursor wires bits position) (hinput : input.read Γ.start) (hcode : code.read Γ.start) (hcounter : counter.read Γ.start) (houtput : output.read Γ.start) :
        ∃ (wires' : Tape), evalFamilyCoreTM.reachesIn (position + 2) (coreCfg CorePhase.rewindWires input code wires counter output) (coreCfg CorePhase.familyTag input code wires' counter output) BinaryCursor wires' bits 0

        Rewinding a wire cursor takes exactly position + 2 steps and enters the family-tag phase with the wire head on its first bit.

        theorem Complexity.CircuitCode.Machine.Internal.initialRewinds_run (codeBits inputBits : List Bool) (input code wires counter output : Tape) (hcode : BinaryCursor code codeBits codeBits.length) (hwires : BinaryCursor wires inputBits inputBits.length) (hinput : input.read Γ.start) (hcounter : counter.read Γ.start) (houtput : output.read Γ.start) :
        ∃ (code' : Tape) (wires' : Tape), evalFamilyCoreTM.reachesIn (codeBits.length + inputBits.length + 4) (coreCfg CorePhase.rewindCode input code wires counter output) (coreCfg CorePhase.familyTag input code' wires' counter output) BinaryCursor code' codeBits 0 BinaryCursor wires' inputBits 0

        From the two staged append frontiers, the evaluator reaches its first family-tag read in exactly code.length + input.length + 4 steps, retaining both canonical tape contents.

        theorem Complexity.CircuitCode.Machine.Internal.familyTag_step_empty (rest : List Bool) (input code wires counter output : Tape) (hcode : BinaryCursor code (false :: rest) 0) (hwires : BinaryCursor wires [] 0) (hinput : input.read Γ.start) (hcounter : counter.read Γ.start) (houtput : output.read Γ.start) :
        evalFamilyCoreTM.step (coreCfg CorePhase.familyTag input code wires counter output) = some (coreCfg CorePhase.emptyAnswer input (code.move Dir3.right) wires counter output)

        An empty-input family tagged with zero enters the explicit empty-answer branch and advances past the tag.

        theorem Complexity.CircuitCode.Machine.Internal.familyTag_step_positive (circuitCode inputRest : List Bool) (input code wires counter output : Tape) (bit : Bool) (hcode : BinaryCursor code (true :: circuitCode) 0) (hwires : BinaryCursor wires (bit :: inputRest) 0) (hinput : input.read Γ.start) (hcounter : counter.read Γ.start) (houtput : output.read Γ.start) :
        evalFamilyCoreTM.step (coreCfg CorePhase.familyTag input code wires counter output) = some (coreCfg CorePhase.count input (code.move Dir3.right) wires counter output)

        A nonempty input paired with a positive-family tag enters the unary gate count phase and advances past the tag.

        theorem Complexity.CircuitCode.Machine.Internal.count_step_one (rest : List Bool) (used : ) (input code wires counter output : Tape) (hcode : code.HasBinarySuffix (true :: rest)) (hcounter : counter.HasUnaryPrefix used) (hinput : input.read Γ.start) (hwires : wires.read Γ.start) (houtput : output.read Γ.start) :
        evalFamilyCoreTM.step (coreCfg CorePhase.count input code wires counter output) = some (coreCfg CorePhase.count input (code.move Dir3.right) wires (counter.writeAndMove Γ.one Dir3.right) output)

        Reading one unary gate-count mark advances the code cursor and extends the counter by one mark.

        theorem Complexity.CircuitCode.Machine.Internal.count_step_zero (rest : List Bool) (used : ) (input code wires counter output : Tape) (hcode : code.HasBinarySuffix (false :: rest)) (hcounter : counter.HasUnaryPrefix used) (hinput : input.read Γ.start) (hwires : wires.read Γ.start) (houtput : output.read Γ.start) :
        evalFamilyCoreTM.step (coreCfg CorePhase.count input code wires counter output) = some (coreCfg CorePhase.rewindCounter input (code.move Dir3.right) wires counter output)

        The zero delimiter ends unary gate-count construction and advances the code cursor to the first serialized gate.

        theorem Complexity.CircuitCode.Machine.Internal.count_run (gateCode : List Bool) (used remaining : ) (input code wires counter output : Tape) (hcode : code.HasBinarySuffix (List.replicate remaining true ++ false :: gateCode)) (hcounter : counter.HasUnaryPrefix used) (hcounter0 : counter.cells 0 = Γ.start) (hinput : input.read Γ.start) (hwires : wires.read Γ.start) (houtput : output.read Γ.start) :
        ∃ (code' : Tape) (counter' : Tape), evalFamilyCoreTM.reachesIn (remaining + 1) (coreCfg CorePhase.count input code wires counter output) (coreCfg CorePhase.rewindCounter input code' wires counter' output) code'.HasBinarySuffix gateCode counter'.HasUnaryPrefix (used + remaining) counter'.cells 0 = Γ.start

        Scanning a terminated unary gate count takes exactly remaining + 1 steps. It leaves the code at the gate stream and materializes all marks on the counter tape.

        theorem Complexity.CircuitCode.Machine.Internal.rewindCounter_step_cursor {bits : List Bool} {position : } (input code wires counter output : Tape) (hcounter : BinaryCursor counter bits position) (hinput : input.read Γ.start) (hcode : code.read Γ.start) (hwires : wires.read Γ.start) (houtput : output.read Γ.start) :
        evalFamilyCoreTM.step (coreCfg CorePhase.rewindCounter input code wires counter output) = some (coreCfg CorePhase.rewindCounter input code wires (counter.move Dir3.left) output)

        In the counter-rewind phase, an off-marker counter cursor takes one ordinary left step while every framed tape remains unchanged.

        theorem Complexity.CircuitCode.Machine.Internal.rewindCounter_step_marker {bits : List Bool} (input code wires counter output : Tape) (hcounter : BinaryAtMarker counter bits) (hinput : input.read Γ.start) (hcode : code.read Γ.start) (hwires : wires.read Γ.start) (houtput : output.read Γ.start) :
        evalFamilyCoreTM.step (coreCfg CorePhase.rewindCounter input code wires counter output) = some (coreCfg (CorePhase.gateCheck false) input code wires (counter.move Dir3.right) output)

        On the left marker, the counter rewind bounces to its first mark and enters the initial gate-check phase.

        theorem Complexity.CircuitCode.Machine.Internal.rewindCounter_run {bits : List Bool} {position : } (input code wires counter output : Tape) (hcounter : BinaryCursor counter bits position) (hinput : input.read Γ.start) (hcode : code.read Γ.start) (hwires : wires.read Γ.start) (houtput : output.read Γ.start) :
        ∃ (counter' : Tape), evalFamilyCoreTM.reachesIn (position + 2) (coreCfg CorePhase.rewindCounter input code wires counter output) (coreCfg (CorePhase.gateCheck false) input code wires counter' output) BinaryCursor counter' bits 0

        Rewinding a counter cursor takes exactly position + 2 steps and enters the first gate check with the counter at position zero.

        theorem Complexity.CircuitCode.Machine.Internal.rewindBuiltCounter_run (count : ) (input code wires counter output : Tape) (hcounter : counter.HasUnaryPrefix count) (hcounter0 : counter.cells 0 = Γ.start) (hinput : input.read Γ.start) (hcode : code.read Γ.start) (hwires : wires.read Γ.start) (houtput : output.read Γ.start) :
        ∃ (counter' : Tape), evalFamilyCoreTM.reachesIn (count + 2) (coreCfg CorePhase.rewindCounter input code wires counter output) (coreCfg (CorePhase.gateCheck false) input code wires counter' output) counter'.HasUnaryCounter count

        A built unary prefix rewinds in exactly count + 2 steps to the public counter shape expected by the gate loop.

        theorem Complexity.CircuitCode.Machine.Internal.positiveHeader_run (count : ) (gateCode inputRest : List Bool) (input code wires counter output : Tape) (bit : Bool) (hcode : BinaryCursor code (true :: (NatCode.encode count ++ gateCode)) 0) (hwires : BinaryCursor wires (bit :: inputRest) 0) (hcounter : counter.HasUnaryPrefix 0) (hcounter0 : counter.cells 0 = Γ.start) (hinput : input.read Γ.start) (houtput : output.read Γ.start) :
        ∃ (code' : Tape) (counter' : Tape), evalFamilyCoreTM.reachesIn (2 * count + 4) (coreCfg CorePhase.familyTag input code wires counter output) (coreCfg (CorePhase.gateCheck false) input code' wires counter' output) code'.HasBinarySuffix gateCode counter'.HasUnaryCounter count

        A well-formed positive-family header builds and rewinds its declared unary gate counter in exactly 2 * count + 4 steps, stopping at the first gate check with the code cursor at the serialized gate stream.

        theorem Complexity.CircuitCode.Machine.Internal.familyTag_step_reject_positive_empty (rest : List Bool) (input code wires counter output : Tape) (hcode : BinaryCursor code (true :: rest) 0) (hwires : BinaryCursor wires [] 0) (hinput : input.read Γ.start) (hcounter : counter.read Γ.start) (houtput : output.read Γ.start) :
        evalFamilyCoreTM.step (coreCfg CorePhase.familyTag input code wires counter output) = some (coreCfg CorePhase.done input code wires counter (output.write Γ.zero))

        A positive-family tag is invalid on the empty input and rejects in one step.

        theorem Complexity.CircuitCode.Machine.Internal.familyTag_step_reject_empty_nonempty (rest inputRest : List Bool) (input code wires counter output : Tape) (bit : Bool) (hcode : BinaryCursor code (false :: rest) 0) (hwires : BinaryCursor wires (bit :: inputRest) 0) (hinput : input.read Γ.start) (hcounter : counter.read Γ.start) (houtput : output.read Γ.start) :
        evalFamilyCoreTM.step (coreCfg CorePhase.familyTag input code wires counter output) = some (coreCfg CorePhase.done input code wires counter (output.write Γ.zero))

        An empty-family tag is invalid on a nonempty input and rejects in one step.

        theorem Complexity.CircuitCode.Machine.Internal.familyTag_step_reject_missing (inputBits : List Bool) (input code wires counter output : Tape) (hcode : BinaryCursor code [] 0) (hwires : BinaryCursor wires inputBits 0) (hinput : input.read Γ.start) (hcounter : counter.read Γ.start) (houtput : output.read Γ.start) :
        evalFamilyCoreTM.step (coreCfg CorePhase.familyTag input code wires counter output) = some (coreCfg CorePhase.done input code wires counter (output.write Γ.zero))

        A missing family tag rejects in one step for either input arity.

        theorem Complexity.CircuitCode.Machine.Internal.emptyAnswer_step (answer : Bool) (rest : List Bool) (input code wires counter output : Tape) (hcode : BinaryCursor code (false :: answer :: rest) 1) (hwires : BinaryCursor wires [] 0) (hinput : input.read Γ.start) (hcounter : counter.read Γ.start) (houtput : output.read Γ.start) :
        evalFamilyCoreTM.step (coreCfg CorePhase.emptyAnswer input code wires counter output) = some (coreCfg (CorePhase.emptyEnd answer) input (code.move Dir3.right) wires counter output)

        The empty-family answer phase consumes its Boolean answer bit, independently of the remaining serialized suffix.

        theorem Complexity.CircuitCode.Machine.Internal.emptyEnd_step (answer : Bool) (input code wires counter output : Tape) (hcode : BinaryCursor code [false, answer] 2) (hwires : BinaryCursor wires [] 0) (hinput : input.read Γ.start) (hcounter : counter.read Γ.start) (houtput : output.read Γ.start) :
        evalFamilyCoreTM.step (coreCfg (CorePhase.emptyEnd answer) input code wires counter output) = some (coreCfg CorePhase.done input code wires counter (output.write (Γ.ofBool answer)))

        At the exact end of an empty-family code, the controller writes the answer and halts.

        theorem Complexity.CircuitCode.Machine.Internal.emptyFamily_run (answer : Bool) (input code wires counter output : Tape) (hcode : BinaryCursor code [false, answer] 0) (hwires : BinaryCursor wires [] 0) (hinput : input.read Γ.start) (hcounter : counter.read Γ.start) (houtput : output.read Γ.start) :
        evalFamilyCoreTM.reachesIn 3 (coreCfg CorePhase.familyTag input code wires counter output) (coreCfg CorePhase.done input ((code.move Dir3.right).move Dir3.right) wires counter (output.write (Γ.ofBool answer)))

        A well-formed empty-input family code runs from its tag read to a halted configuration in exactly three steps.

        theorem Complexity.CircuitCode.Machine.Internal.emptyFamily_fromFrontiers_run (answer : Bool) (input code wires counter output : Tape) (hcode : BinaryCursor code [false, answer] 2) (hwires : BinaryCursor wires [] 0) (hinput : input.read Γ.start) (hcounter : counter.read Γ.start) (houtputInv : output.StartInvariant) (houtputHead : output.head = 1) :
        ∃ (code' : Tape) (wires' : Tape), evalFamilyCoreTM.reachesIn 9 (coreCfg CorePhase.rewindCode input code wires counter output) (coreCfg CorePhase.done input ((code'.move Dir3.right).move Dir3.right) wires' counter (output.write (Γ.ofBool answer))) BinaryCursor code' [false, answer] 0 BinaryCursor wires' [] 0 (output.write (Γ.ofBool answer)).head = 1 (output.write (Γ.ofBool answer)).StartInvariant (output.write (Γ.ofBool answer)).cells 1 = Γ.ofBool answer

        From the staging frontiers, a well-formed empty-input family code reaches its exact halted verdict in nine steps. This is the first complete branch of the streaming controller's machine semantics.