l3lab/ntp-mathlib huggingface dataset:
instance : LocallyFiniteOrder ℕ where
  finsetIcc a b := ⟨List.range' a (b + 1 - a), List.nodup_range' _ _⟩
  finsetIco a b := ⟨List.range' a (b - a), List.nodup_range' _ _⟩
  finsetIoc a b := ⟨List.range' (a + 1) (b - a), List.nodup_range' _ _⟩
  finsetIoo a b := ⟨List.range' (a + 1) (b - a - 1), List.nodup_range' _ _⟩
  finset_mem_Icc a b x := by
    rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]
    cases le_or_lt a b with
    | inl h => rw [add_tsub_cancel_of_le (Nat.lt_succ_of_le h).le, Nat.lt_succ_iff]
    | inr h =>
      rw [tsub_eq_zero_iff_le.2 (succ_le_of_lt h), add_zero]
      exact iff_of_false (fun hx => hx.2.not_le hx.1) fun hx => h.not_le (hx.1.trans hx.2)
  finset_mem_Ico a b x := by
    rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]
    cases le_or_lt a b with
    | inl h => rw [add_tsub_cancel_of_le h]
    | inr h =>
      rw [tsub_eq_zero_iff_le.2 h.le, add_zero]
      exact iff_of_false (fun hx => hx.2.not_le hx.1) fun hx => h.not_le (hx.1.trans hx.2.le)
  finset_mem_Ioc a b x := by
    rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]
    cases le_or_lt a b with
    | inl h =>
      rw [← succ_sub_succ, add_tsub_cancel_of_le (succ_le_succ h), Nat.lt_succ_iff, Nat.succ_le_iff]
    | inr h =>
      rw [tsub_eq_zero_iff_le.2 h.le, add_zero]
      exact iff_of_false (fun hx => hx.2.not_le hx.1) fun hx => h.not_le (hx.1.le.trans hx.2)
  finset_mem_Ioo a b x := by
    rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1, ← tsub_add_eq_tsub_tsub]
    cases le_or_lt (a + 1) b with
    | inl h => rw [add_tsub_cancel_of_le h, Nat.succ_le_iff]
    

Proof state:
case inr
a b x : ℕ
h : b < a + 1
⊢ a + 1 ≤ x ∧ x < a + 1 + (b - (a + 1)) ↔ a < x ∧ x < b

Next tactic:
| inr h =>
      rw [tsub_eq_zero_iff_le.2 h.le, add_zero]
      exact iff_of_false (fun hx => hx.2.not_le hx.1) fun hx => h.not_le (hx.1.trans hx.2)
instance : LocallyFiniteOrder ℕ where
  finsetIcc a b := ⟨List.range' a (b + 1 - a), List.nodup_range' _ _⟩
  finsetIco a b := ⟨List.range' a (b - a), List.nodup_range' _ _⟩
  finsetIoc a b := ⟨List.range' (a + 1) (b - a), List.nodup_range' _ _⟩
  finsetIoo a b := ⟨List.range' (a + 1) (b - a - 1), List.nodup_range' _ _⟩
  finset_mem_Icc a b x := by
    rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]
    cases le_or_lt a b with
    | inl h => rw [add_tsub_cancel_of_le (Nat.lt_succ_of_le h).le, Nat.lt_succ_iff]
    | inr h =>
      rw [tsub_eq_zero_iff_le.2 (succ_le_of_lt h), add_zero]
      exact iff_of_false (fun hx => hx.2.not_le hx.1) fun hx => h.not_le (hx.1.trans hx.2)
  finset_mem_Ico a b x := by
    rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]
    cases le_or_lt a b with
    | inl h => rw [add_tsub_cancel_of_le h]
    | inr h =>
      rw [tsub_eq_zero_iff_le.2 h.le, add_zero]
      exact iff_of_false (fun hx => hx.2.not_le hx.1) fun hx => h.not_le (hx.1.trans hx.2.le)
  finset_mem_Ioc a b x := by
    rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]
    cases le_or_lt a b with
    | inl h =>
      rw [← succ_sub_succ, add_tsub_cancel_of_le (succ_le_succ h), Nat.lt_succ_iff, Nat.succ_le_iff]
    | inr h =>
      rw [tsub_eq_zero_iff_le.2 h.le, add_zero]
      exact iff_of_false (fun hx => hx.2.not_le hx.1) fun hx => h.not_le (hx.1.le.trans hx.2)
  finset_mem_Ioo a b x := by
    rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1, ← tsub_add_eq_tsub_tsub]
    cases le_or_lt (a + 1) b with
    | inl h => rw [add_tsub_cancel_of_le h, Nat.succ_le_iff]
    | inr h =>
      

