Skip to content

Commit bcade54

Browse files
committed
feat(Combinatorics/SimpleGraph/Hamiltonian): every walk is hamiltonian if Subsingleton V (leanprover-community#34185)
1 parent 62a82d6 commit bcade54

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Mathlib/Combinatorics/SimpleGraph/Hamiltonian.lean

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ lemma IsPath.isHamiltonian_of_mem (hp : p.IsPath) (hp' : ∀ w, w ∈ p.support)
5555
lemma IsPath.isHamiltonian_iff (hp : p.IsPath) : p.IsHamiltonian ↔ ∀ w, w ∈ p.support :=
5656
⟨(·.mem_support), hp.isHamiltonian_of_mem⟩
5757

58+
theorem IsHamiltonian.of_subsingleton [Subsingleton α] : p.IsHamiltonian := by
59+
intro v
60+
rw [nil_iff_support_eq.mp p.nil_of_subsingleton, Subsingleton.elim v a, List.count_singleton_self]
61+
5862
/-- If a path `p` is Hamiltonian then its vertex set must be finite. -/
5963
protected def IsHamiltonian.fintype (hp : p.IsHamiltonian) : Fintype α where
6064
elems := p.support.toFinset
@@ -179,6 +183,12 @@ lemma IsHamiltonian.connected (hG : G.IsHamiltonian) : G.Connected where
179183
exact ((p.takeUntil a a_mem).reverse.append <| p.takeUntil b b_mem).reachable
180184
nonempty := not_isEmpty_iff.1 fun _ ↦ by simpa using hG <| by simp [@Fintype.card_eq_zero]
181185

186+
lemma IsHamiltonian.of_card_eq_one (h : Fintype.card α = 1) : G.IsHamiltonian :=
187+
(· h |>.elim)
188+
189+
lemma IsHamiltonian.of_unique [Unique α] : G.IsHamiltonian :=
190+
of_card_eq_one <| Fintype.card_unique
191+
182192
variable {V : Type*} [Fintype V] [DecidableEq V]
183193

184194
/--

Mathlib/Combinatorics/SimpleGraph/Walks/Basic.lean

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,11 @@ lemma nil_iff_eq_nil : ∀ {p : G.Walk v v}, p.Nil ↔ p = nil
383383

384384
alias ⟨Nil.eq_nil, _⟩ := nil_iff_eq_nil
385385

386+
lemma nil_of_subsingleton [Subsingleton V] (p : G.Walk v w) : p.Nil :=
387+
match p with
388+
| nil => Nil.nil
389+
| cons h w => Unique.eq_default G ▸ h |>.elim
390+
386391
/-- The recursion principle for nonempty walks -/
387392
@[elab_as_elim]
388393
def notNilRec {motive : {u w : V} → (p : G.Walk u w) → (h : ¬ p.Nil) → Sort*}

0 commit comments

Comments
 (0)