[GOAL]
p x t : ℝ
⊢ ‖↑(t * x)‖ = |t| * ‖↑x‖
[PROOFSTEP]
have aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b) := fun {a b c} h =>
  by
  simp only [mem_zmultiples_iff] at h ⊢
  obtain ⟨n, rfl⟩ := h
  exact ⟨n, (mul_smul_comm n c b).symm⟩
[GOAL]
p x t a b c : ℝ
h : a ∈ zmultiples b
⊢ c * a ∈ zmultiples (c * b)
[PROOFSTEP]
simp only [mem_zmultiples_iff] at h ⊢
[GOAL]
p x t a b c : ℝ
h : ∃ k, k • b = a
⊢ ∃ k, k • (c * b) = c * a
[PROOFSTEP]
obtain ⟨n, rfl⟩ := h
[GOAL]
case intro
p x t b c : ℝ
n : ℤ
⊢ ∃ k, k • (c * b) = c * n • b
[PROOFSTEP]
exact ⟨n, (mul_smul_comm n c b).symm⟩
[GOAL]
p x t : ℝ
aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b)
⊢ ‖↑(t * x)‖ = |t| * ‖↑x‖
[PROOFSTEP]
rcases eq_or_ne t 0 with (rfl | ht)
[GOAL]
case inl
p x : ℝ
aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b)
⊢ ‖↑(0 * x)‖ = |0| * ‖↑x‖
[PROOFSTEP]
simp
[GOAL]
case inr
p x t : ℝ
aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b)
ht : t ≠ 0
⊢ ‖↑(t * x)‖ = |t| * ‖↑x‖
[PROOFSTEP]
have ht' : |t| ≠ 0 := (not_congr abs_eq_zero).mpr ht
[GOAL]
case inr
p x t : ℝ
aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b)
ht : t ≠ 0
ht' : |t| ≠ 0
⊢ ‖↑(t * x)‖ = |t| * ‖↑x‖
[PROOFSTEP]
simp only [quotient_norm_eq, Real.norm_eq_abs]
[GOAL]
case inr
p x t : ℝ
aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b)
ht : t ≠ 0
ht' : |t| ≠ 0
⊢ sInf ((fun a => |a|) '' {m | ↑m = ↑(t * x)}) = |t| * sInf ((fun a => |a|) '' {m | ↑m = ↑x})
[PROOFSTEP]
conv_rhs => rw [← smul_eq_mul, ← Real.sInf_smul_of_nonneg (abs_nonneg t)]
[GOAL]
p x t : ℝ
aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b)
ht : t ≠ 0
ht' : |t| ≠ 0
| |t| * sInf ((fun a => |a|) '' {m | ↑m = ↑x})
[PROOFSTEP]
rw [← smul_eq_mul, ← Real.sInf_smul_of_nonneg (abs_nonneg t)]
[GOAL]
p x t : ℝ
aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b)
ht : t ≠ 0
ht' : |t| ≠ 0
| |t| * sInf ((fun a => |a|) '' {m | ↑m = ↑x})
[PROOFSTEP]
rw [← smul_eq_mul, ← Real.sInf_smul_of_nonneg (abs_nonneg t)]
[GOAL]
p x t : ℝ
aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b)
ht : t ≠ 0
ht' : |t| ≠ 0
| |t| * sInf ((fun a => |a|) '' {m | ↑m = ↑x})
[PROOFSTEP]
rw [← smul_eq_mul, ← Real.sInf_smul_of_nonneg (abs_nonneg t)]
[GOAL]
case inr
p x t : ℝ
aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b)
ht : t ≠ 0
ht' : |t| ≠ 0
⊢ sInf ((fun a => |a|) '' {m | ↑m = ↑(t * x)}) = sInf (|t| • (fun a => |a|) '' {m | ↑m = ↑x})
[PROOFSTEP]
simp only [QuotientAddGroup.mk'_apply, QuotientAddGroup.eq_iff_sub_mem]
[GOAL]
case inr
p x t : ℝ
aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b)
ht : t ≠ 0
ht' : |t| ≠ 0
⊢ sInf ((fun a => |a|) '' {m | m - t * x ∈ zmultiples (t * p)}) =
    sInf (|t| • (fun a => |a|) '' {m | m - x ∈ zmultiples p})
[PROOFSTEP]
congr 1
[GOAL]
case inr.e_a
p x t : ℝ
aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b)
ht : t ≠ 0
ht' : |t| ≠ 0
⊢ (fun a => |a|) '' {m | m - t * x ∈ zmultiples (t * p)} = |t| • (fun a => |a|) '' {m | m - x ∈ zmultiples p}
[PROOFSTEP]
ext z
[GOAL]
case inr.e_a.h
p x t : ℝ
aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b)
ht : t ≠ 0
ht' : |t| ≠ 0
z : ℝ
⊢ z ∈ (fun a => |a|) '' {m | m - t * x ∈ zmultiples (t * p)} ↔ z ∈ |t| • (fun a => |a|) '' {m | m - x ∈ zmultiples p}
[PROOFSTEP]
rw [mem_smul_set_iff_inv_smul_mem₀ ht']
[GOAL]
case inr.e_a.h
p x t : ℝ
aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b)
ht : t ≠ 0
ht' : |t| ≠ 0
z : ℝ
⊢ z ∈ (fun a => |a|) '' {m | m - t * x ∈ zmultiples (t * p)} ↔ |t|⁻¹ • z ∈ (fun a => |a|) '' {m | m - x ∈ zmultiples p}
[PROOFSTEP]
show (∃ y, y - t * x ∈ zmultiples (t * p) ∧ |y| = z) ↔ ∃ w, w - x ∈ zmultiples p ∧ |w| = |t|⁻¹ * z
[GOAL]
case inr.e_a.h
p x t : ℝ
aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b)
ht : t ≠ 0
ht' : |t| ≠ 0
z : ℝ
⊢ (∃ y, y - t * x ∈ zmultiples (t * p) ∧ |y| = z) ↔ ∃ w, w - x ∈ zmultiples p ∧ |w| = |t|⁻¹ * z
[PROOFSTEP]
constructor
[GOAL]
case inr.e_a.h.mp
p x t : ℝ
aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b)
ht : t ≠ 0
ht' : |t| ≠ 0
z : ℝ
⊢ (∃ y, y - t * x ∈ zmultiples (t * p) ∧ |y| = z) → ∃ w, w - x ∈ zmultiples p ∧ |w| = |t|⁻¹ * z
[PROOFSTEP]
rintro ⟨y, hy, rfl⟩
[GOAL]
case inr.e_a.h.mp.intro.intro
p x t : ℝ
aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b)
ht : t ≠ 0
ht' : |t| ≠ 0
y : ℝ
hy : y - t * x ∈ zmultiples (t * p)
⊢ ∃ w, w - x ∈ zmultiples p ∧ |w| = |t|⁻¹ * |y|
[PROOFSTEP]
refine' ⟨t⁻¹ * y, _, by rw [abs_mul, abs_inv]⟩
[GOAL]
p x t : ℝ
aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b)
ht : t ≠ 0
ht' : |t| ≠ 0
y : ℝ
hy : y - t * x ∈ zmultiples (t * p)
⊢ |t⁻¹ * y| = |t|⁻¹ * |y|
[PROOFSTEP]
rw [abs_mul, abs_inv]
[GOAL]
case inr.e_a.h.mp.intro.intro
p x t : ℝ
aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b)
ht : t ≠ 0
ht' : |t| ≠ 0
y : ℝ
hy : y - t * x ∈ zmultiples (t * p)
⊢ t⁻¹ * y - x ∈ zmultiples p
[PROOFSTEP]
rw [← inv_mul_cancel_left₀ ht x, ← inv_mul_cancel_left₀ ht p, ← mul_sub]
[GOAL]
case inr.e_a.h.mp.intro.intro
p x t : ℝ
aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b)
ht : t ≠ 0
ht' : |t| ≠ 0
y : ℝ
hy : y - t * x ∈ zmultiples (t * p)
⊢ t⁻¹ * (y - t * x) ∈ zmultiples (t⁻¹ * (t * p))
[PROOFSTEP]
exact aux hy
[GOAL]
case inr.e_a.h.mpr
p x t : ℝ
aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b)
ht : t ≠ 0
ht' : |t| ≠ 0
z : ℝ
⊢ (∃ w, w - x ∈ zmultiples p ∧ |w| = |t|⁻¹ * z) → ∃ y, y - t * x ∈ zmultiples (t * p) ∧ |y| = z
[PROOFSTEP]
rintro ⟨w, hw, hw'⟩
[GOAL]
case inr.e_a.h.mpr.intro.intro
p x t : ℝ
aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b)
ht : t ≠ 0
ht' : |t| ≠ 0
z w : ℝ
hw : w - x ∈ zmultiples p
hw' : |w| = |t|⁻¹ * z
⊢ ∃ y, y - t * x ∈ zmultiples (t * p) ∧ |y| = z
[PROOFSTEP]
refine' ⟨t * w, _, by rw [← (eq_inv_mul_iff_mul_eq₀ ht').mp hw', abs_mul]⟩
[GOAL]
p x t : ℝ
aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b)
ht : t ≠ 0
ht' : |t| ≠ 0
z w : ℝ
hw : w - x ∈ zmultiples p
hw' : |w| = |t|⁻¹ * z
⊢ |t * w| = z
[PROOFSTEP]
rw [← (eq_inv_mul_iff_mul_eq₀ ht').mp hw', abs_mul]
[GOAL]
case inr.e_a.h.mpr.intro.intro
p x t : ℝ
aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b)
ht : t ≠ 0
ht' : |t| ≠ 0
z w : ℝ
hw : w - x ∈ zmultiples p
hw' : |w| = |t|⁻¹ * z
⊢ t * w - t * x ∈ zmultiples (t * p)
[PROOFSTEP]
rw [← mul_sub]
[GOAL]
case inr.e_a.h.mpr.intro.intro
p x t : ℝ
aux : ∀ {a b c : ℝ}, a ∈ zmultiples b → c * a ∈ zmultiples (c * b)
ht : t ≠ 0
ht' : |t| ≠ 0
z w : ℝ
hw : w - x ∈ zmultiples p
hw' : |w| = |t|⁻¹ * z
⊢ t * (w - x) ∈ zmultiples (t * p)
[PROOFSTEP]
exact aux hw
[GOAL]
p x : ℝ
⊢ ‖↑x‖ = ‖↑x‖
[PROOFSTEP]
suffices ‖(↑(-1 * x) : AddCircle (-1 * p))‖ = ‖(x : AddCircle p)‖
  by
  rw [← this, neg_one_mul]
  simp
