[GOAL]
⊢ ∀ ⦃x : ℝ × ℝ⦄,
    x ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0} →
      (fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q))) x ∈ Ioi 0 ×ˢ Ioo (-π) π
[PROOFSTEP]
rintro ⟨x, y⟩ hxy
[GOAL]
case mk
x y : ℝ
hxy : (x, y) ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0}
⊢ (fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q))) (x, y) ∈ Ioi 0 ×ˢ Ioo (-π) π
[PROOFSTEP]
simp only [prod_mk_mem_set_prod_eq, mem_Ioi, sqrt_pos, mem_Ioo, Complex.neg_pi_lt_arg, true_and_iff,
  Complex.arg_lt_pi_iff]
[GOAL]
case mk
x y : ℝ
hxy : (x, y) ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0}
⊢ 0 < x ^ 2 + y ^ 2 ∧ (0 ≤ (↑Complex.equivRealProd.symm (x, y)).re ∨ (↑Complex.equivRealProd.symm (x, y)).im ≠ 0)
[PROOFSTEP]
constructor
[GOAL]
case mk.left
x y : ℝ
hxy : (x, y) ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0}
⊢ 0 < x ^ 2 + y ^ 2
[PROOFSTEP]
cases' hxy with hxy hxy
[GOAL]
case mk.left.inl
x y : ℝ
hxy : (x, y) ∈ {q | 0 < q.fst}
⊢ 0 < x ^ 2 + y ^ 2
[PROOFSTEP]
dsimp at hxy
[GOAL]
case mk.left.inl
x y : ℝ
hxy : 0 < x
⊢ 0 < x ^ 2 + y ^ 2
[PROOFSTEP]
linarith [sq_pos_of_ne_zero _ hxy.ne', sq_nonneg y]
[GOAL]
case mk.left.inr
x y : ℝ
hxy : (x, y) ∈ {q | q.snd ≠ 0}
⊢ 0 < x ^ 2 + y ^ 2
[PROOFSTEP]
linarith [sq_nonneg x, sq_pos_of_ne_zero _ hxy]
[GOAL]
case mk.right
x y : ℝ
hxy : (x, y) ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0}
⊢ 0 ≤ (↑Complex.equivRealProd.symm (x, y)).re ∨ (↑Complex.equivRealProd.symm (x, y)).im ≠ 0
[PROOFSTEP]
cases' hxy with hxy hxy
[GOAL]
case mk.right.inl
x y : ℝ
hxy : (x, y) ∈ {q | 0 < q.fst}
⊢ 0 ≤ (↑Complex.equivRealProd.symm (x, y)).re ∨ (↑Complex.equivRealProd.symm (x, y)).im ≠ 0
[PROOFSTEP]
exact Or.inl (le_of_lt hxy)
[GOAL]
case mk.right.inr
x y : ℝ
hxy : (x, y) ∈ {q | q.snd ≠ 0}
⊢ 0 ≤ (↑Complex.equivRealProd.symm (x, y)).re ∨ (↑Complex.equivRealProd.symm (x, y)).im ≠ 0
[PROOFSTEP]
exact Or.inr hxy
[GOAL]
⊢ ∀ ⦃x : ℝ × ℝ⦄,
    x ∈ Ioi 0 ×ˢ Ioo (-π) π → (fun p => (p.fst * cos p.snd, p.fst * sin p.snd)) x ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0}
[PROOFSTEP]
rintro ⟨r, θ⟩ ⟨hr, hθ⟩
[GOAL]
case mk.intro
r θ : ℝ
hr : (r, θ).fst ∈ Ioi 0
hθ : (r, θ).snd ∈ Ioo (-π) π
⊢ (fun p => (p.fst * cos p.snd, p.fst * sin p.snd)) (r, θ) ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0}
[PROOFSTEP]
dsimp at hr hθ
[GOAL]
case mk.intro
r θ : ℝ
hr : r ∈ Ioi 0
hθ : θ ∈ Ioo (-π) π
⊢ (fun p => (p.fst * cos p.snd, p.fst * sin p.snd)) (r, θ) ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0}
[PROOFSTEP]
rcases eq_or_ne θ 0 with (rfl | h'θ)
[GOAL]
case mk.intro.inl
r : ℝ
hr : r ∈ Ioi 0
hθ : 0 ∈ Ioo (-π) π
⊢ (fun p => (p.fst * cos p.snd, p.fst * sin p.snd)) (r, 0) ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0}
[PROOFSTEP]
simpa using hr
[GOAL]
case mk.intro.inr
r θ : ℝ
hr : r ∈ Ioi 0
hθ : θ ∈ Ioo (-π) π
h'θ : θ ≠ 0
⊢ (fun p => (p.fst * cos p.snd, p.fst * sin p.snd)) (r, θ) ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0}
[PROOFSTEP]
right
[GOAL]
case mk.intro.inr.h
r θ : ℝ
hr : r ∈ Ioi 0
hθ : θ ∈ Ioo (-π) π
h'θ : θ ≠ 0
⊢ (fun p => (p.fst * cos p.snd, p.fst * sin p.snd)) (r, θ) ∈ {q | q.snd ≠ 0}
[PROOFSTEP]
simp at hr
[GOAL]
case mk.intro.inr.h
r θ : ℝ
hθ : θ ∈ Ioo (-π) π
h'θ : θ ≠ 0
hr : 0 < r
⊢ (fun p => (p.fst * cos p.snd, p.fst * sin p.snd)) (r, θ) ∈ {q | q.snd ≠ 0}
[PROOFSTEP]
simpa only [ne_of_gt hr, Ne.def, mem_setOf_eq, mul_eq_zero, false_or_iff, sin_eq_zero_iff_of_lt_of_lt hθ.1 hθ.2] using
  h'θ
[GOAL]
⊢ ∀ ⦃x : ℝ × ℝ⦄,
    x ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0} →
      (fun p => (p.fst * cos p.snd, p.fst * sin p.snd))
          ((fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q))) x) =
        x
[PROOFSTEP]
rintro ⟨x, y⟩ _
[GOAL]
case mk
x y : ℝ
a✝ : (x, y) ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0}
⊢ (fun p => (p.fst * cos p.snd, p.fst * sin p.snd))
      ((fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q))) (x, y)) =
    (x, y)
[PROOFSTEP]
have A : sqrt (x ^ 2 + y ^ 2) = Complex.abs (x + y * Complex.I) := by
  simp [Complex.abs_def, Complex.normSq, pow_two, MonoidWithZeroHom.coe_mk, Complex.add_re, Complex.ofReal_re,
    Complex.mul_re, Complex.I_re, mul_zero, Complex.ofReal_im, Complex.I_im, sub_self, add_zero, Complex.add_im,
    Complex.mul_im, mul_one, zero_add]
[GOAL]
x y : ℝ
a✝ : (x, y) ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0}
⊢ sqrt (x ^ 2 + y ^ 2) = ↑Complex.abs (↑x + ↑y * Complex.I)
[PROOFSTEP]
simp [Complex.abs_def, Complex.normSq, pow_two, MonoidWithZeroHom.coe_mk, Complex.add_re, Complex.ofReal_re,
  Complex.mul_re, Complex.I_re, mul_zero, Complex.ofReal_im, Complex.I_im, sub_self, add_zero, Complex.add_im,
  Complex.mul_im, mul_one, zero_add]
[GOAL]
case mk
x y : ℝ
a✝ : (x, y) ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0}
A : sqrt (x ^ 2 + y ^ 2) = ↑Complex.abs (↑x + ↑y * Complex.I)
⊢ (fun p => (p.fst * cos p.snd, p.fst * sin p.snd))
      ((fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q))) (x, y)) =
    (x, y)
[PROOFSTEP]
have Z := Complex.abs_mul_cos_add_sin_mul_I (x + y * Complex.I)
[GOAL]
case mk
x y : ℝ
a✝ : (x, y) ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0}
A : sqrt (x ^ 2 + y ^ 2) = ↑Complex.abs (↑x + ↑y * Complex.I)
Z :
  ↑(↑Complex.abs (↑x + ↑y * Complex.I)) *
      (Complex.cos ↑(Complex.arg (↑x + ↑y * Complex.I)) +
        Complex.sin ↑(Complex.arg (↑x + ↑y * Complex.I)) * Complex.I) =
    ↑x + ↑y * Complex.I
⊢ (fun p => (p.fst * cos p.snd, p.fst * sin p.snd))
      ((fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q))) (x, y)) =
    (x, y)
[PROOFSTEP]
simp only [← Complex.ofReal_cos, ← Complex.ofReal_sin, mul_add, ← Complex.ofReal_mul, ← mul_assoc] at Z
[GOAL]
case mk
x y : ℝ
a✝ : (x, y) ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0}
A : sqrt (x ^ 2 + y ^ 2) = ↑Complex.abs (↑x + ↑y * Complex.I)
Z :
  ↑(↑Complex.abs (↑x + ↑y * Complex.I) * cos (Complex.arg (↑x + ↑y * Complex.I))) +
      ↑(↑Complex.abs (↑x + ↑y * Complex.I) * sin (Complex.arg (↑x + ↑y * Complex.I))) * Complex.I =
    ↑x + ↑y * Complex.I
⊢ (fun p => (p.fst * cos p.snd, p.fst * sin p.snd))
      ((fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q))) (x, y)) =
    (x, y)
[PROOFSTEP]
simpa [A, -Complex.ofReal_cos, -Complex.ofReal_sin] using Complex.ext_iff.1 Z
[GOAL]
⊢ ∀ ⦃x : ℝ × ℝ⦄,
    x ∈ Ioi 0 ×ˢ Ioo (-π) π →
      (fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q)))
          ((fun p => (p.fst * cos p.snd, p.fst * sin p.snd)) x) =
        x
[PROOFSTEP]
rintro ⟨r, θ⟩ ⟨hr, hθ⟩
[GOAL]
case mk.intro
r θ : ℝ
hr : (r, θ).fst ∈ Ioi 0
hθ : (r, θ).snd ∈ Ioo (-π) π
⊢ (fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q)))
      ((fun p => (p.fst * cos p.snd, p.fst * sin p.snd)) (r, θ)) =
    (r, θ)
[PROOFSTEP]
dsimp at hr hθ
[GOAL]
case mk.intro
r θ : ℝ
hr : r ∈ Ioi 0
hθ : θ ∈ Ioo (-π) π
⊢ (fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q)))
      ((fun p => (p.fst * cos p.snd, p.fst * sin p.snd)) (r, θ)) =
    (r, θ)
[PROOFSTEP]
simp only [Prod.mk.inj_iff]
[GOAL]
case mk.intro
r θ : ℝ
hr : r ∈ Ioi 0
hθ : θ ∈ Ioo (-π) π
⊢ sqrt ((r * cos θ) ^ 2 + (r * sin θ) ^ 2) = r ∧ Complex.arg (↑Complex.equivRealProd.symm (r * cos θ, r * sin θ)) = θ
[PROOFSTEP]
constructor
[GOAL]
case mk.intro.left
r θ : ℝ
hr : r ∈ Ioi 0
hθ : θ ∈ Ioo (-π) π
⊢ sqrt ((r * cos θ) ^ 2 + (r * sin θ) ^ 2) = r
[PROOFSTEP]
conv_rhs => rw [← sqrt_sq (le_of_lt hr), ← one_mul (r ^ 2), ← sin_sq_add_cos_sq θ]
[GOAL]
r θ : ℝ
hr : r ∈ Ioi 0
hθ : θ ∈ Ioo (-π) π
| r
[PROOFSTEP]
rw [← sqrt_sq (le_of_lt hr), ← one_mul (r ^ 2), ← sin_sq_add_cos_sq θ]
[GOAL]
r θ : ℝ
hr : r ∈ Ioi 0
hθ : θ ∈ Ioo (-π) π
| r
[PROOFSTEP]
rw [← sqrt_sq (le_of_lt hr), ← one_mul (r ^ 2), ← sin_sq_add_cos_sq θ]
[GOAL]
r θ : ℝ
hr : r ∈ Ioi 0
hθ : θ ∈ Ioo (-π) π
| r
[PROOFSTEP]
rw [← sqrt_sq (le_of_lt hr), ← one_mul (r ^ 2), ← sin_sq_add_cos_sq θ]
[GOAL]
case mk.intro.left
r θ : ℝ
hr : r ∈ Ioi 0
hθ : θ ∈ Ioo (-π) π
⊢ sqrt ((r * cos θ) ^ 2 + (r * sin θ) ^ 2) = sqrt ((sin θ ^ 2 + cos θ ^ 2) * r ^ 2)
[PROOFSTEP]
congr 1
[GOAL]
case mk.intro.left.e_x
r θ : ℝ
hr : r ∈ Ioi 0
hθ : θ ∈ Ioo (-π) π
⊢ (r * cos θ) ^ 2 + (r * sin θ) ^ 2 = (sin θ ^ 2 + cos θ ^ 2) * r ^ 2
[PROOFSTEP]
ring
[GOAL]
case mk.intro.right
r θ : ℝ
hr : r ∈ Ioi 0
hθ : θ ∈ Ioo (-π) π
⊢ Complex.arg (↑Complex.equivRealProd.symm (r * cos θ, r * sin θ)) = θ
[PROOFSTEP]
convert Complex.arg_mul_cos_add_sin_mul_I hr ⟨hθ.1, hθ.2.le⟩
[GOAL]
case h.e'_2.h.e'_1
r θ : ℝ
hr : r ∈ Ioi 0
hθ : θ ∈ Ioo (-π) π
⊢ ↑Complex.equivRealProd.symm (r * cos θ, r * sin θ) = ↑r * (Complex.cos ↑θ + Complex.sin ↑θ * Complex.I)
[PROOFSTEP]
simp only [Complex.equivRealProd_symm_apply, Complex.ofReal_mul, Complex.ofReal_cos, Complex.ofReal_sin]
[GOAL]
case h.e'_2.h.e'_1
r θ : ℝ
hr : r ∈ Ioi 0
hθ : θ ∈ Ioo (-π) π
⊢ ↑r * Complex.cos ↑θ + ↑r * Complex.sin ↑θ * Complex.I = ↑r * (Complex.cos ↑θ + Complex.sin ↑θ * Complex.I)
[PROOFSTEP]
ring
[GOAL]
⊢ ContinuousOn
    ↑{ toFun := fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q)),
        invFun := fun p => (p.fst * cos p.snd, p.fst * sin p.snd), source := {q | 0 < q.fst} ∪ {q | q.snd ≠ 0},
        target := Ioi 0 ×ˢ Ioo (-π) π,
        map_source' :=
          (_ :
            ∀ ⦃x : ℝ × ℝ⦄,
              x ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0} →
                (fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q))) x ∈
                  Ioi 0 ×ˢ Ioo (-π) π),
        map_target' :=
          (_ :
            ∀ ⦃x : ℝ × ℝ⦄,
              x ∈ Ioi 0 ×ˢ Ioo (-π) π →
                (fun p => (p.fst * cos p.snd, p.fst * sin p.snd)) x ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0}),
        left_inv' :=
          (_ :
            ∀ ⦃x : ℝ × ℝ⦄,
              x ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0} →
                (fun p => (p.fst * cos p.snd, p.fst * sin p.snd))
                    ((fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q))) x) =
                  x),
        right_inv' :=
          (_ :
            ∀ ⦃x : ℝ × ℝ⦄,
              x ∈ Ioi 0 ×ˢ Ioo (-π) π →
                (fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q)))
                    ((fun p => (p.fst * cos p.snd, p.fst * sin p.snd)) x) =
                  x) }
    { toFun := fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q)),
        invFun := fun p => (p.fst * cos p.snd, p.fst * sin p.snd), source := {q | 0 < q.fst} ∪ {q | q.snd ≠ 0},
        target := Ioi 0 ×ˢ Ioo (-π) π,
        map_source' :=
          (_ :
            ∀ ⦃x : ℝ × ℝ⦄,
              x ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0} →
                (fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q))) x ∈
                  Ioi 0 ×ˢ Ioo (-π) π),
        map_target' :=
          (_ :
            ∀ ⦃x : ℝ × ℝ⦄,
              x ∈ Ioi 0 ×ˢ Ioo (-π) π →
                (fun p => (p.fst * cos p.snd, p.fst * sin p.snd)) x ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0}),
        left_inv' :=
          (_ :
            ∀ ⦃x : ℝ × ℝ⦄,
              x ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0} →
                (fun p => (p.fst * cos p.snd, p.fst * sin p.snd))
                    ((fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q))) x) =
                  x),
        right_inv' :=
          (_ :
            ∀ ⦃x : ℝ × ℝ⦄,
              x ∈ Ioi 0 ×ˢ Ioo (-π) π →
                (fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q)))
                    ((fun p => (p.fst * cos p.snd, p.fst * sin p.snd)) x) =
                  x) }.source
