l3lab/ntp-mathlib huggingface dataset:
/-- **Rolle's Theorem**, a version for a function on an open interval: if `f` has the same limit
`l` at `𝓝[>] a` and `𝓝[<] b`, then `deriv f c = 0` for some `c ∈ (a, b)`. This version
does not require differentiability of `f` because we define `deriv f c = 0` whenever `f` is not
differentiable at `c`. -/
theorem exists_deriv_eq_zero' (hab : a < b) (hfa : Tendsto f (𝓝[>] a) (𝓝 l))
    (hfb : Tendsto f (𝓝[<] b) (𝓝 l)) : ∃ c ∈ Ioo a b, deriv f c = 0 := by
  by_cases h : ∀ x ∈ Ioo a b, DifferentiableAt ℝ f x
  · 

Proof state:
case pos
f f' : ℝ → ℝ
a b l : ℝ
hab : a < b
hfa : Tendsto f (𝓝[>] a) (𝓝 l)
hfb : Tendsto f (𝓝[<] b) (𝓝 l)
h : ∀ x ∈ Ioo a b, DifferentiableAt ℝ f x
⊢ ∃ c ∈ Ioo a b, deriv f c = 0

Next tactic:
exact exists_hasDerivAt_eq_zero' hab hfa hfb fun x hx => (h x hx).hasDerivAt
/-- **Rolle's Theorem**, a version for a function on an open interval: if `f` has the same limit
`l` at `𝓝[>] a` and `𝓝[<] b`, then `deriv f c = 0` for some `c ∈ (a, b)`. This version
does not require differentiability of `f` because we define `deriv f c = 0` whenever `f` is not
differentiable at `c`. -/
theorem exists_deriv_eq_zero' (hab : a < b) (hfa : Tendsto f (𝓝[>] a) (𝓝 l))
    (hfb : Tendsto f (𝓝[<] b) (𝓝 l)) : ∃ c ∈ Ioo a b, deriv f c = 0 := by
  by_cases h : ∀ x ∈ Ioo a b, DifferentiableAt ℝ f x
  · exact exists_hasDerivAt_eq_zero' hab hfa hfb fun x hx => (h x hx).hasDerivAt
  · 

Proof state:
case neg
f f' : ℝ → ℝ
a b l : ℝ
hab : a < b
hfa : Tendsto f (𝓝[>] a) (𝓝 l)
hfb : Tendsto f (𝓝[<] b) (𝓝 l)
h : ¬∀ x ∈ Ioo a b, DifferentiableAt ℝ f x
⊢ ∃ c ∈ Ioo a b, deriv f c = 0

Next tactic:
obtain ⟨c, hc, hcdiff⟩ : ∃ x ∈ Ioo a b, ¬DifferentiableAt ℝ f x
/-- **Rolle's Theorem**, a version for a function on an open interval: if `f` has the same limit
`l` at `𝓝[>] a` and `𝓝[<] b`, then `deriv f c = 0` for some `c ∈ (a, b)`. This version
does not require differentiability of `f` because we define `deriv f c = 0` whenever `f` is not
differentiable at `c`. -/
theorem exists_deriv_eq_zero' (hab : a < b) (hfa : Tendsto f (𝓝[>] a) (𝓝 l))
    (hfb : Tendsto f (𝓝[<] b) (𝓝 l)) : ∃ c ∈ Ioo a b, deriv f c = 0 := by
  by_cases h : ∀ x ∈ Ioo a b, DifferentiableAt ℝ f x
  · exact exists_hasDerivAt_eq_zero' hab hfa hfb fun x hx => (h x hx).hasDerivAt
  · obtain ⟨c, hc, hcdiff⟩ : ∃ x ∈ Ioo a b, ¬DifferentiableAt ℝ f x
    · 

Proof state:
f f' : ℝ → ℝ
a b l : ℝ
hab : a < b
hfa : Tendsto f (𝓝[>] a) (𝓝 l)
hfb : Tendsto f (𝓝[<] b) (𝓝 l)
h : ¬∀ x ∈ Ioo a b, DifferentiableAt ℝ f x
⊢ ∃ x ∈ Ioo a b, ¬DifferentiableAt ℝ f x

Next tactic:
push_neg at h
/-- **Rolle's Theorem**, a version for a function on an open interval: if `f` has the same limit
`l` at `𝓝[>] a` and `𝓝[<] b`, then `deriv f c = 0` for some `c ∈ (a, b)`. This version
does not require differentiability of `f` because we define `deriv f c = 0` whenever `f` is not
differentiable at `c`. -/
theorem exists_deriv_eq_zero' (hab : a < b) (hfa : Tendsto f (𝓝[>] a) (𝓝 l))
    (hfb : Tendsto f (𝓝[<] b) (𝓝 l)) : ∃ c ∈ Ioo a b, deriv f c = 0 := by
  by_cases h : ∀ x ∈ Ioo a b, DifferentiableAt ℝ f x
  · exact exists_hasDerivAt_eq_zero' hab hfa hfb fun x hx => (h x hx).hasDerivAt
  · obtain ⟨c, hc, hcdiff⟩ : ∃ x ∈ Ioo a b, ¬DifferentiableAt ℝ f x
    · push_neg at h; 

