Theorem: Nat.Ico_image_const_sub_eq_Ico
File: Mathlib/Data/Nat/Interval.lean

tactic: ext x
state_before: a b c : ℕ
hac : a ≤ c
⊢ image (fun x => c - x) (Ico a b) = Ico (c + 1 - b) (c + 1 - a)

tactic: rw [mem_image, mem_Ico]
state_before: 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)

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

tactic: rintro ⟨x, hx, rfl⟩
state_before: case a.mp
a b c : ℕ
hac : a ≤ c
x : ℕ
⊢ (∃ a_1, a_1 ∈ Ico a b ∧ c - a_1 = x) → c + 1 - b ≤ x ∧ x < c + 1 - a

tactic: rw [mem_Ico] at hx
state_before: 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

tactic: refine'
  ⟨_,
    ((tsub_le_tsub_iff_left hac).2 hx.1).trans_lt
      ((tsub_lt_tsub_iff_right hac).2 (Nat.lt_succ_self _))⟩
state_before: 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

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
state_before: case a.mp.intro.intro
a b c : ℕ
hac : a ≤ c
x : ℕ
hx : a ≤ x ∧ x < b
⊢ c + 1 - b ≤ c - x

tactic: rw [tsub_eq_zero_iff_le.mpr (succ_le_of_lt h)]
state_before: 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

tactic: exact zero_le _
state_before: case a.mp.intro.intro.inl
a b c : ℕ
hac : a ≤ c
x : ℕ
hx : a ≤ x ∧ x < b
h : c < b
⊢ 0 ≤ c - x

tactic: rw [← succ_sub_succ c]
state_before: 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

tactic: exact (tsub_le_tsub_iff_left (succ_le_succ <| hx.2.le.trans h)).2 hx.2
state_before: 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

tactic: rintro ⟨hb, ha⟩
state_before: case a.mpr
a b c : ℕ
hac : a ≤ c
x : ℕ
⊢ c + 1 - b ≤ x ∧ x < c + 1 - a → ∃ a_2, a_2 ∈ Ico a b ∧ c - a_2 = x

tactic: rw [lt_tsub_iff_left, lt_succ_iff] at ha
state_before: case a.mpr.intro
a b c : ℕ
hac : a ≤ c
x : ℕ
hb : c + 1 - b ≤ x
ha : x < c + 1 - a
⊢ ∃ a_1, a_1 ∈ Ico a b ∧ c - a_1 = x

tactic: have hx : x ≤ c := (Nat.le_add_left _ _).trans ha
state_before: case a.mpr.intro
a b c : ℕ
hac : a ≤ c
x : ℕ
hb : c + 1 - b ≤ x
ha✝ : x < c + 1 - a
ha : a + x ≤ c
⊢ ∃ a_1, a_1 ∈ Ico a b ∧ c - a_1 = x

tactic: refine' ⟨c - x, _, tsub_tsub_cancel_of_le hx⟩
state_before: case a.mpr.intro
a b c : ℕ
hac : a ≤ c
x : ℕ
hb : c + 1 - b ≤ x
ha✝ : x < c + 1 - a
ha : a + x ≤ c
hx : x ≤ c
⊢ ∃ a_1, a_1 ∈ Ico a b ∧ c - a_1 = x

tactic: rw [mem_Ico]
state_before: case a.mpr.intro
a b c : ℕ
hac : a ≤ c
x : ℕ
hb : c + 1 - b ≤ x
ha✝ : x < c + 1 - a
ha : a + x ≤ c
hx : x ≤ c
⊢ c - x ∈ Ico a b

tactic: exact
  ⟨le_tsub_of_add_le_right ha,
    (tsub_lt_iff_left hx).2 <| succ_le_iff.1 <| tsub_le_iff_right.1 hb⟩
state_before: case a.mpr.intro
a b c : ℕ
hac : a ≤ c
x : ℕ
hb : c + 1 - b ≤ x
ha✝ : x < c + 1 - a
ha : a + x ≤ c
hx : x ≤ c
⊢ a ≤ c - x ∧ c - x < b