Proof state:
case inr
a b x : ℕ
h : b < a + 1
⊢ a + 1 ≤ x ∧ x < a + 1 + (b - (a + 1)) ↔ a < x ∧ x < b

Next tactic:
rw [tsub_eq_zero_iff_le.2 h.le, add_zero]
instance : LocallyFiniteOrder ℕ where
  finsetIcc a b := ⟨List.range' a (b + 1 - a), List.nodup_range' _ _⟩
  finsetIco a b := ⟨List.range' a (b - a), List.nodup_range' _ _⟩
  finsetIoc a b := ⟨List.range' (a + 1) (b - a), List.nodup_range' _ _⟩
  finsetIoo a b := ⟨List.range' (a + 1) (b - a - 1), List.nodup_range' _ _⟩
  finset_mem_Icc a b x := by
    rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]
    cases le_or_lt a b with
    | inl h => rw [add_tsub_cancel_of_le (Nat.lt_succ_of_le h).le, Nat.lt_succ_iff]
    | inr h =>
      rw [tsub_eq_zero_iff_le.2 (succ_le_of_lt h), add_zero]
      exact iff_of_false (fun hx => hx.2.not_le hx.1) fun hx => h.not_le (hx.1.trans hx.2)
  finset_mem_Ico a b x := by
    rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]
    cases le_or_lt a b with
    | inl h => rw [add_tsub_cancel_of_le h]
    | inr h =>
      rw [tsub_eq_zero_iff_le.2 h.le, add_zero]
      exact iff_of_false (fun hx => hx.2.not_le hx.1) fun hx => h.not_le (hx.1.trans hx.2.le)
  finset_mem_Ioc a b x := by
    rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]
    cases le_or_lt a b with
    | inl h =>
      rw [← succ_sub_succ, add_tsub_cancel_of_le (succ_le_succ h), Nat.lt_succ_iff, Nat.succ_le_iff]
    | inr h =>
      rw [tsub_eq_zero_iff_le.2 h.le, add_zero]
      exact iff_of_false (fun hx => hx.2.not_le hx.1) fun hx => h.not_le (hx.1.le.trans hx.2)
  finset_mem_Ioo a b x := by
    rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1, ← tsub_add_eq_tsub_tsub]
    cases le_or_lt (a + 1) b with
    | inl h => rw [add_tsub_cancel_of_le h, Nat.succ_le_iff]
    | inr h =>
      rw [tsub_eq_zero_iff_le.2 h.le, add_zero]
      

Proof state:
case inr
a b x : ℕ
h : b < a + 1
⊢ a + 1 ≤ x ∧ x < a + 1 ↔ a < x ∧ x < b

Next tactic:
exact iff_of_false (fun hx => hx.2.not_le hx.1) fun hx => h.not_le (hx.1.trans hx.2)
theorem Iio_eq_range : Iio = range := by
  

Proof state:
a b c : ℕ
⊢ Iio = range

Next tactic:
ext b x
theorem Iio_eq_range : Iio = range := by
  ext b x
  

Proof state:
case h.a
a b✝ c b x : ℕ
⊢ x ∈ Iio b ↔ x ∈ range b

Next tactic:
rw [mem_Iio, mem_range]
@[simp]
theorem Ico_zero_eq_range : Ico 0 = range := by 

Proof state:
a b c : ℕ
⊢ Ico 0 = range

Next tactic:
rw [← bot_eq_zero, ← Iio_eq_Ico, Iio_eq_range]
@[simp]
theorem card_uIcc : (uIcc a b).card = (b - a : ℤ).natAbs + 1 := by
  

Proof state:
a b c : ℕ
⊢ card (uIcc a b) = Int.natAbs (↑b - ↑a) + 1

Next tactic:
refine' (card_Icc _ _).trans (Int.ofNat.inj _)
@[simp]
theorem card_uIcc : (uIcc a b).card = (b - a : ℤ).natAbs + 1 := by
  refine' (card_Icc _ _).trans (Int.ofNat.inj _)
  

Proof state:
a b c : ℕ
⊢ Int.ofNat (a ⊔ b + 1 - a ⊓ b) = Int.ofNat (Int.natAbs (↑b - ↑a) + 1)

Next tactic:
change ((↑) : ℕ → ℤ) _ = _
@[simp]
theorem card_uIcc : (uIcc a b).card = (b - a : ℤ).natAbs + 1 := by
  refine' (card_Icc _ _).trans (Int.ofNat.inj _)
  change ((↑) : ℕ → ℤ) _ = _
  

Proof state:
a b c : ℕ
⊢ ↑(a ⊔ b + 1 - a ⊓ b) = Int.ofNat (Int.natAbs (↑b - ↑a) + 1)

