l3lab/ntp-mathlib huggingface dataset:
set_option linter.deprecated false in
/-- If a `l : List α` is `Nodup l`, then all of its cyclic permutants are distinct. -/
theorem Nodup.cyclicPermutations {l : List α} (hn : Nodup l) : Nodup (cyclicPermutations l) := by
  cases' l with x l
  · simp
  rw [nodup_iff_nthLe_inj]
  intro i j hi hj h
  simp only [length_cyclicPermutations_cons] at hi hj
  rw [← mod_eq_of_lt hi, ← mod_eq_of_lt hj]
  apply hn.rotate_congr
  · simp
  · 

Proof state:
case cons.h
α : Type u
l✝ l' : List α
x : α
l : List α
hn : Nodup (x :: l)
i j : ℕ
hi✝ : i < length (List.cyclicPermutations (x :: l))
hj✝ : j < length (List.cyclicPermutations (x :: l))
h : nthLe (List.cyclicPermutations (x :: l)) i hi✝ = nthLe (List.cyclicPermutations (x :: l)) j hj✝
hi : i < length l + 1
hj : j < length l + 1
⊢ rotate (x :: l) i = rotate (x :: l) j

Next tactic:
simpa using h
set_option linter.deprecated false in
@[simp]
theorem cyclicPermutations_rotate (l : List α) (k : ℕ) :
    (l.rotate k).cyclicPermutations = l.cyclicPermutations.rotate k := by
  

Proof state:
α : Type u
l✝ l' l : List α
k : ℕ
⊢ cyclicPermutations (rotate l k) = rotate (cyclicPermutations l) k

Next tactic:
have : (l.rotate k).cyclicPermutations.length = length (l.cyclicPermutations.rotate k) := by
    cases l
    · simp
    · rw [length_cyclicPermutations_of_ne_nil] <;> simp
set_option linter.deprecated false in
@[simp]
theorem cyclicPermutations_rotate (l : List α) (k : ℕ) :
    (l.rotate k).cyclicPermutations = l.cyclicPermutations.rotate k := by
  have : (l.rotate k).cyclicPermutations.length = length (l.cyclicPermutations.rotate k) := by
    

Proof state:
α : Type u
l✝ l' l : List α
k : ℕ
⊢ length (cyclicPermutations (rotate l k)) = length (rotate (cyclicPermutations l) k)

Next tactic:
cases l
set_option linter.deprecated false in
@[simp]
theorem cyclicPermutations_rotate (l : List α) (k : ℕ) :
    (l.rotate k).cyclicPermutations = l.cyclicPermutations.rotate k := by
  have : (l.rotate k).cyclicPermutations.length = length (l.cyclicPermutations.rotate k) := by
    cases l
    · 

Proof state:
case nil
α : Type u
l l' : List α
k : ℕ
⊢ length (cyclicPermutations (rotate [] k)) = length (rotate (cyclicPermutations []) k)

Next tactic:
simp
set_option linter.deprecated false in
@[simp]
theorem cyclicPermutations_rotate (l : List α) (k : ℕ) :
    (l.rotate k).cyclicPermutations = l.cyclicPermutations.rotate k := by
  have : (l.rotate k).cyclicPermutations.length = length (l.cyclicPermutations.rotate k) := by
    cases l
    · simp
    · 

Proof state:
case cons
α : Type u
l l' : List α
k : ℕ
head✝ : α
tail✝ : List α
⊢ length (cyclicPermutations (rotate (head✝ :: tail✝) k)) = length (rotate (cyclicPermutations (head✝ :: tail✝)) k)

Next tactic:
rw [length_cyclicPermutations_of_ne_nil]
set_option linter.deprecated false in
@[simp]
theorem cyclicPermutations_rotate (l : List α) (k : ℕ) :
    (l.rotate k).cyclicPermutations = l.cyclicPermutations.rotate k := by
  have : (l.rotate k).cyclicPermutations.length = length (l.cyclicPermutations.rotate k) := by
    cases l
    · simp
    · rw [length_cyclicPermutations_of_ne_nil] <;> 

Proof state:
case cons
α : Type u
l l' : List α
k : ℕ
head✝ : α
tail✝ : List α
⊢ length (rotate (head✝ :: tail✝) k) = length (rotate (cyclicPermutations (head✝ :: tail✝)) k)

