@@ -158,7 +158,7 @@ theorem floor_eq_on_Ico' (n : ℤ) : ∀ a ∈ Set.Ico (n : R) (n + 1), (⌊a⌋
158158theorem preimage_floor_singleton (m : ℤ) : (floor : R → ℤ) ⁻¹' {m} = Ico (m : R) (m + 1 ) :=
159159 ext fun _ => floor_eq_iff
160160
161- variable [IsStrictOrderedRing R]
161+ variable [IsOrderedRing R]
162162
163163@ [simp, bound]
164164theorem sub_one_lt_floor (a : R) : a - 1 < ⌊a⌋ :=
@@ -276,21 +276,16 @@ theorem mul_fract_eq_one_iff_exists_int {x : R} {k : R} (hk : 1 < k) :
276276 rw [floor_eq_iff, ← mul_le_mul_iff_right₀ hk0, ← mul_lt_mul_iff_right₀ hk0, hn]
277277 simp [mul_add, hk]
278278
279- end LinearOrderedRing
280-
281- section LinearOrderedCommRing
282- variable {R : Type *} [CommRing R] [LinearOrder R] [IsStrictOrderedRing R] [FloorRing R] {a : R}
283-
284279theorem cast_mul_floor_div_cancel_of_pos {n : ℤ} (hn : 0 < n) (a : R) : ⌊n * a⌋ / n = ⌊a⌋ := by
285- rw [mul_comm , mul_cast_floor_div_cancel_of_pos hn]
280+ rw [Commute.intCast_left , mul_cast_floor_div_cancel_of_pos hn]
286281
287282theorem natCast_mul_floor_div_cancel {n : ℕ} (hn : n ≠ 0 ) (a : R) : ⌊n * a⌋ / n = ⌊a⌋ := by
288- rw [mul_comm , mul_natCast_floor_div_cancel hn]
283+ rw [Nat.cast_comm , mul_natCast_floor_div_cancel hn]
289284
290- end LinearOrderedCommRing
285+ end LinearOrderedRing
291286
292287section LinearOrderedField
293- variable {k : Type *} [Field k] [LinearOrder k] [IsStrictOrderedRing k] [FloorRing k] {a b : k}
288+ variable {k : Type *} [Field k] [LinearOrder k] [IsOrderedRing k] [FloorRing k] {a b : k}
294289
295290theorem floor_div_cast_of_nonneg {n : ℤ} (hn : 0 ≤ n) (a : k) : ⌊a / n⌋ = ⌊a⌋ / n := by
296291 obtain rfl | hn := hn.eq_or_lt
@@ -332,7 +327,7 @@ theorem fract_sub_self (a : R) : fract a - a = -⌊a⌋ :=
332327theorem fract_add (a b : R) : ∃ z : ℤ, fract (a + b) - fract a - fract b = z :=
333328 ⟨⌊a⌋ + ⌊b⌋ - ⌊a + b⌋, by unfold fract; grind⟩
334329
335- variable [IsStrictOrderedRing R]
330+ variable [IsOrderedRing R]
336331
337332@[simp]
338333theorem fract_add_intCast (a : R) (m : ℤ) : fract (a + m) = fract a := by
@@ -441,8 +436,9 @@ theorem fract_eq_iff {a b : R} : fract a = b ↔ 0 ≤ b ∧ b < 1 ∧ ∃ z :
441436 exact ⟨fract_nonneg _, fract_lt_one _, ⟨⌊a⌋, sub_sub_cancel _ _⟩⟩,
442437 by
443438 rintro ⟨h₀, h₁, z, hz⟩
444- rw [← self_sub_floor, eq_comm, eq_sub_iff_add_eq, add_comm, ← eq_sub_iff_add_eq, hz,
445- Int.cast_inj, floor_eq_iff, ← hz]
439+ rw [← self_sub_floor, eq_comm, eq_sub_iff_add_eq, add_comm, ← eq_sub_iff_add_eq, hz]
440+ refine congrArg Int.cast ?_
441+ rw [floor_eq_iff, ← hz]
446442 constructor <;> simpa [sub_eq_add_neg, add_assoc] ⟩
447443
448444theorem fract_eq_fract {a b : R} : fract a = fract b ↔ ∃ z : ℤ, a - b = z :=
@@ -513,13 +509,13 @@ theorem image_fract (s : Set R) : fract '' s = ⋃ m : ℤ, (fun x : R => x - m)
513509
514510section LinearOrderedField
515511
516- variable {k : Type *} [Field k] [LinearOrder k] [IsStrictOrderedRing k] [FloorRing k] {b : k}
512+ variable {k : Type *} [Field k] [LinearOrder k] [IsOrderedRing k] [FloorRing k] {b : k}
517513
518514theorem fract_div_mul_self_mem_Ico (a b : k) (ha : 0 < a) : fract (b / a) * a ∈ Ico 0 a :=
519515 ⟨(mul_nonneg_iff_of_pos_right ha).2 (fract_nonneg (b / a)),
520516 (mul_lt_iff_lt_one_left ha).2 (fract_lt_one (b / a))⟩
521517
522- omit [IsStrictOrderedRing k] in
518+ omit [IsOrderedRing k] in
523519theorem fract_div_mul_self_add_zsmul_eq (a b : k) (ha : a ≠ 0 ) :
524520 fract (b / a) * a + ⌊b / a⌋ • a = b := by
525521 rw [zsmul_eq_mul, ← add_mul, fract_add_floor, div_mul_cancel₀ b ha]
@@ -619,7 +615,7 @@ theorem ceil_eq_on_Ioc (z : ℤ) : ∀ a ∈ Set.Ioc (z - 1 : R) z, ⌈a⌉ = z
619615theorem preimage_ceil_singleton (m : ℤ) : (ceil : R → ℤ) ⁻¹' {m} = Ioc ((m : R) - 1 ) m :=
620616 ext fun _ => ceil_eq_iff
621617
622- variable [IsStrictOrderedRing R]
618+ variable [IsOrderedRing R]
623619
624620theorem floor_neg : ⌊-a⌋ = -⌈a⌉ :=
625621 eq_of_forall_le_iff fun z => by rw [le_neg, ceil_le, le_floor, Int.cast_neg, le_neg]
@@ -713,8 +709,9 @@ theorem ceil_zero : ⌈(0 : R)⌉ = 0 := by rw [← cast_zero, ceil_intCast]
713709@[simp]
714710theorem ceil_one : ⌈(1 : R)⌉ = 1 := by rw [← cast_one, ceil_intCast]
715711
716- theorem ceil_eq_on_Ioc' (z : ℤ) : ∀ a ∈ Set.Ioc (z - 1 : R) z, (⌈a⌉ : R) = z := fun a ha =>
717- mod_cast ceil_eq_on_Ioc z a ha
712+ omit [IsOrderedRing R] in
713+ theorem ceil_eq_on_Ioc' (z : ℤ) : ∀ a ∈ Set.Ioc (z - 1 : R) z, (⌈a⌉ : R) = z :=
714+ fun a ha => congrArg Int.cast (ceil_eq_on_Ioc z a ha)
718715
719716lemma ceil_eq_self_iff_mem (a : R) : ⌈a⌉ = a ↔ a ∈ Set.range Int.cast := by
720717 aesop
@@ -729,8 +726,9 @@ theorem floor_lt_ceil_of_lt {a b : R} (h : a < b) : ⌊a⌋ < ⌈b⌉ :=
729726
730727lemma ceil_eq_floor_add_one_iff_notMem (a : R) : ⌈a⌉ = ⌊a⌋ + 1 ↔ a ∉ Set.range Int.cast := by
731728 refine ⟨fun h ht => ?_, fun h => ?_⟩
732- · have := ((floor_eq_self_iff_mem _).mpr ht).trans ((ceil_eq_self_iff_mem _).mpr ht).symm
733- linarith [Int.cast_inj.mp this]
729+ · have h0 := ((floor_eq_self_iff_mem _).mpr ht).trans ((ceil_eq_self_iff_mem _).mpr ht).symm
730+ rw [h, cast_add, cast_one, left_eq_add] at h0
731+ exact one_ne_zero h0
734732 · apply le_antisymm (Int.ceil_le_floor_add_one _)
735733 rw [add_one_le_iff, lt_ceil]
736734 exact lt_of_le_of_ne (Int.floor_le a) ((iff_false_right h).mp (floor_eq_self_iff_mem a))
@@ -742,9 +740,8 @@ theorem fract_eq_zero_or_add_one_sub_ceil (a : R) : fract a = 0 ∨ fract a = a
742740 suffices (⌈a⌉ : R) = ⌊a⌋ + 1 by
743741 rw [this, ← self_sub_fract]
744742 abel
745- norm_cast
746- rw [ceil_eq_iff]
747- refine ⟨?_, _root_.le_of_lt <| by simp⟩
743+ rw [← Int.cast_one, ← Int.cast_add]
744+ refine congrArg Int.cast (ceil_eq_iff.mpr ⟨?_, _root_.le_of_lt <| by simp⟩)
748745 rw [cast_add, cast_one, add_tsub_cancel_right, ← self_sub_fract a, sub_lt_self_iff]
749746 exact ha.symm.lt_of_le (fract_nonneg a)
750747
@@ -759,7 +756,7 @@ theorem ceil_sub_self_eq (ha : fract a ≠ 0) : (⌈a⌉ : R) - a = 1 - fract a
759756end ceil
760757
761758section LinearOrderedField
762- variable {k : Type *} [Field k] [LinearOrder k] [IsStrictOrderedRing k] [FloorRing k] {a b : k}
759+ variable {k : Type *} [Field k] [LinearOrder k] [IsOrderedRing k] [FloorRing k] {a b : k}
763760
764761lemma mul_lt_floor (hb₀ : 0 < b) (hb : b < 1 ) (hba : ⌈b / (1 - b)⌉ ≤ a) : b * a < ⌊a⌋ := by
765762 calc
@@ -889,7 +886,7 @@ end Nat
889886
890887section FloorRingToSemiring
891888
892- variable [Ring R] [LinearOrder R] [IsStrictOrderedRing R] [FloorRing R]
889+ variable [Ring R] [LinearOrder R] [IsOrderedRing R] [FloorRing R]
893890
894891/-! #### A floor ring as a floor semiring -/
895892
0 commit comments