Next tactic:
rw [sup_eq_max, inf_eq_min, Int.ofNat_sub]
@[simp]
theorem card_uIcc : (uIcc a b).card = (b - a : ℤ).natAbs + 1 := by
  refine' (card_Icc _ _).trans (Int.ofNat.inj _)
  change ((↑) : ℕ → ℤ) _ = _
  rw [sup_eq_max, inf_eq_min, Int.ofNat_sub]
  · 

Proof state:
a b c : ℕ
⊢ ↑(max a b + 1) - ↑(min a b) = Int.ofNat (Int.natAbs (↑b - ↑a) + 1)

Next tactic:
rw [add_comm, Int.ofNat_add, add_sub_assoc]
@[simp]
theorem card_uIcc : (uIcc a b).card = (b - a : ℤ).natAbs + 1 := by
  refine' (card_Icc _ _).trans (Int.ofNat.inj _)
  change ((↑) : ℕ → ℤ) _ = _
  rw [sup_eq_max, inf_eq_min, Int.ofNat_sub]
  · rw [add_comm, Int.ofNat_add, add_sub_assoc]
    -- porting note: `norm_cast` puts a `Int.subSubNat` in the goal
    -- norm_cast
    

Proof state:
a b c : ℕ
⊢ ↑1 + (↑(max a b) - ↑(min a b)) = Int.ofNat (Int.natAbs (↑b - ↑a) + 1)

Next tactic:
change _ = ↑(Int.natAbs (b - a) + 1)
@[simp]
theorem card_uIcc : (uIcc a b).card = (b - a : ℤ).natAbs + 1 := by
  refine' (card_Icc _ _).trans (Int.ofNat.inj _)
  change ((↑) : ℕ → ℤ) _ = _
  rw [sup_eq_max, inf_eq_min, Int.ofNat_sub]
  · rw [add_comm, Int.ofNat_add, add_sub_assoc]
    -- porting note: `norm_cast` puts a `Int.subSubNat` in the goal
    -- norm_cast
    change _ = ↑(Int.natAbs (b - a) + 1)
    

Proof state:
a b c : ℕ
⊢ ↑1 + (↑(max a b) - ↑(min a b)) = ↑(Int.natAbs (↑b - ↑a) + 1)

Next tactic:
push_cast
@[simp]
theorem card_uIcc : (uIcc a b).card = (b - a : ℤ).natAbs + 1 := by
  refine' (card_Icc _ _).trans (Int.ofNat.inj _)
  change ((↑) : ℕ → ℤ) _ = _
  rw [sup_eq_max, inf_eq_min, Int.ofNat_sub]
  · rw [add_comm, Int.ofNat_add, add_sub_assoc]
    -- porting note: `norm_cast` puts a `Int.subSubNat` in the goal
    -- norm_cast
    change _ = ↑(Int.natAbs (b - a) + 1)
    push_cast
    

Proof state:
a b c : ℕ
⊢ 1 + (max ↑a ↑b - min ↑a ↑b) = |↑b - ↑a| + 1

Next tactic:
rw [max_sub_min_eq_abs, add_comm]
@[simp]
theorem card_uIcc : (uIcc a b).card = (b - a : ℤ).natAbs + 1 := by
  refine' (card_Icc _ _).trans (Int.ofNat.inj _)
  change ((↑) : ℕ → ℤ) _ = _
  rw [sup_eq_max, inf_eq_min, Int.ofNat_sub]
  · rw [add_comm, Int.ofNat_add, add_sub_assoc]
    -- porting note: `norm_cast` puts a `Int.subSubNat` in the goal
    -- norm_cast
    change _ = ↑(Int.natAbs (b - a) + 1)
    push_cast
    rw [max_sub_min_eq_abs, add_comm]
  · 

Proof state:
a b c : ℕ
⊢ min a b ≤ max a b + 1

Next tactic:
exact min_le_max.trans le_self_add
@[simp]
theorem card_Iic : (Iic b).card = b + 1 := by 

Proof state:
a b c : ℕ
⊢ card (Iic b) = b + 1

Next tactic:
rw [Iic_eq_Icc, card_Icc, bot_eq_zero, tsub_zero]
@[simp]
theorem card_Iio : (Iio b).card = b := by 

Proof state:
a b c : ℕ
⊢ card (Iio b) = b

Next tactic:
rw [Iio_eq_Ico, card_Ico, bot_eq_zero, tsub_zero]
theorem card_fintypeIcc : Fintype.card (Set.Icc a b) = b + 1 - a := by
  

Proof state:
a b c : ℕ
⊢ Fintype.card ↑(Set.Icc a b) = b + 1 - a

Next tactic:
rw [Fintype.card_ofFinset, card_Icc]
theorem card_fintypeIco : Fintype.card (Set.Ico a b) = b - a := by
  

Proof state:
a b c : ℕ
⊢ Fintype.card ↑(Set.Ico a b) = b - a