Next tactic:
simp
set_option linter.deprecated false in
@[simp]
theorem cyclicPermutations_rotate (l : List α) (k : ℕ) :
    (l.rotate k).cyclicPermutations = l.cyclicPermutations.rotate k := by
  have : (l.rotate k).cyclicPermutations.length = length (l.cyclicPermutations.rotate k) := by
    cases l
    · simp
    · rw [length_cyclicPermutations_of_ne_nil] <;> 

Proof state:
case cons.h
α : Type u
l l' : List α
k : ℕ
head✝ : α
tail✝ : List α
⊢ rotate (head✝ :: tail✝) k ≠ []

Next tactic:
simp
set_option linter.deprecated false in
@[simp]
theorem cyclicPermutations_rotate (l : List α) (k : ℕ) :
    (l.rotate k).cyclicPermutations = l.cyclicPermutations.rotate k := by
  have : (l.rotate k).cyclicPermutations.length = length (l.cyclicPermutations.rotate k) := by
    cases l
    · simp
    · rw [length_cyclicPermutations_of_ne_nil] <;> simp
  

Proof state:
α : Type u
l✝ l' l : List α
k : ℕ
this : length (cyclicPermutations (rotate l k)) = length (rotate (cyclicPermutations l) k)
⊢ cyclicPermutations (rotate l k) = rotate (cyclicPermutations l) k

Next tactic:
refine' ext_nthLe this fun n hn hn' => _
set_option linter.deprecated false in
@[simp]
theorem cyclicPermutations_rotate (l : List α) (k : ℕ) :
    (l.rotate k).cyclicPermutations = l.cyclicPermutations.rotate k := by
  have : (l.rotate k).cyclicPermutations.length = length (l.cyclicPermutations.rotate k) := by
    cases l
    · simp
    · rw [length_cyclicPermutations_of_ne_nil] <;> simp
  refine' ext_nthLe this fun n hn hn' => _
  

Proof state:
α : Type u
l✝ l' l : List α
k : ℕ
this : length (cyclicPermutations (rotate l k)) = length (rotate (cyclicPermutations l) k)
n : ℕ
hn : n < length (cyclicPermutations (rotate l k))
hn' : n < length (rotate (cyclicPermutations l) k)
⊢ nthLe (cyclicPermutations (rotate l k)) n hn = nthLe (rotate (cyclicPermutations l) k) n hn'

Next tactic:
rw [nthLe_rotate, nthLe_cyclicPermutations, rotate_rotate, ← rotate_mod, add_comm]
set_option linter.deprecated false in
@[simp]
theorem cyclicPermutations_rotate (l : List α) (k : ℕ) :
    (l.rotate k).cyclicPermutations = l.cyclicPermutations.rotate k := by
  have : (l.rotate k).cyclicPermutations.length = length (l.cyclicPermutations.rotate k) := by
    cases l
    · simp
    · rw [length_cyclicPermutations_of_ne_nil] <;> simp
  refine' ext_nthLe this fun n hn hn' => _
  rw [nthLe_rotate, nthLe_cyclicPermutations, rotate_rotate, ← rotate_mod, add_comm]
  

Proof state:
α : Type u
l✝ l' l : List α
k : ℕ
this : length (cyclicPermutations (rotate l k)) = length (rotate (cyclicPermutations l) k)
n : ℕ
hn : n < length (cyclicPermutations (rotate l k))
hn' : n < length (rotate (cyclicPermutations l) k)
⊢ rotate l ((n + k) % length l) =
    nthLe (cyclicPermutations l) ((n + k) % length (cyclicPermutations l))
      (_ : (n + k) % length (cyclicPermutations l) < length (cyclicPermutations l))

Next tactic:
cases l
set_option linter.deprecated false in
@[simp]
theorem cyclicPermutations_rotate (l : List α) (k : ℕ) :
    (l.rotate k).cyclicPermutations = l.cyclicPermutations.rotate k := by
  have : (l.rotate k).cyclicPermutations.length = length (l.cyclicPermutations.rotate k) := by
    cases l
    · simp
    · rw [length_cyclicPermutations_of_ne_nil] <;> simp
  refine' ext_nthLe this fun n hn hn' => _
  rw [nthLe_rotate, nthLe_cyclicPermutations, rotate_rotate, ← rotate_mod, add_comm]
  cases l <;> 