[PROOFSTEP]
apply ((continuous_fst.pow 2).add (continuous_snd.pow 2)).sqrt.continuousOn.prod
[GOAL]
⊢ ContinuousOn (fun x => Complex.arg (↑Complex.equivRealProd.symm x))
    { toFun := fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q)),
        invFun := fun p => (p.fst * cos p.snd, p.fst * sin p.snd), source := {q | 0 < q.fst} ∪ {q | q.snd ≠ 0},
        target := Ioi 0 ×ˢ Ioo (-π) π,
        map_source' :=
          (_ :
            ∀ ⦃x : ℝ × ℝ⦄,
              x ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0} →
                (fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q))) x ∈
                  Ioi 0 ×ˢ Ioo (-π) π),
        map_target' :=
          (_ :
            ∀ ⦃x : ℝ × ℝ⦄,
              x ∈ Ioi 0 ×ˢ Ioo (-π) π →
                (fun p => (p.fst * cos p.snd, p.fst * sin p.snd)) x ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0}),
        left_inv' :=
          (_ :
            ∀ ⦃x : ℝ × ℝ⦄,
              x ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0} →
                (fun p => (p.fst * cos p.snd, p.fst * sin p.snd))
                    ((fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q))) x) =
                  x),
        right_inv' :=
          (_ :
            ∀ ⦃x : ℝ × ℝ⦄,
              x ∈ Ioi 0 ×ˢ Ioo (-π) π →
                (fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q)))
                    ((fun p => (p.fst * cos p.snd, p.fst * sin p.snd)) x) =
                  x) }.source
[PROOFSTEP]
have A : MapsTo Complex.equivRealProd.symm ({q : ℝ × ℝ | 0 < q.1} ∪ {q : ℝ × ℝ | q.2 ≠ 0}) {z | 0 < z.re ∨ z.im ≠ 0} :=
  by rintro ⟨x, y⟩ hxy; simpa only using hxy
[GOAL]
⊢ MapsTo (↑Complex.equivRealProd.symm) ({q | 0 < q.fst} ∪ {q | q.snd ≠ 0}) {z | 0 < z.re ∨ z.im ≠ 0}
[PROOFSTEP]
rintro ⟨x, y⟩ hxy
[GOAL]
case mk
x y : ℝ
hxy : (x, y) ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0}
⊢ ↑Complex.equivRealProd.symm (x, y) ∈ {z | 0 < z.re ∨ z.im ≠ 0}
[PROOFSTEP]
simpa only using hxy
[GOAL]
A : MapsTo (↑Complex.equivRealProd.symm) ({q | 0 < q.fst} ∪ {q | q.snd ≠ 0}) {z | 0 < z.re ∨ z.im ≠ 0}
⊢ ContinuousOn (fun x => Complex.arg (↑Complex.equivRealProd.symm x))
    { toFun := fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q)),
        invFun := fun p => (p.fst * cos p.snd, p.fst * sin p.snd), source := {q | 0 < q.fst} ∪ {q | q.snd ≠ 0},
        target := Ioi 0 ×ˢ Ioo (-π) π,
        map_source' :=
          (_ :
            ∀ ⦃x : ℝ × ℝ⦄,
              x ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0} →
                (fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q))) x ∈
                  Ioi 0 ×ˢ Ioo (-π) π),
        map_target' :=
          (_ :
            ∀ ⦃x : ℝ × ℝ⦄,
              x ∈ Ioi 0 ×ˢ Ioo (-π) π →
                (fun p => (p.fst * cos p.snd, p.fst * sin p.snd)) x ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0}),
        left_inv' :=
          (_ :
            ∀ ⦃x : ℝ × ℝ⦄,
              x ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0} →
                (fun p => (p.fst * cos p.snd, p.fst * sin p.snd))
                    ((fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q))) x) =
                  x),
        right_inv' :=
          (_ :
            ∀ ⦃x : ℝ × ℝ⦄,
              x ∈ Ioi 0 ×ˢ Ioo (-π) π →
                (fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q)))
                    ((fun p => (p.fst * cos p.snd, p.fst * sin p.snd)) x) =
                  x) }.source
[PROOFSTEP]
refine' ContinuousOn.comp (f := Complex.equivRealProd.symm) (g := Complex.arg) (fun z hz => _) _ A
[GOAL]
case refine'_1
A : MapsTo (↑Complex.equivRealProd.symm) ({q | 0 < q.fst} ∪ {q | q.snd ≠ 0}) {z | 0 < z.re ∨ z.im ≠ 0}
z : ℂ
hz : z ∈ {z | 0 < z.re ∨ z.im ≠ 0}
⊢ ContinuousWithinAt Complex.arg {z | 0 < z.re ∨ z.im ≠ 0} z
[PROOFSTEP]
exact (Complex.continuousAt_arg hz).continuousWithinAt
[GOAL]
case refine'_2
A : MapsTo (↑Complex.equivRealProd.symm) ({q | 0 < q.fst} ∪ {q | q.snd ≠ 0}) {z | 0 < z.re ∨ z.im ≠ 0}
⊢ ContinuousOn ↑Complex.equivRealProd.symm
    { toFun := fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q)),
        invFun := fun p => (p.fst * cos p.snd, p.fst * sin p.snd), source := {q | 0 < q.fst} ∪ {q | q.snd ≠ 0},
        target := Ioi 0 ×ˢ Ioo (-π) π,
        map_source' :=
          (_ :
            ∀ ⦃x : ℝ × ℝ⦄,
              x ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0} →
                (fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q))) x ∈
                  Ioi 0 ×ˢ Ioo (-π) π),
        map_target' :=
          (_ :
            ∀ ⦃x : ℝ × ℝ⦄,
              x ∈ Ioi 0 ×ˢ Ioo (-π) π →
                (fun p => (p.fst * cos p.snd, p.fst * sin p.snd)) x ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0}),
        left_inv' :=
          (_ :
            ∀ ⦃x : ℝ × ℝ⦄,
              x ∈ {q | 0 < q.fst} ∪ {q | q.snd ≠ 0} →
                (fun p => (p.fst * cos p.snd, p.fst * sin p.snd))
                    ((fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q))) x) =
                  x),
        right_inv' :=
          (_ :
            ∀ ⦃x : ℝ × ℝ⦄,
              x ∈ Ioi 0 ×ˢ Ioo (-π) π →
                (fun q => (sqrt (q.fst ^ 2 + q.snd ^ 2), Complex.arg (↑Complex.equivRealProd.symm q)))
                    ((fun p => (p.fst * cos p.snd, p.fst * sin p.snd)) x) =
                  x) }.source
[PROOFSTEP]
exact Complex.equivRealProdClm.symm.continuous.continuousOn
[GOAL]
p : ℝ × ℝ
⊢ HasFDerivAt (↑(LocalHomeomorph.symm polarCoord))
    (↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]])))
    p
[PROOFSTEP]
rw [Matrix.toLin_finTwoProd_toContinuousLinearMap]
[GOAL]
p : ℝ × ℝ
⊢ HasFDerivAt (↑(LocalHomeomorph.symm polarCoord))
    (ContinuousLinearMap.prod
      (cos p.snd • ContinuousLinearMap.fst ℝ ℝ ℝ + (-p.fst * sin p.snd) • ContinuousLinearMap.snd ℝ ℝ ℝ)
      (sin p.snd • ContinuousLinearMap.fst ℝ ℝ ℝ + (p.fst * cos p.snd) • ContinuousLinearMap.snd ℝ ℝ ℝ))
    p
[PROOFSTEP]
convert
  HasFDerivAt.prod (𝕜 := ℝ) (hasFDerivAt_fst.mul ((hasDerivAt_cos p.2).comp_hasFDerivAt p hasFDerivAt_snd))
    (hasFDerivAt_fst.mul ((hasDerivAt_sin p.2).comp_hasFDerivAt p hasFDerivAt_snd)) using
  2
[GOAL]
case h.e'_10.h.e'_15.h.h.h
p : ℝ × ℝ
e_4✝ : instTopologicalSpaceProd = UniformSpace.toTopologicalSpace
e_5✝ : Prod.instAddCommMonoid = AddCommGroup.toAddCommMonoid
e_8✝ : NonUnitalNonAssocSemiring.toAddCommMonoid = AddCommGroup.toAddCommMonoid
he✝¹ : Prod.instModule = NormedSpace.toModule
he✝ : NormedSpace.toModule = NormedSpace.toModule
⊢ cos p.snd • ContinuousLinearMap.fst ℝ ℝ ℝ + (-p.fst * sin p.snd) • ContinuousLinearMap.snd ℝ ℝ ℝ =
    p.fst • -sin p.snd • ContinuousLinearMap.snd ℝ ℝ ℝ + (cos ∘ Prod.snd) p • ContinuousLinearMap.fst ℝ ℝ ℝ
[PROOFSTEP]
simp [smul_smul, add_comm, neg_mul, neg_smul, smul_neg]
[GOAL]
case h.e'_10.h.e'_16.h.h.h
p : ℝ × ℝ
e_4✝ : instTopologicalSpaceProd = UniformSpace.toTopologicalSpace
e_5✝ : Prod.instAddCommMonoid = AddCommGroup.toAddCommMonoid
e_11✝ : NonUnitalNonAssocSemiring.toAddCommMonoid = AddCommGroup.toAddCommMonoid
he✝¹ : Prod.instModule = NormedSpace.toModule
he✝ : NormedSpace.toModule = NormedSpace.toModule
⊢ sin p.snd • ContinuousLinearMap.fst ℝ ℝ ℝ + (p.fst * cos p.snd) • ContinuousLinearMap.snd ℝ ℝ ℝ =
    p.fst • cos p.snd • ContinuousLinearMap.snd ℝ ℝ ℝ + (sin ∘ Prod.snd) p • ContinuousLinearMap.fst ℝ ℝ ℝ
[PROOFSTEP]
simp [smul_smul, add_comm, neg_mul, neg_smul, smul_neg]
[GOAL]
⊢ polarCoord.source =ᵐ[volume] univ
[PROOFSTEP]
have A : polarCoord.sourceᶜ ⊆ LinearMap.ker (LinearMap.snd ℝ ℝ ℝ) :=
  by
  intro x hx
  simp only [polarCoord_source, compl_union, mem_inter_iff, mem_compl_iff, mem_setOf_eq, not_lt, Classical.not_not] at
    hx
  exact hx.2
[GOAL]
⊢ polarCoord.sourceᶜ ⊆ ↑(LinearMap.ker (LinearMap.snd ℝ ℝ ℝ))
[PROOFSTEP]
intro x hx
[GOAL]
x : ℝ × ℝ
hx : x ∈ polarCoord.sourceᶜ
⊢ x ∈ ↑(LinearMap.ker (LinearMap.snd ℝ ℝ ℝ))
[PROOFSTEP]
simp only [polarCoord_source, compl_union, mem_inter_iff, mem_compl_iff, mem_setOf_eq, not_lt, Classical.not_not] at hx
[GOAL]
x : ℝ × ℝ
hx : x.fst ≤ 0 ∧ x.snd = 0
⊢ x ∈ ↑(LinearMap.ker (LinearMap.snd ℝ ℝ ℝ))
[PROOFSTEP]
exact hx.2
[GOAL]
A : polarCoord.sourceᶜ ⊆ ↑(LinearMap.ker (LinearMap.snd ℝ ℝ ℝ))
⊢ polarCoord.source =ᵐ[volume] univ
[PROOFSTEP]
have B : volume (LinearMap.ker (LinearMap.snd ℝ ℝ ℝ) : Set (ℝ × ℝ)) = 0 :=
  by
  apply Measure.addHaar_submodule
  rw [Ne.def, LinearMap.ker_eq_top]
  intro h
  have : (LinearMap.snd ℝ ℝ ℝ) (0, 1) = (0 : ℝ × ℝ →ₗ[ℝ] ℝ) (0, 1) := by rw [h]
  simp at this
[GOAL]
A : polarCoord.sourceᶜ ⊆ ↑(LinearMap.ker (LinearMap.snd ℝ ℝ ℝ))
⊢ ↑↑volume ↑(LinearMap.ker (LinearMap.snd ℝ ℝ ℝ)) = 0
[PROOFSTEP]
apply Measure.addHaar_submodule
[GOAL]
case hs
A : polarCoord.sourceᶜ ⊆ ↑(LinearMap.ker (LinearMap.snd ℝ ℝ ℝ))
⊢ LinearMap.ker (LinearMap.snd ℝ ℝ ℝ) ≠ ⊤
[PROOFSTEP]
rw [Ne.def, LinearMap.ker_eq_top]
[GOAL]
case hs
A : polarCoord.sourceᶜ ⊆ ↑(LinearMap.ker (LinearMap.snd ℝ ℝ ℝ))
⊢ ¬LinearMap.snd ℝ ℝ ℝ = 0
[PROOFSTEP]
intro h
[GOAL]
case hs
A : polarCoord.sourceᶜ ⊆ ↑(LinearMap.ker (LinearMap.snd ℝ ℝ ℝ))
h : LinearMap.snd ℝ ℝ ℝ = 0
⊢ False
[PROOFSTEP]
have : (LinearMap.snd ℝ ℝ ℝ) (0, 1) = (0 : ℝ × ℝ →ₗ[ℝ] ℝ) (0, 1) := by rw [h]
[GOAL]
A : polarCoord.sourceᶜ ⊆ ↑(LinearMap.ker (LinearMap.snd ℝ ℝ ℝ))
h : LinearMap.snd ℝ ℝ ℝ = 0
⊢ ↑(LinearMap.snd ℝ ℝ ℝ) (0, 1) = ↑0 (0, 1)
[PROOFSTEP]
rw [h]
[GOAL]
case hs
A : polarCoord.sourceᶜ ⊆ ↑(LinearMap.ker (LinearMap.snd ℝ ℝ ℝ))
h : LinearMap.snd ℝ ℝ ℝ = 0
this : ↑(LinearMap.snd ℝ ℝ ℝ) (0, 1) = ↑0 (0, 1)
⊢ False
[PROOFSTEP]
simp at this
[GOAL]
A : polarCoord.sourceᶜ ⊆ ↑(LinearMap.ker (LinearMap.snd ℝ ℝ ℝ))
B : ↑↑volume ↑(LinearMap.ker (LinearMap.snd ℝ ℝ ℝ)) = 0
⊢ polarCoord.source =ᵐ[volume] univ
[PROOFSTEP]
simp only [ae_eq_univ]
[GOAL]
A : polarCoord.sourceᶜ ⊆ ↑(LinearMap.ker (LinearMap.snd ℝ ℝ ℝ))
B : ↑↑volume ↑(LinearMap.ker (LinearMap.snd ℝ ℝ ℝ)) = 0
⊢ ↑↑volume polarCoord.sourceᶜ = 0
[PROOFSTEP]
exact le_antisymm ((measure_mono A).trans (le_of_eq B)) bot_le
[GOAL]
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
⊢ ∫ (p : ℝ × ℝ) in polarCoord.target, p.fst • f (↑(LocalHomeomorph.symm polarCoord) p) = ∫ (p : ℝ × ℝ), f p
[PROOFSTEP]
set B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ := fun p =>
  LinearMap.toContinuousLinearMap
    (Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ) !![cos p.2, -p.1 * sin p.2; sin p.2, p.1 * cos p.2])
