cfahlgren1/math / lean /OAI /Computability /DirectedFeedback /Machines /PoweringMachineRelationField.lean
cfahlgren1's picture
download
raw
46.1 kB
import Mathlib
import OAI.Computability.DirectedFeedback.Machines.PoweringMachineWord
namespace OAI
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
namespace DFVSGames.Foundations.Complexity.PoweringMachineRelationField
open Turing
open MachineComposition
open PCP
variable {K Λ A : Type} [DecidableEq K]
variable {n d max : Nat}
abbrev Alphabet (_ : K) := Bool
abbrev State (A : Type) := MachineUnaryEqualityBit.State A
abbrev Label (path : List (Fin d)) := PoweringMachineWord.Label path.length ⊕ MachineAffineLookup.Label
def lookupTapes (placement : PoweringMachineTapes.Tape max → K) (i : Fin 5) : K :=
placement (PoweringMachineTapes.relationPlacement max i.succ)
omit [DecidableEq K] in
theorem lookupTapes_injective (placement : PoweringMachineTapes.Tape max → K)
(distinct : Function.Injective placement) : Function.Injective (lookupTapes placement) := by
intro i j h
exact (Fin.succ_injective _) ((PoweringMachineTapes.relationPlacement_injective max) (distinct h))
omit [DecidableEq K] in
theorem source_outside_lookup (placement : PoweringMachineTapes.Tape max → K)
(distinct : Function.Injective placement) :
∀ i, placement (.inl 6) ≠ lookupTapes placement i := by
intro i h
have heq : PoweringMachineTapes.relationPlacement max 0 = PoweringMachineTapes.relationPlacement max i.succ := by
simpa [PoweringMachineTapes.leftEndpoint] using distinct h
have hi := (PoweringMachineTapes.relationPlacement_injective max) heq
have hv := congrArg Fin.val hi
simp at hv
def endpoint (table : PortTables.Table n d) (vertex : Fin n) (path : List (Fin d)) : Fin n :=
PoweringWalks.walkEnd (PortTables.portGraph table) vertex path
theorem endpoint_eq_wordEnd (table : PortTables.Table n d) (vertex : Fin n)
(path : List (Fin d)) :
endpoint table vertex path =
PoweringWalks.wordEnd (PortTables.portGraph table) path.length vertex path.get := by
rw [PoweringReach.wordEnd_eq_walkEnd_ofFn, List.ofFn_get]
rfl
def bit (table : PortTables.Table n d) (vertex : Fin n) (path : List (Fin d))
(port : Fin d) (left right : PortTables.Label) : Nat :=
GraphTables.bitWord (PortTables.accepts table (endpoint table vertex path, port) left right)
def instruction (placement : PoweringMachineTapes.Tape max → K) (path : List (Fin d))
(lengthBound : path.length ≤ max) (port : Fin d) (left right : PortTables.Label)
(labels : Label path → Λ) (exit : Option Λ) :
Label path → TM2.Stmt (Alphabet (K := K)) Λ (State A)
| .inl q => PoweringMachineWord.instruction path.length (placement ∘ PoweringMachineTapes.wordPlacement lengthBound false)
path.get (fun z => labels (.inl z)) (some (labels (.inr .seed))) q
| .inr q => PoweringMachineRelation.instruction (placement (.inl 6)) (lookupTapes placement)
port (GraphTables.relationIndex (left, right)) (fun z => labels (.inr z)) exit q
def afterWord (placement : PoweringMachineTapes.Tape max → K) (path : List (Fin d))
(lengthBound : path.length ≤ max) (table : PortTables.Table n d)
(vertex : Fin n) (base : K → List Bool) : K → List Bool :=
PoweringMachineWord.finalTapes table path.length (placement ∘ PoweringMachineTapes.wordPlacement lengthBound false)
vertex path.get base
def finalTapes (placement : PoweringMachineTapes.Tape max → K) (path : List (Fin d))
(lengthBound : path.length ≤ max) (port : Fin d) (left right : PortTables.Label)
(table : PortTables.Table n d) (vertex : Fin n) (base : K → List Bool) : K → List Bool :=
MachineAffineLookup.finalTapes (lookupTapes placement)
(afterWord placement path lengthBound table vertex base) (PortTables.tableWords table)
(PoweringMachineRelation.address (endpoint table vertex path) port
(GraphTables.relationIndex (left, right))) (bit table vertex path port left right)
def steps (path : List (Fin d)) (port : Fin d) (left right : PortTables.Label)
(table : PortTables.Table n d) (vertex : Fin n) : Nat :=
PoweringMachineWord.steps table path.length vertex path.get +
MachineAffineLookup.steps (PortTables.tableWords table) (endpoint table vertex path).val
(4098 * d) (4098 * port.val + 4 + (GraphTables.relationIndex (left, right)).val)
theorem afterWord_frame (placement : PoweringMachineTapes.Tape max → K) (distinct : Function.Injective placement)
(path : List (Fin d)) (lengthBound : path.length ≤ max)
(table : PortTables.Table n d) (vertex : Fin n) (base : K → List Bool)
(role : Fin 11) (h₂ : role ≠ 2) (h₃ : role ≠ 3) (h₄ : role ≠ 4) (h₆ : role ≠ 6) :
afterWord placement path lengthBound table vertex base (placement (.inl role)) =
base (placement (.inl role)) := by
apply PoweringMachineWord.finalTapes_other
· intro h; exact h₂ (by simpa [PoweringMachineTapes.query] using distinct h)
· intro h; exact h₃ (by simpa [PoweringMachineTapes.scan] using distinct h)
· intro h; exact h₄ (by simpa [PoweringMachineTapes.reverse] using distinct h)
· intro h; exact h₆ (by simpa [PoweringMachineTapes.leftEndpoint] using distinct h)
· intro i h
have heq := distinct h
simp at heq
theorem finalTapes_frame (placement : PoweringMachineTapes.Tape max → K) (distinct : Function.Injective placement)
(path : List (Fin d)) (lengthBound : path.length ≤ max)
(port : Fin d) (left right : PortTables.Label)
(table : PortTables.Table n d) (vertex : Fin n) (base : K → List Bool)
(role : Fin 11) (h₂ : role ≠ 2) (h₃ : role ≠ 3) (h₄ : role ≠ 4)
(h₆ : role ≠ 6) (h₁₀ : role ≠ 10) :
finalTapes placement path lengthBound port left right table vertex base (placement (.inl role)) =
base (placement (.inl role)) := by
calc
finalTapes placement path lengthBound port left right table vertex base (placement (.inl role)) =
afterWord placement path lengthBound table vertex base (placement (.inl role)) := by
apply MachineAffineLookup.finalTapes_other
· intro h; exact h₂ (by simpa [lookupTapes, PoweringMachineTapes.query] using distinct h)
· intro h; exact h₃ (by simpa [lookupTapes, PoweringMachineTapes.scan] using distinct h)
· intro h; exact h₁₀ (by simpa [lookupTapes, PoweringMachineTapes.rowOutput] using distinct h)
_ = _ := afterWord_frame placement distinct path lengthBound table vertex base role h₂ h₃ h₄ h₆
theorem finalTapes_other (placement : PoweringMachineTapes.Tape max → K)
(path : List (Fin d)) (lengthBound : path.length ≤ max)
(port : Fin d) (left right : PortTables.Label)
(table : PortTables.Table n d) (vertex : Fin n) (base : K → List Bool)
(k : K) (outside : ∀ i, k ≠ placement i) :
finalTapes placement path lengthBound port left right table vertex base k = base k := by
calc
finalTapes placement path lengthBound port left right table vertex base k =
afterWord placement path lengthBound table vertex base k :=
MachineAffineLookup.finalTapes_other _ _ _ _ _ _ (outside _) (outside _) (outside _)
_ = base k := PoweringMachineWord.finalTapes_other _ _ _ _ _ _ _
(outside _) (outside _) (outside _) (outside _) (fun i => outside _)
theorem fieldTrace (placement : PoweringMachineTapes.Tape max → K) (distinct : Function.Injective placement)
(path : List (Fin d)) (lengthBound : path.length ≤ max)
(port : Fin d) (left right : PortTables.Label)
(labels : Label path → Λ) (exit : Option Λ)
(program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State A))
(atLabels : ∀ l, program (labels l) = instruction placement path lengthBound port left right labels exit l)
(table : PortTables.Table n d) (vertex : Fin n) (base : K → List Bool)
(tableWord : base (placement (.inl 0)) = PortTables.tableBits table)
(scratchEmpty : base (placement (.inl 5)) = []) (suffix : List Bool)
(sourceWord : base (placement (.inl 1)) = encodeWord vertex.val ++ suffix) (ambient : A) :
(advance (TM2.step program))^[steps path port left right table vertex]
(some ⟨some (labels (.inl (PoweringMachineWord.entry path.length))), MachineUnaryEqualityBit.clean ambient, base⟩) =
some ⟨exit, MachineUnaryEqualityBit.clean ambient,
finalTapes placement path lengthBound port left right table vertex base⟩ ∧
finalTapes placement path lengthBound port left right table vertex base (placement (.inl 10)) =
encodeWord (bit table vertex path port left right) ++ base (placement (.inl 10)) := by
have hword := PoweringMachineWord.wordTrace table path.length (placement ∘ PoweringMachineTapes.wordPlacement lengthBound false)
(distinct.comp (PoweringMachineTapes.wordPlacement_injective lengthBound false)) vertex path.get
(fun q => labels (.inl q)) (some (labels (.inr .seed))) program
(fun q => atLabels (.inl q)) base (by simpa [PoweringMachineTapes.table] using tableWord)
(by simpa [PoweringMachineTapes.scratch] using scratchEmpty) suffix
(by simpa [PoweringMachineTapes.start] using sourceWord) (ambient, false, none) none
let mid := afterWord placement path lengthBound table vertex base
have hmidTable : mid (placement (.inl 0)) = PortTables.tableBits table := by
dsimp only [mid]
rw [afterWord_frame placement distinct path lengthBound table vertex base 0
(by decide) (by decide) (by decide) (by decide)]
exact tableWord
have hmidScratch : mid (placement (.inl 5)) = [] := by
dsimp only [mid]
rw [afterWord_frame placement distinct path lengthBound table vertex base 5
(by decide) (by decide) (by decide) (by decide)]
exact scratchEmpty
have hmidOutput : mid (placement (.inl 10)) = base (placement (.inl 10)) :=
afterWord_frame placement distinct path lengthBound table vertex base 10
(by decide) (by decide) (by decide) (by decide)
have hmidEndpoint : mid (placement (.inl 6)) = encodeWord (endpoint table vertex path).val ++
base (placement (.inl 6)) := by
dsimp only [mid, afterWord]
simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_inl_five, PoweringMachineTapes.endpoint_false,
PoweringMachineTapes.leftEndpoint, ← endpoint_eq_wordEnd] using hword.2
have hrelation := PoweringMachineRelation.relationTrace (placement (.inl 6)) (lookupTapes placement)
(lookupTapes_injective placement distinct) (source_outside_lookup placement distinct)
port (GraphTables.relationIndex (left, right)) (fun q => labels (.inr q)) exit program
(fun q => atLabels (.inr q)) table (endpoint table vertex path) mid
(by simpa [lookupTapes, PoweringMachineTapes.table] using hmidTable)
(by simpa [lookupTapes, PoweringMachineTapes.scratch] using hmidScratch)
(base (placement (.inl 6))) hmidEndpoint (ambient, false, none) none
constructor
· simp only [MachineUnaryEqualityBit.clean]
rw [steps, Nat.add_comm, Function.iterate_add_apply, hword.1]
exact hrelation
· change MachineAffineLookup.finalTapes (lookupTapes placement) _ _ _ _ (lookupTapes placement 3) = _
rw [MachineAffineLookup.finalTapes_output]
change encodeWord (bit table vertex path port left right) ++ mid (placement (.inl 10)) = _
rw [hmidOutput]
theorem steps_le (path : List (Fin d)) (port : Fin d) (left right : PortTables.Label)
(table : PortTables.Table n d) (vertex : Fin n) :
steps path port left right table vertex ≤
(14 * path.length + 9) * (PortTables.tableBits table).length + 12 * path.length + 9 := by
have hw := PoweringMachineWord.steps_le table path.length vertex path.get
have hr := PoweringMachineRelation.steps_le table (endpoint table vertex path) port
(GraphTables.relationIndex (left, right))
simp only [steps, Nat.add_mul, Nat.mul_assoc] at hw ⊢
omega
end DFVSGames.Foundations.Complexity.PoweringMachineRelationField
end
section
namespace DFVSGames.Foundations.Complexity.PoweringMachineEqualityField
open Turing
open MachineComposition
open PCP
variable {K Λ A : Type} [DecidableEq K]
variable {max l r n d : Nat}
abbrev Alphabet (_ : K) := Bool
abbrev Tape := PoweringMachineTapes.Tape
abbrev State := MachineUnaryEqualityBit.State
abbrev Label (l r : Nat) :=
PoweringMachineWord.Label l ⊕ PoweringMachineWord.Label r ⊕ MachineUnaryEqualityBit.Label
def entry (l r : Nat) : Label l r := .inl (PoweringMachineWord.entry l)
def instruction (hl : l ≤ max) (hr : r ≤ max) (placement : Tape max → K)
(left : Fin l → Fin d) (right : Fin r → Fin d)
(labels : Label l r → Λ) (exit : Option Λ) :
Label l r → TM2.Stmt (Alphabet (K := K)) Λ (State A)
| .inl q => PoweringMachineWord.instruction l
(placement ∘ PoweringMachineTapes.wordPlacement hl false) left
(fun z => labels (.inl z))
(some (labels (.inr (.inl (PoweringMachineWord.entry r))))) q
| .inr (.inl q) => PoweringMachineWord.instruction r
(placement ∘ PoweringMachineTapes.wordPlacement hr true) right
(fun z => labels (.inr (.inl z)))
(some (labels (.inr (.inr .seedLeft)))) q
| .inr (.inr q) => MachineUnaryEqualityBit.instruction
(placement ∘ PoweringMachineTapes.equalityPlacement max)
(fun z => labels (.inr (.inr z))) exit q
def endpoint (graph : PortTables.Table n d) {t : Nat} (vertex : Fin n)
(ports : Fin t → Fin d) : Fin n :=
PoweringWalks.wordEnd (PortTables.portGraph graph) t vertex ports
def resultBit (graph : PortTables.Table n d) (vertex : Fin n)
(left : Fin l → Fin d) (right : Fin r → Fin d) : Bool :=
decide (endpoint graph vertex left = endpoint graph vertex right)
def wordTapes (graph : PortTables.Table n d) {t : Nat} (h : t ≤ max)
(placement : Tape max → K) (target : Bool) (vertex : Fin n)
(ports : Fin t → Fin d) (base : K → List Bool) : K → List Bool :=
PoweringMachineWord.finalTapes graph t
(placement ∘ PoweringMachineTapes.wordPlacement h target) vertex ports base
def finalTapes (graph : PortTables.Table n d) (hl : l ≤ max) (hr : r ≤ max)
(placement : Tape max → K) (vertex : Fin n)
(left : Fin l → Fin d) (right : Fin r → Fin d) (base : K → List Bool) :
K → List Bool :=
let afterLeft := wordTapes graph hl placement false vertex left base
let afterBoth := wordTapes graph hr placement true vertex right afterLeft
Function.update afterBoth (placement (.inl 10))
(MachineUnaryEqualityBit.bitEncoding (resultBit graph vertex left right) ++
afterBoth (placement (.inl 10)))
def steps (graph : PortTables.Table n d) (vertex : Fin n)
(left : Fin l → Fin d) (right : Fin r → Fin d) : Nat :=
PoweringMachineWord.steps graph l vertex left +
PoweringMachineWord.steps graph r vertex right +
MachineUnaryEqualityBit.steps (endpoint graph vertex left).val
(endpoint graph vertex right).val
theorem steps_le (graph : PortTables.Table n d) (vertex : Fin n)
(left : Fin l → Fin d) (right : Fin r → Fin d) :
steps graph vertex left right ≤
(14 * (l + r) + 10) * (PortTables.tableBits graph).length + 12 * (l + r) + 15 := by
have hl := PoweringMachineWord.steps_le graph l vertex left
have hr := PoweringMachineWord.steps_le graph r vertex right
have he := MachineUnaryEqualityBit.steps_le
(endpoint graph vertex left).val (endpoint graph vertex right).val
have hleft := Nat.le_trans (Nat.le_of_lt (endpoint graph vertex left).isLt)
(PortTables.vertices_le_tableBits_length graph)
have hright := Nat.le_trans (Nat.le_of_lt (endpoint graph vertex right).isLt)
(PortTables.vertices_le_tableBits_length graph)
unfold steps
simp only [Nat.mul_add, Nat.add_mul, Nat.mul_assoc] at hl hr ⊢
omega
theorem wordTapes_other (graph : PortTables.Table n d) {t : Nat} (h : t ≤ max)
(placement : Tape max → K) (target : Bool) (vertex : Fin n)
(ports : Fin t → Fin d) (base : K → List Bool) (k : K)
(hquery : k ≠ placement (.inl 2)) (hscan : k ≠ placement (.inl 3))
(hreverse : k ≠ placement (.inl 4))
(houtput : k ≠ placement (PoweringMachineTapes.endpoint max target))
(hpositions : ∀ i : Fin max, k ≠ placement (.inr i)) :
wordTapes graph h placement target vertex ports base k = base k := by
apply PoweringMachineWord.finalTapes_other
· simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_inl_one,
PoweringMachineTapes.query] using hquery
· simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_inl_two,
PoweringMachineTapes.scan] using hscan
· simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_inl_three,
PoweringMachineTapes.reverse] using hreverse
· simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_inl_five] using houtput
· intro i
simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_succ] using
hpositions (Fin.castLE h i)
theorem wordTapes_role (graph : PortTables.Table n d) {t : Nat} (h : t ≤ max)
(placement : Tape max → K) (distinct : Function.Injective placement)
(target : Bool) (vertex : Fin n) (ports : Fin t → Fin d)
(base : K → List Bool) (j : Fin 11)
(hquery : j ≠ 2) (hscan : j ≠ 3) (hreverse : j ≠ 4)
(houtput : j ≠ if target then 7 else 6) :
wordTapes graph h placement target vertex ports base (placement (.inl j)) =
base (placement (.inl j)) := by
apply wordTapes_other
· intro he
exact hquery (Sum.inl.inj (distinct he))
· intro he
exact hscan (Sum.inl.inj (distinct he))
· intro he
exact hreverse (Sum.inl.inj (distinct he))
· intro he
apply houtput
cases target <;> exact Sum.inl.inj (distinct he)
· intro i he
cases distinct he
theorem finalTapes_other (graph : PortTables.Table n d) (hl : l ≤ max) (hr : r ≤ max)
(placement : Tape max → K) (vertex : Fin n)
(left : Fin l → Fin d) (right : Fin r → Fin d) (base : K → List Bool) (k : K)
(hquery : k ≠ placement (.inl 2)) (hscan : k ≠ placement (.inl 3))
(hreverse : k ≠ placement (.inl 4)) (hleft : k ≠ placement (.inl 6))
(hright : k ≠ placement (.inl 7)) (hrow : k ≠ placement (.inl 10))
(hpositions : ∀ i : Fin max, k ≠ placement (.inr i)) :
finalTapes graph hl hr placement vertex left right base k = base k := by
unfold finalTapes
rw [Function.update_of_ne hrow]
rw [wordTapes_other graph hr placement true vertex right _ k
hquery hscan hreverse hright hpositions]
exact wordTapes_other graph hl placement false vertex left base k
hquery hscan hreverse hleft hpositions
theorem finalTapes_role (graph : PortTables.Table n d) (hl : l ≤ max) (hr : r ≤ max)
(placement : Tape max → K) (distinct : Function.Injective placement) (vertex : Fin n)
(left : Fin l → Fin d) (right : Fin r → Fin d) (base : K → List Bool)
(j : Fin 11) (hrole : j = 0 ∨ j = 1 ∨ j = 5 ∨ j = 8 ∨ j = 9) :
finalTapes graph hl hr placement vertex left right base (placement (.inl j)) =
base (placement (.inl j)) := by
apply finalTapes_other
all_goals first
| (intro he; have hij := Sum.inl.inj (distinct he); rcases hrole with rfl | rfl | rfl | rfl | rfl <;> simp at hij)
| (intro i he; cases distinct he)
theorem finalTapes_output (graph : PortTables.Table n d) (hl : l ≤ max) (hr : r ≤ max)
(placement : Tape max → K) (distinct : Function.Injective placement) (vertex : Fin n)
(left : Fin l → Fin d) (right : Fin r → Fin d) (base : K → List Bool) :
finalTapes graph hl hr placement vertex left right base (placement (.inl 10)) =
MachineUnaryEqualityBit.bitEncoding (resultBit graph vertex left right) ++
base (placement (.inl 10)) := by
unfold finalTapes
rw [Function.update_self,
wordTapes_role graph hr placement distinct true vertex right _ 10
(by decide) (by decide) (by decide) (by decide),
wordTapes_role graph hl placement distinct false vertex left base 10
(by decide) (by decide) (by decide) (by decide)]
private theorem joinTrace_inline_PoweringMachineEqualityField {X : Type*} {f : X → X} {a b c : X} {u v : Nat}
(first : f^[u] a = b) (second : f^[v] b = c) : f^[u + v] a = c := by
rw [Nat.add_comm, Function.iterate_add_apply, first, second]
theorem fieldTrace (graph : PortTables.Table n d) (hl : l ≤ max) (hr : r ≤ max)
(placement : Tape max → K) (distinct : Function.Injective placement)
(vertex : Fin n) (left : Fin l → Fin d) (right : Fin r → Fin d)
(labels : Label l r → Λ) (exit : Option Λ)
(program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State A))
(atLabels : ∀ q, program (labels q) = instruction hl hr placement left right labels exit q)
(base : K → List Bool)
(tableWord : base (placement (.inl 0)) = PortTables.tableBits graph)
(scratchEmpty : base (placement (.inl 5)) = [])
(leftCopyEmpty : base (placement (.inl 8)) = [])
(rightCopyEmpty : base (placement (.inl 9)) = [])
(suffix : List Bool) (sourceWord : base (placement (.inl 1)) = encodeWord vertex.val ++ suffix)
(ambient : A) :
(advance (TM2.step program))^[steps graph vertex left right]
(some ⟨some (labels (entry l r)), MachineUnaryEqualityBit.clean ambient, base⟩) =
some ⟨exit, MachineUnaryEqualityBit.clean ambient,
finalTapes graph hl hr placement vertex left right base⟩ := by
let afterLeft := wordTapes graph hl placement false vertex left base
let afterBoth := wordTapes graph hr placement true vertex right afterLeft
have leftFrame (j : Fin 11) (h2 : j ≠ 2) (h3 : j ≠ 3) (h4 : j ≠ 4) (h6 : j ≠ 6) :
afterLeft (placement (.inl j)) = base (placement (.inl j)) :=
wordTapes_role graph hl placement distinct false vertex left base j h2 h3 h4 h6
have rightFrame (j : Fin 11) (h2 : j ≠ 2) (h3 : j ≠ 3) (h4 : j ≠ 4) (h7 : j ≠ 7) :
afterBoth (placement (.inl j)) = afterLeft (placement (.inl j)) :=
wordTapes_role graph hr placement distinct true vertex right afterLeft j h2 h3 h4 h7
have bothFrame (j : Fin 11) (h2 : j ≠ 2) (h3 : j ≠ 3) (h4 : j ≠ 4)
(h6 : j ≠ 6) (h7 : j ≠ 7) :
afterBoth (placement (.inl j)) = base (placement (.inl j)) :=
(rightFrame j h2 h3 h4 h7).trans (leftFrame j h2 h3 h4 h6)
have leftRun := PoweringMachineWord.wordTrace graph l
(placement ∘ PoweringMachineTapes.wordPlacement hl false)
(distinct.comp (PoweringMachineTapes.wordPlacement_injective hl false)) vertex left
(fun q => labels (.inl q))
(some (labels (.inr (.inl (PoweringMachineWord.entry r))))) program
(fun q => atLabels (.inl q)) base
(by simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_inl_zero,
PoweringMachineTapes.table] using tableWord)
(by simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_inl_four,
PoweringMachineTapes.scratch] using scratchEmpty)
suffix (by simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_first,
PoweringMachineTapes.start] using sourceWord)
(ambient, false, none) none
have rightTable : afterLeft (placement (.inl 0)) = PortTables.tableBits graph :=
(leftFrame 0 (by decide) (by decide) (by decide) (by decide)).trans tableWord
have rightScratch : afterLeft (placement (.inl 5)) = [] :=
(leftFrame 5 (by decide) (by decide) (by decide) (by decide)).trans scratchEmpty
have rightSource : afterLeft (placement (.inl 1)) = encodeWord vertex.val ++ suffix :=
(leftFrame 1 (by decide) (by decide) (by decide) (by decide)).trans sourceWord
have rightRun := PoweringMachineWord.wordTrace graph r
(placement ∘ PoweringMachineTapes.wordPlacement hr true)
(distinct.comp (PoweringMachineTapes.wordPlacement_injective hr true)) vertex right
(fun q => labels (.inr (.inl q))) (some (labels (.inr (.inr .seedLeft)))) program
(fun q => atLabels (.inr (.inl q))) afterLeft
(by simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_inl_zero,
PoweringMachineTapes.table] using rightTable)
(by simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_inl_four,
PoweringMachineTapes.scratch] using rightScratch)
suffix (by simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_first,
PoweringMachineTapes.start] using rightSource)
(ambient, false, none) none
have leftEndpoint : afterBoth (placement (.inl 6)) =
encodeWord (endpoint graph vertex left).val ++ base (placement (.inl 6)) := by
rw [rightFrame 6 (by decide) (by decide) (by decide) (by decide)]
dsimp only [afterLeft, wordTapes]
simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_inl_five,
PoweringMachineTapes.endpoint_false, PoweringMachineTapes.leftEndpoint,
wordTapes, endpoint] using leftRun.2
have rightEndpoint : afterBoth (placement (.inl 7)) =
encodeWord (endpoint graph vertex right).val ++ afterLeft (placement (.inl 7)) := by
dsimp only [afterBoth, wordTapes]
simpa only [Function.comp_apply, PoweringMachineTapes.wordPlacement_inl_five,
PoweringMachineTapes.endpoint_true, PoweringMachineTapes.rightEndpoint,
wordTapes, endpoint] using rightRun.2
have copiesLeft : afterBoth (placement (.inl 8)) = [] :=
(bothFrame 8 (by decide) (by decide) (by decide) (by decide) (by decide)).trans leftCopyEmpty
have copiesRight : afterBoth (placement (.inl 9)) = [] :=
(bothFrame 9 (by decide) (by decide) (by decide) (by decide) (by decide)).trans rightCopyEmpty
have scratchBoth : afterBoth (placement (.inl 5)) = [] :=
(bothFrame 5 (by decide) (by decide) (by decide) (by decide) (by decide)).trans scratchEmpty
have equalityRun := MachineUnaryEqualityBit.equalityTrace
(placement ∘ PoweringMachineTapes.equalityPlacement max)
(distinct.comp (PoweringMachineTapes.equalityPlacement_injective max))
(fun q => labels (.inr (.inr q))) exit program (fun q => atLabels (.inr (.inr q)))
afterBoth (endpoint graph vertex left).val (endpoint graph vertex right).val
(base (placement (.inl 6))) (afterLeft (placement (.inl 7)))
(by simpa only [Function.comp_apply, PoweringMachineTapes.equalityPlacement_zero,
PoweringMachineTapes.leftEndpoint] using leftEndpoint)
(by simpa only [Function.comp_apply, PoweringMachineTapes.equalityPlacement_one,
PoweringMachineTapes.rightEndpoint] using rightEndpoint)
(by simpa only [Function.comp_apply, PoweringMachineTapes.equalityPlacement_two,
PoweringMachineTapes.leftCopy] using copiesLeft)
(by simpa only [Function.comp_apply, PoweringMachineTapes.equalityPlacement_three,
PoweringMachineTapes.rightCopy] using copiesRight)
(by simpa only [Function.comp_apply, PoweringMachineTapes.equalityPlacement_four,
PoweringMachineTapes.scratch] using scratchBoth)
ambient
have joined := joinTrace_inline_PoweringMachineEqualityField (joinTrace_inline_PoweringMachineEqualityField leftRun.1 rightRun.1) equalityRun
simpa only [steps, entry, MachineUnaryEqualityBit.clean, Function.comp_apply,
PoweringMachineTapes.equalityPlacement_five, PoweringMachineTapes.rowOutput,
finalTapes, resultBit, Fin.ext_iff,
afterLeft, afterBoth, wordTapes] using joined
def fieldInTime (graph : PortTables.Table n d) (hl : l ≤ max) (hr : r ≤ max)
(placement : Tape max → K) (distinct : Function.Injective placement)
(vertex : Fin n) (left : Fin l → Fin d) (right : Fin r → Fin d)
(labels : Label l r → Λ) (exit : Option Λ)
(program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (State A))
(atLabels : ∀ q, program (labels q) = instruction hl hr placement left right labels exit q)
(base : K → List Bool)
(tableWord : base (placement (.inl 0)) = PortTables.tableBits graph)
(scratchEmpty : base (placement (.inl 5)) = [])
(leftCopyEmpty : base (placement (.inl 8)) = [])
(rightCopyEmpty : base (placement (.inl 9)) = [])
(suffix : List Bool) (sourceWord : base (placement (.inl 1)) = encodeWord vertex.val ++ suffix)
(ambient : A) :
StateTransition.EvalsToInTime (TM2.step program)
⟨some (labels (entry l r)), MachineUnaryEqualityBit.clean ambient, base⟩
(some ⟨exit, MachineUnaryEqualityBit.clean ambient,
finalTapes graph hl hr placement vertex left right base⟩)
((14 * (l + r) + 10) * (PortTables.tableBits graph).length + 12 * (l + r) + 15) where
steps := steps graph vertex left right
evals_in_steps := fieldTrace graph hl hr placement distinct vertex left right labels exit program
atLabels base tableWord scratchEmpty leftCopyEmpty rightCopyEmpty suffix sourceWord ambient
steps_le_m := steps_le graph vertex left right
def machine (degree : Nat) (hl : l ≤ max) (hr : r ≤ max)
(left : Fin l → Fin degree) (right : Fin r → Fin degree) : FinTM2 where
K := Tape max
k₀ := .inl 0
k₁ := .inl 10
Γ _ := Bool
Λ := Label l r
main := entry l r
σ := State Unit
initialState := MachineUnaryEqualityBit.clean ()
m := instruction hl hr id left right id none
end DFVSGames.Foundations.Complexity.PoweringMachineEqualityField
end
section
namespace DFVSGames.Foundations.PCP.PoweringRowData
open DFVSGames.Foundations.Complexity
open Turing
open PoweringMachineRow MachineFixedBlockMap
open PoweringWalks PoweringLabels PoweringAddresses PoweringReach
open PoweringOpinionTables PoweringEnumeration
variable {vertices d : Nat}
theorem firstMatch_of_first {S : Nat} (mask : Fin S → Bool) (i : Fin S)
(hi : mask i = true) (hfirst : ∀ j : Fin S, j.val < i.val → mask j = false) :
firstMatch mask = some i := by
unfold firstMatch
apply List.find?_ofFn_eq_some.mpr
refine ⟨hi, i, rfl, ?_⟩
intro j hj
change ¬mask j = true
simp [hfirst j hj]
theorem firstMatch_firstIndex {X : Type*} (p : X → Prop) [DecidablePred p]
(xs : List X) (h : ∃ a ∈ xs, p a) :
firstMatch (fun i : Fin xs.length => decide (p (xs.get i))) =
some (firstIndex p xs h) := by
apply firstMatch_of_first
· exact decide_eq_true (firstIndex_matches p xs h)
· intro j hj
exact decide_eq_false (firstIndex_is_first p xs h j hj)
def endpointMask (G : PortGraph (Fin vertices) (Fin d)) (t : Nat)
(center target : Fin vertices) (i : AddressIndex d t) : Bool :=
decide ((wordToBall G t center ((allAddresses d t).get i)).val = target)
theorem firstMatch_endpointMask (G : PortGraph (Fin vertices) (Fin d)) (t : Nat)
(center : Fin vertices) (u : Ball G t center) :
firstMatch (endpointMask G t center u.val) = some (addressIndex G t center u) := by
unfold endpointMask addressIndex
exact firstMatch_firstIndex
(fun w : PortWords (Fin d) t => (wordToBall G t center w).val = u.val)
(allAddresses d t) (by
obtain ⟨w, hw⟩ := wordToBall_surjective G t center u
exact ⟨w, mem_allAddresses d t w, congrArg Subtype.val hw⟩)
def slotCount (d n : Nat) : Nat := (allAddresses d (n + 1)).length
abbrev RowBuffer (d n : Nat) := Buffer (inputSize (n + 1) (slotCount d n))
def fixedLabelAt (d n : Nat) (a : Fin (PoweringTables.labelCount d n))
(i : Fin (slotCount d n)) : GraphTables.Label :=
decodeLabel d (n + 1) 64 a ((allAddresses d (n + 1)).get i)
theorem fixedLabelAt_addressIndex (G : PortGraph (Fin vertices) (Fin d)) (n : Nat)
(center : Fin vertices) (u : Ball G (n + 1) center)
(a : Fin (PoweringTables.labelCount d n)) :
fixedLabelAt d n a (addressIndex G (n + 1) center u) =
decode (finitePortSelector G (n + 1) center) (decodeLabel d (n + 1) 64 a) u := by
simpa only [fixedLabelAt, labelTable_get] using
labelTable_addressIndex G (n + 1) center u (decodeLabel d (n + 1) 64 a)
def walkData (input : PortTables.Table vertices d) (n : Nat)
(w : Walk (Fin vertices) (Fin d) (n + 1))
(k : Fin (n + 1)) : Field (slotCount d n) → Bool
| .inl (a, b) => PortTables.accepts input (edgeAt (PortTables.portGraph input) n w k) a b
| .inr (.inl i) => endpointMask (PortTables.portGraph input) (n + 1) w.1
(edgeAt (PortTables.portGraph input) n w k).1 i
| .inr (.inr i) => endpointMask (PortTables.portGraph input) (n + 1)
(endpoint (PortTables.portGraph input) w)
((PortTables.portGraph input).rot (edgeAt (PortTables.portGraph input) n w k)).1 i
def walkBits (input : PortTables.Table vertices d) (n : Nat)
(w : Walk (Fin vertices) (Fin d) (n + 1)) : RowBuffer d n :=
packData (walkData input n w)
@[simp] theorem basePredicate_walkBits (input : PortTables.Table vertices d) (n : Nat)
(w : Walk (Fin vertices) (Fin d) (n + 1)) (k : Fin (n + 1))
(a b : GraphTables.Label) :
basePredicate (walkBits input n w) k a b =
PortTables.accepts input (edgeAt (PortTables.portGraph input) n w k) a b := by
simp [basePredicate, walkBits, walkData]
@[simp] theorem leftMatches_walkBits (input : PortTables.Table vertices d) (n : Nat)
(w : Walk (Fin vertices) (Fin d) (n + 1)) (k : Fin (n + 1)) :
leftMatches (walkBits input n w) k = endpointMask (PortTables.portGraph input)
(n + 1) w.1 (edgeAt (PortTables.portGraph input) n w k).1 := by
funext i
simp [leftMatches, walkBits, walkData]
@[simp] theorem rightMatches_walkBits (input : PortTables.Table vertices d) (n : Nat)
(w : Walk (Fin vertices) (Fin d) (n + 1)) (k : Fin (n + 1)) :
rightMatches (walkBits input n w) k = endpointMask (PortTables.portGraph input)
(n + 1) (endpoint (PortTables.portGraph input) w)
((PortTables.portGraph input).rot (edgeAt (PortTables.portGraph input) n w k)).1 := by
funext i
simp [rightMatches, walkBits, walkData]
theorem firstMatch_walkBits_left (input : PortTables.Table vertices d) (n : Nat)
(w : Walk (Fin vertices) (Fin d) (n + 1)) (k : Fin (n + 1)) :
firstMatch (leftMatches (walkBits input n w) k) = some
(addressIndex (PortTables.portGraph input) (n + 1) w.1
(tailFromStart (PortTables.portGraph input) n w k)) := by
rw [leftMatches_walkBits]
simpa only [tailFromStart_val, slotCount] using
firstMatch_endpointMask (PortTables.portGraph input) (n + 1) w.1
(tailFromStart (PortTables.portGraph input) n w k)
theorem firstMatch_walkBits_right (input : PortTables.Table vertices d) (n : Nat)
(w : Walk (Fin vertices) (Fin d) (n + 1)) (k : Fin (n + 1)) :
firstMatch (rightMatches (walkBits input n w) k) = some
(addressIndex (PortTables.portGraph input) (n + 1)
(endpoint (PortTables.portGraph input) w)
(headFromEnd (PortTables.portGraph input) n w k)) := by
rw [rightMatches_walkBits]
simpa only [headFromEnd_val, slotCount] using
firstMatch_endpointMask (PortTables.portGraph input) (n + 1)
(endpoint (PortTables.portGraph input) w) (headFromEnd (PortTables.portGraph input) n w k)
theorem edgeAccept_walkBits (input : PortTables.Table vertices d) (n : Nat)
(w : Walk (Fin vertices) (Fin d) (n + 1)) (k : Fin (n + 1))
(a b : Fin (PoweringTables.labelCount d n)) :
edgeAccept (fixedLabelAt d n) (walkBits input n w) k a b =
PortTables.accepts input (edgeAt (PortTables.portGraph input) n w k)
(decode (finitePortSelector (PortTables.portGraph input) (n + 1) w.1)
(decodeLabel d (n + 1) 64 a) (tailFromStart (PortTables.portGraph input) n w k))
(decode (finitePortSelector (PortTables.portGraph input) (n + 1)
(endpoint (PortTables.portGraph input) w))
(decodeLabel d (n + 1) 64 b) (headFromEnd (PortTables.portGraph input) n w k)) := by
simp only [edgeAccept, firstMatch_walkBits_left, firstMatch_walkBits_right,
basePredicate_walkBits, fixedLabelAt_addressIndex]
theorem rowAccept_walkBits (input : PortTables.Table vertices d) (n : Nat)
(w : Walk (Fin vertices) (Fin d) (n + 1))
(a b : Fin (PoweringTables.labelCount d n)) :
rowAccept (fixedLabelAt d n) (walkBits input n w) a b =
rowsAccepts (PortTables.accepts input) (walkRows (PortTables.portGraph input) n w)
(labelTable (decodeLabel d (n + 1) 64 a))
(labelTable (decodeLabel d (n + 1) 64 b)) := by
rw [rowsAccepts_walkRows]
apply Bool.eq_iff_iff.mpr
simp only [rowAccept_eq_true, PoweringTest.pathAccepts_eq_true_iff, edgeAccept_walkBits]
def transposeField {S : Nat} : Field S → Field S
| .inl (a, b) => .inl (b, a)
| .inr (.inl i) => .inr (.inr i)
| .inr (.inr i) => .inr (.inl i)
def transposeBits {t S : Nat} (bits : Buffer (inputSize t S)) : Buffer (inputSize t S) :=
packData fun k field => bits (inputEquiv t S (k, transposeField field))
@[simp] theorem basePredicate_transposeBits {t S : Nat}
(bits : Buffer (inputSize t S)) (k : Fin t) (a b : GraphTables.Label) :
basePredicate (transposeBits bits) k a b = basePredicate bits k b a := by
simp [basePredicate, transposeBits, transposeField]
@[simp] theorem leftMatches_transposeBits {t S : Nat}
(bits : Buffer (inputSize t S)) (k : Fin t) :
leftMatches (transposeBits bits) k = rightMatches bits k := by
funext i
simp [leftMatches, rightMatches, transposeBits, transposeField]
@[simp] theorem rightMatches_transposeBits {t S : Nat}
(bits : Buffer (inputSize t S)) (k : Fin t) :
rightMatches (transposeBits bits) k = leftMatches bits k := by
funext i
simp [leftMatches, rightMatches, transposeBits, transposeField]
theorem edgeAccept_transposeBits {t S q : Nat}
(labelAt : Fin q → Fin S → GraphTables.Label)
(bits : Buffer (inputSize t S)) (k : Fin t) (a b : Fin q) :
edgeAccept labelAt (transposeBits bits) k a b = edgeAccept labelAt bits k b a := by
simp only [edgeAccept, leftMatches_transposeBits, rightMatches_transposeBits]
cases hl : firstMatch (leftMatches bits k) <;>
cases hr : firstMatch (rightMatches bits k) <;>
simp []
theorem rowAccept_transposeBits {t S q : Nat}
(labelAt : Fin q → Fin S → GraphTables.Label)
(bits : Buffer (inputSize t S)) (a b : Fin q) :
rowAccept labelAt (transposeBits bits) a b = rowAccept labelAt bits b a := by
apply Bool.eq_iff_iff.mpr
simp only [rowAccept_eq_true, edgeAccept_transposeBits]
def rowBits (input : PortTables.Table vertices d) (n : Nat)
(e : PoweringTest.Dart (Fin vertices) (Fin d) n) : RowBuffer d n :=
if e.1 then transposeBits (walkBits input n e.2) else walkBits input n e.2
def rowData (input : PortTables.Table vertices d) (n : Nat)
(e : PoweringTest.Dart (Fin vertices) (Fin d) n)
(k : Fin (n + 1)) (field : Field (slotCount d n)) : Bool :=
walkData input n e.2 k (if e.1 then transposeField field else field)
theorem rowBits_packData (input : PortTables.Table vertices d) (n : Nat)
(e : PoweringTest.Dart (Fin vertices) (Fin d) n) :
rowBits input n e = packData (rowData input n e) := by
rcases e with ⟨direction, w⟩
cases direction <;> funext i <;>
simp [rowBits, rowData, transposeBits, walkBits, packData]
@[simp] theorem rowBits_field (input : PortTables.Table vertices d) (n : Nat)
(e : PoweringTest.Dart (Fin vertices) (Fin d) n)
(k : Fin (n + 1)) (field : Field (slotCount d n)) :
rowBits input n e (inputEquiv (n + 1) (slotCount d n) (k, field)) =
rowData input n e k field := by
rw [rowBits_packData, packData_inputEquiv]
theorem rowAccept_rowBits (input : PortTables.Table vertices d) (n : Nat)
(e : PoweringTest.Dart (Fin vertices) (Fin d) n)
(a b : Fin (PoweringTables.labelCount d n)) :
rowAccept (fixedLabelAt d n) (rowBits input n e) a b =
PoweringTables.rowAccepts input n e a b := by
rcases e with ⟨direction, w⟩
cases direction <;>
simp only [rowBits, Bool.false_eq_true, ite_false, ite_true,
rowAccept_transposeBits, rowAccept_walkBits, PoweringTables.rowAccepts]
theorem rowBlock_at_rowBits (input : PortTables.Table vertices d) (n : Nat)
(e : PoweringTest.Dart (Fin vertices) (Fin d) n)
(a b : Fin (PoweringTables.labelCount d n)) :
rowBlock (fixedLabelAt d n) (rowBits input n e)
(GenericGraphTables.relationIndex (PoweringTables.labelCount d n) (a, b)) =
PoweringTables.rowAccepts input n e a b := by
rw [rowBlock_at, rowAccept_rowBits]
def dataWords (input : PortTables.Table vertices d) (n : Nat)
(e : PoweringTest.Dart (Fin vertices) (Fin d) n) : List Nat :=
(List.ofFn (rowBits input n e)).map GraphTables.bitWord
def dataTape (input : PortTables.Table vertices d) (n : Nat)
(e : PoweringTest.Dart (Fin vertices) (Fin d) n) : List Bool :=
encodeWords (dataWords input n e)
theorem dataTape_eq (input : PortTables.Table vertices d) (n : Nat)
(e : PoweringTest.Dart (Fin vertices) (Fin d) n) :
dataTape input n e = encodeBits (List.ofFn (rowBits input n e)) :=
(encodeBits_graphWords _).symm
theorem dataWords_length (input : PortTables.Table vertices d) (n : Nat)
(e : PoweringTest.Dart (Fin vertices) (Fin d) n) :
(dataWords input n e).length = (n + 1) * (4096 + (slotCount d n + slotCount d n)) := by
rw [dataWords, List.length_map]
simpa only [inputSize] using (List.length_ofFn (f := rowBits input n e))
theorem dataTape_length_le (input : PortTables.Table vertices d) (n : Nat)
(e : PoweringTest.Dart (Fin vertices) (Fin d) n) :
(dataTape input n e).length ≤ 2 * inputSize (n + 1) (slotCount d n) := by
rw [dataTape_eq]
simpa only [List.length_ofFn] using encodeBits_length_le (List.ofFn (rowBits input n e))
def emittedRelation (input : PortTables.Table vertices d) (n : Nat)
(e : PoweringTest.Dart (Fin vertices) (Fin d) n) :
GenericGraphTables.RelationTable (PoweringTables.labelCount d n) :=
Vector.ofFn (rowBlock (fixedLabelAt d n) (rowBits input n e))
theorem emittedRelation_eq (input : PortTables.Table vertices d) (n : Nat)
(e : PoweringTest.Dart (Fin vertices) (Fin d) n) :
emittedRelation input n e = GenericGraphTables.relationOf (PoweringTables.rowAccepts input n e) := by
unfold emittedRelation GenericGraphTables.relationOf
apply congrArg Vector.ofFn
funext i
exact rowAccept_rowBits input n e _ _
theorem rowBlock_unary (input : PortTables.Table vertices d) (n : Nat)
(e : PoweringTest.Dart (Fin vertices) (Fin d) n) :
encodeBits (List.ofFn (rowBlock (fixedLabelAt d n) (rowBits input n e))) =
encodeWords (GenericGraphTables.relationWords (emittedRelation input n e)) := by
have hbit : GraphTables.bitWord = GenericGraphTables.bitWord := by
funext b
cases b <;> rfl
have h := encodeBits_graphWords
(List.ofFn (rowBlock (fixedLabelAt d n) (rowBits input n e)))
rw [hbit] at h
simpa only [emittedRelation, GenericGraphTables.relationWords, Vector.toList_ofFn] using h
theorem emittedRelation_table (input : PortTables.Table vertices d) (n : Nat)
(i : Fin (PoweringTables.dartCount vertices d n)) :
emittedRelation input n (decodeDart vertices d n i) =
(PoweringTables.table input n).rows[i].relation := by
apply Vector.ext
intro j hj
have h := PoweringTables.table_accepts input n i
((GenericGraphTables.relationIndex (PoweringTables.labelCount d n)).symm ⟨j, hj⟩).1
((GenericGraphTables.relationIndex (PoweringTables.labelCount d n)).symm ⟨j, hj⟩).2
have hindex : GenericGraphTables.relationIndex (PoweringTables.labelCount d n)
(((GenericGraphTables.relationIndex (PoweringTables.labelCount d n)).symm ⟨j, hj⟩).1,
((GenericGraphTables.relationIndex (PoweringTables.labelCount d n)).symm ⟨j, hj⟩).2) =
⟨j, hj⟩ := by
change GenericGraphTables.relationIndex (PoweringTables.labelCount d n)
((GenericGraphTables.relationIndex (PoweringTables.labelCount d n)).symm ⟨j, hj⟩) = _
exact Equiv.apply_symm_apply _ _
simp only [GenericGraphTables.acceptsAt, GenericGraphTables.relationAt, hindex,
Fin.getElem_fin] at h
simp only [emittedRelation, Vector.getElem_ofFn]
change rowBlock (fixedLabelAt d n) (rowBits input n (decodeDart vertices d n i)) ⟨j, hj⟩ =
(PoweringTables.table input n).rows[i].relation[j]
change rowAccept (fixedLabelAt d n) (rowBits input n (decodeDart vertices d n i))
((GenericGraphTables.relationIndex (PoweringTables.labelCount d n)).symm ⟨j, hj⟩).1
((GenericGraphTables.relationIndex (PoweringTables.labelCount d n)).symm ⟨j, hj⟩).2 = _
rw [rowAccept_rowBits]
exact h.symm
theorem rowBlock_unary_table (input : PortTables.Table vertices d) (n : Nat)
(i : Fin (PoweringTables.dartCount vertices d n)) :
encodeBits (List.ofFn (rowBlock (fixedLabelAt d n)
(rowBits input n (decodeDart vertices d n i)))) =
encodeWords (GenericGraphTables.relationWords (PoweringTables.table input n).rows[i].relation) := by
rw [rowBlock_unary, emittedRelation_table]
def tableRowMachineInTime (input : PortTables.Table vertices d) (n : Nat)
(i : Fin (PoweringTables.dartCount vertices d n)) (suffix : List Bool)
(register : RowBuffer d n) (tapes : Bool → List Bool)
(hinput : tapes false = dataTape input n (decodeDart vertices d n i) ++ suffix) :
StateTransition.EvalsToInTime (PoweringMachineRow.machine (t := n + 1) (fixedLabelAt d n)).step
⟨some (), ((), register), tapes⟩
(some ⟨none, ((), emptyBuffer (inputSize (n + 1) (slotCount d n))),
Function.update (Function.update tapes false suffix) true
(encodeWords (GenericGraphTables.relationWords
(PoweringTables.table input n).rows[i].relation) ++ tapes true)⟩) 1 := by
have hinput' : tapes false =
encodeBits (List.ofFn (rowBits input n (decodeDart vertices d n i))) ++ suffix := by
simpa only [dataTape_eq] using hinput
have h := PoweringMachineRow.machineInTime (fixedLabelAt d n)
(rowBits input n (decodeDart vertices d n i)) suffix register tapes hinput'
simpa only [rowBlock_unary_table] using h
end DFVSGames.Foundations.PCP.PoweringRowData
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end OAI

Xet Storage Details

Size:
46.1 kB
·
Xet hash:
5054a44082dc4f1df2c1cb445e1709d276d8081a2786a51beeedb301ca4856c7

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