Next tactic:
rw [Fintype.card_ofFinset, card_Ico]
theorem card_fintypeIoc : Fintype.card (Set.Ioc a b) = b - a := by
  

Proof state:
a b c : ℕ
⊢ Fintype.card ↑(Set.Ioc a b) = b - a

Next tactic:
rw [Fintype.card_ofFinset, card_Ioc]
theorem card_fintypeIoo : Fintype.card (Set.Ioo a b) = b - a - 1 := by
  

Proof state:
a b c : ℕ
⊢ Fintype.card ↑(Set.Ioo a b) = b - a - 1

Next tactic:
rw [Fintype.card_ofFinset, card_Ioo]
theorem card_fintypeIic : Fintype.card (Set.Iic b) = b + 1 := by
  

Proof state:
a b c : ℕ
⊢ Fintype.card ↑(Set.Iic b) = b + 1

Next tactic:
rw [Fintype.card_ofFinset, card_Iic]
theorem card_fintypeIio : Fintype.card (Set.Iio b) = b := by 

Proof state:
a b c : ℕ
⊢ Fintype.card ↑(Set.Iio b) = b

Next tactic:
rw [Fintype.card_ofFinset, card_Iio]
theorem Icc_succ_left : Icc a.succ b = Ioc a b := by
  

Proof state:
a b c : ℕ
⊢ Icc (succ a) b = Ioc a b

Next tactic:
ext x
theorem Icc_succ_left : Icc a.succ b = Ioc a b := by
  ext x
  

Proof state:
case a
a b c x : ℕ
⊢ x ∈ Icc (succ a) b ↔ x ∈ Ioc a b

Next tactic:
rw [mem_Icc, mem_Ioc, succ_le_iff]
theorem Ico_succ_right : Ico a b.succ = Icc a b := by
  

Proof state:
a b c : ℕ
⊢ Ico a (succ b) = Icc a b

Next tactic:
ext x
theorem Ico_succ_right : Ico a b.succ = Icc a b := by
  ext x
  

Proof state:
case a
a b c x : ℕ
⊢ x ∈ Ico a (succ b) ↔ x ∈ Icc a b

Next tactic:
rw [mem_Ico, mem_Icc, lt_succ_iff]
theorem Ico_succ_left : Ico a.succ b = Ioo a b := by
  

Proof state:
a b c : ℕ
⊢ Ico (succ a) b = Ioo a b

Next tactic:
ext x
theorem Ico_succ_left : Ico a.succ b = Ioo a b := by
  ext x
  

Proof state:
case a
a b c x : ℕ
⊢ x ∈ Ico (succ a) b ↔ x ∈ Ioo a b

Next tactic:
rw [mem_Ico, mem_Ioo, succ_le_iff]
theorem Icc_pred_right {b : ℕ} (h : 0 < b) : Icc a (b - 1) = Ico a b := by
  

Proof state:
a b✝ c b : ℕ
h : 0 < b
⊢ Icc a (b - 1) = Ico a b

Next tactic:
ext x
theorem Icc_pred_right {b : ℕ} (h : 0 < b) : Icc a (b - 1) = Ico a b := by
  ext x
  

Proof state:
case a
a b✝ c b : ℕ
h : 0 < b
x : ℕ
⊢ x ∈ Icc a (b - 1) ↔ x ∈ Ico a b

Next tactic:
rw [mem_Icc, mem_Ico, lt_iff_le_pred h]
theorem Ico_succ_succ : Ico a.succ b.succ = Ioc a b := by
  

Proof state:
a b c : ℕ
⊢ Ico (succ a) (succ b) = Ioc a b

Next tactic:
ext x
theorem Ico_succ_succ : Ico a.succ b.succ = Ioc a b := by
  ext x
  

Proof state:
case a
a b c x : ℕ
⊢ x ∈ Ico (succ a) (succ b) ↔ x ∈ Ioc a b

Next tactic:
rw [mem_Ico, mem_Ioc, succ_le_iff, lt_succ_iff]
@[simp]
theorem Ico_succ_singleton : Ico a (a + 1) = {a} := by 

Proof state:
a b c : ℕ
⊢ Ico a (a + 1) = {a}

Next tactic:
rw [Ico_succ_right, Icc_self]
@[simp]
theorem Ico_pred_singleton {a : ℕ} (h : 0 < a) : Ico (a - 1) a = {a - 1} := by
  

Proof state:
a✝ b c a : ℕ
h : 0 < a
⊢ Ico (a - 1) a = {a - 1}

Next tactic:
rw [← Icc_pred_right _ h, Icc_self]
@[simp]
theorem Ioc_succ_singleton : Ioc b (b + 1) = {b + 1} := by 

