Theorem: List.prev_nthLe
File: Mathlib/Data/List/Cycle.lean

tactic: cases' l with x l
state_before: α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
n : ℕ
hn : n < length l
⊢ prev l (nthLe l n hn) (_ : nthLe l n hn ∈ l) =
    nthLe l ((n + (length l - 1)) % length l) (_ : (n + (length l - 1)) % length l < length l)

tactic: induction' l with y l hl generalizing n x
state_before: case cons
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
n : ℕ
x : α
l : List α
h : Nodup (x :: l)
hn : n < length (x :: l)
⊢ prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
    nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
      (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))

tactic: simp at hn
state_before: case nil
α : Type u_1
inst✝ : DecidableEq α
l : List α
x : α
n : ℕ
h : Nodup []
hn : n < length []
⊢ prev [] (nthLe [] n hn) (_ : nthLe [] n hn ∈ []) =
    nthLe [] ((n + (length [] - 1)) % length []) (_ : (n + (length [] - 1)) % length [] < length [])

tactic: simp
state_before: case cons.nil
α : Type u_1
inst✝ : DecidableEq α
l✝ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l : List α
h✝ : Nodup (x✝ :: l)
hn✝ : n✝ < length (x✝ :: l)
n : ℕ
x : α
h : Nodup [x]
hn : n < length [x]
⊢ prev [x] (nthLe [x] n hn) (_ : nthLe [x] n hn ∈ [x]) =
    nthLe [x] ((n + (length [x] - 1)) % length [x]) (_ : (n + (length [x] - 1)) % length [x] < length [x])

tactic: rcases n with (_ | _ | n)
state_before: case cons.cons
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
n : ℕ
x : α
h : Nodup (x :: y :: l)
hn : n < length (x :: y :: l)
⊢ prev (x :: y :: l) (nthLe (x :: y :: l) n hn) (_ : nthLe (x :: y :: l) n hn ∈ x :: y :: l) =
    nthLe (x :: y :: l) ((n + (length (x :: y :: l) - 1)) % length (x :: y :: l))
      (_ : (n + (length (x :: y :: l) - 1)) % length (x :: y :: l) < length (x :: y :: l))

tactic: simp [Nat.add_succ_sub_one, add_zero, List.prev_cons_cons_eq, Nat.zero_eq, List.length,
  List.nthLe, Nat.succ_add_sub_one, zero_add, getLast_eq_get,
  Nat.mod_eq_of_lt (Nat.succ_lt_succ l.length.lt_succ_self)]
state_before: case cons.cons.zero
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h : Nodup (x :: y :: l)
hn : Nat.zero < length (x :: y :: l)
⊢ prev (x :: y :: l) (nthLe (x :: y :: l) Nat.zero hn) (_ : nthLe (x :: y :: l) Nat.zero hn ∈ x :: y :: l) =
    nthLe (x :: y :: l) ((Nat.zero + (length (x :: y :: l) - 1)) % length (x :: y :: l))
      (_ : (Nat.zero + (length (x :: y :: l) - 1)) % length (x :: y :: l) < length (x :: y :: l))

tactic: simp only [mem_cons, nodup_cons] at h
state_before: case cons.cons.succ.zero
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h : Nodup (x :: y :: l)
hn : Nat.succ Nat.zero < length (x :: y :: l)
⊢ prev (x :: y :: l) (nthLe (x :: y :: l) (Nat.succ Nat.zero) hn)
      (_ : nthLe (x :: y :: l) (Nat.succ Nat.zero) hn ∈ x :: y :: l) =
    nthLe (x :: y :: l) ((Nat.succ Nat.zero + (length (x :: y :: l) - 1)) % length (x :: y :: l))
      (_ : (Nat.succ Nat.zero + (length (x :: y :: l) - 1)) % length (x :: y :: l) < length (x :: y :: l))

