Hamiltonian cycles
Lax881656.HamiltonianCycle · concepts/Lax881656/HamiltonianCycle.lean · lax-881656
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
A Hamiltonian cycle in a graph is a cycle that visits every vertex. A graph has a Hamiltonian cycle when such a closed walk exists.
Concept map
Lean source view on GitHub
| 1 | import Mathlib.Combinatorics.SimpleGraph.Paths |
| 2 | |
| 3 | /-! |
| 4 | --- |
| 5 | title: Hamiltonian cycles |
| 6 | type: definition |
| 7 | --- |
| 8 | A Hamiltonian cycle in a graph is a cycle that visits every vertex. A graph |
| 9 | has a Hamiltonian cycle when such a closed walk exists. |
| 10 | |
| 11 | # Formalization notes |
| 12 | |
| 13 | A cycle is represented by mathlib's closed-walk predicate, which ensures that |
| 14 | no vertex is repeated except for the common start and end. The separate |
| 15 | spanning condition says that every graph vertex belongs to its support. |
| 16 | -/ |
| 17 | |
| 18 | set_option autoImplicit false |
| 19 | |
| 20 | namespace Lax881656.HamiltonianCycle |
| 21 | |
| 22 | /-- A closed walk is a Hamiltonian cycle when it is a cycle and visits every |
| 23 | vertex of the graph. -/ |
| 24 | def IsHamiltonianCycle {V : Type*} [DecidableEq V] {G : SimpleGraph V} |
| 25 | {v : V} (cycle : G.Walk v v) : Prop := |
| 26 | cycle.IsCycle ∧ ∀ w : V, w ∈ cycle.support |
| 27 | |
| 28 | /-- A graph has a Hamiltonian cycle when it contains a spanning cycle. -/ |
| 29 | def HasHamiltonianCycle {V : Type*} [DecidableEq V] |
| 30 | (G : SimpleGraph V) : Prop := |
| 31 | ∃ v : V, ∃ cycle : G.Walk v v, IsHamiltonianCycle cycle |
| 32 | |
| 33 | end Lax881656.HamiltonianCycle |
| 34 |
Formalization notes
A cycle is represented by mathlib's closed-walk predicate, which ensures that no vertex is repeated except for the common start and end. The separate spanning condition says that every graph vertex belongs to its support.
Builds on
none
Used by
From Mathlib
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments