Skip to content

Commit 3a762c3

Browse files
committed
feat(SimpleGraph): lemmas relating edges and darts to the support (#26720)
Useful lemmas to make it easier to pass between the support/edges/darts of a walk. - [x] depends on: #25812
1 parent 6e59af1 commit 3a762c3

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Mathlib/Combinatorics/SimpleGraph/Walk.lean

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,23 @@ theorem nodup_tail_support_reverse {u : V} {p : G.Walk u u} :
824824
← getVert_eq_support_getElem? _ (by rw [Walk.length_support]; cutsat)]
825825
aesop
826826

827+
theorem edges_eq_zipWith_support {u v : V} {p : G.Walk u v} :
828+
p.edges = List.zipWith (s(·, ·)) p.support p.support.tail := by
829+
induction p with
830+
| nil => simp
831+
| cons _ p' ih => cases p' <;> simp [edges_cons, ih]
832+
833+
theorem darts_getElem_eq_getVert {u v : V} {p : G.Walk u v} (n : ℕ) (h : n < p.darts.length) :
834+
p.darts[n] = ⟨⟨p.getVert n, p.getVert (n + 1)⟩, p.adj_getVert_succ (p.length_darts ▸ h)⟩ := by
835+
rw [p.length_darts] at h
836+
ext
837+
· simp only [p.getVert_eq_support_getElem (le_of_lt h)]
838+
by_cases h' : n = 0
839+
· simp [h', List.getElem_zero]
840+
· have := p.isChain_dartAdj_darts.getElem (n - 1) (by grind)
841+
grind [DartAdj, =_ cons_map_snd_darts]
842+
· simp [p.getVert_eq_support_getElem h, ← p.cons_map_snd_darts]
843+
827844
theorem edges_injective {u v : V} : Function.Injective (Walk.edges : G.Walk u v → List (Sym2 V))
828845
| .nil, .nil, _ => rfl
829846
| .nil, .cons _ _, h => by simp at h
@@ -1103,6 +1120,15 @@ lemma edge_firstDart (p : G.Walk v w) (hp : ¬ p.Nil) :
11031120
lemma edge_lastDart (p : G.Walk v w) (hp : ¬ p.Nil) :
11041121
(p.lastDart hp).edge = s(p.penultimate, w) := rfl
11051122

1123+
theorem firstDart_eq {p : G.Walk v w} (h₁ : ¬ p.Nil) (h₂ : 0 < p.darts.length) :
1124+
p.firstDart h₁ = p.darts[0] := by
1125+
simp [Dart.ext_iff, firstDart_toProd, darts_getElem_eq_getVert]
1126+
1127+
theorem lastDart_eq {p : G.Walk v w} (h₁ : ¬ p.Nil) (h₂ : 0 < p.darts.length) :
1128+
p.lastDart h₁ = p.darts[p.darts.length - 1] := by
1129+
simp (disch := grind) [Dart.ext_iff, lastDart_toProd, darts_getElem_eq_getVert,
1130+
p.getVert_of_length_le]
1131+
11061132
lemma cons_tail_eq (p : G.Walk u v) (hp : ¬ p.Nil) :
11071133
cons (p.adj_snd hp) p.tail = p := by
11081134
cases p with
@@ -1556,3 +1582,5 @@ lemma isSubwalk_antisymm {u v} {p₁ p₂ : G.Walk u v} (h₁ : p₁.IsSubwalk p
15561582
end Walk
15571583

15581584
end SimpleGraph
1585+
1586+
set_option linter.style.longFile 1700

0 commit comments

Comments
 (0)