[GOAL]
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
⊢ ∫ (p : ℝ × ℝ) in polarCoord.target, p.fst • f (↑(LocalHomeomorph.symm polarCoord) p) = ∫ (p : ℝ × ℝ), f p
[PROOFSTEP]
have A : ∀ p ∈ polarCoord.symm.source, HasFDerivAt polarCoord.symm (B p) p := fun p _ => hasFDerivAt_polarCoord_symm p
[GOAL]
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
⊢ ∫ (p : ℝ × ℝ) in polarCoord.target, p.fst • f (↑(LocalHomeomorph.symm polarCoord) p) = ∫ (p : ℝ × ℝ), f p
[PROOFSTEP]
have B_det : ∀ p, (B p).det = p.1 := by
  intro p
  conv_rhs => rw [← one_mul p.1, ← cos_sq_add_sin_sq p.2]
  simp only [neg_mul, LinearMap.det_toContinuousLinearMap, LinearMap.det_toLin, Matrix.det_fin_two_of, sub_neg_eq_add]
  ring
[GOAL]
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
⊢ ∀ (p : ℝ × ℝ), ContinuousLinearMap.det (B p) = p.fst
[PROOFSTEP]
intro p
[GOAL]
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
p : ℝ × ℝ
⊢ ContinuousLinearMap.det (B p) = p.fst
[PROOFSTEP]
conv_rhs => rw [← one_mul p.1, ← cos_sq_add_sin_sq p.2]
[GOAL]
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
p : ℝ × ℝ
| p.fst
[PROOFSTEP]
rw [← one_mul p.1, ← cos_sq_add_sin_sq p.2]
[GOAL]
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
p : ℝ × ℝ
| p.fst
[PROOFSTEP]
rw [← one_mul p.1, ← cos_sq_add_sin_sq p.2]
[GOAL]
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
p : ℝ × ℝ
| p.fst
[PROOFSTEP]
rw [← one_mul p.1, ← cos_sq_add_sin_sq p.2]
[GOAL]
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
p : ℝ × ℝ
⊢ ContinuousLinearMap.det (B p) = (cos p.snd ^ 2 + sin p.snd ^ 2) * p.fst
[PROOFSTEP]
simp only [neg_mul, LinearMap.det_toContinuousLinearMap, LinearMap.det_toLin, Matrix.det_fin_two_of, sub_neg_eq_add]
[GOAL]
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
p : ℝ × ℝ
⊢ cos p.snd * (p.fst * cos p.snd) + p.fst * sin p.snd * sin p.snd = (cos p.snd ^ 2 + sin p.snd ^ 2) * p.fst
[PROOFSTEP]
ring
[GOAL]
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
B_det : ∀ (p : ℝ × ℝ), ContinuousLinearMap.det (B p) = p.fst
⊢ ∫ (p : ℝ × ℝ) in polarCoord.target, p.fst • f (↑(LocalHomeomorph.symm polarCoord) p) = ∫ (p : ℝ × ℝ), f p
[PROOFSTEP]
symm
[GOAL]
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
B_det : ∀ (p : ℝ × ℝ), ContinuousLinearMap.det (B p) = p.fst
⊢ ∫ (p : ℝ × ℝ), f p = ∫ (p : ℝ × ℝ) in polarCoord.target, p.fst • f (↑(LocalHomeomorph.symm polarCoord) p)
[PROOFSTEP]
calc
  ∫ p, f p = ∫ p in polarCoord.source, f p := by
    rw [← integral_univ]
    apply set_integral_congr_set_ae
    exact polarCoord_source_ae_eq_univ.symm
  _ = ∫ p in polarCoord.target, abs (B p).det • f (polarCoord.symm p) := by
    apply integral_target_eq_integral_abs_det_fderiv_smul volume A
  _ = ∫ p in polarCoord.target, p.1 • f (polarCoord.symm p) :=
    by
    apply set_integral_congr polarCoord.open_target.measurableSet fun x hx => ?_
    rw [B_det, abs_of_pos]
    exact hx.1
[GOAL]
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
B_det : ∀ (p : ℝ × ℝ), ContinuousLinearMap.det (B p) = p.fst
⊢ ∫ (p : ℝ × ℝ), f p = ∫ (p : ℝ × ℝ) in polarCoord.source, f p
[PROOFSTEP]
rw [← integral_univ]
[GOAL]
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
B_det : ∀ (p : ℝ × ℝ), ContinuousLinearMap.det (B p) = p.fst
⊢ ∫ (x : ℝ × ℝ) in univ, f x = ∫ (p : ℝ × ℝ) in polarCoord.source, f p
[PROOFSTEP]
apply set_integral_congr_set_ae
[GOAL]
case hst
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
B_det : ∀ (p : ℝ × ℝ), ContinuousLinearMap.det (B p) = p.fst
⊢ univ =ᵐ[volume] polarCoord.source
[PROOFSTEP]
exact polarCoord_source_ae_eq_univ.symm
[GOAL]
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
B_det : ∀ (p : ℝ × ℝ), ContinuousLinearMap.det (B p) = p.fst
⊢ ∫ (p : ℝ × ℝ) in polarCoord.source, f p =
    ∫ (p : ℝ × ℝ) in polarCoord.target, |ContinuousLinearMap.det (B p)| • f (↑(LocalHomeomorph.symm polarCoord) p)
[PROOFSTEP]
apply integral_target_eq_integral_abs_det_fderiv_smul volume A
[GOAL]
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
B_det : ∀ (p : ℝ × ℝ), ContinuousLinearMap.det (B p) = p.fst
⊢ ∫ (p : ℝ × ℝ) in polarCoord.target, |ContinuousLinearMap.det (B p)| • f (↑(LocalHomeomorph.symm polarCoord) p) =
    ∫ (p : ℝ × ℝ) in polarCoord.target, p.fst • f (↑(LocalHomeomorph.symm polarCoord) p)
[PROOFSTEP]
apply set_integral_congr polarCoord.open_target.measurableSet fun x hx => ?_
[GOAL]
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
B_det : ∀ (p : ℝ × ℝ), ContinuousLinearMap.det (B p) = p.fst
x : ℝ × ℝ
hx : x ∈ polarCoord.target
⊢ |ContinuousLinearMap.det (B x)| • f (↑(LocalHomeomorph.symm polarCoord) x) =
    x.fst • f (↑(LocalHomeomorph.symm polarCoord) x)
[PROOFSTEP]
rw [B_det, abs_of_pos]
[GOAL]
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
B_det : ∀ (p : ℝ × ℝ), ContinuousLinearMap.det (B p) = p.fst
x : ℝ × ℝ
hx : x ∈ polarCoord.target
⊢ 0 < x.fst
[PROOFSTEP]
exact hx.1