tactic: push_neg  at h
state_before: case cons.cons.succ.zero
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
hn : Nat.succ Nat.zero < length (x :: y :: l)
h : ¬(x = y ∨ x ∈ l) ∧ ¬y ∈ l ∧ Nodup l
⊢ prev (x :: y :: l) (nthLe (x :: y :: l) (Nat.succ Nat.zero) hn)
      (_ : nthLe (x :: y :: l) (Nat.succ Nat.zero) hn ∈ x :: y :: l) =
    nthLe (x :: y :: l) ((Nat.succ Nat.zero + (length (x :: y :: l) - 1)) % length (x :: y :: l))
      (_ : (Nat.succ Nat.zero + (length (x :: y :: l) - 1)) % length (x :: y :: l) < length (x :: y :: l))

tactic: simp only [List.prev_cons_cons_of_ne _ _ _ _ h.left.left.symm, Nat.zero_eq, List.length,
  List.nthLe, add_comm, eq_self_iff_true, Nat.succ_add_sub_one, Nat.mod_self, zero_add,
  List.get]
state_before: case cons.cons.succ.zero
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
hn : Nat.succ Nat.zero < length (x :: y :: l)
h : (x ≠ y ∧ ¬x ∈ l) ∧ ¬y ∈ l ∧ Nodup l
⊢ prev (x :: y :: l) (nthLe (x :: y :: l) (Nat.succ Nat.zero) hn)
      (_ : nthLe (x :: y :: l) (Nat.succ Nat.zero) hn ∈ x :: y :: l) =
    nthLe (x :: y :: l) ((Nat.succ Nat.zero + (length (x :: y :: l) - 1)) % length (x :: y :: l))
      (_ : (Nat.succ Nat.zero + (length (x :: y :: l) - 1)) % length (x :: y :: l) < length (x :: y :: l))

tactic: rw [prev_ne_cons_cons]
state_before: case cons.cons.succ.succ
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h : Nodup (x :: y :: l)
n : ℕ
hn : Nat.succ (Nat.succ n) < length (x :: y :: l)
⊢ prev (x :: y :: l) (nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn)
      (_ : nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn ∈ x :: y :: l) =
    nthLe (x :: y :: l) ((Nat.succ (Nat.succ n) + (length (x :: y :: l) - 1)) % length (x :: y :: l))
      (_ : (Nat.succ (Nat.succ n) + (length (x :: y :: l) - 1)) % length (x :: y :: l) < length (x :: y :: l))

tactic: convert hl n.succ y h.of_cons (Nat.le_of_succ_le_succ hn) using 1
state_before: case cons.cons.succ.succ
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h : Nodup (x :: y :: l)
n : ℕ
hn : Nat.succ (Nat.succ n) < length (x :: y :: l)
⊢ prev (y :: l) (nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn)
      (_ : nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn ∈ y :: l) =
    nthLe (x :: y :: l) ((Nat.succ (Nat.succ n) + (length (x :: y :: l) - 1)) % length (x :: y :: l))
      (_ : (Nat.succ (Nat.succ n) + (length (x :: y :: l) - 1)) % length (x :: y :: l) < length (x :: y :: l))

tactic: have : ∀ k hk, (y :: l).nthLe k hk = (x :: y :: l).nthLe (k + 1) (Nat.succ_lt_succ hk) := by
  intros
  simp [List.nthLe]
state_before: case h.e'_3
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h : Nodup (x :: y :: l)
n : ℕ
hn : Nat.succ (Nat.succ n) < length (x :: y :: l)
⊢ nthLe (x :: y :: l) ((Nat.succ (Nat.succ n) + (length (x :: y :: l) - 1)) % length (x :: y :: l))
      (_ : (Nat.succ (Nat.succ n) + (length (x :: y :: l) - 1)) % length (x :: y :: l) < length (x :: y :: l)) =
    nthLe (y :: l) ((Nat.succ n + (length (y :: l) - 1)) % length (y :: l))
      (_ : (Nat.succ n + (length (y :: l) - 1)) % length (y :: l) < length (y :: l))

