Skip to content

Commit ae47de7

Browse files
committed
feat(Combinatorics/SimpleGraph/Hamiltonian): golf getVertEquiv using grind
1 parent 2d278af commit ae47de7

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

Mathlib/Combinatorics/SimpleGraph/Hamiltonian.lean

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,14 @@ def IsHamiltonian.supportGetEquiv (hp : p.IsHamiltonian) : Fin p.support.length
7979
/-- If a path `p` is Hamiltonian, then `p.getVert` defines an equivalence between
8080
`Fin p.support.length` and `α`. -/
8181
def IsHamiltonian.getVertEquiv (hp : p.IsHamiltonian) : Fin p.support.length ≃ α where
82-
toFun i := p.getVert i
83-
invFun := IsHamiltonian.supportGetEquiv hp |>.invFun
82+
toFun := p.getVert ∘ Fin.val
83+
invFun := supportGetEquiv hp |>.invFun
8484
left_inv i := by
85-
dsimp only
86-
have := i.prop.trans_eq p.length_support
87-
rw [getVert_eq_support_getElem _ <| by cutsat]
88-
have := p.support.idxOf_getElem hp.isPath.support_nodup _ i.prop
89-
simp [IsHamiltonian.supportGetEquiv, List.getEquivOfForallCountEqOne,
90-
List.Nodup.getEquivOfForallMemList]
91-
congr
92-
right_inv a := by
93-
have := hp.supportGetEquiv.symm a |>.prop
94-
exact (getVert_eq_support_getElem _ <| Nat.le_of_lt_add_one <| this.trans_eq p.length_support)
95-
|>.trans <| p.support.getElem_idxOf this
85+
have := i.prop
86+
grind [getVert_eq_support_getElem, supportGetEquiv, List.getEquivOfForallCountEqOne,
87+
List.Nodup.getEquivOfForallMemList, Equiv.invFun_as_coe, List.idxOf_getElem, length_support]
88+
right_inv a := (getVert_eq_support_getElem _ <| by grind [length_support]).trans <|
89+
p.support.getElem_idxOf <| hp.supportGetEquiv.symm a |>.prop
9690

9791
/-- A Hamiltonian cycle is a cycle that visits every vertex once. -/
9892
structure IsHamiltonianCycle (p : G.Walk a a) : Prop extends p.IsCycle where

0 commit comments

Comments
 (0)