l3lab/ntp-mathlib huggingface dataset:
theorem ceil_add_ceil_le (a b : α) : ⌈a⌉ + ⌈b⌉ ≤ ⌈a + b⌉ + 1 := by
  rw [← le_sub_iff_add_le, ceil_le, Int.cast_sub, Int.cast_add, Int.cast_one, le_sub_comm]
  refine' (ceil_lt_add_one _).le.trans _
  rw [le_sub_iff_add_le', ← add_assoc, add_le_add_iff_right]
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ a + b ≤ ↑⌈a + b⌉

Next tactic:
exact le_ceil _
@[simp]
theorem ceil_pos : 0 < ⌈a⌉ ↔ 0 < a := by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ 0 < ⌈a⌉ ↔ 0 < a

Next tactic:
rw [lt_ceil, cast_zero]
@[simp]
theorem ceil_zero : ⌈(0 : α)⌉ = 0 := by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ ⌈0⌉ = 0

Next tactic:
rw [← cast_zero, ceil_intCast]
@[simp]
theorem ceil_one : ⌈(1 : α)⌉ = 1 := by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ ⌈1⌉ = 1

Next tactic:
rw [← cast_one, ceil_intCast]
theorem ceil_eq_iff : ⌈a⌉ = z ↔ ↑z - 1 < a ∧ a ≤ z := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ ⌈a⌉ = z ↔ ↑z - 1 < a ∧ a ≤ ↑z

Next tactic:
rw [← ceil_le, ← Int.cast_one, ← Int.cast_sub, ← lt_ceil, Int.sub_one_lt_iff, le_antisymm_iff,
    and_comm]
@[simp]
theorem ceil_eq_zero_iff : ⌈a⌉ = 0 ↔ a ∈ Ioc (-1 : α) 0 := by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ ⌈a⌉ = 0 ↔ a ∈ Ioc (-1) 0

Next tactic:
simp [ceil_eq_iff]
theorem fract_eq_zero_or_add_one_sub_ceil (a : α) : fract a = 0 ∨ fract a = a + 1 - (⌈a⌉ : α) := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
⊢ fract a = 0 ∨ fract a = a + 1 - ↑⌈a⌉

Next tactic:
rcases eq_or_ne (fract a) 0 with ha | ha
theorem fract_eq_zero_or_add_one_sub_ceil (a : α) : fract a = 0 ∨ fract a = a + 1 - (⌈a⌉ : α) := by
  rcases eq_or_ne (fract a) 0 with ha | ha
  · 

Proof state:
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
ha : fract a = 0
⊢ fract a = 0 ∨ fract a = a + 1 - ↑⌈a⌉

Next tactic:
exact Or.inl ha
theorem fract_eq_zero_or_add_one_sub_ceil (a : α) : fract a = 0 ∨ fract a = a + 1 - (⌈a⌉ : α) := by
  rcases eq_or_ne (fract a) 0 with ha | ha
  · exact Or.inl ha
  

Proof state:
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
ha : fract a ≠ 0
⊢ fract a = 0 ∨ fract a = a + 1 - ↑⌈a⌉

Next tactic:
right
theorem fract_eq_zero_or_add_one_sub_ceil (a : α) : fract a = 0 ∨ fract a = a + 1 - (⌈a⌉ : α) := by
  rcases eq_or_ne (fract a) 0 with ha | ha
  · exact Or.inl ha
  right
  

Proof state:
case inr.h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
ha : fract a ≠ 0
⊢ fract a = a + 1 - ↑⌈a⌉

Next tactic:
suffices (⌈a⌉ : α) = ⌊a⌋ + 1 by
    rw [this, ← self_sub_fract]
    abel
theorem fract_eq_zero_or_add_one_sub_ceil (a : α) : fract a = 0 ∨ fract a = a + 1 - (⌈a⌉ : α) := by
  rcases eq_or_ne (fract a) 0 with ha | ha
  · exact Or.inl ha
  right
  suffices (⌈a⌉ : α) = ⌊a⌋ + 1 by
    

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
ha : fract a ≠ 0
this : ↑⌈a⌉ = ↑⌊a⌋ + 1
⊢ fract a = a + 1 - ↑⌈a⌉

Next tactic:
rw [this, ← self_sub_fract]
theorem fract_eq_zero_or_add_one_sub_ceil (a : α) : fract a = 0 ∨ fract a = a + 1 - (⌈a⌉ : α) := by
  rcases eq_or_ne (fract a) 0 with ha | ha
  · exact Or.inl ha
  right
  suffices (⌈a⌉ : α) = ⌊a⌋ + 1 by
    rw [this, ← self_sub_fract]
    

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
ha : fract a ≠ 0
this : ↑⌈a⌉ = ↑⌊a⌋ + 1
⊢ fract a = a + 1 - (a - fract a + 1)

Next tactic:
abel
theorem fract_eq_zero_or_add_one_sub_ceil (a : α) : fract a = 0 ∨ fract a = a + 1 - (⌈a⌉ : α) := by
  rcases eq_or_ne (fract a) 0 with ha | ha
  · exact Or.inl ha
  right
  suffices (⌈a⌉ : α) = ⌊a⌋ + 1 by
    rw [this, ← self_sub_fract]
    abel
  

Proof state:
case inr.h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
ha : fract a ≠ 0
⊢ ↑⌈a⌉ = ↑⌊a⌋ + 1

Next tactic:
norm_cast
theorem fract_eq_zero_or_add_one_sub_ceil (a : α) : fract a = 0 ∨ fract a = a + 1 - (⌈a⌉ : α) := by
  rcases eq_or_ne (fract a) 0 with ha | ha
  · exact Or.inl ha
  right
  suffices (⌈a⌉ : α) = ⌊a⌋ + 1 by
    rw [this, ← self_sub_fract]
    abel
  norm_cast
  

Proof state:
case inr.h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
ha : fract a ≠ 0
⊢ ⌈a⌉ = ⌊a⌋ + 1

Next tactic:
rw [ceil_eq_iff]
theorem fract_eq_zero_or_add_one_sub_ceil (a : α) : fract a = 0 ∨ fract a = a + 1 - (⌈a⌉ : α) := by
  rcases eq_or_ne (fract a) 0 with ha | ha
  · exact Or.inl ha
  right
  suffices (⌈a⌉ : α) = ⌊a⌋ + 1 by
    rw [this, ← self_sub_fract]
    abel
  norm_cast
  rw [ceil_eq_iff]
  

Proof state:
case inr.h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
ha : fract a ≠ 0
⊢ ↑(⌊a⌋ + 1) - 1 < a ∧ a ≤ ↑(⌊a⌋ + 1)

Next tactic:
refine' ⟨_, _root_.le_of_lt <| by simp⟩
theorem fract_eq_zero_or_add_one_sub_ceil (a : α) : fract a = 0 ∨ fract a = a + 1 - (⌈a⌉ : α) := by
  rcases eq_or_ne (fract a) 0 with ha | ha
  · exact Or.inl ha
  right
  suffices (⌈a⌉ : α) = ⌊a⌋ + 1 by
    rw [this, ← self_sub_fract]
    abel
  norm_cast
  rw [ceil_eq_iff]
  refine' ⟨_, _root_.le_of_lt <| by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
ha : fract a ≠ 0
⊢ a < ↑(⌊a⌋ + 1)

Next tactic:
simp
theorem fract_eq_zero_or_add_one_sub_ceil (a : α) : fract a = 0 ∨ fract a = a + 1 - (⌈a⌉ : α) := by
  rcases eq_or_ne (fract a) 0 with ha | ha
  · exact Or.inl ha
  right
  suffices (⌈a⌉ : α) = ⌊a⌋ + 1 by
    rw [this, ← self_sub_fract]
    abel
  norm_cast
  rw [ceil_eq_iff]
  refine' ⟨_, _root_.le_of_lt <| by simp⟩
  

Proof state:
case inr.h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
ha : fract a ≠ 0
⊢ ↑(⌊a⌋ + 1) - 1 < a

Next tactic:
rw [cast_add, cast_one, add_tsub_cancel_right, ← self_sub_fract a, sub_lt_self_iff]
theorem fract_eq_zero_or_add_one_sub_ceil (a : α) : fract a = 0 ∨ fract a = a + 1 - (⌈a⌉ : α) := by
  rcases eq_or_ne (fract a) 0 with ha | ha
  · exact Or.inl ha
  right
  suffices (⌈a⌉ : α) = ⌊a⌋ + 1 by
    rw [this, ← self_sub_fract]
    abel
  norm_cast
  rw [ceil_eq_iff]
  refine' ⟨_, _root_.le_of_lt <| by simp⟩
  rw [cast_add, cast_one, add_tsub_cancel_right, ← self_sub_fract a, sub_lt_self_iff]
  

Proof state:
case inr.h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
ha : fract a ≠ 0
⊢ 0 < fract a

Next tactic:
exact ha.symm.lt_of_le (fract_nonneg a)
theorem ceil_eq_add_one_sub_fract (ha : fract a ≠ 0) : (⌈a⌉ : α) = a + 1 - fract a := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
ha : fract a ≠ 0
⊢ ↑⌈a⌉ = a + 1 - fract a

Next tactic:
rw [(or_iff_right ha).mp (fract_eq_zero_or_add_one_sub_ceil a)]
theorem ceil_eq_add_one_sub_fract (ha : fract a ≠ 0) : (⌈a⌉ : α) = a + 1 - fract a := by
  rw [(or_iff_right ha).mp (fract_eq_zero_or_add_one_sub_ceil a)]
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
ha : fract a ≠ 0
⊢ ↑⌈a⌉ = a + 1 - (a + 1 - ↑⌈a⌉)

Next tactic:
abel
theorem ceil_sub_self_eq (ha : fract a ≠ 0) : (⌈a⌉ : α) - a = 1 - fract a := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
ha : fract a ≠ 0
⊢ ↑⌈a⌉ - a = 1 - fract a

Next tactic:
rw [(or_iff_right ha).mp (fract_eq_zero_or_add_one_sub_ceil a)]
theorem ceil_sub_self_eq (ha : fract a ≠ 0) : (⌈a⌉ : α) - a = 1 - fract a := by
  rw [(or_iff_right ha).mp (fract_eq_zero_or_add_one_sub_ceil a)]
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
ha : fract a ≠ 0
⊢ ↑⌈a⌉ - a = 1 - (a + 1 - ↑⌈a⌉)

Next tactic:
abel
@[simp]
theorem preimage_Ioo {a b : α} : (Int.cast : ℤ → α) ⁻¹' Set.Ioo a b = Set.Ioo ⌊a⌋ ⌈b⌉ := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ Int.cast ⁻¹' Ioo a b = Ioo ⌊a⌋ ⌈b⌉

Next tactic:
ext
@[simp]
theorem preimage_Ioo {a b : α} : (Int.cast : ℤ → α) ⁻¹' Set.Ioo a b = Set.Ioo ⌊a⌋ ⌈b⌉ := by
  ext
  

Proof state:
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
x✝ : ℤ
⊢ x✝ ∈ Int.cast ⁻¹' Ioo a b ↔ x✝ ∈ Ioo ⌊a⌋ ⌈b⌉

Next tactic:
simp [floor_lt, lt_ceil]
@[simp]
theorem preimage_Ico {a b : α} : (Int.cast : ℤ → α) ⁻¹' Set.Ico a b = Set.Ico ⌈a⌉ ⌈b⌉ := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ Int.cast ⁻¹' Ico a b = Ico ⌈a⌉ ⌈b⌉

Next tactic:
ext
@[simp]
theorem preimage_Ico {a b : α} : (Int.cast : ℤ → α) ⁻¹' Set.Ico a b = Set.Ico ⌈a⌉ ⌈b⌉ := by
  ext
  

Proof state:
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
x✝ : ℤ
⊢ x✝ ∈ Int.cast ⁻¹' Ico a b ↔ x✝ ∈ Ico ⌈a⌉ ⌈b⌉

Next tactic:
simp [ceil_le, lt_ceil]
@[simp]
theorem preimage_Ioc {a b : α} : (Int.cast : ℤ → α) ⁻¹' Set.Ioc a b = Set.Ioc ⌊a⌋ ⌊b⌋ := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ Int.cast ⁻¹' Ioc a b = Ioc ⌊a⌋ ⌊b⌋

Next tactic:
ext
@[simp]
theorem preimage_Ioc {a b : α} : (Int.cast : ℤ → α) ⁻¹' Set.Ioc a b = Set.Ioc ⌊a⌋ ⌊b⌋ := by
  ext
  

Proof state:
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
x✝ : ℤ
⊢ x✝ ∈ Int.cast ⁻¹' Ioc a b ↔ x✝ ∈ Ioc ⌊a⌋ ⌊b⌋

Next tactic:
simp [floor_lt, le_floor]
@[simp]
theorem preimage_Icc {a b : α} : (Int.cast : ℤ → α) ⁻¹' Set.Icc a b = Set.Icc ⌈a⌉ ⌊b⌋ := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ Int.cast ⁻¹' Icc a b = Icc ⌈a⌉ ⌊b⌋

Next tactic:
ext
@[simp]
theorem preimage_Icc {a b : α} : (Int.cast : ℤ → α) ⁻¹' Set.Icc a b = Set.Icc ⌈a⌉ ⌊b⌋ := by
  ext
  

Proof state:
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
x✝ : ℤ
⊢ x✝ ∈ Int.cast ⁻¹' Icc a b ↔ x✝ ∈ Icc ⌈a⌉ ⌊b⌋

Next tactic:
simp [ceil_le, le_floor]
@[simp]
theorem preimage_Ioi : (Int.cast : ℤ → α) ⁻¹' Set.Ioi a = Set.Ioi ⌊a⌋ := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ Int.cast ⁻¹' Ioi a = Ioi ⌊a⌋

Next tactic:
ext
@[simp]
theorem preimage_Ioi : (Int.cast : ℤ → α) ⁻¹' Set.Ioi a = Set.Ioi ⌊a⌋ := by
  ext
  

Proof state:
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
x✝ : ℤ
⊢ x✝ ∈ Int.cast ⁻¹' Ioi a ↔ x✝ ∈ Ioi ⌊a⌋

Next tactic:
simp [floor_lt]
@[simp]
theorem preimage_Ici : (Int.cast : ℤ → α) ⁻¹' Set.Ici a = Set.Ici ⌈a⌉ := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ Int.cast ⁻¹' Ici a = Ici ⌈a⌉

Next tactic:
ext
@[simp]
theorem preimage_Ici : (Int.cast : ℤ → α) ⁻¹' Set.Ici a = Set.Ici ⌈a⌉ := by
  ext
  

Proof state:
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
x✝ : ℤ
⊢ x✝ ∈ Int.cast ⁻¹' Ici a ↔ x✝ ∈ Ici ⌈a⌉

Next tactic:
simp [ceil_le]
@[simp]
theorem preimage_Iio : (Int.cast : ℤ → α) ⁻¹' Set.Iio a = Set.Iio ⌈a⌉ := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ Int.cast ⁻¹' Iio a = Iio ⌈a⌉

Next tactic:
ext
@[simp]
theorem preimage_Iio : (Int.cast : ℤ → α) ⁻¹' Set.Iio a = Set.Iio ⌈a⌉ := by
  ext
  

Proof state:
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
x✝ : ℤ
⊢ x✝ ∈ Int.cast ⁻¹' Iio a ↔ x✝ ∈ Iio ⌈a⌉

Next tactic:
simp [lt_ceil]
@[simp]
theorem preimage_Iic : (Int.cast : ℤ → α) ⁻¹' Set.Iic a = Set.Iic ⌊a⌋ := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ Int.cast ⁻¹' Iic a = Iic ⌊a⌋

Next tactic:
ext
@[simp]
theorem preimage_Iic : (Int.cast : ℤ → α) ⁻¹' Set.Iic a = Set.Iic ⌊a⌋ := by
  ext
  

Proof state:
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
x✝ : ℤ
⊢ x✝ ∈ Int.cast ⁻¹' Iic a ↔ x✝ ∈ Iic ⌊a⌋

Next tactic:
simp [le_floor]
@[simp]
theorem round_zero : round (0 : α) = 0 := by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
⊢ round 0 = 0

Next tactic:
simp [round]
@[simp]
theorem round_one : round (1 : α) = 1 := by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
⊢ round 1 = 1

Next tactic:
simp [round]
@[simp]
theorem round_natCast (n : ℕ) : round (n : α) = n := by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
n : ℕ
⊢ round ↑n = ↑n

Next tactic:
simp [round]
@[simp]
theorem round_intCast (n : ℤ) : round (n : α) = n := by 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
n : ℤ
⊢ round ↑n = n

Next tactic:
simp [round]
@[simp]
theorem round_add_int (x : α) (y : ℤ) : round (x + y) = round x + y := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
y : ℤ
⊢ round (x + ↑y) = round x + y

Next tactic:
rw [round, round, Int.fract_add_int, Int.floor_add_int, Int.ceil_add_int, ← apply_ite₂, ite_self]
@[simp]
theorem round_add_one (a : α) : round (a + 1) = round a + 1 := by
  -- Porting note: broken `convert round_add_int a 1`
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
a : α
⊢ round (a + 1) = round a + 1

Next tactic:
rw [← round_add_int a 1, cast_one]
@[simp]
theorem round_sub_int (x : α) (y : ℤ) : round (x - y) = round x - y := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
y : ℤ
⊢ round (x - ↑y) = round x - y

Next tactic:
rw [sub_eq_add_neg]
@[simp]
theorem round_sub_int (x : α) (y : ℤ) : round (x - y) = round x - y := by
  rw [sub_eq_add_neg]
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
y : ℤ
⊢ round (x + -↑y) = round x - y

Next tactic:
norm_cast
@[simp]
theorem round_sub_int (x : α) (y : ℤ) : round (x - y) = round x - y := by
  rw [sub_eq_add_neg]
  norm_cast
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
y : ℤ
⊢ round (x + ↑(-y)) = round x - y

Next tactic:
rw [round_add_int, sub_eq_add_neg]
@[simp]
theorem round_sub_one (a : α) : round (a - 1) = round a - 1 := by
  -- Porting note: broken `convert round_sub_int a 1`
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
a : α
⊢ round (a - 1) = round a - 1

Next tactic:
rw [← round_sub_int a 1, cast_one]
@[simp]
theorem round_int_add (x : α) (y : ℤ) : round ((y : α) + x) = y + round x := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
y : ℤ
⊢ round (↑y + x) = y + round x

Next tactic:
rw [add_comm, round_add_int, add_comm]
@[simp]
theorem round_nat_add (x : α) (y : ℕ) : round ((y : α) + x) = y + round x := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
y : ℕ
⊢ round (↑y + x) = ↑y + round x

Next tactic:
rw [add_comm, round_add_nat, add_comm]
theorem abs_sub_round_eq_min (x : α) : |x - round x| = min (fract x) (1 - fract x) := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
⊢ |x - ↑(round x)| = min (fract x) (1 - fract x)

Next tactic:
simp_rw [round, min_def_lt, two_mul, ← lt_tsub_iff_left]
theorem abs_sub_round_eq_min (x : α) : |x - round x| = min (fract x) (1 - fract x) := by
  simp_rw [round, min_def_lt, two_mul, ← lt_tsub_iff_left]
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
⊢ |x - ↑(if fract x < 1 - fract x then ⌊x⌋ else ⌈x⌉)| = if fract x < 1 - fract x then fract x else 1 - fract x

Next tactic:
cases' lt_or_ge (fract x) (1 - fract x) with hx hx
theorem abs_sub_round_eq_min (x : α) : |x - round x| = min (fract x) (1 - fract x) := by
  simp_rw [round, min_def_lt, two_mul, ← lt_tsub_iff_left]
  cases' lt_or_ge (fract x) (1 - fract x) with hx hx
  · 

Proof state:
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
hx : fract x < 1 - fract x
⊢ |x - ↑(if fract x < 1 - fract x then ⌊x⌋ else ⌈x⌉)| = if fract x < 1 - fract x then fract x else 1 - fract x

Next tactic:
rw [if_pos hx, if_pos hx, self_sub_floor, abs_fract]
theorem abs_sub_round_eq_min (x : α) : |x - round x| = min (fract x) (1 - fract x) := by
  simp_rw [round, min_def_lt, two_mul, ← lt_tsub_iff_left]
  cases' lt_or_ge (fract x) (1 - fract x) with hx hx
  · rw [if_pos hx, if_pos hx, self_sub_floor, abs_fract]
  · 

Proof state:
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
hx : fract x ≥ 1 - fract x
⊢ |x - ↑(if fract x < 1 - fract x then ⌊x⌋ else ⌈x⌉)| = if fract x < 1 - fract x then fract x else 1 - fract x

Next tactic:
have : 0 < fract x := by
      replace hx : 0 < fract x + fract x := lt_of_lt_of_le zero_lt_one (tsub_le_iff_left.mp hx)
      simpa only [← two_mul, zero_lt_mul_left, zero_lt_two] using hx
theorem abs_sub_round_eq_min (x : α) : |x - round x| = min (fract x) (1 - fract x) := by
  simp_rw [round, min_def_lt, two_mul, ← lt_tsub_iff_left]
  cases' lt_or_ge (fract x) (1 - fract x) with hx hx
  · rw [if_pos hx, if_pos hx, self_sub_floor, abs_fract]
  · have : 0 < fract x := by
      

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
hx : fract x ≥ 1 - fract x
⊢ 0 < fract x

Next tactic:
replace hx : 0 < fract x + fract x := lt_of_lt_of_le zero_lt_one (tsub_le_iff_left.mp hx)
theorem abs_sub_round_eq_min (x : α) : |x - round x| = min (fract x) (1 - fract x) := by
  simp_rw [round, min_def_lt, two_mul, ← lt_tsub_iff_left]
  cases' lt_or_ge (fract x) (1 - fract x) with hx hx
  · rw [if_pos hx, if_pos hx, self_sub_floor, abs_fract]
  · have : 0 < fract x := by
      replace hx : 0 < fract x + fract x := lt_of_lt_of_le zero_lt_one (tsub_le_iff_left.mp hx)
      

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
hx : 0 < fract x + fract x
⊢ 0 < fract x

Next tactic:
simpa only [← two_mul, zero_lt_mul_left, zero_lt_two] using hx
theorem abs_sub_round_eq_min (x : α) : |x - round x| = min (fract x) (1 - fract x) := by
  simp_rw [round, min_def_lt, two_mul, ← lt_tsub_iff_left]
  cases' lt_or_ge (fract x) (1 - fract x) with hx hx
  · rw [if_pos hx, if_pos hx, self_sub_floor, abs_fract]
  · have : 0 < fract x := by
      replace hx : 0 < fract x + fract x := lt_of_lt_of_le zero_lt_one (tsub_le_iff_left.mp hx)
      simpa only [← two_mul, zero_lt_mul_left, zero_lt_two] using hx
    

Proof state:
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
hx : fract x ≥ 1 - fract x
this : 0 < fract x
⊢ |x - ↑(if fract x < 1 - fract x then ⌊x⌋ else ⌈x⌉)| = if fract x < 1 - fract x then fract x else 1 - fract x

Next tactic:
rw [if_neg (not_lt.mpr hx), if_neg (not_lt.mpr hx), abs_sub_comm, ceil_sub_self_eq this.ne.symm,
      abs_one_sub_fract]
theorem round_le (x : α) (z : ℤ) : |x - round x| ≤ |x - z| := by
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
z : ℤ
⊢ |x - ↑(round x)| ≤ |x - ↑z|

Next tactic:
rw [abs_sub_round_eq_min, min_le_iff]
theorem round_le (x : α) (z : ℤ) : |x - round x| ≤ |x - z| := by
  rw [abs_sub_round_eq_min, min_le_iff]
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
z : ℤ
⊢ fract x ≤ |x - ↑z| ∨ 1 - fract x ≤ |x - ↑z|

Next tactic:
rcases le_or_lt (z : α) x with (hx | hx) <;> [left; right]
theorem round_le (x : α) (z : ℤ) : |x - round x| ≤ |x - z| := by
  rw [abs_sub_round_eq_min, min_le_iff]
  

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
z : ℤ
⊢ fract x ≤ |x - ↑z| ∨ 1 - fract x ≤ |x - ↑z|

Next tactic:
rcases le_or_lt (z : α) x with (hx | hx)
theorem round_le (x : α) (z : ℤ) : |x - round x| ≤ |x - z| := by
  rw [abs_sub_round_eq_min, min_le_iff]
  rcases le_or_lt (z : α) x with (hx | hx) <;> [

Proof state:
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
z : ℤ
hx : ↑z ≤ x
⊢ fract x ≤ |x - ↑z| ∨ 1 - fract x ≤ |x - ↑z|

Next tactic:
left
theorem round_le (x : α) (z : ℤ) : |x - round x| ≤ |x - z| := by
  rw [abs_sub_round_eq_min, min_le_iff]
  rcases le_or_lt (z : α) x with (hx | hx) <;> [left; 

Proof state:
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
z : ℤ
hx : x < ↑z
⊢ fract x ≤ |x - ↑z| ∨ 1 - fract x ≤ |x - ↑z|

Next tactic:
right
theorem round_le (x : α) (z : ℤ) : |x - round x| ≤ |x - z| := by
  rw [abs_sub_round_eq_min, min_le_iff]
  rcases le_or_lt (z : α) x with (hx | hx) <;> [left; right]
  · 

Proof state:
case inl.h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
z : ℤ
hx : ↑z ≤ x
⊢ fract x ≤ |x - ↑z|

Next tactic:
conv_rhs => rw [abs_eq_self.mpr (sub_nonneg.mpr hx), ← fract_add_floor x, add_sub_assoc]
theorem round_le (x : α) (z : ℤ) : |x - round x| ≤ |x - z| := by
  rw [abs_sub_round_eq_min, min_le_iff]
  rcases le_or_lt (z : α) x with (hx | hx) <;> [left; right]
  · conv_rhs => 

Proof state:
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
z : ℤ
hx : ↑z ≤ x
| |x - ↑z|

Next tactic:
rw [abs_eq_self.mpr (sub_nonneg.mpr hx), ← fract_add_floor x, add_sub_assoc]
theorem round_le (x : α) (z : ℤ) : |x - round x| ≤ |x - z| := by
  rw [abs_sub_round_eq_min, min_le_iff]
  rcases le_or_lt (z : α) x with (hx | hx) <;> [left; right]
  · conv_rhs => rw [abs_eq_self.mpr (sub_nonneg.mpr hx), ← fract_add_floor x, add_sub_assoc]
    

Proof state:
case inl.h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
z : ℤ
hx : ↑z ≤ x
⊢ fract x ≤ fract x + (↑⌊x⌋ - ↑z)

Next tactic:
simpa only [le_add_iff_nonneg_right, sub_nonneg, cast_le] using le_floor.mpr hx
theorem round_le (x : α) (z : ℤ) : |x - round x| ≤ |x - z| := by
  rw [abs_sub_round_eq_min, min_le_iff]
  rcases le_or_lt (z : α) x with (hx | hx) <;> [left; right]
  · conv_rhs => rw [abs_eq_self.mpr (sub_nonneg.mpr hx), ← fract_add_floor x, add_sub_assoc]
    simpa only [le_add_iff_nonneg_right, sub_nonneg, cast_le] using le_floor.mpr hx
  · 

Proof state:
case inr.h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
z : ℤ
hx : x < ↑z
⊢ 1 - fract x ≤ |x - ↑z|

Next tactic:
rw [abs_eq_neg_self.mpr (sub_neg.mpr hx).le]
theorem round_le (x : α) (z : ℤ) : |x - round x| ≤ |x - z| := by
  rw [abs_sub_round_eq_min, min_le_iff]
  rcases le_or_lt (z : α) x with (hx | hx) <;> [left; right]
  · conv_rhs => rw [abs_eq_self.mpr (sub_nonneg.mpr hx), ← fract_add_floor x, add_sub_assoc]
    simpa only [le_add_iff_nonneg_right, sub_nonneg, cast_le] using le_floor.mpr hx
  · rw [abs_eq_neg_self.mpr (sub_neg.mpr hx).le]
    

Proof state:
case inr.h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
z : ℤ
hx : x < ↑z
⊢ 1 - fract x ≤ -(x - ↑z)

Next tactic:
conv_rhs => rw [← fract_add_floor x]