[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
a✝ n✝ : ℕ
x✝ : 0 ≤ a✝
⊢ n✝ ≤ id a✝ ↔ ↑n✝ ≤ a✝
[PROOFSTEP]
rw [Nat.cast_id]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
a✝ n✝ : ℕ
x✝ : 0 ≤ a✝
⊢ n✝ ≤ id a✝ ↔ n✝ ≤ a✝
[PROOFSTEP]
rfl
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
n a : ℕ
⊢ id n ≤ a ↔ n ≤ ↑a
[PROOFSTEP]
rw [Nat.cast_id]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
n a : ℕ
⊢ id n ≤ a ↔ n ≤ a
[PROOFSTEP]
rfl
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
ha : 0 ≤ a
⊢ a < ↑1 ↔ a < 1
[PROOFSTEP]
rw [Nat.cast_one]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
h : ⌊a⌋₊ < 1
⊢ a < 1
[PROOFSTEP]
exact_mod_cast lt_of_floor_lt h
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a : α
⊢ a < ↑⌊a⌋₊ + 1
[PROOFSTEP]
simpa using lt_succ_floor a
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n✝ n a : ℕ
⊢ a ≤ ⌊↑n⌋₊ ↔ a ≤ n
[PROOFSTEP]
rw [le_floor_iff, Nat.cast_le]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n✝ n a : ℕ
⊢ 0 ≤ ↑n
[PROOFSTEP]
exact n.cast_nonneg
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
⊢ ⌊0⌋₊ = 0
[PROOFSTEP]
rw [← Nat.cast_zero, floor_coe]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
⊢ ⌊1⌋₊ = 1
[PROOFSTEP]
rw [← Nat.cast_one, floor_coe]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
ha : a ≤ 0
⊢ a = 0 → ⌊a⌋₊ = 0
[PROOFSTEP]
rintro rfl
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
n : ℕ
ha : 0 ≤ 0
⊢ ⌊0⌋₊ = 0
[PROOFSTEP]
exact floor_zero
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a b : α
h : a ≤ b
⊢ ⌊a⌋₊ ≤ ⌊b⌋₊
[PROOFSTEP]
obtain ha | ha := le_total a 0
[GOAL]
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a b : α
h : a ≤ b
ha : a ≤ 0
⊢ ⌊a⌋₊ ≤ ⌊b⌋₊
[PROOFSTEP]
rw [floor_of_nonpos ha]
[GOAL]
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a b : α
h : a ≤ b
ha : a ≤ 0
⊢ 0 ≤ ⌊b⌋₊
[PROOFSTEP]
exact Nat.zero_le _
[GOAL]
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a b : α
h : a ≤ b
ha : 0 ≤ a
⊢ ⌊a⌋₊ ≤ ⌊b⌋₊
[PROOFSTEP]
exact le_floor ((floor_le ha).trans h)
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
hn : n ≠ 0
⊢ n ≤ ⌊a⌋₊ ↔ ↑n ≤ a
[PROOFSTEP]
obtain ha | ha := le_total a 0
[GOAL]
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
hn : n ≠ 0
ha : a ≤ 0
⊢ n ≤ ⌊a⌋₊ ↔ ↑n ≤ a
[PROOFSTEP]
rw [floor_of_nonpos ha]
[GOAL]
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
hn : n ≠ 0
ha : a ≤ 0
⊢ n ≤ 0 ↔ ↑n ≤ a
[PROOFSTEP]
exact iff_of_false (Nat.pos_of_ne_zero hn).not_le (not_le_of_lt <| ha.trans_lt <| cast_pos.2 <| Nat.pos_of_ne_zero hn)
[GOAL]
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
hn : n ≠ 0
ha : 0 ≤ a
⊢ n ≤ ⌊a⌋₊ ↔ ↑n ≤ a
[PROOFSTEP]
exact le_floor_iff ha
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
x : α
⊢ 1 ≤ ⌊x⌋₊ ↔ 1 ≤ x
[PROOFSTEP]
exact_mod_cast @le_floor_iff' α _ _ x 1 one_ne_zero
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
⊢ 0 < ⌊a⌋₊ ↔ 1 ≤ a
[PROOFSTEP]
rw [Nat.lt_iff_add_one_le, zero_add, le_floor_iff' Nat.one_ne_zero, cast_one]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
h : 0 < ⌊a⌋₊
ha : a ≤ 0
⊢ 0 < 0
[PROOFSTEP]
rwa [floor_of_nonpos ha] at h 
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
⊢ ⌊a⌋₊ = 0 ↔ a < 1
[PROOFSTEP]
rw [← lt_one_iff, ← @cast_one α]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
⊢ ⌊a⌋₊ < 1 ↔ a < ↑1
[PROOFSTEP]
exact floor_lt' Nat.one_ne_zero
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
ha : 0 ≤ a
⊢ ⌊a⌋₊ = n ↔ ↑n ≤ a ∧ a < ↑n + 1
[PROOFSTEP]
rw [← le_floor_iff ha, ← Nat.cast_one, ← Nat.cast_add, ← floor_lt ha, Nat.lt_add_one_iff, le_antisymm_iff, and_comm]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
hn : n ≠ 0
⊢ ⌊a⌋₊ = n ↔ ↑n ≤ a ∧ a < ↑n + 1
[PROOFSTEP]
rw [← le_floor_iff' hn, ← Nat.cast_one, ← Nat.cast_add, ← floor_lt' (Nat.add_one_ne_zero n), Nat.lt_add_one_iff,
  le_antisymm_iff, and_comm]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n✝ n : ℕ
x : α
hx : x ∈ Ico (↑n) (↑n + 1)
⊢ ↑⌊x⌋₊ = ↑n
[PROOFSTEP]
exact_mod_cast floor_eq_on_Ico n x hx
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
⊢ n + 1 ≤ ⌈a⌉₊ ↔ ↑n < a
[PROOFSTEP]
rw [← Nat.lt_ceil, Nat.add_one_le_iff]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
⊢ 1 ≤ ⌈a⌉₊ ↔ 0 < a
[PROOFSTEP]
rw [← zero_add 1, Nat.add_one_le_ceil_iff, Nat.cast_zero]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a : α
⊢ ⌈a⌉₊ ≤ ⌊a⌋₊ + 1
[PROOFSTEP]
rw [ceil_le, Nat.cast_add, Nat.cast_one]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a : α
⊢ a ≤ ↑⌊a⌋₊ + 1
[PROOFSTEP]
exact (lt_floor_add_one a).le
[GOAL]
F : Type u_1
α✝ : Type u_2
β : Type u_3
inst✝³ : LinearOrderedSemiring α✝
inst✝² : FloorSemiring α✝
a✝ : α✝
n : ℕ
α : Type u_4
inst✝¹ : LinearOrderedRing α
inst✝ : FloorSemiring α
z : ℤ
a : ℕ
⊢ ⌈↑z⌉₊ ≤ a ↔ Int.toNat z ≤ a
[PROOFSTEP]
simp
[GOAL]
F : Type u_1
α✝ : Type u_2
β : Type u_3
inst✝³ : LinearOrderedSemiring α✝
inst✝² : FloorSemiring α✝
a✝ : α✝
n : ℕ
α : Type u_4
inst✝¹ : LinearOrderedRing α
inst✝ : FloorSemiring α
z : ℤ
a : ℕ
⊢ ↑z ≤ ↑a ↔ z ≤ ↑a
[PROOFSTEP]
norm_cast
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n✝ n a : ℕ
⊢ ⌈↑n⌉₊ ≤ a ↔ n ≤ a
[PROOFSTEP]
rw [ceil_le, cast_le]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
⊢ ⌈0⌉₊ = 0
[PROOFSTEP]
rw [← Nat.cast_zero, ceil_natCast]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
⊢ ⌈1⌉₊ = 1
[PROOFSTEP]
rw [← Nat.cast_one, ceil_natCast]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
⊢ ⌈a⌉₊ = 0 ↔ a ≤ 0
[PROOFSTEP]
rw [← le_zero_iff, ceil_le, Nat.cast_zero]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
⊢ 0 < ⌈a⌉₊ ↔ 0 < a
[PROOFSTEP]
rw [lt_ceil, cast_zero]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a : α
⊢ ⌊a⌋₊ ≤ ⌈a⌉₊
[PROOFSTEP]
obtain ha | ha := le_total a 0
[GOAL]
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a : α
ha : a ≤ 0
⊢ ⌊a⌋₊ ≤ ⌈a⌉₊
[PROOFSTEP]
rw [floor_of_nonpos ha]
[GOAL]
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a : α
ha : a ≤ 0
⊢ 0 ≤ ⌈a⌉₊
[PROOFSTEP]
exact Nat.zero_le _
[GOAL]
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a : α
ha : 0 ≤ a
⊢ ⌊a⌋₊ ≤ ⌈a⌉₊
[PROOFSTEP]
exact cast_le.1 ((floor_le ha).trans <| le_ceil _)
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a b : α
h : a < b
h' : 0 < b
⊢ ⌊a⌋₊ < ⌈b⌉₊
[PROOFSTEP]
rcases le_or_lt 0 a with (ha | ha)
[GOAL]
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a b : α
h : a < b
h' : 0 < b
ha : 0 ≤ a
⊢ ⌊a⌋₊ < ⌈b⌉₊
[PROOFSTEP]
rw [floor_lt ha]
[GOAL]
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a b : α
h : a < b
h' : 0 < b
ha : 0 ≤ a
⊢ a < ↑⌈b⌉₊
[PROOFSTEP]
exact h.trans_le (le_ceil _)
[GOAL]
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a b : α
h : a < b
h' : 0 < b
ha : a < 0
⊢ ⌊a⌋₊ < ⌈b⌉₊
[PROOFSTEP]
rwa [floor_of_nonpos ha.le, lt_ceil, Nat.cast_zero]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
hn : n ≠ 0
⊢ ⌈a⌉₊ = n ↔ ↑(n - 1) < a ∧ a ≤ ↑n
[PROOFSTEP]
rw [← ceil_le, ← not_le, ← ceil_le, not_le, tsub_lt_iff_right (Nat.add_one_le_iff.2 (pos_iff_ne_zero.2 hn)),
  Nat.lt_add_one_iff, le_antisymm_iff, and_comm]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a b : α
ha : 0 ≤ a
⊢ Nat.cast ⁻¹' Ioo a b = Ioo ⌊a⌋₊ ⌈b⌉₊
[PROOFSTEP]
ext
[GOAL]
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a b : α
ha : 0 ≤ a
x✝ : ℕ
⊢ x✝ ∈ Nat.cast ⁻¹' Ioo a b ↔ x✝ ∈ Ioo ⌊a⌋₊ ⌈b⌉₊
[PROOFSTEP]
simp [floor_lt, lt_ceil, ha]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a b : α
⊢ Nat.cast ⁻¹' Ico a b = Ico ⌈a⌉₊ ⌈b⌉₊
[PROOFSTEP]
ext
[GOAL]
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a b : α
x✝ : ℕ
⊢ x✝ ∈ Nat.cast ⁻¹' Ico a b ↔ x✝ ∈ Ico ⌈a⌉₊ ⌈b⌉₊
[PROOFSTEP]
simp [ceil_le, lt_ceil]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a b : α
ha : 0 ≤ a
hb : 0 ≤ b
⊢ Nat.cast ⁻¹' Ioc a b = Ioc ⌊a⌋₊ ⌊b⌋₊
[PROOFSTEP]
ext
[GOAL]
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a b : α
ha : 0 ≤ a
hb : 0 ≤ b
x✝ : ℕ
⊢ x✝ ∈ Nat.cast ⁻¹' Ioc a b ↔ x✝ ∈ Ioc ⌊a⌋₊ ⌊b⌋₊
[PROOFSTEP]
simp [floor_lt, le_floor_iff, hb, ha]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a b : α
hb : 0 ≤ b
⊢ Nat.cast ⁻¹' Icc a b = Icc ⌈a⌉₊ ⌊b⌋₊
[PROOFSTEP]
ext
[GOAL]
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a b : α
hb : 0 ≤ b
x✝ : ℕ
⊢ x✝ ∈ Nat.cast ⁻¹' Icc a b ↔ x✝ ∈ Icc ⌈a⌉₊ ⌊b⌋₊
[PROOFSTEP]
simp [ceil_le, hb, le_floor_iff]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a : α
ha : 0 ≤ a
⊢ Nat.cast ⁻¹' Ioi a = Ioi ⌊a⌋₊
[PROOFSTEP]
ext
[GOAL]
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a : α
ha : 0 ≤ a
x✝ : ℕ
⊢ x✝ ∈ Nat.cast ⁻¹' Ioi a ↔ x✝ ∈ Ioi ⌊a⌋₊
[PROOFSTEP]
simp [floor_lt, ha]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a : α
⊢ Nat.cast ⁻¹' Ici a = Ici ⌈a⌉₊
[PROOFSTEP]
ext
[GOAL]
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a : α
x✝ : ℕ
⊢ x✝ ∈ Nat.cast ⁻¹' Ici a ↔ x✝ ∈ Ici ⌈a⌉₊
[PROOFSTEP]
simp [ceil_le]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a : α
⊢ Nat.cast ⁻¹' Iio a = Iio ⌈a⌉₊
[PROOFSTEP]
ext
[GOAL]
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a : α
x✝ : ℕ
⊢ x✝ ∈ Nat.cast ⁻¹' Iio a ↔ x✝ ∈ Iio ⌈a⌉₊
[PROOFSTEP]
simp [lt_ceil]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a : α
ha : 0 ≤ a
⊢ Nat.cast ⁻¹' Iic a = Iic ⌊a⌋₊
[PROOFSTEP]
ext
[GOAL]
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a : α
ha : 0 ≤ a
x✝ : ℕ
⊢ x✝ ∈ Nat.cast ⁻¹' Iic a ↔ x✝ ∈ Iic ⌊a⌋₊
[PROOFSTEP]
simp [le_floor_iff, ha]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n✝ : ℕ
ha : 0 ≤ a
n b : ℕ
⊢ b ≤ ⌊a + ↑n⌋₊ ↔ b ≤ ⌊a⌋₊ + n
[PROOFSTEP]
rw [le_floor_iff (add_nonneg ha n.cast_nonneg)]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n✝ : ℕ
ha : 0 ≤ a
n b : ℕ
⊢ ↑b ≤ a + ↑n ↔ b ≤ ⌊a⌋₊ + n
[PROOFSTEP]
obtain hb | hb := le_total n b
[GOAL]
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n✝ : ℕ
ha : 0 ≤ a
n b : ℕ
hb : n ≤ b
⊢ ↑b ≤ a + ↑n ↔ b ≤ ⌊a⌋₊ + n
[PROOFSTEP]
obtain ⟨d, rfl⟩ := exists_add_of_le hb
[GOAL]
case inl.intro
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n✝ : ℕ
ha : 0 ≤ a
n d : ℕ
hb : n ≤ n + d
⊢ ↑(n + d) ≤ a + ↑n ↔ n + d ≤ ⌊a⌋₊ + n
[PROOFSTEP]
rw [Nat.cast_add, add_comm n, add_comm (n : α), add_le_add_iff_right, add_le_add_iff_right, le_floor_iff ha]
[GOAL]
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n✝ : ℕ
ha : 0 ≤ a
n b : ℕ
hb : b ≤ n
⊢ ↑b ≤ a + ↑n ↔ b ≤ ⌊a⌋₊ + n
[PROOFSTEP]
obtain ⟨d, rfl⟩ := exists_add_of_le hb
[GOAL]
case inr.intro
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
ha : 0 ≤ a
b d : ℕ
hb : b ≤ b + d
⊢ ↑b ≤ a + ↑(b + d) ↔ b ≤ ⌊a⌋₊ + (b + d)
[PROOFSTEP]
rw [Nat.cast_add, add_left_comm _ b, add_left_comm _ (b : α)]
[GOAL]
case inr.intro
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
ha : 0 ≤ a
b d : ℕ
hb : b ≤ b + d
⊢ ↑b ≤ ↑b + (a + ↑d) ↔ b ≤ b + (⌊a⌋₊ + d)
[PROOFSTEP]
refine' iff_of_true _ le_self_add
[GOAL]
case inr.intro
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
ha : 0 ≤ a
b d : ℕ
hb : b ≤ b + d
⊢ ↑b ≤ ↑b + (a + ↑d)
[PROOFSTEP]
exact le_add_of_nonneg_right <| ha.trans <| le_add_of_nonneg_right d.cast_nonneg
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
ha : 0 ≤ a
⊢ ⌊a + 1⌋₊ = ⌊a⌋₊ + 1
[PROOFSTEP]
rw [← cast_one, floor_add_nat ha 1]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝⁴ : LinearOrderedSemiring α
inst✝³ : FloorSemiring α
a✝ : α
n✝ : ℕ
inst✝² : Sub α
inst✝¹ : OrderedSub α
inst✝ : ExistsAddOfLE α
a : α
n : ℕ
⊢ ⌊a - ↑n⌋₊ = ⌊a⌋₊ - n
[PROOFSTEP]
obtain ha | ha := le_total a 0
[GOAL]
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝⁴ : LinearOrderedSemiring α
inst✝³ : FloorSemiring α
a✝ : α
n✝ : ℕ
inst✝² : Sub α
inst✝¹ : OrderedSub α
inst✝ : ExistsAddOfLE α
a : α
n : ℕ
ha : a ≤ 0
⊢ ⌊a - ↑n⌋₊ = ⌊a⌋₊ - n
[PROOFSTEP]
rw [floor_of_nonpos ha, floor_of_nonpos (tsub_nonpos_of_le (ha.trans n.cast_nonneg)), zero_tsub]
[GOAL]
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝⁴ : LinearOrderedSemiring α
inst✝³ : FloorSemiring α
a✝ : α
n✝ : ℕ
inst✝² : Sub α
inst✝¹ : OrderedSub α
inst✝ : ExistsAddOfLE α
a : α
n : ℕ
ha : 0 ≤ a
⊢ ⌊a - ↑n⌋₊ = ⌊a⌋₊ - n
[PROOFSTEP]
cases' le_total a n with h h
[GOAL]
case inr.inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝⁴ : LinearOrderedSemiring α
inst✝³ : FloorSemiring α
a✝ : α
n✝ : ℕ
inst✝² : Sub α
inst✝¹ : OrderedSub α
inst✝ : ExistsAddOfLE α
a : α
n : ℕ
ha : 0 ≤ a
h : a ≤ ↑n
⊢ ⌊a - ↑n⌋₊ = ⌊a⌋₊ - n
[PROOFSTEP]
rw [floor_of_nonpos (tsub_nonpos_of_le h), eq_comm, tsub_eq_zero_iff_le]
[GOAL]
case inr.inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝⁴ : LinearOrderedSemiring α
inst✝³ : FloorSemiring α
a✝ : α
n✝ : ℕ
inst✝² : Sub α
inst✝¹ : OrderedSub α
inst✝ : ExistsAddOfLE α
a : α
n : ℕ
ha : 0 ≤ a
h : a ≤ ↑n
⊢ ⌊a⌋₊ ≤ n
[PROOFSTEP]
exact Nat.cast_le.1 ((Nat.floor_le ha).trans h)
[GOAL]
case inr.inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝⁴ : LinearOrderedSemiring α
inst✝³ : FloorSemiring α
a✝ : α
n✝ : ℕ
inst✝² : Sub α
inst✝¹ : OrderedSub α
inst✝ : ExistsAddOfLE α
a : α
n : ℕ
ha : 0 ≤ a
h : ↑n ≤ a
⊢ ⌊a - ↑n⌋₊ = ⌊a⌋₊ - n
[PROOFSTEP]
rw [eq_tsub_iff_add_eq_of_le (le_floor h), ← floor_add_nat _, tsub_add_cancel_of_le h]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝⁴ : LinearOrderedSemiring α
inst✝³ : FloorSemiring α
a✝ : α
n✝ : ℕ
inst✝² : Sub α
inst✝¹ : OrderedSub α
inst✝ : ExistsAddOfLE α
a : α
n : ℕ
ha : 0 ≤ a
h : ↑n ≤ a
⊢ 0 ≤ a - ↑n
[PROOFSTEP]
exact le_tsub_of_add_le_left ((add_zero _).trans_le h)
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝⁴ : LinearOrderedSemiring α
inst✝³ : FloorSemiring α
a✝ : α
n : ℕ
inst✝² : Sub α
inst✝¹ : OrderedSub α
inst✝ : ExistsAddOfLE α
a : α
⊢ ⌊a - 1⌋₊ = ⌊a⌋₊ - 1
[PROOFSTEP]
exact_mod_cast floor_sub_nat a 1
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n✝ : ℕ
ha : 0 ≤ a
n b : ℕ
⊢ ⌈a + ↑n⌉₊ ≤ b ↔ ⌈a⌉₊ + n ≤ b
[PROOFSTEP]
rw [← not_lt, ← not_lt, not_iff_not, lt_ceil]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n✝ : ℕ
ha : 0 ≤ a
n b : ℕ
⊢ ↑b < a + ↑n ↔ b < ⌈a⌉₊ + n
[PROOFSTEP]
obtain hb | hb := le_or_lt n b
[GOAL]
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n✝ : ℕ
ha : 0 ≤ a
n b : ℕ
hb : n ≤ b
⊢ ↑b < a + ↑n ↔ b < ⌈a⌉₊ + n
[PROOFSTEP]
obtain ⟨d, rfl⟩ := exists_add_of_le hb
[GOAL]
case inl.intro
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n✝ : ℕ
ha : 0 ≤ a
n d : ℕ
hb : n ≤ n + d
⊢ ↑(n + d) < a + ↑n ↔ n + d < ⌈a⌉₊ + n
[PROOFSTEP]
rw [Nat.cast_add, add_comm n, add_comm (n : α), add_lt_add_iff_right, add_lt_add_iff_right, lt_ceil]
[GOAL]
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n✝ : ℕ
ha : 0 ≤ a
n b : ℕ
hb : b < n
⊢ ↑b < a + ↑n ↔ b < ⌈a⌉₊ + n
[PROOFSTEP]
exact iff_of_true (lt_add_of_nonneg_of_lt ha <| cast_lt.2 hb) (lt_add_left _ _ _ hb)
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a : α
n : ℕ
ha : 0 ≤ a
⊢ ⌈a + 1⌉₊ = ⌈a⌉₊ + 1
[PROOFSTEP]
rw [cast_one.symm, ceil_add_nat ha 1]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a b : α
⊢ ⌈a + b⌉₊ ≤ ⌈a⌉₊ + ⌈b⌉₊
[PROOFSTEP]
rw [ceil_le, Nat.cast_add]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemiring α
inst✝ : FloorSemiring α
a✝ : α
n : ℕ
a b : α
⊢ a + b ≤ ↑⌈a⌉₊ + ↑⌈b⌉₊
[PROOFSTEP]
exact _root_.add_le_add (le_ceil _) (le_ceil _)
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemifield α
inst✝ : FloorSemiring α
a : α
n : ℕ
⊢ ⌊a / ↑n⌋₊ = ⌊a⌋₊ / n
[PROOFSTEP]
cases' le_total a 0 with ha ha
[GOAL]
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemifield α
inst✝ : FloorSemiring α
a : α
n : ℕ
ha : a ≤ 0
⊢ ⌊a / ↑n⌋₊ = ⌊a⌋₊ / n
[PROOFSTEP]
rw [floor_of_nonpos, floor_of_nonpos ha]
[GOAL]
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemifield α
inst✝ : FloorSemiring α
a : α
n : ℕ
ha : a ≤ 0
⊢ 0 = 0 / n
[PROOFSTEP]
simp
[GOAL]
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemifield α
inst✝ : FloorSemiring α
a : α
n : ℕ
ha : a ≤ 0
⊢ a / ↑n ≤ 0
[PROOFSTEP]
apply div_nonpos_of_nonpos_of_nonneg ha n.cast_nonneg
[GOAL]
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemifield α
inst✝ : FloorSemiring α
a : α
n : ℕ
ha : 0 ≤ a
⊢ ⌊a / ↑n⌋₊ = ⌊a⌋₊ / n
[PROOFSTEP]
obtain rfl | hn := n.eq_zero_or_pos
[GOAL]
case inr.inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemifield α
inst✝ : FloorSemiring α
a : α
ha : 0 ≤ a
⊢ ⌊a / ↑0⌋₊ = ⌊a⌋₊ / 0
[PROOFSTEP]
rw [cast_zero, div_zero, Nat.div_zero, floor_zero]
[GOAL]
case inr.inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemifield α
inst✝ : FloorSemiring α
a : α
n : ℕ
ha : 0 ≤ a
hn : n > 0
⊢ ⌊a / ↑n⌋₊ = ⌊a⌋₊ / n
[PROOFSTEP]
refine' (floor_eq_iff _).2 _
[GOAL]
case inr.inr.refine'_1
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemifield α
inst✝ : FloorSemiring α
a : α
n : ℕ
ha : 0 ≤ a
hn : n > 0
⊢ 0 ≤ a / ↑n
[PROOFSTEP]
exact div_nonneg ha n.cast_nonneg
[GOAL]
case inr.inr.refine'_2
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemifield α
inst✝ : FloorSemiring α
a : α
n : ℕ
ha : 0 ≤ a
hn : n > 0
⊢ ↑(⌊a⌋₊ / n) ≤ a / ↑n ∧ a / ↑n < ↑(⌊a⌋₊ / n) + 1
[PROOFSTEP]
constructor
[GOAL]
case inr.inr.refine'_2.left
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemifield α
inst✝ : FloorSemiring α
a : α
n : ℕ
ha : 0 ≤ a
hn : n > 0
⊢ ↑(⌊a⌋₊ / n) ≤ a / ↑n
[PROOFSTEP]
exact cast_div_le.trans (div_le_div_of_le_of_nonneg (floor_le ha) n.cast_nonneg)
[GOAL]
case inr.inr.refine'_2.right
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemifield α
inst✝ : FloorSemiring α
a : α
n : ℕ
ha : 0 ≤ a
hn : n > 0
⊢ a / ↑n < ↑(⌊a⌋₊ / n) + 1
[PROOFSTEP]
rw [div_lt_iff, add_mul, one_mul, ← cast_mul, ← cast_add, ← floor_lt ha]
[GOAL]
case inr.inr.refine'_2.right
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemifield α
inst✝ : FloorSemiring α
a : α
n : ℕ
ha : 0 ≤ a
hn : n > 0
⊢ ⌊a⌋₊ < ⌊a⌋₊ / n * n + n
[PROOFSTEP]
exact lt_div_mul_add hn
[GOAL]
case inr.inr.refine'_2.right
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemifield α
inst✝ : FloorSemiring α
a : α
n : ℕ
ha : 0 ≤ a
hn : n > 0
⊢ 0 < ↑n
[PROOFSTEP]
exact cast_pos.2 hn
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemifield α
inst✝ : FloorSemiring α
m n : ℕ
⊢ ⌊↑m / ↑n⌋₊ = m / n
[PROOFSTEP]
convert floor_div_nat (m : α) n
[GOAL]
case h.e'_3.h.e'_5
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedSemifield α
inst✝ : FloorSemiring α
m n : ℕ
⊢ m = ⌊↑m⌋₊
[PROOFSTEP]
rw [m.floor_coe]
[GOAL]
F : Type u_1
α✝ : Type u_2
β : Type u_3
α : Type u_4
inst✝ : LinearOrderedSemiring α
⊢ Subsingleton (FloorSemiring α)
[PROOFSTEP]
refine' ⟨fun H₁ H₂ => _⟩
[GOAL]
F : Type u_1
α✝ : Type u_2
β : Type u_3
α : Type u_4
inst✝ : LinearOrderedSemiring α
H₁ H₂ : FloorSemiring α
⊢ H₁ = H₂
[PROOFSTEP]
have : H₁.ceil = H₂.ceil := funext fun a => (H₁.gc_ceil.l_unique H₂.gc_ceil) fun n => rfl
[GOAL]
F : Type u_1
α✝ : Type u_2
β : Type u_3
α : Type u_4
inst✝ : LinearOrderedSemiring α
H₁ H₂ : FloorSemiring α
this : FloorSemiring.ceil = FloorSemiring.ceil
⊢ H₁ = H₂
[PROOFSTEP]
have : H₁.floor = H₂.floor := by
  ext a
  cases' lt_or_le a 0 with h h
  · rw [H₁.floor_of_neg, H₂.floor_of_neg] <;> exact h
  · refine' eq_of_forall_le_iff fun n => _
    rw [H₁.gc_floor, H₂.gc_floor] <;> exact h
[GOAL]
F : Type u_1
α✝ : Type u_2
β : Type u_3
α : Type u_4
inst✝ : LinearOrderedSemiring α
H₁ H₂ : FloorSemiring α
this : FloorSemiring.ceil = FloorSemiring.ceil
⊢ FloorSemiring.floor = FloorSemiring.floor
[PROOFSTEP]
ext a
[GOAL]
case h
F : Type u_1
α✝ : Type u_2
β : Type u_3
α : Type u_4
inst✝ : LinearOrderedSemiring α
H₁ H₂ : FloorSemiring α
this : FloorSemiring.ceil = FloorSemiring.ceil
a : α
⊢ FloorSemiring.floor a = FloorSemiring.floor a
[PROOFSTEP]
cases' lt_or_le a 0 with h h
[GOAL]
case h.inl
F : Type u_1
α✝ : Type u_2
β : Type u_3
α : Type u_4
inst✝ : LinearOrderedSemiring α
H₁ H₂ : FloorSemiring α
this : FloorSemiring.ceil = FloorSemiring.ceil
a : α
h : a < 0
⊢ FloorSemiring.floor a = FloorSemiring.floor a
[PROOFSTEP]
rw [H₁.floor_of_neg, H₂.floor_of_neg]
[GOAL]
case h.inl
F : Type u_1
α✝ : Type u_2
β : Type u_3
α : Type u_4
inst✝ : LinearOrderedSemiring α
H₁ H₂ : FloorSemiring α
this : FloorSemiring.ceil = FloorSemiring.ceil
a : α
h : a < 0
⊢ a < 0
[PROOFSTEP]
exact h
[GOAL]
case h.inl
F : Type u_1
α✝ : Type u_2
β : Type u_3
α : Type u_4
inst✝ : LinearOrderedSemiring α
H₁ H₂ : FloorSemiring α
this : FloorSemiring.ceil = FloorSemiring.ceil
a : α
h : a < 0
⊢ a < 0
[PROOFSTEP]
exact h
[GOAL]
case h.inr
F : Type u_1
α✝ : Type u_2
β : Type u_3
α : Type u_4
inst✝ : LinearOrderedSemiring α
H₁ H₂ : FloorSemiring α
this : FloorSemiring.ceil = FloorSemiring.ceil
a : α
h : 0 ≤ a
⊢ FloorSemiring.floor a = FloorSemiring.floor a
[PROOFSTEP]
refine' eq_of_forall_le_iff fun n => _
[GOAL]
case h.inr
F : Type u_1
α✝ : Type u_2
β : Type u_3
α : Type u_4
inst✝ : LinearOrderedSemiring α
H₁ H₂ : FloorSemiring α
this : FloorSemiring.ceil = FloorSemiring.ceil
a : α
h : 0 ≤ a
n : ℕ
⊢ n ≤ FloorSemiring.floor a ↔ n ≤ FloorSemiring.floor a
[PROOFSTEP]
rw [H₁.gc_floor, H₂.gc_floor]
[GOAL]
case h.inr
F : Type u_1
α✝ : Type u_2
β : Type u_3
α : Type u_4
inst✝ : LinearOrderedSemiring α
H₁ H₂ : FloorSemiring α
this : FloorSemiring.ceil = FloorSemiring.ceil
a : α
h : 0 ≤ a
n : ℕ
⊢ 0 ≤ a
[PROOFSTEP]
exact h
[GOAL]
case h.inr
F : Type u_1
α✝ : Type u_2
β : Type u_3
α : Type u_4
inst✝ : LinearOrderedSemiring α
H₁ H₂ : FloorSemiring α
this : FloorSemiring.ceil = FloorSemiring.ceil
a : α
h : 0 ≤ a
n : ℕ
⊢ 0 ≤ a
[PROOFSTEP]
exact h
[GOAL]
F : Type u_1
α✝ : Type u_2
β : Type u_3
α : Type u_4
inst✝ : LinearOrderedSemiring α
H₁ H₂ : FloorSemiring α
this✝ : FloorSemiring.ceil = FloorSemiring.ceil
this : FloorSemiring.floor = FloorSemiring.floor
⊢ H₁ = H₂
[PROOFSTEP]
cases H₁
[GOAL]
case mk
F : Type u_1
α✝ : Type u_2
β : Type u_3
α : Type u_4
inst✝ : LinearOrderedSemiring α
H₂ : FloorSemiring α
floor✝ ceil✝ : α → ℕ
floor_of_neg✝ : ∀ {a : α}, a < 0 → floor✝ a = 0
gc_floor✝ : ∀ {a : α} {n : ℕ}, 0 ≤ a → (n ≤ floor✝ a ↔ ↑n ≤ a)
gc_ceil✝ : GaloisConnection ceil✝ Nat.cast
this✝ : FloorSemiring.ceil = FloorSemiring.ceil
this : FloorSemiring.floor = FloorSemiring.floor
⊢ { floor := floor✝, ceil := ceil✝, floor_of_neg := floor_of_neg✝, gc_floor := gc_floor✝, gc_ceil := gc_ceil✝ } = H₂
[PROOFSTEP]
cases H₂
[GOAL]
case mk.mk
F : Type u_1
α✝ : Type u_2
β : Type u_3
α : Type u_4
inst✝ : LinearOrderedSemiring α
floor✝¹ ceil✝¹ : α → ℕ
floor_of_neg✝¹ : ∀ {a : α}, a < 0 → floor✝¹ a = 0
gc_floor✝¹ : ∀ {a : α} {n : ℕ}, 0 ≤ a → (n ≤ floor✝¹ a ↔ ↑n ≤ a)
gc_ceil✝¹ : GaloisConnection ceil✝¹ Nat.cast
floor✝ ceil✝ : α → ℕ
floor_of_neg✝ : ∀ {a : α}, a < 0 → floor✝ a = 0
gc_floor✝ : ∀ {a : α} {n : ℕ}, 0 ≤ a → (n ≤ floor✝ a ↔ ↑n ≤ a)
gc_ceil✝ : GaloisConnection ceil✝ Nat.cast
this✝ : FloorSemiring.ceil = FloorSemiring.ceil
this : FloorSemiring.floor = FloorSemiring.floor
⊢ { floor := floor✝¹, ceil := ceil✝¹, floor_of_neg := floor_of_neg✝¹, gc_floor := gc_floor✝¹, gc_ceil := gc_ceil✝¹ } =
    { floor := floor✝, ceil := ceil✝, floor_of_neg := floor_of_neg✝, gc_floor := gc_floor✝, gc_ceil := gc_ceil✝ }
[PROOFSTEP]
congr
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
a b : ℤ
⊢ ↑a ≤ b ↔ a ≤ id b
[PROOFSTEP]
rw [Int.cast_id]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
a b : ℤ
⊢ a ≤ b ↔ a ≤ id b
[PROOFSTEP]
rfl
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
a b : ℤ
⊢ id a ≤ b ↔ a ≤ ↑b
[PROOFSTEP]
rw [Int.cast_id]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
a b : ℤ
⊢ id a ≤ b ↔ a ≤ b
[PROOFSTEP]
rfl
[GOAL]
F : Type u_1
α✝ : Type u_2
β : Type u_3
α : Type ?u.109134
inst✝ : LinearOrderedRing α
floor : α → ℤ
gc_coe_floor : GaloisConnection Int.cast floor
a : α
z : ℤ
⊢ (fun a => -floor (-a)) a ≤ z ↔ a ≤ ↑z
[PROOFSTEP]
rw [neg_le, ← gc_coe_floor, Int.cast_neg, neg_le_neg_iff]
[GOAL]
F : Type u_1
α✝ : Type u_2
β : Type u_3
α : Type ?u.110495
inst✝ : LinearOrderedRing α
ceil : α → ℤ
gc_ceil_coe : GaloisConnection ceil Int.cast
a : ℤ
z : α
⊢ ↑a ≤ z ↔ a ≤ (fun a => -ceil (-a)) z
[PROOFSTEP]
rw [le_neg, gc_ceil_coe, Int.cast_neg, neg_le_neg_iff]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
x : ℤ
⊢ fract x = OfNat.ofNat 0 x
[PROOFSTEP]
simp [fract]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ 0 ≤ ⌊a⌋ ↔ 0 ≤ a
[PROOFSTEP]
rw [le_floor, Int.cast_zero]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ ⌊a⌋ ≤ z - 1 ↔ a < ↑z
[PROOFSTEP]
rw [← floor_lt, le_sub_one_iff]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ ⌊a⌋ ≤ -1 ↔ a < 0
[PROOFSTEP]
rw [← zero_sub (1 : ℤ), floor_le_sub_one_iff, cast_zero]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
ha : a ≤ 0
⊢ ⌊a⌋ ≤ 0
[PROOFSTEP]
rw [← @cast_le α, Int.cast_zero]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
ha : a ≤ 0
⊢ ↑⌊a⌋ ≤ 0
[PROOFSTEP]
exact (floor_le a).trans ha
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
⊢ a < ↑⌊a⌋ + 1
[PROOFSTEP]
simpa only [Int.succ, Int.cast_add, Int.cast_one] using lt_succ_floor a
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a✝ : α
z a : ℤ
⊢ a ≤ ⌊↑z⌋ ↔ a ≤ z
[PROOFSTEP]
rw [le_floor, Int.cast_le]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ : α
n : ℕ
a : ℤ
⊢ a ≤ ⌊↑n⌋ ↔ a ≤ ↑n
[PROOFSTEP]
rw [le_floor, ← cast_ofNat, cast_le]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ ⌊0⌋ = 0
[PROOFSTEP]
rw [← cast_zero, floor_intCast]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ ⌊1⌋ = 1
[PROOFSTEP]
rw [← cast_one, floor_intCast]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ 0 < ⌊a⌋ ↔ 1 ≤ a
[PROOFSTEP]
rw [Int.lt_iff_add_one_le, zero_add, le_floor, cast_one]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a✝¹ a✝ : α
z a : ℤ
⊢ a ≤ ⌊a✝ + ↑z⌋ ↔ a ≤ ⌊a✝⌋ + z
[PROOFSTEP]
rw [le_floor, ← sub_le_iff_le_add, ← sub_le_iff_le_add, le_floor, Int.cast_sub]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
⊢ ⌊a + 1⌋ = ⌊a⌋ + 1
[PROOFSTEP]
rw [← cast_one, floor_add_int]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ ⌊a⌋ + ⌊b⌋ ≤ ⌊a + b⌋
[PROOFSTEP]
rw [le_floor, Int.cast_add]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ ↑⌊a⌋ + ↑⌊b⌋ ≤ a + b
[PROOFSTEP]
exact add_le_add (floor_le _) (floor_le _)
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ ⌊a + b⌋ - 1 ≤ ⌊a⌋ + ⌊b⌋
[PROOFSTEP]
rw [← sub_le_iff_le_add, le_floor, Int.cast_sub, sub_le_comm, Int.cast_sub, Int.cast_one]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ ↑⌊a + b⌋ - 1 - a ≤ ↑⌊b⌋
[PROOFSTEP]
refine' le_trans _ (sub_one_lt_floor _).le
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ ↑⌊a + b⌋ - 1 - a ≤ b - 1
[PROOFSTEP]
rw [sub_le_iff_le_add', ← add_sub_assoc, sub_le_sub_iff_right]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ ↑⌊a + b⌋ ≤ a + b
[PROOFSTEP]
exact floor_le _
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a✝ : α
z : ℤ
a : α
⊢ ⌊↑z + a⌋ = z + ⌊a⌋
[PROOFSTEP]
simpa only [add_comm] using floor_add_int a z
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
n : ℕ
⊢ ⌊a + ↑n⌋ = ⌊a⌋ + ↑n
[PROOFSTEP]
rw [← Int.cast_ofNat, floor_add_int]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ : α
n : ℕ
a : α
⊢ ⌊↑n + a⌋ = ↑n + ⌊a⌋
[PROOFSTEP]
rw [← Int.cast_ofNat, floor_int_add]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a✝ a : α
z : ℤ
⊢ ⌊a - ↑z⌋ = ⌊a + ↑(-z)⌋
[PROOFSTEP]
rw [Int.cast_neg, sub_eq_add_neg]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
n : ℕ
⊢ ⌊a - ↑n⌋ = ⌊a⌋ - ↑n
[PROOFSTEP]
rw [← Int.cast_ofNat, floor_sub_int]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
⊢ ⌊a - 1⌋ = ⌊a⌋ - 1
[PROOFSTEP]
exact_mod_cast floor_sub_nat a 1
[GOAL]
F : Type u_1
α✝ : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α✝
inst✝² : FloorRing α✝
z : ℤ
a✝ : α✝
α : Type u_4
inst✝¹ : LinearOrderedCommRing α
inst✝ : FloorRing α
a b : α
h : ⌊a⌋ = ⌊b⌋
⊢ |a - b| < 1
[PROOFSTEP]
have : a < ⌊a⌋ + 1 := lt_floor_add_one a
[GOAL]
F : Type u_1
α✝ : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α✝
inst✝² : FloorRing α✝
z : ℤ
a✝ : α✝
α : Type u_4
inst✝¹ : LinearOrderedCommRing α
inst✝ : FloorRing α
a b : α
h : ⌊a⌋ = ⌊b⌋
this : a < ↑⌊a⌋ + 1
⊢ |a - b| < 1
[PROOFSTEP]
have : b < ⌊b⌋ + 1 := lt_floor_add_one b
[GOAL]
F : Type u_1
α✝ : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α✝
inst✝² : FloorRing α✝
z : ℤ
a✝ : α✝
α : Type u_4
inst✝¹ : LinearOrderedCommRing α
inst✝ : FloorRing α
a b : α
h : ⌊a⌋ = ⌊b⌋
this✝ : a < ↑⌊a⌋ + 1
this : b < ↑⌊b⌋ + 1
⊢ |a - b| < 1
[PROOFSTEP]
have : (⌊a⌋ : α) = ⌊b⌋ := Int.cast_inj.2 h
[GOAL]
F : Type u_1
α✝ : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α✝
inst✝² : FloorRing α✝
z : ℤ
a✝ : α✝
α : Type u_4
inst✝¹ : LinearOrderedCommRing α
inst✝ : FloorRing α
a b : α
h : ⌊a⌋ = ⌊b⌋
this✝¹ : a < ↑⌊a⌋ + 1
this✝ : b < ↑⌊b⌋ + 1
this : ↑⌊a⌋ = ↑⌊b⌋
⊢ |a - b| < 1
[PROOFSTEP]
have : (⌊a⌋ : α) ≤ a := floor_le a
[GOAL]
F : Type u_1
α✝ : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α✝
inst✝² : FloorRing α✝
z : ℤ
a✝ : α✝
α : Type u_4
inst✝¹ : LinearOrderedCommRing α
inst✝ : FloorRing α
a b : α
h : ⌊a⌋ = ⌊b⌋
this✝² : a < ↑⌊a⌋ + 1
this✝¹ : b < ↑⌊b⌋ + 1
this✝ : ↑⌊a⌋ = ↑⌊b⌋
this : ↑⌊a⌋ ≤ a
⊢ |a - b| < 1
[PROOFSTEP]
have : (⌊b⌋ : α) ≤ b := floor_le b
[GOAL]
F : Type u_1
α✝ : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α✝
inst✝² : FloorRing α✝
z : ℤ
a✝ : α✝
α : Type u_4
inst✝¹ : LinearOrderedCommRing α
inst✝ : FloorRing α
a b : α
h : ⌊a⌋ = ⌊b⌋
this✝³ : a < ↑⌊a⌋ + 1
this✝² : b < ↑⌊b⌋ + 1
this✝¹ : ↑⌊a⌋ = ↑⌊b⌋
this✝ : ↑⌊a⌋ ≤ a
this : ↑⌊b⌋ ≤ b
⊢ |a - b| < 1
[PROOFSTEP]
exact abs_sub_lt_iff.2 ⟨by linarith, by linarith⟩
[GOAL]
F : Type u_1
α✝ : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α✝
inst✝² : FloorRing α✝
z : ℤ
a✝ : α✝
α : Type u_4
inst✝¹ : LinearOrderedCommRing α
inst✝ : FloorRing α
a b : α
h : ⌊a⌋ = ⌊b⌋
this✝³ : a < ↑⌊a⌋ + 1
this✝² : b < ↑⌊b⌋ + 1
this✝¹ : ↑⌊a⌋ = ↑⌊b⌋
this✝ : ↑⌊a⌋ ≤ a
this : ↑⌊b⌋ ≤ b
⊢ a - b < 1
[PROOFSTEP]
linarith
[GOAL]
F : Type u_1
α✝ : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α✝
inst✝² : FloorRing α✝
z : ℤ
a✝ : α✝
α : Type u_4
inst✝¹ : LinearOrderedCommRing α
inst✝ : FloorRing α
a b : α
h : ⌊a⌋ = ⌊b⌋
this✝³ : a < ↑⌊a⌋ + 1
this✝² : b < ↑⌊b⌋ + 1
this✝¹ : ↑⌊a⌋ = ↑⌊b⌋
this✝ : ↑⌊a⌋ ≤ a
this : ↑⌊b⌋ ≤ b
⊢ b - a < 1
[PROOFSTEP]
linarith
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ ⌊a⌋ = z ↔ ↑z ≤ a ∧ a < ↑z + 1
[PROOFSTEP]
rw [le_antisymm_iff, le_floor, ← Int.lt_add_one_iff, floor_lt, Int.cast_add, Int.cast_one, and_comm]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ ⌊a⌋ = 0 ↔ a ∈ Ico 0 1
[PROOFSTEP]
simp [floor_eq_iff]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
m : ℤ
⊢ fract (a + ↑m) = fract a
[PROOFSTEP]
rw [fract]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
m : ℤ
⊢ a + ↑m - ↑⌊a + ↑m⌋ = fract a
[PROOFSTEP]
simp
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
m : ℕ
⊢ fract (a + ↑m) = fract a
[PROOFSTEP]
rw [fract]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
m : ℕ
⊢ a + ↑m - ↑⌊a + ↑m⌋ = fract a
[PROOFSTEP]
simp
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
⊢ fract (a + 1) = fract a
[PROOFSTEP]
exact_mod_cast fract_add_nat a 1
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ : α
m : ℤ
a : α
⊢ fract (↑m + a) = fract a
[PROOFSTEP]
rw [add_comm, fract_add_int]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ : α
n : ℕ
a : α
⊢ fract (↑n + a) = fract a
[PROOFSTEP]
rw [add_comm, fract_add_nat]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
⊢ fract (1 + a) = fract a
[PROOFSTEP]
exact_mod_cast fract_nat_add 1 a
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
m : ℤ
⊢ fract (a - ↑m) = fract a
[PROOFSTEP]
rw [fract]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
m : ℤ
⊢ a - ↑m - ↑⌊a - ↑m⌋ = fract a
[PROOFSTEP]
simp
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
n : ℕ
⊢ fract (a - ↑n) = fract a
[PROOFSTEP]
rw [fract]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
n : ℕ
⊢ a - ↑n - ↑⌊a - ↑n⌋ = fract a
[PROOFSTEP]
simp
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
⊢ fract (a - 1) = fract a
[PROOFSTEP]
exact_mod_cast fract_sub_nat a 1
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ fract (a + b) ≤ fract a + fract b
[PROOFSTEP]
rw [fract, fract, fract, sub_add_sub_comm, sub_le_sub_iff_left, ← Int.cast_add, Int.cast_le]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ ⌊a⌋ + ⌊b⌋ ≤ ⌊a + b⌋
[PROOFSTEP]
exact le_floor_add _ _
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ fract a + fract b ≤ fract (a + b) + 1
[PROOFSTEP]
rw [fract, fract, fract, sub_add_sub_comm, sub_add, sub_le_sub_iff_left]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ ↑⌊a + b⌋ - 1 ≤ ↑⌊a⌋ + ↑⌊b⌋
[PROOFSTEP]
exact_mod_cast le_floor_add_floor a b
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ fract 0 = 0
[PROOFSTEP]
rw [fract, floor_zero, cast_zero, sub_self]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ fract 1 = 0
[PROOFSTEP]
simp [fract]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a : α
z : ℤ
⊢ fract ↑z = 0
[PROOFSTEP]
unfold fract
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a : α
z : ℤ
⊢ ↑z - ↑⌊↑z⌋ = 0
[PROOFSTEP]
rw [floor_intCast]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a : α
z : ℤ
⊢ ↑z - ↑z = 0
[PROOFSTEP]
exact sub_self _
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
n : ℕ
⊢ fract ↑n = 0
[PROOFSTEP]
simp [fract]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
⊢ ⌊fract a⌋ = 0
[PROOFSTEP]
rw [floor_eq_iff, Int.cast_zero, zero_add]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
⊢ 0 ≤ fract a ∧ fract a < 1
[PROOFSTEP]
exact ⟨fract_nonneg _, fract_lt_one _⟩
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
h : fract a = b
⊢ 0 ≤ b ∧ b < 1 ∧ ∃ z, a - b = ↑z
[PROOFSTEP]
rw [← h]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
h : fract a = b
⊢ 0 ≤ fract a ∧ fract a < 1 ∧ ∃ z, a - fract a = ↑z
[PROOFSTEP]
exact ⟨fract_nonneg _, fract_lt_one _, ⟨⌊a⌋, sub_sub_cancel _ _⟩⟩
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ (0 ≤ b ∧ b < 1 ∧ ∃ z, a - b = ↑z) → fract a = b
[PROOFSTEP]
rintro ⟨h₀, h₁, z, hz⟩
[GOAL]
case intro.intro.intro
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a✝ a b : α
h₀ : 0 ≤ b
h₁ : b < 1
z : ℤ
hz : a - b = ↑z
⊢ fract a = b
[PROOFSTEP]
rw [← self_sub_floor, eq_comm, eq_sub_iff_add_eq, add_comm, ← eq_sub_iff_add_eq, hz, Int.cast_inj, floor_eq_iff, ← hz]
[GOAL]
case intro.intro.intro
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a✝ a b : α
h₀ : 0 ≤ b
h₁ : b < 1
z : ℤ
hz : a - b = ↑z
⊢ a - b ≤ a ∧ a < a - b + 1
[PROOFSTEP]
constructor
[GOAL]
case intro.intro.intro.left
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a✝ a b : α
h₀ : 0 ≤ b
h₁ : b < 1
z : ℤ
hz : a - b = ↑z
⊢ a - b ≤ a
[PROOFSTEP]
simpa [sub_eq_add_neg, add_assoc]
[GOAL]
case intro.intro.intro.right
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a✝ a b : α
h₀ : 0 ≤ b
h₁ : b < 1
z : ℤ
hz : a - b = ↑z
⊢ a < a - b + 1
[PROOFSTEP]
simpa [sub_eq_add_neg, add_assoc]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
h : fract a = fract b
⊢ a - b = ↑(⌊a⌋ - ⌊b⌋)
[PROOFSTEP]
unfold fract at h 
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
h : a - ↑⌊a⌋ = b - ↑⌊b⌋
⊢ a - b = ↑(⌊a⌋ - ⌊b⌋)
[PROOFSTEP]
rw [Int.cast_sub, sub_eq_sub_iff_sub_eq_sub.1 h]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ (∃ z, a - b = ↑z) → fract a = fract b
[PROOFSTEP]
rintro ⟨z, hz⟩
[GOAL]
case intro
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a✝ a b : α
z : ℤ
hz : a - b = ↑z
⊢ fract a = fract b
[PROOFSTEP]
refine' fract_eq_iff.2 ⟨fract_nonneg _, fract_lt_one _, z + ⌊b⌋, _⟩
[GOAL]
case intro
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a✝ a b : α
z : ℤ
hz : a - b = ↑z
⊢ a - fract b = ↑(z + ⌊b⌋)
[PROOFSTEP]
rw [eq_add_of_sub_eq hz, add_comm, Int.cast_add]
[GOAL]
case intro
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a✝ a b : α
z : ℤ
hz : a - b = ↑z
⊢ b + ↑z - fract b = ↑z + ↑⌊b⌋
[PROOFSTEP]
exact add_sub_sub_cancel _ _ _
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
⊢ a - a = ↑0
[PROOFSTEP]
simp
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ fract (a + b) - fract a - fract b = ↑(⌊a⌋ + ⌊b⌋ - ⌊a + b⌋)
[PROOFSTEP]
unfold fract
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ a + b - ↑⌊a + b⌋ - (a - ↑⌊a⌋) - (b - ↑⌊b⌋) = ↑(⌊a⌋ + ⌊b⌋ - ⌊a + b⌋)
[PROOFSTEP]
simp [sub_eq_add_neg]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ a + b + -↑⌊a + b⌋ + (↑⌊a⌋ + -a) + (↑⌊b⌋ + -b) = ↑⌊a⌋ + ↑⌊b⌋ + -↑⌊a + b⌋
[PROOFSTEP]
abel
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ a + b + -↑⌊a + b⌋ + (↑⌊a⌋ + -a) + (↑⌊b⌋ + -b) = ↑⌊a⌋ + ↑⌊b⌋ + -↑⌊a + b⌋
[PROOFSTEP]
abel
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a x : α
hx : fract x ≠ 0
⊢ fract (-x) = 1 - fract x
[PROOFSTEP]
rw [fract_eq_iff]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a x : α
hx : fract x ≠ 0
⊢ 0 ≤ 1 - fract x ∧ 1 - fract x < 1 ∧ ∃ z, -x - (1 - fract x) = ↑z
[PROOFSTEP]
constructor
[GOAL]
case left
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a x : α
hx : fract x ≠ 0
⊢ 0 ≤ 1 - fract x
[PROOFSTEP]
rw [le_sub_iff_add_le, zero_add]
[GOAL]
case left
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a x : α
hx : fract x ≠ 0
⊢ fract x ≤ 1
[PROOFSTEP]
exact (fract_lt_one x).le
[GOAL]
case right
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a x : α
hx : fract x ≠ 0
⊢ 1 - fract x < 1 ∧ ∃ z, -x - (1 - fract x) = ↑z
[PROOFSTEP]
refine' ⟨sub_lt_self _ (lt_of_le_of_ne' (fract_nonneg x) hx), -⌊x⌋ - 1, _⟩
[GOAL]
case right
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a x : α
hx : fract x ≠ 0
⊢ -x - (1 - fract x) = ↑(-⌊x⌋ - 1)
[PROOFSTEP]
simp only [sub_sub_eq_add_sub, cast_sub, cast_neg, cast_one, sub_left_inj]
[GOAL]
case right
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a x : α
hx : fract x ≠ 0
⊢ -x + fract x = -↑⌊x⌋
[PROOFSTEP]
conv in -x => rw [← floor_add_fract x]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a x : α
hx : fract x ≠ 0
| -x
[PROOFSTEP]
rw [← floor_add_fract x]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a x : α
hx : fract x ≠ 0
| -x
[PROOFSTEP]
rw [← floor_add_fract x]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a x : α
hx : fract x ≠ 0
| -x
[PROOFSTEP]
rw [← floor_add_fract x]
[GOAL]
case right
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a x : α
hx : fract x ≠ 0
⊢ -(↑⌊x⌋ + fract x) + fract x = -↑⌊x⌋
[PROOFSTEP]
simp [-floor_add_fract]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a x : α
⊢ fract (-x) = 0 ↔ fract x = 0
[PROOFSTEP]
simp only [fract_eq_iff, le_refl, zero_lt_one, tsub_zero, true_and_iff]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a x : α
⊢ (∃ z, -x = ↑z) ↔ ∃ z, x = ↑z
[PROOFSTEP]
constructor
[GOAL]
case mp
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a x : α
⊢ (∃ z, -x = ↑z) → ∃ z, x = ↑z
[PROOFSTEP]
rintro ⟨z, hz⟩
[GOAL]
case mpr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a x : α
⊢ (∃ z, x = ↑z) → ∃ z, -x = ↑z
[PROOFSTEP]
rintro ⟨z, hz⟩
[GOAL]
case mp.intro
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a x : α
z : ℤ
hz : -x = ↑z
⊢ ∃ z, x = ↑z
[PROOFSTEP]
use-z
[GOAL]
case mpr.intro
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a x : α
z : ℤ
hz : x = ↑z
⊢ ∃ z, -x = ↑z
[PROOFSTEP]
use-z
[GOAL]
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a x : α
z : ℤ
hz : -x = ↑z
⊢ x = ↑(-z)
[PROOFSTEP]
simp [← hz]
[GOAL]
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a x : α
z : ℤ
hz : x = ↑z
⊢ -x = ↑(-z)
[PROOFSTEP]
simp [← hz]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
b : ℕ
⊢ ∃ z, fract a * ↑b - fract (a * ↑b) = ↑z
[PROOFSTEP]
induction' b with c hc
[GOAL]
case zero
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
⊢ ∃ z, fract a * ↑Nat.zero - fract (a * ↑Nat.zero) = ↑z
[PROOFSTEP]
use 0
[GOAL]
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
⊢ fract a * ↑Nat.zero - fract (a * ↑Nat.zero) = ↑0
[PROOFSTEP]
simp
[GOAL]
case succ
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
c : ℕ
hc : ∃ z, fract a * ↑c - fract (a * ↑c) = ↑z
⊢ ∃ z, fract a * ↑(Nat.succ c) - fract (a * ↑(Nat.succ c)) = ↑z
[PROOFSTEP]
rcases hc with ⟨z, hz⟩
[GOAL]
case succ.intro
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a✝ a : α
c : ℕ
z : ℤ
hz : fract a * ↑c - fract (a * ↑c) = ↑z
⊢ ∃ z, fract a * ↑(Nat.succ c) - fract (a * ↑(Nat.succ c)) = ↑z
[PROOFSTEP]
rw [Nat.succ_eq_add_one, Nat.cast_add, mul_add, mul_add, Nat.cast_one, mul_one, mul_one]
[GOAL]
case succ.intro
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a✝ a : α
c : ℕ
z : ℤ
hz : fract a * ↑c - fract (a * ↑c) = ↑z
⊢ ∃ z, fract a * ↑c + fract a - fract (a * ↑c + a) = ↑z
[PROOFSTEP]
rcases fract_add (a * c) a with ⟨y, hy⟩
[GOAL]
case succ.intro.intro
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a✝ a : α
c : ℕ
z : ℤ
hz : fract a * ↑c - fract (a * ↑c) = ↑z
y : ℤ
hy : fract (a * ↑c + a) - fract (a * ↑c) - fract a = ↑y
⊢ ∃ z, fract a * ↑c + fract a - fract (a * ↑c + a) = ↑z
[PROOFSTEP]
use z - y
[GOAL]
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a✝ a : α
c : ℕ
z : ℤ
hz : fract a * ↑c - fract (a * ↑c) = ↑z
y : ℤ
hy : fract (a * ↑c + a) - fract (a * ↑c) - fract a = ↑y
⊢ fract a * ↑c + fract a - fract (a * ↑c + a) = ↑(z - y)
[PROOFSTEP]
rw [Int.cast_sub, ← hz, ← hy]
[GOAL]
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a✝ a : α
c : ℕ
z : ℤ
hz : fract a * ↑c - fract (a * ↑c) = ↑z
y : ℤ
hy : fract (a * ↑c + a) - fract (a * ↑c) - fract a = ↑y
⊢ fract a * ↑c + fract a - fract (a * ↑c + a) =
    fract a * ↑c - fract (a * ↑c) - (fract (a * ↑c + a) - fract (a * ↑c) - fract a)
[PROOFSTEP]
abel
[GOAL]
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a✝ a : α
c : ℕ
z : ℤ
hz : fract a * ↑c - fract (a * ↑c) = ↑z
y : ℤ
hy : fract (a * ↑c + a) - fract (a * ↑c) - fract a = ↑y
⊢ fract a * ↑c + fract a - fract (a * ↑c + a) =
    fract a * ↑c - fract (a * ↑c) - (fract (a * ↑c + a) - fract (a * ↑c) - fract a)
[PROOFSTEP]
abel
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
s : Set α
⊢ fract ⁻¹' s = ⋃ (m : ℤ), (fun x => x - ↑m) ⁻¹' (s ∩ Ico 0 1)
[PROOFSTEP]
ext x
[GOAL]
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
s : Set α
x : α
⊢ x ∈ fract ⁻¹' s ↔ x ∈ ⋃ (m : ℤ), (fun x => x - ↑m) ⁻¹' (s ∩ Ico 0 1)
[PROOFSTEP]
simp only [mem_preimage, mem_iUnion, mem_inter_iff]
[GOAL]
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
s : Set α
x : α
⊢ fract x ∈ s ↔ ∃ i, x - ↑i ∈ s ∧ x - ↑i ∈ Ico 0 1
[PROOFSTEP]
refine' ⟨fun h => ⟨⌊x⌋, h, fract_nonneg x, fract_lt_one x⟩, _⟩
[GOAL]
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
s : Set α
x : α
⊢ (∃ i, x - ↑i ∈ s ∧ x - ↑i ∈ Ico 0 1) → fract x ∈ s
[PROOFSTEP]
rintro ⟨m, hms, hm0, hm1⟩
[GOAL]
case h.intro.intro.intro
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
s : Set α
x : α
m : ℤ
hms : x - ↑m ∈ s
hm0 : 0 ≤ x - ↑m
hm1 : x - ↑m < 1
⊢ fract x ∈ s
[PROOFSTEP]
obtain rfl : ⌊x⌋ = m := floor_eq_iff.2 ⟨sub_nonneg.1 hm0, sub_lt_iff_lt_add'.1 hm1⟩
[GOAL]
case h.intro.intro.intro
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
s : Set α
x : α
hms : x - ↑⌊x⌋ ∈ s
hm0 : 0 ≤ x - ↑⌊x⌋
hm1 : x - ↑⌊x⌋ < 1
⊢ fract x ∈ s
[PROOFSTEP]
exact hms
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
s : Set α
⊢ fract '' s = ⋃ (m : ℤ), (fun x => x - ↑m) '' s ∩ Ico 0 1
[PROOFSTEP]
ext x
[GOAL]
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
s : Set α
x : α
⊢ x ∈ fract '' s ↔ x ∈ ⋃ (m : ℤ), (fun x => x - ↑m) '' s ∩ Ico 0 1
[PROOFSTEP]
simp only [mem_image, mem_inter_iff, mem_iUnion]
[GOAL]
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
s : Set α
x : α
⊢ (∃ x_1, x_1 ∈ s ∧ fract x_1 = x) ↔ ∃ i, (∃ x_1, x_1 ∈ s ∧ x_1 - ↑i = x) ∧ x ∈ Ico 0 1
[PROOFSTEP]
constructor
[GOAL]
case h.mp
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
s : Set α
x : α
⊢ (∃ x_1, x_1 ∈ s ∧ fract x_1 = x) → ∃ i, (∃ x_1, x_1 ∈ s ∧ x_1 - ↑i = x) ∧ x ∈ Ico 0 1
[PROOFSTEP]
rintro ⟨y, hy, rfl⟩
[GOAL]
case h.mp.intro.intro
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
s : Set α
y : α
hy : y ∈ s
⊢ ∃ i, (∃ x, x ∈ s ∧ x - ↑i = fract y) ∧ fract y ∈ Ico 0 1
[PROOFSTEP]
exact ⟨⌊y⌋, ⟨y, hy, rfl⟩, fract_nonneg y, fract_lt_one y⟩
[GOAL]
case h.mpr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
s : Set α
x : α
⊢ (∃ i, (∃ x_1, x_1 ∈ s ∧ x_1 - ↑i = x) ∧ x ∈ Ico 0 1) → ∃ x_1, x_1 ∈ s ∧ fract x_1 = x
[PROOFSTEP]
rintro ⟨m, ⟨y, hys, rfl⟩, h0, h1⟩
[GOAL]
case h.mpr.intro.intro.intro.intro.intro
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
s : Set α
m : ℤ
y : α
hys : y ∈ s
h0 : 0 ≤ y - ↑m
h1 : y - ↑m < 1
⊢ ∃ x, x ∈ s ∧ fract x = y - ↑m
[PROOFSTEP]
obtain rfl : ⌊y⌋ = m := floor_eq_iff.2 ⟨sub_nonneg.1 h0, sub_lt_iff_lt_add'.1 h1⟩
[GOAL]
case h.mpr.intro.intro.intro.intro.intro
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
s : Set α
y : α
hys : y ∈ s
h0 : 0 ≤ y - ↑⌊y⌋
h1 : y - ↑⌊y⌋ < 1
⊢ ∃ x, x ∈ s ∧ fract x = y - ↑⌊y⌋
[PROOFSTEP]
exact ⟨y, hys, rfl⟩
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a✝ : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b✝ a b : k
ha : a ≠ 0
⊢ fract (b / a) * a + ⌊b / a⌋ • a = b
[PROOFSTEP]
rw [zsmul_eq_mul, ← add_mul, fract_add_floor, div_mul_cancel b ha]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a✝ : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b a : k
hb : 0 < b
⊢ a < b + ↑⌊a / b⌋ * b
[PROOFSTEP]
rw [← one_add_mul _ b, ← div_lt_iff hb, add_comm]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a✝ : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b a : k
hb : 0 < b
⊢ a / b < ↑⌊a / b⌋ + 1
[PROOFSTEP]
exact lt_floor_add_one _
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
m n : ℕ
⊢ fract (↑m / ↑n) = ↑(m % n) / ↑n
[PROOFSTEP]
rcases n.eq_zero_or_pos with (rfl | hn)
[GOAL]
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
m : ℕ
⊢ fract (↑m / ↑0) = ↑(m % 0) / ↑0
[PROOFSTEP]
simp
[GOAL]
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
m n : ℕ
hn : n > 0
⊢ fract (↑m / ↑n) = ↑(m % n) / ↑n
[PROOFSTEP]
have hn' : 0 < (n : k) := by norm_cast
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
m n : ℕ
hn : n > 0
⊢ 0 < ↑n
[PROOFSTEP]
norm_cast
[GOAL]
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
m n : ℕ
hn : n > 0
hn' : 0 < ↑n
⊢ fract (↑m / ↑n) = ↑(m % n) / ↑n
[PROOFSTEP]
refine fract_eq_iff.mpr ⟨?_, ?_, m / n, ?_⟩
[GOAL]
case inr.refine_1
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
m n : ℕ
hn : n > 0
hn' : 0 < ↑n
⊢ 0 ≤ ↑(m % n) / ↑n
[PROOFSTEP]
positivity
[GOAL]
case inr.refine_2
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
m n : ℕ
hn : n > 0
hn' : 0 < ↑n
⊢ ↑(m % n) / ↑n < 1
[PROOFSTEP]
simpa only [div_lt_one hn', Nat.cast_lt] using m.mod_lt hn
[GOAL]
case inr.refine_3
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
m n : ℕ
hn : n > 0
hn' : 0 < ↑n
⊢ ↑m / ↑n - ↑(m % n) / ↑n = ↑(↑m / ↑n)
[PROOFSTEP]
rw [sub_eq_iff_eq_add', ← mul_right_inj' hn'.ne', mul_div_cancel' _ hn'.ne', mul_add, mul_div_cancel' _ hn'.ne']
[GOAL]
case inr.refine_3
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
m n : ℕ
hn : n > 0
hn' : 0 < ↑n
⊢ ↑m = ↑(m % n) + ↑n * ↑(↑m / ↑n)
[PROOFSTEP]
norm_cast
[GOAL]
case inr.refine_3
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
m n : ℕ
hn : n > 0
hn' : 0 < ↑n
⊢ ↑m = ↑(m % n) + ↑(n * (m / n))
[PROOFSTEP]
rw [← Nat.cast_add, Nat.mod_add_div m n]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
m : ℤ
n : ℕ
⊢ fract (↑m / ↑n) = ↑(m % ↑n) / ↑n
[PROOFSTEP]
rcases n.eq_zero_or_pos with (rfl | hn)
[GOAL]
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
m : ℤ
⊢ fract (↑m / ↑0) = ↑(m % ↑0) / ↑0
[PROOFSTEP]
simp
[GOAL]
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
m : ℤ
n : ℕ
hn : n > 0
⊢ fract (↑m / ↑n) = ↑(m % ↑n) / ↑n
[PROOFSTEP]
replace hn : 0 < (n : k)
[GOAL]
case hn
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
m : ℤ
n : ℕ
hn : n > 0
⊢ 0 < ↑n
[PROOFSTEP]
norm_cast
[GOAL]
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
m : ℤ
n : ℕ
hn : 0 < ↑n
⊢ fract (↑m / ↑n) = ↑(m % ↑n) / ↑n
[PROOFSTEP]
have : ∀ {l : ℤ}, 0 ≤ l → fract ((l : k) / n) = ↑(l % n) / n :=
  by
  intros l hl
  obtain ⟨l₀, rfl | rfl⟩ := l.eq_nat_or_neg
  · rw [cast_ofNat, ← coe_nat_mod, cast_ofNat, fract_div_natCast_eq_div_natCast_mod]
  · rw [Right.nonneg_neg_iff, coe_nat_nonpos_iff] at hl 
    simp [hl, zero_mod]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
m : ℤ
n : ℕ
hn : 0 < ↑n
⊢ ∀ {l : ℤ}, 0 ≤ l → fract (↑l / ↑n) = ↑(l % ↑n) / ↑n
[PROOFSTEP]
intros l hl
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
m : ℤ
n : ℕ
hn : 0 < ↑n
l : ℤ
hl : 0 ≤ l
⊢ fract (↑l / ↑n) = ↑(l % ↑n) / ↑n
[PROOFSTEP]
obtain ⟨l₀, rfl | rfl⟩ := l.eq_nat_or_neg
[GOAL]
case intro.inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
m : ℤ
n : ℕ
hn : 0 < ↑n
l₀ : ℕ
hl : 0 ≤ ↑l₀
⊢ fract (↑↑l₀ / ↑n) = ↑(↑l₀ % ↑n) / ↑n
[PROOFSTEP]
rw [cast_ofNat, ← coe_nat_mod, cast_ofNat, fract_div_natCast_eq_div_natCast_mod]
[GOAL]
case intro.inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
m : ℤ
n : ℕ
hn : 0 < ↑n
l₀ : ℕ
hl : 0 ≤ -↑l₀
⊢ fract (↑(-↑l₀) / ↑n) = ↑(-↑l₀ % ↑n) / ↑n
[PROOFSTEP]
rw [Right.nonneg_neg_iff, coe_nat_nonpos_iff] at hl 
[GOAL]
case intro.inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
m : ℤ
n : ℕ
hn : 0 < ↑n
l₀ : ℕ
hl : l₀ = 0
⊢ fract (↑(-↑l₀) / ↑n) = ↑(-↑l₀ % ↑n) / ↑n
[PROOFSTEP]
simp [hl, zero_mod]
[GOAL]
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
m : ℤ
n : ℕ
hn : 0 < ↑n
this : ∀ {l : ℤ}, 0 ≤ l → fract (↑l / ↑n) = ↑(l % ↑n) / ↑n
⊢ fract (↑m / ↑n) = ↑(m % ↑n) / ↑n
[PROOFSTEP]
obtain ⟨m₀, rfl | rfl⟩ := m.eq_nat_or_neg
[GOAL]
case inr.intro.inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
n : ℕ
hn : 0 < ↑n
this : ∀ {l : ℤ}, 0 ≤ l → fract (↑l / ↑n) = ↑(l % ↑n) / ↑n
m₀ : ℕ
⊢ fract (↑↑m₀ / ↑n) = ↑(↑m₀ % ↑n) / ↑n
[PROOFSTEP]
exact this (ofNat_nonneg m₀)
[GOAL]
case inr.intro.inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
n : ℕ
hn : 0 < ↑n
this : ∀ {l : ℤ}, 0 ≤ l → fract (↑l / ↑n) = ↑(l % ↑n) / ↑n
m₀ : ℕ
⊢ fract (↑(-↑m₀) / ↑n) = ↑(-↑m₀ % ↑n) / ↑n
[PROOFSTEP]
let q := ⌈↑m₀ / (n : k)⌉
[GOAL]
case inr.intro.inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
n : ℕ
hn : 0 < ↑n
this : ∀ {l : ℤ}, 0 ≤ l → fract (↑l / ↑n) = ↑(l % ↑n) / ↑n
m₀ : ℕ
q : ℤ := ⌈↑m₀ / ↑n⌉
⊢ fract (↑(-↑m₀) / ↑n) = ↑(-↑m₀ % ↑n) / ↑n
[PROOFSTEP]
let m₁ := q * ↑n - (↑m₀ : ℤ)
[GOAL]
case inr.intro.inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
n : ℕ
hn : 0 < ↑n
this : ∀ {l : ℤ}, 0 ≤ l → fract (↑l / ↑n) = ↑(l % ↑n) / ↑n
m₀ : ℕ
q : ℤ := ⌈↑m₀ / ↑n⌉
m₁ : ℤ := q * ↑n - ↑m₀
⊢ fract (↑(-↑m₀) / ↑n) = ↑(-↑m₀ % ↑n) / ↑n
[PROOFSTEP]
have hm₁ : 0 ≤ m₁ := by simpa [← @cast_le k, ← div_le_iff hn] using FloorRing.gc_ceil_coe.le_u_l _
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
n : ℕ
hn : 0 < ↑n
this : ∀ {l : ℤ}, 0 ≤ l → fract (↑l / ↑n) = ↑(l % ↑n) / ↑n
m₀ : ℕ
q : ℤ := ⌈↑m₀ / ↑n⌉
m₁ : ℤ := q * ↑n - ↑m₀
⊢ 0 ≤ m₁
[PROOFSTEP]
simpa [← @cast_le k, ← div_le_iff hn] using FloorRing.gc_ceil_coe.le_u_l _
[GOAL]
case inr.intro.inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
n : ℕ
hn : 0 < ↑n
this : ∀ {l : ℤ}, 0 ≤ l → fract (↑l / ↑n) = ↑(l % ↑n) / ↑n
m₀ : ℕ
q : ℤ := ⌈↑m₀ / ↑n⌉
m₁ : ℤ := q * ↑n - ↑m₀
hm₁ : 0 ≤ m₁
⊢ fract (↑(-↑m₀) / ↑n) = ↑(-↑m₀ % ↑n) / ↑n
[PROOFSTEP]
calc
  fract
        ((Int.cast (-(m₀ : ℤ)) : k) / (n : k))
          -- Porting note: the `rw [cast_neg, cast_ofNat]` was `push_cast` =
      fract (-(m₀ : k) / n) :=
    by rw [cast_neg, cast_ofNat]
  _ = fract ((m₁ : k) / n) := ?_
  _ = Int.cast (m₁ % (n : ℤ)) / Nat.cast n := (this hm₁)
  _ = Int.cast (-(↑m₀ : ℤ) % ↑n) / Nat.cast n := ?_
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
n : ℕ
hn : 0 < ↑n
this : ∀ {l : ℤ}, 0 ≤ l → fract (↑l / ↑n) = ↑(l % ↑n) / ↑n
m₀ : ℕ
q : ℤ := ⌈↑m₀ / ↑n⌉
m₁ : ℤ := q * ↑n - ↑m₀
hm₁ : 0 ≤ m₁
⊢ fract (↑(-↑m₀) / ↑n) = fract (-↑m₀ / ↑n)
[PROOFSTEP]
rw [cast_neg, cast_ofNat]
[GOAL]
case inr.intro.inr.calc_1
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
n : ℕ
hn : 0 < ↑n
this : ∀ {l : ℤ}, 0 ≤ l → fract (↑l / ↑n) = ↑(l % ↑n) / ↑n
m₀ : ℕ
q : ℤ := ⌈↑m₀ / ↑n⌉
m₁ : ℤ := q * ↑n - ↑m₀
hm₁ : 0 ≤ m₁
⊢ fract (-↑m₀ / ↑n) = fract (↑m₁ / ↑n)
[PROOFSTEP]
rw [← fract_int_add q, ← mul_div_cancel (q : k) (ne_of_gt hn), ← add_div, ← sub_eq_add_neg]
  -- Porting note: the `simp` was `push_cast`
[GOAL]
case inr.intro.inr.calc_1
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
n : ℕ
hn : 0 < ↑n
this : ∀ {l : ℤ}, 0 ≤ l → fract (↑l / ↑n) = ↑(l % ↑n) / ↑n
m₀ : ℕ
q : ℤ := ⌈↑m₀ / ↑n⌉
m₁ : ℤ := q * ↑n - ↑m₀
hm₁ : 0 ≤ m₁
⊢ fract ((↑q * ↑n - ↑m₀) / ↑n) = fract (↑m₁ / ↑n)
[PROOFSTEP]
simp
[GOAL]
case inr.intro.inr.calc_2
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
n : ℕ
hn : 0 < ↑n
this : ∀ {l : ℤ}, 0 ≤ l → fract (↑l / ↑n) = ↑(l % ↑n) / ↑n
m₀ : ℕ
q : ℤ := ⌈↑m₀ / ↑n⌉
m₁ : ℤ := q * ↑n - ↑m₀
hm₁ : 0 ≤ m₁
⊢ ↑(m₁ % ↑n) / ↑n = ↑(-↑m₀ % ↑n) / ↑n
[PROOFSTEP]
congr 2
[GOAL]
case inr.intro.inr.calc_2.e_a.e_a
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
n : ℕ
hn : 0 < ↑n
this : ∀ {l : ℤ}, 0 ≤ l → fract (↑l / ↑n) = ↑(l % ↑n) / ↑n
m₀ : ℕ
q : ℤ := ⌈↑m₀ / ↑n⌉
m₁ : ℤ := q * ↑n - ↑m₀
hm₁ : 0 ≤ m₁
⊢ m₁ % ↑n = -↑m₀ % ↑n
[PROOFSTEP]
change (q * ↑n - (↑m₀ : ℤ)) % ↑n = _
[GOAL]
case inr.intro.inr.calc_2.e_a.e_a
F : Type u_1
α : Type u_2
β : Type u_3
inst✝³ : LinearOrderedRing α
inst✝² : FloorRing α
z : ℤ
a : α
k : Type u_4
inst✝¹ : LinearOrderedField k
inst✝ : FloorRing k
b : k
n : ℕ
hn : 0 < ↑n
this : ∀ {l : ℤ}, 0 ≤ l → fract (↑l / ↑n) = ↑(l % ↑n) / ↑n
m₀ : ℕ
q : ℤ := ⌈↑m₀ / ↑n⌉
m₁ : ℤ := q * ↑n - ↑m₀
hm₁ : 0 ≤ m₁
⊢ (q * ↑n - ↑m₀) % ↑n = -↑m₀ % ↑n
[PROOFSTEP]
rw [sub_eq_add_neg, add_comm (q * ↑n), add_mul_emod_self]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a : α
z : ℤ
⊢ z ≤ ⌊-a⌋ ↔ z ≤ -⌈a⌉
[PROOFSTEP]
rw [le_neg, ceil_le, le_floor, Int.cast_neg, le_neg]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a : α
z : ℤ
⊢ ⌈-a⌉ ≤ z ↔ -⌊a⌋ ≤ z
[PROOFSTEP]
rw [neg_le, ceil_le, le_floor, Int.cast_neg, neg_le]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ z + 1 ≤ ⌈a⌉ ↔ ↑z < a
[PROOFSTEP]
rw [← lt_ceil, add_one_le_iff]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ 1 ≤ ⌈a⌉ ↔ 0 < a
[PROOFSTEP]
rw [← zero_add (1 : ℤ), add_one_le_ceil_iff, cast_zero]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
⊢ ⌈a⌉ ≤ ⌊a⌋ + 1
[PROOFSTEP]
rw [ceil_le, Int.cast_add, Int.cast_one]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
⊢ a ≤ ↑⌊a⌋ + 1
[PROOFSTEP]
exact (lt_floor_add_one a).le
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a✝ : α
z a : ℤ
⊢ ⌈↑z⌉ ≤ a ↔ z ≤ a
[PROOFSTEP]
rw [ceil_le, Int.cast_le]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ : α
n : ℕ
a : ℤ
⊢ ⌈↑n⌉ ≤ a ↔ ↑n ≤ a
[PROOFSTEP]
rw [ceil_le, ← cast_ofNat, cast_le]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a✝ a : α
z : ℤ
⊢ ⌈a + ↑z⌉ = ⌈a⌉ + z
[PROOFSTEP]
rw [← neg_inj, neg_add', ← floor_neg, ← floor_neg, neg_add', floor_sub_int]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
n : ℕ
⊢ ⌈a + ↑n⌉ = ⌈a⌉ + ↑n
[PROOFSTEP]
rw [← Int.cast_ofNat, ceil_add_int]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
⊢ ⌈a + 1⌉ = ⌈a⌉ + 1
[PROOFSTEP]
rw [← ceil_add_int a (1 : ℤ), cast_one]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a✝ a : α
z : ℤ
⊢ ⌈a - ↑z⌉ = ⌈a + ↑(-z)⌉
[PROOFSTEP]
rw [Int.cast_neg, sub_eq_add_neg]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
n : ℕ
⊢ ⌈a - ↑n⌉ = ⌈a⌉ - ↑n
[PROOFSTEP]
convert ceil_sub_int a n using 1
[GOAL]
case h.e'_2
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
n : ℕ
⊢ ⌈a - ↑n⌉ = ⌈a - ↑↑n⌉
[PROOFSTEP]
simp
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
⊢ ⌈a - 1⌉ = ⌈a⌉ - 1
[PROOFSTEP]
rw [eq_sub_iff_add_eq, ← ceil_add_one, sub_add_cancel]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
⊢ ↑⌈a⌉ < a + 1
[PROOFSTEP]
rw [← lt_ceil, ← Int.cast_one, ceil_add_int]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
⊢ ⌈a⌉ < ⌈a⌉ + 1
[PROOFSTEP]
apply lt_add_one
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ ⌈a + b⌉ ≤ ⌈a⌉ + ⌈b⌉
[PROOFSTEP]
rw [ceil_le, Int.cast_add]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ a + b ≤ ↑⌈a⌉ + ↑⌈b⌉
[PROOFSTEP]
exact add_le_add (le_ceil _) (le_ceil _)
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ ⌈a⌉ + ⌈b⌉ ≤ ⌈a + b⌉ + 1
[PROOFSTEP]
rw [← le_sub_iff_add_le, ceil_le, Int.cast_sub, Int.cast_add, Int.cast_one, le_sub_comm]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ ↑⌈b⌉ ≤ ↑⌈a + b⌉ + 1 - a
[PROOFSTEP]
refine' (ceil_lt_add_one _).le.trans _
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ b + 1 ≤ ↑⌈a + b⌉ + 1 - a
[PROOFSTEP]
rw [le_sub_iff_add_le', ← add_assoc, add_le_add_iff_right]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a b : α
⊢ a + b ≤ ↑⌈a + b⌉
[PROOFSTEP]
exact le_ceil _
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ 0 < ⌈a⌉ ↔ 0 < a
[PROOFSTEP]
rw [lt_ceil, cast_zero]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ ⌈0⌉ = 0
[PROOFSTEP]
rw [← cast_zero, ceil_intCast]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ ⌈1⌉ = 1
[PROOFSTEP]
rw [← cast_one, ceil_intCast]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
ha : 0 ≤ a
⊢ 0 ≤ ⌈a⌉
[PROOFSTEP]
exact_mod_cast ha.trans (le_ceil a)
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ ⌈a⌉ = z ↔ ↑z - 1 < a ∧ a ≤ ↑z
[PROOFSTEP]
rw [← ceil_le, ← Int.cast_one, ← Int.cast_sub, ← lt_ceil, Int.sub_one_lt_iff, le_antisymm_iff, and_comm]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ ⌈a⌉ = 0 ↔ a ∈ Ioc (-1) 0
[PROOFSTEP]
simp [ceil_eq_iff]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z✝ : ℤ
a✝ : α
z : ℤ
a : α
ha : a ∈ Ioc (↑z - 1) ↑z
⊢ ↑⌈a⌉ = ↑z
[PROOFSTEP]
exact_mod_cast ceil_eq_on_Ioc z a ha
[GOAL]
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⌉
[PROOFSTEP]
cases' eq_or_ne (fract a) 0 with ha ha
[GOAL]
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⌉
[PROOFSTEP]
exact Or.inl ha
[GOAL]
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⌉
[PROOFSTEP]
right
[GOAL]
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⌉
[PROOFSTEP]
suffices (⌈a⌉ : α) = ⌊a⌋ + 1 by
  rw [this, ← self_sub_fract]
  abel
[GOAL]
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⌉
[PROOFSTEP]
rw [this, ← self_sub_fract]
[GOAL]
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)
[PROOFSTEP]
abel
[GOAL]
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)
[PROOFSTEP]
abel
[GOAL]
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
[PROOFSTEP]
norm_cast
[GOAL]
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
[PROOFSTEP]
rw [ceil_eq_iff]
[GOAL]
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)
[PROOFSTEP]
refine' ⟨_, _root_.le_of_lt <| by simp⟩
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a✝ a : α
ha : fract a ≠ 0
⊢ a < ↑(⌊a⌋ + 1)
[PROOFSTEP]
simp
[GOAL]
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
[PROOFSTEP]
rw [cast_add, cast_one, add_tsub_cancel_right, ← self_sub_fract a, sub_lt_self_iff]
[GOAL]
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
[PROOFSTEP]
exact ha.symm.lt_of_le (fract_nonneg a)
[GOAL]
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
[PROOFSTEP]
rw [(or_iff_right ha).mp (fract_eq_zero_or_add_one_sub_ceil a)]
[GOAL]
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⌉)
[PROOFSTEP]
abel
[GOAL]
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⌉)
[PROOFSTEP]
abel
[GOAL]
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
[PROOFSTEP]
rw [(or_iff_right ha).mp (fract_eq_zero_or_add_one_sub_ceil a)]
[GOAL]
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⌉)
[PROOFSTEP]
abel
[GOAL]
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⌉)
[PROOFSTEP]
abel
[GOAL]
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⌉
[PROOFSTEP]
ext
[GOAL]
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⌉
[PROOFSTEP]
simp [floor_lt, lt_ceil]
[GOAL]
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⌉
[PROOFSTEP]
ext
[GOAL]
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⌉
[PROOFSTEP]
simp [ceil_le, lt_ceil]
[GOAL]
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⌋
[PROOFSTEP]
ext
[GOAL]
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⌋
[PROOFSTEP]
simp [floor_lt, le_floor]
[GOAL]
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⌋
[PROOFSTEP]
ext
[GOAL]
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⌋
[PROOFSTEP]
simp [ceil_le, le_floor]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ Int.cast ⁻¹' Ioi a = Ioi ⌊a⌋
[PROOFSTEP]
ext
[GOAL]
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⌋
[PROOFSTEP]
simp [floor_lt]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ Int.cast ⁻¹' Ici a = Ici ⌈a⌉
[PROOFSTEP]
ext
[GOAL]
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⌉
[PROOFSTEP]
simp [ceil_le]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ Int.cast ⁻¹' Iio a = Iio ⌈a⌉
[PROOFSTEP]
ext
[GOAL]
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⌉
[PROOFSTEP]
simp [lt_ceil]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
⊢ Int.cast ⁻¹' Iic a = Iic ⌊a⌋
[PROOFSTEP]
ext
[GOAL]
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⌋
[PROOFSTEP]
simp [le_floor]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
⊢ round 0 = 0
[PROOFSTEP]
simp [round]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
⊢ round 1 = 1
[PROOFSTEP]
simp [round]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
n : ℕ
⊢ round ↑n = ↑n
[PROOFSTEP]
simp [round]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
n : ℤ
⊢ round ↑n = n
[PROOFSTEP]
simp [round]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
y : ℤ
⊢ round (x + ↑y) = round x + y
[PROOFSTEP]
rw [round, round, Int.fract_add_int, Int.floor_add_int, Int.ceil_add_int, ← apply_ite₂, ite_self]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
a : α
⊢ round (a + 1) = round a + 1
[PROOFSTEP]
rw [← round_add_int a 1, cast_one]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
y : ℤ
⊢ round (x - ↑y) = round x - y
[PROOFSTEP]
rw [sub_eq_add_neg]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
y : ℤ
⊢ round (x + -↑y) = round x - y
[PROOFSTEP]
norm_cast
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
y : ℤ
⊢ round (x + ↑(-y)) = round x - y
[PROOFSTEP]
rw [round_add_int, sub_eq_add_neg]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
a : α
⊢ round (a - 1) = round a - 1
[PROOFSTEP]
rw [← round_sub_int a 1, cast_one]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
y : ℕ
⊢ round (x + ↑y) = round x + ↑y
[PROOFSTEP]
exact_mod_cast round_add_int x y
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
y : ℕ
⊢ round (x - ↑y) = round x - ↑y
[PROOFSTEP]
exact_mod_cast round_sub_int x y
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
y : ℤ
⊢ round (↑y + x) = y + round x
[PROOFSTEP]
rw [add_comm, round_add_int, add_comm]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
y : ℕ
⊢ round (↑y + x) = ↑y + round x
[PROOFSTEP]
rw [add_comm, round_add_nat, add_comm]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
⊢ |x - ↑(round x)| = min (fract x) (1 - fract x)
[PROOFSTEP]
simp_rw [round, min_def_lt, two_mul, ← lt_tsub_iff_left]
[GOAL]
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
[PROOFSTEP]
cases' lt_or_ge (fract x) (1 - fract x) with hx hx
[GOAL]
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
[PROOFSTEP]
rw [if_pos hx, if_pos hx, self_sub_floor, abs_fract]
[GOAL]
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
[PROOFSTEP]
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
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
hx : fract x ≥ 1 - fract x
⊢ 0 < fract x
[PROOFSTEP]
replace hx : 0 < fract x + fract x := lt_of_lt_of_le zero_lt_one (tsub_le_iff_left.mp hx)
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
hx : 0 < fract x + fract x
⊢ 0 < fract x
[PROOFSTEP]
simpa only [← two_mul, zero_lt_mul_left, zero_lt_two] using hx
[GOAL]
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
[PROOFSTEP]
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]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
z : ℤ
⊢ |x - ↑(round x)| ≤ |x - ↑z|
[PROOFSTEP]
rw [abs_sub_round_eq_min, min_le_iff]
[GOAL]
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|
[PROOFSTEP]
rcases le_or_lt (z : α) x with (hx | hx) <;> [left; right]
[GOAL]
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|
[PROOFSTEP]
rcases le_or_lt (z : α) x with (hx | hx)
[GOAL]
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|
[PROOFSTEP]
left
[GOAL]
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|
[PROOFSTEP]
right
[GOAL]
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|
[PROOFSTEP]
conv_rhs => rw [abs_eq_self.mpr (sub_nonneg.mpr hx), ← fract_add_floor x, add_sub_assoc]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
z : ℤ
hx : ↑z ≤ x
| |x - ↑z|
[PROOFSTEP]
rw [abs_eq_self.mpr (sub_nonneg.mpr hx), ← fract_add_floor x, add_sub_assoc]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
z : ℤ
hx : ↑z ≤ x
| |x - ↑z|
[PROOFSTEP]
rw [abs_eq_self.mpr (sub_nonneg.mpr hx), ← fract_add_floor x, add_sub_assoc]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
z : ℤ
hx : ↑z ≤ x
| |x - ↑z|
[PROOFSTEP]
rw [abs_eq_self.mpr (sub_nonneg.mpr hx), ← fract_add_floor x, add_sub_assoc]
[GOAL]
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)
[PROOFSTEP]
simpa only [le_add_iff_nonneg_right, sub_nonneg, cast_le] using le_floor.mpr hx
[GOAL]
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|
[PROOFSTEP]
rw [abs_eq_neg_self.mpr (sub_neg.mpr hx).le]
[GOAL]
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)
[PROOFSTEP]
conv_rhs => rw [← fract_add_floor x]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
z : ℤ
hx : x < ↑z
| -(x - ↑z)
[PROOFSTEP]
rw [← fract_add_floor x]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
z : ℤ
hx : x < ↑z
| -(x - ↑z)
[PROOFSTEP]
rw [← fract_add_floor x]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
z : ℤ
hx : x < ↑z
| -(x - ↑z)
[PROOFSTEP]
rw [← fract_add_floor x]
[GOAL]
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 ≤ -(fract x + ↑⌊x⌋ - ↑z)
[PROOFSTEP]
rw [add_sub_assoc, add_comm, neg_add, neg_sub, le_add_neg_iff_add_le, sub_add_cancel, le_sub_comm]
[GOAL]
case inr.h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
z : ℤ
hx : x < ↑z
⊢ ↑⌊x⌋ ≤ ↑z - 1
[PROOFSTEP]
norm_cast
[GOAL]
case inr.h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
x : α
z : ℤ
hx : x < ↑z
⊢ ⌊x⌋ ≤ z - 1
[PROOFSTEP]
exact floor_le_sub_one_iff.mpr hx
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
⊢ round x = ⌊x + 1 / 2⌋
[PROOFSTEP]
simp_rw [round, (by simp only [lt_div_iff', two_pos] : 2 * fract x < 1 ↔ fract x < 1 / 2)]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
⊢ 2 * fract x < 1 ↔ fract x < 1 / 2
[PROOFSTEP]
simp only [lt_div_iff', two_pos]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
⊢ (if fract x < 1 / 2 then ⌊x⌋ else ⌈x⌉) = ⌊x + 1 / 2⌋
[PROOFSTEP]
cases' lt_or_le (fract x) (1 / 2) with hx hx
[GOAL]
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
hx : fract x < 1 / 2
⊢ (if fract x < 1 / 2 then ⌊x⌋ else ⌈x⌉) = ⌊x + 1 / 2⌋
[PROOFSTEP]
conv_rhs => rw [← fract_add_floor x, add_assoc, add_left_comm, floor_int_add]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
hx : fract x < 1 / 2
| ⌊x + 1 / 2⌋
[PROOFSTEP]
rw [← fract_add_floor x, add_assoc, add_left_comm, floor_int_add]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
hx : fract x < 1 / 2
| ⌊x + 1 / 2⌋
[PROOFSTEP]
rw [← fract_add_floor x, add_assoc, add_left_comm, floor_int_add]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
hx : fract x < 1 / 2
| ⌊x + 1 / 2⌋
[PROOFSTEP]
rw [← fract_add_floor x, add_assoc, add_left_comm, floor_int_add]
[GOAL]
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
hx : fract x < 1 / 2
⊢ (if fract x < 1 / 2 then ⌊x⌋ else ⌈x⌉) = ⌊x⌋ + ⌊fract x + 1 / 2⌋
[PROOFSTEP]
rw [if_pos hx, self_eq_add_right, floor_eq_iff, cast_zero, zero_add]
[GOAL]
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
hx : fract x < 1 / 2
⊢ 0 ≤ fract x + 1 / 2 ∧ fract x + 1 / 2 < 1
[PROOFSTEP]
constructor
[GOAL]
case inl.left
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
hx : fract x < 1 / 2
⊢ 0 ≤ fract x + 1 / 2
[PROOFSTEP]
linarith [fract_nonneg x]
[GOAL]
case inl.right
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
hx : fract x < 1 / 2
⊢ fract x + 1 / 2 < 1
[PROOFSTEP]
linarith
[GOAL]
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
hx : 1 / 2 ≤ fract x
⊢ (if fract x < 1 / 2 then ⌊x⌋ else ⌈x⌉) = ⌊x + 1 / 2⌋
[PROOFSTEP]
have : ⌊fract x + 1 / 2⌋ = 1 := by
  rw [floor_eq_iff]
  constructor
  · norm_num
    linarith
  · norm_num
    linarith [fract_lt_one x]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
hx : 1 / 2 ≤ fract x
⊢ ⌊fract x + 1 / 2⌋ = 1
[PROOFSTEP]
rw [floor_eq_iff]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
hx : 1 / 2 ≤ fract x
⊢ ↑1 ≤ fract x + 1 / 2 ∧ fract x + 1 / 2 < ↑1 + 1
[PROOFSTEP]
constructor
[GOAL]
case left
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
hx : 1 / 2 ≤ fract x
⊢ ↑1 ≤ fract x + 1 / 2
[PROOFSTEP]
norm_num
[GOAL]
case left
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
hx : 1 / 2 ≤ fract x
⊢ 1 ≤ fract x + 1 / 2
[PROOFSTEP]
linarith
[GOAL]
case right
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
hx : 1 / 2 ≤ fract x
⊢ fract x + 1 / 2 < ↑1 + 1
[PROOFSTEP]
norm_num
[GOAL]
case right
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
hx : 1 / 2 ≤ fract x
⊢ fract x + 1 / 2 < 2
[PROOFSTEP]
linarith [fract_lt_one x]
[GOAL]
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
hx : 1 / 2 ≤ fract x
this : ⌊fract x + 1 / 2⌋ = 1
⊢ (if fract x < 1 / 2 then ⌊x⌋ else ⌈x⌉) = ⌊x + 1 / 2⌋
[PROOFSTEP]
rw [if_neg (not_lt.mpr hx), ← fract_add_floor x, add_assoc, add_left_comm, floor_int_add, ceil_add_int, add_comm _ ⌊x⌋,
  add_right_inj, ceil_eq_iff, this, cast_one, sub_self]
[GOAL]
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
hx : 1 / 2 ≤ fract x
this : ⌊fract x + 1 / 2⌋ = 1
⊢ 0 < fract x ∧ fract x ≤ 1
[PROOFSTEP]
constructor
[GOAL]
case inr.left
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
hx : 1 / 2 ≤ fract x
this : ⌊fract x + 1 / 2⌋ = 1
⊢ 0 < fract x
[PROOFSTEP]
linarith
[GOAL]
case inr.right
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
hx : 1 / 2 ≤ fract x
this : ⌊fract x + 1 / 2⌋ = 1
⊢ fract x ≤ 1
[PROOFSTEP]
linarith [fract_lt_one x]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
⊢ round 2⁻¹ = 1
[PROOFSTEP]
simp only [round_eq, ← one_div, add_halves', floor_one]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
⊢ round (-2⁻¹) = 0
[PROOFSTEP]
simp only [round_eq, ← one_div, add_left_neg, floor_zero]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
⊢ round x = 0 ↔ x ∈ Ico (-(1 / 2)) (1 / 2)
[PROOFSTEP]
rw [round_eq, floor_eq_zero_iff, add_mem_Ico_iff_left]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
⊢ x ∈ Ico (0 - 1 / 2) (1 - 1 / 2) ↔ x ∈ Ico (-(1 / 2)) (1 / 2)
[PROOFSTEP]
norm_num
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
⊢ |x - ↑(round x)| ≤ 1 / 2
[PROOFSTEP]
rw [round_eq, abs_sub_le_iff]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
⊢ x - ↑⌊x + 1 / 2⌋ ≤ 1 / 2 ∧ ↑⌊x + 1 / 2⌋ - x ≤ 1 / 2
[PROOFSTEP]
have := floor_le (x + 1 / 2)
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
this : ↑⌊x + 1 / 2⌋ ≤ x + 1 / 2
⊢ x - ↑⌊x + 1 / 2⌋ ≤ 1 / 2 ∧ ↑⌊x + 1 / 2⌋ - x ≤ 1 / 2
[PROOFSTEP]
have := lt_floor_add_one (x + 1 / 2)
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
this✝ : ↑⌊x + 1 / 2⌋ ≤ x + 1 / 2
this : x + 1 / 2 < ↑⌊x + 1 / 2⌋ + 1
⊢ x - ↑⌊x + 1 / 2⌋ ≤ 1 / 2 ∧ ↑⌊x + 1 / 2⌋ - x ≤ 1 / 2
[PROOFSTEP]
constructor
[GOAL]
case left
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
this✝ : ↑⌊x + 1 / 2⌋ ≤ x + 1 / 2
this : x + 1 / 2 < ↑⌊x + 1 / 2⌋ + 1
⊢ x - ↑⌊x + 1 / 2⌋ ≤ 1 / 2
[PROOFSTEP]
linarith
[GOAL]
case right
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
x : α
this✝ : ↑⌊x + 1 / 2⌋ ≤ x + 1 / 2
this : x + 1 / 2 < ↑⌊x + 1 / 2⌋ + 1
⊢ ↑⌊x + 1 / 2⌋ - x ≤ 1 / 2
[PROOFSTEP]
linarith
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
m n : ℕ
⊢ |↑m / ↑n - ↑(round (↑m / ↑n))| = ↑(min (m % n) (n - m % n)) / ↑n
[PROOFSTEP]
rcases n.eq_zero_or_pos with (rfl | hn)
[GOAL]
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
m : ℕ
⊢ |↑m / ↑0 - ↑(round (↑m / ↑0))| = ↑(min (m % 0) (0 - m % 0)) / ↑0
[PROOFSTEP]
simp
[GOAL]
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
m n : ℕ
hn : n > 0
⊢ |↑m / ↑n - ↑(round (↑m / ↑n))| = ↑(min (m % n) (n - m % n)) / ↑n
[PROOFSTEP]
have hn' : 0 < (n : α) := by norm_cast
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
m n : ℕ
hn : n > 0
⊢ 0 < ↑n
[PROOFSTEP]
norm_cast
[GOAL]
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedField α
inst✝ : FloorRing α
m n : ℕ
hn : n > 0
hn' : 0 < ↑n
⊢ |↑m / ↑n - ↑(round (↑m / ↑n))| = ↑(min (m % n) (n - m % n)) / ↑n
[PROOFSTEP]
rw [abs_sub_round_eq_min, Nat.cast_min, ← min_div_div_right hn'.le, fract_div_natCast_eq_div_natCast_mod,
  Nat.cast_sub (m.mod_lt hn).le, sub_div, div_self hn'.ne']
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝⁴ : LinearOrderedSemiring α
inst✝³ : LinearOrderedSemiring β
inst✝² : FloorSemiring α
inst✝¹ : FloorSemiring β
inst✝ : RingHomClass F α β
a : α
b : β
h : ∀ (n : ℕ), ↑n ≤ a ↔ ↑n ≤ b
⊢ ⌊a⌋₊ = ⌊b⌋₊
[PROOFSTEP]
have h₀ : 0 ≤ a ↔ 0 ≤ b := by simpa only [cast_zero] using h 0
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝⁴ : LinearOrderedSemiring α
inst✝³ : LinearOrderedSemiring β
inst✝² : FloorSemiring α
inst✝¹ : FloorSemiring β
inst✝ : RingHomClass F α β
a : α
b : β
h : ∀ (n : ℕ), ↑n ≤ a ↔ ↑n ≤ b
⊢ 0 ≤ a ↔ 0 ≤ b
[PROOFSTEP]
simpa only [cast_zero] using h 0
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝⁴ : LinearOrderedSemiring α
inst✝³ : LinearOrderedSemiring β
inst✝² : FloorSemiring α
inst✝¹ : FloorSemiring β
inst✝ : RingHomClass F α β
a : α
b : β
h : ∀ (n : ℕ), ↑n ≤ a ↔ ↑n ≤ b
h₀ : 0 ≤ a ↔ 0 ≤ b
⊢ ⌊a⌋₊ = ⌊b⌋₊
[PROOFSTEP]
obtain ha | ha := lt_or_le a 0
[GOAL]
case inl
F : Type u_1
α : Type u_2
β : Type u_3
inst✝⁴ : LinearOrderedSemiring α
inst✝³ : LinearOrderedSemiring β
inst✝² : FloorSemiring α
inst✝¹ : FloorSemiring β
inst✝ : RingHomClass F α β
a : α
b : β
h : ∀ (n : ℕ), ↑n ≤ a ↔ ↑n ≤ b
h₀ : 0 ≤ a ↔ 0 ≤ b
ha : a < 0
⊢ ⌊a⌋₊ = ⌊b⌋₊
[PROOFSTEP]
rw [floor_of_nonpos ha.le, floor_of_nonpos (le_of_not_le <| h₀.not.mp ha.not_le)]
[GOAL]
case inr
F : Type u_1
α : Type u_2
β : Type u_3
inst✝⁴ : LinearOrderedSemiring α
inst✝³ : LinearOrderedSemiring β
inst✝² : FloorSemiring α
inst✝¹ : FloorSemiring β
inst✝ : RingHomClass F α β
a : α
b : β
h : ∀ (n : ℕ), ↑n ≤ a ↔ ↑n ≤ b
h₀ : 0 ≤ a ↔ 0 ≤ b
ha : 0 ≤ a
⊢ ⌊a⌋₊ = ⌊b⌋₊
[PROOFSTEP]
exact (le_floor <| (h _).1 <| floor_le ha).antisymm (le_floor <| (h _).2 <| floor_le <| h₀.1 ha)
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝⁴ : LinearOrderedSemiring α
inst✝³ : LinearOrderedSemiring β
inst✝² : FloorSemiring α
inst✝¹ : FloorSemiring β
inst✝ : RingHomClass F α β
a✝ : α
b : β
f : F
hf : StrictMono ↑f
a : α
n : ℕ
⊢ ↑n ≤ ↑f a ↔ ↑n ≤ a
[PROOFSTEP]
rw [← map_natCast f, hf.le_iff_le]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝⁴ : LinearOrderedSemiring α
inst✝³ : LinearOrderedSemiring β
inst✝² : FloorSemiring α
inst✝¹ : FloorSemiring β
inst✝ : RingHomClass F α β
a✝ : α
b : β
f : F
hf : StrictMono ↑f
a : α
n : ℕ
⊢ ↑f a ≤ ↑n ↔ a ≤ ↑n
[PROOFSTEP]
rw [← map_natCast f, hf.le_iff_le]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝⁴ : LinearOrderedRing α
inst✝³ : LinearOrderedRing β
inst✝² : FloorRing α
inst✝¹ : FloorRing β
inst✝ : RingHomClass F α β
a✝ : α
b : β
f : F
hf : StrictMono ↑f
a : α
n : ℤ
⊢ ↑n ≤ ↑f a ↔ ↑n ≤ a
[PROOFSTEP]
rw [← map_intCast f, hf.le_iff_le]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝⁴ : LinearOrderedRing α
inst✝³ : LinearOrderedRing β
inst✝² : FloorRing α
inst✝¹ : FloorRing β
inst✝ : RingHomClass F α β
a✝ : α
b : β
f : F
hf : StrictMono ↑f
a : α
n : ℤ
⊢ ↑f a ≤ ↑n ↔ a ≤ ↑n
[PROOFSTEP]
rw [← map_intCast f, hf.le_iff_le]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝⁴ : LinearOrderedRing α
inst✝³ : LinearOrderedRing β
inst✝² : FloorRing α
inst✝¹ : FloorRing β
inst✝ : RingHomClass F α β
a✝ : α
b : β
f : F
hf : StrictMono ↑f
a : α
⊢ fract (↑f a) = ↑f (fract a)
[PROOFSTEP]
simp_rw [fract, map_sub, map_intCast, map_floor _ hf]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝⁴ : LinearOrderedField α
inst✝³ : LinearOrderedField β
inst✝² : FloorRing α
inst✝¹ : FloorRing β
inst✝ : RingHomClass F α β
a✝ : α
b : β
f : F
hf : StrictMono ↑f
a : α
⊢ round (↑f a) = round a
[PROOFSTEP]
have H : f 2 = 2 := map_natCast f 2
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝⁴ : LinearOrderedField α
inst✝³ : LinearOrderedField β
inst✝² : FloorRing α
inst✝¹ : FloorRing β
inst✝ : RingHomClass F α β
a✝ : α
b : β
f : F
hf : StrictMono ↑f
a : α
H : ↑f 2 = 2
⊢ round (↑f a) = round a
[PROOFSTEP]
simp_rw [round_eq, ← map_floor _ hf, map_add, one_div, map_inv₀, H]
  -- Porting note: was
    -- simp_rw [round_eq, ← map_floor _ hf, map_add, one_div, map_inv₀, map_bit0, map_one]
    -- Would have thought that `map_natCast` would replace `map_bit0, map_one` but seems not
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
a : α
n : ℕ
ha : 0 ≤ a
⊢ n ≤ (fun a => toNat ⌊a⌋) a ↔ ↑n ≤ a
[PROOFSTEP]
rw [Int.le_toNat (Int.floor_nonneg.2 ha), Int.le_floor, Int.cast_ofNat]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
a : α
n : ℕ
⊢ (fun a => toNat ⌈a⌉) a ≤ n ↔ a ≤ ↑n
[PROOFSTEP]
rw [Int.toNat_le, Int.ceil_le, Int.cast_ofNat]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
a : α
ha : 0 ≤ a
⊢ ↑⌊a⌋₊ = ⌊a⌋
[PROOFSTEP]
rw [← Int.floor_toNat, Int.toNat_of_nonneg (Int.floor_nonneg.2 ha)]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
a : α
ha : 0 ≤ a
⊢ ↑⌊a⌋₊ = ↑⌊a⌋
[PROOFSTEP]
rw [← Nat.cast_floor_eq_int_floor ha, Int.cast_ofNat]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
a : α
ha : 0 ≤ a
⊢ ↑⌈a⌉₊ = ⌈a⌉
[PROOFSTEP]
rw [← Int.ceil_toNat, Int.toNat_of_nonneg (Int.ceil_nonneg ha)]
[GOAL]
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
a : α
ha : 0 ≤ a
⊢ ↑⌈a⌉₊ = ↑⌈a⌉
[PROOFSTEP]
rw [← Nat.cast_ceil_eq_int_ceil ha, Int.cast_ofNat]
[GOAL]
F : Type u_1
α✝ : Type u_2
β : Type u_3
α : Type u_4
inst✝ : LinearOrderedRing α
⊢ Subsingleton (FloorRing α)
[PROOFSTEP]
refine' ⟨fun H₁ H₂ => _⟩
[GOAL]
F : Type u_1
α✝ : Type u_2
β : Type u_3
α : Type u_4
inst✝ : LinearOrderedRing α
H₁ H₂ : FloorRing α
⊢ H₁ = H₂
[PROOFSTEP]
have : H₁.floor = H₂.floor := funext fun a => (H₁.gc_coe_floor.u_unique H₂.gc_coe_floor) fun _ => rfl
[GOAL]
F : Type u_1
α✝ : Type u_2
β : Type u_3
α : Type u_4
inst✝ : LinearOrderedRing α
H₁ H₂ : FloorRing α
this : FloorRing.floor = FloorRing.floor
⊢ H₁ = H₂
[PROOFSTEP]
have : H₁.ceil = H₂.ceil := funext fun a => (H₁.gc_ceil_coe.l_unique H₂.gc_ceil_coe) fun _ => rfl
[GOAL]
F : Type u_1
α✝ : Type u_2
β : Type u_3
α : Type u_4
inst✝ : LinearOrderedRing α
H₁ H₂ : FloorRing α
this✝ : FloorRing.floor = FloorRing.floor
this : FloorRing.ceil = FloorRing.ceil
⊢ H₁ = H₂
[PROOFSTEP]
cases H₁
[GOAL]
case mk
F : Type u_1
α✝ : Type u_2
β : Type u_3
α : Type u_4
inst✝ : LinearOrderedRing α
H₂ : FloorRing α
floor✝ ceil✝ : α → ℤ
gc_coe_floor✝ : GaloisConnection Int.cast floor✝
gc_ceil_coe✝ : GaloisConnection ceil✝ Int.cast
this✝ : FloorRing.floor = FloorRing.floor
this : FloorRing.ceil = FloorRing.ceil
⊢ { floor := floor✝, ceil := ceil✝, gc_coe_floor := gc_coe_floor✝, gc_ceil_coe := gc_ceil_coe✝ } = H₂
[PROOFSTEP]
cases H₂
[GOAL]
case mk.mk
F : Type u_1
α✝ : Type u_2
β : Type u_3
α : Type u_4
inst✝ : LinearOrderedRing α
floor✝¹ ceil✝¹ : α → ℤ
gc_coe_floor✝¹ : GaloisConnection Int.cast floor✝¹
gc_ceil_coe✝¹ : GaloisConnection ceil✝¹ Int.cast
floor✝ ceil✝ : α → ℤ
gc_coe_floor✝ : GaloisConnection Int.cast floor✝
gc_ceil_coe✝ : GaloisConnection ceil✝ Int.cast
this✝ : FloorRing.floor = FloorRing.floor
this : FloorRing.ceil = FloorRing.ceil
⊢ { floor := floor✝¹, ceil := ceil✝¹, gc_coe_floor := gc_coe_floor✝¹, gc_ceil_coe := gc_ceil_coe✝¹ } =
    { floor := floor✝, ceil := ceil✝, gc_coe_floor := gc_coe_floor✝, gc_ceil_coe := gc_ceil_coe✝ }
[PROOFSTEP]
congr