Proof state:
case nil
α : Type u
l l' : List α
k n : ℕ
this : length (cyclicPermutations (rotate [] k)) = length (rotate (cyclicPermutations []) k)
hn : n < length (cyclicPermutations (rotate [] k))
hn' : n < length (rotate (cyclicPermutations []) k)
⊢ rotate [] ((n + k) % length []) =
    nthLe (cyclicPermutations []) ((n + k) % length (cyclicPermutations []))
      (_ : (n + k) % length (cyclicPermutations []) < length (cyclicPermutations []))

Next tactic:
simp
set_option linter.deprecated false in
@[simp]
theorem cyclicPermutations_rotate (l : List α) (k : ℕ) :
    (l.rotate k).cyclicPermutations = l.cyclicPermutations.rotate k := by
  have : (l.rotate k).cyclicPermutations.length = length (l.cyclicPermutations.rotate k) := by
    cases l
    · simp
    · rw [length_cyclicPermutations_of_ne_nil] <;> simp
  refine' ext_nthLe this fun n hn hn' => _
  rw [nthLe_rotate, nthLe_cyclicPermutations, rotate_rotate, ← rotate_mod, add_comm]
  cases l <;> 

Proof state:
case cons
α : Type u
l l' : List α
k n : ℕ
head✝ : α
tail✝ : List α
this : length (cyclicPermutations (rotate (head✝ :: tail✝) k)) = length (rotate (cyclicPermutations (head✝ :: tail✝)) k)
hn : n < length (cyclicPermutations (rotate (head✝ :: tail✝) k))
hn' : n < length (rotate (cyclicPermutations (head✝ :: tail✝)) k)
⊢ rotate (head✝ :: tail✝) ((n + k) % length (head✝ :: tail✝)) =
    nthLe (cyclicPermutations (head✝ :: tail✝)) ((n + k) % length (cyclicPermutations (head✝ :: tail✝)))
      (_ : (n + k) % length (cyclicPermutations (head✝ :: tail✝)) < length (cyclicPermutations (head✝ :: tail✝)))

Next tactic:
simp
theorem IsRotated.cyclicPermutations {l l' : List α} (h : l ~r l') :
    l.cyclicPermutations ~r l'.cyclicPermutations := by
  

Proof state:
α : Type u
l✝ l'✝ l l' : List α
h : l ~r l'
⊢ List.cyclicPermutations l ~r List.cyclicPermutations l'

Next tactic:
obtain ⟨k, rfl⟩ := h
theorem IsRotated.cyclicPermutations {l l' : List α} (h : l ~r l') :
    l.cyclicPermutations ~r l'.cyclicPermutations := by
  obtain ⟨k, rfl⟩ := h
  

Proof state:
case intro
α : Type u
l✝ l' l : List α
k : ℕ
⊢ List.cyclicPermutations l ~r List.cyclicPermutations (rotate l k)

Next tactic:
exact ⟨k, by simp⟩
theorem IsRotated.cyclicPermutations {l l' : List α} (h : l ~r l') :
    l.cyclicPermutations ~r l'.cyclicPermutations := by
  obtain ⟨k, rfl⟩ := h
  exact ⟨k, by 

Proof state:
α : Type u
l✝ l' l : List α
k : ℕ
⊢ rotate (List.cyclicPermutations l) k = List.cyclicPermutations (rotate l k)

