l3lab/ntp-mathlib huggingface dataset:
@[simp]
theorem fract_neg_eq_zero {x : α} : fract (-x) = 0 ↔ fract x = 0 := by
  simp only [fract_eq_iff, le_refl, zero_lt_one, tsub_zero, true_and_iff]
  constructor <;> rintro ⟨z, hz⟩ <;> 

Proof state:
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

Next tactic:
use -z
@[simp]
theorem fract_neg_eq_zero {x : α} : fract (-x) = 0 ↔ fract x = 0 := by
  simp only [fract_eq_iff, le_refl, zero_lt_one, tsub_zero, true_and_iff]
  constructor <;> rintro ⟨z, hz⟩ <;> use -z <;> 

Proof state:
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)

Next tactic:
simp [← hz]
@[simp]
theorem fract_neg_eq_zero {x : α} : fract (-x) = 0 ↔ fract x = 0 := by
  simp only [fract_eq_iff, le_refl, zero_lt_one, tsub_zero, true_and_iff]
  constructor <;> rintro ⟨z, hz⟩ <;> use -z <;> 

Proof state:
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)

Next tactic:
simp [← hz]
theorem fract_mul_nat (a : α) (b : ℕ) : ∃ z : ℤ, fract a * b - fract (a * b) = z := by
  

Proof state:
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

Next tactic:
induction' b with c hc
theorem fract_mul_nat (a : α) (b : ℕ) : ∃ z : ℤ, fract a * b - fract (a * b) = z := by
  induction' b with c hc
  · 

Proof state:
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

Next tactic:
use 0
theorem fract_mul_nat (a : α) (b : ℕ) : ∃ z : ℤ, fract a * b - fract (a * b) = z := by
  induction' b with c hc
  · use 0; 

Proof state:
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

Next tactic:
simp
theorem fract_mul_nat (a : α) (b : ℕ) : ∃ z : ℤ, fract a * b - fract (a * b) = z := by
  induction' b with c hc
  · use 0; simp
  · 

Proof state:
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

Next tactic:
rcases hc with ⟨z, hz⟩
theorem fract_mul_nat (a : α) (b : ℕ) : ∃ z : ℤ, fract a * b - fract (a * b) = z := by
  induction' b with c hc
  · use 0; simp
  · rcases hc with ⟨z, hz⟩
    

Proof state:
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

Next tactic:
rw [Nat.succ_eq_add_one, Nat.cast_add, mul_add, mul_add, Nat.cast_one, mul_one, mul_one]
theorem fract_mul_nat (a : α) (b : ℕ) : ∃ z : ℤ, fract a * b - fract (a * b) = z := by
  induction' b with c hc
  · use 0; simp
  · rcases hc with ⟨z, hz⟩
    rw [Nat.succ_eq_add_one, Nat.cast_add, mul_add, mul_add, Nat.cast_one, mul_one, mul_one]
    

Proof state:
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

Next tactic:
rcases fract_add (a * c) a with ⟨y, hy⟩
theorem fract_mul_nat (a : α) (b : ℕ) : ∃ z : ℤ, fract a * b - fract (a * b) = z := by
  induction' b with c hc
  · use 0; simp
  · rcases hc with ⟨z, hz⟩
    rw [Nat.succ_eq_add_one, Nat.cast_add, mul_add, mul_add, Nat.cast_one, mul_one, mul_one]
    rcases fract_add (a * c) a with ⟨y, hy⟩
    

Proof state:
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

Next tactic:
use z - y
theorem fract_mul_nat (a : α) (b : ℕ) : ∃ z : ℤ, fract a * b - fract (a * b) = z := by
  induction' b with c hc
  · use 0; simp
  · rcases hc with ⟨z, hz⟩
    rw [Nat.succ_eq_add_one, Nat.cast_add, mul_add, mul_add, Nat.cast_one, mul_one, mul_one]
    rcases fract_add (a * c) a with ⟨y, hy⟩
    use z - y
    

Proof state:
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)

Next tactic:
rw [Int.cast_sub, ← hz, ← hy]
theorem fract_mul_nat (a : α) (b : ℕ) : ∃ z : ℤ, fract a * b - fract (a * b) = z := by
  induction' b with c hc
  · use 0; simp
  · rcases hc with ⟨z, hz⟩
    rw [Nat.succ_eq_add_one, Nat.cast_add, mul_add, mul_add, Nat.cast_one, mul_one, mul_one]
    rcases fract_add (a * c) a with ⟨y, hy⟩
    use z - y
    rw [Int.cast_sub, ← hz, ← hy]
    

