Skip to content

Commit 61abd2f

Browse files
committed
feat: Add next_getLast_eq_head (leanprover-community#31714)
1 parent dba5de8 commit 61abd2f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Mathlib/Data/List/Cycle.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,12 @@ theorem prev_getElem (l : List α) (h : Nodup l) (i : Nat) (hi : i < l.length) :
316316
rw [nodup_iff_injective_get] at h
317317
apply h; rw [← H]; simp
318318

319+
@[simp]
320+
theorem next_getLast_eq_head (l : List α) (h : l ≠ []) (hn : l.Nodup) :
321+
l.next (l.getLast h) (getLast_mem h) = l.head h := by
322+
have h1 : l.length - 1 + 1 = l.length := by grind [length_pos_iff]
323+
simp [getLast_eq_getElem h, head_eq_getElem h, next_getElem l hn (l.length - 1) (by grind), h1]
324+
319325
theorem pmap_next_eq_rotate_one (h : Nodup l) : (l.pmap l.next fun _ h => h) = l.rotate 1 := by
320326
apply List.ext_getElem
321327
· simp

0 commit comments

Comments
 (0)