[GOAL]
R✝ : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R✝
m n : ℕ
R : Type u_1
inst✝ : CommSemiring R
x y : R
⊢ (x + y) ^ 0 = x ^ 0 + ↑0 * x ^ (0 - 1) * y + 0 * y ^ 2
[PROOFSTEP]
simp
[GOAL]
R✝ : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R✝
m n : ℕ
R : Type u_1
inst✝ : CommSemiring R
x y : R
⊢ (x + y) ^ 1 = x ^ 1 + ↑1 * x ^ (1 - 1) * y + 0 * y ^ 2
[PROOFSTEP]
simp
[GOAL]
R✝ : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R✝
m n✝ : ℕ
R : Type u_1
inst✝ : CommSemiring R
x y : R
n : ℕ
⊢ { k // (x + y) ^ (n + 2) = x ^ (n + 2) + ↑(n + 2) * x ^ (n + 2 - 1) * y + k * y ^ 2 }
[PROOFSTEP]
cases' (powAddExpansion x y (n + 1)) with z hz
[GOAL]
case mk
R✝ : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R✝
m n✝ : ℕ
R : Type u_1
inst✝ : CommSemiring R
x y : R
n : ℕ
z : R
hz : (x + y) ^ (n + 1) = x ^ (n + 1) + ↑(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2
⊢ { k // (x + y) ^ (n + 2) = x ^ (n + 2) + ↑(n + 2) * x ^ (n + 2 - 1) * y + k * y ^ 2 }
[PROOFSTEP]
exists x * z + (n + 1) * x ^ n + z * y
[GOAL]
case mk
R✝ : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R✝
m n✝ : ℕ
R : Type u_1
inst✝ : CommSemiring R
x y : R
n : ℕ
z : R
hz : (x + y) ^ (n + 1) = x ^ (n + 1) + ↑(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2
⊢ (x + y) ^ (n + 2) = x ^ (n + 2) + ↑(n + 2) * x ^ (n + 2 - 1) * y + (x * z + (↑n + 1) * x ^ n + z * y) * y ^ 2
[PROOFSTEP]
calc
  (x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
  _ = (x + y) * (x ^ (n + 1) + ↑(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
  _ = x ^ (n + 2) + ↑(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 :=
    by
    push_cast
    ring!
[GOAL]
R✝ : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R✝
m n✝ : ℕ
R : Type u_1
inst✝ : CommSemiring R
x y : R
n : ℕ
z : R
hz : (x + y) ^ (n + 1) = x ^ (n + 1) + ↑(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2
⊢ (x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1)
[PROOFSTEP]
ring
[GOAL]
R✝ : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R✝
m n✝ : ℕ
R : Type u_1
inst✝ : CommSemiring R
x y : R
n : ℕ
z : R
hz : (x + y) ^ (n + 1) = x ^ (n + 1) + ↑(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2
⊢ (x + y) * (x + y) ^ (n + 1) = (x + y) * (x ^ (n + 1) + ↑(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2)
[PROOFSTEP]
rw [hz]
[GOAL]
R✝ : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R✝
m n✝ : ℕ
R : Type u_1
inst✝ : CommSemiring R
x y : R
n : ℕ
z : R
hz : (x + y) ^ (n + 1) = x ^ (n + 1) + ↑(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2
⊢ (x + y) * (x ^ (n + 1) + ↑(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) =
    x ^ (n + 2) + ↑(n + 2) * x ^ (n + 1) * y + (x * z + (↑n + 1) * x ^ n + z * y) * y ^ 2
[PROOFSTEP]
push_cast
[GOAL]
R✝ : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R✝
m n✝ : ℕ
R : Type u_1
inst✝ : CommSemiring R
x y : R
n : ℕ
z : R
hz : (x + y) ^ (n + 1) = x ^ (n + 1) + ↑(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2
⊢ (x + y) * (x ^ (n + 1) + (↑n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) =
    x ^ (n + 2) + (↑n + 2) * x ^ (n + 1) * y + (x * z + (↑n + 1) * x ^ n + z * y) * y ^ 2
[PROOFSTEP]
ring!
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a✝ b : R
m n : ℕ
inst✝ : CommRing R
x y : R
e : ℕ
a : R
⊢ { k // a * (x + y) ^ e = a * (x ^ e + ↑e * x ^ (e - 1) * y + k * y ^ 2) }
[PROOFSTEP]
exists (powAddExpansion x y e).val
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a✝ b : R
m n : ℕ
inst✝ : CommRing R
x y : R
e : ℕ
a : R
⊢ a * (x + y) ^ e = a * (x ^ e + ↑e * x ^ (e - 1) * y + ↑(powAddExpansion x y e) * y ^ 2)
[PROOFSTEP]
congr
[GOAL]
case e_a
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a✝ b : R
m n : ℕ
inst✝ : CommRing R
x y : R
e : ℕ
a : R
⊢ (x + y) ^ e = x ^ e + ↑e * x ^ (e - 1) * y + ↑(powAddExpansion x y e) * y ^ 2
[PROOFSTEP]
apply (powAddExpansion _ _ _).property
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
f : R[X]
x y : R
⊢ eval (x + y) f = sum f fun e a => a * (x ^ e + ↑e * x ^ (e - 1) * y + ↑(Polynomial.polyBinomAux1 x y e a) * y ^ 2)
[PROOFSTEP]
unfold eval
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
f : R[X]
x y : R
⊢ eval₂ (RingHom.id R) (x + y) f =
    sum f fun e a => a * (x ^ e + ↑e * x ^ (e - 1) * y + ↑(Polynomial.polyBinomAux1 x y e a) * y ^ 2)
[PROOFSTEP]
rw [eval₂_eq_sum]
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
f : R[X]
x y : R
⊢ (sum f fun e a => ↑(RingHom.id R) a * (x + y) ^ e) =
    sum f fun e a => a * (x ^ e + ↑e * x ^ (e - 1) * y + ↑(Polynomial.polyBinomAux1 x y e a) * y ^ 2)
[PROOFSTEP]
congr with (n z)
[GOAL]
case e_f.h.h
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n✝ : ℕ
inst✝ : CommRing R
f : R[X]
x y : R
n : ℕ
z : R
⊢ ↑(RingHom.id R) z * (x + y) ^ n = z * (x ^ n + ↑n * x ^ (n - 1) * y + ↑(Polynomial.polyBinomAux1 x y n z) * y ^ 2)
[PROOFSTEP]
apply (polyBinomAux1 x y _ _).property
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
f : R[X]
x y : R
⊢ eval (x + y) f =
    ((sum f fun e a => a * x ^ e) + sum f fun e a => a * ↑e * x ^ (e - 1) * y) +
      sum f fun e a => a * ↑(Polynomial.polyBinomAux1 x y e a) * y ^ 2
[PROOFSTEP]
rw [poly_binom_aux2]
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
f : R[X]
x y : R
⊢ (sum f fun e a => a * (x ^ e + ↑e * x ^ (e - 1) * y + ↑(Polynomial.polyBinomAux1 x y e a) * y ^ 2)) =
    ((sum f fun e a => a * x ^ e) + sum f fun e a => a * ↑e * x ^ (e - 1) * y) +
      sum f fun e a => a * ↑(Polynomial.polyBinomAux1 x y e a) * y ^ 2
[PROOFSTEP]
simp [left_distrib, sum_add, mul_assoc]
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
f : R[X]
x y : R
⊢ { k // eval (x + y) f = eval x f + eval x (↑derivative f) * y + k * y ^ 2 }
[PROOFSTEP]
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
f : R[X]
x y : R
⊢ eval (x + y) f =
    eval x f + eval x (↑derivative f) * y + (sum f fun e a => a * ↑(Polynomial.polyBinomAux1 x y e a)) * y ^ 2
[PROOFSTEP]
rw [poly_binom_aux3]
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
f : R[X]
x y : R
⊢ (((sum f fun e a => a * x ^ e) + sum f fun e a => a * ↑e * x ^ (e - 1) * y) +
      sum f fun e a => a * ↑(Polynomial.polyBinomAux1 x y e a) * y ^ 2) =
    eval x f + eval x (↑derivative f) * y + (sum f fun e a => a * ↑(Polynomial.polyBinomAux1 x y e a)) * y ^ 2
[PROOFSTEP]
congr
[GOAL]
case e_a.e_a
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
f : R[X]
x y : R
⊢ (sum f fun e a => a * x ^ e) = eval x f
[PROOFSTEP]
rw [← eval_eq_sum]
[GOAL]
case e_a.e_a
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
f : R[X]
x y : R
⊢ (sum f fun e a => a * ↑e * x ^ (e - 1) * y) = eval x (↑derivative f) * y
[PROOFSTEP]
rw [derivative_eval]
[GOAL]
case e_a.e_a
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
f : R[X]
x y : R
⊢ (sum f fun e a => a * ↑e * x ^ (e - 1) * y) = (sum f fun n a => a * ↑n * x ^ (n - 1)) * y
[PROOFSTEP]
exact Finset.sum_mul.symm
[GOAL]
case e_a
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
f : R[X]
x y : R
⊢ (sum f fun e a => a * ↑(Polynomial.polyBinomAux1 x y e a) * y ^ 2) =
    (sum f fun e a => a * ↑(Polynomial.polyBinomAux1 x y e a)) * y ^ 2
[PROOFSTEP]
exact Finset.sum_mul.symm
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
x y : R
⊢ x ^ 0 - y ^ 0 = 0 * (x - y)
[PROOFSTEP]
simp
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
x y : R
⊢ x ^ 1 - y ^ 1 = 1 * (x - y)
[PROOFSTEP]
simp
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k✝ : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
x y : R
k : ℕ
⊢ { z // x ^ (k + 2) - y ^ (k + 2) = z * (x - y) }
[PROOFSTEP]
cases' @powSubPowFactor x y (k + 1) with z hz
[GOAL]
case mk
R : Type u
S : Type v
T : Type w
ι : Type x
k✝ : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
x y : R
k : ℕ
z : R
hz : x ^ (k + 1) - y ^ (k + 1) = z * (x - y)
⊢ { z // x ^ (k + 2) - y ^ (k + 2) = z * (x - y) }
[PROOFSTEP]
exists z * x + y ^ (k + 1)
[GOAL]
case mk
R : Type u
S : Type v
T : Type w
ι : Type x
k✝ : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
x y : R
k : ℕ
z : R
hz : x ^ (k + 1) - y ^ (k + 1) = z * (x - y)
⊢ x ^ (k + 2) - y ^ (k + 2) = (z * x + y ^ (k + 1)) * (x - y)
[PROOFSTEP]
linear_combination (norm := ring) x * hz
[GOAL]
case a
R : Type u
S : Type v
T : Type w
ι : Type x
k✝ : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
x y : R
k : ℕ
z : R
hz : x ^ (k + 1) - y ^ (k + 1) = z * (x - y)
⊢ x ^ (k + 2) - y ^ (k + 2) - (z * x + y ^ (k + 1)) * (x - y) - (x * (x ^ (k + 1) - y ^ (k + 1)) - x * (z * (x - y))) =
    0
[PROOFSTEP]
ring
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
f : R[X]
x y : R
⊢ { z // eval x f - eval y f = z * (x - y) }
[PROOFSTEP]
refine' ⟨f.sum fun i r => r * (powSubPowFactor x y i).val, _⟩
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
f : R[X]
x y : R
⊢ eval x f - eval y f = (sum f fun i r => r * ↑(powSubPowFactor x y i)) * (x - y)
[PROOFSTEP]
delta eval
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
f : R[X]
x y : R
⊢ eval₂ (RingHom.id R) x f - eval₂ (RingHom.id R) y f = (sum f fun i r => r * ↑(powSubPowFactor x y i)) * (x - y)
[PROOFSTEP]
rw [eval₂_eq_sum, eval₂_eq_sum]
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
f : R[X]
x y : R
⊢ ((sum f fun e a => ↑(RingHom.id R) a * x ^ e) - sum f fun e a => ↑(RingHom.id R) a * y ^ e) =
    (sum f fun i r => r * ↑(powSubPowFactor x y i)) * (x - y)
[PROOFSTEP]
simp only [sum, ← Finset.sum_sub_distrib, Finset.sum_mul]
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
f : R[X]
x y : R
⊢ (Finset.sum (support f) fun x_1 =>
      ↑(RingHom.id R) (coeff f x_1) * x ^ x_1 - ↑(RingHom.id R) (coeff f x_1) * y ^ x_1) =
    Finset.sum (support f) fun x_1 => coeff f x_1 * ↑(powSubPowFactor x y x_1) * (x - y)
[PROOFSTEP]
dsimp
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
f : R[X]
x y : R
⊢ (Finset.sum (support f) fun x_1 => coeff f x_1 * x ^ x_1 - coeff f x_1 * y ^ x_1) =
    Finset.sum (support f) fun x_1 => coeff f x_1 * ↑(powSubPowFactor x y x_1) * (x - y)
[PROOFSTEP]
congr with i
[GOAL]
case e_f.h
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : CommRing R
f : R[X]
x y : R
i : ℕ
⊢ coeff f i * x ^ i - coeff f i * y ^ i = coeff f i * ↑(powSubPowFactor x y i) * (x - y)
[PROOFSTEP]
rw [mul_assoc, ← (powSubPowFactor x y _).prop, mul_sub]


[GOAL]
p : ℕ
h : 0 < p
⊢ 0 < mersenne p
[PROOFSTEP]
dsimp [mersenne]
[GOAL]
p : ℕ
h : 0 < p
⊢ 0 < 2 ^ p - 1
[PROOFSTEP]
calc
  0 < 2 ^ 1 - 1 := by norm_num
  _ ≤ 2 ^ p - 1 := Nat.sub_le_sub_right (Nat.pow_le_pow_of_le_right (Nat.succ_pos 1) h) 1
[GOAL]
p : ℕ
h : 0 < p
⊢ 0 < 2 ^ 1 - 1
[PROOFSTEP]
norm_num
[GOAL]
p : ℕ
hp : 1 < p
⊢ 1 + 1 = 2 ^ 1
[PROOFSTEP]
rw [one_add_one_eq_two, pow_one]
[GOAL]
k : ℕ
⊢ mersenne k + 1 = 2 ^ k
[PROOFSTEP]
rw [mersenne, tsub_add_cancel_of_le]
[GOAL]
k : ℕ
⊢ 1 ≤ 2 ^ k
[PROOFSTEP]
exact one_le_pow_of_one_le (by norm_num) k
[GOAL]
k : ℕ
⊢ 1 ≤ 2
[PROOFSTEP]
norm_num
[GOAL]
p : ℕ
hp : 0 < p
⊢ 1 < 2 ^ p
[PROOFSTEP]
exact_mod_cast Nat.one_lt_two_pow p hp
[GOAL]
p : ℕ
w : 0 < p
i : ℕ
⊢ 0 ≤ sMod p i
[PROOFSTEP]
cases i
[GOAL]
case zero
p : ℕ
w : 0 < p
⊢ 0 ≤ sMod p zero
[PROOFSTEP]
dsimp [sMod]
[GOAL]
case succ
p : ℕ
w : 0 < p
n✝ : ℕ
⊢ 0 ≤ sMod p (succ n✝)
[PROOFSTEP]
dsimp [sMod]
[GOAL]
case zero
p : ℕ
w : 0 < p
⊢ 0 ≤ 4 % (2 ^ p - 1)
[PROOFSTEP]
exact sup_eq_right.mp rfl
[GOAL]
case succ
p : ℕ
w : 0 < p
n✝ : ℕ
⊢ 0 ≤ (sMod p n✝ ^ 2 - 2) % (2 ^ p - 1)
[PROOFSTEP]
apply Int.emod_nonneg
[GOAL]
case succ.a
p : ℕ
w : 0 < p
n✝ : ℕ
⊢ 2 ^ p - 1 ≠ 0
[PROOFSTEP]
exact mersenne_int_ne_zero p w
[GOAL]
p i : ℕ
⊢ sMod p i % (2 ^ p - 1) = sMod p i
[PROOFSTEP]
cases i
[GOAL]
case zero
p : ℕ
⊢ sMod p zero % (2 ^ p - 1) = sMod p zero
[PROOFSTEP]
simp [sMod]
[GOAL]
case succ
p n✝ : ℕ
⊢ sMod p (succ n✝) % (2 ^ p - 1) = sMod p (succ n✝)
[PROOFSTEP]
simp [sMod]
[GOAL]
p : ℕ
w : 0 < p
i : ℕ
⊢ sMod p i < 2 ^ p - 1
[PROOFSTEP]
rw [← sMod_mod]
[GOAL]
p : ℕ
w : 0 < p
i : ℕ
⊢ sMod p i % (2 ^ p - 1) < 2 ^ p - 1
[PROOFSTEP]
refine (Int.emod_lt _ (mersenne_int_ne_zero p w)).trans_eq ?_
[GOAL]
p : ℕ
w : 0 < p
i : ℕ
⊢ |2 ^ p - 1| = 2 ^ p - 1
[PROOFSTEP]
exact abs_of_nonneg (mersenne_int_pos w).le
[GOAL]
p' i : ℕ
⊢ sZMod (p' + 2) i = ↑(s i)
[PROOFSTEP]
induction' i with i ih
[GOAL]
case zero
p' : ℕ
⊢ sZMod (p' + 2) zero = ↑(s zero)
[PROOFSTEP]
dsimp [s, sZMod]
[GOAL]
case zero
p' : ℕ
⊢ 4 = ↑4
[PROOFSTEP]
norm_num
[GOAL]
case succ
p' i : ℕ
ih : sZMod (p' + 2) i = ↑(s i)
⊢ sZMod (p' + 2) (succ i) = ↑(s (succ i))
[PROOFSTEP]
push_cast [s, sZMod, ih]
[GOAL]
case succ
p' i : ℕ
ih : sZMod (p' + 2) i = ↑(s i)
⊢ ↑(s i) ^ 2 - 2 = ↑(s i) ^ 2 - 2
[PROOFSTEP]
rfl
[GOAL]
b p : ℕ
w : 0 < b
⊢ ↑(b ^ p - 1) = ↑b ^ p - 1
[PROOFSTEP]
have : 1 ≤ b ^ p := Nat.one_le_pow p b w
[GOAL]
b p : ℕ
w : 0 < b
this : 1 ≤ b ^ p
⊢ ↑(b ^ p - 1) = ↑b ^ p - 1
[PROOFSTEP]
norm_cast
[GOAL]
p : ℕ
⊢ 0 < 2
[PROOFSTEP]
decide
[GOAL]
p i : ℕ
⊢ sZMod p i = ↑(sMod p i)
[PROOFSTEP]
induction i
[GOAL]
case zero
p : ℕ
⊢ sZMod p zero = ↑(sMod p zero)
[PROOFSTEP]
push_cast [← Int.coe_nat_two_pow_pred p, sMod, sZMod, *]
[GOAL]
case succ
p n✝ : ℕ
n_ih✝ : sZMod p n✝ = ↑(sMod p n✝)
⊢ sZMod p (succ n✝) = ↑(sMod p (succ n✝))
[PROOFSTEP]
push_cast [← Int.coe_nat_two_pow_pred p, sMod, sZMod, *]
[GOAL]
case zero
p : ℕ
⊢ 4 = 4
[PROOFSTEP]
rfl
[GOAL]
case succ
p n✝ : ℕ
n_ih✝ : sZMod p n✝ = ↑(sMod p n✝)
⊢ ↑(sMod p n✝) ^ 2 - 2 = ↑(sMod p n✝) ^ 2 - 2
[PROOFSTEP]
rfl
[GOAL]
p : ℕ
w : 1 < p
⊢ lucasLehmerResidue p = 0 ↔ sMod p (p - 2) = 0
[PROOFSTEP]
dsimp [lucasLehmerResidue]
[GOAL]
p : ℕ
w : 1 < p
⊢ sZMod p (p - 2) = 0 ↔ sMod p (p - 2) = 0
[PROOFSTEP]
rw [sZMod_eq_sMod p]
[GOAL]
p : ℕ
w : 1 < p
⊢ ↑(sMod p (p - 2)) = 0 ↔ sMod p (p - 2) = 0
[PROOFSTEP]
constructor
[GOAL]
case mp
p : ℕ
w : 1 < p
⊢ ↑(sMod p (p - 2)) = 0 → sMod p (p - 2) = 0
[PROOFSTEP]
intro h
[GOAL]
case mp
p : ℕ
w : 1 < p
h : ↑(sMod p (p - 2)) = 0
⊢ sMod p (p - 2) = 0
[PROOFSTEP]
simp [ZMod.int_cast_zmod_eq_zero_iff_dvd] at h
[GOAL]
case mp
p : ℕ
w : 1 < p
h : 2 ^ p - 1 ∣ sMod p (p - 2)
⊢ sMod p (p - 2) = 0
[PROOFSTEP]
apply Int.eq_zero_of_dvd_of_nonneg_of_lt _ _ h
[GOAL]
p : ℕ
w : 1 < p
h : 2 ^ p - 1 ∣ sMod p (p - 2)
⊢ 0 ≤ sMod p (p - 2)
[PROOFSTEP]
clear h
[GOAL]
p : ℕ
w : 1 < p
h : 2 ^ p - 1 ∣ sMod p (p - 2)
⊢ sMod p (p - 2) < 2 ^ p - 1
[PROOFSTEP]
clear h
[GOAL]
p : ℕ
w : 1 < p
⊢ 0 ≤ sMod p (p - 2)
[PROOFSTEP]
apply sMod_nonneg _ (Nat.lt_of_succ_lt w)
[GOAL]
p : ℕ
w : 1 < p
⊢ sMod p (p - 2) < 2 ^ p - 1
[PROOFSTEP]
exact sMod_lt _ (Nat.lt_of_succ_lt w) (p - 2)
[GOAL]
case mpr
p : ℕ
w : 1 < p
⊢ sMod p (p - 2) = 0 → ↑(sMod p (p - 2)) = 0
[PROOFSTEP]
intro h
[GOAL]
case mpr
p : ℕ
w : 1 < p
h : sMod p (p - 2) = 0
⊢ ↑(sMod p (p - 2)) = 0
[PROOFSTEP]
rw [h]
[GOAL]
case mpr
p : ℕ
w : 1 < p
h : sMod p (p - 2) = 0
⊢ ↑0 = 0
[PROOFSTEP]
simp
[GOAL]
q : ℕ+
x y : X q
h₁ : x.fst = y.fst
h₂ : x.snd = y.snd
⊢ x = y
[PROOFSTEP]
cases x
[GOAL]
case mk
q : ℕ+
y : X q
fst✝ snd✝ : ZMod ↑q
h₁ : (fst✝, snd✝).fst = y.fst
h₂ : (fst✝, snd✝).snd = y.snd
⊢ (fst✝, snd✝) = y
[PROOFSTEP]
cases y
[GOAL]
case mk.mk
q : ℕ+
fst✝¹ snd✝¹ fst✝ snd✝ : ZMod ↑q
h₁ : (fst✝¹, snd✝¹).fst = (fst✝, snd✝).fst
h₂ : (fst✝¹, snd✝¹).snd = (fst✝, snd✝).snd
⊢ (fst✝¹, snd✝¹) = (fst✝, snd✝)
[PROOFSTEP]
congr
[GOAL]
q : ℕ+
src✝¹ : Mul (X q) := inferInstanceAs (Mul (X q))
src✝ : One (X q) := inferInstanceAs (One (X q))
x y z : X q
⊢ x * y * z = x * (y * z)
[PROOFSTEP]
ext
[GOAL]
case h₁
q : ℕ+
src✝¹ : Mul (X q) := inferInstanceAs (Mul (X q))
src✝ : One (X q) := inferInstanceAs (One (X q))
x y z : X q
⊢ (x * y * z).fst = (x * (y * z)).fst
[PROOFSTEP]
dsimp
[GOAL]
case h₂
q : ℕ+
src✝¹ : Mul (X q) := inferInstanceAs (Mul (X q))
src✝ : One (X q) := inferInstanceAs (One (X q))
x y z : X q
⊢ (x * y * z).snd = (x * (y * z)).snd
[PROOFSTEP]
dsimp
[GOAL]
case h₁
q : ℕ+
src✝¹ : Mul (X q) := inferInstanceAs (Mul (X q))
src✝ : One (X q) := inferInstanceAs (One (X q))
x y z : X q
⊢ (x.fst * y.fst + 3 * x.snd * y.snd) * z.fst + 3 * (x.fst * y.snd + x.snd * y.fst) * z.snd =
    x.fst * (y.fst * z.fst + 3 * y.snd * z.snd) + 3 * x.snd * (y.fst * z.snd + y.snd * z.fst)
[PROOFSTEP]
ring
[GOAL]
case h₂
q : ℕ+
src✝¹ : Mul (X q) := inferInstanceAs (Mul (X q))
src✝ : One (X q) := inferInstanceAs (One (X q))
x y z : X q
⊢ (x.fst * y.fst + 3 * x.snd * y.snd) * z.snd + (x.fst * y.snd + x.snd * y.fst) * z.fst =
    x.fst * (y.fst * z.snd + y.snd * z.fst) + x.snd * (y.fst * z.fst + 3 * y.snd * z.snd)
[PROOFSTEP]
ring
[GOAL]
q : ℕ+
src✝¹ : Mul (X q) := inferInstanceAs (Mul (X q))
src✝ : One (X q) := inferInstanceAs (One (X q))
x : X q
⊢ 1 * x = x
[PROOFSTEP]
ext
[GOAL]
case h₁
q : ℕ+
src✝¹ : Mul (X q) := inferInstanceAs (Mul (X q))
src✝ : One (X q) := inferInstanceAs (One (X q))
x : X q
⊢ (1 * x).fst = x.fst
[PROOFSTEP]
simp
[GOAL]
case h₂
q : ℕ+
src✝¹ : Mul (X q) := inferInstanceAs (Mul (X q))
src✝ : One (X q) := inferInstanceAs (One (X q))
x : X q
⊢ (1 * x).snd = x.snd
[PROOFSTEP]
simp
[GOAL]
q : ℕ+
src✝¹ : Mul (X q) := inferInstanceAs (Mul (X q))
src✝ : One (X q) := inferInstanceAs (One (X q))
x : X q
⊢ x * 1 = x
[PROOFSTEP]
ext
[GOAL]
case h₁
q : ℕ+
src✝¹ : Mul (X q) := inferInstanceAs (Mul (X q))
src✝ : One (X q) := inferInstanceAs (One (X q))
x : X q
⊢ (x * 1).fst = x.fst
[PROOFSTEP]
simp
[GOAL]
case h₂
q : ℕ+
src✝¹ : Mul (X q) := inferInstanceAs (Mul (X q))
src✝ : One (X q) := inferInstanceAs (One (X q))
x : X q
⊢ (x * 1).snd = x.snd
[PROOFSTEP]
simp
[GOAL]
q : ℕ+
src✝² : Monoid (X q) := inferInstanceAs (Monoid (X q))
src✝¹ : AddCommGroup (X q) := inferInstanceAs (AddCommGroup (X q))
src✝ : NatCast (X q) := inferInstanceAs (NatCast (X q))
⊢ NatCast.natCast 0 = 0
[PROOFSTEP]
ext
[GOAL]
case h₁
q : ℕ+
src✝² : Monoid (X q) := inferInstanceAs (Monoid (X q))
src✝¹ : AddCommGroup (X q) := inferInstanceAs (AddCommGroup (X q))
src✝ : NatCast (X q) := inferInstanceAs (NatCast (X q))
⊢ (NatCast.natCast 0).fst = 0.fst
[PROOFSTEP]
simp
[GOAL]
case h₂
q : ℕ+
src✝² : Monoid (X q) := inferInstanceAs (Monoid (X q))
src✝¹ : AddCommGroup (X q) := inferInstanceAs (AddCommGroup (X q))
src✝ : NatCast (X q) := inferInstanceAs (NatCast (X q))
⊢ (NatCast.natCast 0).snd = 0.snd
[PROOFSTEP]
simp
[GOAL]
q : ℕ+
src✝² : Monoid (X q) := inferInstanceAs (Monoid (X q))
src✝¹ : AddCommGroup (X q) := inferInstanceAs (AddCommGroup (X q))
src✝ : NatCast (X q) := inferInstanceAs (NatCast (X q))
x✝ : ℕ
⊢ NatCast.natCast (x✝ + 1) = NatCast.natCast x✝ + 1
[PROOFSTEP]
ext
[GOAL]
case h₁
q : ℕ+
src✝² : Monoid (X q) := inferInstanceAs (Monoid (X q))
src✝¹ : AddCommGroup (X q) := inferInstanceAs (AddCommGroup (X q))
src✝ : NatCast (X q) := inferInstanceAs (NatCast (X q))
x✝ : ℕ
⊢ (NatCast.natCast (x✝ + 1)).fst = (NatCast.natCast x✝ + 1).fst
[PROOFSTEP]
simp
[GOAL]
case h₂
q : ℕ+
src✝² : Monoid (X q) := inferInstanceAs (Monoid (X q))
src✝¹ : AddCommGroup (X q) := inferInstanceAs (AddCommGroup (X q))
src✝ : NatCast (X q) := inferInstanceAs (NatCast (X q))
x✝ : ℕ
⊢ (NatCast.natCast (x✝ + 1)).snd = (NatCast.natCast x✝ + 1).snd
[PROOFSTEP]
simp
[GOAL]
q : ℕ+
src✝² : Monoid (X q) := inferInstanceAs (Monoid (X q))
src✝¹ : AddCommGroup (X q) := inferInstanceAs (AddCommGroup (X q))
src✝ : NatCast (X q) := inferInstanceAs (NatCast (X q))
n : ℕ
⊢ IntCast.intCast ↑n = ↑n
[PROOFSTEP]
ext
[GOAL]
case h₁
q : ℕ+
src✝² : Monoid (X q) := inferInstanceAs (Monoid (X q))
src✝¹ : AddCommGroup (X q) := inferInstanceAs (AddCommGroup (X q))
src✝ : NatCast (X q) := inferInstanceAs (NatCast (X q))
n : ℕ
⊢ (IntCast.intCast ↑n).fst = (↑n).fst
[PROOFSTEP]
simp
[GOAL]
case h₂
q : ℕ+
src✝² : Monoid (X q) := inferInstanceAs (Monoid (X q))
src✝¹ : AddCommGroup (X q) := inferInstanceAs (AddCommGroup (X q))
src✝ : NatCast (X q) := inferInstanceAs (NatCast (X q))
n : ℕ
⊢ (IntCast.intCast ↑n).snd = (↑n).snd
[PROOFSTEP]
simp
[GOAL]
q : ℕ+
src✝² : Monoid (X q) := inferInstanceAs (Monoid (X q))
src✝¹ : AddCommGroup (X q) := inferInstanceAs (AddCommGroup (X q))
src✝ : NatCast (X q) := inferInstanceAs (NatCast (X q))
n : ℕ
⊢ IntCast.intCast (Int.negSucc n) = -↑(n + 1)
[PROOFSTEP]
ext
[GOAL]
case h₁
q : ℕ+
src✝² : Monoid (X q) := inferInstanceAs (Monoid (X q))
src✝¹ : AddCommGroup (X q) := inferInstanceAs (AddCommGroup (X q))
src✝ : NatCast (X q) := inferInstanceAs (NatCast (X q))
n : ℕ
⊢ (IntCast.intCast (Int.negSucc n)).fst = (-↑(n + 1)).fst
[PROOFSTEP]
simp
[GOAL]
case h₂
q : ℕ+
src✝² : Monoid (X q) := inferInstanceAs (Monoid (X q))
src✝¹ : AddCommGroup (X q) := inferInstanceAs (AddCommGroup (X q))
src✝ : NatCast (X q) := inferInstanceAs (NatCast (X q))
n : ℕ
⊢ (IntCast.intCast (Int.negSucc n)).snd = (-↑(n + 1)).snd
[PROOFSTEP]
simp
[GOAL]
q : ℕ+
x y z : X q
⊢ x * (y + z) = x * y + x * z
[PROOFSTEP]
ext
[GOAL]
case h₁
q : ℕ+
x y z : X q
⊢ (x * (y + z)).fst = (x * y + x * z).fst
[PROOFSTEP]
dsimp
[GOAL]
case h₂
q : ℕ+
x y z : X q
⊢ (x * (y + z)).snd = (x * y + x * z).snd
[PROOFSTEP]
dsimp
[GOAL]
case h₁
q : ℕ+
x y z : X q
⊢ x.fst * (y.fst + z.fst) + 3 * x.snd * (y.snd + z.snd) =
    x.fst * y.fst + 3 * x.snd * y.snd + (x.fst * z.fst + 3 * x.snd * z.snd)
[PROOFSTEP]
ring
[GOAL]
case h₂
q : ℕ+
x y z : X q
⊢ x.fst * (y.snd + z.snd) + x.snd * (y.fst + z.fst) = x.fst * y.snd + x.snd * y.fst + (x.fst * z.snd + x.snd * z.fst)
[PROOFSTEP]
ring
[GOAL]
q : ℕ+
x y z : X q
⊢ (x + y) * z = x * z + y * z
[PROOFSTEP]
ext
[GOAL]
case h₁
q : ℕ+
x y z : X q
⊢ ((x + y) * z).fst = (x * z + y * z).fst
[PROOFSTEP]
dsimp
[GOAL]
case h₂
q : ℕ+
x y z : X q
⊢ ((x + y) * z).snd = (x * z + y * z).snd
[PROOFSTEP]
dsimp
[GOAL]
case h₁
q : ℕ+
x y z : X q
⊢ (x.fst + y.fst) * z.fst + 3 * (x.snd + y.snd) * z.snd =
    x.fst * z.fst + 3 * x.snd * z.snd + (y.fst * z.fst + 3 * y.snd * z.snd)
[PROOFSTEP]
ring
[GOAL]
case h₂
q : ℕ+
x y z : X q
⊢ (x.fst + y.fst) * z.snd + (x.snd + y.snd) * z.fst = x.fst * z.snd + x.snd * z.fst + (y.fst * z.snd + y.snd * z.fst)
[PROOFSTEP]
ring
[GOAL]
q : ℕ+
src✝² : AddGroupWithOne (X q) := inferInstanceAs (AddGroupWithOne (X q))
src✝¹ : AddCommGroup (X q) := inferInstanceAs (AddCommGroup (X q))
src✝ : Monoid (X q) := inferInstanceAs (Monoid (X q))
x✝ : X q
⊢ 0 * x✝ = 0
[PROOFSTEP]
ext
[GOAL]
case h₁
q : ℕ+
src✝² : AddGroupWithOne (X q) := inferInstanceAs (AddGroupWithOne (X q))
src✝¹ : AddCommGroup (X q) := inferInstanceAs (AddCommGroup (X q))
src✝ : Monoid (X q) := inferInstanceAs (Monoid (X q))
x✝ : X q
⊢ (0 * x✝).fst = 0.fst
[PROOFSTEP]
simp
[GOAL]
case h₂
q : ℕ+
src✝² : AddGroupWithOne (X q) := inferInstanceAs (AddGroupWithOne (X q))
src✝¹ : AddCommGroup (X q) := inferInstanceAs (AddCommGroup (X q))
src✝ : Monoid (X q) := inferInstanceAs (Monoid (X q))
x✝ : X q
⊢ (0 * x✝).snd = 0.snd
[PROOFSTEP]
simp
[GOAL]
q : ℕ+
src✝² : AddGroupWithOne (X q) := inferInstanceAs (AddGroupWithOne (X q))
src✝¹ : AddCommGroup (X q) := inferInstanceAs (AddCommGroup (X q))
src✝ : Monoid (X q) := inferInstanceAs (Monoid (X q))
x✝ : X q
⊢ x✝ * 0 = 0
[PROOFSTEP]
ext
[GOAL]
case h₁
q : ℕ+
src✝² : AddGroupWithOne (X q) := inferInstanceAs (AddGroupWithOne (X q))
src✝¹ : AddCommGroup (X q) := inferInstanceAs (AddCommGroup (X q))
src✝ : Monoid (X q) := inferInstanceAs (Monoid (X q))
x✝ : X q
⊢ (x✝ * 0).fst = 0.fst
[PROOFSTEP]
simp
[GOAL]
case h₂
q : ℕ+
src✝² : AddGroupWithOne (X q) := inferInstanceAs (AddGroupWithOne (X q))
src✝¹ : AddCommGroup (X q) := inferInstanceAs (AddCommGroup (X q))
src✝ : Monoid (X q) := inferInstanceAs (Monoid (X q))
x✝ : X q
⊢ (x✝ * 0).snd = 0.snd
[PROOFSTEP]
simp
[GOAL]
q : ℕ+
src✝ : Ring (X q) := inferInstanceAs (Ring (X q))
x✝¹ x✝ : X q
⊢ x✝¹ * x✝ = x✝ * x✝¹
[PROOFSTEP]
ext
[GOAL]
case h₁
q : ℕ+
src✝ : Ring (X q) := inferInstanceAs (Ring (X q))
x✝¹ x✝ : X q
⊢ (x✝¹ * x✝).fst = (x✝ * x✝¹).fst
[PROOFSTEP]
dsimp
[GOAL]
case h₂
q : ℕ+
src✝ : Ring (X q) := inferInstanceAs (Ring (X q))
x✝¹ x✝ : X q
⊢ (x✝¹ * x✝).snd = (x✝ * x✝¹).snd
[PROOFSTEP]
dsimp
[GOAL]
case h₁
q : ℕ+
src✝ : Ring (X q) := inferInstanceAs (Ring (X q))
x✝¹ x✝ : X q
⊢ x✝¹.fst * x✝.fst + 3 * x✝¹.snd * x✝.snd = x✝.fst * x✝¹.fst + 3 * x✝.snd * x✝¹.snd
[PROOFSTEP]
ring
[GOAL]
case h₂
q : ℕ+
src✝ : Ring (X q) := inferInstanceAs (Ring (X q))
x✝¹ x✝ : X q
⊢ x✝¹.fst * x✝.snd + x✝¹.snd * x✝.fst = x✝.fst * x✝¹.snd + x✝.snd * x✝¹.fst
[PROOFSTEP]
ring
[GOAL]
q : ℕ+
n m : ℤ
⊢ ↑(n * m) = ↑n * ↑m
[PROOFSTEP]
ext
[GOAL]
case h₁
q : ℕ+
n m : ℤ
⊢ (↑(n * m)).fst = (↑n * ↑m).fst
[PROOFSTEP]
simp
[GOAL]
case h₂
q : ℕ+
n m : ℤ
⊢ (↑(n * m)).snd = (↑n * ↑m).snd
[PROOFSTEP]
simp
[GOAL]
q : ℕ+
n : ℕ
⊢ ↑↑n = ↑n
[PROOFSTEP]
ext
[GOAL]
case h₁
q : ℕ+
n : ℕ
⊢ (↑↑n).fst = (↑n).fst
[PROOFSTEP]
simp
[GOAL]
case h₂
q : ℕ+
n : ℕ
⊢ (↑↑n).snd = (↑n).snd
[PROOFSTEP]
simp
[GOAL]
q : ℕ+
⊢ Fintype.card (X q) = ↑q ^ 2
[PROOFSTEP]
dsimp [X]
[GOAL]
q : ℕ+
⊢ Fintype.card (ZMod ↑q × ZMod ↑q) = ↑q ^ 2
[PROOFSTEP]
rw [Fintype.card_prod, ZMod.card q, sq]
[GOAL]
q : ℕ+
w : 1 < q
⊢ Fintype.card (X q)ˣ < ↑q ^ 2
[PROOFSTEP]
have : Fact (1 < (q : ℕ)) := ⟨w⟩
[GOAL]
q : ℕ+
w : 1 < q
this : Fact (1 < ↑q)
⊢ Fintype.card (X q)ˣ < ↑q ^ 2
[PROOFSTEP]
convert card_units_lt (X q)
[GOAL]
case h.e'_4
q : ℕ+
w : 1 < q
this : Fact (1 < ↑q)
⊢ ↑q ^ 2 = Fintype.card (X q)
[PROOFSTEP]
rw [card_eq]
[GOAL]
q✝ q : ℕ+
⊢ ω * ωb = 1
[PROOFSTEP]
dsimp [ω, ωb]
[GOAL]
q✝ q : ℕ+
⊢ (2, 1) * (2, -1) = 1
[PROOFSTEP]
ext
[GOAL]
case h₁
q✝ q : ℕ+
⊢ ((2, 1) * (2, -1)).fst = 1.fst
[PROOFSTEP]
simp
[GOAL]
case h₂
q✝ q : ℕ+
⊢ ((2, 1) * (2, -1)).snd = 1.snd
[PROOFSTEP]
simp
[GOAL]
case h₁
q✝ q : ℕ+
⊢ 2 * 2 + -3 = 1
[PROOFSTEP]
ring
[GOAL]
q✝ q : ℕ+
⊢ ωb * ω = 1
[PROOFSTEP]
rw [mul_comm, ω_mul_ωb]
[GOAL]
q : ℕ+
i : ℕ
⊢ ↑(s i) = ω ^ 2 ^ i + ωb ^ 2 ^ i
[PROOFSTEP]
induction' i with i ih
[GOAL]
case zero
q : ℕ+
⊢ ↑(s zero) = ω ^ 2 ^ zero + ωb ^ 2 ^ zero
[PROOFSTEP]
dsimp [s, ω, ωb]
[GOAL]
case zero
q : ℕ+
⊢ ↑4 = (2, 1) ^ 1 + (2, -1) ^ 1
[PROOFSTEP]
ext
[GOAL]
case zero.h₁
q : ℕ+
⊢ (↑4).fst = ((2, 1) ^ 1 + (2, -1) ^ 1).fst
[PROOFSTEP]
norm_num
[GOAL]
case zero.h₂
q : ℕ+
⊢ (↑4).snd = ((2, 1) ^ 1 + (2, -1) ^ 1).snd
[PROOFSTEP]
norm_num
[GOAL]
case succ
q : ℕ+
i : ℕ
ih : ↑(s i) = ω ^ 2 ^ i + ωb ^ 2 ^ i
⊢ ↑(s (succ i)) = ω ^ 2 ^ succ i + ωb ^ 2 ^ succ i
[PROOFSTEP]
calc
  (s (i + 1) : X q) = (s i ^ 2 - 2 : ℤ) := rfl
  _ = (s i : X q) ^ 2 - 2 := by push_cast ; rfl
  _ = (ω ^ 2 ^ i + ωb ^ 2 ^ i) ^ 2 - 2 := by rw [ih]
  _ = (ω ^ 2 ^ i) ^ 2 + (ωb ^ 2 ^ i) ^ 2 + 2 * (ωb ^ 2 ^ i * ω ^ 2 ^ i) - 2 := by ring
  _ = (ω ^ 2 ^ i) ^ 2 + (ωb ^ 2 ^ i) ^ 2 := by rw [← mul_pow ωb ω, ωb_mul_ω, one_pow, mul_one, add_sub_cancel]
  _ = ω ^ 2 ^ (i + 1) + ωb ^ 2 ^ (i + 1) := by rw [← pow_mul, ← pow_mul, _root_.pow_succ']
[GOAL]
q : ℕ+
i : ℕ
ih : ↑(s i) = ω ^ 2 ^ i + ωb ^ 2 ^ i
⊢ ↑(s i ^ 2 - 2) = ↑(s i) ^ 2 - 2
[PROOFSTEP]
push_cast
[GOAL]
q : ℕ+
i : ℕ
ih : ↑(s i) = ω ^ 2 ^ i + ωb ^ 2 ^ i
⊢ ↑(s i) ^ 2 - 2 = ↑(s i) ^ 2 - 2
[PROOFSTEP]
rfl
[GOAL]
q : ℕ+
i : ℕ
ih : ↑(s i) = ω ^ 2 ^ i + ωb ^ 2 ^ i
⊢ ↑(s i) ^ 2 - 2 = (ω ^ 2 ^ i + ωb ^ 2 ^ i) ^ 2 - 2
[PROOFSTEP]
rw [ih]
[GOAL]
q : ℕ+
i : ℕ
ih : ↑(s i) = ω ^ 2 ^ i + ωb ^ 2 ^ i
⊢ (ω ^ 2 ^ i + ωb ^ 2 ^ i) ^ 2 - 2 = (ω ^ 2 ^ i) ^ 2 + (ωb ^ 2 ^ i) ^ 2 + 2 * (ωb ^ 2 ^ i * ω ^ 2 ^ i) - 2
[PROOFSTEP]
ring
[GOAL]
q : ℕ+
i : ℕ
ih : ↑(s i) = ω ^ 2 ^ i + ωb ^ 2 ^ i
⊢ (ω ^ 2 ^ i) ^ 2 + (ωb ^ 2 ^ i) ^ 2 + 2 * (ωb ^ 2 ^ i * ω ^ 2 ^ i) - 2 = (ω ^ 2 ^ i) ^ 2 + (ωb ^ 2 ^ i) ^ 2
[PROOFSTEP]
rw [← mul_pow ωb ω, ωb_mul_ω, one_pow, mul_one, add_sub_cancel]
[GOAL]
q : ℕ+
i : ℕ
ih : ↑(s i) = ω ^ 2 ^ i + ωb ^ 2 ^ i
⊢ (ω ^ 2 ^ i) ^ 2 + (ωb ^ 2 ^ i) ^ 2 = ω ^ 2 ^ (i + 1) + ωb ^ 2 ^ (i + 1)
[PROOFSTEP]
rw [← pow_mul, ← pow_mul, _root_.pow_succ']
[GOAL]
p' : ℕ
⊢ 2 < q (p' + 2)
[PROOFSTEP]
refine (minFac_prime (one_lt_mersenne ?_).ne').two_le.lt_of_ne' ?_
[GOAL]
case refine_1
p' : ℕ
⊢ 1 < p' + 2
[PROOFSTEP]
exact le_add_left _ _
[GOAL]
case refine_2
p' : ℕ
⊢ minFac (mersenne (p' + 2)) ≠ 2
[PROOFSTEP]
rw [Ne.def, minFac_eq_two_iff, mersenne, Nat.pow_succ']
[GOAL]
case refine_2
p' : ℕ
⊢ ¬2 ∣ 2 * 2 ^ (p' + 1) - 1
[PROOFSTEP]
exact Nat.two_not_dvd_two_mul_sub_one (Nat.one_le_two_pow _)
[GOAL]
p' : ℕ
h : lucasLehmerResidue (p' + 2) = 0
⊢ ∃ k, ω ^ 2 ^ (p' + 1) = ↑k * ↑(mersenne (p' + 2)) * ω ^ 2 ^ p' - 1
[PROOFSTEP]
dsimp [lucasLehmerResidue] at h
[GOAL]
p' : ℕ
h : sZMod (p' + 2) (p' + 2 - 2) = 0
⊢ ∃ k, ω ^ 2 ^ (p' + 1) = ↑k * ↑(mersenne (p' + 2)) * ω ^ 2 ^ p' - 1
[PROOFSTEP]
rw [sZMod_eq_s p'] at h
[GOAL]
p' : ℕ
h : ↑(s (p' + 2 - 2)) = 0
⊢ ∃ k, ω ^ 2 ^ (p' + 1) = ↑k * ↑(mersenne (p' + 2)) * ω ^ 2 ^ p' - 1
[PROOFSTEP]
simp [ZMod.int_cast_zmod_eq_zero_iff_dvd] at h
[GOAL]
p' : ℕ
h : 2 ^ (p' + 2) - 1 ∣ s p'
⊢ ∃ k, ω ^ 2 ^ (p' + 1) = ↑k * ↑(mersenne (p' + 2)) * ω ^ 2 ^ p' - 1
[PROOFSTEP]
cases' h with k h
[GOAL]
case intro
p' : ℕ
k : ℤ
h : s p' = (2 ^ (p' + 2) - 1) * k
⊢ ∃ k, ω ^ 2 ^ (p' + 1) = ↑k * ↑(mersenne (p' + 2)) * ω ^ 2 ^ p' - 1
[PROOFSTEP]
use k
[GOAL]
case h
p' : ℕ
k : ℤ
h : s p' = (2 ^ (p' + 2) - 1) * k
⊢ ω ^ 2 ^ (p' + 1) = ↑k * ↑(mersenne (p' + 2)) * ω ^ 2 ^ p' - 1
[PROOFSTEP]
replace h := congr_arg (fun n : ℤ => (n : X (q (p' + 2)))) h
[GOAL]
case h
p' : ℕ
k : ℤ
h : (fun n => ↑n) (s p') = (fun n => ↑n) ((2 ^ (p' + 2) - 1) * k)
⊢ ω ^ 2 ^ (p' + 1) = ↑k * ↑(mersenne (p' + 2)) * ω ^ 2 ^ p' - 1
[PROOFSTEP]
dsimp at h
[GOAL]
case h
p' : ℕ
k : ℤ
h : ↑(s p') = ↑((2 ^ (p' + 2) - 1) * k)
⊢ ω ^ 2 ^ (p' + 1) = ↑k * ↑(mersenne (p' + 2)) * ω ^ 2 ^ p' - 1
[PROOFSTEP]
rw [closed_form] at h
[GOAL]
case h
p' : ℕ
k : ℤ
h : ω ^ 2 ^ p' + ωb ^ 2 ^ p' = ↑((2 ^ (p' + 2) - 1) * k)
⊢ ω ^ 2 ^ (p' + 1) = ↑k * ↑(mersenne (p' + 2)) * ω ^ 2 ^ p' - 1
[PROOFSTEP]
replace h := congr_arg (fun x => ω ^ 2 ^ p' * x) h
[GOAL]
case h
p' : ℕ
k : ℤ
h : (fun x => ω ^ 2 ^ p' * x) (ω ^ 2 ^ p' + ωb ^ 2 ^ p') = (fun x => ω ^ 2 ^ p' * x) ↑((2 ^ (p' + 2) - 1) * k)
⊢ ω ^ 2 ^ (p' + 1) = ↑k * ↑(mersenne (p' + 2)) * ω ^ 2 ^ p' - 1
[PROOFSTEP]
dsimp at h
[GOAL]
case h
p' : ℕ
k : ℤ
h : ω ^ 2 ^ p' * (ω ^ 2 ^ p' + ωb ^ 2 ^ p') = ω ^ 2 ^ p' * ↑((2 ^ (p' + 2) - 1) * k)
⊢ ω ^ 2 ^ (p' + 1) = ↑k * ↑(mersenne (p' + 2)) * ω ^ 2 ^ p' - 1
[PROOFSTEP]
have t : 2 ^ p' + 2 ^ p' = 2 ^ (p' + 1) := by ring
[GOAL]
p' : ℕ
k : ℤ
h : ω ^ 2 ^ p' * (ω ^ 2 ^ p' + ωb ^ 2 ^ p') = ω ^ 2 ^ p' * ↑((2 ^ (p' + 2) - 1) * k)
⊢ 2 ^ p' + 2 ^ p' = 2 ^ (p' + 1)
[PROOFSTEP]
ring
[GOAL]
case h
p' : ℕ
k : ℤ
h : ω ^ 2 ^ p' * (ω ^ 2 ^ p' + ωb ^ 2 ^ p') = ω ^ 2 ^ p' * ↑((2 ^ (p' + 2) - 1) * k)
t : 2 ^ p' + 2 ^ p' = 2 ^ (p' + 1)
⊢ ω ^ 2 ^ (p' + 1) = ↑k * ↑(mersenne (p' + 2)) * ω ^ 2 ^ p' - 1
[PROOFSTEP]
rw [mul_add, ← pow_add ω, t, ← mul_pow ω ωb (2 ^ p'), ω_mul_ωb, one_pow] at h
[GOAL]
case h
p' : ℕ
k : ℤ
h : ω ^ 2 ^ (p' + 1) + 1 = ω ^ 2 ^ p' * ↑((2 ^ (p' + 2) - 1) * k)
t : 2 ^ p' + 2 ^ p' = 2 ^ (p' + 1)
⊢ ω ^ 2 ^ (p' + 1) = ↑k * ↑(mersenne (p' + 2)) * ω ^ 2 ^ p' - 1
[PROOFSTEP]
rw [mul_comm, coe_mul] at h
[GOAL]
case h
p' : ℕ
k : ℤ
h : ω ^ 2 ^ (p' + 1) + 1 = ↑(2 ^ (p' + 2) - 1) * ↑k * ω ^ 2 ^ p'
t : 2 ^ p' + 2 ^ p' = 2 ^ (p' + 1)
⊢ ω ^ 2 ^ (p' + 1) = ↑k * ↑(mersenne (p' + 2)) * ω ^ 2 ^ p' - 1
[PROOFSTEP]
rw [mul_comm _ (k : X (q (p' + 2)))] at h
[GOAL]
case h
p' : ℕ
k : ℤ
h : ω ^ 2 ^ (p' + 1) + 1 = ↑k * ↑(2 ^ (p' + 2) - 1) * ω ^ 2 ^ p'
t : 2 ^ p' + 2 ^ p' = 2 ^ (p' + 1)
⊢ ω ^ 2 ^ (p' + 1) = ↑k * ↑(mersenne (p' + 2)) * ω ^ 2 ^ p' - 1
[PROOFSTEP]
replace h := eq_sub_of_add_eq h
[GOAL]
case h
p' : ℕ
k : ℤ
t : 2 ^ p' + 2 ^ p' = 2 ^ (p' + 1)
h : ω ^ 2 ^ (p' + 1) = ↑k * ↑(2 ^ (p' + 2) - 1) * ω ^ 2 ^ p' - 1
⊢ ω ^ 2 ^ (p' + 1) = ↑k * ↑(mersenne (p' + 2)) * ω ^ 2 ^ p' - 1
[PROOFSTEP]
have : 1 ≤ 2 ^ (p' + 2) := Nat.one_le_pow _ _ (by decide)
[GOAL]
p' : ℕ
k : ℤ
t : 2 ^ p' + 2 ^ p' = 2 ^ (p' + 1)
h : ω ^ 2 ^ (p' + 1) = ↑k * ↑(2 ^ (p' + 2) - 1) * ω ^ 2 ^ p' - 1
⊢ 0 < 2
[PROOFSTEP]
decide
[GOAL]
case h
p' : ℕ
k : ℤ
t : 2 ^ p' + 2 ^ p' = 2 ^ (p' + 1)
h : ω ^ 2 ^ (p' + 1) = ↑k * ↑(2 ^ (p' + 2) - 1) * ω ^ 2 ^ p' - 1
this : 1 ≤ 2 ^ (p' + 2)
⊢ ω ^ 2 ^ (p' + 1) = ↑k * ↑(mersenne (p' + 2)) * ω ^ 2 ^ p' - 1
[PROOFSTEP]
exact_mod_cast h
[GOAL]
p : ℕ
⊢ ↑(mersenne p) = 0
[PROOFSTEP]
ext
[GOAL]
case h₁
p : ℕ
⊢ (↑(mersenne p)).fst = 0.fst
[PROOFSTEP]
simp [mersenne, q, ZMod.nat_cast_zmod_eq_zero_iff_dvd, -pow_pos]
[GOAL]
case h₂
p : ℕ
⊢ (↑(mersenne p)).snd = 0.snd
[PROOFSTEP]
simp [mersenne, q, ZMod.nat_cast_zmod_eq_zero_iff_dvd, -pow_pos]
[GOAL]
case h₁
p : ℕ
⊢ minFac (2 ^ p - 1) ∣ 2 ^ p - 1
[PROOFSTEP]
apply Nat.minFac_dvd
[GOAL]
p' : ℕ
h : lucasLehmerResidue (p' + 2) = 0
⊢ ω ^ 2 ^ (p' + 1) = -1
[PROOFSTEP]
cases' ω_pow_formula p' h with k w
[GOAL]
case intro
p' : ℕ
h : lucasLehmerResidue (p' + 2) = 0
k : ℤ
w : ω ^ 2 ^ (p' + 1) = ↑k * ↑(mersenne (p' + 2)) * ω ^ 2 ^ p' - 1
⊢ ω ^ 2 ^ (p' + 1) = -1
[PROOFSTEP]
rw [mersenne_coe_X] at w
[GOAL]
case intro
p' : ℕ
h : lucasLehmerResidue (p' + 2) = 0
k : ℤ
w : ω ^ 2 ^ (p' + 1) = ↑k * 0 * ω ^ 2 ^ p' - 1
⊢ ω ^ 2 ^ (p' + 1) = -1
[PROOFSTEP]
simpa using w
[GOAL]
p' : ℕ
h : lucasLehmerResidue (p' + 2) = 0
⊢ ω ^ 2 ^ (p' + 2) = (ω ^ 2 ^ (p' + 1)) ^ 2
[PROOFSTEP]
rw [← pow_mul, ← Nat.pow_succ]
[GOAL]
p' : ℕ
h : lucasLehmerResidue (p' + 2) = 0
⊢ (ω ^ 2 ^ (p' + 1)) ^ 2 = (-1) ^ 2
[PROOFSTEP]
rw [ω_pow_eq_neg_one p' h]
[GOAL]
p' : ℕ
h : lucasLehmerResidue (p' + 2) = 0
⊢ (-1) ^ 2 = 1
[PROOFSTEP]
simp
[GOAL]
p' : ℕ
h : lucasLehmerResidue (p' + 2) = 0
⊢ orderOf (ωUnit (p' + 2)) = 2 ^ (p' + 2)
[PROOFSTEP]
apply Nat.eq_prime_pow_of_dvd_least_prime_pow
[GOAL]
case pp
p' : ℕ
h : lucasLehmerResidue (p' + 2) = 0
⊢ Nat.Prime 2
[PROOFSTEP]
exact Nat.prime_two
[GOAL]
case h₁
p' : ℕ
h : lucasLehmerResidue (p' + 2) = 0
⊢ ¬orderOf (ωUnit (p' + 2)) ∣ 2 ^ (p' + 1)
[PROOFSTEP]
intro o
[GOAL]
case h₁
p' : ℕ
h : lucasLehmerResidue (p' + 2) = 0
o : orderOf (ωUnit (p' + 2)) ∣ 2 ^ (p' + 1)
⊢ False
[PROOFSTEP]
have ω_pow := orderOf_dvd_iff_pow_eq_one.1 o
[GOAL]
case h₁
p' : ℕ
h : lucasLehmerResidue (p' + 2) = 0
o : orderOf (ωUnit (p' + 2)) ∣ 2 ^ (p' + 1)
ω_pow : ωUnit (p' + 2) ^ 2 ^ (p' + 1) = 1
⊢ False
[PROOFSTEP]
replace ω_pow := congr_arg (Units.coeHom (X (q (p' + 2))) : Units (X (q (p' + 2))) → X (q (p' + 2))) ω_pow
[GOAL]
case h₁
p' : ℕ
h : lucasLehmerResidue (p' + 2) = 0
o : orderOf (ωUnit (p' + 2)) ∣ 2 ^ (p' + 1)
ω_pow : ↑(Units.coeHom (X (q (p' + 2)))) (ωUnit (p' + 2) ^ 2 ^ (p' + 1)) = ↑(Units.coeHom (X (q (p' + 2)))) 1
⊢ False
[PROOFSTEP]
simp at ω_pow
[GOAL]
case h₁
p' : ℕ
h : lucasLehmerResidue (p' + 2) = 0
o : orderOf (ωUnit (p' + 2)) ∣ 2 ^ (p' + 1)
ω_pow : ω ^ 2 ^ (p' + 1) = 1
⊢ False
[PROOFSTEP]
have h : (1 : ZMod (q (p' + 2))) = -1 := congr_arg Prod.fst (ω_pow.symm.trans (ω_pow_eq_neg_one p' h))
[GOAL]
case h₁
p' : ℕ
h✝ : lucasLehmerResidue (p' + 2) = 0
o : orderOf (ωUnit (p' + 2)) ∣ 2 ^ (p' + 1)
ω_pow : ω ^ 2 ^ (p' + 1) = 1
h : 1 = -1
⊢ False
[PROOFSTEP]
haveI : Fact (2 < (q (p' + 2) : ℕ)) := ⟨two_lt_q _⟩
[GOAL]
case h₁
p' : ℕ
h✝ : lucasLehmerResidue (p' + 2) = 0
o : orderOf (ωUnit (p' + 2)) ∣ 2 ^ (p' + 1)
ω_pow : ω ^ 2 ^ (p' + 1) = 1
h : 1 = -1
this : Fact (2 < ↑(q (p' + 2)))
⊢ False
[PROOFSTEP]
apply ZMod.neg_one_ne_one h.symm
[GOAL]
case h₂
p' : ℕ
h : lucasLehmerResidue (p' + 2) = 0
⊢ orderOf (ωUnit (p' + 2)) ∣ 2 ^ (p' + 1 + 1)
[PROOFSTEP]
apply orderOf_dvd_iff_pow_eq_one.2
[GOAL]
case h₂
p' : ℕ
h : lucasLehmerResidue (p' + 2) = 0
⊢ ωUnit (p' + 2) ^ 2 ^ (p' + 1 + 1) = 1
[PROOFSTEP]
apply Units.ext
[GOAL]
case h₂.a
p' : ℕ
h : lucasLehmerResidue (p' + 2) = 0
⊢ ↑(ωUnit (p' + 2) ^ 2 ^ (p' + 1 + 1)) = ↑1
[PROOFSTEP]
push_cast
[GOAL]
case h₂.a
p' : ℕ
h : lucasLehmerResidue (p' + 2) = 0
⊢ ↑(ωUnit (p' + 2)) ^ 2 ^ (p' + 1 + 1) = 1
[PROOFSTEP]
exact ω_pow_eq_one p' h
[GOAL]
p : ℕ
w : 1 < p
⊢ LucasLehmerTest p → Nat.Prime (mersenne p)
[PROOFSTEP]
let p' := p - 2
[GOAL]
p : ℕ
w : 1 < p
p' : ℕ := p - 2
⊢ LucasLehmerTest p → Nat.Prime (mersenne p)
[PROOFSTEP]
have z : p = p' + 2 := (tsub_eq_iff_eq_add_of_le w.nat_succ_le).mp rfl
[GOAL]
p : ℕ
w : 1 < p
p' : ℕ := p - 2
z : p = p' + 2
⊢ LucasLehmerTest p → Nat.Prime (mersenne p)
[PROOFSTEP]
have w : 1 < p' + 2 := Nat.lt_of_sub_eq_succ rfl
[GOAL]
p : ℕ
w✝ : 1 < p
p' : ℕ := p - 2
z : p = p' + 2
w : 1 < p' + 2
⊢ LucasLehmerTest p → Nat.Prime (mersenne p)
[PROOFSTEP]
contrapose
[GOAL]
p : ℕ
w✝ : 1 < p
p' : ℕ := p - 2
z : p = p' + 2
w : 1 < p' + 2
⊢ ¬Nat.Prime (mersenne p) → ¬LucasLehmerTest p
[PROOFSTEP]
intro a t
[GOAL]
p : ℕ
w✝ : 1 < p
p' : ℕ := p - 2
z : p = p' + 2
w : 1 < p' + 2
a : ¬Nat.Prime (mersenne p)
t : LucasLehmerTest p
⊢ False
[PROOFSTEP]
rw [z] at a
[GOAL]
p : ℕ
w✝ : 1 < p
p' : ℕ := p - 2
z : p = p' + 2
w : 1 < p' + 2
a : ¬Nat.Prime (mersenne (p' + 2))
t : LucasLehmerTest p
⊢ False
[PROOFSTEP]
rw [z] at t
[GOAL]
p : ℕ
w✝ : 1 < p
p' : ℕ := p - 2
z : p = p' + 2
w : 1 < p' + 2
a : ¬Nat.Prime (mersenne (p' + 2))
t : LucasLehmerTest (p' + 2)
⊢ False
[PROOFSTEP]
have h₁ := order_ineq p' t
[GOAL]
p : ℕ
w✝ : 1 < p
p' : ℕ := p - 2
z : p = p' + 2
w : 1 < p' + 2
a : ¬Nat.Prime (mersenne (p' + 2))
t : LucasLehmerTest (p' + 2)
h₁ : 2 ^ (p' + 2) < ↑(q (p' + 2)) ^ 2
⊢ False
[PROOFSTEP]
have h₂ := Nat.minFac_sq_le_self (mersenne_pos (Nat.lt_of_succ_lt w)) a
[GOAL]
p : ℕ
w✝ : 1 < p
p' : ℕ := p - 2
z : p = p' + 2
w : 1 < p' + 2
a : ¬Nat.Prime (mersenne (p' + 2))
t : LucasLehmerTest (p' + 2)
h₁ : 2 ^ (p' + 2) < ↑(q (p' + 2)) ^ 2
h₂ : Nat.minFac (mersenne (p' + 2)) ^ 2 ≤ mersenne (p' + 2)
⊢ False
[PROOFSTEP]
have h := lt_of_lt_of_le h₁ h₂
[GOAL]
p : ℕ
w✝ : 1 < p
p' : ℕ := p - 2
z : p = p' + 2
w : 1 < p' + 2
a : ¬Nat.Prime (mersenne (p' + 2))
t : LucasLehmerTest (p' + 2)
h₁ : 2 ^ (p' + 2) < ↑(q (p' + 2)) ^ 2
h₂ : Nat.minFac (mersenne (p' + 2)) ^ 2 ≤ mersenne (p' + 2)
h : 2 ^ (p' + 2) < mersenne (p' + 2)
⊢ False
[PROOFSTEP]
exact not_lt_of_ge (Nat.sub_le _ _) h
[GOAL]
p k : ℕ
hp : 2 ≤ p
⊢ ↑(sMod' (2 ^ p - 1) k) = sMod p k
[PROOFSTEP]
have h1 :=
  calc
    4 = 2 ^ 2 := by norm_num
    _ ≤ 2 ^ p := Nat.pow_le_pow_of_le_right (by norm_num) hp
[GOAL]
p k : ℕ
hp : 2 ≤ p
⊢ 4 = 2 ^ 2
[PROOFSTEP]
norm_num
[GOAL]
p k : ℕ
hp : 2 ≤ p
⊢ 2 > 0
[PROOFSTEP]
norm_num
[GOAL]
p k : ℕ
hp : 2 ≤ p
h1 : 4 ≤ 2 ^ p
⊢ ↑(sMod' (2 ^ p - 1) k) = sMod p k
[PROOFSTEP]
have h2 : 1 ≤ 2 ^ p := by linarith
[GOAL]
p k : ℕ
hp : 2 ≤ p
h1 : 4 ≤ 2 ^ p
⊢ 1 ≤ 2 ^ p
[PROOFSTEP]
linarith
[GOAL]
p k : ℕ
hp : 2 ≤ p
h1 : 4 ≤ 2 ^ p
h2 : 1 ≤ 2 ^ p
⊢ ↑(sMod' (2 ^ p - 1) k) = sMod p k
[PROOFSTEP]
induction k with
| zero =>
  rw [sMod', sMod, Int.ofNat_emod]
  simp [h2]
| succ k ih =>
  rw [sMod', sMod, ← ih]
  have h3 : 2 ≤ 2 ^ p - 1 := by
    zify [h2]
    calc
      (2 : Int) ≤ 4 - 1 := by norm_num
      _ ≤ 2 ^ p - 1 := by zify at h1 ; exact Int.sub_le_sub_right h1 _
  zify [h2, h3]
  rw [← add_sub_assoc, sub_eq_add_neg, add_assoc, add_comm _ (-2), ← add_assoc, Int.add_emod_self, ← sub_eq_add_neg]
[GOAL]
p k : ℕ
hp : 2 ≤ p
h1 : 4 ≤ 2 ^ p
h2 : 1 ≤ 2 ^ p
⊢ ↑(sMod' (2 ^ p - 1) k) = sMod p k
[PROOFSTEP]
induction k with
| zero =>
  rw [sMod', sMod, Int.ofNat_emod]
  simp [h2]
| succ k ih =>
  rw [sMod', sMod, ← ih]
  have h3 : 2 ≤ 2 ^ p - 1 := by
    zify [h2]
    calc
      (2 : Int) ≤ 4 - 1 := by norm_num
      _ ≤ 2 ^ p - 1 := by zify at h1 ; exact Int.sub_le_sub_right h1 _
  zify [h2, h3]
  rw [← add_sub_assoc, sub_eq_add_neg, add_assoc, add_comm _ (-2), ← add_assoc, Int.add_emod_self, ← sub_eq_add_neg]
[GOAL]
case zero
p : ℕ
hp : 2 ≤ p
h1 : 4 ≤ 2 ^ p
h2 : 1 ≤ 2 ^ p
⊢ ↑(sMod' (2 ^ p - 1) Nat.zero) = sMod p Nat.zero
[PROOFSTEP]

| zero =>
  rw [sMod', sMod, Int.ofNat_emod]
  simp [h2]
[GOAL]
case zero
p : ℕ
hp : 2 ≤ p
h1 : 4 ≤ 2 ^ p
h2 : 1 ≤ 2 ^ p
⊢ ↑(sMod' (2 ^ p - 1) Nat.zero) = sMod p Nat.zero
[PROOFSTEP]
rw [sMod', sMod, Int.ofNat_emod]
[GOAL]
case zero
p : ℕ
hp : 2 ≤ p
h1 : 4 ≤ 2 ^ p
h2 : 1 ≤ 2 ^ p
⊢ ↑4 % ↑(2 ^ p - 1) = 4 % (2 ^ p - 1)
[PROOFSTEP]
simp [h2]
[GOAL]
case succ
p : ℕ
hp : 2 ≤ p
h1 : 4 ≤ 2 ^ p
h2 : 1 ≤ 2 ^ p
k : ℕ
ih : ↑(sMod' (2 ^ p - 1) k) = sMod p k
⊢ ↑(sMod' (2 ^ p - 1) (Nat.succ k)) = sMod p (Nat.succ k)
[PROOFSTEP]

| succ k ih =>
  rw [sMod', sMod, ← ih]
  have h3 : 2 ≤ 2 ^ p - 1 := by
    zify [h2]
    calc
      (2 : Int) ≤ 4 - 1 := by norm_num
      _ ≤ 2 ^ p - 1 := by zify at h1 ; exact Int.sub_le_sub_right h1 _
  zify [h2, h3]
  rw [← add_sub_assoc, sub_eq_add_neg, add_assoc, add_comm _ (-2), ← add_assoc, Int.add_emod_self, ← sub_eq_add_neg]
[GOAL]
case succ
p : ℕ
hp : 2 ≤ p
h1 : 4 ≤ 2 ^ p
h2 : 1 ≤ 2 ^ p
k : ℕ
ih : ↑(sMod' (2 ^ p - 1) k) = sMod p k
⊢ ↑(sMod' (2 ^ p - 1) (Nat.succ k)) = sMod p (Nat.succ k)
[PROOFSTEP]
rw [sMod', sMod, ← ih]
[GOAL]
case succ
p : ℕ
hp : 2 ≤ p
h1 : 4 ≤ 2 ^ p
h2 : 1 ≤ 2 ^ p
k : ℕ
ih : ↑(sMod' (2 ^ p - 1) k) = sMod p k
⊢ ↑((sMod' (2 ^ p - 1) k ^ 2 + (2 ^ p - 1 - 2)) % (2 ^ p - 1)) = (↑(sMod' (2 ^ p - 1) k) ^ 2 - 2) % (2 ^ p - 1)
[PROOFSTEP]
have h3 : 2 ≤ 2 ^ p - 1 := by
  zify [h2]
  calc
    (2 : Int) ≤ 4 - 1 := by norm_num
    _ ≤ 2 ^ p - 1 := by zify at h1 ; exact Int.sub_le_sub_right h1 _
[GOAL]
p : ℕ
hp : 2 ≤ p
h1 : 4 ≤ 2 ^ p
h2 : 1 ≤ 2 ^ p
k : ℕ
ih : ↑(sMod' (2 ^ p - 1) k) = sMod p k
⊢ 2 ≤ 2 ^ p - 1
[PROOFSTEP]
zify [h2]
[GOAL]
p : ℕ
hp : 2 ≤ p
h1 : 4 ≤ 2 ^ p
h2 : 1 ≤ 2 ^ p
k : ℕ
ih : ↑(sMod' (2 ^ p - 1) k) = sMod p k
⊢ 2 ≤ 2 ^ p - 1
[PROOFSTEP]
calc
  (2 : Int) ≤ 4 - 1 := by norm_num
  _ ≤ 2 ^ p - 1 := by zify at h1 ; exact Int.sub_le_sub_right h1 _
[GOAL]
p : ℕ
hp : 2 ≤ p
h1 : 4 ≤ 2 ^ p
h2 : 1 ≤ 2 ^ p
k : ℕ
ih : ↑(sMod' (2 ^ p - 1) k) = sMod p k
⊢ 2 ≤ 4 - 1
[PROOFSTEP]
norm_num
[GOAL]
p : ℕ
hp : 2 ≤ p
h1 : 4 ≤ 2 ^ p
h2 : 1 ≤ 2 ^ p
k : ℕ
ih : ↑(sMod' (2 ^ p - 1) k) = sMod p k
⊢ 4 - 1 ≤ 2 ^ p - 1
[PROOFSTEP]
zify at h1
[GOAL]
p : ℕ
hp : 2 ≤ p
h2 : 1 ≤ 2 ^ p
k : ℕ
ih : ↑(sMod' (2 ^ p - 1) k) = sMod p k
h1 : 4 ≤ 2 ^ p
⊢ 4 - 1 ≤ 2 ^ p - 1
[PROOFSTEP]
exact Int.sub_le_sub_right h1 _
[GOAL]
case succ
p : ℕ
hp : 2 ≤ p
h1 : 4 ≤ 2 ^ p
h2 : 1 ≤ 2 ^ p
k : ℕ
ih : ↑(sMod' (2 ^ p - 1) k) = sMod p k
h3 : 2 ≤ 2 ^ p - 1
⊢ ↑((sMod' (2 ^ p - 1) k ^ 2 + (2 ^ p - 1 - 2)) % (2 ^ p - 1)) = (↑(sMod' (2 ^ p - 1) k) ^ 2 - 2) % (2 ^ p - 1)
[PROOFSTEP]
zify [h2, h3]
[GOAL]
case succ
p : ℕ
hp : 2 ≤ p
h1 : 4 ≤ 2 ^ p
h2 : 1 ≤ 2 ^ p
k : ℕ
ih : ↑(sMod' (2 ^ p - 1) k) = sMod p k
h3 : 2 ≤ 2 ^ p - 1
⊢ (↑(sMod' (2 ^ p - 1) k) ^ 2 + (2 ^ p - 1 - 2)) % (2 ^ p - 1) = (↑(sMod' (2 ^ p - 1) k) ^ 2 - 2) % (2 ^ p - 1)
[PROOFSTEP]
rw [← add_sub_assoc, sub_eq_add_neg, add_assoc, add_comm _ (-2), ← add_assoc, Int.add_emod_self, ← sub_eq_add_neg]
[GOAL]
p : ℕ
hp : Nat.blt 1 p = true
h : sMod' (2 ^ p - 1) (p - 2) = 0
⊢ LucasLehmerTest p
[PROOFSTEP]
rw [Nat.blt_eq] at hp
[GOAL]
p : ℕ
hp : 1 < p
h : sMod' (2 ^ p - 1) (p - 2) = 0
⊢ LucasLehmerTest p
[PROOFSTEP]
rw [LucasLehmerTest, LucasLehmer.residue_eq_zero_iff_sMod_eq_zero p hp, ← sMod'_eq_sMod p _ hp, h]
[GOAL]
p : ℕ
hp : 1 < p
h : sMod' (2 ^ p - 1) (p - 2) = 0
⊢ ↑0 = 0
[PROOFSTEP]
rfl
[GOAL]
p : ℕ
hp : Nat.blt 1 p = true
h : Nat.ble 1 (sMod' (2 ^ p - 1) (p - 2)) = true
⊢ ¬LucasLehmerTest p
[PROOFSTEP]
rw [Nat.blt_eq] at hp
[GOAL]
p : ℕ
hp : 1 < p
h : Nat.ble 1 (sMod' (2 ^ p - 1) (p - 2)) = true
⊢ ¬LucasLehmerTest p
[PROOFSTEP]
rw [Nat.ble_eq, Nat.succ_le, Nat.pos_iff_ne_zero] at h
[GOAL]
p : ℕ
hp : 1 < p
h : sMod' (2 ^ p - 1) (p - 2) ≠ 0
⊢ ¬LucasLehmerTest p
[PROOFSTEP]
rw [LucasLehmerTest, LucasLehmer.residue_eq_zero_iff_sMod_eq_zero p hp, ← sMod'_eq_sMod p _ hp]
[GOAL]
p : ℕ
hp : 1 < p
h : sMod' (2 ^ p - 1) (p - 2) ≠ 0
⊢ ¬↑(sMod' (2 ^ p - 1) (p - 2)) = 0
[PROOFSTEP]
simpa using h
[GOAL]
n k : ℕ
⊢ 1 * (k / 2 ^ n) + k % 2 ^ n = k / 2 ^ n + k % 2 ^ n
[PROOFSTEP]
rw [one_mul]


[GOAL]
L : Language
M : Type u_1
s : Setoid M
ps : Prestructure L s
n : ℕ
f : Functions L n
x : Fin n → M
⊢ (funMap f fun i => Quotient.mk s (x i)) = Quotient.mk s (funMap f x)
[PROOFSTEP]
change Quotient.map (@funMap L M ps.toStructure n f) Prestructure.fun_equiv (Quotient.finChoice _) = _
[GOAL]
L : Language
M : Type u_1
s : Setoid M
ps : Prestructure L s
n : ℕ
f : Functions L n
x : Fin n → M
⊢ Quotient.map (funMap f) (_ : ∀ (x y : Fin n → M), x ≈ y → funMap f x ≈ funMap f y)
      (Quotient.finChoice fun i => Quotient.mk s (x i)) =
    Quotient.mk s (funMap f x)
[PROOFSTEP]
rw [Quotient.finChoice_eq, Quotient.map_mk]
[GOAL]
L : Language
M : Type u_1
s : Setoid M
ps : Prestructure L s
n : ℕ
r : Relations L n
x : Fin n → M
⊢ (RelMap r fun i => Quotient.mk s (x i)) ↔ RelMap r x
[PROOFSTEP]
change Quotient.lift (@RelMap L M ps.toStructure n r) Prestructure.rel_equiv (Quotient.finChoice _) ↔ _
[GOAL]
L : Language
M : Type u_1
s : Setoid M
ps : Prestructure L s
n : ℕ
r : Relations L n
x : Fin n → M
⊢ Quotient.lift (RelMap r) (_ : ∀ (x y : Fin n → M), x ≈ y → RelMap r x = RelMap r y)
      (Quotient.finChoice fun i => Quotient.mk s (x i)) ↔
    RelMap r x
[PROOFSTEP]
rw [Quotient.finChoice_eq, Quotient.lift_mk]
[GOAL]
L : Language
M : Type u_1
s : Setoid M
ps : Prestructure L s
β : Type u_2
t : Term L β
x : β → M
⊢ realize (fun i => Quotient.mk s (x i)) t = Quotient.mk s (realize x t)
[PROOFSTEP]
induction' t with _ _ _ _ ih
[GOAL]
case var
L : Language
M : Type u_1
s : Setoid M
ps : Prestructure L s
β : Type u_2
x : β → M
_a✝ : β
⊢ realize (fun i => Quotient.mk s (x i)) (var _a✝) = Quotient.mk s (realize x (var _a✝))
[PROOFSTEP]
rfl
[GOAL]
case func
L : Language
M : Type u_1
s : Setoid M
ps : Prestructure L s
β : Type u_2
x : β → M
l✝ : ℕ
_f✝ : Functions L l✝
_ts✝ : Fin l✝ → Term L β
ih : ∀ (a : Fin l✝), realize (fun i => Quotient.mk s (x i)) (_ts✝ a) = Quotient.mk s (realize x (_ts✝ a))
⊢ realize (fun i => Quotient.mk s (x i)) (func _f✝ _ts✝) = Quotient.mk s (realize x (func _f✝ _ts✝))
[PROOFSTEP]
simp only [ih, funMap_quotient_mk', Term.realize]


[GOAL]
t : ℝ
⊢ t ∈ I ↔ 1 - t ∈ I
[PROOFSTEP]
rw [mem_Icc, mem_Icc]
[GOAL]
t : ℝ
⊢ 0 ≤ t ∧ t ≤ 1 ↔ 0 ≤ 1 - t ∧ 1 - t ≤ 1
[PROOFSTEP]
constructor
[GOAL]
case mp
t : ℝ
⊢ 0 ≤ t ∧ t ≤ 1 → 0 ≤ 1 - t ∧ 1 - t ≤ 1
[PROOFSTEP]
intro
[GOAL]
case mpr
t : ℝ
⊢ 0 ≤ 1 - t ∧ 1 - t ≤ 1 → 0 ≤ t ∧ t ≤ 1
[PROOFSTEP]
intro
[GOAL]
case mp
t : ℝ
a✝ : 0 ≤ t ∧ t ≤ 1
⊢ 0 ≤ 1 - t ∧ 1 - t ≤ 1
[PROOFSTEP]
constructor
[GOAL]
case mpr
t : ℝ
a✝ : 0 ≤ 1 - t ∧ 1 - t ≤ 1
⊢ 0 ≤ t ∧ t ≤ 1
[PROOFSTEP]
constructor
[GOAL]
case mp.left
t : ℝ
a✝ : 0 ≤ t ∧ t ≤ 1
⊢ 0 ≤ 1 - t
[PROOFSTEP]
linarith
[GOAL]
case mp.right
t : ℝ
a✝ : 0 ≤ t ∧ t ≤ 1
⊢ 1 - t ≤ 1
[PROOFSTEP]
linarith
[GOAL]
case mpr.left
t : ℝ
a✝ : 0 ≤ 1 - t ∧ 1 - t ≤ 1
⊢ 0 ≤ t
[PROOFSTEP]
linarith
[GOAL]
case mpr.right
t : ℝ
a✝ : 0 ≤ 1 - t ∧ 1 - t ≤ 1
⊢ t ≤ 1
[PROOFSTEP]
linarith
[GOAL]
⊢ 1 ∈ I
[PROOFSTEP]
constructor
[GOAL]
case left
⊢ 0 ≤ 1
[PROOFSTEP]
norm_num
[GOAL]
case right
⊢ 1 ≤ 1
[PROOFSTEP]
norm_num
[GOAL]
⊢ ↑(σ 0) = ↑1
[PROOFSTEP]
simp [symm]
[GOAL]
⊢ ↑(σ 1) = ↑0
[PROOFSTEP]
simp [symm]
[GOAL]
x : ↑I
⊢ ↑(σ (σ x)) = ↑x
[PROOFSTEP]
simp [symm]
[GOAL]
⊢ CompactSpace ↑I
[PROOFSTEP]
infer_instance
[GOAL]
x : ↑I
⊢ 0 ≤ 1 - ↑x
[PROOFSTEP]
simpa using x.2.2
[GOAL]
x : ↑I
⊢ 1 - ↑x ≤ 1
[PROOFSTEP]
simpa using x.2.1
[GOAL]
a t : ℝ
ha : 0 < a
⊢ a * t ∈ I ↔ t ∈ Icc 0 (1 / a)
[PROOFSTEP]
constructor
[GOAL]
case mp
a t : ℝ
ha : 0 < a
⊢ a * t ∈ I → t ∈ Icc 0 (1 / a)
[PROOFSTEP]
rintro ⟨h₁, h₂⟩
[GOAL]
case mpr
a t : ℝ
ha : 0 < a
⊢ t ∈ Icc 0 (1 / a) → a * t ∈ I
[PROOFSTEP]
rintro ⟨h₁, h₂⟩
[GOAL]
case mp.intro
a t : ℝ
ha : 0 < a
h₁ : 0 ≤ a * t
h₂ : a * t ≤ 1
⊢ t ∈ Icc 0 (1 / a)
[PROOFSTEP]
constructor
[GOAL]
case mpr.intro
a t : ℝ
ha : 0 < a
h₁ : 0 ≤ t
h₂ : t ≤ 1 / a
⊢ a * t ∈ I
[PROOFSTEP]
constructor
[GOAL]
case mp.intro.left
a t : ℝ
ha : 0 < a
h₁ : 0 ≤ a * t
h₂ : a * t ≤ 1
⊢ 0 ≤ t
[PROOFSTEP]
exact nonneg_of_mul_nonneg_right h₁ ha
[GOAL]
case mp.intro.right
a t : ℝ
ha : 0 < a
h₁ : 0 ≤ a * t
h₂ : a * t ≤ 1
⊢ t ≤ 1 / a
[PROOFSTEP]
rwa [le_div_iff ha, mul_comm]
[GOAL]
case mpr.intro.left
a t : ℝ
ha : 0 < a
h₁ : 0 ≤ t
h₂ : t ≤ 1 / a
⊢ 0 ≤ a * t
[PROOFSTEP]
exact mul_nonneg ha.le h₁
[GOAL]
case mpr.intro.right
a t : ℝ
ha : 0 < a
h₁ : 0 ≤ t
h₂ : t ≤ 1 / a
⊢ a * t ≤ 1
[PROOFSTEP]
rwa [le_div_iff ha, mul_comm] at h₂
[GOAL]
t : ℝ
⊢ 2 * t - 1 ∈ I ↔ t ∈ Icc (1 / 2) 1
[PROOFSTEP]
constructor
[GOAL]
case mp
t : ℝ
⊢ 2 * t - 1 ∈ I → t ∈ Icc (1 / 2) 1
[PROOFSTEP]
rintro ⟨h₁, h₂⟩
[GOAL]
case mpr
t : ℝ
⊢ t ∈ Icc (1 / 2) 1 → 2 * t - 1 ∈ I
[PROOFSTEP]
rintro ⟨h₁, h₂⟩
[GOAL]
case mp.intro
t : ℝ
h₁ : 0 ≤ 2 * t - 1
h₂ : 2 * t - 1 ≤ 1
⊢ t ∈ Icc (1 / 2) 1
[PROOFSTEP]
constructor
[GOAL]
case mpr.intro
t : ℝ
h₁ : 1 / 2 ≤ t
h₂ : t ≤ 1
⊢ 2 * t - 1 ∈ I
[PROOFSTEP]
constructor
[GOAL]
case mp.intro.left
t : ℝ
h₁ : 0 ≤ 2 * t - 1
h₂ : 2 * t - 1 ≤ 1
⊢ 1 / 2 ≤ t
[PROOFSTEP]
linarith
[GOAL]
case mp.intro.right
t : ℝ
h₁ : 0 ≤ 2 * t - 1
h₂ : 2 * t - 1 ≤ 1
⊢ t ≤ 1
[PROOFSTEP]
linarith
[GOAL]
case mpr.intro.left
t : ℝ
h₁ : 1 / 2 ≤ t
h₂ : t ≤ 1
⊢ 0 ≤ 2 * t - 1
[PROOFSTEP]
linarith
[GOAL]
case mpr.intro.right
t : ℝ
h₁ : 1 / 2 ≤ t
h₂ : t ≤ 1
⊢ 2 * t - 1 ≤ 1
[PROOFSTEP]
linarith
[GOAL]
x : ↑unitInterval
⊢ 0 ≤ ↑x
[PROOFSTEP]
unit_interval
[GOAL]
𝕜 : Type u_1
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : TopologicalRing 𝕜
a b : 𝕜
h : 0 < a
⊢ ↑(affineHomeomorph a b (_ : a ≠ 0)) '' Icc 0 1 = Icc b (a + b)
[PROOFSTEP]
simp [h]
[GOAL]
𝕜 : Type u_1
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : TopologicalRing 𝕜
a b : 𝕜
h : a < b
⊢ ↑(Icc a b) ≃ₜ ↑(Icc 0 1)
[PROOFSTEP]
let e := Homeomorph.image (affineHomeomorph (b - a) a (sub_pos.mpr h).ne.symm) (Set.Icc 0 1)
[GOAL]
𝕜 : Type u_1
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : TopologicalRing 𝕜
a b : 𝕜
h : a < b
e : ↑(Icc 0 1) ≃ₜ ↑(↑(affineHomeomorph (b - a) a (_ : b - a ≠ 0)) '' Icc 0 1) :=
  Homeomorph.image (affineHomeomorph (b - a) a (_ : b - a ≠ 0)) (Icc 0 1)
⊢ ↑(Icc a b) ≃ₜ ↑(Icc 0 1)
[PROOFSTEP]
refine' (e.trans _).symm
[GOAL]
𝕜 : Type u_1
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : TopologicalRing 𝕜
a b : 𝕜
h : a < b
e : ↑(Icc 0 1) ≃ₜ ↑(↑(affineHomeomorph (b - a) a (_ : b - a ≠ 0)) '' Icc 0 1) :=
  Homeomorph.image (affineHomeomorph (b - a) a (_ : b - a ≠ 0)) (Icc 0 1)
⊢ ↑(↑(affineHomeomorph (b - a) a (_ : b - a ≠ 0)) '' Icc 0 1) ≃ₜ ↑(Icc a b)
[PROOFSTEP]
apply Homeomorph.setCongr
[GOAL]
case h
𝕜 : Type u_1
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : TopologicalRing 𝕜
a b : 𝕜
h : a < b
e : ↑(Icc 0 1) ≃ₜ ↑(↑(affineHomeomorph (b - a) a (_ : b - a ≠ 0)) '' Icc 0 1) :=
  Homeomorph.image (affineHomeomorph (b - a) a (_ : b - a ≠ 0)) (Icc 0 1)
⊢ ↑(affineHomeomorph (b - a) a (_ : b - a ≠ 0)) '' Icc 0 1 = Icc a b
[PROOFSTEP]
rw [affineHomeomorph_image_I _ _ (sub_pos.2 h)]
[GOAL]
case h
𝕜 : Type u_1
inst✝² : LinearOrderedField 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : TopologicalRing 𝕜
a b : 𝕜
h : a < b
e : ↑(Icc 0 1) ≃ₜ ↑(↑(affineHomeomorph (b - a) a (_ : b - a ≠ 0)) '' Icc 0 1) :=
  Homeomorph.image (affineHomeomorph (b - a) a (_ : b - a ≠ 0)) (Icc 0 1)
⊢ Icc a (b - a + a) = Icc a b
[PROOFSTEP]
simp