Proof state:
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)

Next tactic:
abel
theorem preimage_fract (s : Set α) :
    fract ⁻¹' s = ⋃ m : ℤ, (fun x => x - (m:α)) ⁻¹' (s ∩ Ico (0 : α) 1) := by
  

Proof state:
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)

Next tactic:
ext x
theorem preimage_fract (s : Set α) :
    fract ⁻¹' s = ⋃ m : ℤ, (fun x => x - (m:α)) ⁻¹' (s ∩ Ico (0 : α) 1) := by
  ext x
  

Proof state:
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)

Next tactic:
simp only [mem_preimage, mem_iUnion, mem_inter_iff]
theorem preimage_fract (s : Set α) :
    fract ⁻¹' s = ⋃ m : ℤ, (fun x => x - (m:α)) ⁻¹' (s ∩ Ico (0 : α) 1) := by
  ext x
  simp only [mem_preimage, mem_iUnion, mem_inter_iff]
  

Proof state:
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

Next tactic:
refine' ⟨fun h => ⟨⌊x⌋, h, fract_nonneg x, fract_lt_one x⟩, _⟩
theorem preimage_fract (s : Set α) :
    fract ⁻¹' s = ⋃ m : ℤ, (fun x => x - (m:α)) ⁻¹' (s ∩ Ico (0 : α) 1) := by
  ext x
  simp only [mem_preimage, mem_iUnion, mem_inter_iff]
  refine' ⟨fun h => ⟨⌊x⌋, h, fract_nonneg x, fract_lt_one x⟩, _⟩
  

Proof state:
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

Next tactic:
rintro ⟨m, hms, hm0, hm1⟩
theorem preimage_fract (s : Set α) :
    fract ⁻¹' s = ⋃ m : ℤ, (fun x => x - (m:α)) ⁻¹' (s ∩ Ico (0 : α) 1) := by
  ext x
  simp only [mem_preimage, mem_iUnion, mem_inter_iff]
  refine' ⟨fun h => ⟨⌊x⌋, h, fract_nonneg x, fract_lt_one x⟩, _⟩
  rintro ⟨m, hms, hm0, hm1⟩
  

Proof state:
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

Next tactic:
obtain rfl : ⌊x⌋ = m := floor_eq_iff.2 ⟨sub_nonneg.1 hm0, sub_lt_iff_lt_add'.1 hm1⟩
theorem preimage_fract (s : Set α) :
    fract ⁻¹' s = ⋃ m : ℤ, (fun x => x - (m:α)) ⁻¹' (s ∩ Ico (0 : α) 1) := by
  ext x
  simp only [mem_preimage, mem_iUnion, mem_inter_iff]
  refine' ⟨fun h => ⟨⌊x⌋, h, fract_nonneg x, fract_lt_one x⟩, _⟩
  rintro ⟨m, hms, hm0, hm1⟩
  obtain rfl : ⌊x⌋ = m := floor_eq_iff.2 ⟨sub_nonneg.1 hm0, sub_lt_iff_lt_add'.1 hm1⟩
  

Proof state:
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

Next tactic:
exact hms
theorem image_fract (s : Set α) : fract '' s = ⋃ m : ℤ, (fun x : α => x - m) '' s ∩ Ico 0 1 := by
  

Proof state:
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

Next tactic:
ext x
theorem image_fract (s : Set α) : fract '' s = ⋃ m : ℤ, (fun x : α => x - m) '' s ∩ Ico 0 1 := by
  ext x
  

Proof state:
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

Next tactic:
simp only [mem_image, mem_inter_iff, mem_iUnion]
theorem image_fract (s : Set α) : fract '' s = ⋃ m : ℤ, (fun x : α => x - m) '' s ∩ Ico 0 1 := by
  ext x
  simp only [mem_image, mem_inter_iff, mem_iUnion]; 

Proof state:
case h
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
s : Set α
x : α
⊢ (∃ x_1 ∈ s, fract x_1 = x) ↔ ∃ i, (∃ x_1 ∈ s, x_1 - ↑i = x) ∧ x ∈ Ico 0 1

Next tactic:
constructor
theorem image_fract (s : Set α) : fract '' s = ⋃ m : ℤ, (fun x : α => x - m) '' s ∩ Ico 0 1 := by
  ext x
  simp only [mem_image, mem_inter_iff, mem_iUnion]; constructor
  · 

