OAI/Computability/MaxCut/Machines/Machine.lean
85 declarations, 0 contain sorry, 0 declared as axioms
Actual complete-stack cleanup, with an arbitrary continuation. Each symbol costs one transition and the empty-stack branch costs one final transition.
- abbrev
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.Alphabetline 14 - def
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.fieldLoopline 17Source documentation
Read one unary field, stopping at its zero delimiter.
def fieldLoop (source destination : K) (loopLabel : Λ) (exit : Option Λ) : TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) := …Mentions: OAI.MaxCutGames.Foundations.Hastad.SourceMachine.Alphabet
- def
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.fieldStartline 26Source documentation
Seed the destination delimiter before scanning the unary payload.
def fieldStart (destination : K) (loopLabel : Λ) : TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) := …Mentions: OAI.MaxCutGames.Foundations.Hastad.SourceMachine.Alphabet
- def
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.fieldTapesline 30 - theorem
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.fieldTapes_sourceline 34 - theorem
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.fieldTapes_destinationline 39 - theorem
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.fieldTapes_selfline 44 - theorem
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.fieldTapes_otherline 48 - theorem
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.update_field_source_inline_SourceMachineline 54 - theorem
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.update_field_destination_inline_SourceMachineline 65 - theorem
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.fieldStep_delimiterline 71 - theorem
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.fieldStep_trueline 85 - theorem
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.fieldLoopTraceline 100Source documentation
Exactly one transition per unary bit, including its terminating delimiter.
theorem fieldLoopTrace (source destination : K) (hne : source ≠ destination) (loopLabel : Λ) (exit : Option Λ) (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) …Mentions: OAI.MaxCutGames.Foundations.Hastad.SourceMachine.Alphabet
- theorem
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.fieldStartStepline 132 - def
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.fieldInTimeline 146 - def
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.afterFieldline 177Source documentation
Stack state after one completed field, retaining an arbitrary old destination.
def afterField (source destination : K) (base : K → List Bool) (n : Nat) (suffix : List Bool) : K → List Bool := … - def
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.fieldNextline 181 - def
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.fourTapesline 188 - theorem
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.fourTapes_sourceline 195 - theorem
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.fourTapes_otherline 201 - theorem
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.fourField_time_eq_lengthline 207 - def
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.fourFieldsInTimeline 214Source documentation
Four fields are separated by actual finite-stack transitions. The stated bound is exactly their serialized length plus four delimiter-seeding steps.
def fourFieldsInTime (source : K) (destination : Fin 4 → K) (hsep : ∀ j, source ≠ destination j) (start loopLabel : Fin 4 → Λ) (exit : Option Λ) (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) …Mentions: OAI.MaxCutGames.Foundations.Hastad.SourceMachine.Alphabet
- def
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.fieldDestinationline 258 - theorem
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.fourTapes_concreteline 260 - def
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.groupingProgramline 272 - def
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.groupingMachineline 281Source documentation
One concrete finite machine: five Boolean stacks, eight labels, and three internal states. Four destination stacks hold the four separated fields.
def groupingMachine : FinTM2 where …
- def
OAI.MaxCutGames.Foundations.Hastad.SourceMachine.groupingMachineInTimeline 294Source documentation
The concrete machine's verified trace includes arbitrary unread input and arbitrary prior destination contents. No assumed algorithm remains here.
def groupingMachineInTime (base : Fin 5 → List Bool) (a b c d : Nat) (suffix : List Bool) (hinput : base 0 = encodeWords [a, b, c, d] ++ suffix) (register : Option Bool) : StateTransition.EvalsToInTime groupingMachine.step ⟨some (0, false), ((), register), base⟩ (some ⟨none, ((), none), fourTapes (0 : Fin 5) fieldDestination base a b c d suffix⟩) (a + b + c + d + 8) := …Mentions: OAI.MaxCutGames.Foundations.Hastad.SourceMachine.fourTapes, OAI.MaxCutGames.Foundations.Hastad.SourceMachine.fieldDestination
- abbrev
OAI.MaxCutGames.Foundations.Complexity.MachineDrain.Alphabetline 320 - def
OAI.MaxCutGames.Foundations.Complexity.MachineDrain.drainline 322 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineDrain.drainTraceline 329 - def
OAI.MaxCutGames.Foundations.Complexity.MachineDrain.drainInTimeline 350 - def
OAI.MaxCutGames.Foundations.Complexity.MachineFiniteSequence.Labelline 379 - instance
OAI.MaxCutGames.Foundations.Complexity.MachineFiniteSequence.labelFintypeline 383 - instance
OAI.MaxCutGames.Foundations.Complexity.MachineFiniteSequence.labelDecidableEqline 391 - def
OAI.MaxCutGames.Foundations.Complexity.MachineFiniteSequence.entryline 402 - def
OAI.MaxCutGames.Foundations.Complexity.MachineFiniteSequence.instructionline 409 - def
OAI.MaxCutGames.Foundations.Complexity.MachineFiniteSequence.resultOfline 420 - def
OAI.MaxCutGames.Foundations.Complexity.MachineFiniteSequence.stepsline 424 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineFiniteSequence.traceline 432Source documentation
This generic composition lemma retains the local execution obligations. Concrete callers discharge them with the rotor, comparison and row programs.
theorem trace (program : Λ → TM2.Stmt Γ Λ σ) (invariant : Data → Prop) (state : Data → σ) (tapes : Data → ∀ k, List (Γ k)) (commands : List Command) (localInvariant : ∀ command ∈ commands, ∀ data, invariant data → invariant (result command data)) (localTrace : ∀ command ∈ commands, ∀ (labels : LocalLabel command → Λ) (exit : Option Λ), (∀ l, program (labels l) = localInstruction command labels exit l) → ∀ data, invariant data → (advance (TM2.step program))^[cost command data] (some ⟨some (labels (main command)), state data, tapes data⟩) = some ⟨exit, state (result command data), tapes (result command data)⟩) (labels : Label LocalLabel commands → Λ) (exit : Option Λ) …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineFiniteSequence.Label
- abbrev
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.Alphabetline 487 - abbrev
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.Tapesline 488 - abbrev
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.LocalLabelline 489 - abbrev
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.Labelline 490 - abbrev
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.Dataline 491 - def
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.entryline 493 - def
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.localInstructionline 496 - def
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.instructionline 500 - def
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.resultline 505 - def
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.costline 508 - def
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.finalTapesline 510 - def
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.finalRegisterline 514 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.finalRegister_noneline 519 - def
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.stepsline 522 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.sequence_resultline 527 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.sequence_stepsline 537 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.finalTapes_applyline 545Source documentation
Selected tapes are empty; every other tape word is preserved.
theorem finalTapes_apply (chosen : List K) (base : Tapes K) (k : K) : finalTapes chosen base k = if k ∈ chosen then [] else base k := by …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.Tapes, OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.finalTapes
- theorem
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.finalTapes_memline 556 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.finalTapes_not_memline 559 - def
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.lengthSumline 562 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.lengthSum_monoline 566 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.steps_leline 576Source documentation
This upper bound remains valid when the cleanup list repeats tapes.
theorem steps_le (chosen : List K) (base : Tapes K) : steps chosen base ≤ lengthSum chosen base + chosen.length := by …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.Tapes, OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.steps, OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.lengthSum
- theorem
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.steps_le_uniformline 592 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.traceline 608Source documentation
Exact execution of all concrete drains in the supplied ambient program.
theorem trace (chosen : List K) (labels : Label chosen → Λ) (exit : Option Λ) (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.Label, OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.Alphabet
- def
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.executionline 629 - def
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.workTapesline 642Source documentation
An executable complete cleanup list from an explicit finite enumeration.
def workTapes {N : Nat} (enumeration : Fin N ≃ K) (output : K) : List K := … - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.mem_workTapesline 645 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.workTapes_length_leline 652 - def
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.haltTapesline 658Source documentation
The tape component of the actual halted configuration: only output remains.
def haltTapes (output : K) (word : List Bool) : Tapes K := …
Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.Tapes
- theorem
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.finalTapes_workTapesline 661 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.cleanupTraceline 673Source documentation
With a clean register, complete work-tape cleanup reaches the standard halted shape, preserving the output word and the ambient state exactly.
theorem cleanupTrace {N : Nat} (enumeration : Fin N ≃ K) (output : K) (labels : Label (workTapes enumeration output) → Λ) (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.Label, OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.workTapes, OAI.MaxCutGames.Foundations.Complexity.MachineDrainMany.Alphabet
- abbrev
OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.Labelline 693 - abbrev
OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.Tapesline 694 - def
OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.entryline 696 - def
OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.statementline 701Source documentation
All instructions act on physical stacks. The final load only resets the finite internal register; no input-dependent integer is stored in it.
def statement (clearKeys : List K) (accumulator output : K) (canonical : σ) (labels : Label clearKeys → Λ) (exit : Option Λ) : Label clearKeys → TM2.Stmt (fun _ : K => Bool) Λ (σ × Option Bool) | .inl label => MachineDrainMany.instruction clearKeys (fun l => labels (.inl l)) (some (labels (.inr false))) label | .inr false => Reduction.MachineTransfer.loopAt accumulator output id false (labels (.inr false)) (some (labels (.inr true))) | .inr true => .load (fun _ => (canonical, none)) (Reduction.MachineTransfer.exitAt output exit)Mentions: OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.Label, OAI.MaxCutGames.Reduction.MachineTransfer.loopAt, OAI.MaxCutGames.Reduction.MachineTransfer.exitAt
- def
OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.canonicalTapesline 710 - def
OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.finishCostline 713 - theorem
OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.cleared_frameline 716 - theorem
OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.reversed_tapesline 720 - def
OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.finishInTimeline 739Source documentation
Exact execution, including the real drain loops, reversal, and reset. The only program hypotheses identify the caller's actual placed statements.
def finishInTime (clearKeys : List K) (accumulator output : K) (distinct : accumulator ≠ output) (keepAccumulator : accumulator ∉ clearKeys) (keepOutput : output ∉ clearKeys) (covers : ∀ k, k ≠ accumulator → k ≠ output → k ∈ clearKeys) (canonical : σ) (labels : Label clearKeys → Λ) (exit : Option Λ) (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (σ × Option Bool)) (atLabels : ∀ label, program (labels label) = statement clearKeys accumulator output canonical labels exit label) (base : Tapes K) (outputEmpty : base output = []) (ambient : σ) (register : Option Bool) : StateTransition.EvalsToInTime (TM2.step program) ⟨entry clearKeys labels, (ambient, register), base⟩ (some ⟨exit, (canonical, none), canonicalTapes output (base accumulator).reverse⟩) …Mentions: OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.Label, OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.statement, OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.Tapes, OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.entry, OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.canonicalTapes
- theorem
OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.finishCost_le_listline 799 - def
OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.totalLengthline 809 - theorem
OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.totalLength_eraseline 811 - theorem
OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.drain_conservationline 827Source documentation
Each physical pop removes one stored symbol; repeated clear keys add only the extra empty-tape loop test after their first occurrence.
theorem drain_conservation (clearKeys : List K) (base : Tapes K) : MachineDrainMany.steps clearKeys base + totalLength (MachineDrainMany.finalTapes clearKeys base) = totalLength base + clearKeys.length := by …Mentions: OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.Tapes, OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.totalLength
- theorem
OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.cleared_totalLengthline 839 - theorem
OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.finishCost_eq_totalLengthline 858Source documentation
Exact finalization cost from the complete initial stack contents.
theorem finishCost_eq_totalLength (clearKeys : List K) (accumulator output : K) (keepAccumulator : accumulator ∉ clearKeys) (keepOutput : output ∉ clearKeys) (covers : ∀ k, k ≠ accumulator → k ≠ output → k ∈ clearKeys) (base : Tapes K) (outputEmpty : base output = []) : finishCost clearKeys accumulator base = totalLength base + clearKeys.length + 2 := by …Mentions: OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.Tapes, OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.finishCost, OAI.MaxCutGames.Foundations.Hastad.SourceRuntimeFinish.totalLength