Proof state:
a b c : ℕ
⊢ Ioc b (b + 1) = {b + 1}

Next tactic:
rw [← Nat.Icc_succ_left, Icc_self]
theorem Ico_succ_right_eq_insert_Ico (h : a ≤ b) : Ico a (b + 1) = insert b (Ico a b) := by
  

Proof state:
a b c : ℕ
h : a ≤ b
⊢ Ico a (b + 1) = insert b (Ico a b)

Next tactic:
rw [Ico_succ_right, ← Ico_insert_right h]
theorem Ico_insert_succ_left (h : a < b) : insert a (Ico a.succ b) = Ico a b := by
  

Proof state:
a b c : ℕ
h : a < b
⊢ insert a (Ico (succ a) b) = Ico a b

Next tactic:
rw [Ico_succ_left, ← Ioo_insert_left h]
theorem image_sub_const_Ico (h : c ≤ a) :
    ((Ico a b).image fun x => x - c) = Ico (a - c) (b - c) := by
  

Proof state:
a b c : ℕ
h : c ≤ a
⊢ image (fun x => x - c) (Ico a b) = Ico (a - c) (b - c)

Next tactic:
ext x
theorem image_sub_const_Ico (h : c ≤ a) :
    ((Ico a b).image fun x => x - c) = Ico (a - c) (b - c) := by
  ext x
  

Proof state:
case a
a b c : ℕ
h : c ≤ a
x : ℕ
⊢ x ∈ image (fun x => x - c) (Ico a b) ↔ x ∈ Ico (a - c) (b - c)

Next tactic:
rw [mem_image]
theorem image_sub_const_Ico (h : c ≤ a) :
    ((Ico a b).image fun x => x - c) = Ico (a - c) (b - c) := by
  ext x
  rw [mem_image]
  

Proof state:
case a
a b c : ℕ
h : c ≤ a
x : ℕ
⊢ (∃ a_1 ∈ Ico a b, a_1 - c = x) ↔ x ∈ Ico (a - c) (b - c)

Next tactic:
constructor
theorem image_sub_const_Ico (h : c ≤ a) :
    ((Ico a b).image fun x => x - c) = Ico (a - c) (b - c) := by
  ext x
  rw [mem_image]
  constructor
  · 

Proof state:
case a.mp
a b c : ℕ
h : c ≤ a
x : ℕ
⊢ (∃ a_1 ∈ Ico a b, a_1 - c = x) → x ∈ Ico (a - c) (b - c)

Next tactic:
rintro ⟨x, hx, rfl⟩
theorem image_sub_const_Ico (h : c ≤ a) :
    ((Ico a b).image fun x => x - c) = Ico (a - c) (b - c) := by
  ext x
  rw [mem_image]
  constructor
  · rintro ⟨x, hx, rfl⟩
    

Proof state:
case a.mp.intro.intro
a b c : ℕ
h : c ≤ a
x : ℕ
hx : x ∈ Ico a b
⊢ x - c ∈ Ico (a - c) (b - c)

Next tactic:
rw [mem_Ico] at hx ⊢
theorem image_sub_const_Ico (h : c ≤ a) :
    ((Ico a b).image fun x => x - c) = Ico (a - c) (b - c) := by
  ext x
  rw [mem_image]
  constructor
  · rintro ⟨x, hx, rfl⟩
    rw [mem_Ico] at hx ⊢
    

Proof state:
case a.mp.intro.intro
a b c : ℕ
h : c ≤ a
x : ℕ
hx : a ≤ x ∧ x < b
⊢ a - c ≤ x - c ∧ x - c < b - c

Next tactic:
exact ⟨tsub_le_tsub_right hx.1 _, tsub_lt_tsub_right_of_le (h.trans hx.1) hx.2⟩
theorem image_sub_const_Ico (h : c ≤ a) :
    ((Ico a b).image fun x => x - c) = Ico (a - c) (b - c) := by
  ext x
  rw [mem_image]
  constructor
  · rintro ⟨x, hx, rfl⟩
    rw [mem_Ico] at hx ⊢
    exact ⟨tsub_le_tsub_right hx.1 _, tsub_lt_tsub_right_of_le (h.trans hx.1) hx.2⟩
  · 

Proof state:
case a.mpr
a b c : ℕ
h : c ≤ a
x : ℕ
⊢ x ∈ Ico (a - c) (b - c) → ∃ a_2 ∈ Ico a b, a_2 - c = x

Next tactic:
rintro h
theorem image_sub_const_Ico (h : c ≤ a) :
    ((Ico a b).image fun x => x - c) = Ico (a - c) (b - c) := by
  ext x
  rw [mem_image]
  constructor
  · rintro ⟨x, hx, rfl⟩
    rw [mem_Ico] at hx ⊢
    exact ⟨tsub_le_tsub_right hx.1 _, tsub_lt_tsub_right_of_le (h.trans hx.1) hx.2⟩
  · rintro h
    