tactic: rw [this]
state_before: case h.e'_3
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h : Nodup (x :: y :: l)
n : ℕ
hn : Nat.succ (Nat.succ n) < length (x :: y :: l)
this :
  ∀ (k : ℕ) (hk : k < length (y :: l)),
    nthLe (y :: l) k hk = nthLe (x :: y :: l) (k + 1) (_ : Nat.succ k < Nat.succ (length (y :: l)))
⊢ nthLe (x :: y :: l) ((Nat.succ (Nat.succ n) + (length (x :: y :: l) - 1)) % length (x :: y :: l))
      (_ : (Nat.succ (Nat.succ n) + (length (x :: y :: l) - 1)) % length (x :: y :: l) < length (x :: y :: l)) =
    nthLe (y :: l) ((Nat.succ n + (length (y :: l) - 1)) % length (y :: l))
      (_ : (Nat.succ n + (length (y :: l) - 1)) % length (y :: l) < length (y :: l))

tactic: congr
state_before: case h.e'_3
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h : Nodup (x :: y :: l)
n : ℕ
hn : Nat.succ (Nat.succ n) < length (x :: y :: l)
this :
  ∀ (k : ℕ) (hk : k < length (y :: l)),
    nthLe (y :: l) k hk = nthLe (x :: y :: l) (k + 1) (_ : Nat.succ k < Nat.succ (length (y :: l)))
⊢ nthLe (x :: y :: l) ((Nat.succ (Nat.succ n) + (length (x :: y :: l) - 1)) % length (x :: y :: l))
      (_ : (Nat.succ (Nat.succ n) + (length (x :: y :: l) - 1)) % length (x :: y :: l) < length (x :: y :: l)) =
    nthLe (x :: y :: l) ((Nat.succ n + (length (y :: l) - 1)) % length (y :: l) + 1)
      (_ : Nat.succ ((Nat.succ n + (length (y :: l) - 1)) % length (y :: l)) < Nat.succ (length (y :: l)))

tactic: simp only [Nat.add_succ_sub_one, add_zero, length]
state_before: case h.e'_3.e_n
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h : Nodup (x :: y :: l)
n : ℕ
hn : Nat.succ (Nat.succ n) < length (x :: y :: l)
this :
  ∀ (k : ℕ) (hk : k < length (y :: l)),
    nthLe (y :: l) k hk = nthLe (x :: y :: l) (k + 1) (_ : Nat.succ k < Nat.succ (length (y :: l)))
⊢ (Nat.succ (Nat.succ n) + (length (x :: y :: l) - 1)) % length (x :: y :: l) =
    (Nat.succ n + (length (y :: l) - 1)) % length (y :: l) + 1

tactic: simp only [length, Nat.succ_lt_succ_iff] at hn
state_before: case h.e'_3.e_n
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h : Nodup (x :: y :: l)
n : ℕ
hn : Nat.succ (Nat.succ n) < length (x :: y :: l)
this :
  ∀ (k : ℕ) (hk : k < length (y :: l)),
    nthLe (y :: l) k hk = nthLe (x :: y :: l) (k + 1) (_ : Nat.succ k < Nat.succ (length (y :: l)))
⊢ (Nat.succ (Nat.succ n) + (length l + 1)) % (length l + 1 + 1) = (Nat.succ n + length l) % (length l + 1) + 1

tactic: set k := l.length
state_before: case h.e'_3.e_n
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h : Nodup (x :: y :: l)
n : ℕ
this :
  ∀ (k : ℕ) (hk : k < length (y :: l)),
    nthLe (y :: l) k hk = nthLe (x :: y :: l) (k + 1) (_ : Nat.succ k < Nat.succ (length (y :: l)))
hn : n < length l
⊢ (Nat.succ (Nat.succ n) + (length l + 1)) % (length l + 1 + 1) = (Nat.succ n + length l) % (length l + 1) + 1

