Download lean/OAI/Combinatorics/IndependentSets/Expansion/PreprocessingOverlayWords.lean from roseking/openAI-math-dataset: direct link, hf CLI and curl.
privatetheoremrelation_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_overlay_old (G : PortTables.Table n d) (H : ExpanderTables.Table n e)
(v : Fin n) (p : Fin d) :
row (overlay GH) v (overlayPorts d e (.inl p)) = oldRow G e v p :=by
proof · 9
lines
havehr : (overlay GH).reverseIndex[rowIndex n (d + e) (v, overlayPorts d e (.inl p))] =
rowIndex n (d + e) ((rotation G (v, p)).1,
overlayPorts d e (.inl (rotation G (v, p)).2)) :=by
rw [← rowIndex_rotation, overlay_rotation_old]
havehp : (overlay GH).relations[rowIndex n (d + e) (v, overlayPorts d e (.inl p))] =
G.relations[rowIndex n d (v, p)] :=by
apply relation_ext
exact overlay_accepts_old GH v p
exact congrArg₂ (DartRow.mk v) hr hp
theoremrow_overlay_expander (G : PortTables.Table n d) (H : ExpanderTables.Table n e)
(v : Fin n) (p : Fin e) :
row (overlay GH) v (overlayPorts d e (.inr p)) = expanderRow d H v p :=by
proof · 12
lines
havehr : (overlay GH).reverseIndex[rowIndex n (d + e) (v, overlayPorts d e (.inr p))] =
rowIndex n (d + e) ((ExpanderTables.lookup H (v, p)).1,
overlayPorts d e (.inr (ExpanderTables.lookup H (v, p)).2)) :=by
rw [← rowIndex_rotation, overlay_rotation_expander]
havehp : (overlay GH).relations[rowIndex n (d + e) (v, overlayPorts d e (.inr p))] =
trueRelation :=by
apply relation_ext
intro a b
simpa only [PortTables.accepts, relationAt, trueRelation,
PreprocessingLazyWords.trueRelation, Fin.getElem_fin, Vector.getElem_replicate] using
overlay_accepts_expander GH v p a b
exact congrArg₂ (DartRow.mk v) hr hp
theoremoldRow_reverse_val (G : PortTables.Table n d) (v : Fin n) (p : Fin d) :
(oldRow G e v p).reverseIndex.val = oldReverseMap d e (row G v p).reverseIndex.val :=by
proof · 5
lines
simp only [oldRow, rowIndex_val, overlayPorts_inl_val, oldReverseMap, row,
PreprocessingLazyWords.row]
change (G.reverseIndex[rowIndex n d (v, p)]).val % d +
(d + e) * ((G.reverseIndex[rowIndex n d (v, p)]).val / d) = _
omega
theoremexpanderRow_reverse_val (H : ExpanderTables.Table n e) (v : Fin n) (p : Fin e) :
(expanderRow d H v p).reverseIndex.val =
expanderReverseMap d e (ExpanderTables.reverseIndex H (ExpanderTables.rowIndex n e (v, p))).val :=by
proof · 4
lines
simp only [expanderRow, rowIndex_val, overlayPorts_inr_val, expanderReverseMap]
change d + (ExpanderTables.reverseIndex H (ExpanderTables.rowIndex n e (v, p))).val % e +
(d + e) * ((ExpanderTables.reverseIndex H (ExpanderTables.rowIndex n e (v, p))).val / e) = _
omega
theoremoldRow_words (G : PortTables.Table n d) (v : Fin n) (p : Fin d) :
rowWords (oldRow G e v p) =
[v.val, oldReverseMap d e (row G v p).reverseIndex.val] ++
relationWords (row G v p).relation :=by
theoremexpanderRow_words (H : ExpanderTables.Table n e) (v : Fin n) (p : Fin e) :
rowWords (expanderRow d H v p) =
[v.val, expanderReverseMap d e
(ExpanderTables.reverseIndex H (ExpanderTables.rowIndex n e (v, p))).val] ++
List.replicate 40961:=by
proof · 4
lines
rw [rowWords, expanderRow_reverse_val]
exact congrArg (fun rs => [v.val, expanderReverseMap d e
(ExpanderTables.reverseIndex H (ExpanderTables.rowIndex n e (v, p))).val] ++ rs)
PreprocessingLazyWords.relationWords_true
theoremofFn_overlayPorts {α : Type*} (f : Fin (d + e) → α) :
List.ofFn f = List.ofFn (fun p => f (overlayPorts d e (.inl p))) ++
List.ofFn (fun p => f (overlayPorts d e (.inr p))) :=by
theoremvertexRows_words (G : PortTables.Table n d) (H : ExpanderTables.Table n e) (v : Fin n) :
(vertexRows GH v).flatMap rowWords =
(List.ofFn fun p : Fin d =>
[v.val, oldReverseMap d e (row G v p).reverseIndex.val] ++
relationWords (row G v p).relation).flatten ++
(List.ofFn fun p : Fin e =>
[v.val, expanderReverseMap d e
(ExpanderTables.reverseIndex H (ExpanderTables.rowIndex n e (v, p))).val] ++
List.replicate 40961).flatten :=by
proof · 13
lines
haveho : rowWords ∘ oldRow G e v = funp : Fin d =>
[v.val, oldReverseMap d e (row G v p).reverseIndex.val] ++
relationWords (row G v p).relation :=by
funext p
exact oldRow_words G v p
havehe : rowWords ∘ expanderRow d H v = funp : Fin e =>
[v.val, expanderReverseMap d e
(ExpanderTables.reverseIndex H (ExpanderTables.rowIndex n e (v, p))).val] ++
List.replicate 40961:=by
funext p
exact expanderRow_words H v p
simp only [vertexRows, List.flatMap_def, List.map_append, List.map_ofFn, List.flatten_append]
rw [ho, he]
theoremrotationWords_vertices (H : ExpanderTables.Table n e) :
ExpanderTableWords.rotationWords H =
(List.ofFn fun v : Fin n =>List.ofFn fun p : Fin e =>
(ExpanderTables.reverseIndex H (ExpanderTables.rowIndex n e (v, p))).val).flatten :=by
proof · 9
lines
havehflat : ExpanderTableWords.rotationWords H =
List.ofFn (funi : Fin (n * e) => (ExpanderTables.reverseIndex H i).val) :=by
apply List.ext_getElem
· simp [ExpanderTableWords.rotationWords_length]
· intro i hi hj
rw [ExpanderTableWords.rotationWords_getElem H i (by simpa using hi)]
simp only [List.getElem_ofFn]
rw [hflat, PreprocessingLazyWords.ofFn_rowIndex]
rfl