Download lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingInternalRows.lean from roseking/openAI-math-dataset: direct link, hf CLI and curl.
defrow (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) :
GraphTables.DartRow (vertexCount t padding) (vertexCount t padding * (q + 1)) :=
body · 1
line
(PortTables.flatRows (ofCloudTables t padding tables))[rowIndex t padding v x p]
theoremcloud_rotation (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) :
(cloudGraphs t padding tables v).rot (x, p) =
(destination t padding tables v x p, (localStep t padding tables v x p).2) :=by
proof · 5
lines
have h :=GraphTransport.reindex_rot (ExpanderTables.graph (tables v))
(paddedCloudEquiv t padding v).symm (Equiv.refl _)
(paddedCloudRank t padding v x) p
simpa only [cloudGraphs, ExpanderTables.graph_rot, Equiv.refl_apply,
paddedCloudRank, paddedCloudSelect, Equiv.symm_apply_apply, destination, localStep] using h
theoremsource_rotation (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) :
(sourcePortGraph t padding tables).rot (x.val, .inl p) =
((destination t padding tables v x p).val,
.inl (localStep t padding tables v x p).2) :=by
proof · 7
lines
rcases x with ⟨x, hx⟩
subst v
exact congrArg
(funz : PaddedCloud t padding
((paddedGraph (GraphTables.semantics t) (fun v =>Fin (padding v))).tail x) ×Fin q =>
(z.1.val, (Sum.inl z.2 : Fin q ⊕ Unit)))
(cloud_rotation t padding tables _ ⟨x, rfl⟩ p)
theoremrotation_internal (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) :
PortTables.rotation (ofCloudTables t padding tables)
(vertexOrder t padding x.val, portOrder q (.inl p)) =
(vertexOrder t padding (destination t padding tables v x p).val,
portOrder q (.inl (localStep t padding tables v x p).2)) :=by
proof · 1
line
rw [rotation_ofCloudTables, source_rotation t padding tables v x p]
theoremreverseIndex_internal (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) :
((ofCloudTables t padding tables).reverseIndex[rowIndex t padding v x p]).val =
(q + 1) * (vertexOrder t padding (destination t padding tables v x p).val).val +
(localStep t padding tables v x p).2.val :=by
proof · 5
lines
unfold rowIndex
rw [←PortTables.rowIndex_rotation, rotation_internal t padding tables v x p,
PortTables.rowIndex_val, portOrder_internal]
dsimp only
omega
theoremrelation_ext {r s : GraphTables.RelationTable}
(h : ∀ a b, GraphTables.relationAt r a b = GraphTables.relationAt s a b) : r = s :=by
proof · 6
lines
apply Vector.ext
intro i hi
simpa only [GraphTables.relationAt, Prod.eta, Equiv.apply_symm_apply,
Fin.getElem_fin] using
h (GraphTables.relationIndex.symm ⟨i, hi⟩).1
(GraphTables.relationIndex.symm ⟨i, hi⟩).2
theoremrelations_internal (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) :
(ofCloudTables t padding tables).relations[rowIndex t padding v x p] = equalityRelation :=by
proof · 4
lines
apply relation_ext
intro a b
rw [equalityRelation_apply]
exact accepts_internal t padding tables x.val p a b
@[simp]theoremrow_tail (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) :
(row t padding tables v x p).tail.val = (vertexOrder t padding x.val).val :=by
proof · 2
lines
simp only [row, rowIndex, PortTables.flatRows, Vector.getElem_ofFn,
Fin.getElem_fin, Fin.eta, Equiv.symm_apply_apply]
theoremrow_reverse (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) :
(row t padding tables v x p).reverseIndex.val =
(q + 1) * (vertexOrder t padding (destination t padding tables v x p).val).val +
(localStep t padding tables v x p).2.val :=by
proof · 2
lines
simpa only [row, PortTables.flatRows, Vector.getElem_ofFn, Fin.getElem_fin] using
reverseIndex_internal t padding tables v x p
@[simp]theoremrow_relation (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) :
(row t padding tables v x p).relation = equalityRelation :=by
proof · 2
lines
simpa only [row, PortTables.flatRows, Vector.getElem_ofFn, Fin.getElem_fin] using
relations_internal t padding tables v x p
@[simp]theoremlocalStep_original (v : Fin t.vertices) (x : Cloud (GraphTables.semantics t) v)
(p : Fin q) :
localStep t padding tables v (paddedOld t padding v x) p =
ExpanderTables.lookup (tables v) (Fin.castAdd (padding v) (cloudRank t v x), p) := rfl
@[simp]theoremlocalStep_dummy (v : Fin t.vertices) (j : Fin (padding v)) (p : Fin q) :
localStep t padding tables v (paddedNew t padding v j) p =
ExpanderTables.lookup (tables v) (Fin.natAdd (cloudSize t v) j, p) := rfl
@[simp]theoremrow_tail_original (v : Fin t.vertices) (x : Cloud (GraphTables.semantics t) v)
(p : Fin q) :
(row t padding tables v (paddedOld t padding v x) p).tail.val = x.val.val :=by
@[simp]theoremrow_tail_dummy (v : Fin t.vertices) (j : Fin (padding v)) (p : Fin q) :
(row t padding tables v (paddedNew t padding v j) p).tail.val =
t.darts + PreprocessingPaddingOffsets.offset padding v.val + j.val :=by
proof · 2
lines
rw [row_tail]
exact PreprocessingPaddingOffsets.vertexOrder_dummy_val t padding v j
defselectedIndex (v : Fin t.vertices) (i : Fin (cloudSize t v + padding v)) : Nat:=
body · 3
lines
ifhi : i.val < cloudSize t v then
(cloudSelect t v ⟨i.val, hi⟩).val.val
else t.darts + PreprocessingPaddingOffsets.offset padding v.val + (i.val - cloudSize t v)
theoremselectedIndex_eq (v : Fin t.vertices) (i : Fin (cloudSize t v + padding v)) :
(vertexOrder t padding (paddedCloudSelect t padding v i).val).val =
selectedIndex t padding v i :=by
proof · 20
lines
unfold selectedIndex
split
· rename_i hi
havehe : i = Fin.castAdd (padding v) (⟨i.val, hi⟩ : Fin (cloudSize t v)) :=Fin.ext rfl
refine (congrArg (fun j =>
(vertexOrder t padding (paddedCloudSelect t padding v j).val).val) he).trans ?_
rw [paddedCloudSelect_castAdd]
rfl
· rename_i hi
havehj : i.val - cloudSize t v < padding v :=byhave h := i.isLt; omega
havehe : i = Fin.natAdd (cloudSize t v) (⟨i.val - cloudSize t v, hj⟩ : Fin (padding v)) :=by
apply Fin.ext
dsimp only [Fin.val_natAdd]
omega
refine (congrArg (fun j =>
(vertexOrder t padding (paddedCloudSelect t padding v j).val).val) he).trans ?_
rw [paddedCloudSelect_natAdd]
change (vertexOrder t padding
(Sum.inr ⟨v, (⟨i.val - cloudSize t v, hj⟩ : Fin (padding v))⟩)).val = _
exact PreprocessingPaddingOffsets.vertexOrder_dummy_val t padding v _
theoremselectedIndex_old (v : Fin t.vertices) (i : Fin (cloudSize t v + padding v))
(hi : i.val < cloudSize t v) :
selectedIndex t padding v i = (cloudSelect t v ⟨i.val, hi⟩).val.val :=by
theoremselectedIndex_dummy (v : Fin t.vertices) (i : Fin (cloudSize t v + padding v))
(hi : cloudSize t v ≤ i.val) :
selectedIndex t padding v i =
t.darts + PreprocessingPaddingOffsets.offset padding v.val + (i.val - cloudSize t v) :=by
proof · 1
line
simp only [selectedIndex, dite_eq_right (Nat.not_lt_of_ge hi)]
theoremrow_reverse_selectedIndex (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) :
(row t padding tables v x p).reverseIndex.val =
(q + 1) * selectedIndex t padding v (localStep t padding tables v x p).1 +
(localStep t padding tables v x p).2.val :=by
theoremrowWords_eq (v : Fin t.vertices) (x : PaddedCloud t padding v) (p : Fin q) :
GraphTables.rowWords (row t padding tables v x p) =
[(vertexOrder t padding x.val).val,
(q + 1) * selectedIndex t padding v (localStep t padding tables v x p).1 +
(localStep t padding tables v x p).2.val] ++
GraphTables.relationWords equalityRelation :=by