tactic: rw [Nat.succ_add, ← Nat.add_succ, Nat.add_mod_right, Nat.succ_add, ← Nat.add_succ _ k,
  Nat.add_mod_right, Nat.mod_eq_of_lt, Nat.mod_eq_of_lt]
state_before: case h.e'_3.e_n
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h : Nodup (x :: y :: l)
n : ℕ
this :
  ∀ (k : ℕ) (hk : k < length (y :: l)),
    nthLe (y :: l) k hk = nthLe (x :: y :: l) (k + 1) (_ : Nat.succ k < Nat.succ (length (y :: l)))
k : ℕ := length l
hn : n < k
⊢ (Nat.succ (Nat.succ n) + (k + 1)) % (k + 1 + 1) = (Nat.succ n + k) % (k + 1) + 1

tactic: intros
state_before: α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h : Nodup (x :: y :: l)
n : ℕ
hn : Nat.succ (Nat.succ n) < length (x :: y :: l)
⊢ ∀ (k : ℕ) (hk : k < length (y :: l)),
    nthLe (y :: l) k hk = nthLe (x :: y :: l) (k + 1) (_ : Nat.succ k < Nat.succ (length (y :: l)))

tactic: simp [List.nthLe]
state_before: α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h : Nodup (x :: y :: l)
n : ℕ
hn : Nat.succ (Nat.succ n) < length (x :: y :: l)
k✝ : ℕ
hk✝ : k✝ < length (y :: l)
⊢ nthLe (y :: l) k✝ hk✝ = nthLe (x :: y :: l) (k✝ + 1) (_ : Nat.succ k✝ < Nat.succ (length (y :: l)))

tactic: exact Nat.lt_succ_of_lt hn
state_before: case h.e'_3.e_n
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h : Nodup (x :: y :: l)
n : ℕ
this :
  ∀ (k : ℕ) (hk : k < length (y :: l)),
    nthLe (y :: l) k hk = nthLe (x :: y :: l) (k + 1) (_ : Nat.succ k < Nat.succ (length (y :: l)))
k : ℕ := length l
hn : n < k
⊢ n < Nat.succ k

tactic: exact Nat.succ_lt_succ (Nat.lt_succ_of_lt hn)
state_before: case h.e'_3.e_n
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h : Nodup (x :: y :: l)
n : ℕ
this :
  ∀ (k : ℕ) (hk : k < length (y :: l)),
    nthLe (y :: l) k hk = nthLe (x :: y :: l) (k + 1) (_ : Nat.succ k < Nat.succ (length (y :: l)))
k : ℕ := length l
hn : n < k
⊢ n + 1 < Nat.succ (k + 1)

tactic: intro H
state_before: case cons.cons.succ.succ.hy
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h : Nodup (x :: y :: l)
n : ℕ
hn : Nat.succ (Nat.succ n) < length (x :: y :: l)
⊢ nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn ≠ x

tactic: suffices n.succ.succ = 0 by simpa
state_before: case cons.cons.succ.succ.hy
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h : Nodup (x :: y :: l)
n : ℕ
hn : Nat.succ (Nat.succ n) < length (x :: y :: l)
H : nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn = x
⊢ False

tactic: rw [nodup_iff_nthLe_inj] at h
state_before: case cons.cons.succ.succ.hy
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h : Nodup (x :: y :: l)
n : ℕ
hn : Nat.succ (Nat.succ n) < length (x :: y :: l)
H : nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn = x
⊢ Nat.succ (Nat.succ n) = 0

tactic: refine' h _ _ hn Nat.succ_pos' _
state_before: case cons.cons.succ.succ.hy
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h :
  ∀ (i j : ℕ) (h₁ : i < length (x :: y :: l)) (h₂ : j < length (x :: y :: l)),
    nthLe (x :: y :: l) i h₁ = nthLe (x :: y :: l) j h₂ → i = j