Proof state:
f f' : ℝ → ℝ
a b l : ℝ
hab : a < b
hfa : Tendsto f (𝓝[>] a) (𝓝 l)
hfb : Tendsto f (𝓝[<] b) (𝓝 l)
h : ∃ x ∈ Ioo a b, ¬DifferentiableAt ℝ f x
⊢ ∃ x ∈ Ioo a b, ¬DifferentiableAt ℝ f x

Next tactic:
exact h
/-- **Rolle's Theorem**, a version for a function on an open interval: if `f` has the same limit
`l` at `𝓝[>] a` and `𝓝[<] b`, then `deriv f c = 0` for some `c ∈ (a, b)`. This version
does not require differentiability of `f` because we define `deriv f c = 0` whenever `f` is not
differentiable at `c`. -/
theorem exists_deriv_eq_zero' (hab : a < b) (hfa : Tendsto f (𝓝[>] a) (𝓝 l))
    (hfb : Tendsto f (𝓝[<] b) (𝓝 l)) : ∃ c ∈ Ioo a b, deriv f c = 0 := by
  by_cases h : ∀ x ∈ Ioo a b, DifferentiableAt ℝ f x
  · exact exists_hasDerivAt_eq_zero' hab hfa hfb fun x hx => (h x hx).hasDerivAt
  · obtain ⟨c, hc, hcdiff⟩ : ∃ x ∈ Ioo a b, ¬DifferentiableAt ℝ f x
    · push_neg at h; exact h
    

Proof state:
case neg.intro.intro
f f' : ℝ → ℝ
a b l : ℝ
hab : a < b
hfa : Tendsto f (𝓝[>] a) (𝓝 l)
hfb : Tendsto f (𝓝[<] b) (𝓝 l)
h : ¬∀ x ∈ Ioo a b, DifferentiableAt ℝ f x
c : ℝ
hc : c ∈ Ioo a b
hcdiff : ¬DifferentiableAt ℝ f c
⊢ ∃ c ∈ Ioo a b, deriv f c = 0

Next tactic:
exact ⟨c, hc, deriv_zero_of_not_differentiableAt hcdiff⟩
theorem zero_bot (n : ℕ) : Ico 0 n = range n := by 

Proof state:
n : ℕ
⊢ Ico 0 n = range n