[GOAL]
p x : ℝ
this : ‖↑(-1 * x)‖ = ‖↑x‖
⊢ ‖↑x‖ = ‖↑x‖
[PROOFSTEP]
rw [← this, neg_one_mul]
[GOAL]
p x : ℝ
this : ‖↑(-1 * x)‖ = ‖↑x‖
⊢ ‖↑x‖ = ‖↑(-1 * x)‖
[PROOFSTEP]
simp
[GOAL]
p x : ℝ
⊢ ‖↑(-1 * x)‖ = ‖↑x‖
[PROOFSTEP]
simp only [norm_coe_mul, abs_neg, abs_one, one_mul]
[GOAL]
p x : ℝ
⊢ ‖↑x‖ = |x|
[PROOFSTEP]
suffices {y : ℝ | (y : AddCircle (0 : ℝ)) = (x : AddCircle (0 : ℝ))} = { x } by
  rw [quotient_norm_eq, this, image_singleton, Real.norm_eq_abs, csInf_singleton]
[GOAL]
p x : ℝ
this : {y | ↑y = ↑x} = {x}
⊢ ‖↑x‖ = |x|
[PROOFSTEP]
rw [quotient_norm_eq, this, image_singleton, Real.norm_eq_abs, csInf_singleton]
[GOAL]
p x : ℝ
⊢ {y | ↑y = ↑x} = {x}
[PROOFSTEP]
ext y
[GOAL]
case h
p x y : ℝ
⊢ y ∈ {y | ↑y = ↑x} ↔ y ∈ {x}
[PROOFSTEP]
simp [QuotientAddGroup.eq_iff_sub_mem, mem_zmultiples_iff, sub_eq_zero]
[GOAL]
p x : ℝ
⊢ ‖↑x‖ = |x - ↑(round (p⁻¹ * x)) * p|
[PROOFSTEP]
suffices ∀ x : ℝ, ‖(x : AddCircle (1 : ℝ))‖ = |x - round x|
  by
  rcases eq_or_ne p 0 with (rfl | hp)
  · simp
  intros
  have hx := norm_coe_mul p x p⁻¹
  rw [abs_inv, eq_inv_mul_iff_mul_eq₀ ((not_congr abs_eq_zero).mpr hp)] at hx 
  rw [← hx, inv_mul_cancel hp, this, ← abs_mul, mul_sub, mul_inv_cancel_left₀ hp, mul_comm p]
[GOAL]
p x : ℝ
this : ∀ (x : ℝ), ‖↑x‖ = |x - ↑(round x)|
⊢ ‖↑x‖ = |x - ↑(round (p⁻¹ * x)) * p|
[PROOFSTEP]
rcases eq_or_ne p 0 with (rfl | hp)
[GOAL]
case inl
x : ℝ
this : ∀ (x : ℝ), ‖↑x‖ = |x - ↑(round x)|
⊢ ‖↑x‖ = |x - ↑(round (0⁻¹ * x)) * 0|
[PROOFSTEP]
simp
[GOAL]
case inr
p x : ℝ
this : ∀ (x : ℝ), ‖↑x‖ = |x - ↑(round x)|
hp : p ≠ 0
⊢ ‖↑x‖ = |x - ↑(round (p⁻¹ * x)) * p|
[PROOFSTEP]
intros
[GOAL]
case inr
p x : ℝ
this : ∀ (x : ℝ), ‖↑x‖ = |x - ↑(round x)|
hp : p ≠ 0
⊢ ‖↑x‖ = |x - ↑(round (p⁻¹ * x)) * p|
[PROOFSTEP]
have hx := norm_coe_mul p x p⁻¹
[GOAL]
case inr
p x : ℝ
this : ∀ (x : ℝ), ‖↑x‖ = |x - ↑(round x)|
hp : p ≠ 0
hx : ‖↑(p⁻¹ * x)‖ = |p⁻¹| * ‖↑x‖
⊢ ‖↑x‖ = |x - ↑(round (p⁻¹ * x)) * p|
[PROOFSTEP]
rw [abs_inv, eq_inv_mul_iff_mul_eq₀ ((not_congr abs_eq_zero).mpr hp)] at hx 
[GOAL]
case inr
p x : ℝ
this : ∀ (x : ℝ), ‖↑x‖ = |x - ↑(round x)|
hp : p ≠ 0
hx : |p| * ‖↑(p⁻¹ * x)‖ = ‖↑x‖
⊢ ‖↑x‖ = |x - ↑(round (p⁻¹ * x)) * p|
[PROOFSTEP]
rw [← hx, inv_mul_cancel hp, this, ← abs_mul, mul_sub, mul_inv_cancel_left₀ hp, mul_comm p]
[GOAL]
p x : ℝ
⊢ ∀ (x : ℝ), ‖↑x‖ = |x - ↑(round x)|
[PROOFSTEP]
clear! x p
[GOAL]
⊢ ∀ (x : ℝ), ‖↑x‖ = |x - ↑(round x)|
[PROOFSTEP]
intros x
[GOAL]
x : ℝ
⊢ ‖↑x‖ = |x - ↑(round x)|
[PROOFSTEP]
rw [quotient_norm_eq, abs_sub_round_eq_min]
[GOAL]
x : ℝ
⊢ sInf (norm '' {m | ↑m = ↑x}) = min (fract x) (1 - fract x)
[PROOFSTEP]
have h₁ : BddBelow (abs '' {m : ℝ | (m : AddCircle (1 : ℝ)) = x}) := ⟨0, by simp [mem_lowerBounds]⟩
[GOAL]
x : ℝ
⊢ 0 ∈ lowerBounds (abs '' {m | ↑m = ↑x})
[PROOFSTEP]
simp [mem_lowerBounds]
[GOAL]
x : ℝ
h₁ : BddBelow (abs '' {m | ↑m = ↑x})
⊢ sInf (norm '' {m | ↑m = ↑x}) = min (fract x) (1 - fract x)
[PROOFSTEP]
have h₂ : (abs '' {m : ℝ | (m : AddCircle (1 : ℝ)) = x}).Nonempty := ⟨|x|, ⟨x, rfl, rfl⟩⟩
[GOAL]
x : ℝ
h₁ : BddBelow (abs '' {m | ↑m = ↑x})
h₂ : Set.Nonempty (abs '' {m | ↑m = ↑x})
⊢ sInf (norm '' {m | ↑m = ↑x}) = min (fract x) (1 - fract x)
[PROOFSTEP]
apply le_antisymm
[GOAL]
case a
x : ℝ
h₁ : BddBelow (abs '' {m | ↑m = ↑x})
h₂ : Set.Nonempty (abs '' {m | ↑m = ↑x})
⊢ sInf (norm '' {m | ↑m = ↑x}) ≤ min (fract x) (1 - fract x)
[PROOFSTEP]
simp_rw [Real.norm_eq_abs, csInf_le_iff h₁ h₂, le_min_iff]
[GOAL]
case a
x : ℝ
h₁ : BddBelow (abs '' {m | ↑m = ↑x})
h₂ : Set.Nonempty (abs '' {m | ↑m = ↑x})
⊢ ∀ (b : ℝ), b ∈ lowerBounds (abs '' {m | ↑m = ↑x}) → b ≤ fract x ∧ b ≤ 1 - fract x
[PROOFSTEP]
intro b h
[GOAL]
case a
x : ℝ
h₁ : BddBelow (abs '' {m | ↑m = ↑x})
h₂ : Set.Nonempty (abs '' {m | ↑m = ↑x})
b : ℝ
h : b ∈ lowerBounds (abs '' {m | ↑m = ↑x})
⊢ b ≤ fract x ∧ b ≤ 1 - fract x
[PROOFSTEP]
refine'
  ⟨mem_lowerBounds.1 h _ ⟨fract x, _, abs_fract⟩,
    mem_lowerBounds.1 h _ ⟨fract x - 1, _, by rw [abs_sub_comm, abs_one_sub_fract]⟩⟩