Proof state:
case h.mp
F : Type u_1
α : Type u_2
β : Type u_3
inst✝¹ : LinearOrderedRing α
inst✝ : FloorRing α
z : ℤ
a : α
s : Set α
x : α
⊢ (∃ x_1 ∈ s, fract x_1 = x) → ∃ i, (∃ x_1 ∈ s, x_1 - ↑i = x) ∧ x ∈ Ico 0 1

Next tactic:
rintro ⟨y, hy, rfl⟩
theorem image_fract (s : Set α) : fract '' s = ⋃ m : ℤ, (fun x : α => x - m) '' s ∩ Ico 0 1 := by
  ext x
  simp only [mem_image, mem_inter_iff, mem_iUnion]; constructor
  · rintro ⟨y, hy, rfl⟩
    

Proof state:
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 ∈ s, x - ↑i = fract y) ∧ fract y ∈ Ico 0 1

Next tactic:
exact ⟨⌊y⌋, ⟨y, hy, rfl⟩, fract_nonneg y, fract_lt_one y⟩
theorem image_fract (s : Set α) : fract '' s = ⋃ m : ℤ, (fun x : α => x - m) '' s ∩ Ico 0 1 := by
  ext x
  simp only [mem_image, mem_inter_iff, mem_iUnion]; constructor
  · rintro ⟨y, hy, rfl⟩
    exact ⟨⌊y⌋, ⟨y, hy, rfl⟩, fract_nonneg y, fract_lt_one y⟩
  · 

Proof state:
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 ∈ s, x_1 - ↑i = x) ∧ x ∈ Ico 0 1) → ∃ x_1 ∈ s, fract x_1 = x

Next tactic:
rintro ⟨m, ⟨y, hys, rfl⟩, h0, h1⟩
theorem image_fract (s : Set α) : fract '' s = ⋃ m : ℤ, (fun x : α => x - m) '' s ∩ Ico 0 1 := by
  ext x
  simp only [mem_image, mem_inter_iff, mem_iUnion]; constructor
  · rintro ⟨y, hy, rfl⟩
    exact ⟨⌊y⌋, ⟨y, hy, rfl⟩, fract_nonneg y, fract_lt_one y⟩
  · rintro ⟨m, ⟨y, hys, rfl⟩, h0, h1⟩
    

Proof state:
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 ∈ s, fract x = y - ↑m

Next tactic:
obtain rfl : ⌊y⌋ = m := floor_eq_iff.2 ⟨sub_nonneg.1 h0, sub_lt_iff_lt_add'.1 h1⟩
theorem image_fract (s : Set α) : fract '' s = ⋃ m : ℤ, (fun x : α => x - m) '' s ∩ Ico 0 1 := by
  ext x
  simp only [mem_image, mem_inter_iff, mem_iUnion]; constructor
  · rintro ⟨y, hy, rfl⟩
    exact ⟨⌊y⌋, ⟨y, hy, rfl⟩, fract_nonneg y, fract_lt_one y⟩
  · rintro ⟨m, ⟨y, hys, rfl⟩, h0, h1⟩
    obtain rfl : ⌊y⌋ = m := floor_eq_iff.2 ⟨sub_nonneg.1 h0, sub_lt_iff_lt_add'.1 h1⟩
    

Proof state:
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 ∈ s, fract x = y - ↑⌊y⌋

Next tactic:
exact ⟨y, hys, rfl⟩
theorem fract_div_mul_self_add_zsmul_eq (a b : k) (ha : a ≠ 0) :
    fract (b / a) * a + ⌊b / a⌋ • a = b := by
  

Proof state:
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

Next tactic:
rw [zsmul_eq_mul, ← add_mul, fract_add_floor, div_mul_cancel b ha]
theorem sub_floor_div_mul_lt (a : k) (hb : 0 < b) : a - ⌊a / b⌋ * b < b :=
  sub_lt_iff_lt_add.2 <| by
    -- Porting note: `← one_add_mul` worked in mathlib3 without the argument
    

Proof state:
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

Next tactic:
rw [← one_add_mul _ b, ← div_lt_iff hb, add_comm]
theorem sub_floor_div_mul_lt (a : k) (hb : 0 < b) : a - ⌊a / b⌋ * b < b :=
  sub_lt_iff_lt_add.2 <| by
    -- Porting note: `← one_add_mul` worked in mathlib3 without the argument
    rw [← one_add_mul _ b, ← div_lt_iff hb, add_comm]
    

