l3lab/ntp-mathlib huggingface dataset:
set_option linter.deprecated false in
theorem next_prev (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
    next l (prev l x hx) (prev_mem _ _ _) = x := by
  obtain ⟨n, hn, rfl⟩ := nthLe_of_mem hx
  simp only [next_nthLe, prev_nthLe, h, Nat.mod_add_mod]
  

Proof state:
case intro.intro
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
n : ℕ
hn : n < length l
hx : nthLe l n hn ∈ l
⊢ nthLe l ((n + (length l - 1) + 1) % length l) (_ : (n + (length l - 1) + 1) % length l < length l) = nthLe l n hn

Next tactic:
cases' l with hd tl
set_option linter.deprecated false in
theorem next_prev (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
    next l (prev l x hx) (prev_mem _ _ _) = x := by
  obtain ⟨n, hn, rfl⟩ := nthLe_of_mem hx
  simp only [next_nthLe, prev_nthLe, h, Nat.mod_add_mod]
  cases' l with hd tl
  · 

Proof state:
case intro.intro.nil
α : Type u_1
inst✝ : DecidableEq α
l : List α
x : α
n : ℕ
h : Nodup []
hn : n < length []
hx : nthLe [] n hn ∈ []
⊢ nthLe [] ((n + (length [] - 1) + 1) % length []) (_ : (n + (length [] - 1) + 1) % length [] < length []) =
    nthLe [] n hn

Next tactic:
simp at hx
set_option linter.deprecated false in
theorem next_prev (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
    next l (prev l x hx) (prev_mem _ _ _) = x := by
  obtain ⟨n, hn, rfl⟩ := nthLe_of_mem hx
  simp only [next_nthLe, prev_nthLe, h, Nat.mod_add_mod]
  cases' l with hd tl
  · simp at hx
  · 

Proof state:
case intro.intro.cons
α : Type u_1
inst✝ : DecidableEq α
l : List α
x : α
n : ℕ
hd : α
tl : List α
h : Nodup (hd :: tl)
hn : n < length (hd :: tl)
hx : nthLe (hd :: tl) n hn ∈ hd :: tl
⊢ nthLe (hd :: tl) ((n + (length (hd :: tl) - 1) + 1) % length (hd :: tl))
      (_ : (n + (length (hd :: tl) - 1) + 1) % length (hd :: tl) < length (hd :: tl)) =
    nthLe (hd :: tl) n hn

Next tactic:
have : (n + length tl + 1) % (length tl + 1) = n := by
      rw [length_cons] at hn
      rw [add_assoc, Nat.add_mod_right, Nat.mod_eq_of_lt hn]
set_option linter.deprecated false in
theorem next_prev (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
    next l (prev l x hx) (prev_mem _ _ _) = x := by
  obtain ⟨n, hn, rfl⟩ := nthLe_of_mem hx
  simp only [next_nthLe, prev_nthLe, h, Nat.mod_add_mod]
  cases' l with hd tl
  · simp at hx
  · have : (n + length tl + 1) % (length tl + 1) = n := by
      

Proof state:
α : Type u_1
inst✝ : DecidableEq α
l : List α
x : α
n : ℕ
hd : α
tl : List α
h : Nodup (hd :: tl)
hn : n < length (hd :: tl)
hx : nthLe (hd :: tl) n hn ∈ hd :: tl
⊢ (n + length tl + 1) % (length tl + 1) = n

Next tactic:
rw [length_cons] at hn
set_option linter.deprecated false in
theorem next_prev (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
    next l (prev l x hx) (prev_mem _ _ _) = x := by
  obtain ⟨n, hn, rfl⟩ := nthLe_of_mem hx
  simp only [next_nthLe, prev_nthLe, h, Nat.mod_add_mod]
  cases' l with hd tl
  · simp at hx
  · have : (n + length tl + 1) % (length tl + 1) = n := by
      rw [length_cons] at hn
      

Proof state:
α : Type u_1
inst✝ : DecidableEq α
l : List α
x : α
n : ℕ
hd : α
tl : List α
h : Nodup (hd :: tl)
hn✝ : n < length (hd :: tl)
hn : n < Nat.succ (length tl)
hx : nthLe (hd :: tl) n hn✝ ∈ hd :: tl
⊢ (n + length tl + 1) % (length tl + 1) = n

Next tactic:
rw [add_assoc, Nat.add_mod_right, Nat.mod_eq_of_lt hn]
set_option linter.deprecated false in
theorem next_prev (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
    next l (prev l x hx) (prev_mem _ _ _) = x := by
  obtain ⟨n, hn, rfl⟩ := nthLe_of_mem hx
  simp only [next_nthLe, prev_nthLe, h, Nat.mod_add_mod]
  cases' l with hd tl
  · simp at hx
  · have : (n + length tl + 1) % (length tl + 1) = n := by
      rw [length_cons] at hn
      rw [add_assoc, Nat.add_mod_right, Nat.mod_eq_of_lt hn]
    

Proof state:
case intro.intro.cons
α : Type u_1
inst✝ : DecidableEq α
l : List α
x : α
n : ℕ
hd : α
tl : List α
h : Nodup (hd :: tl)
hn : n < length (hd :: tl)
hx : nthLe (hd :: tl) n hn ∈ hd :: tl
this : (n + length tl + 1) % (length tl + 1) = n
⊢ nthLe (hd :: tl) ((n + (length (hd :: tl) - 1) + 1) % length (hd :: tl))
      (_ : (n + (length (hd :: tl) - 1) + 1) % length (hd :: tl) < length (hd :: tl)) =
    nthLe (hd :: tl) n hn

Next tactic:
simp [this]
set_option linter.deprecated false in
theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
    prev l.reverse x (mem_reverse.mpr hx) = next l x hx := by
  

Proof state:
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
h : Nodup l
x : α
hx : x ∈ l
⊢ prev (reverse l) x (_ : x ∈ reverse l) = next l x hx

Next tactic:
obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
set_option linter.deprecated false in
theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
    prev l.reverse x (mem_reverse.mpr hx) = next l x hx := by
  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
  

Proof state:
case intro.intro
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
⊢ prev (reverse l) (nthLe l k hk) (_ : nthLe l k hk ∈ reverse l) = next l (nthLe l k hk) hx

Next tactic:
have lpos : 0 < l.length := k.zero_le.trans_lt hk
set_option linter.deprecated false in
theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
    prev l.reverse x (mem_reverse.mpr hx) = next l x hx := by
  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
  have lpos : 0 < l.length := k.zero_le.trans_lt hk
  

Proof state:
case intro.intro
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
lpos : 0 < length l
⊢ prev (reverse l) (nthLe l k hk) (_ : nthLe l k hk ∈ reverse l) = next l (nthLe l k hk) hx

Next tactic:
have key : l.length - 1 - k < l.length :=
    (Nat.sub_le _ _).trans_lt (tsub_lt_self lpos Nat.succ_pos')
set_option linter.deprecated false in
theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
    prev l.reverse x (mem_reverse.mpr hx) = next l x hx := by
  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
  have lpos : 0 < l.length := k.zero_le.trans_lt hk
  have key : l.length - 1 - k < l.length :=
    (Nat.sub_le _ _).trans_lt (tsub_lt_self lpos Nat.succ_pos')
  

Proof state:
case intro.intro
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
lpos : 0 < length l
key : length l - 1 - k < length l
⊢ prev (reverse l) (nthLe l k hk) (_ : nthLe l k hk ∈ reverse l) = next l (nthLe l k hk) hx

Next tactic:
rw [← nthLe_pmap l.next (fun _ h => h) (by simpa using hk)]
set_option linter.deprecated false in
theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
    prev l.reverse x (mem_reverse.mpr hx) = next l x hx := by
  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
  have lpos : 0 < l.length := k.zero_le.trans_lt hk
  have key : l.length - 1 - k < l.length :=
    (Nat.sub_le _ _).trans_lt (tsub_lt_self lpos Nat.succ_pos')
  rw [← nthLe_pmap l.next (fun _ h => h) (by 

Proof state:
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
lpos : 0 < length l
key : length l - 1 - k < length l
⊢ k < length (pmap (next l) l (_ : ∀ x ∈ l, x ∈ l))

Next tactic:
simpa using hk
set_option linter.deprecated false in
theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
    prev l.reverse x (mem_reverse.mpr hx) = next l x hx := by
  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
  have lpos : 0 < l.length := k.zero_le.trans_lt hk
  have key : l.length - 1 - k < l.length :=
    (Nat.sub_le _ _).trans_lt (tsub_lt_self lpos Nat.succ_pos')
  rw [← nthLe_pmap l.next (fun _ h => h) (by simpa using hk)]
  

Proof state:
case intro.intro
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
lpos : 0 < length l
key : length l - 1 - k < length l
⊢ prev (reverse l) (nthLe l k hk) (_ : nthLe l k hk ∈ reverse l) =
    nthLe (pmap (next l) l (_ : ∀ x ∈ l, x ∈ l)) k (_ : k < length (pmap (next l) l (_ : ∀ x ∈ l, x ∈ l)))

Next tactic:
simp_rw [← nthLe_reverse l k (key.trans_le (by simp)), pmap_next_eq_rotate_one _ h]
set_option linter.deprecated false in
theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
    prev l.reverse x (mem_reverse.mpr hx) = next l x hx := by
  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
  have lpos : 0 < l.length := k.zero_le.trans_lt hk
  have key : l.length - 1 - k < l.length :=
    (Nat.sub_le _ _).trans_lt (tsub_lt_self lpos Nat.succ_pos')
  rw [← nthLe_pmap l.next (fun _ h => h) (by simpa using hk)]
  simp_rw [← nthLe_reverse l k (key.trans_le (by 

Proof state:
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
lpos : 0 < length l
key : length l - 1 - k < length l
⊢ length l ≤ length (reverse l)

Next tactic:
simp
set_option linter.deprecated false in
theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
    prev l.reverse x (mem_reverse.mpr hx) = next l x hx := by
  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
  have lpos : 0 < l.length := k.zero_le.trans_lt hk
  have key : l.length - 1 - k < l.length :=
    (Nat.sub_le _ _).trans_lt (tsub_lt_self lpos Nat.succ_pos')
  rw [← nthLe_pmap l.next (fun _ h => h) (by simpa using hk)]
  simp_rw [← nthLe_reverse l k (key.trans_le (by simp)), pmap_next_eq_rotate_one _ h]
  

Proof state:
case intro.intro
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
lpos : 0 < length l
key : length l - 1 - k < length l
⊢ prev (reverse l) (nthLe (reverse l) (length l - 1 - k) (_ : length l - 1 - k < length (reverse l)))
      (_ : nthLe (reverse l) (length l - 1 - k) (_ : length l - 1 - k < length (reverse l)) ∈ reverse l) =
    nthLe (rotate l 1) k (_ : k < length (rotate l 1))

Next tactic:
rw [← nthLe_pmap l.reverse.prev fun _ h => h]
set_option linter.deprecated false in
theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
    prev l.reverse x (mem_reverse.mpr hx) = next l x hx := by
  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
  have lpos : 0 < l.length := k.zero_le.trans_lt hk
  have key : l.length - 1 - k < l.length :=
    (Nat.sub_le _ _).trans_lt (tsub_lt_self lpos Nat.succ_pos')
  rw [← nthLe_pmap l.next (fun _ h => h) (by simpa using hk)]
  simp_rw [← nthLe_reverse l k (key.trans_le (by simp)), pmap_next_eq_rotate_one _ h]
  rw [← nthLe_pmap l.reverse.prev fun _ h => h]
  · 

Proof state:
case intro.intro
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
lpos : 0 < length l
key : length l - 1 - k < length l
⊢ nthLe (pmap (prev (reverse l)) (reverse l) (_ : ∀ x ∈ reverse l, x ∈ reverse l)) (length l - 1 - k) ?intro.intro =
    nthLe (rotate l 1) k (_ : k < length (rotate l 1))

Next tactic:
simp_rw [pmap_prev_eq_rotate_length_sub_one _ (nodup_reverse.mpr h), rotate_reverse,
      length_reverse, Nat.mod_eq_of_lt (tsub_lt_self lpos Nat.succ_pos'),
      tsub_tsub_cancel_of_le (Nat.succ_le_of_lt lpos)]
set_option linter.deprecated false in
theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
    prev l.reverse x (mem_reverse.mpr hx) = next l x hx := by
  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
  have lpos : 0 < l.length := k.zero_le.trans_lt hk
  have key : l.length - 1 - k < l.length :=
    (Nat.sub_le _ _).trans_lt (tsub_lt_self lpos Nat.succ_pos')
  rw [← nthLe_pmap l.next (fun _ h => h) (by simpa using hk)]
  simp_rw [← nthLe_reverse l k (key.trans_le (by simp)), pmap_next_eq_rotate_one _ h]
  rw [← nthLe_pmap l.reverse.prev fun _ h => h]
  · simp_rw [pmap_prev_eq_rotate_length_sub_one _ (nodup_reverse.mpr h), rotate_reverse,
      length_reverse, Nat.mod_eq_of_lt (tsub_lt_self lpos Nat.succ_pos'),
      tsub_tsub_cancel_of_le (Nat.succ_le_of_lt lpos)]
    

Proof state:
case intro.intro
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
lpos : 0 < length l
key : length l - 1 - k < length l
⊢ nthLe (reverse (rotate l (Nat.succ 0))) (length l - 1 - k)
      (_ : length l - 1 - k < length (reverse (rotate l (Nat.succ 0)))) =
    nthLe (rotate l 1) k (_ : k < length (rotate l 1))

Next tactic:
rw [← nthLe_reverse]
set_option linter.deprecated false in
theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
    prev l.reverse x (mem_reverse.mpr hx) = next l x hx := by
  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
  have lpos : 0 < l.length := k.zero_le.trans_lt hk
  have key : l.length - 1 - k < l.length :=
    (Nat.sub_le _ _).trans_lt (tsub_lt_self lpos Nat.succ_pos')
  rw [← nthLe_pmap l.next (fun _ h => h) (by simpa using hk)]
  simp_rw [← nthLe_reverse l k (key.trans_le (by simp)), pmap_next_eq_rotate_one _ h]
  rw [← nthLe_pmap l.reverse.prev fun _ h => h]
  · simp_rw [pmap_prev_eq_rotate_length_sub_one _ (nodup_reverse.mpr h), rotate_reverse,
      length_reverse, Nat.mod_eq_of_lt (tsub_lt_self lpos Nat.succ_pos'),
      tsub_tsub_cancel_of_le (Nat.succ_le_of_lt lpos)]
    rw [← nthLe_reverse]
    · 

Proof state:
case intro.intro
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
lpos : 0 < length l
key : length l - 1 - k < length l
⊢ nthLe (reverse (reverse (rotate l (Nat.succ 0)))) (length (reverse (rotate l (Nat.succ 0))) - 1 - (length l - 1 - k))
      ?intro.intro.h1 =
    nthLe (rotate l 1) k (_ : k < length (rotate l 1))

Next tactic:
simp [tsub_tsub_cancel_of_le (Nat.le_sub_one_of_lt hk)]
set_option linter.deprecated false in
theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
    prev l.reverse x (mem_reverse.mpr hx) = next l x hx := by
  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
  have lpos : 0 < l.length := k.zero_le.trans_lt hk
  have key : l.length - 1 - k < l.length :=
    (Nat.sub_le _ _).trans_lt (tsub_lt_self lpos Nat.succ_pos')
  rw [← nthLe_pmap l.next (fun _ h => h) (by simpa using hk)]
  simp_rw [← nthLe_reverse l k (key.trans_le (by simp)), pmap_next_eq_rotate_one _ h]
  rw [← nthLe_pmap l.reverse.prev fun _ h => h]
  · simp_rw [pmap_prev_eq_rotate_length_sub_one _ (nodup_reverse.mpr h), rotate_reverse,
      length_reverse, Nat.mod_eq_of_lt (tsub_lt_self lpos Nat.succ_pos'),
      tsub_tsub_cancel_of_le (Nat.succ_le_of_lt lpos)]
    rw [← nthLe_reverse]
    · simp [tsub_tsub_cancel_of_le (Nat.le_sub_one_of_lt hk)]
    · 

Proof state:
case intro.intro.h1
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
lpos : 0 < length l
key : length l - 1 - k < length l
⊢ length (reverse (rotate l (Nat.succ 0))) - 1 - (length l - 1 - k) < length (reverse (reverse (rotate l (Nat.succ 0))))

Next tactic:
simpa using (Nat.sub_le _ _).trans_lt (tsub_lt_self lpos Nat.succ_pos')
set_option linter.deprecated false in
theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
    prev l.reverse x (mem_reverse.mpr hx) = next l x hx := by
  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
  have lpos : 0 < l.length := k.zero_le.trans_lt hk
  have key : l.length - 1 - k < l.length :=
    (Nat.sub_le _ _).trans_lt (tsub_lt_self lpos Nat.succ_pos')
  rw [← nthLe_pmap l.next (fun _ h => h) (by simpa using hk)]
  simp_rw [← nthLe_reverse l k (key.trans_le (by simp)), pmap_next_eq_rotate_one _ h]
  rw [← nthLe_pmap l.reverse.prev fun _ h => h]
  · simp_rw [pmap_prev_eq_rotate_length_sub_one _ (nodup_reverse.mpr h), rotate_reverse,
      length_reverse, Nat.mod_eq_of_lt (tsub_lt_self lpos Nat.succ_pos'),
      tsub_tsub_cancel_of_le (Nat.succ_le_of_lt lpos)]
    rw [← nthLe_reverse]
    · simp [tsub_tsub_cancel_of_le (Nat.le_sub_one_of_lt hk)]
    · simpa using (Nat.sub_le _ _).trans_lt (tsub_lt_self lpos Nat.succ_pos')
    · 

Proof state:
case intro.intro
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
lpos : 0 < length l
key : length l - 1 - k < length l
⊢ length l - 1 - k < length (pmap (prev (reverse l)) (reverse l) (_ : ∀ x ∈ reverse l, x ∈ reverse l))

Next tactic:
simpa
theorem next_reverse_eq_prev (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
    next l.reverse x (mem_reverse.mpr hx) = prev l x hx := by
  

Proof state:
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
h : Nodup l
x : α
hx : x ∈ l
⊢ next (reverse l) x (_ : x ∈ reverse l) = prev l x hx

Next tactic:
convert (prev_reverse_eq_next l.reverse (nodup_reverse.mpr h) x (mem_reverse.mpr hx)).symm
theorem next_reverse_eq_prev (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
    next l.reverse x (mem_reverse.mpr hx) = prev l x hx := by
  convert (prev_reverse_eq_next l.reverse (nodup_reverse.mpr h) x (mem_reverse.mpr hx)).symm
  

Proof state:
case h.e'_3.h.e'_3
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
h : Nodup l
x : α
hx : x ∈ l
⊢ l = reverse (reverse l)

Next tactic:
exact (reverse_reverse l).symm
set_option linter.deprecated false in
theorem isRotated_next_eq {l l' : List α} (h : l ~r l') (hn : Nodup l) {x : α} (hx : x ∈ l) :
    l.next x hx = l'.next x (h.mem_iff.mp hx) := by
  

Proof state:
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l l' : List α
h : l ~r l'
hn : Nodup l
x : α
hx : x ∈ l
⊢ next l x hx = next l' x (_ : x ∈ l')

Next tactic:
obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
set_option linter.deprecated false in
theorem isRotated_next_eq {l l' : List α} (h : l ~r l') (hn : Nodup l) {x : α} (hx : x ∈ l) :
    l.next x hx = l'.next x (h.mem_iff.mp hx) := by
  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
  

Proof state:
case intro.intro
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x : α
l l' : List α
h : l ~r l'
hn : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
⊢ next l (nthLe l k hk) hx = next l' (nthLe l k hk) (_ : nthLe l k hk ∈ l')

Next tactic:
obtain ⟨n, rfl⟩ := id h
set_option linter.deprecated false in
theorem isRotated_next_eq {l l' : List α} (h : l ~r l') (hn : Nodup l) {x : α} (hx : x ∈ l) :
    l.next x hx = l'.next x (h.mem_iff.mp hx) := by
  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
  obtain ⟨n, rfl⟩ := id h
  

Proof state:
case intro.intro.intro
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
hn : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
n : ℕ
h : l ~r rotate l n
⊢ next l (nthLe l k hk) hx = next (rotate l n) (nthLe l k hk) (_ : nthLe l k hk ∈ rotate l n)

Next tactic:
rw [next_nthLe _ hn]
set_option linter.deprecated false in
theorem isRotated_next_eq {l l' : List α} (h : l ~r l') (hn : Nodup l) {x : α} (hx : x ∈ l) :
    l.next x hx = l'.next x (h.mem_iff.mp hx) := by
  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
  obtain ⟨n, rfl⟩ := id h
  rw [next_nthLe _ hn]
  

Proof state:
case intro.intro.intro
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
hn : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
n : ℕ
h : l ~r rotate l n
⊢ nthLe l ((k + 1) % length l) (_ : (k + 1) % length l < length l) =
    next (rotate l n) (nthLe l k hk) (_ : nthLe l k hk ∈ rotate l n)

Next tactic:
simp_rw [← nthLe_rotate' _ n k]
set_option linter.deprecated false in
theorem isRotated_next_eq {l l' : List α} (h : l ~r l') (hn : Nodup l) {x : α} (hx : x ∈ l) :
    l.next x hx = l'.next x (h.mem_iff.mp hx) := by
  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
  obtain ⟨n, rfl⟩ := id h
  rw [next_nthLe _ hn]
  simp_rw [← nthLe_rotate' _ n k]
  

Proof state:
case intro.intro.intro
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
hn : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
n : ℕ
h : l ~r rotate l n
⊢ nthLe l ((k + 1) % length l) (_ : (k + 1) % length l < length l) =
    next (rotate l n)
      (nthLe (rotate l n) ((length l - n % length l + k) % length l)
        (_ : (length l - n % length l + k) % length l < length (rotate l n)))
      (_ :
        nthLe (rotate l n) ((length l - n % length l + k) % length l)
            (_ : (length l - n % length l + k) % length l < length (rotate l n)) ∈
          rotate l n)

Next tactic:
rw [next_nthLe _ (h.nodup_iff.mp hn), ← nthLe_rotate' _ n]
set_option linter.deprecated false in
theorem isRotated_next_eq {l l' : List α} (h : l ~r l') (hn : Nodup l) {x : α} (hx : x ∈ l) :
    l.next x hx = l'.next x (h.mem_iff.mp hx) := by
  obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
  obtain ⟨n, rfl⟩ := id h
  rw [next_nthLe _ hn]
  simp_rw [← nthLe_rotate' _ n k]
  rw [next_nthLe _ (h.nodup_iff.mp hn), ← nthLe_rotate' _ n]
  

Proof state:
case intro.intro.intro
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
hn : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
n : ℕ
h : l ~r rotate l n
⊢ nthLe (rotate l n) ((length l - n % length l + (k + 1) % length l) % length l)
      (_ : (length l - n % length l + (k + 1) % length l) % length l < length (rotate l n)) =
    nthLe (rotate l n) (((length l - n % length l + k) % length l + 1) % length (rotate l n))
      (_ : ((length l - n % length l + k) % length l + 1) % length (rotate l n) < length (rotate l n))

Next tactic:
simp [add_assoc]
theorem isRotated_prev_eq {l l' : List α} (h : l ~r l') (hn : Nodup l) {x : α} (hx : x ∈ l) :
    l.prev x hx = l'.prev x (h.mem_iff.mp hx) := by
  

Proof state:
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l l' : List α
h : l ~r l'
hn : Nodup l
x : α
hx : x ∈ l
⊢ prev l x hx = prev l' x (_ : x ∈ l')

Next tactic:
rw [← next_reverse_eq_prev _ hn, ← next_reverse_eq_prev _ (h.nodup_iff.mp hn)]
theorem isRotated_prev_eq {l l' : List α} (h : l ~r l') (hn : Nodup l) {x : α} (hx : x ∈ l) :
    l.prev x hx = l'.prev x (h.mem_iff.mp hx) := by
  rw [← next_reverse_eq_prev _ hn, ← next_reverse_eq_prev _ (h.nodup_iff.mp hn)]
  

Proof state:
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l l' : List α
h : l ~r l'
hn : Nodup l
x : α
hx : x ∈ l
⊢ next (reverse l) x (_ : x ∈ reverse l) = next (reverse l') x (_ : x ∈ reverse l')

Next tactic:
exact isRotated_next_eq h.reverse (nodup_reverse.mpr hn) _
theorem coe_cons_eq_coe_append (l : List α) (a : α) :
    (↑(a :: l) : Cycle α) = (↑(l ++ [a]) : Cycle α) :=
  Quot.sound ⟨1, by 

Proof state:
α : Type u_1
l : List α
a : α
⊢ rotate (a :: l) 1 = l ++ [a]

Next tactic:
rw [rotate_cons_succ, rotate_zero]
/-- An induction principle for `Cycle`. Use as `induction s using Cycle.induction_on`. -/
@[elab_as_elim]
theorem induction_on {C : Cycle α → Prop} (s : Cycle α) (H0 : C nil)
    (HI : ∀ (a) (l : List α), C ↑l → C ↑(a :: l)) : C s :=
  Quotient.inductionOn' s fun l => by
    

Proof state:
α : Type u_1
C : Cycle α → Prop
s : Cycle α
H0 : C nil
HI : ∀ (a : α) (l : List α), C ↑l → C ↑(a :: l)
l : List α
⊢ C (Quotient.mk'' l)

Next tactic:
refine List.recOn l ?_ ?_
/-- An induction principle for `Cycle`. Use as `induction s using Cycle.induction_on`. -/
@[elab_as_elim]
theorem induction_on {C : Cycle α → Prop} (s : Cycle α) (H0 : C nil)
    (HI : ∀ (a) (l : List α), C ↑l → C ↑(a :: l)) : C s :=
  Quotient.inductionOn' s fun l => by
    refine List.recOn l ?_ ?_ <;> 

Proof state:
case refine_1
α : Type u_1
C : Cycle α → Prop
s : Cycle α
H0 : C nil
HI : ∀ (a : α) (l : List α), C ↑l → C ↑(a :: l)
l : List α
⊢ C (Quotient.mk'' [])

Next tactic:
simp
/-- An induction principle for `Cycle`. Use as `induction s using Cycle.induction_on`. -/
@[elab_as_elim]
theorem induction_on {C : Cycle α → Prop} (s : Cycle α) (H0 : C nil)
    (HI : ∀ (a) (l : List α), C ↑l → C ↑(a :: l)) : C s :=
  Quotient.inductionOn' s fun l => by
    refine List.recOn l ?_ ?_ <;> 

Proof state:
case refine_2
α : Type u_1
C : Cycle α → Prop
s : Cycle α
H0 : C nil
HI : ∀ (a : α) (l : List α), C ↑l → C ↑(a :: l)
l : List α
⊢ ∀ (head : α) (tail : List α), C (Quotient.mk'' tail) → C (Quotient.mk'' (head :: tail))

Next tactic:
simp