theoremrelation_ext {r s : RelationTable}
(h : ∀ a b, relationAt r a b = relationAt s a b) : r = s :=by
proof · 4
lines
apply Vector.ext
intro i hi
simpa only [relationAt, Prod.eta, Equiv.apply_symm_apply, Fin.getElem_fin] using
h (relationIndex.symm ⟨i, hi⟩).1 (relationIndex.symm ⟨i, hi⟩).2
theoremrow_lazy_stay (table : PortTables.Table n d) (v : Fin n) (p : Fin d) :
row (lazy table) v (lazyPorts d (false, p)) = stayRow d v p :=by
proof · 10
lines
havehr : (lazy table).reverseIndex[rowIndex n (2 * d) (v, lazyPorts d (false, p))] =
rowIndex n (2 * d) (v, lazyPorts d (false, p)) :=by
rw [← rowIndex_rotation, lazy_rotation_false]
havehp : (lazy table).relations[rowIndex n (2 * d) (v, lazyPorts d (false, p))] =
trueRelation :=by
apply relation_ext
intro a b
simpa only [PortTables.accepts, relationAt, trueRelation, Fin.getElem_fin,
Vector.getElem_replicate] using lazy_accepts_false table v p a b
exact congrArg₂ (DartRow.mk v) hr hp
theoremrow_lazy_move (table : PortTables.Table n d) (v : Fin n) (p : Fin d) :
row (lazy table) v (lazyPorts d (true, p)) = moveRow table v p :=by
proof · 10
lines
havehr : (lazy table).reverseIndex[rowIndex n (2 * d) (v, lazyPorts d (true, p))] =
rowIndex n (2 * d) ((rotation table (v, p)).1,
lazyPorts d (true, (rotation table (v, p)).2)) :=by
rw [← rowIndex_rotation, lazy_rotation_true]
havehp : (lazy table).relations[rowIndex n (2 * d) (v, lazyPorts d (true, p))] =
table.relations[rowIndex n d (v, p)] :=by
apply relation_ext
intro a b
exact lazy_accepts_true table v p a b
exact congrArg₂ (DartRow.mk v) hr hp
theoremmoveRow_reverse_val (table : PortTables.Table n d) (v : Fin n) (p : Fin d) :
(moveRow table v p).reverseIndex.val =
reverseMap d (row table v p).reverseIndex.val :=by
proof · 4
lines
simp only [moveRow, rowIndex_val, lazyPorts_true_val, reverseMap, row]
change (table.reverseIndex[rowIndex n d (v, p)]).val % d + d +
(2 * d) * ((table.reverseIndex[rowIndex n d (v, p)]).val / d) = _
omega
theoremmoveRow_words (table : PortTables.Table n d) (v : Fin n) (p : Fin d) :
rowWords (moveRow table v p) =
[v.val, reverseMap d (row table v p).reverseIndex.val] ++
relationWords (row table v p).relation :=by
theoremofFn_rowIndex {α : Type*} (f : Fin (n * d) → α) :
List.ofFn f = (List.ofFn fun v : Fin n =>List.ofFn fun p : Fin d => f (rowIndex n d (v, p))).flatten :=by
proof · 10
lines
rw [List.ofFn_mul]
apply congrArg List.flatten
congr 1
funext v
congr 1
funext p
apply congrArg f
apply Fin.ext
simp only [rowIndex_val]
ac_rfl
theoremofFn_lazyPorts {α : Type*} (f : Fin (2 * d) → α) :
List.ofFn f = List.ofFn (fun p => f (lazyPorts d (false, p))) ++
List.ofFn (fun p => f (lazyPorts d (true, p))) :=by
proof · 9
lines
have hf (p : Fin d) : rowIndex 2 d (0, p) = lazyPorts d (false, p) :=by
apply Fin.ext
simp only [rowIndex_val, Fin.val_zero, Nat.mul_zero, Nat.add_zero, lazyPorts_false_val]
have ht (p : Fin d) : rowIndex 2 d ((0 : Fin1).succ, p) = lazyPorts d (true, p) :=by
apply Fin.ext
simp only [rowIndex_val, Fin.val_succ, Fin.val_zero, Nat.zero_add,
Nat.mul_one, lazyPorts_true_val]
simpa only [List.ofFn_succ, List.ofFn_zero, List.flatten_cons, List.flatten_nil,
List.append_nil, hf, ht] using (ofFn_rowIndex (n :=2) (d := d) f)
theoremvertexRows_words (table : PortTables.Table n d) (v : Fin n) :
(vertexRows table v).flatMap rowWords =
(List.ofFn fun p : Fin d =>
[v.val, 2 * d * v.val + p.val] ++ List.replicate 40961).flatten ++
(List.ofFn fun p : Fin d =>
[v.val, reverseMap d (row table v p).reverseIndex.val] ++
relationWords (row table v p).relation).flatten :=by
proof · 12
lines
havehs : rowWords ∘ stayRow d v = funp : Fin d =>
[v.val, 2 * d * v.val + p.val] ++ List.replicate 40961:=by
funext p
exact stayRow_words v p
havehm : rowWords ∘ moveRow table v = funp : Fin d =>
[v.val, reverseMap d (row table v p).reverseIndex.val] ++
relationWords (row table v p).relation :=by
funext p
exact moveRow_words table v p
simp only [vertexRows, List.flatMap_def, List.map_append, List.map_ofFn,
List.flatten_append]
rw [hs, hm]