OAI/Computability/MaxCut/Machines/MachineLookupCore.lean
74 declarations, 0 contain sorry, 0 declared as axioms
Finite control for destructive unary-indexed table lookup. The guard decreases the index even when the table is exhausted. Selection tests for an empty table before writing the destination. All tests inspect just one finite head register.
- abbrev
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.Alphabetline 18 - def
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.discardline 20 - def
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.selectline 28Source documentation
Check that a field exists before seeding its destination delimiter.
def select (source destination : K) (copyLabel rejected : Λ) : TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) := …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineLookup.Alphabet
- inductive
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.Labelline 35 - abbrev
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.Label.enumListline 39 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.Label.enumList_getElem?_ctorIdx_eqline 42 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.Label.enumList_nodupline 46 - instance
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.(instance at line 48)line 48 - def
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.programline 53Source documentation
Six fixed labels and a single optional-bit register, independent of input.
def program (index source destination : K) : Label → TM2.Stmt (Alphabet (K := K)) Label (σ × Option Bool) …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineLookup.Label, OAI.MaxCutGames.Foundations.Complexity.MachineLookup.Alphabet
- def
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.tapesline 63Source documentation
Three caller tapes with every other tape retained verbatim.
def tapes (index source destination : K) (base : K → List Bool) (counter input output : List Bool) : K → List Bool := … - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.tapes_indexline 68 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.tapes_sourceline 74 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.tapes_destinationline 80 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.tapes_otherline 85 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.update_indexline 91 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.update_sourceline 105 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.update_destinationline 116 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.fieldTapes_eqline 122 - def
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.machineline 131Source documentation
A concrete finite machine using exactly three binary stacks. Its table and unary index may be supplied in a caller configuration; no list oracle is used.
def machine : FinTM2 where …
- def
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.skipWordline 152Source documentation
Saturating removal of one zero-delimited word.
def skipWord : List Bool → List Bool | [] => [] | true :: bs => skipWord bs | false :: bs => bs
- theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.skipWord_encodeWordline 157 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.skipWord_iterate_encodeWordsline 166Source documentation
Iterated word removal agrees with zero-based list dropping, even after running past the end of the table.
theorem skipWord_iterate_encodeWords (i : Nat) (values : List Nat) : (skipWord^[i]) (encodeWords values) = encodeWords (values.drop i) := by …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.skipWord, OAI.MaxCutGames.Foundations.Complexity.encodeWords
- def
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.headWordline 179Source documentation
Copy the next complete word, including its delimiter. Empty input and unterminated words fail explicitly.
def headWord : List Bool → Option (List Bool) | [] => none | false :: _ => some [false] | true :: bs => (headWord bs).map (true :: ·)
- theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.headWord_encodeWordline 184 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.headWord_encodeWordsline 192 - def
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.lookupBitsline 198 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.lookupBits_encodeWordsline 201 - def
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.lookupEncodedline 207Source documentation
The index is on a separate tape and must decode to exactly one word.
def lookupEncoded (index table : List Bool) : Option (List Bool) := …
- theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.decodeWords_encodeWordline 212 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.lookupEncoded_encodeline 216 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.lookupEncoded_someline 221 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.lookupEncoded_noneline 226 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.encoded_selected_splitline 232Source documentation
Literal split at the selected word.
theorem encoded_selected_split (values : List Nat) (i value : Nat) (h : values[i]? = some value) : encodeWords values = encodeWords (values.take i) ++ encodeWord value ++ encodeWords (values.drop (i + 1)) := by …Mentions: OAI.MaxCutGames.Foundations.Complexity.encodeWords, OAI.MaxCutGames.Foundations.Complexity.encodeWord
- def
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.scannedBitsline 246Source documentation
This counts the bits through the selected word, capped at the whole table when the index is invalid. It is not a machine step count.
def scannedBits (values : List Nat) (i : Nat) : Nat := …
- theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.encoded_prefix_length_leline 249 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.scannedBits_leline 258 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.scannedBits_of_someline 262 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.selected_scan_length_leline 269 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.output_length_leline 276 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.index_length_leline 283 - def
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.stepsline 297 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.steps_le_encoded_length_strongline 303Source documentation
A uniform bound, including indices beyond the end of the table.
theorem steps_le_encoded_length_strong (values : List Nat) (i : Nat) : steps values i ≤ (encodeWords values).length + 2 * i + 2 := by …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.steps, OAI.MaxCutGames.Foundations.Complexity.encodeWords
- theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.steps_le_encoded_lengthline 318Source documentation
The requested recurrence bound with one further unit of slack.
theorem steps_le_encoded_length (values : List Nat) (i : Nat) : steps values i ≤ (encodeWords values).length + 2 * i + 3 := by …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.steps, OAI.MaxCutGames.Foundations.Complexity.encodeWords
- theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.steps_eq_scannedBits_of_ltline 325Source documentation
Successful lookup uses exactly the consumed table prefix, one guard per skipped word, and the two final control steps.
theorem steps_eq_scannedBits_of_lt (values : List Nat) (i : Nat) (h : i < values.length) : steps values i = scannedBits values i + i + 2 := by …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.steps, OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.scannedBits
- theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.steps_eq_scannedBits_of_someline 340 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.steps_add_length_of_invalidline 348Source documentation
A subtraction-free exact failure formula: the whole table has been consumed, and every remaining unary index bit costs two steps.
theorem steps_add_length_of_invalid (values : List Nat) (i : Nat) (h : values.length ≤ i) : steps values i + values.length = (encodeWords values).length + 2 * i + 2 := by …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.steps, OAI.MaxCutGames.Foundations.Complexity.encodeWords
- theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.steps_le_input_encoding_sizeline 364Source documentation
Linear in the combined encoded tape lengths. This is a bound for
steps, not yet a theorem about a concrete machine's execution.theorem steps_le_input_encoding_size (values : List Nat) (i : Nat) : steps values i ≤ (encodeWords values).length + 2 * (encodeWord i).length := by …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.steps, OAI.MaxCutGames.Foundations.Complexity.encodeWords, OAI.MaxCutGames.Foundations.Complexity.encodeWord
- theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.discard_update_twice_inline_MachineLookupDiscardline 385 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.discardStep_delimiterline 394 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.discardStep_trueline 407 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.discard_empty_stepline 421Source documentation
EOF returns to the guard in one transition, without changing any tape.
theorem discard_empty_step (source : K) (loopLabel returnLabel : Λ) (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineLookup.program, OAI.MaxCutGames.Foundations.Complexity.MachineLookup.Alphabet
- theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.discardTrace_updateline 438Source documentation
A normalized tape form for the field-discard trace.
theorem discardTrace_update (source : K) (loopLabel returnLabel : Λ) (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineLookup.program, OAI.MaxCutGames.Foundations.Complexity.MachineLookup.Alphabet
- theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.discardTraceline 463Source documentation
Discard exactly the first encoded field, in one transition per payload bit plus one transition for its delimiter. No condition is imposed on other tapes.
theorem discardTrace (source : K) (loopLabel returnLabel : Λ) (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineLookup.program, OAI.MaxCutGames.Foundations.Complexity.MachineLookup.Alphabet
- def
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.discardInTimeline 483Source documentation
The same exact trace packaged for composition with ambient machine phases.
def discardInTime (source : K) (loopLabel returnLabel : Λ) (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineLookup.program, OAI.MaxCutGames.Foundations.Complexity.MachineLookup.Alphabet
- theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.guard_step_succline 513 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.guard_step_zeroline 526 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.select_step_nonemptyline 539 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.select_step_emptyline 555 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.copyTraceline 566 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.selectTraceline 581 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.skipCycleTraceline 596 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.emptyCycleTraceline 614 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.successPrefixTraceline 632Source documentation
A successful positional lookup scans precisely its prior and selected field. The suffix is arbitrary and is retained byte for byte.
theorem successPrefixTrace (index source destination : K) (his : index ≠ source) (hid : index ≠ destination) (hsd : source ≠ destination) (base : K → List Bool) (prior : List Nat) (value : Nat) (indexSuffix suffix output : List Bool) (ambient : σ) (register : Option Bool) : (advance (TM2.step (program index source destination)))^[ (encodeWords prior).length + prior.length + value + 3] (some ⟨some .guard, (ambient, register), tapes index source destination base (encodeWord prior.length ++ indexSuffix) (encodeWords prior ++ (encodeWord value ++ suffix)) output⟩) = some ⟨some .accepted, (ambient, none), tapes index source destination base (encodeWord 0 ++ indexSuffix) suffix (encodeWord value ++ output)⟩ := by …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineLookup.program, OAI.MaxCutGames.Foundations.Complexity.encodeWords, OAI.MaxCutGames.Foundations.Complexity.MachineLookup.tapes, OAI.MaxCutGames.Foundations.Complexity.encodeWord
- theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.lookupTrace_someline 660Source documentation
Successful array access, with explicit selected value and preserved framing.
theorem lookupTrace_some (index source destination : K) (his : index ≠ source) (hid : index ≠ destination) (hsd : source ≠ destination) (base : K → List Bool) (values : List Nat) (i value : Nat) (selected : values[i]? = some value) (indexSuffix suffix output : List Bool) (ambient : σ) (register : Option Bool) : (advance (TM2.step (program index source destination)))^[MachineLookupSpec.steps values i] (some ⟨some .guard, (ambient, register), tapes index source destination base (encodeWord i ++ indexSuffix) (encodeWords values ++ suffix) output⟩) = some ⟨some .accepted, (ambient, none), tapes index source destination base (encodeWord 0 ++ indexSuffix) (encodeWords (values.drop (i + 1)) ++ suffix) (encodeWord value ++ output)⟩ := by …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineLookup.program, OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.steps, OAI.MaxCutGames.Foundations.Complexity.MachineLookup.tapes, OAI.MaxCutGames.Foundations.Complexity.encodeWord, OAI.MaxCutGames.Foundations.Complexity.encodeWords
- theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.emptyTraceline 689 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.lookupTrace_invalidline 712Source documentation
Invalid indices reject on a complete encoded table, after consuming that table and all positive index bits. The output and other tapes are unchanged.
theorem lookupTrace_invalid (index source destination : K) (his : index ≠ source) (hid : index ≠ destination) (hsd : source ≠ destination) (base : K → List Bool) (values : List Nat) (i : Nat) (invalid : values.length ≤ i) (indexSuffix output : List Bool) (ambient : σ) (register : Option Bool) : (advance (TM2.step (program index source destination)))^[MachineLookupSpec.steps values i] (some ⟨some .guard, (ambient, register), tapes index source destination base (encodeWord i ++ indexSuffix) (encodeWords values) output⟩) = some ⟨some .rejected, (ambient, none), tapes index source destination base (encodeWord 0 ++ indexSuffix) [] output⟩ := by …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineLookup.program, OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.steps, OAI.MaxCutGames.Foundations.Complexity.MachineLookup.tapes, OAI.MaxCutGames.Foundations.Complexity.encodeWord, OAI.MaxCutGames.Foundations.Complexity.encodeWords
- def
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.resultLabelline 735Source documentation
The two explicit control outcomes on a complete encoded table.
def resultLabel (values : List Nat) (i : Nat) : Label := …
Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineLookup.Label
- def
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.resultOutputline 741Source documentation
Successful lookup prefixes a complete unary word; failure writes nothing.
def resultOutput (values : List Nat) (i : Nat) (output : List Bool) : List Bool := …
- theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.lookupTraceline 748Source documentation
A total execution statement for every natural index and complete table. No bound or validity assumption on the index is needed.
theorem lookupTrace (index source destination : K) (his : index ≠ source) (hid : index ≠ destination) (hsd : source ≠ destination) (base : K → List Bool) (values : List Nat) (i : Nat) (indexSuffix output : List Bool) (ambient : σ) (register : Option Bool) : (advance (TM2.step (program index source destination)))^[MachineLookupSpec.steps values i] (some ⟨some .guard, (ambient, register), tapes index source destination base (encodeWord i ++ indexSuffix) (encodeWords values) output⟩) = some ⟨some (resultLabel values i), (ambient, none), tapes index source destination base (encodeWord 0 ++ indexSuffix) (encodeWords (values.drop (i + 1))) (resultOutput values i output)⟩ := by …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineLookup.program, OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.steps, OAI.MaxCutGames.Foundations.Complexity.MachineLookup.tapes, OAI.MaxCutGames.Foundations.Complexity.encodeWord, OAI.MaxCutGames.Foundations.Complexity.encodeWords, OAI.MaxCutGames.Foundations.Complexity.MachineLookup.resultLabel, OAI.MaxCutGames.Foundations.Complexity.MachineLookup.resultOutput
- def
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.lookupInTimeline 772Source documentation
A proved linear transition budget in the lengths of the encoded table and index, including invalid indices. The witness is the actual trace above.
def lookupInTime (index source destination : K) (his : index ≠ source) (hid : index ≠ destination) (hsd : source ≠ destination) (base : K → List Bool) (values : List Nat) (i : Nat) (indexSuffix output : List Bool) (ambient : σ) (register : Option Bool) : StateTransition.EvalsToInTime (TM2.step (program index source destination)) ⟨some .guard, (ambient, register), tapes index source destination base (encodeWord i ++ indexSuffix) (encodeWords values) output⟩ (some ⟨some (resultLabel values i), (ambient, none), tapes index source destination base (encodeWord 0 ++ indexSuffix) (encodeWords (values.drop (i + 1))) (resultOutput values i output)⟩) ((encodeWords values).length + 2 * (encodeWord i).length) where …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineLookup.program, OAI.MaxCutGames.Foundations.Complexity.MachineLookup.tapes, OAI.MaxCutGames.Foundations.Complexity.encodeWord, OAI.MaxCutGames.Foundations.Complexity.encodeWords, OAI.MaxCutGames.Foundations.Complexity.MachineLookup.resultLabel, OAI.MaxCutGames.Foundations.Complexity.MachineLookup.resultOutput
- theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.lookupHaltTraceline 789Source documentation
The final control label executes a genuine halt in one more transition.
theorem lookupHaltTrace (index source destination : K) (his : index ≠ source) (hid : index ≠ destination) (hsd : source ≠ destination) (base : K → List Bool) (values : List Nat) (i : Nat) (indexSuffix output : List Bool) (ambient : σ) (register : Option Bool) : (advance (TM2.step (program index source destination)))^[MachineLookupSpec.steps values i + 1] (some ⟨some .guard, (ambient, register), tapes index source destination base (encodeWord i ++ indexSuffix) (encodeWords values) output⟩) = some ⟨none, (ambient, none), tapes index source destination base (encodeWord 0 ++ indexSuffix) (encodeWords (values.drop (i + 1))) (resultOutput values i output)⟩ := by …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineLookup.program, OAI.MaxCutGames.Foundations.Complexity.MachineLookupSpec.steps, OAI.MaxCutGames.Foundations.Complexity.MachineLookup.tapes, OAI.MaxCutGames.Foundations.Complexity.encodeWord, OAI.MaxCutGames.Foundations.Complexity.encodeWords, OAI.MaxCutGames.Foundations.Complexity.MachineLookup.resultOutput
- def
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.timePolynomialline 804Source documentation
A single polynomial in the combined two input lengths.
noncomputable def timePolynomial : Polynomial Nat := Polynomial.C 2 * Polynomial.X + 1
- theorem
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.timePolynomial_boundsline 806 - def
OAI.MaxCutGames.Foundations.Complexity.MachineLookup.machineInTimeline 817Source documentation
The same exact computation as a certificate for the concrete finite three-stack machine. Both valid and invalid indices terminate with reset local state, retaining the zero index delimiter and all other stated tape contents.
def machineInTime (base : Fin 3 → List Bool) (values : List Nat) (i : Nat) (indexSuffix output : List Bool) (register : Option Bool) : StateTransition.EvalsToInTime machine.step ⟨some .guard, ((), register), tapes (K := Fin 3) 0 1 2 base …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineLookup.tapes