Next tactic:
simp
set_option linter.deprecated false in
@[simp]
theorem isRotated_cyclicPermutations_iff {l l' : List α} :
    l.cyclicPermutations ~r l'.cyclicPermutations ↔ l ~r l' := by
  

Proof state:
α : Type u
l✝ l'✝ l l' : List α
⊢ cyclicPermutations l ~r cyclicPermutations l' ↔ l ~r l'

Next tactic:
by_cases hl : l = []
set_option linter.deprecated false in
@[simp]
theorem isRotated_cyclicPermutations_iff {l l' : List α} :
    l.cyclicPermutations ~r l'.cyclicPermutations ↔ l ~r l' := by
  by_cases hl : l = []
  · 

Proof state:
case pos
α : Type u
l✝ l'✝ l l' : List α
hl : l = []
⊢ cyclicPermutations l ~r cyclicPermutations l' ↔ l ~r l'

Next tactic:
simp [hl, eq_comm]
set_option linter.deprecated false in
@[simp]
theorem isRotated_cyclicPermutations_iff {l l' : List α} :
    l.cyclicPermutations ~r l'.cyclicPermutations ↔ l ~r l' := by
  by_cases hl : l = []
  · simp [hl, eq_comm]
  

Proof state:
case neg
α : Type u
l✝ l'✝ l l' : List α
hl : ¬l = []
⊢ cyclicPermutations l ~r cyclicPermutations l' ↔ l ~r l'

Next tactic:
have hl' : l.cyclicPermutations.length = l.length := length_cyclicPermutations_of_ne_nil _ hl
set_option linter.deprecated false in
@[simp]
theorem isRotated_cyclicPermutations_iff {l l' : List α} :
    l.cyclicPermutations ~r l'.cyclicPermutations ↔ l ~r l' := by
  by_cases hl : l = []
  · simp [hl, eq_comm]
  have hl' : l.cyclicPermutations.length = l.length := length_cyclicPermutations_of_ne_nil _ hl
  

Proof state:
case neg
α : Type u
l✝ l'✝ l l' : List α
hl : ¬l = []
hl' : length (cyclicPermutations l) = length l
⊢ cyclicPermutations l ~r cyclicPermutations l' ↔ l ~r l'

Next tactic:
refine' ⟨fun h => _, IsRotated.cyclicPermutations⟩
set_option linter.deprecated false in
@[simp]
theorem isRotated_cyclicPermutations_iff {l l' : List α} :
    l.cyclicPermutations ~r l'.cyclicPermutations ↔ l ~r l' := by
  by_cases hl : l = []
  · simp [hl, eq_comm]
  have hl' : l.cyclicPermutations.length = l.length := length_cyclicPermutations_of_ne_nil _ hl
  refine' ⟨fun h => _, IsRotated.cyclicPermutations⟩
  

Proof state:
case neg
α : Type u
l✝ l'✝ l l' : List α
hl : ¬l = []
hl' : length (cyclicPermutations l) = length l
h : cyclicPermutations l ~r cyclicPermutations l'
⊢ l ~r l'

Next tactic:
obtain ⟨k, hk⟩ := h
set_option linter.deprecated false in
@[simp]
theorem isRotated_cyclicPermutations_iff {l l' : List α} :
    l.cyclicPermutations ~r l'.cyclicPermutations ↔ l ~r l' := by
  by_cases hl : l = []
  · simp [hl, eq_comm]
  have hl' : l.cyclicPermutations.length = l.length := length_cyclicPermutations_of_ne_nil _ hl
  refine' ⟨fun h => _, IsRotated.cyclicPermutations⟩
  obtain ⟨k, hk⟩ := h
  

Proof state:
case neg.intro
α : Type u
l✝ l'✝ l l' : List α
hl : ¬l = []
hl' : length (cyclicPermutations l) = length l
k : ℕ
hk : rotate (cyclicPermutations l) k = cyclicPermutations l'
⊢ l ~r l'

Next tactic:
refine' ⟨k % l.length, _⟩
set_option linter.deprecated false in
@[simp]
theorem isRotated_cyclicPermutations_iff {l l' : List α} :
    l.cyclicPermutations ~r l'.cyclicPermutations ↔ l ~r l' := by
  by_cases hl : l = []
  · simp [hl, eq_comm]
  have hl' : l.cyclicPermutations.length = l.length := length_cyclicPermutations_of_ne_nil _ hl
  refine' ⟨fun h => _, IsRotated.cyclicPermutations⟩
  obtain ⟨k, hk⟩ := h
  refine' ⟨k % l.length, _⟩
  

Proof state:
case neg.intro
α : Type u
l✝ l'✝ l l' : List α
hl : ¬l = []
hl' : length (cyclicPermutations l) = length l
k : ℕ
hk : rotate (cyclicPermutations l) k = cyclicPermutations l'
⊢ rotate l (k % length l) = l'

Next tactic:
have hk' : k % l.length < l.length := mod_lt _ (length_pos_of_ne_nil hl)
set_option linter.deprecated false in
@[simp]
theorem isRotated_cyclicPermutations_iff {l l' : List α} :
    l.cyclicPermutations ~r l'.cyclicPermutations ↔ l ~r l' := by
  by_cases hl : l = []
  · simp [hl, eq_comm]
  have hl' : l.cyclicPermutations.length = l.length := length_cyclicPermutations_of_ne_nil _ hl
  refine' ⟨fun h => _, IsRotated.cyclicPermutations⟩
  obtain ⟨k, hk⟩ := h
  refine' ⟨k % l.length, _⟩
  have hk' : k % l.length < l.length := mod_lt _ (length_pos_of_ne_nil hl)
  

Proof state:
case neg.intro
α : Type u
l✝ l'✝ l l' : List α
hl : ¬l = []
hl' : length (cyclicPermutations l) = length l
k : ℕ
hk : rotate (cyclicPermutations l) k = cyclicPermutations l'
hk' : k % length l < length l
⊢ rotate l (k % length l) = l'

Next tactic:
rw [← nthLe_cyclicPermutations _ _ (hk'.trans_le hl'.ge), ← nthLe_rotate' _ k]
set_option linter.deprecated false in
@[simp]
theorem isRotated_cyclicPermutations_iff {l l' : List α} :
    l.cyclicPermutations ~r l'.cyclicPermutations ↔ l ~r l' := by
  by_cases hl : l = []
  · simp [hl, eq_comm]
  have hl' : l.cyclicPermutations.length = l.length := length_cyclicPermutations_of_ne_nil _ hl
  refine' ⟨fun h => _, IsRotated.cyclicPermutations⟩
  obtain ⟨k, hk⟩ := h
  refine' ⟨k % l.length, _⟩
  have hk' : k % l.length < l.length := mod_lt _ (length_pos_of_ne_nil hl)
  rw [← nthLe_cyclicPermutations _ _ (hk'.trans_le hl'.ge), ← nthLe_rotate' _ k]
  

Proof state:
case neg.intro
α : Type u
l✝ l'✝ l l' : List α
hl : ¬l = []
hl' : length (cyclicPermutations l) = length l
k : ℕ
hk : rotate (cyclicPermutations l) k = cyclicPermutations l'
hk' : k % length l < length l
⊢ nthLe (rotate (cyclicPermutations l) k)
      ((length (cyclicPermutations l) - k % length (cyclicPermutations l) + k % length l) %
        length (cyclicPermutations l))
      (_ :
        (length (cyclicPermutations l) - k % length (cyclicPermutations l) + k % length l) %
            length (cyclicPermutations l) <
          length (rotate (cyclicPermutations l) k)) =
    l'

Next tactic:
simp [hk, hl', tsub_add_cancel_of_le hk'.le]
theorem wellFounded_iff_has_min {r : α → α → Prop} :
    WellFounded r ↔ ∀ s : Set α, s.Nonempty → ∃ m ∈ s, ∀ x ∈ s, ¬r x m := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r✝ r' r : α → α → Prop
⊢ WellFounded r ↔ ∀ (s : Set α), Set.Nonempty s → ∃ m ∈ s, ∀ x ∈ s, ¬r x m

Next tactic:
refine ⟨fun h => h.has_min, fun h => ⟨fun x => ?_⟩⟩
theorem wellFounded_iff_has_min {r : α → α → Prop} :
    WellFounded r ↔ ∀ s : Set α, s.Nonempty → ∃ m ∈ s, ∀ x ∈ s, ¬r x m := by
  refine ⟨fun h => h.has_min, fun h => ⟨fun x => ?_⟩⟩
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r✝ r' r : α → α → Prop
h : ∀ (s : Set α), Set.Nonempty s → ∃ m ∈ s, ∀ x ∈ s, ¬r x m
x : α
⊢ Acc r x

Next tactic:
by_contra hx
theorem wellFounded_iff_has_min {r : α → α → Prop} :
    WellFounded r ↔ ∀ s : Set α, s.Nonempty → ∃ m ∈ s, ∀ x ∈ s, ¬r x m := by
  refine ⟨fun h => h.has_min, fun h => ⟨fun x => ?_⟩⟩
  by_contra hx
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r✝ r' r : α → α → Prop
h : ∀ (s : Set α), Set.Nonempty s → ∃ m ∈ s, ∀ x ∈ s, ¬r x m
x : α
hx : ¬Acc r x
⊢ False

Next tactic:
obtain ⟨m, hm, hm'⟩ := h {x | ¬Acc r x} ⟨x, hx⟩
theorem wellFounded_iff_has_min {r : α → α → Prop} :
    WellFounded r ↔ ∀ s : Set α, s.Nonempty → ∃ m ∈ s, ∀ x ∈ s, ¬r x m := by
  refine ⟨fun h => h.has_min, fun h => ⟨fun x => ?_⟩⟩
  by_contra hx
  obtain ⟨m, hm, hm'⟩ := h {x | ¬Acc r x} ⟨x, hx⟩
  

Proof state:
case intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
r✝ r' r : α → α → Prop
h : ∀ (s : Set α), Set.Nonempty s → ∃ m ∈ s, ∀ x ∈ s, ¬r x m
x : α
hx : ¬Acc r x
m : α
hm : m ∈ {x | ¬Acc r x}
hm' : ∀ x ∈ {x | ¬Acc r x}, ¬r x m
⊢ False

Next tactic:
refine' hm ⟨_, fun y hy => _⟩
theorem wellFounded_iff_has_min {r : α → α → Prop} :
    WellFounded r ↔ ∀ s : Set α, s.Nonempty → ∃ m ∈ s, ∀ x ∈ s, ¬r x m := by
  refine ⟨fun h => h.has_min, fun h => ⟨fun x => ?_⟩⟩
  by_contra hx
  obtain ⟨m, hm, hm'⟩ := h {x | ¬Acc r x} ⟨x, hx⟩
  refine' hm ⟨_, fun y hy => _⟩
  

Proof state:
case intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
r✝ r' r : α → α → Prop
h : ∀ (s : Set α), Set.Nonempty s → ∃ m ∈ s, ∀ x ∈ s, ¬r x m
x : α
hx : ¬Acc r x
m : α
hm : m ∈ {x | ¬Acc r x}
hm' : ∀ x ∈ {x | ¬Acc r x}, ¬r x m
y : α
hy : r y m
⊢ Acc r y

Next tactic:
by_contra hy'
theorem wellFounded_iff_has_min {r : α → α → Prop} :
    WellFounded r ↔ ∀ s : Set α, s.Nonempty → ∃ m ∈ s, ∀ x ∈ s, ¬r x m := by
  refine ⟨fun h => h.has_min, fun h => ⟨fun x => ?_⟩⟩
  by_contra hx
  obtain ⟨m, hm, hm'⟩ := h {x | ¬Acc r x} ⟨x, hx⟩
  refine' hm ⟨_, fun y hy => _⟩
  by_contra hy'
  

Proof state:
case intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
r✝ r' r : α → α → Prop
h : ∀ (s : Set α), Set.Nonempty s → ∃ m ∈ s, ∀ x ∈ s, ¬r x m
x : α
hx : ¬Acc r x
m : α
hm : m ∈ {x | ¬Acc r x}
hm' : ∀ x ∈ {x | ¬Acc r x}, ¬r x m
y : α
hy : r y m
hy' : ¬Acc r y
⊢ False

Next tactic:
exact hm' y hy' hy
protected theorem lt_succ {r : α → α → Prop} (wf : WellFounded r) {x : α} (h : ∃ y, r x y) :
    r x (wf.succ x) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r✝ r' r : α → α → Prop
wf : WellFounded r
x : α
h : ∃ y, r x y
⊢ r x (WellFounded.succ wf x)

Next tactic:
rw [WellFounded.succ, dif_pos h]
protected theorem lt_succ {r : α → α → Prop} (wf : WellFounded r) {x : α} (h : ∃ y, r x y) :
    r x (wf.succ x) := by
  rw [WellFounded.succ, dif_pos h]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r✝ r' r : α → α → Prop
wf : WellFounded r
x : α
h : ∃ y, r x y
⊢ r x (min wf {y | r x y} h)

Next tactic:
apply min_mem
protected theorem lt_succ_iff {r : α → α → Prop} [wo : IsWellOrder α r] {x : α} (h : ∃ y, r x y)
    (y : α) : r y (wo.wf.succ x) ↔ r y x ∨ y = x := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r✝ r' r : α → α → Prop
wo : IsWellOrder α r
x : α
h : ∃ y, r x y
y : α
⊢ r y (WellFounded.succ (_ : WellFounded r) x) ↔ r y x ∨ y = x

Next tactic:
constructor
protected theorem lt_succ_iff {r : α → α → Prop} [wo : IsWellOrder α r] {x : α} (h : ∃ y, r x y)
    (y : α) : r y (wo.wf.succ x) ↔ r y x ∨ y = x := by
  constructor
  · 

Proof state:
case mp
α : Type u_1
β : Type u_2
γ : Type u_3
r✝ r' r : α → α → Prop
wo : IsWellOrder α r
x : α
h : ∃ y, r x y
y : α
⊢ r y (WellFounded.succ (_ : WellFounded r) x) → r y x ∨ y = x

Next tactic:
intro h'
protected theorem lt_succ_iff {r : α → α → Prop} [wo : IsWellOrder α r] {x : α} (h : ∃ y, r x y)
    (y : α) : r y (wo.wf.succ x) ↔ r y x ∨ y = x := by
  constructor
  · intro h'
    

Proof state:
case mp
α : Type u_1
β : Type u_2
γ : Type u_3
r✝ r' r : α → α → Prop
wo : IsWellOrder α r
x : α
h : ∃ y, r x y
y : α
h' : r y (WellFounded.succ (_ : WellFounded r) x)
⊢ r y x ∨ y = x

Next tactic:
have : ¬r x y := by
      intro hy
      rw [WellFounded.succ, dif_pos] at h'
      exact wo.wf.not_lt_min _ h hy h'
protected theorem lt_succ_iff {r : α → α → Prop} [wo : IsWellOrder α r] {x : α} (h : ∃ y, r x y)
    (y : α) : r y (wo.wf.succ x) ↔ r y x ∨ y = x := by
  constructor
  · intro h'
    have : ¬r x y := by
      

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r✝ r' r : α → α → Prop
wo : IsWellOrder α r
x : α
h : ∃ y, r x y
y : α
h' : r y (WellFounded.succ (_ : WellFounded r) x)
⊢ ¬r x y

Next tactic:
intro hy
protected theorem lt_succ_iff {r : α → α → Prop} [wo : IsWellOrder α r] {x : α} (h : ∃ y, r x y)
    (y : α) : r y (wo.wf.succ x) ↔ r y x ∨ y = x := by
  constructor
  · intro h'
    have : ¬r x y := by
      intro hy
      

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r✝ r' r : α → α → Prop
wo : IsWellOrder α r
x : α
h : ∃ y, r x y
y : α
h' : r y (WellFounded.succ (_ : WellFounded r) x)
hy : r x y
⊢ False

Next tactic:
rw [WellFounded.succ, dif_pos] at h'
protected theorem lt_succ_iff {r : α → α → Prop} [wo : IsWellOrder α r] {x : α} (h : ∃ y, r x y)
    (y : α) : r y (wo.wf.succ x) ↔ r y x ∨ y = x := by
  constructor
  · intro h'
    have : ¬r x y := by
      intro hy
      rw [WellFounded.succ, dif_pos] at h'
      

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r✝ r' r : α → α → Prop
wo : IsWellOrder α r
x : α
h : ∃ y, r x y
y : α
h'✝ : r y (if h : ∃ y, r x y then min (_ : WellFounded r) {y | r x y} h else x)
h' : r y (min (_ : WellFounded r) {y | r x y} ?hc)
hy : r x y
⊢ False
case hc
α : Type u_1
β : Type u_2
γ : Type u_3
r✝ r' r : α → α → Prop
wo : IsWellOrder α r
x : α
h : ∃ y, r x y
y : α
h' : r y (if h : ∃ y, r x y then min (_ : WellFounded r) {y | r x y} h else x)
hy : r x y
⊢ ∃ y, r x y

Next tactic:
exact wo.wf.not_lt_min _ h hy h'
protected theorem lt_succ_iff {r : α → α → Prop} [wo : IsWellOrder α r] {x : α} (h : ∃ y, r x y)
    (y : α) : r y (wo.wf.succ x) ↔ r y x ∨ y = x := by
  constructor
  · intro h'
    have : ¬r x y := by
      intro hy
      rw [WellFounded.succ, dif_pos] at h'
      exact wo.wf.not_lt_min _ h hy h'
    

Proof state:
case mp
α : Type u_1
β : Type u_2
γ : Type u_3
r✝ r' r : α → α → Prop
wo : IsWellOrder α r
x : α
h : ∃ y, r x y
y : α
h' : r y (WellFounded.succ (_ : WellFounded r) x)
this : ¬r x y
⊢ r y x ∨ y = x

Next tactic:
rcases trichotomous_of r x y with (hy | hy | hy)
protected theorem lt_succ_iff {r : α → α → Prop} [wo : IsWellOrder α r] {x : α} (h : ∃ y, r x y)
    (y : α) : r y (wo.wf.succ x) ↔ r y x ∨ y = x := by
  constructor
  · intro h'
    have : ¬r x y := by
      intro hy
      rw [WellFounded.succ, dif_pos] at h'
      exact wo.wf.not_lt_min _ h hy h'
    rcases trichotomous_of r x y with (hy | hy | hy)
    

Proof state:
case mp.inl
α : Type u_1
β : Type u_2
γ : Type u_3
r✝ r' r : α → α → Prop
wo : IsWellOrder α r
x : α
h : ∃ y, r x y
y : α
h' : r y (WellFounded.succ (_ : WellFounded r) x)
this : ¬r x y
hy : r x y
⊢ r y x ∨ y = x
case mp.inr.inl
α : Type u_1
β : Type u_2
γ : Type u_3
r✝ r' r : α → α → Prop
wo : IsWellOrder α r
x : α
h : ∃ y, r x y
y : α
h' : r y (WellFounded.succ (_ : WellFounded r) x)
this : ¬r x y
hy : x = y
⊢ r y x ∨ y = x
case mp.inr.inr
α : Type u_1
β : Type u_2
γ : Type u_3
r✝ r' r : α → α → Prop
wo : IsWellOrder α r
x : α
h : ∃ y, r x y
y : α
h' : r y (WellFounded.succ (_ : WellFounded r) x)
this : ¬r x y
hy : r y x
⊢ r y x ∨ y = x

Next tactic:
exfalso
protected theorem lt_succ_iff {r : α → α → Prop} [wo : IsWellOrder α r] {x : α} (h : ∃ y, r x y)
    (y : α) : r y (wo.wf.succ x) ↔ r y x ∨ y = x := by
  constructor
  · intro h'
    have : ¬r x y := by
      intro hy
      rw [WellFounded.succ, dif_pos] at h'
      exact wo.wf.not_lt_min _ h hy h'
    rcases trichotomous_of r x y with (hy | hy | hy)
    exfalso
    

Proof state:
case mp.inl.h
α : Type u_1
β : Type u_2
γ : Type u_3
r✝ r' r : α → α → Prop
wo : IsWellOrder α r
x : α
h : ∃ y, r x y
y : α
h' : r y (WellFounded.succ (_ : WellFounded r) x)
this : ¬r x y
hy : r x y
⊢ False
case mp.inr.inl
α : Type u_1
β : Type u_2
γ : Type u_3
r✝ r' r : α → α → Prop
wo : IsWellOrder α r
x : α
h : ∃ y, r x y
y : α
h' : r y (WellFounded.succ (_ : WellFounded r) x)
this : ¬r x y
hy : x = y
⊢ r y x ∨ y = x
case mp.inr.inr
α : Type u_1
β : Type u_2
γ : Type u_3
r✝ r' r : α → α → Prop
wo : IsWellOrder α r
x : α
h : ∃ y, r x y
y : α
h' : r y (WellFounded.succ (_ : WellFounded r) x)
this : ¬r x y
hy : r y x
⊢ r y x ∨ y = x

Next tactic:
exact this hy