[GOAL]
x : ℝ
h₁ : BddBelow (abs '' {m | ↑m = ↑x})
h₂ : Set.Nonempty (abs '' {m | ↑m = ↑x})
b : ℝ
h : b ∈ lowerBounds (abs '' {m | ↑m = ↑x})
⊢ |fract x - 1| = 1 - fract x
[PROOFSTEP]
rw [abs_sub_comm, abs_one_sub_fract]
[GOAL]
case a.refine'_1
x : ℝ
h₁ : BddBelow (abs '' {m | ↑m = ↑x})
h₂ : Set.Nonempty (abs '' {m | ↑m = ↑x})
b : ℝ
h : b ∈ lowerBounds (abs '' {m | ↑m = ↑x})
⊢ fract x ∈ {m | ↑m = ↑x}
[PROOFSTEP]
simp only [mem_setOf, fract, sub_eq_self, QuotientAddGroup.mk_sub, QuotientAddGroup.eq_zero_iff,
  int_cast_mem_zmultiples_one]
[GOAL]
case a.refine'_2
x : ℝ
h₁ : BddBelow (abs '' {m | ↑m = ↑x})
h₂ : Set.Nonempty (abs '' {m | ↑m = ↑x})
b : ℝ
h : b ∈ lowerBounds (abs '' {m | ↑m = ↑x})
⊢ fract x - 1 ∈ {m | ↑m = ↑x}
[PROOFSTEP]
simp only [mem_setOf, fract, sub_eq_self, QuotientAddGroup.mk_sub, QuotientAddGroup.eq_zero_iff,
  int_cast_mem_zmultiples_one, sub_sub, (by norm_cast : (⌊x⌋ : ℝ) + 1 = (↑(⌊x⌋ + 1) : ℝ))]