n : ℕ
hn : Nat.succ (Nat.succ n) < length (x :: y :: l)
H : nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn = x
⊢ Nat.succ (Nat.succ n) = 0

tactic: simpa using H
state_before: case cons.cons.succ.succ.hy
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h :
  ∀ (i j : ℕ) (h₁ : i < length (x :: y :: l)) (h₂ : j < length (x :: y :: l)),
    nthLe (x :: y :: l) i h₁ = nthLe (x :: y :: l) j h₂ → i = j
n : ℕ
hn : Nat.succ (Nat.succ n) < length (x :: y :: l)
H : nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn = x
⊢ nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn = nthLe (x :: y :: l) 0 (_ : 0 < Nat.succ (length (y :: l)))

tactic: simpa
state_before: α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h : Nodup (x :: y :: l)
n : ℕ
hn : Nat.succ (Nat.succ n) < length (x :: y :: l)
H : nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn = x
this : Nat.succ (Nat.succ n) = 0
⊢ False

tactic: intro H
state_before: case cons.cons.succ.succ.hz
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h : Nodup (x :: y :: l)
n : ℕ
hn : Nat.succ (Nat.succ n) < length (x :: y :: l)
⊢ nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn ≠ y

tactic: suffices n.succ.succ = 1 by simpa
state_before: case cons.cons.succ.succ.hz
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h : Nodup (x :: y :: l)
n : ℕ
hn : Nat.succ (Nat.succ n) < length (x :: y :: l)
H : nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn = y
⊢ False

tactic: rw [nodup_iff_nthLe_inj] at h
state_before: case cons.cons.succ.succ.hz
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h : Nodup (x :: y :: l)
n : ℕ
hn : Nat.succ (Nat.succ n) < length (x :: y :: l)
H : nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn = y
⊢ Nat.succ (Nat.succ n) = 1

tactic: refine' h _ _ hn (Nat.succ_lt_succ Nat.succ_pos') _
state_before: case cons.cons.succ.succ.hz
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h :
  ∀ (i j : ℕ) (h₁ : i < length (x :: y :: l)) (h₂ : j < length (x :: y :: l)),
    nthLe (x :: y :: l) i h₁ = nthLe (x :: y :: l) j h₂ → i = j
n : ℕ
hn : Nat.succ (Nat.succ n) < length (x :: y :: l)
H : nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn = y
⊢ Nat.succ (Nat.succ n) = 1

tactic: simpa using H
state_before: case cons.cons.succ.succ.hz
α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h :
  ∀ (i j : ℕ) (h₁ : i < length (x :: y :: l)) (h₂ : j < length (x :: y :: l)),
    nthLe (x :: y :: l) i h₁ = nthLe (x :: y :: l) j h₂ → i = j
n : ℕ
hn : Nat.succ (Nat.succ n) < length (x :: y :: l)
H : nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn = y
⊢ nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn = nthLe (x :: y :: l) 1 (_ : Nat.succ 0 < Nat.succ (length (y :: l)))

tactic: simpa
state_before: α : Type u_1
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ : α
n✝ : ℕ
x✝ : α
l✝ : List α
h✝ : Nodup (x✝ :: l✝)
hn✝ : n✝ < length (x✝ :: l✝)
y : α
l : List α
hl :
  ∀ (n : ℕ) (x : α),
    Nodup (x :: l) →
      ∀ (hn : n < length (x :: l)),
        prev (x :: l) (nthLe (x :: l) n hn) (_ : nthLe (x :: l) n hn ∈ x :: l) =
          nthLe (x :: l) ((n + (length (x :: l) - 1)) % length (x :: l))
            (_ : (n + (length (x :: l) - 1)) % length (x :: l) < length (x :: l))
x : α
h : Nodup (x :: y :: l)
n : ℕ
hn : Nat.succ (Nat.succ n) < length (x :: y :: l)
H : nthLe (x :: y :: l) (Nat.succ (Nat.succ n)) hn = y
this : Nat.succ (Nat.succ n) = 1
⊢ False