Proof state:
case a.mpr
a b c : ℕ
h✝ : c ≤ a
x : ℕ
h : x ∈ Ico (a - c) (b - c)
⊢ ∃ a_1 ∈ Ico a b, a_1 - c = x

Next tactic:
refine' ⟨x + c, _, add_tsub_cancel_right _ _⟩
theorem image_sub_const_Ico (h : c ≤ a) :
    ((Ico a b).image fun x => x - c) = Ico (a - c) (b - c) := by
  ext x
  rw [mem_image]
  constructor
  · rintro ⟨x, hx, rfl⟩
    rw [mem_Ico] at hx ⊢
    exact ⟨tsub_le_tsub_right hx.1 _, tsub_lt_tsub_right_of_le (h.trans hx.1) hx.2⟩
  · rintro h
    refine' ⟨x + c, _, add_tsub_cancel_right _ _⟩
    

Proof state:
case a.mpr
a b c : ℕ
h✝ : c ≤ a
x : ℕ
h : x ∈ Ico (a - c) (b - c)
⊢ x + c ∈ Ico a b

Next tactic:
rw [mem_Ico] at h ⊢
theorem image_sub_const_Ico (h : c ≤ a) :
    ((Ico a b).image fun x => x - c) = Ico (a - c) (b - c) := by
  ext x
  rw [mem_image]
  constructor
  · rintro ⟨x, hx, rfl⟩
    rw [mem_Ico] at hx ⊢
    exact ⟨tsub_le_tsub_right hx.1 _, tsub_lt_tsub_right_of_le (h.trans hx.1) hx.2⟩
  · rintro h
    refine' ⟨x + c, _, add_tsub_cancel_right _ _⟩
    rw [mem_Ico] at h ⊢
    

Proof state:
case a.mpr
a b c : ℕ
h✝ : c ≤ a
x : ℕ
h : a - c ≤ x ∧ x < b - c
⊢ a ≤ x + c ∧ x + c < b

Next tactic:
exact ⟨tsub_le_iff_right.1 h.1, lt_tsub_iff_right.1 h.2⟩
theorem Ico_image_const_sub_eq_Ico (hac : a ≤ c) :
    ((Ico a b).image fun x => c - x) = Ico (c + 1 - b) (c + 1 - a) := by
  

Proof state:
a b c : ℕ
hac : a ≤ c
⊢ image (fun x => c - x) (Ico a b) = Ico (c + 1 - b) (c + 1 - a)

Next tactic:
ext x
theorem Ico_image_const_sub_eq_Ico (hac : a ≤ c) :
    ((Ico a b).image fun x => c - x) = Ico (c + 1 - b) (c + 1 - a) := by
  ext x
  

Proof state:
case a
a b c : ℕ
hac : a ≤ c
x : ℕ
⊢ x ∈ image (fun x => c - x) (Ico a b) ↔ x ∈ Ico (c + 1 - b) (c + 1 - a)

Next tactic:
rw [mem_image, mem_Ico]
theorem Ico_image_const_sub_eq_Ico (hac : a ≤ c) :
    ((Ico a b).image fun x => c - x) = Ico (c + 1 - b) (c + 1 - a) := by
  ext x
  rw [mem_image, mem_Ico]
  

Proof state:
case a
a b c : ℕ
hac : a ≤ c
x : ℕ
⊢ (∃ a_1 ∈ Ico a b, c - a_1 = x) ↔ c + 1 - b ≤ x ∧ x < c + 1 - a

Next tactic:
constructor
theorem Ico_image_const_sub_eq_Ico (hac : a ≤ c) :
    ((Ico a b).image fun x => c - x) = Ico (c + 1 - b) (c + 1 - a) := by
  ext x
  rw [mem_image, mem_Ico]
  constructor
  · 

Proof state:
case a.mp
a b c : ℕ
hac : a ≤ c
x : ℕ
⊢ (∃ a_1 ∈ Ico a b, c - a_1 = x) → c + 1 - b ≤ x ∧ x < c + 1 - a

Next tactic:
rintro ⟨x, hx, rfl⟩
theorem Ico_image_const_sub_eq_Ico (hac : a ≤ c) :
    ((Ico a b).image fun x => c - x) = Ico (c + 1 - b) (c + 1 - a) := by
  ext x
  rw [mem_image, mem_Ico]
  constructor
  · rintro ⟨x, hx, rfl⟩
    

Proof state:
case a.mp.intro.intro
a b c : ℕ
hac : a ≤ c
x : ℕ
hx : x ∈ Ico a b
⊢ c + 1 - b ≤ c - x ∧ c - x < c + 1 - a

