OAI/Computability/MaxCut/Machines/MachineBinaryFormula.lean
86 declarations, 0 contain sorry, 0 declared as axioms
An explicit ordinary-binary codec for sparse-name three-literal CNF.
A natural name uses its canonical little-endian binary digits. Each payload
digit b is represented by the pair true,b; false terminates the name.
Zero has the empty payload and therefore the one-bit encoding [false].
A literal is its sign bit followed by its name. A clause contains three literal
encodings. A formula contains true followed by each clause, then one final
false. There is no unary expansion of a variable name, declared variable
universe, or deduplication of literal or clause occurrences.
The parser rejects noncanonical name payloads, incomplete literals/clauses, and trailing input. The input length is within a fixed factor of the total ordinary binary name lengths plus signs and clause framing. Machine correspondence and runtime are proved separately; these output-size bounds are not time bounds.
- def
OAI.MaxCutGames.BinaryFormula.sourceNamesline 12 - def
OAI.MaxCutGames.BinaryFormula.activeNamesline 17Source documentation
Explicit list of occurring names, with duplicates removed. The list lengths depend only on occurrences; no interval of natural-number names is enumerated.
def activeNames (F : Formula) : List Nat := …
Mentions: OAI.MaxCutGames.BinaryFormula.Formula
- theorem
OAI.MaxCutGames.BinaryFormula.literal_mem_activeline 20 - def
OAI.MaxCutGames.BinaryFormula.compactIndexline 28 - def
OAI.MaxCutGames.BinaryFormula.decodeNameline 32 - def
OAI.MaxCutGames.BinaryFormula.compactLiteralline 35 - def
OAI.MaxCutGames.BinaryFormula.compactClauseline 39 - def
OAI.MaxCutGames.BinaryFormula.compactClausesline 45 - def
OAI.MaxCutGames.BinaryFormula.denseline 48 - def
OAI.MaxCutGames.BinaryFormula.restrictAssignmentline 52 - def
OAI.MaxCutGames.BinaryFormula.extendAssignmentline 55 - theorem
OAI.MaxCutGames.BinaryFormula.decode_compactIndexline 59 - theorem
OAI.MaxCutGames.BinaryFormula.compactIndex_injectiveline 65Source documentation
Distinct occurring names remain distinct. Repeated occurrences of one name use the same index, since the proof argument of
compactIndexis irrelevant.theorem compactIndex_injective (F : Formula) (u v : Nat) (hu : u ∈ activeNames F) (hv : v ∈ activeNames F) (h : compactIndex F u hu = compactIndex F v hv) : u = v := by …Mentions: OAI.MaxCutGames.BinaryFormula.Formula, OAI.MaxCutGames.BinaryFormula.activeNames, OAI.MaxCutGames.BinaryFormula.compactIndex
- theorem
OAI.MaxCutGames.BinaryFormula.compactLiteral_positiveline 71 - theorem
OAI.MaxCutGames.BinaryFormula.eval_compact_restrictline 74 - theorem
OAI.MaxCutGames.BinaryFormula.eval_compact_extendline 80 - def
OAI.MaxCutGames.BinaryFormula.evaluationListline 89 - theorem
OAI.MaxCutGames.BinaryFormula.evaluationList_restrictline 94Source documentation
Evaluation lists retain every clause occurrence, so this is stronger than merely preserving satisfiability or the set of distinct clauses.
theorem evaluationList_restrict (F : Formula) (A : Nat → Bool) : PCP.NameCompaction.evaluationList (dense F) (restrictAssignment F A) = evaluationList F A := by …Mentions: OAI.MaxCutGames.BinaryFormula.Formula, OAI.MaxCutGames.BinaryFormula.dense, OAI.MaxCutGames.BinaryFormula.restrictAssignment, OAI.MaxCutGames.BinaryFormula.evaluationList
- theorem
OAI.MaxCutGames.BinaryFormula.evaluationList_extendline 102 - def
OAI.MaxCutGames.BinaryFormula.failedCountline 116 - theorem
OAI.MaxCutGames.BinaryFormula.failedCount_restrictline 119 - theorem
OAI.MaxCutGames.BinaryFormula.failedCount_extendline 123 - theorem
OAI.MaxCutGames.BinaryFormula.clauseNames_flat_lengthline 127 - theorem
OAI.MaxCutGames.BinaryFormula.dense_clause_countline 136 - theorem
OAI.MaxCutGames.BinaryFormula.dense_variable_boundline 142Source documentation
No greatest-name bound occurs: even very large, sparsely used names yield at most three dense «variables» per explicitly listed clause.
theorem dense_variable_bound (F : Formula) : (dense F).«variables» ≤ 3 * F.clauses.length := by …Mentions: OAI.MaxCutGames.BinaryFormula.Formula, OAI.MaxCutGames.BinaryFormula.dense
- theorem
OAI.MaxCutGames.BinaryFormula.dense_completenessline 147 - theorem
OAI.MaxCutGames.BinaryFormula.dense_reflectsline 156 - theorem
OAI.MaxCutGames.BinaryFormula.dense_satisfiable_iffline 166 - theorem
OAI.MaxCutGames.BinaryFormula.dense_preserves_gapline 170 - theorem
OAI.MaxCutGames.BinaryFormula.dense_encoding_boundline 180Source documentation
Size of the reused dense formula encoding, bounded only by the number of explicit clause occurrences. This does not assert a binary input parser or a running-time bound for sparse-to-dense conversion.
theorem dense_encoding_bound (F : Formula) : (Complexity.formulaBits (dense F)).length ≤ 9 * F.clauses.length * F.clauses.length + 10 * F.clauses.length + 2 := by …Mentions: OAI.MaxCutGames.BinaryFormula.Formula, OAI.MaxCutGames.BinaryFormula.dense
- theorem
OAI.MaxCutGames.BinaryEncoding.dense_encoding_boundline 222Source documentation
The existing dense unary output is polynomial in this ordinary binary input length. This remains an output-size theorem, not a runtime certificate.
theorem dense_encoding_bound (formula : Formula) : (MaxCutGames.Foundations.Complexity.formulaBits (dense formula)).length ≤ 9 * (formulaBits formula).length * (formulaBits formula).length + 10 * (formulaBits formula).length + 2 := by …Mentions: OAI.MaxCutGames.Foundations.Complexity.formulaBits, OAI.MaxCutGames.BinaryEncoding.formulaBits
- abbrev
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.Alphabetline 250 - abbrev
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.Stateline 251 - def
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.exitAtline 254Source documentation
An optional continuation, without reading or writing any tape.
def exitAt (exit : Option Λ) : TM2.Stmt (Alphabet K) Λ (State σ) := …
Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineCompare.Alphabet, OAI.MaxCutGames.Foundations.Complexity.MachineCompare.State
- def
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.finishline 260Source documentation
Clear both head registers and the mismatch flag after choosing the exit.
def finish (exit : Option Λ) : TM2.Stmt (Alphabet K) Λ (State σ) := …
Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineCompare.Alphabet, OAI.MaxCutGames.Foundations.Complexity.MachineCompare.State
- def
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.loopline 265Source documentation
The only comparison performed by the program is on two
Option Boolheads. In particular, no statement is given a whole-list equality oracle.def loop (left right : K) (loopLabel : Λ) (equalExit differentExit : Option Λ) : TM2.Stmt (Alphabet K) Λ (State σ) := …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineCompare.Alphabet, OAI.MaxCutGames.Foundations.Complexity.MachineCompare.State
- def
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.mismatchline 276Source documentation
Specification-only outcome, also recording an earlier mismatch.
def mismatch (flag : Bool) (leftWord rightWord : List Bool) : Bool := …
- theorem
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.mismatch_nil_nilline 279 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.mismatch_nil_consline 282 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.mismatch_cons_nilline 285 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.mismatch_trueline 288 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.mismatch_consline 291 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.stepAux_exitAtline 296 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.stepAux_finishline 301 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.update_left_inline_MachineCompareline 307 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.update_right_inline_MachineCompareline 320 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.step_emptyline 326 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.step_nil_consline 343 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.step_cons_nilline 358 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.step_cons_consline 373 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.trace_left_empty_inline_MachineCompareline 390 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.compareTrace_flagline 417Source documentation
The exact trace with a possibly pre-existing mismatch. Every input symbol is consumed even when disagreement has already been detected.
theorem compareTrace_flag (left right : K) (distinct : left ≠ right) (loopLabel : Λ) (equalExit differentExit : Option Λ) (program : Λ → TM2.Stmt (Alphabet K) Λ (State σ)) (atLoop : program loopLabel = loop left right loopLabel equalExit differentExit) (base : K → List Bool) (leftWord rightWord : List Bool) (ambient : σ) (flag : Bool) (leftRegister rightRegister : Option Bool) : (MachineComposition.advance (TM2.step program))^[max leftWord.length rightWord.length + 1] (some ⟨some loopLabel, (ambient, flag, leftRegister, rightRegister), tapesAt left right base leftWord rightWord⟩) = some ⟨if mismatch flag leftWord rightWord then differentExit else equalExit, (ambient, false, none, none), tapesAt left right base [] []⟩ := by …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineCompare.Alphabet, OAI.MaxCutGames.Foundations.Complexity.MachineCompare.State, OAI.MaxCutGames.Foundations.Complexity.MachineCompare.loop, OAI.MaxCutGames.Foundations.Complexity.MachineComposition.advance, OAI.MaxCutGames.Foundations.Complexity.MachineCompare.mismatch
- theorem
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.compareTraceline 454Source documentation
With a clear initial flag, the final continuation tests equality of the two complete original words. Both tapes and all comparison registers are empty.
theorem compareTrace (left right : K) (distinct : left ≠ right) (loopLabel : Λ) (equalExit differentExit : Option Λ) (program : Λ → TM2.Stmt (Alphabet K) Λ (State σ)) (atLoop : program loopLabel = loop left right loopLabel equalExit differentExit) (base : K → List Bool) (leftWord rightWord : List Bool) (ambient : σ) (leftRegister rightRegister : Option Bool) : (MachineComposition.advance (TM2.step program))^[max leftWord.length rightWord.length + 1] (some ⟨some loopLabel, (ambient, false, leftRegister, rightRegister), tapesAt left right base leftWord rightWord⟩) = some ⟨if leftWord = rightWord then equalExit else differentExit, (ambient, false, none, none), tapesAt left right base [] []⟩ := by …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineCompare.Alphabet, OAI.MaxCutGames.Foundations.Complexity.MachineCompare.State, OAI.MaxCutGames.Foundations.Complexity.MachineCompare.loop, OAI.MaxCutGames.Foundations.Complexity.MachineComposition.advance
- theorem
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.compareTrace_fromTapesline 469 - theorem
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.drained_otherline 483Source documentation
The final tape family agrees with the original at every unselected tape.
theorem drained_other (left right k : K) (notLeft : k ≠ left) (notRight : k ≠ right) (base : K → List Bool) : tapesAt left right base [] [] k = base k := … - def
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.compareInTimeline 488Source documentation
An actual timed execution witness, with the exact stored transition count.
def compareInTime (left right : K) (distinct : left ≠ right) (loopLabel : Λ) (equalExit differentExit : Option Λ) (program : Λ → TM2.Stmt (Alphabet K) Λ (State σ)) (atLoop : program loopLabel = loop left right loopLabel equalExit differentExit) (base : K → List Bool) (ambient : σ) (leftRegister rightRegister : Option Bool) : StateTransition.EvalsToInTime (TM2.step program) ⟨some loopLabel, (ambient, false, leftRegister, rightRegister), base⟩ (some ⟨if base left = base right then equalExit else differentExit, (ambient, false, none, none), tapesAt left right base [] []⟩) (max (base left).length (base right).length + 1) where …Mentions: OAI.MaxCutGames.Foundations.Complexity.MachineCompare.Alphabet, OAI.MaxCutGames.Foundations.Complexity.MachineCompare.State, OAI.MaxCutGames.Foundations.Complexity.MachineCompare.loop
- theorem
OAI.MaxCutGames.Foundations.Complexity.MachineCompare.compareInTime_stepsline 503 - def
OAI.MaxCutGames.BinaryNameMachine.frameline 521 - def
OAI.MaxCutGames.BinaryNameMachine.finalDigitline 525 - def
OAI.MaxCutGames.BinaryNameMachine.canonicalline 529 - structure
OAI.MaxCutGames.BinaryNameMachine.Resultline 531 - def
OAI.MaxCutGames.BinaryNameMachine.scanSpecline 538Source documentation
A specification with the same one- or two-symbol cases as the program.
def scanSpec : List Bool → List Bool → Option Bool → Result | [], acc, _ => ⟨false, [], acc⟩ | false :: rest, acc, last => ⟨last.getD true, rest, acc⟩ | [true], acc, _ => ⟨false, [], acc⟩ | true :: bit :: rest, acc, _ => scanSpec rest (bit :: acc) (some bit)
Mentions: OAI.MaxCutGames.BinaryNameMachine.Result
- def
OAI.MaxCutGames.BinaryNameMachine.stepsline 544 - theorem
OAI.MaxCutGames.BinaryNameMachine.steps_leline 548 - theorem
OAI.MaxCutGames.BinaryNameMachine.frame_lengthline 557 - theorem
OAI.MaxCutGames.BinaryNameMachine.scanSpec_frameline 563 - theorem
OAI.MaxCutGames.BinaryNameMachine.steps_frameline 572 - abbrev
OAI.MaxCutGames.BinaryNameMachine.Alphabetline 582 - abbrev
OAI.MaxCutGames.BinaryNameMachine.Stateline 583 - def
OAI.MaxCutGames.BinaryNameMachine.cleanline 585 - def
OAI.MaxCutGames.BinaryNameMachine.exitAtline 587 - def
OAI.MaxCutGames.BinaryNameMachine.finishline 592 - def
OAI.MaxCutGames.BinaryNameMachine.scanline 596Source documentation
Only the finite head and final-digit registers are inspected by branches.
def scan (source destination : K) (again : Λ) (accepted rejected : Option Λ) : TM2.Stmt (Alphabet (K := K)) Λ (State A) := …Mentions: OAI.MaxCutGames.BinaryNameMachine.Alphabet, OAI.MaxCutGames.BinaryNameMachine.State
- theorem
OAI.MaxCutGames.BinaryNameMachine.stepAux_finishline 611 - theorem
OAI.MaxCutGames.BinaryNameMachine.update_source_inline_MachineBinaryNameMachineline 616 - theorem
OAI.MaxCutGames.BinaryNameMachine.update_destination_inline_MachineBinaryNameMachineline 627 - theorem
OAI.MaxCutGames.BinaryNameMachine.step_emptyline 641 - theorem
OAI.MaxCutGames.BinaryNameMachine.step_endline 649 - theorem
OAI.MaxCutGames.BinaryNameMachine.step_truncatedline 660 - theorem
OAI.MaxCutGames.BinaryNameMachine.step_digitline 668 - theorem
OAI.MaxCutGames.BinaryNameMachine.scanTraceline 679Source documentation
Total correspondence, including malformed input and its exact unread suffix.
theorem scanTrace (input output : List Bool) (last register : Option Bool) : (advance (TM2.step program))^[steps input] (some ⟨some again, (ambient, last, register), tapesAt source destination base input output⟩) = some ⟨if (scanSpec input output last).accepted then accepted else rejected, clean ambient, tapesAt source destination base (scanSpec input output last).remaining (scanSpec input output last).reversedPayload⟩ := by …Mentions: OAI.MaxCutGames.BinaryNameMachine.steps, OAI.MaxCutGames.BinaryNameMachine.scanSpec, OAI.MaxCutGames.BinaryNameMachine.clean
- def
OAI.MaxCutGames.BinaryNameMachine.scanInTimeline 714Source documentation
A real timed execution; the instruction equation is the only program premise.
def scanInTime (input output : List Bool) (last register : Option Bool) : StateTransition.EvalsToInTime (TM2.step program) ⟨some again, (ambient, last, register), tapesAt source destination base input output⟩ (some ⟨if (scanSpec input output last).accepted then accepted else rejected, clean ambient, tapesAt source destination base (scanSpec input output last).remaining (scanSpec input output last).reversedPayload⟩) (input.length + 1) where …Mentions: OAI.MaxCutGames.BinaryNameMachine.scanSpec, OAI.MaxCutGames.BinaryNameMachine.clean
- theorem
OAI.MaxCutGames.BinaryNameMachine.framedTraceline 728Source documentation
A complete framed name needs exactly one transition per digit and one for the terminator. No transition inspects the magnitude denoted by the payload.
theorem framedTrace (bits suffix output : List Bool) (register : Option Bool) : (advance (TM2.step program))^[bits.length + 1] (some ⟨some again, (ambient, none, register), tapesAt source destination base (frame bits ++ suffix) output⟩) = some ⟨if canonical bits then accepted else rejected, clean ambient, tapesAt source destination base suffix (bits.reverse ++ output)⟩ := by …Mentions: OAI.MaxCutGames.BinaryNameMachine.frame, OAI.MaxCutGames.BinaryNameMachine.canonical, OAI.MaxCutGames.BinaryNameMachine.clean
- def
OAI.MaxCutGames.BinaryNameMachine.machineline 743Source documentation
One concrete machine with two Boolean stacks and finite control. The two exit labels expose acceptance to a caller; the scanner leaves them unexecuted.
def machine : FinTM2 where …
- theorem
OAI.MaxCutGames.BinaryNameMachine.machine_finiteAlphabetline 754 - def
OAI.MaxCutGames.BinaryNameMachine.machineInTimeline 760Source documentation
The bounded run instantiated with the displayed finite machine, including its actual entry and two actual exit labels.
def machineInTime (input output : List Bool) : StateTransition.EvalsToInTime machine.step ⟨some (0 : Fin 3), clean (), tapesAt false true (fun _ : Bool => []) input output⟩ (some ⟨if (scanSpec input output none).accepted then some (1 : Fin 3) else some (2 : Fin 3), clean (), tapesAt false true (fun _ : Bool => []) (scanSpec input output none).remaining (scanSpec input output none).reversedPayload⟩) (input.length + 1) := …Mentions: OAI.MaxCutGames.BinaryNameMachine.clean, OAI.MaxCutGames.BinaryNameMachine.scanSpec