[GOAL]
x : ℝ
h₁ : BddBelow (abs '' {m | ↑m = ↑x})
h₂ : Set.Nonempty (abs '' {m | ↑m = ↑x})
b : ℝ
h : b ∈ lowerBounds (abs '' {m | ↑m = ↑x})
⊢ ↑⌊x⌋ + 1 = ↑(⌊x⌋ + 1)
[PROOFSTEP]
norm_cast
[GOAL]
case a
x : ℝ
h₁ : BddBelow (abs '' {m | ↑m = ↑x})
h₂ : Set.Nonempty (abs '' {m | ↑m = ↑x})
⊢ min (fract x) (1 - fract x) ≤ sInf (norm '' {m | ↑m = ↑x})
[PROOFSTEP]
simp only [QuotientAddGroup.mk'_apply, Real.norm_eq_abs, le_csInf_iff h₁ h₂]
[GOAL]
case a
x : ℝ
h₁ : BddBelow (abs '' {m | ↑m = ↑x})
h₂ : Set.Nonempty (abs '' {m | ↑m = ↑x})
⊢ ∀ (b : ℝ), b ∈ abs '' {m | ↑m = ↑x} → min (fract x) (1 - fract x) ≤ b
[PROOFSTEP]
rintro b' ⟨b, hb, rfl⟩
[GOAL]
case a.intro.intro
x : ℝ
h₁ : BddBelow (abs '' {m | ↑m = ↑x})
h₂ : Set.Nonempty (abs '' {m | ↑m = ↑x})
b : ℝ
hb : b ∈ {m | ↑m = ↑x}
⊢ min (fract x) (1 - fract x) ≤ |b|
[PROOFSTEP]
simp only [mem_setOf, QuotientAddGroup.eq_iff_sub_mem, mem_zmultiples_iff, smul_one_eq_coe] at hb 
[GOAL]
case a.intro.intro
x : ℝ
h₁ : BddBelow (abs '' {m | ↑m = ↑x})
h₂ : Set.Nonempty (abs '' {m | ↑m = ↑x})
b : ℝ
hb : ∃ k, ↑k = b - x
⊢ min (fract x) (1 - fract x) ≤ |b|
[PROOFSTEP]
obtain ⟨z, hz⟩ := hb
[GOAL]
case a.intro.intro.intro
x : ℝ
h₁ : BddBelow (abs '' {m | ↑m = ↑x})
h₂ : Set.Nonempty (abs '' {m | ↑m = ↑x})
b : ℝ
z : ℤ
hz : ↑z = b - x
⊢ min (fract x) (1 - fract x) ≤ |b|
[PROOFSTEP]
rw [(by rw [hz]; abel : x = b - z), fract_sub_int, ← abs_sub_round_eq_min]
[GOAL]
x : ℝ
h₁ : BddBelow (abs '' {m | ↑m = ↑x})
h₂ : Set.Nonempty (abs '' {m | ↑m = ↑x})
b : ℝ
z : ℤ
hz : ↑z = b - x
⊢ x = b - ↑z
[PROOFSTEP]
rw [hz]
[GOAL]
x : ℝ
h₁ : BddBelow (abs '' {m | ↑m = ↑x})
h₂ : Set.Nonempty (abs '' {m | ↑m = ↑x})
b : ℝ
z : ℤ
hz : ↑z = b - x
⊢ x = b - (b - x)
[PROOFSTEP]
abel
[GOAL]
x : ℝ
h₁ : BddBelow (abs '' {m | ↑m = ↑x})
h₂ : Set.Nonempty (abs '' {m | ↑m = ↑x})
b : ℝ
z : ℤ
hz : ↑z = b - x
⊢ x = b - (b - x)
[PROOFSTEP]
abel
[GOAL]
case a.intro.intro.intro
x : ℝ
h₁ : BddBelow (abs '' {m | ↑m = ↑x})
h₂ : Set.Nonempty (abs '' {m | ↑m = ↑x})
b : ℝ
z : ℤ
hz : ↑z = b - x
⊢ |b - ↑(round b)| ≤ |b|
[PROOFSTEP]
convert round_le b 0
[GOAL]
case h.e'_4.h.e'_3
x : ℝ
h₁ : BddBelow (abs '' {m | ↑m = ↑x})
h₂ : Set.Nonempty (abs '' {m | ↑m = ↑x})
b : ℝ
z : ℤ
hz : ↑z = b - x
⊢ b = b - ↑0
[PROOFSTEP]
simp
[GOAL]
p : ℝ
hp : 0 < p
x : ℝ
⊢ ‖↑x‖ = p * |p⁻¹ * x - ↑(round (p⁻¹ * x))|
[PROOFSTEP]
conv_rhs =>
  congr
  rw [← abs_eq_self.mpr hp.le]
[GOAL]
p : ℝ
hp : 0 < p
x : ℝ
| p * |p⁻¹ * x - ↑(round (p⁻¹ * x))|
[PROOFSTEP]
  congr
  rw [← abs_eq_self.mpr hp.le]
[GOAL]
p : ℝ
hp : 0 < p
x : ℝ
| p * |p⁻¹ * x - ↑(round (p⁻¹ * x))|
[PROOFSTEP]
  congr
  rw [← abs_eq_self.mpr hp.le]
[GOAL]
p : ℝ
hp : 0 < p
x : ℝ
| p * |p⁻¹ * x - ↑(round (p⁻¹ * x))|
[PROOFSTEP]
congr
[GOAL]
case a
p : ℝ
hp : 0 < p
x : ℝ
| p
case a p : ℝ hp : 0 < p x : ℝ | |p⁻¹ * x - ↑(round (p⁻¹ * x))|
[PROOFSTEP]
rw [← abs_eq_self.mpr hp.le]
[GOAL]
p : ℝ
hp : 0 < p
x : ℝ
⊢ ‖↑x‖ = |p| * |p⁻¹ * x - ↑(round (p⁻¹ * x))|
[PROOFSTEP]
rw [← abs_mul, mul_sub, mul_inv_cancel_left₀ hp.ne.symm, norm_eq, mul_comm p]
[GOAL]
p : ℝ
x : AddCircle p
hp : p ≠ 0
⊢ ‖x‖ ≤ |p| / 2
[PROOFSTEP]
obtain ⟨x⟩ := x
[GOAL]
case mk
p : ℝ
x✝ : AddCircle p
hp : p ≠ 0
x : ℝ
⊢ ‖Quot.mk Setoid.r x‖ ≤ |p| / 2
[PROOFSTEP]
change ‖(x : AddCircle p)‖ ≤ |p| / 2
[GOAL]
case mk
p : ℝ
x✝ : AddCircle p
hp : p ≠ 0
x : ℝ
⊢ ‖↑x‖ ≤ |p| / 2
[PROOFSTEP]
rw [norm_eq, ← mul_le_mul_left (abs_pos.mpr (inv_ne_zero hp)), ← abs_mul, mul_sub, mul_left_comm, ← mul_div_assoc, ←
  abs_mul, inv_mul_cancel hp, mul_one, abs_one]
[GOAL]
case mk
p : ℝ
x✝ : AddCircle p
hp : p ≠ 0
x : ℝ
⊢ |p⁻¹ * x - ↑(round (p⁻¹ * x))| ≤ 1 / 2
[PROOFSTEP]
exact abs_sub_round (p⁻¹ * x)
[GOAL]
p : ℝ
⊢ ‖↑(p / 2)‖ = |p| / 2
[PROOFSTEP]
rcases eq_or_ne p 0 with (rfl | hp)
[GOAL]
case inl
⊢ ‖↑(0 / 2)‖ = |0| / 2
[PROOFSTEP]
simp
[GOAL]
case inr
p : ℝ
hp : p ≠ 0
⊢ ‖↑(p / 2)‖ = |p| / 2
[PROOFSTEP]
rw [norm_eq, ← mul_div_assoc, inv_mul_cancel hp, one_div, round_two_inv, Int.cast_one, one_mul,
  (by linarith : p / 2 - p = -(p / 2)), abs_neg, abs_div, abs_two]
[GOAL]
p : ℝ
hp : p ≠ 0
⊢ p / 2 - p = -(p / 2)
[PROOFSTEP]
linarith
[GOAL]
p x : ℝ
hp : p ≠ 0
⊢ ‖↑x‖ = |x| ↔ |x| ≤ |p| / 2
[PROOFSTEP]
refine' ⟨fun hx => hx ▸ norm_le_half_period p hp, fun hx => _⟩
[GOAL]
p x : ℝ
hp : p ≠ 0
hx : |x| ≤ |p| / 2
⊢ ‖↑x‖ = |x|
[PROOFSTEP]
suffices ∀ p : ℝ, 0 < p → |x| ≤ p / 2 → ‖(x : AddCircle p)‖ = |x| by
  -- Porting note: replaced `lt_trichotomy` which had trouble substituting `p = 0`.
  rcases hp.symm.lt_or_lt with (hp | hp)
  · rw [abs_eq_self.mpr hp.le] at hx 
    exact this p hp hx
  · rw [← norm_neg_period]
    rw [abs_eq_neg_self.mpr hp.le] at hx 
    exact this (-p) (neg_pos.mpr hp) hx
[GOAL]
p x : ℝ
hp : p ≠ 0
hx : |x| ≤ |p| / 2
this : ∀ (p : ℝ), 0 < p → |x| ≤ p / 2 → ‖↑x‖ = |x|
⊢ ‖↑x‖ = |x|
[PROOFSTEP]
rcases hp.symm.lt_or_lt with (hp | hp)
[GOAL]
case inl
p x : ℝ
hp✝ : p ≠ 0
hx : |x| ≤ |p| / 2
this : ∀ (p : ℝ), 0 < p → |x| ≤ p / 2 → ‖↑x‖ = |x|
hp : 0 < p
⊢ ‖↑x‖ = |x|
[PROOFSTEP]
rw [abs_eq_self.mpr hp.le] at hx 
[GOAL]
case inl
p x : ℝ
hp✝ : p ≠ 0
hx : |x| ≤ p / 2
this : ∀ (p : ℝ), 0 < p → |x| ≤ p / 2 → ‖↑x‖ = |x|
hp : 0 < p
⊢ ‖↑x‖ = |x|
[PROOFSTEP]
exact this p hp hx
[GOAL]
case inr
p x : ℝ
hp✝ : p ≠ 0
hx : |x| ≤ |p| / 2
this : ∀ (p : ℝ), 0 < p → |x| ≤ p / 2 → ‖↑x‖ = |x|
hp : p < 0
⊢ ‖↑x‖ = |x|
[PROOFSTEP]
rw [← norm_neg_period]
[GOAL]
case inr
p x : ℝ
hp✝ : p ≠ 0
hx : |x| ≤ |p| / 2
this : ∀ (p : ℝ), 0 < p → |x| ≤ p / 2 → ‖↑x‖ = |x|
hp : p < 0
⊢ ‖↑x‖ = |x|
[PROOFSTEP]
rw [abs_eq_neg_self.mpr hp.le] at hx 
[GOAL]
case inr
p x : ℝ
hp✝ : p ≠ 0
hx : |x| ≤ -p / 2
this : ∀ (p : ℝ), 0 < p → |x| ≤ p / 2 → ‖↑x‖ = |x|
hp : p < 0
⊢ ‖↑x‖ = |x|
[PROOFSTEP]
exact this (-p) (neg_pos.mpr hp) hx
[GOAL]
p x : ℝ
hp : p ≠ 0
hx : |x| ≤ |p| / 2
⊢ ∀ (p : ℝ), 0 < p → |x| ≤ p / 2 → ‖↑x‖ = |x|
[PROOFSTEP]
clear hx
[GOAL]
p x : ℝ
hp : p ≠ 0
⊢ ∀ (p : ℝ), 0 < p → |x| ≤ p / 2 → ‖↑x‖ = |x|
[PROOFSTEP]
intro p hp hx
[GOAL]
p✝ x : ℝ
hp✝ : p✝ ≠ 0
p : ℝ
hp : 0 < p
hx : |x| ≤ p / 2
⊢ ‖↑x‖ = |x|
[PROOFSTEP]
rcases eq_or_ne x (p / (2 : ℝ)) with (rfl | hx')
[GOAL]
case inl
p✝ : ℝ
hp✝ : p✝ ≠ 0
p : ℝ
hp : 0 < p
hx : |p / 2| ≤ p / 2
⊢ ‖↑(p / 2)‖ = |p / 2|
[PROOFSTEP]
simp [abs_div, abs_two]
[GOAL]
case inr
p✝ x : ℝ
hp✝ : p✝ ≠ 0
p : ℝ
hp : 0 < p
hx : |x| ≤ p / 2
hx' : x ≠ p / 2
⊢ ‖↑x‖ = |x|
[PROOFSTEP]
suffices round (p⁻¹ * x) = 0 by simp [norm_eq, this]
[GOAL]
p✝ x : ℝ
hp✝ : p✝ ≠ 0
p : ℝ
hp : 0 < p
hx : |x| ≤ p / 2
hx' : x ≠ p / 2
this : round (p⁻¹ * x) = 0
⊢ ‖↑x‖ = |x|
[PROOFSTEP]
simp [norm_eq, this]
[GOAL]
case inr
p✝ x : ℝ
hp✝ : p✝ ≠ 0
p : ℝ
hp : 0 < p
hx : |x| ≤ p / 2
hx' : x ≠ p / 2
⊢ round (p⁻¹ * x) = 0
[PROOFSTEP]
rw [round_eq_zero_iff]
[GOAL]
case inr
p✝ x : ℝ
hp✝ : p✝ ≠ 0
p : ℝ
hp : 0 < p
hx : |x| ≤ p / 2
hx' : x ≠ p / 2
⊢ p⁻¹ * x ∈ Ico (-(1 / 2)) (1 / 2)
[PROOFSTEP]
obtain ⟨hx₁, hx₂⟩ := abs_le.mp hx
[GOAL]
case inr.intro
p✝ x : ℝ
hp✝ : p✝ ≠ 0
p : ℝ
hp : 0 < p
hx : |x| ≤ p / 2
hx' : x ≠ p / 2
hx₁ : -(p / 2) ≤ x
hx₂ : x ≤ p / 2
⊢ p⁻¹ * x ∈ Ico (-(1 / 2)) (1 / 2)
[PROOFSTEP]
replace hx₂ := Ne.lt_of_le hx' hx₂
[GOAL]
case inr.intro
p✝ x : ℝ
hp✝ : p✝ ≠ 0
p : ℝ
hp : 0 < p
hx : |x| ≤ p / 2
hx' : x ≠ p / 2
hx₁ : -(p / 2) ≤ x
hx₂ : x < p / 2
⊢ p⁻¹ * x ∈ Ico (-(1 / 2)) (1 / 2)
[PROOFSTEP]
constructor
[GOAL]
case inr.intro.left
p✝ x : ℝ
hp✝ : p✝ ≠ 0
p : ℝ
hp : 0 < p
hx : |x| ≤ p / 2
hx' : x ≠ p / 2
hx₁ : -(p / 2) ≤ x
hx₂ : x < p / 2
⊢ -(1 / 2) ≤ p⁻¹ * x
[PROOFSTEP]
rwa [← mul_le_mul_left hp, ← mul_assoc, mul_inv_cancel hp.ne.symm, one_mul, mul_neg, ← mul_div_assoc, mul_one]
[GOAL]
case inr.intro.right
p✝ x : ℝ
hp✝ : p✝ ≠ 0
p : ℝ
hp : 0 < p
hx : |x| ≤ p / 2
hx' : x ≠ p / 2
hx₁ : -(p / 2) ≤ x
hx₂ : x < p / 2
⊢ p⁻¹ * x < 1 / 2
[PROOFSTEP]
rwa [← mul_lt_mul_left hp, ← mul_assoc, mul_inv_cancel hp.ne.symm, one_mul, ← mul_div_assoc, mul_one]
[GOAL]
p : ℝ
hp : p ≠ 0
x✝ : AddCircle p
ε : ℝ
hε : |p| / 2 ≤ ε
x : AddCircle p
⊢ x ∈ closedBall x✝ ε
[PROOFSTEP]
simpa only [mem_closedBall, dist_eq_norm] using (norm_le_half_period p hp).trans hε
[GOAL]
p x ε : ℝ
⊢ QuotientAddGroup.mk ⁻¹' closedBall (↑x) ε = closedBall x ε
[PROOFSTEP]
ext y
[GOAL]
case h
p x ε y : ℝ
⊢ y ∈ QuotientAddGroup.mk ⁻¹' closedBall (↑x) ε ↔ y ∈ closedBall x ε
[PROOFSTEP]
simp only [Set.mem_preimage, dist_eq_norm, AddCircle.norm_eq_of_zero, iff_self, ← QuotientAddGroup.mk_sub,
  Metric.mem_closedBall, Real.norm_eq_abs]
[GOAL]
p x ε : ℝ
⊢ QuotientAddGroup.mk ⁻¹' closedBall (↑x) ε = ⋃ (z : ℤ), closedBall (x + z • p) ε
[PROOFSTEP]
rcases eq_or_ne p 0 with (rfl | hp)
[GOAL]
case inl
x ε : ℝ
⊢ QuotientAddGroup.mk ⁻¹' closedBall (↑x) ε = ⋃ (z : ℤ), closedBall (x + z • 0) ε
[PROOFSTEP]
simp [iUnion_const]
[GOAL]
case inr
p x ε : ℝ
hp : p ≠ 0
⊢ QuotientAddGroup.mk ⁻¹' closedBall (↑x) ε = ⋃ (z : ℤ), closedBall (x + z • p) ε
[PROOFSTEP]
ext y
[GOAL]
case inr.h
p x ε : ℝ
hp : p ≠ 0
y : ℝ
⊢ y ∈ QuotientAddGroup.mk ⁻¹' closedBall (↑x) ε ↔ y ∈ ⋃ (z : ℤ), closedBall (x + z • p) ε
[PROOFSTEP]
simp only [dist_eq_norm, mem_preimage, mem_closedBall, zsmul_eq_mul, mem_iUnion, Real.norm_eq_abs, ←
  QuotientAddGroup.mk_sub, norm_eq, ← sub_sub]
[GOAL]
case inr.h
p x ε : ℝ
hp : p ≠ 0
y : ℝ
⊢ |y - x - ↑(round (p⁻¹ * (y - x))) * p| ≤ ε ↔ ∃ i, |y - x - ↑i * p| ≤ ε
[PROOFSTEP]
refine' ⟨fun h => ⟨round (p⁻¹ * (y - x)), h⟩, _⟩
[GOAL]
case inr.h
p x ε : ℝ
hp : p ≠ 0
y : ℝ
⊢ (∃ i, |y - x - ↑i * p| ≤ ε) → |y - x - ↑(round (p⁻¹ * (y - x))) * p| ≤ ε
[PROOFSTEP]
rintro ⟨n, hn⟩
[GOAL]
case inr.h.intro
p x ε : ℝ
hp : p ≠ 0
y : ℝ
n : ℤ
hn : |y - x - ↑n * p| ≤ ε
⊢ |y - x - ↑(round (p⁻¹ * (y - x))) * p| ≤ ε
[PROOFSTEP]
rw [← mul_le_mul_left (abs_pos.mpr <| inv_ne_zero hp), ← abs_mul, mul_sub, mul_comm _ p, inv_mul_cancel_left₀ hp] at hn
  ⊢
[GOAL]
case inr.h.intro
p x ε : ℝ
hp : p ≠ 0
y : ℝ
n : ℤ
hn : |p⁻¹ * (y - x) - ↑n| ≤ |p⁻¹| * ε
⊢ |p⁻¹ * (y - x) - ↑(round (p⁻¹ * (y - x)))| ≤ |p⁻¹| * ε
[PROOFSTEP]
exact (round_le (p⁻¹ * (y - x)) n).trans hn
[GOAL]
p x ε : ℝ
s : Set ℝ
hs : s ⊆ closedBall x (|p| / 2)
⊢ QuotientAddGroup.mk ⁻¹' closedBall (↑x) ε ∩ s = if ε < |p| / 2 then closedBall x ε ∩ s else s
[PROOFSTEP]
cases' le_or_lt (|p| / 2) ε with hε hε
[GOAL]
case inl
p x ε : ℝ
s : Set ℝ
hs : s ⊆ closedBall x (|p| / 2)
hε : |p| / 2 ≤ ε
⊢ QuotientAddGroup.mk ⁻¹' closedBall (↑x) ε ∩ s = if ε < |p| / 2 then closedBall x ε ∩ s else s
[PROOFSTEP]
rcases eq_or_ne p 0 with (rfl | hp)
[GOAL]
case inl.inl
x ε : ℝ
s : Set ℝ
hs : s ⊆ closedBall x (|0| / 2)
hε : |0| / 2 ≤ ε
⊢ QuotientAddGroup.mk ⁻¹' closedBall (↑x) ε ∩ s = if ε < |0| / 2 then closedBall x ε ∩ s else s
[PROOFSTEP]
simp only [abs_zero, zero_div] at hε 
[GOAL]
case inl.inl
x ε : ℝ
s : Set ℝ
hs : s ⊆ closedBall x (|0| / 2)
hε : 0 ≤ ε
⊢ QuotientAddGroup.mk ⁻¹' closedBall (↑x) ε ∩ s = if ε < |0| / 2 then closedBall x ε ∩ s else s
[PROOFSTEP]
simp only [not_lt.mpr hε, coe_real_preimage_closedBall_period_zero, abs_zero, zero_div, if_false,
  inter_eq_right_iff_subset]
[GOAL]
case inl.inl
x ε : ℝ
s : Set ℝ
hs : s ⊆ closedBall x (|0| / 2)
hε : 0 ≤ ε
⊢ s ⊆ closedBall x ε
[PROOFSTEP]
exact
  hs.trans
    (closedBall_subset_closedBall <| by simp [hε])
      -- Porting note: was
          -- simp [closedBall_eq_univ_of_half_period_le p hp (↑x) hε, not_lt.mpr hε]
[GOAL]
x ε : ℝ
s : Set ℝ
hs : s ⊆ closedBall x (|0| / 2)
hε : 0 ≤ ε
⊢ |0| / 2 ≤ ε
[PROOFSTEP]
simp [hε]
[GOAL]
case inl.inr
p x ε : ℝ
s : Set ℝ
hs : s ⊆ closedBall x (|p| / 2)
hε : |p| / 2 ≤ ε
hp : p ≠ 0
⊢ QuotientAddGroup.mk ⁻¹' closedBall (↑x) ε ∩ s = if ε < |p| / 2 then closedBall x ε ∩ s else s
[PROOFSTEP]
simp only [not_lt.mpr hε, ite_false, inter_eq_right_iff_subset]
[GOAL]
case inl.inr
p x ε : ℝ
s : Set ℝ
hs : s ⊆ closedBall x (|p| / 2)
hε : |p| / 2 ≤ ε
hp : p ≠ 0
⊢ s ⊆ QuotientAddGroup.mk ⁻¹' closedBall (↑x) ε
[PROOFSTEP]
rw [closedBall_eq_univ_of_half_period_le p hp (↑x : ℝ ⧸ zmultiples p) hε, preimage_univ]
[GOAL]
case inl.inr
p x ε : ℝ
s : Set ℝ
hs : s ⊆ closedBall x (|p| / 2)
hε : |p| / 2 ≤ ε
hp : p ≠ 0
⊢ s ⊆ univ
[PROOFSTEP]
apply subset_univ
[GOAL]
case inr
p x ε : ℝ
s : Set ℝ
hs : s ⊆ closedBall x (|p| / 2)
hε : ε < |p| / 2
⊢ QuotientAddGroup.mk ⁻¹' closedBall (↑x) ε ∩ s = if ε < |p| / 2 then closedBall x ε ∩ s else s
[PROOFSTEP]
suffices ∀ z : ℤ, closedBall (x + z • p) ε ∩ s = if z = 0 then closedBall x ε ∩ s else ∅ by
  simp [-zsmul_eq_mul, ← QuotientAddGroup.mk_zero, coe_real_preimage_closedBall_eq_iUnion, iUnion_inter, iUnion_ite,
    this, hε]
[GOAL]
p x ε : ℝ
s : Set ℝ
hs : s ⊆ closedBall x (|p| / 2)
hε : ε < |p| / 2
this : ∀ (z : ℤ), closedBall (x + z • p) ε ∩ s = if z = 0 then closedBall x ε ∩ s else ∅
⊢ QuotientAddGroup.mk ⁻¹' closedBall (↑x) ε ∩ s = if ε < |p| / 2 then closedBall x ε ∩ s else s
[PROOFSTEP]
simp [-zsmul_eq_mul, ← QuotientAddGroup.mk_zero, coe_real_preimage_closedBall_eq_iUnion, iUnion_inter, iUnion_ite, this,
  hε]
[GOAL]
case inr
p x ε : ℝ
s : Set ℝ
hs : s ⊆ closedBall x (|p| / 2)
hε : ε < |p| / 2
⊢ ∀ (z : ℤ), closedBall (x + z • p) ε ∩ s = if z = 0 then closedBall x ε ∩ s else ∅
[PROOFSTEP]
intro z
[GOAL]
case inr
p x ε : ℝ
s : Set ℝ
hs : s ⊆ closedBall x (|p| / 2)
hε : ε < |p| / 2
z : ℤ
⊢ closedBall (x + z • p) ε ∩ s = if z = 0 then closedBall x ε ∩ s else ∅
[PROOFSTEP]
simp only [Real.closedBall_eq_Icc, zero_sub, zero_add] at hs ⊢
[GOAL]
case inr
p x ε : ℝ
s : Set ℝ
hε : ε < |p| / 2
z : ℤ
hs : s ⊆ Icc (x - |p| / 2) (x + |p| / 2)
⊢ Icc (x + z • p - ε) (x + z • p + ε) ∩ s = if z = 0 then Icc (x - ε) (x + ε) ∩ s else ∅
[PROOFSTEP]
rcases eq_or_ne z 0 with (rfl | hz)
[GOAL]
case inr.inl
p x ε : ℝ
s : Set ℝ
hε : ε < |p| / 2
hs : s ⊆ Icc (x - |p| / 2) (x + |p| / 2)
⊢ Icc (x + 0 • p - ε) (x + 0 • p + ε) ∩ s = if 0 = 0 then Icc (x - ε) (x + ε) ∩ s else ∅
[PROOFSTEP]
simp
[GOAL]
case inr.inr
p x ε : ℝ
s : Set ℝ
hε : ε < |p| / 2
z : ℤ
hs : s ⊆ Icc (x - |p| / 2) (x + |p| / 2)
hz : z ≠ 0
⊢ Icc (x + z • p - ε) (x + z • p + ε) ∩ s = if z = 0 then Icc (x - ε) (x + ε) ∩ s else ∅
[PROOFSTEP]
simp only [hz, zsmul_eq_mul, if_false, eq_empty_iff_forall_not_mem]
[GOAL]
case inr.inr
p x ε : ℝ
s : Set ℝ
hε : ε < |p| / 2
z : ℤ
hs : s ⊆ Icc (x - |p| / 2) (x + |p| / 2)
hz : z ≠ 0
⊢ ∀ (x_1 : ℝ), ¬x_1 ∈ Icc (x + ↑z * p - ε) (x + ↑z * p + ε) ∩ s
[PROOFSTEP]
rintro y ⟨⟨hy₁, hy₂⟩, hy₀⟩
[GOAL]
case inr.inr.intro.intro
p x ε : ℝ
s : Set ℝ
hε : ε < |p| / 2
z : ℤ
hs : s ⊆ Icc (x - |p| / 2) (x + |p| / 2)
hz : z ≠ 0
y : ℝ
hy₀ : y ∈ s
hy₁ : x + ↑z * p - ε ≤ y
hy₂ : y ≤ x + ↑z * p + ε
⊢ False
[PROOFSTEP]
obtain ⟨hy₃, hy₄⟩ := hs hy₀
[GOAL]
case inr.inr.intro.intro.intro
p x ε : ℝ
s : Set ℝ
hε : ε < |p| / 2
z : ℤ
hs : s ⊆ Icc (x - |p| / 2) (x + |p| / 2)
hz : z ≠ 0
y : ℝ
hy₀ : y ∈ s
hy₁ : x + ↑z * p - ε ≤ y
hy₂ : y ≤ x + ↑z * p + ε
hy₃ : x - |p| / 2 ≤ y
hy₄ : y ≤ x + |p| / 2
⊢ False
[PROOFSTEP]
rcases lt_trichotomy 0 p with (hp | (rfl : 0 = p) | hp)
[GOAL]
case inr.inr.intro.intro.intro.inl
p x ε : ℝ
s : Set ℝ
hε : ε < |p| / 2
z : ℤ
hs : s ⊆ Icc (x - |p| / 2) (x + |p| / 2)
hz : z ≠ 0
y : ℝ
hy₀ : y ∈ s
hy₁ : x + ↑z * p - ε ≤ y
hy₂ : y ≤ x + ↑z * p + ε
hy₃ : x - |p| / 2 ≤ y
hy₄ : y ≤ x + |p| / 2
hp : 0 < p
⊢ False
[PROOFSTEP]
cases' Int.cast_le_neg_one_or_one_le_cast_of_ne_zero ℝ hz with hz' hz'
[GOAL]
case inr.inr.intro.intro.intro.inl.inl
p x ε : ℝ
s : Set ℝ
hε : ε < |p| / 2
z : ℤ
hs : s ⊆ Icc (x - |p| / 2) (x + |p| / 2)
hz : z ≠ 0
y : ℝ
hy₀ : y ∈ s
hy₁ : x + ↑z * p - ε ≤ y
hy₂ : y ≤ x + ↑z * p + ε
hy₃ : x - |p| / 2 ≤ y
hy₄ : y ≤ x + |p| / 2
hp : 0 < p
hz' : ↑z ≤ -1
⊢ False
[PROOFSTEP]
have : ↑z * p ≤ -p
[GOAL]
case this
p x ε : ℝ
s : Set ℝ
hε : ε < |p| / 2
z : ℤ
hs : s ⊆ Icc (x - |p| / 2) (x + |p| / 2)
hz : z ≠ 0
y : ℝ
hy₀ : y ∈ s
hy₁ : x + ↑z * p - ε ≤ y
hy₂ : y ≤ x + ↑z * p + ε
hy₃ : x - |p| / 2 ≤ y
hy₄ : y ≤ x + |p| / 2
hp : 0 < p
hz' : ↑z ≤ -1
⊢ ↑z * p ≤ -p
case inr.inr.intro.intro.intro.inl.inl
p x ε : ℝ
s : Set ℝ
hε : ε < |p| / 2
z : ℤ
hs : s ⊆ Icc (x - |p| / 2) (x + |p| / 2)
hz : z ≠ 0
y : ℝ
hy₀ : y ∈ s
hy₁ : x + ↑z * p - ε ≤ y
hy₂ : y ≤ x + ↑z * p + ε
hy₃ : x - |p| / 2 ≤ y
hy₄ : y ≤ x + |p| / 2
hp : 0 < p
hz' : ↑z ≤ -1
this : ↑z * p ≤ -p
⊢ False
[PROOFSTEP]
nlinarith
[GOAL]
case inr.inr.intro.intro.intro.inl.inl
p x ε : ℝ
s : Set ℝ
hε : ε < |p| / 2
z : ℤ
hs : s ⊆ Icc (x - |p| / 2) (x + |p| / 2)
hz : z ≠ 0
y : ℝ
hy₀ : y ∈ s
hy₁ : x + ↑z * p - ε ≤ y
hy₂ : y ≤ x + ↑z * p + ε
hy₃ : x - |p| / 2 ≤ y
hy₄ : y ≤ x + |p| / 2
hp : 0 < p
hz' : ↑z ≤ -1
this : ↑z * p ≤ -p
⊢ False
[PROOFSTEP]
linarith [abs_eq_self.mpr hp.le]
[GOAL]
case inr.inr.intro.intro.intro.inl.inr
p x ε : ℝ
s : Set ℝ
hε : ε < |p| / 2
z : ℤ
hs : s ⊆ Icc (x - |p| / 2) (x + |p| / 2)
hz : z ≠ 0
y : ℝ
hy₀ : y ∈ s
hy₁ : x + ↑z * p - ε ≤ y
hy₂ : y ≤ x + ↑z * p + ε
hy₃ : x - |p| / 2 ≤ y
hy₄ : y ≤ x + |p| / 2
hp : 0 < p
hz' : 1 ≤ ↑z
⊢ False
[PROOFSTEP]
have : p ≤ ↑z * p
[GOAL]
case this
p x ε : ℝ
s : Set ℝ
hε : ε < |p| / 2
z : ℤ
hs : s ⊆ Icc (x - |p| / 2) (x + |p| / 2)
hz : z ≠ 0
y : ℝ
hy₀ : y ∈ s
hy₁ : x + ↑z * p - ε ≤ y
hy₂ : y ≤ x + ↑z * p + ε
hy₃ : x - |p| / 2 ≤ y
hy₄ : y ≤ x + |p| / 2
hp : 0 < p
hz' : 1 ≤ ↑z
⊢ p ≤ ↑z * p
case inr.inr.intro.intro.intro.inl.inr
p x ε : ℝ
s : Set ℝ
hε : ε < |p| / 2
z : ℤ
hs : s ⊆ Icc (x - |p| / 2) (x + |p| / 2)
hz : z ≠ 0
y : ℝ
hy₀ : y ∈ s
hy₁ : x + ↑z * p - ε ≤ y
hy₂ : y ≤ x + ↑z * p + ε
hy₃ : x - |p| / 2 ≤ y
hy₄ : y ≤ x + |p| / 2
hp : 0 < p
hz' : 1 ≤ ↑z
this : p ≤ ↑z * p
⊢ False
[PROOFSTEP]
nlinarith
[GOAL]
case inr.inr.intro.intro.intro.inl.inr
p x ε : ℝ
s : Set ℝ
hε : ε < |p| / 2
z : ℤ
hs : s ⊆ Icc (x - |p| / 2) (x + |p| / 2)
hz : z ≠ 0
y : ℝ
hy₀ : y ∈ s
hy₁ : x + ↑z * p - ε ≤ y
hy₂ : y ≤ x + ↑z * p + ε
hy₃ : x - |p| / 2 ≤ y
hy₄ : y ≤ x + |p| / 2
hp : 0 < p
hz' : 1 ≤ ↑z
this : p ≤ ↑z * p
⊢ False
[PROOFSTEP]
linarith [abs_eq_self.mpr hp.le]
[GOAL]
case inr.inr.intro.intro.intro.inr.inl
x ε : ℝ
s : Set ℝ
z : ℤ
hz : z ≠ 0
y : ℝ
hy₀ : y ∈ s
hε : ε < |0| / 2
hs : s ⊆ Icc (x - |0| / 2) (x + |0| / 2)
hy₁ : x + ↑z * 0 - ε ≤ y
hy₂ : y ≤ x + ↑z * 0 + ε
hy₃ : x - |0| / 2 ≤ y
hy₄ : y ≤ x + |0| / 2
⊢ False
[PROOFSTEP]
simp only [mul_zero, add_zero, abs_zero, zero_div] at hy₁ hy₂ hε 
[GOAL]
case inr.inr.intro.intro.intro.inr.inl
x ε : ℝ
s : Set ℝ
z : ℤ
hz : z ≠ 0
y : ℝ
hy₀ : y ∈ s
hs : s ⊆ Icc (x - |0| / 2) (x + |0| / 2)
hy₃ : x - |0| / 2 ≤ y
hy₄ : y ≤ x + |0| / 2
hy₁ : x - ε ≤ y
hy₂ : y ≤ x + ε
hε : ε < 0
⊢ False
[PROOFSTEP]
linarith
[GOAL]
case inr.inr.intro.intro.intro.inr.inr
p x ε : ℝ
s : Set ℝ
hε : ε < |p| / 2
z : ℤ
hs : s ⊆ Icc (x - |p| / 2) (x + |p| / 2)
hz : z ≠ 0
y : ℝ
hy₀ : y ∈ s
hy₁ : x + ↑z * p - ε ≤ y
hy₂ : y ≤ x + ↑z * p + ε
hy₃ : x - |p| / 2 ≤ y
hy₄ : y ≤ x + |p| / 2
hp : p < 0
⊢ False
[PROOFSTEP]
cases' Int.cast_le_neg_one_or_one_le_cast_of_ne_zero ℝ hz with hz' hz'
[GOAL]
case inr.inr.intro.intro.intro.inr.inr.inl
p x ε : ℝ
s : Set ℝ
hε : ε < |p| / 2
z : ℤ
hs : s ⊆ Icc (x - |p| / 2) (x + |p| / 2)
hz : z ≠ 0
y : ℝ
hy₀ : y ∈ s
hy₁ : x + ↑z * p - ε ≤ y
hy₂ : y ≤ x + ↑z * p + ε
hy₃ : x - |p| / 2 ≤ y
hy₄ : y ≤ x + |p| / 2
hp : p < 0
hz' : ↑z ≤ -1
⊢ False
[PROOFSTEP]
have : -p ≤ ↑z * p
[GOAL]
case this
p x ε : ℝ
s : Set ℝ
hε : ε < |p| / 2
z : ℤ
hs : s ⊆ Icc (x - |p| / 2) (x + |p| / 2)
hz : z ≠ 0
y : ℝ
hy₀ : y ∈ s
hy₁ : x + ↑z * p - ε ≤ y
hy₂ : y ≤ x + ↑z * p + ε
hy₃ : x - |p| / 2 ≤ y
hy₄ : y ≤ x + |p| / 2
hp : p < 0
hz' : ↑z ≤ -1
⊢ -p ≤ ↑z * p
case inr.inr.intro.intro.intro.inr.inr.inl
p x ε : ℝ
s : Set ℝ
hε : ε < |p| / 2
z : ℤ
hs : s ⊆ Icc (x - |p| / 2) (x + |p| / 2)
hz : z ≠ 0
y : ℝ
hy₀ : y ∈ s
hy₁ : x + ↑z * p - ε ≤ y
hy₂ : y ≤ x + ↑z * p + ε
hy₃ : x - |p| / 2 ≤ y
hy₄ : y ≤ x + |p| / 2
hp : p < 0
hz' : ↑z ≤ -1
this : -p ≤ ↑z * p
⊢ False
[PROOFSTEP]
nlinarith
[GOAL]
case inr.inr.intro.intro.intro.inr.inr.inl
p x ε : ℝ
s : Set ℝ
hε : ε < |p| / 2
z : ℤ
hs : s ⊆ Icc (x - |p| / 2) (x + |p| / 2)
hz : z ≠ 0
y : ℝ
hy₀ : y ∈ s
hy₁ : x + ↑z * p - ε ≤ y
hy₂ : y ≤ x + ↑z * p + ε
hy₃ : x - |p| / 2 ≤ y
hy₄ : y ≤ x + |p| / 2
hp : p < 0
hz' : ↑z ≤ -1
this : -p ≤ ↑z * p
⊢ False
[PROOFSTEP]
linarith [abs_eq_neg_self.mpr hp.le]
[GOAL]
case inr.inr.intro.intro.intro.inr.inr.inr
p x ε : ℝ
s : Set ℝ
hε : ε < |p| / 2
z : ℤ
hs : s ⊆ Icc (x - |p| / 2) (x + |p| / 2)
hz : z ≠ 0
y : ℝ
hy₀ : y ∈ s
hy₁ : x + ↑z * p - ε ≤ y
hy₂ : y ≤ x + ↑z * p + ε
hy₃ : x - |p| / 2 ≤ y
hy₄ : y ≤ x + |p| / 2
hp : p < 0
hz' : 1 ≤ ↑z
⊢ False
[PROOFSTEP]
have : ↑z * p ≤ p
[GOAL]
case this
p x ε : ℝ
s : Set ℝ
hε : ε < |p| / 2
z : ℤ
hs : s ⊆ Icc (x - |p| / 2) (x + |p| / 2)
hz : z ≠ 0
y : ℝ
hy₀ : y ∈ s
hy₁ : x + ↑z * p - ε ≤ y
hy₂ : y ≤ x + ↑z * p + ε
hy₃ : x - |p| / 2 ≤ y
hy₄ : y ≤ x + |p| / 2
hp : p < 0
hz' : 1 ≤ ↑z
⊢ ↑z * p ≤ p
case inr.inr.intro.intro.intro.inr.inr.inr
p x ε : ℝ
s : Set ℝ
hε : ε < |p| / 2
z : ℤ
hs : s ⊆ Icc (x - |p| / 2) (x + |p| / 2)
hz : z ≠ 0
y : ℝ
hy₀ : y ∈ s
hy₁ : x + ↑z * p - ε ≤ y
hy₂ : y ≤ x + ↑z * p + ε
hy₃ : x - |p| / 2 ≤ y
hy₄ : y ≤ x + |p| / 2
hp : p < 0
hz' : 1 ≤ ↑z
this : ↑z * p ≤ p
⊢ False
[PROOFSTEP]
nlinarith
[GOAL]
case inr.inr.intro.intro.intro.inr.inr.inr
p x ε : ℝ
s : Set ℝ
hε : ε < |p| / 2
z : ℤ
hs : s ⊆ Icc (x - |p| / 2) (x + |p| / 2)
hz : z ≠ 0
y : ℝ
hy₀ : y ∈ s
hy₁ : x + ↑z * p - ε ≤ y
hy₂ : y ≤ x + ↑z * p + ε
hy₃ : x - |p| / 2 ≤ y
hy₄ : y ≤ x + |p| / 2
hp : p < 0
hz' : 1 ≤ ↑z
this : ↑z * p ≤ p
⊢ False
[PROOFSTEP]
linarith [abs_eq_neg_self.mpr hp.le]
[GOAL]
p : ℝ
hp : Fact (0 < p)
m n : ℕ
⊢ ‖↑(↑m / ↑n * p)‖ = p * (↑(min (m % n) (n - m % n)) / ↑n)
[PROOFSTEP]
have : p⁻¹ * (↑m / ↑n * p) = ↑m / ↑n := by rw [mul_comm _ p, inv_mul_cancel_left₀ hp.out.ne.symm]
[GOAL]
p : ℝ
hp : Fact (0 < p)
m n : ℕ
⊢ p⁻¹ * (↑m / ↑n * p) = ↑m / ↑n
[PROOFSTEP]
rw [mul_comm _ p, inv_mul_cancel_left₀ hp.out.ne.symm]
[GOAL]
p : ℝ
hp : Fact (0 < p)
m n : ℕ
this : p⁻¹ * (↑m / ↑n * p) = ↑m / ↑n
⊢ ‖↑(↑m / ↑n * p)‖ = p * (↑(min (m % n) (n - m % n)) / ↑n)
[PROOFSTEP]
rw [norm_eq' p hp.out, this, abs_sub_round_div_natCast_eq]
[GOAL]
p : ℝ
hp : Fact (0 < p)
u : AddCircle p
hu : IsOfFinAddOrder u
⊢ ∃ k, ‖u‖ = p * (↑k / ↑(addOrderOf u))
[PROOFSTEP]
let n := addOrderOf u
[GOAL]
p : ℝ
hp : Fact (0 < p)
u : AddCircle p
hu : IsOfFinAddOrder u
n : ℕ := addOrderOf u
⊢ ∃ k, ‖u‖ = p * (↑k / ↑(addOrderOf u))
[PROOFSTEP]
change ∃ k : ℕ, ‖u‖ = p * (k / n)
[GOAL]
p : ℝ
hp : Fact (0 < p)
u : AddCircle p
hu : IsOfFinAddOrder u
n : ℕ := addOrderOf u
⊢ ∃ k, ‖u‖ = p * (↑k / ↑n)
[PROOFSTEP]
obtain ⟨m, -, -, hm⟩ := exists_gcd_eq_one_of_isOfFinAddOrder hu
[GOAL]
case intro.intro.intro
p : ℝ
hp : Fact (0 < p)
u : AddCircle p
hu : IsOfFinAddOrder u
n : ℕ := addOrderOf u
m : ℕ
hm : ↑(↑m / ↑(addOrderOf u) * p) = u
⊢ ∃ k, ‖u‖ = p * (↑k / ↑n)
[PROOFSTEP]
refine' ⟨min (m % n) (n - m % n), _⟩
[GOAL]
case intro.intro.intro
p : ℝ
hp : Fact (0 < p)
u : AddCircle p
hu : IsOfFinAddOrder u
n : ℕ := addOrderOf u
m : ℕ
hm : ↑(↑m / ↑(addOrderOf u) * p) = u
⊢ ‖u‖ = p * (↑(min (m % n) (n - m % n)) / ↑n)
[PROOFSTEP]
rw [← hm, norm_div_nat_cast]
[GOAL]
p : ℝ
hp : Fact (0 < p)
u : AddCircle p
hu : IsOfFinAddOrder u
hu' : u ≠ 0
⊢ p ≤ addOrderOf u • ‖u‖
[PROOFSTEP]
obtain ⟨n, hn⟩ := exists_norm_eq_of_isOfFinAddOrder hu
[GOAL]
case intro
p : ℝ
hp : Fact (0 < p)
u : AddCircle p
hu : IsOfFinAddOrder u
hu' : u ≠ 0
n : ℕ
hn : ‖u‖ = p * (↑n / ↑(addOrderOf u))
⊢ p ≤ addOrderOf u • ‖u‖
[PROOFSTEP]
replace hu : (addOrderOf u : ℝ) ≠ 0
[GOAL]
case hu
p : ℝ
hp : Fact (0 < p)
u : AddCircle p
hu : IsOfFinAddOrder u
hu' : u ≠ 0
n : ℕ
hn : ‖u‖ = p * (↑n / ↑(addOrderOf u))
⊢ ↑(addOrderOf u) ≠ 0
[PROOFSTEP]
norm_cast
[GOAL]
case hu
p : ℝ
hp : Fact (0 < p)
u : AddCircle p
hu : IsOfFinAddOrder u
hu' : u ≠ 0
n : ℕ
hn : ‖u‖ = p * (↑n / ↑(addOrderOf u))
⊢ ¬addOrderOf u = 0
[PROOFSTEP]
exact (addOrderOf_pos_iff.mpr hu).ne'
[GOAL]
case intro
p : ℝ
hp : Fact (0 < p)
u : AddCircle p
hu' : u ≠ 0
n : ℕ
hn : ‖u‖ = p * (↑n / ↑(addOrderOf u))
hu : ↑(addOrderOf u) ≠ 0
⊢ p ≤ addOrderOf u • ‖u‖
[PROOFSTEP]
conv_lhs => rw [← mul_one p]
[GOAL]
p : ℝ
hp : Fact (0 < p)
u : AddCircle p
hu' : u ≠ 0
n : ℕ
hn : ‖u‖ = p * (↑n / ↑(addOrderOf u))
hu : ↑(addOrderOf u) ≠ 0
| p
[PROOFSTEP]
rw [← mul_one p]
[GOAL]
p : ℝ
hp : Fact (0 < p)
u : AddCircle p
hu' : u ≠ 0
n : ℕ
hn : ‖u‖ = p * (↑n / ↑(addOrderOf u))
hu : ↑(addOrderOf u) ≠ 0
| p
[PROOFSTEP]
rw [← mul_one p]
[GOAL]
p : ℝ
hp : Fact (0 < p)
u : AddCircle p
hu' : u ≠ 0
n : ℕ
hn : ‖u‖ = p * (↑n / ↑(addOrderOf u))
hu : ↑(addOrderOf u) ≠ 0
| p
[PROOFSTEP]
rw [← mul_one p]
[GOAL]
case intro
p : ℝ
hp : Fact (0 < p)
u : AddCircle p
hu' : u ≠ 0
n : ℕ
hn : ‖u‖ = p * (↑n / ↑(addOrderOf u))
hu : ↑(addOrderOf u) ≠ 0
⊢ p * 1 ≤ addOrderOf u • ‖u‖
[PROOFSTEP]
rw [hn, nsmul_eq_mul, ← mul_assoc, mul_comm _ p, mul_assoc, mul_div_cancel' _ hu, mul_le_mul_left hp.out,
  Nat.one_le_cast, Nat.one_le_iff_ne_zero]
[GOAL]
case intro
p : ℝ
hp : Fact (0 < p)
u : AddCircle p
hu' : u ≠ 0
n : ℕ
hn : ‖u‖ = p * (↑n / ↑(addOrderOf u))
hu : ↑(addOrderOf u) ≠ 0
⊢ n ≠ 0
[PROOFSTEP]
contrapose! hu'
[GOAL]
case intro
p : ℝ
hp : Fact (0 < p)
u : AddCircle p
n : ℕ
hn : ‖u‖ = p * (↑n / ↑(addOrderOf u))
hu : ↑(addOrderOf u) ≠ 0
hu' : n = 0
⊢ u = 0
[PROOFSTEP]
simpa only [hu', Nat.cast_zero, zero_div, mul_zero, norm_eq_zero] using hn
[GOAL]
x : ℝ
⊢ ‖↑x‖ = |x - ↑(round x)|
[PROOFSTEP]
simp [AddCircle.norm_eq]