Next tactic:
rw [mem_Ico] at hx
theorem Ico_image_const_sub_eq_Ico (hac : a ≤ c) :
    ((Ico a b).image fun x => c - x) = Ico (c + 1 - b) (c + 1 - a) := by
  ext x
  rw [mem_image, mem_Ico]
  constructor
  · rintro ⟨x, hx, rfl⟩
    rw [mem_Ico] at hx
    

Proof state:
case a.mp.intro.intro
a b c : ℕ
hac : a ≤ c
x : ℕ
hx : a ≤ x ∧ x < b
⊢ c + 1 - b ≤ c - x ∧ c - x < c + 1 - a

Next tactic:
refine'
      ⟨_,
        ((tsub_le_tsub_iff_left hac).2 hx.1).trans_lt
          ((tsub_lt_tsub_iff_right hac).2 (Nat.lt_succ_self _))⟩
theorem Ico_image_const_sub_eq_Ico (hac : a ≤ c) :
    ((Ico a b).image fun x => c - x) = Ico (c + 1 - b) (c + 1 - a) := by
  ext x
  rw [mem_image, mem_Ico]
  constructor
  · rintro ⟨x, hx, rfl⟩
    rw [mem_Ico] at hx
    refine'
      ⟨_,
        ((tsub_le_tsub_iff_left hac).2 hx.1).trans_lt
          ((tsub_lt_tsub_iff_right hac).2 (Nat.lt_succ_self _))⟩
    

Proof state:
case a.mp.intro.intro
a b c : ℕ
hac : a ≤ c
x : ℕ
hx : a ≤ x ∧ x < b
⊢ c + 1 - b ≤ c - x

Next tactic:
cases lt_or_le c b with
    | inl h =>
      rw [tsub_eq_zero_iff_le.mpr (succ_le_of_lt h)]
      exact zero_le _
    | inr h =>
      rw [← succ_sub_succ c]
      exact (tsub_le_tsub_iff_left (succ_le_succ <| hx.2.le.trans h)).2 hx.2
theorem Ico_image_const_sub_eq_Ico (hac : a ≤ c) :
    ((Ico a b).image fun x => c - x) = Ico (c + 1 - b) (c + 1 - a) := by
  ext x
  rw [mem_image, mem_Ico]
  constructor
  · rintro ⟨x, hx, rfl⟩
    rw [mem_Ico] at hx
    refine'
      ⟨_,
        ((tsub_le_tsub_iff_left hac).2 hx.1).trans_lt
          ((tsub_lt_tsub_iff_right hac).2 (Nat.lt_succ_self _))⟩
    

Proof state:
case a.mp.intro.intro
a b c : ℕ
hac : a ≤ c
x : ℕ
hx : a ≤ x ∧ x < b
x✝ : c < b ∨ b ≤ c
⊢ c + 1 - b ≤ c - x

Next tactic:
cases lt_or_le c b with
    | inl h =>
      rw [tsub_eq_zero_iff_le.mpr (succ_le_of_lt h)]
      exact zero_le _
    | inr h =>
      rw [← succ_sub_succ c]
      exact (tsub_le_tsub_iff_left (succ_le_succ <| hx.2.le.trans h)).2 hx.2
theorem Ico_image_const_sub_eq_Ico (hac : a ≤ c) :
    ((Ico a b).image fun x => c - x) = Ico (c + 1 - b) (c + 1 - a) := by
  ext x
  rw [mem_image, mem_Ico]
  constructor
  · rintro ⟨x, hx, rfl⟩
    rw [mem_Ico] at hx
    refine'
      ⟨_,
        ((tsub_le_tsub_iff_left hac).2 hx.1).trans_lt
          ((tsub_lt_tsub_iff_right hac).2 (Nat.lt_succ_self _))⟩
    cases lt_or_le c b with
    

Proof state:
case a.mp.intro.intro.inl
a b c : ℕ
hac : a ≤ c
x : ℕ
hx : a ≤ x ∧ x < b
h : c < b
⊢ c + 1 - b ≤ c - x

Next tactic:
| inl h =>
      rw [tsub_eq_zero_iff_le.mpr (succ_le_of_lt h)]
      exact zero_le _
theorem Ico_image_const_sub_eq_Ico (hac : a ≤ c) :
    ((Ico a b).image fun x => c - x) = Ico (c + 1 - b) (c + 1 - a) := by
  ext x
  rw [mem_image, mem_Ico]
  constructor
  · rintro ⟨x, hx, rfl⟩
    rw [mem_Ico] at hx
    refine'
      ⟨_,
        ((tsub_le_tsub_iff_left hac).2 hx.1).trans_lt
          ((tsub_lt_tsub_iff_right hac).2 (Nat.lt_succ_self _))⟩
    cases lt_or_le c b with
    | inl h =>
      

