cfahlgren1/math / lean /OAI /Combinatorics /IndependentSets /Machines /MachineExpanderTableBoundary.lean
cfahlgren1's picture
download
raw
12.4 kB
import Mathlib
import OAI.Combinatorics.IndependentSets.Machines.MachineExpanderTableProgram
namespace OAI
namespace IndependentSetsGames.Foundations.Complexity.MachineExpanderTable
open Turing
open PCP.ExpanderTables PCP.ExpanderRowControl
variable {ρ : Type} {d : Nat}
@[simp] theorem caller_boundaryState (positive : 0 < d) (H : Table (cloudSize d) d)
(ambient : ρ) (position : Position d) :
caller (boundaryState positive H ambient position) = ambient := rfl
@[simp] theorem prepareState_boundaryState (positive : 0 < d) (H : Table (cloudSize d) d)
(ambient : ρ) (position : Position d) :
prepareState positive H (boundaryState positive H ambient position) =
boundaryState positive H ambient position := rfl
@[simp] theorem clearRegister_boundaryState (positive : 0 < d) (H : Table (cloudSize d) d)
(ambient : ρ) (position : Position d) :
clearRegister (boundaryState positive H ambient position) =
boundaryState positive H ambient position := rfl
@[simp] theorem caller_prepareState (positive : 0 < d) (H : Table (cloudSize d) d)
(state : State ρ d) : caller (prepareState positive H state) = caller state := rfl
@[simp] theorem caller_resetState (positive : 0 < d) (H : Table (cloudSize d) d)
(state : State ρ d) : caller (resetState positive H state) = caller state := rfl
@[simp] theorem caller_clearRegister (state : State ρ d) :
caller (clearRegister state) = caller state := rfl
@[simp] theorem caller_advancePositionState (positive : 0 < d) (state : State ρ d) :
caller (advancePositionState positive state) = caller state := rfl
@[simp] theorem caller_resetPositionState (positive : 0 < d) (state : State ρ d) :
caller (resetPositionState positive state) = caller state := rfl
theorem nextPosition_val_of_lt (positive : 0 < d) (position : Position d)
(more : position.val + 1 < rowFactor d) :
(nextPosition positive position).val = position.val + 1 := Nat.mod_eq_of_lt more
theorem boundaryTapes_update_count (vertex remaining next : Nat)
(oldTable output countSuffix result : List Bool) :
Function.update (boundaryTapes vertex remaining oldTable output countSuffix result)
(.inr .vertexCount) (encodeWord next ++ countSuffix) =
boundaryTapes vertex next oldTable output countSuffix result := by
funext tape
rcases tape with row | extra
· cases row <;> simp [boundaryTapes, rowTapes, MachineEmbedding.tapes, Function.update]
· cases extra <;> simp [boundaryTapes, extraTapes, MachineEmbedding.tapes, Function.update]
theorem boundaryTapes_increment_vertex (vertex remaining : Nat)
(oldTable output countSuffix result : List Bool) :
Function.update (boundaryTapes vertex remaining oldTable output countSuffix result)
(.inl .inputVertex) (true :: encodeWord vertex) =
boundaryTapes (vertex + 1) remaining oldTable output countSuffix result := by
funext tape
rcases tape with row | extra
· cases row <;>
simp [boundaryTapes, rowTapes, MachineEmbedding.tapes, Function.update,
encodeWord, List.replicate_succ]
· cases extra <;>
simp [boundaryTapes, extraTapes, MachineEmbedding.tapes, Function.update]
theorem initialTapes_initialize (vertices : Nat) (oldTable countSuffix : List Bool) :
Function.update (initialTapes vertices oldTable countSuffix) (.inl .inputVertex) [false] =
boundaryTapes 0 vertices oldTable [] countSuffix [] := by
funext tape
rcases tape with row | extra
· cases row <;>
simp [initialTapes, boundaryTapes, rowTapes, MachineEmbedding.tapes,
Function.update, encodeWord]
· cases extra <;>
simp [initialTapes, boundaryTapes, extraTapes, MachineEmbedding.tapes,
Function.update]
variable [Fintype ρ]
theorem initializeStep (positive : 0 < d) (H : Table (cloudSize d) d)
(base : ∀ tape, List (Alphabet tape)) (state : State ρ d) :
TM2.step (program positive H) ⟨some (.inr .initialize), state, base⟩ =
some ⟨some (.inr .vertexGuard), resetState positive H state,
Function.update base (.inl .inputVertex) (false :: base (.inl .inputVertex))⟩ := by
change some (TM2.stepAux (program positive H (.inr .initialize)) state base) = _
rw [program_outer]
rfl
theorem initialize_boundaryStep (positive : 0 < d) (H : Table (cloudSize d) d)
(vertices : Nat) (oldTable countSuffix : List Bool) (state : State ρ d) :
TM2.step (program positive H)
⟨some (.inr .initialize), state, initialTapes vertices oldTable countSuffix⟩ =
some ⟨some (.inr .vertexGuard), initialState positive H (caller state),
boundaryTapes 0 vertices oldTable [] countSuffix []⟩ := by
have h := initializeStep positive H (initialTapes vertices oldTable countSuffix) state
have input : initialTapes vertices oldTable countSuffix (.inl .inputVertex) = [] := rfl
simp only [input, resetState] at h
exact h.trans (congrArg
(fun tapes : ∀ tape, List (Alphabet tape) =>
(some ⟨some (.inr .vertexGuard), initialState positive H (caller state), tapes⟩ :
Option (TM2.Cfg Alphabet (Label d) (State ρ d))))
(initialTapes_initialize vertices oldTable countSuffix))
theorem vertexGuard_succStep (positive : 0 < d) (H : Table (cloudSize d) d)
(base : ∀ tape, List (Alphabet tape)) (state : State ρ d)
(remaining : Nat) (suffix : List Bool)
(counter : base (.inr .vertexCount) = encodeWord (remaining + 1) ++ suffix) :
TM2.step (program positive H) ⟨some (.inr .vertexGuard), state, base⟩ =
some ⟨some (.inr .prepareRow), clearRegister state,
Function.update base (.inr .vertexCount) (encodeWord remaining ++ suffix)⟩ := by
change some (TM2.stepAux (program positive H (.inr .vertexGuard)) state base) = _
rw [program_outer]
simp [outerStatement, MachineControl.statement, vertexGuardCore, TM2.stepAux,
guardStates, clearRegister, counter, encodeWord, List.replicate_succ]
theorem vertexGuard_zeroStep (positive : 0 < d) (H : Table (cloudSize d) d)
(base : ∀ tape, List (Alphabet tape)) (state : State ρ d)
(suffix : List Bool)
(counter : base (.inr .vertexCount) = encodeWord 0 ++ suffix) :
TM2.step (program positive H) ⟨some (.inr .vertexGuard), state, base⟩ =
some ⟨some (.inr .reverseOutput), clearRegister state, base⟩ := by
change some (TM2.stepAux (program positive H (.inr .vertexGuard)) state base) = _
rw [program_outer]
simp [outerStatement, MachineControl.statement, vertexGuardCore, TM2.stepAux,
guardStates, clearRegister, counter, encodeWord]
theorem vertexGuard_boundary_succStep (positive : 0 < d) (H : Table (cloudSize d) d)
(vertex remaining : Nat) (oldTable output countSuffix result : List Bool)
(state : State ρ d) :
TM2.step (program positive H)
⟨some (.inr .vertexGuard), state,
boundaryTapes vertex (remaining + 1) oldTable output countSuffix result⟩ =
some ⟨some (.inr .prepareRow), clearRegister state,
boundaryTapes vertex remaining oldTable output countSuffix result⟩ := by
simpa only [boundaryTapes_update_count] using
vertexGuard_succStep positive H
(boundaryTapes vertex (remaining + 1) oldTable output countSuffix result)
state remaining countSuffix rfl
theorem vertexGuard_boundary_zeroStep (positive : 0 < d) (H : Table (cloudSize d) d)
(vertex : Nat) (oldTable output countSuffix result : List Bool) (state : State ρ d) :
TM2.step (program positive H)
⟨some (.inr .vertexGuard), state,
boundaryTapes vertex 0 oldTable output countSuffix result⟩ =
some ⟨some (.inr .reverseOutput), clearRegister state,
boundaryTapes vertex 0 oldTable output countSuffix result⟩ :=
vertexGuard_zeroStep positive H
(boundaryTapes vertex 0 oldTable output countSuffix result) state countSuffix rfl
theorem prepareRowStep (positive : 0 < d) (H : Table (cloudSize d) d)
(base : ∀ tape, List (Alphabet tape)) (state : State ρ d) :
TM2.step (program positive H) ⟨some (.inr .prepareRow), state, base⟩ =
some ⟨some (.inl .initialize), prepareState positive H state, base⟩ := by
change some (TM2.stepAux (program positive H (.inr .prepareRow)) state base) = _
rw [program_outer]
rfl
theorem afterRow_moreStep (positive : 0 < d) (H : Table (cloudSize d) d)
(base : ∀ tape, List (Alphabet tape)) (state : State ρ d)
(more : state.2.val + 1 < rowFactor d) :
TM2.step (program positive H) ⟨some (.inr .afterRow), state, base⟩ =
some ⟨some (.inr .prepareRow), advancePositionState positive state, base⟩ := by
change some (TM2.stepAux (program positive H (.inr .afterRow)) state base) = _
rw [program_outer]
simp [outerStatement, TM2.stepAux, more]
theorem afterRow_lastStep (positive : 0 < d) (H : Table (cloudSize d) d)
(base : ∀ tape, List (Alphabet tape)) (state : State ρ d)
(last : ¬ state.2.val + 1 < rowFactor d) :
TM2.step (program positive H) ⟨some (.inr .afterRow), state, base⟩ =
some ⟨some (.inr .vertexGuard), resetPositionState positive state,
Function.update base (.inl .inputVertex) (true :: base (.inl .inputVertex))⟩ := by
change some (TM2.stepAux (program positive H (.inr .afterRow)) state base) = _
rw [program_outer]
simp [outerStatement, TM2.stepAux, last]
theorem afterRow_last_boundaryStep (positive : 0 < d) (H : Table (cloudSize d) d)
(vertex remaining : Nat) (oldTable output countSuffix result : List Bool)
(state : State ρ d) (last : ¬ state.2.val + 1 < rowFactor d) :
TM2.step (program positive H)
⟨some (.inr .afterRow), state,
boundaryTapes vertex remaining oldTable output countSuffix result⟩ =
some ⟨some (.inr .vertexGuard), resetPositionState positive state,
boundaryTapes (vertex + 1) remaining oldTable output countSuffix result⟩ := by
have input : boundaryTapes vertex remaining oldTable output countSuffix result
(.inl .inputVertex) = encodeWord vertex := rfl
have h := afterRow_lastStep positive H
(boundaryTapes vertex remaining oldTable output countSuffix result) state last
simp only [input] at h
exact h.trans (congrArg
(fun tapes : ∀ tape, List (Alphabet tape) =>
(some ⟨some (.inr .vertexGuard), resetPositionState positive state, tapes⟩ :
Option (TM2.Cfg Alphabet (Label d) (State ρ d))))
(boundaryTapes_increment_vertex vertex remaining oldTable output countSuffix result))
theorem reverseOutput_consStep (positive : 0 < d) (H : Table (cloudSize d) d)
(base : ∀ tape, List (Alphabet tape)) (state : State ρ d)
(symbol : Bool) (word : List Bool) (source : base (.inl .output) = symbol :: word) :
TM2.step (program positive H) ⟨some (.inr .reverseOutput), state, base⟩ =
some ⟨some (.inr .reverseOutput), ((state.1.1, some symbol), state.2),
Function.update (Function.update base (.inl .output) word)
(.inr .result) (symbol :: base (.inr .result))⟩ := by
change some (TM2.stepAux (program positive H (.inr .reverseOutput)) state base) = _
rw [program_outer]
simp [outerStatement, MachineControl.statement, Reduction.MachineTransfer.loopAt,
Reduction.MachineTransfer.exitAt, TM2.stepAux, guardStates, source]
theorem reverseOutput_nilStep (positive : 0 < d) (H : Table (cloudSize d) d)
(base : ∀ tape, List (Alphabet tape)) (state : State ρ d)
(source : base (.inl .output) = []) :
TM2.step (program positive H) ⟨some (.inr .reverseOutput), state, base⟩ =
some ⟨some (.inr .done), clearRegister state, base⟩ := by
have same : Function.update base (.inl .output) [] = base := by
simpa only [source] using Function.update_eq_self (.inl .output) base
change some (TM2.stepAux (program positive H (.inr .reverseOutput)) state base) = _
rw [program_outer]
simp [outerStatement, MachineControl.statement, Reduction.MachineTransfer.loopAt,
Reduction.MachineTransfer.exitAt, TM2.stepAux, guardStates, clearRegister, source, same]
theorem doneStep (positive : 0 < d) (H : Table (cloudSize d) d)
(base : ∀ tape, List (Alphabet tape)) (state : State ρ d) :
TM2.step (program positive H) ⟨some (.inr .done), state, base⟩ =
some ⟨none, state, base⟩ := by
change some (TM2.stepAux (program positive H (.inr .done)) state base) = _
rw [program_outer]
rfl
end IndependentSetsGames.Foundations.Complexity.MachineExpanderTable
end OAI

Xet Storage Details

Size:
12.4 kB
·
Xet hash:
ce4323102382b05c01be5867363cf6206d4bd03962733315d7d4198a10077cf6

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.