OAI/Computability/MaxCut/Games/EquationLookup.lean
52 declarations, 0 contain sorry, 0 declared as axioms
- inductive
OAI.MaxCutGames.Reduction.SourceEquationLookup.Tapeline 15 - inductive
OAI.MaxCutGames.Reduction.SourceEquationLookup.Labelline 19 - def
OAI.MaxCutGames.Reduction.SourceEquationLookup.fieldDestinationline 25 - def
OAI.MaxCutGames.Reduction.SourceEquationLookup.readStartline 26 - def
OAI.MaxCutGames.Reduction.SourceEquationLookup.readLoopline 27 - def
OAI.MaxCutGames.Reduction.SourceEquationLookup.skipLabelline 28 - def
OAI.MaxCutGames.Reduction.SourceEquationLookup.headerLabelline 29 - def
OAI.MaxCutGames.Reduction.SourceEquationLookup.programline 36Source documentation
Eight binary stacks and fixed finite control. Every loop scans one actual bit or tests one actual counter bit. The arbitrary ambient state is preserved.
def program : Label → TM2.Stmt (fun _ : Tape => Bool) Label (σ × Option Bool) | .copyOut => Reduction.MachineTransfer.loopAt .source .scratch id false .copyOut (some .copyBack) | .copyBack => MachineCopy.forkLoop .scratch .source .work false .copyBack (some .headerFirst) | .headerFirst => MachineLookup.discard .work .headerFirst .headerSecond | .headerSecond => MachineLookup.discard .work .headerSecond .guard | .guard => MachineUnaryCounter.guard .index (skipLabel 0) (readStart 0) | .skip slot => MachineLookup.discard .work (.skip slot) (skipLabel (slot.val + 1)) | .read slot => if slot.1.val < 4 then if slot.2 then …Mentions: OAI.MaxCutGames.Reduction.SourceEquationLookup.Label, OAI.MaxCutGames.Reduction.SourceEquationLookup.Tape, OAI.MaxCutGames.Reduction.MachineTransfer.loopAt, OAI.MaxCutGames.Reduction.SourceEquationLookup.skipLabel, OAI.MaxCutGames.Reduction.SourceEquationLookup.readStart
- theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.atSkipline 53 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.atReadStartline 57 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.atReadLoopline 61 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.atReadDoneline 66 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.discardHeadersTraceline 70Source documentation
The two header fields are physically consumed from the work copy.
theorem discardHeadersTrace (base : Tape → List Bool) (variableCount equations : Nat) (suffix : List Bool) (hinput : base .work = encodeWords [variableCount, equations] ++ suffix) (ambient : σ) : (advance (TM2.step program))^[variableCount + equations + 2] (some ⟨some .headerFirst, (ambient, none), base⟩) = some ⟨some .guard, (ambient, none), Function.update base .work suffix⟩ := by …Mentions: OAI.MaxCutGames.Reduction.SourceEquationLookup.Tape, OAI.MaxCutGames.Reduction.SourceEquationLookup.program
- theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.discardFourTraceline 84Source documentation
The fixed skip body consumes four complete unary fields and returns to the same counter guard, preserving the counter and every other tape.
theorem discardFourTrace (base : Tape → List Bool) (values : List Nat) (hlen : values.length = 4) (suffix : List Bool) (hinput : base .work = encodeWords values ++ suffix) (ambient : σ) : (advance (TM2.step program))^[(encodeWords values).length] (some ⟨some (skipLabel 0), (ambient, none), base⟩) = some ⟨some .guard, (ambient, none), Function.update base .work suffix⟩ := by …Mentions: OAI.MaxCutGames.Reduction.SourceEquationLookup.Tape, OAI.MaxCutGames.Reduction.SourceEquationLookup.program, OAI.MaxCutGames.Reduction.SourceEquationLookup.skipLabel
- theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.readFourTraceline 95Source documentation
Read the selected four fields using the already checked scanner.
theorem readFourTrace (base : Tape → List Bool) (values : List Nat) (hlen : values.length = 4) (suffix : List Bool) (hinput : base .work = encodeWords values ++ suffix) (ambient : σ) : (advance (TM2.step program))^[(encodeWords values).length + 5] (some ⟨some (readStart 0), (ambient, none), base⟩) = some ⟨none, (ambient, none), SourceFieldArray.sequenceTapes .work fieldDestination base 0 values suffix⟩ := by …Mentions: OAI.MaxCutGames.Reduction.SourceEquationLookup.Tape, OAI.MaxCutGames.Reduction.SourceEquationLookup.program, OAI.MaxCutGames.Reduction.SourceEquationLookup.readStart, OAI.MaxCutGames.Reduction.SourceEquationLookup.fieldDestination
- def
OAI.MaxCutGames.Reduction.SourceEquationLookup.scanTapesline 112Source documentation
Normal form for the changing counter and consumed work-copy prefix.
def scanTapes (base : Tape → List Bool) (index : Nat) (indexSuffix input : List Bool) : Tape → List Bool := …Mentions: OAI.MaxCutGames.Reduction.SourceEquationLookup.Tape
- theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.scanTapes_workline 116 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.scanTapes_indexline 120 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.scanTapes_otherline 125 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.update_scanTapes_workline 130 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.skipEquationsTraceline 139Source documentation
Each equation-index bit causes one genuine guard transition and exactly four field-discard loops. The final zero guard enters the field reader.
theorem skipEquationsTrace {n : Nat} (base : Tape → List Bool) (prior : List (CloneGap.Equation (Fin n))) (indexSuffix suffix : List Bool) (ambient : σ) (register : Option Bool) : (advance (TM2.step program))^[(encodeWords (prior.flatMap equationWords)).length + prior.length + 1] (some ⟨some .guard, (ambient, register), scanTapes base prior.length indexSuffix (encodeWords (prior.flatMap equationWords) ++ suffix)⟩) = some ⟨some (readStart 0), (ambient, none), scanTapes base 0 indexSuffix suffix⟩ := by …Mentions: OAI.MaxCutGames.Reduction.SourceEquationLookup.Tape, OAI.MaxCutGames.Reduction.CloneGap.Equation, OAI.MaxCutGames.Reduction.SourceEquationLookup.program, OAI.MaxCutGames.Reduction.SourceEquationLookup.scanTapes, OAI.MaxCutGames.Reduction.SourceEquationLookup.readStart
- theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.fieldDestination_eqline 187 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.fieldDestination_injective_belowline 193 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.readFour_output_fieldline 199 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.readFour_output_workline 211 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.readFour_output_frameline 219 - def
OAI.MaxCutGames.Reduction.SourceEquationLookup.outputTapesline 227 - def
OAI.MaxCutGames.Reduction.SourceEquationLookup.scanStepsline 233 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.scanReadTraceline 239 - def
OAI.MaxCutGames.Reduction.SourceEquationLookup.lookupStepsline 267 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.lookupWithSplitTraceline 271 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.output_sourceline 301 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.output_indexline 307 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.output_workline 313 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.output_fieldline 319 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.output_firstline 326 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.output_secondline 332 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.output_thirdline 338 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.output_rhsline 344 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.output_frameline 350 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.equationWords_fourline 357 - def
OAI.MaxCutGames.Reduction.SourceEquationLookup.fieldWordsline 362 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.output_fieldWordsline 365 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.lookupSteps_le_inputline 371 - def
OAI.MaxCutGames.Reduction.SourceEquationLookup.timePolynomialline 390 - theorem
OAI.MaxCutGames.Reduction.SourceEquationLookup.timePolynomial_evalline 392 - def
OAI.MaxCutGames.Reduction.SourceEquationLookup.lookupWithSplitInTimeline 396Source documentation
A polynomial bound on the actual complete copy/skip/read execution.
def lookupWithSplitInTime (F : SourceEncoding.Input) (prior : List (CloneGap.Equation (Fin F.«variables»))) (equation : CloneGap.Equation (Fin F.«variables»)) (after : List (CloneGap.Equation (Fin F.«variables»))) (hsplit : F.equations = prior ++ equation :: after) (base : Tape → List Bool) (indexSuffix : List Bool) (hsource : base .source = inputBits F) (hindex : base .index = encodeWord prior.length ++ indexSuffix) (hwork : base .work = []) (hscratch : base .scratch = []) (ambient : σ) (register : Option Bool) : StateTransition.EvalsToInTime (TM2.step program) ⟨some .copyOut, (ambient, register), base⟩ (some ⟨none, (ambient, none), outputTapes base equation indexSuffix (encodeWords (after.flatMap equationWords))⟩) …Mentions: OAI.MaxCutGames.Reduction.SourceEncoding.Input, OAI.MaxCutGames.Reduction.CloneGap.Equation, OAI.MaxCutGames.Reduction.SourceEquationLookup.Tape, OAI.MaxCutGames.Reduction.SourceEquationLookup.program, OAI.MaxCutGames.Reduction.SourceEquationLookup.outputTapes
- def
OAI.MaxCutGames.Reduction.SourceEquationLookup.lookupInTimeline 416 - def
OAI.MaxCutGames.Reduction.SourceEquationLookup.machineline 435 - def
OAI.MaxCutGames.Reduction.SourceEquationLookup.machineInTimeline 447Source documentation
The same proved run stated directly for the concrete finite machine.
def machineInTime (F : SourceEncoding.Input) (i : Fin F.equations.length) (base : Tape → List Bool) (indexSuffix : List Bool) (hsource : base .source = inputBits F) (hindex : base .index = encodeWord i.val ++ indexSuffix) (hwork : base .work = []) (hscratch : base .scratch = []) (register : Option Bool) : StateTransition.EvalsToInTime machine.step ⟨some .copyOut, ((), register), base⟩ (some ⟨none, ((), none), outputTapes base F.equations[i.val] indexSuffix (encodeWords ((F.equations.drop (i.val + 1)).flatMap equationWords))⟩) (timePolynomial.eval (inputBits F).length) := by …Mentions: OAI.MaxCutGames.Reduction.SourceEncoding.Input, OAI.MaxCutGames.Reduction.SourceEquationLookup.Tape, OAI.MaxCutGames.Reduction.SourceEquationLookup.outputTapes
- def
OAI.MaxCutGames.Reduction.SourceEquationLookup.placedLookupInTimeline 463Source documentation
Same-tape placement into the caller's finite control. Choosing the ambient type to be
τ × Unitgives the shared state(τ × Unit) × Option Boolused by the field-template machinery. The lookup's final transition entersexit.noncomputable def placedLookupInTime {Λ' : Type} (labels : Label → Λ') (exit : Option Λ') (target : Λ' → TM2.Stmt (fun _ : Tape => Bool) Λ' (σ × Option Bool)) (atLabels : ∀ l, target (labels l) = MachineSubroutine.statement labels exit (program (σ := σ) l)) …Mentions: OAI.MaxCutGames.Reduction.SourceEquationLookup.Label, OAI.MaxCutGames.Reduction.SourceEquationLookup.Tape, OAI.MaxCutGames.Reduction.SourceEquationLookup.program
- def
OAI.MaxCutGames.Reduction.SourceEquationLookup.embeddedLookupInTimeline 484Source documentation
An optional disjoint-stack placement preserves arbitrary extra tapes and state. It reuses the same generic lookup and introduces no extra transitions.
noncomputable def embeddedLookupInTime {E Λextra τ : Type} [DecidableEq E] (continuation : Option (Label ⊕ Λextra)) (extraState : τ) (extraTapes : E → List Bool) (extra : Λextra → TM2.Stmt (MachineEmbedding.Alphabet (fun _ : Tape => Bool) (fun _ : E => Bool)) (Label ⊕ Λextra) ((σ × Option Bool) × τ)) (input : SourceEncoding.Input) (i : Fin input.equations.length) (base : Tape → List Bool) (indexSuffix : List Bool) (hsource : base .source = inputBits input) (hindex : base .index = encodeWord i.val ++ indexSuffix) (hwork : base .work = []) (hscratch : base .scratch = []) (ambient : σ) (register : Option Bool) : …Mentions: OAI.MaxCutGames.Reduction.SourceEquationLookup.Label, OAI.MaxCutGames.Reduction.SourceEquationLookup.Tape, OAI.MaxCutGames.Reduction.SourceEncoding.Input