Proof state:
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

Next tactic:
exact lt_floor_add_one _
theorem fract_div_natCast_eq_div_natCast_mod {m n : ℕ} : fract ((m : k) / n) = ↑(m % n) / n := by
  

Proof state:
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

Next tactic:
rcases n.eq_zero_or_pos with (rfl | hn)
theorem fract_div_natCast_eq_div_natCast_mod {m n : ℕ} : fract ((m : k) / n) = ↑(m % n) / n := by
  rcases n.eq_zero_or_pos with (rfl | hn)
  · 

Proof state:
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

Next tactic:
simp
theorem fract_div_natCast_eq_div_natCast_mod {m n : ℕ} : fract ((m : k) / n) = ↑(m % n) / n := by
  rcases n.eq_zero_or_pos with (rfl | hn)
  · simp
  

Proof state:
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

Next tactic:
have hn' : 0 < (n : k) := by
    norm_cast
theorem fract_div_natCast_eq_div_natCast_mod {m n : ℕ} : fract ((m : k) / n) = ↑(m % n) / n := by
  rcases n.eq_zero_or_pos with (rfl | hn)
  · simp
  have hn' : 0 < (n : k) := by
    

Proof state:
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

Next tactic:
norm_cast
theorem fract_div_natCast_eq_div_natCast_mod {m n : ℕ} : fract ((m : k) / n) = ↑(m % n) / n := by
  rcases n.eq_zero_or_pos with (rfl | hn)
  · simp
  have hn' : 0 < (n : k) := by
    norm_cast
  

Proof state:
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

Next tactic:
refine fract_eq_iff.mpr ⟨?_, ?_, m / n, ?_⟩
theorem fract_div_natCast_eq_div_natCast_mod {m n : ℕ} : fract ((m : k) / n) = ↑(m % n) / n := by
  rcases n.eq_zero_or_pos with (rfl | hn)
  · simp
  have hn' : 0 < (n : k) := by
    norm_cast
  refine fract_eq_iff.mpr ⟨?_, ?_, m / n, ?_⟩
  · 

Proof state:
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

Next tactic:
positivity
theorem fract_div_natCast_eq_div_natCast_mod {m n : ℕ} : fract ((m : k) / n) = ↑(m % n) / n := by
  rcases n.eq_zero_or_pos with (rfl | hn)
  · simp
  have hn' : 0 < (n : k) := by
    norm_cast
  refine fract_eq_iff.mpr ⟨?_, ?_, m / n, ?_⟩
  · positivity
  · 

Proof state:
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

