Skip to content

Commit ff99cda

Browse files
committed
feat(SimpleGraph/Walk): edge sets of walks (#23946)
We introduce a definition `SimpleGraph.Walk.edgeSet (p : SimpleGraph.Walk G u v) : Set (Sym2 V)` for the edge set of a walk, and give a few very basic API lemmas. This allows us to avoid both decidability and the ugly `p.edges.toFinset.toSet` when talking about the set of edges of a walk.
1 parent f4c39d0 commit ff99cda

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

Mathlib/Combinatorics/SimpleGraph/Walk.lean

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,37 @@ theorem edges_injective {u v : V} : Function.Injective (Walk.edges : G.Walk u v
780780
theorem darts_injective {u v : V} : Function.Injective (Walk.darts : G.Walk u v → List G.Dart) :=
781781
edges_injective.of_comp
782782

783+
/-- The `Set` of edges of a walk. -/
784+
def edgeSet {u v : V} (p : G.Walk u v) : Set (Sym2 V) := {e | e ∈ p.edges}
785+
786+
@[simp]
787+
lemma mem_edgeSet {u v : V} {p : G.Walk u v} {e : Sym2 V} : e ∈ p.edgeSet ↔ e ∈ p.edges := Iff.rfl
788+
789+
@[simp]
790+
lemma edgeSet_nil (u : V) : (nil : G.Walk u u).edgeSet = ∅ := by ext; simp
791+
792+
@[simp]
793+
lemma edgeSet_reverse {u v : V} (p : G.Walk u v) : p.reverse.edgeSet = p.edgeSet := by ext; simp
794+
795+
@[simp]
796+
theorem edgeSet_cons {u v w : V} (h : G.Adj u v) (p : G.Walk v w) :
797+
(cons h p).edgeSet = insert s(u, v) p.edgeSet := by ext; simp
798+
799+
@[simp]
800+
theorem edgeSet_concat {u v w : V} (p : G.Walk u v) (h : G.Adj v w) :
801+
(p.concat h).edgeSet = insert s(v, w) p.edgeSet := by ext; simp [or_comm]
802+
803+
theorem edgeSet_append {u v w : V} (p : G.Walk u v) (q : G.Walk v w) :
804+
(p.append q).edgeSet = p.edgeSet ∪ q.edgeSet := by ext; simp
805+
806+
@[simp]
807+
theorem edgeSet_copy {u v u' v'} (p : G.Walk u v) (hu : u = u') (hv : v = v') :
808+
(p.copy hu hv).edgeSet = p.edgeSet := by ext; simp
809+
810+
theorem coe_edges_toFinset [DecidableEq V] {u v : V} (p : G.Walk u v) :
811+
(p.edges.toFinset : Set (Sym2 V)) = p.edgeSet := by
812+
simp [edgeSet]
813+
783814
/-- Predicate for the empty walk.
784815
785816
Solves the dependent type problem where `p = G.Walk.nil` typechecks
@@ -1122,6 +1153,9 @@ theorem edges_map : (p.map f).edges = p.edges.map (Sym2.map f) := by
11221153
simp only [Walk.map_cons, edges_cons, List.map_cons, Sym2.map_pair_eq, List.cons.injEq,
11231154
true_and, ih]
11241155

1156+
@[simp]
1157+
theorem edgeSet_map : (p.map f).edgeSet = Sym2.map f '' p.edgeSet := by ext; simp
1158+
11251159
theorem map_injective_of_injective {f : G →g G'} (hinj : Function.Injective f) (u v : V) :
11261160
Function.Injective (Walk.map f : G.Walk u v → G'.Walk (f u) (f v)) := by
11271161
intro p p' h
@@ -1171,6 +1205,9 @@ theorem transfer_eq_map_ofLE (hp) (GH : G ≤ H) : p.transfer H hp = p.map (.ofL
11711205
theorem edges_transfer (hp) : (p.transfer H hp).edges = p.edges := by
11721206
induction p <;> simp [*]
11731207

1208+
@[simp]
1209+
theorem edgeSet_transfer (hp) : (p.transfer H hp).edgeSet = p.edgeSet := by ext; simp
1210+
11741211
@[simp]
11751212
theorem support_transfer (hp) : (p.transfer H hp).support = p.support := by
11761213
induction p <;> simp [*]

0 commit comments

Comments
 (0)