Skip to content

Commit 72ea06d

Browse files
committed
refactor(Combinatorics/SimpleGraph/Walk): simplify proof of "support_tail_of_not_nil" (#28967)
The proof of the lemma named "support_tail_of_not_nil" is shortened. Since "support_tail" is not needed anymore, it is removed. @[deprecated (since := "2025-08-26")] sign is added for the removed "support_tail". The library references to "support_tail" are replaced with "support_tail_of_not_nil". To keep [@simp] on "cons_support_tail" and avoid the linter error, the [@simp] of "support_tail_of_not_nil" (previously on "support_tail") is removed. There might be a better way that I am missing, to deal with the linter error. Co-authored-by: utkuo <utkuokur@gmail.com>
1 parent 2ea7c11 commit 72ea06d

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

Mathlib/Combinatorics/SimpleGraph/Hamiltonian.lean

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,13 @@ lemma isHamiltonianCycle_isCycle_and_isHamiltonian_tail :
126126
lemma isHamiltonianCycle_iff_isCycle_and_support_count_tail_eq_one :
127127
p.IsHamiltonianCycle ↔ p.IsCycle ∧ ∀ a, (support p).tail.count a = 1 := by
128128
simp +contextual [isHamiltonianCycle_isCycle_and_isHamiltonian_tail,
129-
IsHamiltonian, support_tail, IsCycle.not_nil]
129+
IsHamiltonian, support_tail_of_not_nil, IsCycle.not_nil]
130130

131131
/-- A Hamiltonian cycle visits every vertex. -/
132132
lemma IsHamiltonianCycle.mem_support (hp : p.IsHamiltonianCycle) (b : α) :
133133
b ∈ p.support :=
134-
List.mem_of_mem_tail <| support_tail p hp.1.not_nil ▸ hp.isHamiltonian_tail.mem_support _
134+
List.mem_of_mem_tail <|
135+
support_tail_of_not_nil p hp.1.not_nil ▸ hp.isHamiltonian_tail.mem_support _
135136

136137
/-- The length of a Hamiltonian cycle is the number of vertices. -/
137138
lemma IsHamiltonianCycle.length_eq [Fintype α] (hp : p.IsHamiltonianCycle) :
@@ -142,7 +143,8 @@ lemma IsHamiltonianCycle.length_eq [Fintype α] (hp : p.IsHamiltonianCycle) :
142143

143144
lemma IsHamiltonianCycle.count_support_self (hp : p.IsHamiltonianCycle) :
144145
p.support.count a = 2 := by
145-
rw [support_eq_cons, List.count_cons_self, ← support_tail _ hp.1.not_nil, hp.isHamiltonian_tail]
146+
rw [support_eq_cons, List.count_cons_self,
147+
← support_tail_of_not_nil _ hp.1.not_nil, hp.isHamiltonian_tail]
146148

147149
lemma IsHamiltonianCycle.support_count_of_ne (hp : p.IsHamiltonianCycle) (h : a ≠ b) :
148150
p.support.count b = 1 := by

Mathlib/Combinatorics/SimpleGraph/Walk.lean

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,16 +1162,11 @@ lemma not_nil_of_tail_not_nil {p : G.Walk v w} (hp : ¬ p.tail.Nil) : ¬ p.Nil :
11621162
(p.copy hu hv).Nil = p.Nil := by
11631163
subst_vars; rfl
11641164

1165-
@[simp] lemma support_tail (p : G.Walk u u) (hp : ¬ p.Nil) :
1165+
lemma support_tail_of_not_nil (p : G.Walk u v) (hp : ¬ p.Nil) :
11661166
p.tail.support = p.support.tail := by
11671167
rw [← cons_support_tail p hp, List.tail_cons]
11681168

1169-
lemma support_tail_of_not_nil (p : G.Walk u v) (hnp : ¬p.Nil) :
1170-
p.tail.support = p.support.tail := by
1171-
match p with
1172-
| .nil => simp only [nil_nil, not_true_eq_false] at hnp
1173-
| .cons h q =>
1174-
simp only [tail_cons, getVert_cons_succ, support_copy, support_cons, List.tail_cons]
1169+
@[deprecated (since := "2025-08-26")] alias support_tail := support_tail_of_not_nil
11751170

11761171
/-- Given a set `S` and a walk `w` from `u` to `v` such that `u ∈ S` but `v ∉ S`,
11771172
there exists a dart in the walk whose start is in `S` but whose end is not. -/

0 commit comments

Comments
 (0)