Next tactic:
simpa only [div_lt_one hn', Nat.cast_lt] using m.mod_lt hn
theorem fract_div_natCast_eq_div_natCast_mod {m n : ℕ} : fract ((m : k) / n) = ↑(m % n) / n := by
  rcases n.eq_zero_or_pos with (rfl | hn)
  · simp
  have hn' : 0 < (n : k) := by
    norm_cast
  refine fract_eq_iff.mpr ⟨?_, ?_, m / n, ?_⟩
  · positivity
  · simpa only [div_lt_one hn', Nat.cast_lt] using m.mod_lt hn
  · 

Proof state:
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)

Next tactic:
rw [sub_eq_iff_eq_add', ← mul_right_inj' hn'.ne', mul_div_cancel' _ hn'.ne', mul_add,
      mul_div_cancel' _ hn'.ne']
theorem fract_div_natCast_eq_div_natCast_mod {m n : ℕ} : fract ((m : k) / n) = ↑(m % n) / n := by
  rcases n.eq_zero_or_pos with (rfl | hn)
  · simp
  have hn' : 0 < (n : k) := by
    norm_cast
  refine fract_eq_iff.mpr ⟨?_, ?_, m / n, ?_⟩
  · positivity
  · simpa only [div_lt_one hn', Nat.cast_lt] using m.mod_lt hn
  · rw [sub_eq_iff_eq_add', ← mul_right_inj' hn'.ne', mul_div_cancel' _ hn'.ne', mul_add,
      mul_div_cancel' _ hn'.ne']
    

Proof state:
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)

Next tactic:
norm_cast
theorem fract_div_natCast_eq_div_natCast_mod {m n : ℕ} : fract ((m : k) / n) = ↑(m % n) / n := by
  rcases n.eq_zero_or_pos with (rfl | hn)
  · simp
  have hn' : 0 < (n : k) := by
    norm_cast
  refine fract_eq_iff.mpr ⟨?_, ?_, m / n, ?_⟩
  · positivity
  · simpa only [div_lt_one hn', Nat.cast_lt] using m.mod_lt hn
  · rw [sub_eq_iff_eq_add', ← mul_right_inj' hn'.ne', mul_div_cancel' _ hn'.ne', mul_add,
      mul_div_cancel' _ hn'.ne']
    norm_cast
    

Proof state:
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))

Next tactic:
rw [← Nat.cast_add, Nat.mod_add_div m n]
theorem fract_div_intCast_eq_div_intCast_mod {m : ℤ} {n : ℕ} :
    fract ((m : k) / n) = ↑(m % n) / n := by
  

Proof state:
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

Next tactic:
rcases n.eq_zero_or_pos with (rfl | hn)
theorem fract_div_intCast_eq_div_intCast_mod {m : ℤ} {n : ℕ} :
    fract ((m : k) / n) = ↑(m % n) / n := by
  rcases n.eq_zero_or_pos with (rfl | hn)
  · 

Proof state:
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

Next tactic:
simp
theorem fract_div_intCast_eq_div_intCast_mod {m : ℤ} {n : ℕ} :
    fract ((m : k) / n) = ↑(m % n) / n := by
  rcases n.eq_zero_or_pos with (rfl | hn)
  · simp
  

Proof state:
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

Next tactic:
replace hn : 0 < (n : k)
theorem fract_div_intCast_eq_div_intCast_mod {m : ℤ} {n : ℕ} :
    fract ((m : k) / n) = ↑(m % n) / n := by
  rcases n.eq_zero_or_pos with (rfl | hn)
  · simp
  replace hn : 0 < (n : k)
  · 

Proof state:
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

Next tactic:
norm_cast
theorem fract_div_intCast_eq_div_intCast_mod {m : ℤ} {n : ℕ} :
    fract ((m : k) / n) = ↑(m % n) / n := by
  rcases n.eq_zero_or_pos with (rfl | hn)
  · simp
  replace hn : 0 < (n : k)
  · norm_cast
  

Proof state:
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

Next tactic:
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]
theorem fract_div_intCast_eq_div_intCast_mod {m : ℤ} {n : ℕ} :
    fract ((m : k) / n) = ↑(m % n) / n := by
  rcases n.eq_zero_or_pos with (rfl | hn)
  · simp
  replace hn : 0 < (n : k)
  · norm_cast
  have : ∀ {l : ℤ}, 0 ≤ l → fract ((l : k) / n) = ↑(l % n) / n := by
    

Proof state:
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

Next tactic:
intros l hl
theorem fract_div_intCast_eq_div_intCast_mod {m : ℤ} {n : ℕ} :
    fract ((m : k) / n) = ↑(m % n) / n := by
  rcases n.eq_zero_or_pos with (rfl | hn)
  · simp
  replace hn : 0 < (n : k)
  · norm_cast
  have : ∀ {l : ℤ}, 0 ≤ l → fract ((l : k) / n) = ↑(l % n) / n := by
    intros l hl
    

Proof state:
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

Next tactic:
obtain ⟨l₀, rfl | rfl⟩ := l.eq_nat_or_neg
theorem fract_div_intCast_eq_div_intCast_mod {m : ℤ} {n : ℕ} :
    fract ((m : k) / n) = ↑(m % n) / n := by
  rcases n.eq_zero_or_pos with (rfl | hn)
  · simp
  replace hn : 0 < (n : k)
  · norm_cast
  have : ∀ {l : ℤ}, 0 ≤ l → fract ((l : k) / n) = ↑(l % n) / n := by
    intros l hl
    obtain ⟨l₀, rfl | rfl⟩ := l.eq_nat_or_neg
    · 

Proof state:
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

Next tactic:
rw [cast_ofNat, ← coe_nat_mod, cast_ofNat, fract_div_natCast_eq_div_natCast_mod]
theorem fract_div_intCast_eq_div_intCast_mod {m : ℤ} {n : ℕ} :
    fract ((m : k) / n) = ↑(m % n) / n := by
  rcases n.eq_zero_or_pos with (rfl | hn)
  · simp
  replace hn : 0 < (n : k)
  · norm_cast
  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]
    · 

Proof state:
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

Next tactic:
rw [Right.nonneg_neg_iff, coe_nat_nonpos_iff] at hl