OAI/Computability/UniqueGames/Machines/MachineLemmas.lean
79 declarations, 0 contain sorry, 0 declared as axioms
Verifier-defined NP over finite bitstring machines. This definition does not
mention SAT. Inputs and witnesses use a fixed explicit framing, verifiers return
one Boolean symbol, and all stacks have finite alphabets. The Cook–Levin target
separately requires an actual polynomial-time machine producing the established
formulaBits serialization, in addition to satisfiability equivalence.
- def
OAI.UniqueGamesTheorem.Foundations.Complexity.naturalWordsEncodingline 13 - def
OAI.UniqueGamesTheorem.Foundations.Complexity.formulaEncodingline 18 - def
OAI.UniqueGamesTheorem.Foundations.Complexity.gameEncodingline 24Source documentation
Concrete forward-table output syntax with a checked parser.
def gameEncoding (alphabet : Nat) : Computability.Encoding (Target.Instance alphabet) Bool where …
Mentions: OAI.UniqueGamesTheorem.Foundations.Target.Instance
- def
OAI.UniqueGamesTheorem.Foundations.Complexity.prefixBitMachineline 31Source documentation
A fixed-bit prefixer uses one finite stack, one label, and one internal state. The bit is fixed in the program; it is not a second, freely accessible input.
def prefixBitMachine (bit : Bool) : Turing.FinTM2 where …
- def
OAI.UniqueGamesTheorem.Foundations.Complexity.prefixBitPolyTimeline 45Source documentation
A real machine certificate: one transition performs the push and halts. TM2 counts execution of one finite statement as one transition. Here that statement contains exactly one stack push.
noncomputable def prefixBitPolyTime (bit : Bool) : Turing.TM2ComputableInPolyTime (id : List Bool → List Bool) id (bit :: ·) where … - def
OAI.UniqueGamesTheorem.Foundations.Complexity.enlargePolynomialBoundline 65Source documentation
Increasing a polynomial bound preserves the actual execution witness.
def enlargePolynomialBound {α β αΓ βΓ : Type} {ea : α → List αΓ} {eb : β → List βΓ} {f : α → β} (certificate : Turing.TM2ComputableInPolyTime ea eb f) (bound : Polynomial Nat) (larger : ∀ n, certificate.time.eval n ≤ bound.eval n) : Turing.TM2ComputableInPolyTime ea eb f where … - def
OAI.UniqueGamesTheorem.Foundations.Complexity.composeMachinePhasesline 81Source documentation
Two verified phases of one transition system compose with added polynomial budgets, both measured in the original input length. This theorem preserves the actual sequence of transition steps, not merely the sizes of configurations.
def composeMachinePhases {σ : Type} (step : σ → Option σ) (start intermediate : σ) (finish : Option σ) (p q : Polynomial Nat) (inputLength : Nat) (first : StateTransition.EvalsToInTime step start (some intermediate) (p.eval inputLength)) (second : StateTransition.EvalsToInTime step intermediate finish (q.eval inputLength)) : StateTransition.EvalsToInTime step start finish ((p + q).eval inputLength) := by … - structure
OAI.UniqueGamesTheorem.Foundations.Complexity.PolynomialGapReductionline 93 - def
OAI.UniqueGamesTheorem.Foundations.Complexity.CookLevin.pairBitsline 116Source documentation
A unary length frame followed by input bits and witness bits.
def pairBits (input : List Bool × List Bool) : List Bool := …
- def
OAI.UniqueGamesTheorem.Foundations.Complexity.CookLevin.decodePairAuxline 119 - def
OAI.UniqueGamesTheorem.Foundations.Complexity.CookLevin.decodePairline 125 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.CookLevin.decodePairAux_frameline 128 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.CookLevin.decodePair_pairBitsline 138 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.CookLevin.pairBits_injectiveline 144 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.CookLevin.pairBits_lengthline 149 - def
OAI.UniqueGamesTheorem.Foundations.Complexity.CookLevin.pairEncodingline 154 - structure
OAI.UniqueGamesTheorem.Foundations.Complexity.CookLevin.NPVerifierline 163Source documentation
A standard polynomial-time Boolean verifier.
FinTM2already requires finitely many stacks, control labels, and internal states; this field also requires every stack alphabet to be finite. The actual machine runs on the explicit paired input and halts with exactly one Boolean output symbol.structure NPVerifier where …
- def
OAI.UniqueGamesTheorem.Foundations.Complexity.CookLevin.NPVerifier.Acceptsline 169 - def
OAI.UniqueGamesTheorem.Foundations.Complexity.CookLevin.InNPline 176Source documentation
NP is specified by polynomial witnesses and genuine finite-machine verification, independently of any reduction or satisfiability problem.
def InNP (language : List Bool → Prop) : Prop := …
- theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.CookLevin.NPVerifier.acceptedLanguage_inNPline 179 - structure
OAI.UniqueGamesTheorem.Foundations.Complexity.CookLevin.PolynomialThreeSATReductionline 185Source documentation
The demanded Cook–Levin endpoint: both the SAT equivalence and an actual machine producing the fixed existing unary-token 3CNF encoding. This structure contains obligations; its inhabitance is not assumed or asserted here.
structure PolynomialThreeSATReduction (language : List Bool → Prop) where …
- def
OAI.UniqueGamesTheorem.Foundations.Complexity.CookLevin.NPVerifier.horizonline 191Source documentation
A common clock for all witnesses of permitted length for one input.
noncomputable def NPVerifier.horizon (verifier : NPVerifier) (inputLength : Nat) : Nat := …
Mentions: OAI.UniqueGamesTheorem.Foundations.Complexity.CookLevin.NPVerifier
- theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.CookLevin.NPVerifier.input_time_le_horizonline 195 - def
OAI.UniqueGamesTheorem.Foundations.Complexity.CookLevin.NPVerifier.runWithinHorizonline 206Source documentation
A real verifier execution, enlarged to the single input-dependent clock. The machine and its output are the ones supplied in the verifier definition.
def NPVerifier.runWithinHorizon (verifier : NPVerifier) (input witness : List Bool) (bounded : witness.length ≤ verifier.witnessBound.eval input.length) : Turing.TM2OutputsInTime verifier.computation.tm ((pairBits (input, witness)).map verifier.computation.inputAlphabet.invFun) (some ([verifier.verify (input, witness)].map verifier.computation.outputAlphabet.invFun)) (verifier.horizon input.length) where …Mentions: OAI.UniqueGamesTheorem.Foundations.Complexity.CookLevin.NPVerifier, OAI.UniqueGamesTheorem.Foundations.Complexity.CookLevin.pairBits
- def
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.skipWordline 232Source documentation
Saturating removal of one zero-delimited word.
def skipWord : List Bool → List Bool | [] => [] | true :: bs => skipWord bs | false :: bs => bs
- theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.skipWord_encodeWordline 237 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.skipWord_iterate_encodeWordsline 246Source 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.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.skipWord, OAI.UniqueGamesTheorem.Foundations.Complexity.encodeWords
- def
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.headWordline 259Source 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.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.headWord_encodeWordline 264 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.headWord_encodeWordsline 272 - def
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.lookupBitsline 278 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.lookupBits_encodeWordsline 281 - def
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.lookupEncodedline 287Source 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.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.decodeWords_encodeWordline 292 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.lookupEncoded_encodeline 296 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.lookupEncoded_someline 301 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.lookupEncoded_noneline 306 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.encoded_selected_splitline 312Source 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.UniqueGamesTheorem.Foundations.Complexity.encodeWords, OAI.UniqueGamesTheorem.Foundations.Complexity.encodeWord
- def
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.scannedBitsline 326Source 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.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.encoded_prefix_length_leline 329 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.scannedBits_leline 338 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.scannedBits_of_someline 342 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.selected_scan_length_leline 349 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.output_length_leline 356 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.index_length_leline 363 - def
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.stepsline 377 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.steps_le_encoded_length_strongline 383Source 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.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.steps, OAI.UniqueGamesTheorem.Foundations.Complexity.encodeWords
- theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.steps_le_encoded_lengthline 398Source 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.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.steps, OAI.UniqueGamesTheorem.Foundations.Complexity.encodeWords
- theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.steps_eq_scannedBits_of_ltline 405Source 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.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.steps, OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.scannedBits
- theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.steps_eq_scannedBits_of_someline 420 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.steps_add_length_of_invalidline 428Source 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.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.steps, OAI.UniqueGamesTheorem.Foundations.Complexity.encodeWords
- theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.steps_le_input_encoding_sizeline 444Source 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.UniqueGamesTheorem.Foundations.Complexity.MachineLookupSpec.steps, OAI.UniqueGamesTheorem.Foundations.Complexity.encodeWords, OAI.UniqueGamesTheorem.Foundations.Complexity.encodeWord
- abbrev
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineUnaryCounter.Alphabetline 469 - def
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineUnaryCounter.guardline 473Source documentation
A single finite statement: inspect the counter, decrement a positive counter, and jump to the body or exit. The zero delimiter is never consumed.
def guard (counter : K) (bodyLabel exitLabel : Λ) : TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) := …Mentions: OAI.UniqueGamesTheorem.Foundations.Complexity.MachineUnaryCounter.Alphabet
- def
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineUnaryCounter.counterTapesline 482Source documentation
An arbitrary caller frame with one tape holding the unary counter and its unread suffix. Only this tape depends on the counter value.
def counterTapes (counter : K) (base : K → List Bool) (n : Nat) (suffix : List Bool) : K → List Bool := … - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineUnaryCounter.counterTapes_counterline 486 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineUnaryCounter.counterTapes_otherline 491 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineUnaryCounter.guardPushBoundline 497 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineUnaryCounter.stepAux_succline 503Source documentation
Positive counters lose exactly one true bit; the delimiter and suffix remain. Ambient state, unrelated tapes, and labels are accounted for explicitly.
theorem stepAux_succ (counter : K) (bodyLabel exitLabel : Λ) (base : K → List Bool) (n : Nat) (suffix : List Bool) (ambient : σ) (register : Option Bool) : TM2.stepAux (guard counter bodyLabel exitLabel) (ambient, register) (counterTapes counter base (n + 1) suffix) = ⟨some bodyLabel, (ambient, none), counterTapes counter base n suffix⟩ := by …Mentions: OAI.UniqueGamesTheorem.Foundations.Complexity.MachineUnaryCounter.guard, OAI.UniqueGamesTheorem.Foundations.Complexity.MachineUnaryCounter.counterTapes
- theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineUnaryCounter.stepAux_zeroline 512Source documentation
A zero counter is inspected without removing its delimiter.
theorem stepAux_zero (counter : K) (bodyLabel exitLabel : Λ) (base : K → List Bool) (suffix : List Bool) (ambient : σ) (register : Option Bool) : TM2.stepAux (guard counter bodyLabel exitLabel) (ambient, register) (counterTapes counter base 0 suffix) = ⟨some exitLabel, (ambient, none), counterTapes counter base 0 suffix⟩ := by …Mentions: OAI.UniqueGamesTheorem.Foundations.Complexity.MachineUnaryCounter.guard, OAI.UniqueGamesTheorem.Foundations.Complexity.MachineUnaryCounter.counterTapes
- theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineUnaryCounter.guardStep_succline 520 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineUnaryCounter.guardStep_zeroline 532 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineUnaryCounter.guardTrace_succline 545Source documentation
The positive branch executes in exactly one transition of the ambient program.
theorem guardTrace_succ (counter : K) (guardLabel bodyLabel exitLabel : Λ) (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) …Mentions: OAI.UniqueGamesTheorem.Foundations.Complexity.MachineUnaryCounter.Alphabet
- theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineUnaryCounter.guardTrace_zeroline 558 - def
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineUnaryCounter.guardInTime_succline 570 - def
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineUnaryCounter.guardInTime_zeroline 585 - def
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineCountedLoop.guardConfigurationline 624 - def
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineCountedLoop.bodyConfigurationline 630 - def
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineCountedLoop.exitConfigurationline 635 - def
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineCountedLoop.BodyTracesline 642Source documentation
The hypotheses are actual traces of the caller's body in the same program. Both endpoints have the same unary remainder and unread suffix.
def BodyTraces (counter : K) (guardLabel bodyLabel : Λ) (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) … - def
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineCountedLoop.totalStepsline 652Source documentation
Exactly
nsupplied body blocks andn + 1concrete guard transitions.def totalSteps (cost : Nat → Nat) (n : Nat) : Nat := …
- theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineCountedLoop.totalSteps_zeroline 655 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineCountedLoop.totalSteps_succline 658 - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineCountedLoop.loopTraceline 665Source documentation
The loop trace is derived by composing each actual unary guard transition with one supplied body trace. No whole-loop execution is assumed.
theorem loopTrace (counter : K) (guardLabel bodyLabel exitLabel : Λ) (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) … - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineCountedLoop.totalSteps_leline 698 - def
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineCountedLoop.loopInTimeline 710Source documentation
An actual timed execution witness with the exact composed step count.
def loopInTime (counter : K) (guardLabel bodyLabel exitLabel : Λ) (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) … - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineCountedLoop.baseFrameline 731Source documentation
Chaining the caller's declared per-body frame equalities.
theorem baseFrame (base : Nat → K → List Bool) (frame : K → Prop) (n : Nat) (bodyFrame : ∀ r, r < n → ∀ k, frame k → base (r + 1) k = base r k) : ∀ k, frame k → base n k = base 0 k := by … - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineCountedLoop.counterFrameline 744Source documentation
Protected tapes are unchanged by the complete loop, including its guard steps. The counter itself is explicitly excluded from this frame.
theorem counterFrame (counter : K) (suffix : List Bool) (base : Nat → K → List Bool) (frame : K → Prop) (n : Nat) (counterOutside : ∀ k, frame k → k ≠ counter) (bodyFrame : ∀ r, r < n → ∀ k, frame k → base (r + 1) k = base r k) : ∀ k, frame k → counterTapes counter (base n) n suffix k = counterTapes counter (base 0) 0 suffix k := by … - theorem
OAI.UniqueGamesTheorem.Foundations.Complexity.MachineCountedLoop.loopTrace_framedline 756Source documentation
Actual loop execution and preservation of an arbitrary declared tape frame.
theorem loopTrace_framed (counter : K) (guardLabel bodyLabel exitLabel : Λ) (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) …