Proof state:
case a.mp.intro.intro.inl
a b c : ℕ
hac : a ≤ c
x : ℕ
hx : a ≤ x ∧ x < b
h : c < b
⊢ c + 1 - b ≤ c - x

Next tactic:
rw [tsub_eq_zero_iff_le.mpr (succ_le_of_lt h)]
theorem Ico_image_const_sub_eq_Ico (hac : a ≤ c) :
    ((Ico a b).image fun x => c - x) = Ico (c + 1 - b) (c + 1 - a) := by
  ext x
  rw [mem_image, mem_Ico]
  constructor
  · rintro ⟨x, hx, rfl⟩
    rw [mem_Ico] at hx
    refine'
      ⟨_,
        ((tsub_le_tsub_iff_left hac).2 hx.1).trans_lt
          ((tsub_lt_tsub_iff_right hac).2 (Nat.lt_succ_self _))⟩
    cases lt_or_le c b with
    | inl h =>
      rw [tsub_eq_zero_iff_le.mpr (succ_le_of_lt h)]
      

Proof state:
case a.mp.intro.intro.inl
a b c : ℕ
hac : a ≤ c
x : ℕ
hx : a ≤ x ∧ x < b
h : c < b
⊢ 0 ≤ c - x

Next tactic:
exact zero_le _
theorem Ico_image_const_sub_eq_Ico (hac : a ≤ c) :
    ((Ico a b).image fun x => c - x) = Ico (c + 1 - b) (c + 1 - a) := by
  ext x
  rw [mem_image, mem_Ico]
  constructor
  · rintro ⟨x, hx, rfl⟩
    rw [mem_Ico] at hx
    refine'
      ⟨_,
        ((tsub_le_tsub_iff_left hac).2 hx.1).trans_lt
          ((tsub_lt_tsub_iff_right hac).2 (Nat.lt_succ_self _))⟩
    cases lt_or_le c b with
    | inl h =>
      rw [tsub_eq_zero_iff_le.mpr (succ_le_of_lt h)]
      exact zero_le _
    

Proof state:
case a.mp.intro.intro.inr
a b c : ℕ
hac : a ≤ c
x : ℕ
hx : a ≤ x ∧ x < b
h : b ≤ c
⊢ c + 1 - b ≤ c - x

Next tactic:
| inr h =>
      rw [← succ_sub_succ c]
      exact (tsub_le_tsub_iff_left (succ_le_succ <| hx.2.le.trans h)).2 hx.2
theorem Ico_image_const_sub_eq_Ico (hac : a ≤ c) :
    ((Ico a b).image fun x => c - x) = Ico (c + 1 - b) (c + 1 - a) := by
  ext x
  rw [mem_image, mem_Ico]
  constructor
  · rintro ⟨x, hx, rfl⟩
    rw [mem_Ico] at hx
    refine'
      ⟨_,
        ((tsub_le_tsub_iff_left hac).2 hx.1).trans_lt
          ((tsub_lt_tsub_iff_right hac).2 (Nat.lt_succ_self _))⟩
    cases lt_or_le c b with
    | inl h =>
      rw [tsub_eq_zero_iff_le.mpr (succ_le_of_lt h)]
      exact zero_le _
    | inr h =>
      

Proof state:
case a.mp.intro.intro.inr
a b c : ℕ
hac : a ≤ c
x : ℕ
hx : a ≤ x ∧ x < b
h : b ≤ c
⊢ c + 1 - b ≤ c - x

Next tactic:
rw [← succ_sub_succ c]
theorem Ico_image_const_sub_eq_Ico (hac : a ≤ c) :
    ((Ico a b).image fun x => c - x) = Ico (c + 1 - b) (c + 1 - a) := by
  ext x
  rw [mem_image, mem_Ico]
  constructor
  · rintro ⟨x, hx, rfl⟩
    rw [mem_Ico] at hx
    refine'
      ⟨_,
        ((tsub_le_tsub_iff_left hac).2 hx.1).trans_lt
          ((tsub_lt_tsub_iff_right hac).2 (Nat.lt_succ_self _))⟩
    cases lt_or_le c b with
    | inl h =>
      rw [tsub_eq_zero_iff_le.mpr (succ_le_of_lt h)]
      exact zero_le _
    | inr h =>
      rw [← succ_sub_succ c]
      

Proof state:
case a.mp.intro.intro.inr
a b c : ℕ
hac : a ≤ c
x : ℕ
hx : a ≤ x ∧ x < b
h : b ≤ c
⊢ c + 1 - b ≤ succ c - succ x

Next tactic:
exact (tsub_le_tsub_iff_left (succ_le_succ <| hx.2.le.trans h)).2 hx.2