Next tactic:
rw [Ico, tsub_zero, range_eq_range']
@[simp]
theorem length (n m : ℕ) : length (Ico n m) = m - n := by
  

Proof state:
n m : ℕ
⊢ List.length (Ico n m) = m - n

Next tactic:
dsimp [Ico]
@[simp]
theorem length (n m : ℕ) : length (Ico n m) = m - n := by
  dsimp [Ico]
  

Proof state:
n m : ℕ
⊢ List.length (range' n (m - n)) = m - n

Next tactic:
simp [length_range', autoParam]
theorem pairwise_lt (n m : ℕ) : Pairwise (· < ·) (Ico n m) := by
  

Proof state:
n m : ℕ
⊢ Pairwise (fun x x_1 => x < x_1) (Ico n m)

Next tactic:
dsimp [Ico]
theorem pairwise_lt (n m : ℕ) : Pairwise (· < ·) (Ico n m) := by
  dsimp [Ico]
  

Proof state:
n m : ℕ
⊢ Pairwise (fun x x_1 => x < x_1) (range' n (m - n))

Next tactic:
simp [pairwise_lt_range', autoParam]
theorem nodup (n m : ℕ) : Nodup (Ico n m) := by
  

Proof state:
n m : ℕ
⊢ Nodup (Ico n m)

Next tactic:
dsimp [Ico]
theorem nodup (n m : ℕ) : Nodup (Ico n m) := by
  dsimp [Ico]
  

Proof state:
n m : ℕ
⊢ Nodup (range' n (m - n))

Next tactic:
simp [nodup_range', autoParam]
@[simp]
theorem mem {n m l : ℕ} : l ∈ Ico n m ↔ n ≤ l ∧ l < m := by
  

Proof state:
n m l : ℕ
⊢ l ∈ Ico n m ↔ n ≤ l ∧ l < m

Next tactic:
suffices n ≤ l ∧ l < n + (m - n) ↔ n ≤ l ∧ l < m by simp [Ico, this]
@[simp]
theorem mem {n m l : ℕ} : l ∈ Ico n m ↔ n ≤ l ∧ l < m := by
  suffices n ≤ l ∧ l < n + (m - n) ↔ n ≤ l ∧ l < m by 

Proof state:
n m l : ℕ
this : n ≤ l ∧ l < n + (m - n) ↔ n ≤ l ∧ l < m
⊢ l ∈ Ico n m ↔ n ≤ l ∧ l < m

Next tactic:
simp [Ico, this]
@[simp]
theorem mem {n m l : ℕ} : l ∈ Ico n m ↔ n ≤ l ∧ l < m := by
  suffices n ≤ l ∧ l < n + (m - n) ↔ n ≤ l ∧ l < m by simp [Ico, this]
  

Proof state:
n m l : ℕ
⊢ n ≤ l ∧ l < n + (m - n) ↔ n ≤ l ∧ l < m

Next tactic:
rcases le_total n m with hnm | hmn
@[simp]
theorem mem {n m l : ℕ} : l ∈ Ico n m ↔ n ≤ l ∧ l < m := by
  suffices n ≤ l ∧ l < n + (m - n) ↔ n ≤ l ∧ l < m by simp [Ico, this]
  rcases le_total n m with hnm | hmn
  · 

Proof state:
case inl
n m l : ℕ
hnm : n ≤ m
⊢ n ≤ l ∧ l < n + (m - n) ↔ n ≤ l ∧ l < m

Next tactic:
rw [add_tsub_cancel_of_le hnm]
@[simp]
theorem mem {n m l : ℕ} : l ∈ Ico n m ↔ n ≤ l ∧ l < m := by
  suffices n ≤ l ∧ l < n + (m - n) ↔ n ≤ l ∧ l < m by simp [Ico, this]
  rcases le_total n m with hnm | hmn
  · rw [add_tsub_cancel_of_le hnm]
  · 

Proof state:
case inr
n m l : ℕ
hmn : m ≤ n
⊢ n ≤ l ∧ l < n + (m - n) ↔ n ≤ l ∧ l < m

Next tactic:
rw [tsub_eq_zero_iff_le.mpr hmn, add_zero]
@[simp]
theorem mem {n m l : ℕ} : l ∈ Ico n m ↔ n ≤ l ∧ l < m := by
  suffices n ≤ l ∧ l < n + (m - n) ↔ n ≤ l ∧ l < m by simp [Ico, this]
  rcases le_total n m with hnm | hmn
  · rw [add_tsub_cancel_of_le hnm]
  · rw [tsub_eq_zero_iff_le.mpr hmn, add_zero]
    

Proof state:
case inr
n m l : ℕ
hmn : m ≤ n
⊢ n ≤ l ∧ l < n ↔ n ≤ l ∧ l < m

Next tactic:
exact
      and_congr_right fun hnl =>
        Iff.intro (fun hln => (not_le_of_gt hln hnl).elim) fun hlm => lt_of_lt_of_le hlm hmn
theorem eq_nil_of_le {n m : ℕ} (h : m ≤ n) : Ico n m = [] := by
  

Proof state:
n m : ℕ
h : m ≤ n
⊢ Ico n m = []

Next tactic:
simp [Ico, tsub_eq_zero_iff_le.mpr h]
theorem map_add (n m k : ℕ) : (Ico n m).map (k + ·) = Ico (n + k) (m + k) := by
  

Proof state:
n m k : ℕ
⊢ map (fun x => k + x) (Ico n m) = Ico (n + k) (m + k)

Next tactic:
rw [Ico, Ico, map_add_range', add_tsub_add_eq_tsub_right m k, add_comm n k]
theorem map_sub (n m k : ℕ) (h₁ : k ≤ n) :
    ((Ico n m).map fun x => x - k) = Ico (n - k) (m - k) := by
  

Proof state:
n m k : ℕ
h₁ : k ≤ n
⊢ map (fun x => x - k) (Ico n m) = Ico (n - k) (m - k)

Next tactic:
rw [Ico, Ico, tsub_tsub_tsub_cancel_right h₁, map_sub_range' _ _ _ h₁]
@[simp]
theorem eq_empty_iff {n m : ℕ} : Ico n m = [] ↔ m ≤ n :=
  Iff.intro (fun h => tsub_eq_zero_iff_le.mp <| by 

Proof state:
n m : ℕ
h : Ico n m = []
⊢ m - n = 0

Next tactic:
rw [← length, h, List.length]
theorem append_consecutive {n m l : ℕ} (hnm : n ≤ m) (hml : m ≤ l) :
    Ico n m ++ Ico m l = Ico n l := by
  

Proof state:
n m l : ℕ
hnm : n ≤ m
hml : m ≤ l
⊢ Ico n m ++ Ico m l = Ico n l

Next tactic:
dsimp only [Ico]
theorem append_consecutive {n m l : ℕ} (hnm : n ≤ m) (hml : m ≤ l) :
    Ico n m ++ Ico m l = Ico n l := by
  dsimp only [Ico]
  

Proof state:
n m l : ℕ
hnm : n ≤ m
hml : m ≤ l
⊢ range' n (m - n) ++ range' m (l - m) = range' n (l - n)

Next tactic:
convert range'_append n (m-n) (l-m) 1 using 2
theorem append_consecutive {n m l : ℕ} (hnm : n ≤ m) (hml : m ≤ l) :
    Ico n m ++ Ico m l = Ico n l := by
  dsimp only [Ico]
  convert range'_append n (m-n) (l-m) 1 using 2
  · 

Proof state:
case h.e'_2.h.e'_6
n m l : ℕ
hnm : n ≤ m
hml : m ≤ l
⊢ range' m (l - m) = range' (n + 1 * (m - n)) (l - m)

Next tactic:
rw [one_mul, add_tsub_cancel_of_le hnm]
theorem append_consecutive {n m l : ℕ} (hnm : n ≤ m) (hml : m ≤ l) :
    Ico n m ++ Ico m l = Ico n l := by
  dsimp only [Ico]
  convert range'_append n (m-n) (l-m) 1 using 2
  · rw [one_mul, add_tsub_cancel_of_le hnm]
  · 

Proof state:
case h.e'_3.h.e'_2
n m l : ℕ
hnm : n ≤ m
hml : m ≤ l
⊢ l - n = l - m + (m - n)

Next tactic:
rw [tsub_add_tsub_cancel hml hnm]
@[simp]
theorem inter_consecutive (n m l : ℕ) : Ico n m ∩ Ico m l = [] := by
  

Proof state:
n m l : ℕ
⊢ Ico n m ∩ Ico m l = []

Next tactic:
apply eq_nil_iff_forall_not_mem.2
@[simp]
theorem inter_consecutive (n m l : ℕ) : Ico n m ∩ Ico m l = [] := by
  apply eq_nil_iff_forall_not_mem.2
  

Proof state:
n m l : ℕ
⊢ ∀ (a : ℕ), a ∉ Ico n m ∩ Ico m l

Next tactic:
intro a
@[simp]
theorem inter_consecutive (n m l : ℕ) : Ico n m ∩ Ico m l = [] := by
  apply eq_nil_iff_forall_not_mem.2
  intro a
  

Proof state:
n m l a : ℕ
⊢ a ∉ Ico n m ∩ Ico m l

Next tactic:
simp only [and_imp, not_and, not_lt, List.mem_inter_iff, List.Ico.mem]
@[simp]
theorem inter_consecutive (n m l : ℕ) : Ico n m ∩ Ico m l = [] := by
  apply eq_nil_iff_forall_not_mem.2
  intro a
  simp only [and_imp, not_and, not_lt, List.mem_inter_iff, List.Ico.mem]
  

Proof state:
n m l a : ℕ
⊢ n ≤ a → a < m → m ≤ a → l ≤ a

Next tactic:
intro _ h₂ h₃
@[simp]
theorem inter_consecutive (n m l : ℕ) : Ico n m ∩ Ico m l = [] := by
  apply eq_nil_iff_forall_not_mem.2
  intro a
  simp only [and_imp, not_and, not_lt, List.mem_inter_iff, List.Ico.mem]
  intro _ h₂ h₃
  

Proof state:
n m l a : ℕ
a✝ : n ≤ a
h₂ : a < m
h₃ : m ≤ a
⊢ l ≤ a

Next tactic:
exfalso
@[simp]
theorem inter_consecutive (n m l : ℕ) : Ico n m ∩ Ico m l = [] := by
  apply eq_nil_iff_forall_not_mem.2
  intro a
  simp only [and_imp, not_and, not_lt, List.mem_inter_iff, List.Ico.mem]
  intro _ h₂ h₃
  exfalso
  

Proof state:
case h
n m l a : ℕ
a✝ : n ≤ a
h₂ : a < m
h₃ : m ≤ a
⊢ False

Next tactic:
exact not_lt_of_ge h₃ h₂
@[simp]
theorem succ_singleton {n : ℕ} : Ico n (n + 1) = [n] := by
  

Proof state:
n : ℕ
⊢ Ico n (n + 1) = [n]

Next tactic:
dsimp [Ico]
@[simp]
theorem succ_singleton {n : ℕ} : Ico n (n + 1) = [n] := by
  dsimp [Ico]
  

Proof state:
n : ℕ
⊢ range' n (n + 1 - n) = [n]

Next tactic:
simp [range', add_tsub_cancel_left]
theorem succ_top {n m : ℕ} (h : n ≤ m) : Ico n (m + 1) = Ico n m ++ [m] := by
  

Proof state:
n m : ℕ
h : n ≤ m
⊢ Ico n (m + 1) = Ico n m ++ [m]

Next tactic:
rwa [← succ_singleton, append_consecutive]
theorem succ_top {n m : ℕ} (h : n ≤ m) : Ico n (m + 1) = Ico n m ++ [m] := by
  rwa [← succ_singleton, append_consecutive]
  

Proof state:
case hml
n m : ℕ
h : n ≤ m
⊢ m ≤ m + 1

Next tactic:
exact Nat.le_succ _
theorem eq_cons {n m : ℕ} (h : n < m) : Ico n m = n :: Ico (n + 1) m := by
  

Proof state:
n m : ℕ
h : n < m
⊢ Ico n m = n :: Ico (n + 1) m

Next tactic:
rw [← append_consecutive (Nat.le_succ n) h, succ_singleton]
theorem eq_cons {n m : ℕ} (h : n < m) : Ico n m = n :: Ico (n + 1) m := by
  rw [← append_consecutive (Nat.le_succ n) h, succ_singleton]
  

Proof state:
n m : ℕ
h : n < m
⊢ [n] ++ Ico (succ n) m = n :: Ico (n + 1) m

Next tactic:
rfl
@[simp]
theorem pred_singleton {m : ℕ} (h : 0 < m) : Ico (m - 1) m = [m - 1] := by
  

Proof state:
m : ℕ
h : 0 < m
⊢ Ico (m - 1) m = [m - 1]

Next tactic:
dsimp [Ico]
@[simp]
theorem pred_singleton {m : ℕ} (h : 0 < m) : Ico (m - 1) m = [m - 1] := by
  dsimp [Ico]
  

Proof state:
m : ℕ
h : 0 < m
⊢ range' (m - 1) (m - (m - 1)) = [m - 1]

Next tactic:
rw [tsub_tsub_cancel_of_le (succ_le_of_lt h)]
@[simp]
theorem pred_singleton {m : ℕ} (h : 0 < m) : Ico (m - 1) m = [m - 1] := by
  dsimp [Ico]
  rw [tsub_tsub_cancel_of_le (succ_le_of_lt h)]
  

Proof state:
m : ℕ
h : 0 < m
⊢ range' (m - 1) (succ 0) = [m - 1]

Next tactic:
simp [← Nat.one_eq_succ_zero]
theorem chain'_succ (n m : ℕ) : Chain' (fun a b => b = succ a) (Ico n m) := by
  

Proof state:
n m : ℕ
⊢ Chain' (fun a b => b = succ a) (Ico n m)

Next tactic:
by_cases h : n < m
theorem chain'_succ (n m : ℕ) : Chain' (fun a b => b = succ a) (Ico n m) := by
  by_cases h : n < m
  · 

Proof state:
case pos
n m : ℕ
h : n < m
⊢ Chain' (fun a b => b = succ a) (Ico n m)

Next tactic:
rw [eq_cons h]
theorem chain'_succ (n m : ℕ) : Chain' (fun a b => b = succ a) (Ico n m) := by
  by_cases h : n < m
  · rw [eq_cons h]
    

Proof state:
case pos
n m : ℕ
h : n < m
⊢ Chain' (fun a b => b = succ a) (n :: Ico (n + 1) m)

Next tactic:
exact chain_succ_range' _ _ 1
theorem chain'_succ (n m : ℕ) : Chain' (fun a b => b = succ a) (Ico n m) := by
  by_cases h : n < m
  · rw [eq_cons h]
    exact chain_succ_range' _ _ 1
  · 

Proof state:
case neg
n m : ℕ
h : ¬n < m
⊢ Chain' (fun a b => b = succ a) (Ico n m)

Next tactic:
rw [eq_nil_of_le (le_of_not_gt h)]
theorem chain'_succ (n m : ℕ) : Chain' (fun a b => b = succ a) (Ico n m) := by
  by_cases h : n < m
  · rw [eq_cons h]
    exact chain_succ_range' _ _ 1
  · rw [eq_nil_of_le (le_of_not_gt h)]
    

Proof state:
case neg
n m : ℕ
h : ¬n < m
⊢ Chain' (fun a b => b = succ a) []

Next tactic:
trivial
theorem not_mem_top {n m : ℕ} : m ∉ Ico n m := by 

Proof state:
n m : ℕ
⊢ m ∉ Ico n m

Next tactic:
simp
theorem filter_lt_of_top_le {n m l : ℕ} (hml : m ≤ l) :
    ((Ico n m).filter fun x => x < l) = Ico n m :=
  filter_eq_self.2 fun k hk => by
    

Proof state:
n m l : ℕ
hml : m ≤ l
k : ℕ
hk : k ∈ Ico n m
⊢ decide (k < l) = true

Next tactic:
simp only [(lt_of_lt_of_le (mem.1 hk).2 hml), decide_True]
theorem filter_lt_of_le_bot {n m l : ℕ} (hln : l ≤ n) : ((Ico n m).filter fun x => x < l) = [] :=
  filter_eq_nil.2 fun k hk => by
     

Proof state:
n m l : ℕ
hln : l ≤ n
k : ℕ
hk : k ∈ Ico n m
⊢ ¬decide (k < l) = true

Next tactic:
simp only [decide_eq_true_eq, not_lt]
theorem filter_lt_of_le_bot {n m l : ℕ} (hln : l ≤ n) : ((Ico n m).filter fun x => x < l) = [] :=
  filter_eq_nil.2 fun k hk => by
     simp only [decide_eq_true_eq, not_lt]
     

Proof state:
n m l : ℕ
hln : l ≤ n
k : ℕ
hk : k ∈ Ico n m
⊢ l ≤ k

Next tactic:
apply le_trans hln
theorem filter_lt_of_le_bot {n m l : ℕ} (hln : l ≤ n) : ((Ico n m).filter fun x => x < l) = [] :=
  filter_eq_nil.2 fun k hk => by
     simp only [decide_eq_true_eq, not_lt]
     apply le_trans hln
     

Proof state:
n m l : ℕ
hln : l ≤ n
k : ℕ
hk : k ∈ Ico n m
⊢ n ≤ k

Next tactic:
exact (mem.1 hk).1
theorem filter_lt_of_ge {n m l : ℕ} (hlm : l ≤ m) :
    ((Ico n m).filter fun x => x < l) = Ico n l := by
  

Proof state:
n m l : ℕ
hlm : l ≤ m
⊢ filter (fun x => decide (x < l)) (Ico n m) = Ico n l

Next tactic:
rcases le_total n l with hnl | hln
theorem filter_lt_of_ge {n m l : ℕ} (hlm : l ≤ m) :
    ((Ico n m).filter fun x => x < l) = Ico n l := by
  rcases le_total n l with hnl | hln
  · 

Proof state:
case inl
n m l : ℕ
hlm : l ≤ m
hnl : n ≤ l
⊢ filter (fun x => decide (x < l)) (Ico n m) = Ico n l

Next tactic:
rw [← append_consecutive hnl hlm, filter_append, filter_lt_of_top_le (le_refl l),
      filter_lt_of_le_bot (le_refl l), append_nil]
theorem filter_lt_of_ge {n m l : ℕ} (hlm : l ≤ m) :
    ((Ico n m).filter fun x => x < l) = Ico n l := by
  rcases le_total n l with hnl | hln
  · rw [← append_consecutive hnl hlm, filter_append, filter_lt_of_top_le (le_refl l),
      filter_lt_of_le_bot (le_refl l), append_nil]
  · 

Proof state:
case inr
n m l : ℕ
hlm : l ≤ m
hln : l ≤ n
⊢ filter (fun x => decide (x < l)) (Ico n m) = Ico n l

Next tactic:
rw [eq_nil_of_le hln, filter_lt_of_le_bot hln]
@[simp]
theorem filter_lt (n m l : ℕ) :
    ((Ico n m).filter fun x => x < l) = Ico n (min m l) := by
  

Proof state:
n m l : ℕ
⊢ filter (fun x => decide (x < l)) (Ico n m) = Ico n (min m l)

Next tactic:
rcases le_total m l with hml | hlm
@[simp]
theorem filter_lt (n m l : ℕ) :
    ((Ico n m).filter fun x => x < l) = Ico n (min m l) := by
  rcases le_total m l with hml | hlm
  · 

Proof state:
case inl
n m l : ℕ
hml : m ≤ l
⊢ filter (fun x => decide (x < l)) (Ico n m) = Ico n (min m l)

Next tactic:
rw [min_eq_left hml, filter_lt_of_top_le hml]
@[simp]
theorem filter_lt (n m l : ℕ) :
    ((Ico n m).filter fun x => x < l) = Ico n (min m l) := by
  rcases le_total m l with hml | hlm
  · rw [min_eq_left hml, filter_lt_of_top_le hml]
  · 

Proof state:
case inr
n m l : ℕ
hlm : l ≤ m
⊢ filter (fun x => decide (x < l)) (Ico n m) = Ico n (min m l)

Next tactic:
rw [min_eq_right hlm, filter_lt_of_ge hlm]
theorem filter_le_of_le_bot {n m l : ℕ} (hln : l ≤ n) :
    ((Ico n m).filter fun x => l ≤ x) = Ico n m :=
  filter_eq_self.2 fun k hk => by
    

Proof state:
n m l : ℕ
hln : l ≤ n
k : ℕ
hk : k ∈ Ico n m
⊢ decide (l ≤ k) = true

Next tactic:
rw [decide_eq_true_eq]
theorem filter_le_of_le_bot {n m l : ℕ} (hln : l ≤ n) :
    ((Ico n m).filter fun x => l ≤ x) = Ico n m :=
  filter_eq_self.2 fun k hk => by
    rw [decide_eq_true_eq]
    

Proof state:
n m l : ℕ
hln : l ≤ n
k : ℕ
hk : k ∈ Ico n m
⊢ l ≤ k

Next tactic:
exact le_trans hln (mem.1 hk).1
theorem filter_le_of_top_le {n m l : ℕ} (hml : m ≤ l) : ((Ico n m).filter fun x => l ≤ x) = [] :=
  filter_eq_nil.2 fun k hk => by
    

Proof state:
n m l : ℕ
hml : m ≤ l
k : ℕ
hk : k ∈ Ico n m
⊢ ¬decide (l ≤ k) = true

Next tactic:
rw [decide_eq_true_eq]
theorem filter_le_of_top_le {n m l : ℕ} (hml : m ≤ l) : ((Ico n m).filter fun x => l ≤ x) = [] :=
  filter_eq_nil.2 fun k hk => by
    rw [decide_eq_true_eq]
    

Proof state:
n m l : ℕ
hml : m ≤ l
k : ℕ
hk : k ∈ Ico n m
⊢ ¬l ≤ k

Next tactic:
exact not_le_of_gt (lt_of_lt_of_le (mem.1 hk).2 hml)
theorem filter_le_of_le {n m l : ℕ} (hnl : n ≤ l) :
    ((Ico n m).filter fun x => l ≤ x) = Ico l m := by
  

Proof state:
n m l : ℕ
hnl : n ≤ l
⊢ filter (fun x => decide (l ≤ x)) (Ico n m) = Ico l m

Next tactic:
rcases le_total l m with hlm | hml
theorem filter_le_of_le {n m l : ℕ} (hnl : n ≤ l) :
    ((Ico n m).filter fun x => l ≤ x) = Ico l m := by
  rcases le_total l m with hlm | hml
  · 

Proof state:
case inl
n m l : ℕ
hnl : n ≤ l
hlm : l ≤ m
⊢ filter (fun x => decide (l ≤ x)) (Ico n m) = Ico l m

Next tactic:
rw [← append_consecutive hnl hlm, filter_append, filter_le_of_top_le (le_refl l),
      filter_le_of_le_bot (le_refl l), nil_append]
theorem filter_le_of_le {n m l : ℕ} (hnl : n ≤ l) :
    ((Ico n m).filter fun x => l ≤ x) = Ico l m := by
  rcases le_total l m with hlm | hml
  · rw [← append_consecutive hnl hlm, filter_append, filter_le_of_top_le (le_refl l),
      filter_le_of_le_bot (le_refl l), nil_append]
  · 

Proof state:
case inr
n m l : ℕ
hnl : n ≤ l
hml : m ≤ l
⊢ filter (fun x => decide (l ≤ x)) (Ico n m) = Ico l m

Next tactic:
rw [eq_nil_of_le hml, filter_le_of_top_le hml]
@[simp]
theorem filter_le (n m l : ℕ) : ((Ico n m).filter fun x => l ≤ x) = Ico (max n l) m := by
  

Proof state:
n m l : ℕ
⊢ filter (fun x => decide (l ≤ x)) (Ico n m) = Ico (max n l) m

Next tactic:
rcases le_total n l with hnl | hln
@[simp]
theorem filter_le (n m l : ℕ) : ((Ico n m).filter fun x => l ≤ x) = Ico (max n l) m := by
  rcases le_total n l with hnl | hln
  · 

Proof state:
case inl
n m l : ℕ
hnl : n ≤ l
⊢ filter (fun x => decide (l ≤ x)) (Ico n m) = Ico (max n l) m

Next tactic:
rw [max_eq_right hnl, filter_le_of_le hnl]
@[simp]
theorem filter_le (n m l : ℕ) : ((Ico n m).filter fun x => l ≤ x) = Ico (max n l) m := by
  rcases le_total n l with hnl | hln
  · rw [max_eq_right hnl, filter_le_of_le hnl]
  · 

Proof state:
case inr
n m l : ℕ
hln : l ≤ n
⊢ filter (fun x => decide (l ≤ x)) (Ico n m) = Ico (max n l) m

Next tactic:
rw [max_eq_left hln, filter_le_of_le_bot hln]
theorem filter_lt_of_succ_bot {n m : ℕ} (hnm : n < m) :
    ((Ico n m).filter fun x => x < n + 1) = [n] := by
  

Proof state:
n m : ℕ
hnm : n < m
⊢ filter (fun x => decide (x < n + 1)) (Ico n m) = [n]

Next tactic:
have r : min m (n + 1) = n + 1 := (@inf_eq_right _ _ m (n + 1)).mpr hnm
theorem filter_lt_of_succ_bot {n m : ℕ} (hnm : n < m) :
    ((Ico n m).filter fun x => x < n + 1) = [n] := by
  have r : min m (n + 1) = n + 1 := (@inf_eq_right _ _ m (n + 1)).mpr hnm
  

Proof state:
n m : ℕ
hnm : n < m
r : min m (n + 1) = n + 1
⊢ filter (fun x => decide (x < n + 1)) (Ico n m) = [n]

Next tactic:
simp [filter_lt n m (n + 1), r]
@[simp]
theorem filter_le_of_bot {n m : ℕ} (hnm : n < m) : ((Ico n m).filter fun x => x ≤ n) = [n] := by
  

Proof state:
n m : ℕ
hnm : n < m
⊢ filter (fun x => decide (x ≤ n)) (Ico n m) = [n]

Next tactic:
rw [← filter_lt_of_succ_bot hnm]
@[simp]
theorem filter_le_of_bot {n m : ℕ} (hnm : n < m) : ((Ico n m).filter fun x => x ≤ n) = [n] := by
  rw [← filter_lt_of_succ_bot hnm]
  

Proof state:
n m : ℕ
hnm : n < m
⊢ filter (fun x => decide (x ≤ n)) (Ico n m) = filter (fun x => decide (x < n + 1)) (Ico n m)

Next tactic:
exact filter_congr' fun _ _ => by
    rw [decide_eq_true_eq, decide_eq_true_eq]
    exact lt_succ_iff.symm
@[simp]
theorem filter_le_of_bot {n m : ℕ} (hnm : n < m) : ((Ico n m).filter fun x => x ≤ n) = [n] := by
  rw [← filter_lt_of_succ_bot hnm]
  exact filter_congr' fun _ _ => by
    

Proof state:
n m : ℕ
hnm : n < m
x✝¹ : ℕ
x✝ : x✝¹ ∈ Ico n m
⊢ decide (x✝¹ ≤ n) = true ↔ decide (x✝¹ < n + 1) = true

Next tactic:
rw [decide_eq_true_eq, decide_eq_true_eq]
@[simp]
theorem filter_le_of_bot {n m : ℕ} (hnm : n < m) : ((Ico n m).filter fun x => x ≤ n) = [n] := by
  rw [← filter_lt_of_succ_bot hnm]
  exact filter_congr' fun _ _ => by
    rw [decide_eq_true_eq, decide_eq_true_eq]
    

Proof state:
n m : ℕ
hnm : n < m
x✝¹ : ℕ
x✝ : x✝¹ ∈ Ico n m
⊢ x✝¹ ≤ n ↔ x✝¹ < n + 1

Next tactic:
exact lt_succ_iff.symm
/-- For any natural numbers n, a, and b, one of the following holds:
1. n < a
2. n ≥ b
3. n ∈ Ico a b
-/
theorem trichotomy (n a b : ℕ) : n < a ∨ b ≤ n ∨ n ∈ Ico a b := by
  

Proof state:
n a b : ℕ
⊢ n < a ∨ b ≤ n ∨ n ∈ Ico a b

Next tactic:
by_cases h₁ : n < a
/-- For any natural numbers n, a, and b, one of the following holds:
1. n < a
2. n ≥ b
3. n ∈ Ico a b
-/
theorem trichotomy (n a b : ℕ) : n < a ∨ b ≤ n ∨ n ∈ Ico a b := by
  by_cases h₁ : n < a
  · 

Proof state:
case pos
n a b : ℕ
h₁ : n < a
⊢ n < a ∨ b ≤ n ∨ n ∈ Ico a b

Next tactic:
left
/-- For any natural numbers n, a, and b, one of the following holds:
1. n < a
2. n ≥ b
3. n ∈ Ico a b
-/
theorem trichotomy (n a b : ℕ) : n < a ∨ b ≤ n ∨ n ∈ Ico a b := by
  by_cases h₁ : n < a
  · left
    

Proof state:
case pos.h
n a b : ℕ
h₁ : n < a
⊢ n < a

Next tactic:
exact h₁
/-- For any natural numbers n, a, and b, one of the following holds:
1. n < a
2. n ≥ b
3. n ∈ Ico a b
-/
theorem trichotomy (n a b : ℕ) : n < a ∨ b ≤ n ∨ n ∈ Ico a b := by
  by_cases h₁ : n < a
  · left
    exact h₁
  · 

Proof state:
case neg
n a b : ℕ
h₁ : ¬n < a
⊢ n < a ∨ b ≤ n ∨ n ∈ Ico a b

Next tactic:
right
/-- For any natural numbers n, a, and b, one of the following holds:
1. n < a
2. n ≥ b
3. n ∈ Ico a b
-/
theorem trichotomy (n a b : ℕ) : n < a ∨ b ≤ n ∨ n ∈ Ico a b := by
  by_cases h₁ : n < a
  · left
    exact h₁
  · right
    

Proof state:
case neg.h
n a b : ℕ
h₁ : ¬n < a
⊢ b ≤ n ∨ n ∈ Ico a b

Next tactic:
by_cases h₂ : n ∈ Ico a b