number_theory.zsqrtd.gaussian_int
⟷
Mathlib.NumberTheory.Zsqrtd.GaussianInt
The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(last sync)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -187,18 +187,18 @@ theorem toComplex_eq_zero {x : ℤ[i]} : (x : ℂ) = 0 ↔ x = 0 := by
#align gaussian_int.to_complex_eq_zero GaussianInt.toComplex_eq_zero
-/
-#print GaussianInt.int_cast_real_norm /-
+#print GaussianInt.intCast_real_norm /-
@[simp]
-theorem int_cast_real_norm (x : ℤ[i]) : (x.norm : ℝ) = (x : ℂ).normSq := by
+theorem intCast_real_norm (x : ℤ[i]) : (x.norm : ℝ) = (x : ℂ).normSq := by
rw [Zsqrtd.norm, norm_sq] <;> simp
-#align gaussian_int.nat_cast_real_norm GaussianInt.int_cast_real_norm
+#align gaussian_int.nat_cast_real_norm GaussianInt.intCast_real_norm
-/
-#print GaussianInt.int_cast_complex_norm /-
+#print GaussianInt.intCast_complex_norm /-
@[simp]
-theorem int_cast_complex_norm (x : ℤ[i]) : (x.norm : ℂ) = (x : ℂ).normSq := by
+theorem intCast_complex_norm (x : ℤ[i]) : (x.norm : ℂ) = (x : ℂ).normSq := by
cases x <;> rw [Zsqrtd.norm, norm_sq] <;> simp
-#align gaussian_int.nat_cast_complex_norm GaussianInt.int_cast_complex_norm
+#align gaussian_int.nat_cast_complex_norm GaussianInt.intCast_complex_norm
-/
#print GaussianInt.norm_nonneg /-
@@ -225,11 +225,11 @@ theorem abs_natCast_norm (x : ℤ[i]) : (x.norm.natAbs : ℤ) = x.norm :=
#align gaussian_int.abs_coe_nat_norm GaussianInt.abs_natCast_norm
-/
-#print GaussianInt.nat_cast_natAbs_norm /-
+#print GaussianInt.natCast_natAbs_norm /-
@[simp]
-theorem nat_cast_natAbs_norm {α : Type _} [Ring α] (x : ℤ[i]) : (x.norm.natAbs : α) = x.norm := by
+theorem natCast_natAbs_norm {α : Type _} [Ring α] (x : ℤ[i]) : (x.norm.natAbs : α) = x.norm := by
rw [← Int.cast_natCast, abs_coe_nat_norm]
-#align gaussian_int.nat_cast_nat_abs_norm GaussianInt.nat_cast_natAbs_norm
+#align gaussian_int.nat_cast_nat_abs_norm GaussianInt.natCast_natAbs_norm
-/
#print GaussianInt.natAbs_norm_eq /-
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -219,10 +219,10 @@ theorem norm_pos {x : ℤ[i]} : 0 < norm x ↔ x ≠ 0 := by
#align gaussian_int.norm_pos GaussianInt.norm_pos
-/
-#print GaussianInt.abs_coe_nat_norm /-
-theorem abs_coe_nat_norm (x : ℤ[i]) : (x.norm.natAbs : ℤ) = x.norm :=
+#print GaussianInt.abs_natCast_norm /-
+theorem abs_natCast_norm (x : ℤ[i]) : (x.norm.natAbs : ℤ) = x.norm :=
Int.natAbs_of_nonneg (norm_nonneg _)
-#align gaussian_int.abs_coe_nat_norm GaussianInt.abs_coe_nat_norm
+#align gaussian_int.abs_coe_nat_norm GaussianInt.abs_natCast_norm
-/
#print GaussianInt.nat_cast_natAbs_norm /-
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -228,7 +228,7 @@ theorem abs_coe_nat_norm (x : ℤ[i]) : (x.norm.natAbs : ℤ) = x.norm :=
#print GaussianInt.nat_cast_natAbs_norm /-
@[simp]
theorem nat_cast_natAbs_norm {α : Type _} [Ring α] (x : ℤ[i]) : (x.norm.natAbs : α) = x.norm := by
- rw [← Int.cast_ofNat, abs_coe_nat_norm]
+ rw [← Int.cast_natCast, abs_coe_nat_norm]
#align gaussian_int.nat_cast_nat_abs_norm GaussianInt.nat_cast_natAbs_norm
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -313,7 +313,7 @@ theorem norm_mod_lt (x : ℤ[i]) {y : ℤ[i]} (hy : y ≠ 0) : (x % y).norm < y.
calc
↑(Zsqrtd.norm (x % y)) = (x - y * (x / y : ℤ[i]) : ℂ).normSq := by simp [mod_def]
_ = (y : ℂ).normSq * (x / y - (x / y : ℤ[i]) : ℂ).normSq := by
- rw [← norm_sq_mul, mul_sub, mul_div_cancel' _ this]
+ rw [← norm_sq_mul, mul_sub, mul_div_cancel₀ _ this]
_ < (y : ℂ).normSq * 1 :=
(mul_lt_mul_of_pos_left (normSq_div_sub_div_lt_one _ _) (normSq_pos.2 this))
_ = Zsqrtd.norm y := by simp
@@ -366,7 +366,7 @@ theorem sq_add_sq_of_nat_prime_of_not_irreducible (p : ℕ) [hp : Fact p.Prime]
let ⟨a, b, hpab, hau, hbu⟩ := hab
have hnap : (norm a).natAbs = p :=
((hp.1.mul_eq_prime_sq_iff (mt norm_eq_one_iff.1 hau) (mt norm_eq_one_iff.1 hbu)).1 <| by
- rw [← Int.coe_nat_inj', Int.coe_nat_pow, sq, ← @norm_nat_cast (-1), hpab] <;> simp).1
+ rw [← Int.natCast_inj, Int.coe_nat_pow, sq, ← @norm_nat_cast (-1), hpab] <;> simp).1
⟨a.re.natAbs, a.im.natAbs, by simpa [nat_abs_norm_eq, sq] using hnap⟩
#align gaussian_int.sq_add_sq_of_nat_prime_of_not_irreducible GaussianInt.sq_add_sq_of_nat_prime_of_not_irreducible
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/b1abe23ae96fef89ad30d9f4362c307f72a55010
@@ -362,7 +362,7 @@ theorem sq_add_sq_of_nat_prime_of_not_irreducible (p : ℕ) [hp : Fact p.Prime]
rw [norm_nat_cast, Int.natAbs_mul, mul_eq_one] <;>
exact fun h => (ne_of_lt hp.1.one_lt).symm h.1
have hab : ∃ a b, (p : ℤ[i]) = a * b ∧ ¬IsUnit a ∧ ¬IsUnit b := by
- simpa [irreducible_iff, hpu, not_forall, not_or] using hpi
+ simpa [irreducible_iff, hpu, Classical.not_forall, not_or] using hpi
let ⟨a, b, hpab, hau, hbu⟩ := hab
have hnap : (norm a).natAbs = p :=
((hp.1.mul_eq_prime_sq_iff (mt norm_eq_one_iff.1 hau) (mt norm_eq_one_iff.1 hbu)).1 <| by
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,9 +3,9 @@ Copyright (c) 2019 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
-/
-import Mathbin.NumberTheory.Zsqrtd.Basic
-import Mathbin.Data.Complex.Basic
-import Mathbin.RingTheory.PrincipalIdealDomain
+import NumberTheory.Zsqrtd.Basic
+import Data.Complex.Basic
+import RingTheory.PrincipalIdealDomain
#align_import number_theory.zsqrtd.gaussian_int from "leanprover-community/mathlib"@"5d0c76894ada7940957143163d7b921345474cbc"
mathlib commit https://github.com/leanprover-community/mathlib/commit/32a7e535287f9c73f2e4d2aef306a39190f0b504
@@ -132,7 +132,7 @@ theorem toComplex_add (x y : ℤ[i]) : ((x + y : ℤ[i]) : ℂ) = x + y :=
#print GaussianInt.toComplex_mul /-
@[simp]
theorem toComplex_mul (x y : ℤ[i]) : ((x * y : ℤ[i]) : ℂ) = x * y :=
- toComplex.map_mul _ _
+ toComplex.map_hMul _ _
#align gaussian_int.to_complex_mul GaussianInt.toComplex_mul
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -2,16 +2,13 @@
Copyright (c) 2019 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
-
-! This file was ported from Lean 3 source module number_theory.zsqrtd.gaussian_int
-! leanprover-community/mathlib commit 5d0c76894ada7940957143163d7b921345474cbc
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.NumberTheory.Zsqrtd.Basic
import Mathbin.Data.Complex.Basic
import Mathbin.RingTheory.PrincipalIdealDomain
+#align_import number_theory.zsqrtd.gaussian_int from "leanprover-community/mathlib"@"5d0c76894ada7940957143163d7b921345474cbc"
+
/-!
# Gaussian integers
mathlib commit https://github.com/leanprover-community/mathlib/commit/93f880918cb51905fd51b76add8273cbc27718ab
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
! This file was ported from Lean 3 source module number_theory.zsqrtd.gaussian_int
-! leanprover-community/mathlib commit 5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9
+! leanprover-community/mathlib commit 5d0c76894ada7940957143163d7b921345474cbc
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -15,6 +15,9 @@ import Mathbin.RingTheory.PrincipalIdealDomain
/-!
# Gaussian integers
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
The Gaussian integers are complex integer, complex numbers whose real and imaginary parts are both
integers.
mathlib commit https://github.com/leanprover-community/mathlib/commit/6285167a053ad0990fc88e56c48ccd9fae6550eb
@@ -46,11 +46,13 @@ open Zsqrtd Complex
open scoped ComplexConjugate
+#print GaussianInt /-
/-- The Gaussian integers, defined as `ℤ√(-1)`. -/
@[reducible]
def GaussianInt : Type :=
Zsqrtd (-1)
#align gaussian_int GaussianInt
+-/
local notation "ℤ[i]" => GaussianInt
@@ -64,128 +66,178 @@ instance : CommRing ℤ[i] :=
section
-attribute [-instance] Complex.field
+attribute [-instance] Complex.instField
+#print GaussianInt.toComplex /-
-- Avoid making things noncomputable unnecessarily.
/-- The embedding of the Gaussian integers into the complex numbers, as a ring homomorphism. -/
def toComplex : ℤ[i] →+* ℂ :=
Zsqrtd.lift ⟨I, by simp⟩
#align gaussian_int.to_complex GaussianInt.toComplex
+-/
end
instance : Coe ℤ[i] ℂ :=
⟨toComplex⟩
-theorem to_complex_def (x : ℤ[i]) : (x : ℂ) = x.re + x.im * I :=
+#print GaussianInt.toComplex_def /-
+theorem toComplex_def (x : ℤ[i]) : (x : ℂ) = x.re + x.im * I :=
rfl
-#align gaussian_int.to_complex_def GaussianInt.to_complex_def
+#align gaussian_int.to_complex_def GaussianInt.toComplex_def
+-/
-theorem to_complex_def' (x y : ℤ) : ((⟨x, y⟩ : ℤ[i]) : ℂ) = x + y * I := by simp [to_complex_def]
-#align gaussian_int.to_complex_def' GaussianInt.to_complex_def'
+#print GaussianInt.toComplex_def' /-
+theorem toComplex_def' (x y : ℤ) : ((⟨x, y⟩ : ℤ[i]) : ℂ) = x + y * I := by simp [to_complex_def]
+#align gaussian_int.to_complex_def' GaussianInt.toComplex_def'
+-/
-theorem to_complex_def₂ (x : ℤ[i]) : (x : ℂ) = ⟨x.re, x.im⟩ := by
+#print GaussianInt.toComplex_def₂ /-
+theorem toComplex_def₂ (x : ℤ[i]) : (x : ℂ) = ⟨x.re, x.im⟩ := by
apply Complex.ext <;> simp [to_complex_def]
-#align gaussian_int.to_complex_def₂ GaussianInt.to_complex_def₂
+#align gaussian_int.to_complex_def₂ GaussianInt.toComplex_def₂
+-/
+#print GaussianInt.to_real_re /-
@[simp]
theorem to_real_re (x : ℤ[i]) : ((x.re : ℤ) : ℝ) = (x : ℂ).re := by simp [to_complex_def]
#align gaussian_int.to_real_re GaussianInt.to_real_re
+-/
+#print GaussianInt.to_real_im /-
@[simp]
theorem to_real_im (x : ℤ[i]) : ((x.im : ℤ) : ℝ) = (x : ℂ).im := by simp [to_complex_def]
#align gaussian_int.to_real_im GaussianInt.to_real_im
+-/
+#print GaussianInt.toComplex_re /-
@[simp]
-theorem to_complex_re (x y : ℤ) : ((⟨x, y⟩ : ℤ[i]) : ℂ).re = x := by simp [to_complex_def]
-#align gaussian_int.to_complex_re GaussianInt.to_complex_re
+theorem toComplex_re (x y : ℤ) : ((⟨x, y⟩ : ℤ[i]) : ℂ).re = x := by simp [to_complex_def]
+#align gaussian_int.to_complex_re GaussianInt.toComplex_re
+-/
+#print GaussianInt.toComplex_im /-
@[simp]
-theorem to_complex_im (x y : ℤ) : ((⟨x, y⟩ : ℤ[i]) : ℂ).im = y := by simp [to_complex_def]
-#align gaussian_int.to_complex_im GaussianInt.to_complex_im
+theorem toComplex_im (x y : ℤ) : ((⟨x, y⟩ : ℤ[i]) : ℂ).im = y := by simp [to_complex_def]
+#align gaussian_int.to_complex_im GaussianInt.toComplex_im
+-/
+#print GaussianInt.toComplex_add /-
@[simp]
-theorem to_complex_add (x y : ℤ[i]) : ((x + y : ℤ[i]) : ℂ) = x + y :=
+theorem toComplex_add (x y : ℤ[i]) : ((x + y : ℤ[i]) : ℂ) = x + y :=
toComplex.map_add _ _
-#align gaussian_int.to_complex_add GaussianInt.to_complex_add
+#align gaussian_int.to_complex_add GaussianInt.toComplex_add
+-/
+#print GaussianInt.toComplex_mul /-
@[simp]
-theorem to_complex_mul (x y : ℤ[i]) : ((x * y : ℤ[i]) : ℂ) = x * y :=
+theorem toComplex_mul (x y : ℤ[i]) : ((x * y : ℤ[i]) : ℂ) = x * y :=
toComplex.map_mul _ _
-#align gaussian_int.to_complex_mul GaussianInt.to_complex_mul
+#align gaussian_int.to_complex_mul GaussianInt.toComplex_mul
+-/
+#print GaussianInt.toComplex_one /-
@[simp]
-theorem to_complex_one : ((1 : ℤ[i]) : ℂ) = 1 :=
+theorem toComplex_one : ((1 : ℤ[i]) : ℂ) = 1 :=
toComplex.map_one
-#align gaussian_int.to_complex_one GaussianInt.to_complex_one
+#align gaussian_int.to_complex_one GaussianInt.toComplex_one
+-/
+#print GaussianInt.toComplex_zero /-
@[simp]
-theorem to_complex_zero : ((0 : ℤ[i]) : ℂ) = 0 :=
+theorem toComplex_zero : ((0 : ℤ[i]) : ℂ) = 0 :=
toComplex.map_zero
-#align gaussian_int.to_complex_zero GaussianInt.to_complex_zero
+#align gaussian_int.to_complex_zero GaussianInt.toComplex_zero
+-/
+#print GaussianInt.toComplex_neg /-
@[simp]
-theorem to_complex_neg (x : ℤ[i]) : ((-x : ℤ[i]) : ℂ) = -x :=
+theorem toComplex_neg (x : ℤ[i]) : ((-x : ℤ[i]) : ℂ) = -x :=
toComplex.map_neg _
-#align gaussian_int.to_complex_neg GaussianInt.to_complex_neg
+#align gaussian_int.to_complex_neg GaussianInt.toComplex_neg
+-/
+#print GaussianInt.toComplex_sub /-
@[simp]
-theorem to_complex_sub (x y : ℤ[i]) : ((x - y : ℤ[i]) : ℂ) = x - y :=
+theorem toComplex_sub (x y : ℤ[i]) : ((x - y : ℤ[i]) : ℂ) = x - y :=
toComplex.map_sub _ _
-#align gaussian_int.to_complex_sub GaussianInt.to_complex_sub
+#align gaussian_int.to_complex_sub GaussianInt.toComplex_sub
+-/
+#print GaussianInt.toComplex_star /-
@[simp]
-theorem to_complex_star (x : ℤ[i]) : ((star x : ℤ[i]) : ℂ) = conj (x : ℂ) :=
+theorem toComplex_star (x : ℤ[i]) : ((star x : ℤ[i]) : ℂ) = conj (x : ℂ) :=
by
rw [to_complex_def₂, to_complex_def₂]
exact congr_arg₂ _ rfl (Int.cast_neg _)
-#align gaussian_int.to_complex_star GaussianInt.to_complex_star
+#align gaussian_int.to_complex_star GaussianInt.toComplex_star
+-/
+#print GaussianInt.toComplex_inj /-
@[simp]
-theorem to_complex_inj {x y : ℤ[i]} : (x : ℂ) = y ↔ x = y := by
+theorem toComplex_inj {x y : ℤ[i]} : (x : ℂ) = y ↔ x = y := by
cases x <;> cases y <;> simp [to_complex_def₂]
-#align gaussian_int.to_complex_inj GaussianInt.to_complex_inj
+#align gaussian_int.to_complex_inj GaussianInt.toComplex_inj
+-/
+#print GaussianInt.toComplex_eq_zero /-
@[simp]
-theorem to_complex_eq_zero {x : ℤ[i]} : (x : ℂ) = 0 ↔ x = 0 := by
+theorem toComplex_eq_zero {x : ℤ[i]} : (x : ℂ) = 0 ↔ x = 0 := by
rw [← to_complex_zero, to_complex_inj]
-#align gaussian_int.to_complex_eq_zero GaussianInt.to_complex_eq_zero
+#align gaussian_int.to_complex_eq_zero GaussianInt.toComplex_eq_zero
+-/
+#print GaussianInt.int_cast_real_norm /-
@[simp]
-theorem nat_cast_real_norm (x : ℤ[i]) : (x.norm : ℝ) = (x : ℂ).normSq := by
+theorem int_cast_real_norm (x : ℤ[i]) : (x.norm : ℝ) = (x : ℂ).normSq := by
rw [Zsqrtd.norm, norm_sq] <;> simp
-#align gaussian_int.nat_cast_real_norm GaussianInt.nat_cast_real_norm
+#align gaussian_int.nat_cast_real_norm GaussianInt.int_cast_real_norm
+-/
+#print GaussianInt.int_cast_complex_norm /-
@[simp]
-theorem nat_cast_complex_norm (x : ℤ[i]) : (x.norm : ℂ) = (x : ℂ).normSq := by
+theorem int_cast_complex_norm (x : ℤ[i]) : (x.norm : ℂ) = (x : ℂ).normSq := by
cases x <;> rw [Zsqrtd.norm, norm_sq] <;> simp
-#align gaussian_int.nat_cast_complex_norm GaussianInt.nat_cast_complex_norm
+#align gaussian_int.nat_cast_complex_norm GaussianInt.int_cast_complex_norm
+-/
+#print GaussianInt.norm_nonneg /-
theorem norm_nonneg (x : ℤ[i]) : 0 ≤ norm x :=
norm_nonneg (by norm_num) _
#align gaussian_int.norm_nonneg GaussianInt.norm_nonneg
+-/
+#print GaussianInt.norm_eq_zero /-
@[simp]
theorem norm_eq_zero {x : ℤ[i]} : norm x = 0 ↔ x = 0 := by rw [← @Int.cast_inj ℝ _ _ _] <;> simp
#align gaussian_int.norm_eq_zero GaussianInt.norm_eq_zero
+-/
+#print GaussianInt.norm_pos /-
theorem norm_pos {x : ℤ[i]} : 0 < norm x ↔ x ≠ 0 := by
rw [lt_iff_le_and_ne, Ne.def, eq_comm, norm_eq_zero] <;> simp [norm_nonneg]
#align gaussian_int.norm_pos GaussianInt.norm_pos
+-/
+#print GaussianInt.abs_coe_nat_norm /-
theorem abs_coe_nat_norm (x : ℤ[i]) : (x.norm.natAbs : ℤ) = x.norm :=
Int.natAbs_of_nonneg (norm_nonneg _)
#align gaussian_int.abs_coe_nat_norm GaussianInt.abs_coe_nat_norm
+-/
+#print GaussianInt.nat_cast_natAbs_norm /-
@[simp]
theorem nat_cast_natAbs_norm {α : Type _} [Ring α] (x : ℤ[i]) : (x.norm.natAbs : α) = x.norm := by
rw [← Int.cast_ofNat, abs_coe_nat_norm]
#align gaussian_int.nat_cast_nat_abs_norm GaussianInt.nat_cast_natAbs_norm
+-/
+#print GaussianInt.natAbs_norm_eq /-
theorem natAbs_norm_eq (x : ℤ[i]) :
x.norm.natAbs = x.re.natAbs * x.re.natAbs + x.im.natAbs * x.im.natAbs :=
Int.ofNat.inj <| by simp; simp [Zsqrtd.norm]
#align gaussian_int.nat_abs_norm_eq GaussianInt.natAbs_norm_eq
+-/
instance : Div ℤ[i] :=
⟨fun x y =>
@@ -193,21 +245,28 @@ instance : Div ℤ[i] :=
let c := star y
⟨round ((x * c).re * n : ℚ), round ((x * c).im * n : ℚ)⟩⟩
+#print GaussianInt.div_def /-
theorem div_def (x y : ℤ[i]) :
x / y = ⟨round ((x * star y).re / norm y : ℚ), round ((x * star y).im / norm y : ℚ)⟩ :=
show Zsqrtd.mk _ _ = _ by simp [div_eq_mul_inv]
#align gaussian_int.div_def GaussianInt.div_def
+-/
-theorem to_complex_div_re (x y : ℤ[i]) : ((x / y : ℤ[i]) : ℂ).re = round (x / y : ℂ).re := by
+#print GaussianInt.toComplex_div_re /-
+theorem toComplex_div_re (x y : ℤ[i]) : ((x / y : ℤ[i]) : ℂ).re = round (x / y : ℂ).re := by
rw [div_def, ← @Rat.round_cast ℝ _ _] <;>
simp [-Rat.round_cast, mul_assoc, div_eq_mul_inv, mul_add, add_mul]
-#align gaussian_int.to_complex_div_re GaussianInt.to_complex_div_re
+#align gaussian_int.to_complex_div_re GaussianInt.toComplex_div_re
+-/
-theorem to_complex_div_im (x y : ℤ[i]) : ((x / y : ℤ[i]) : ℂ).im = round (x / y : ℂ).im := by
+#print GaussianInt.toComplex_div_im /-
+theorem toComplex_div_im (x y : ℤ[i]) : ((x / y : ℤ[i]) : ℂ).im = round (x / y : ℂ).im := by
rw [div_def, ← @Rat.round_cast ℝ _ _, ← @Rat.round_cast ℝ _ _] <;>
simp [-Rat.round_cast, mul_assoc, div_eq_mul_inv, mul_add, add_mul]
-#align gaussian_int.to_complex_div_im GaussianInt.to_complex_div_im
+#align gaussian_int.to_complex_div_im GaussianInt.toComplex_div_im
+-/
+#print GaussianInt.normSq_le_normSq_of_re_le_of_im_le /-
theorem normSq_le_normSq_of_re_le_of_im_le {x y : ℂ} (hre : |x.re| ≤ |y.re|)
(him : |x.im| ≤ |y.im|) : x.normSq ≤ y.normSq := by
rw [norm_sq_apply, norm_sq_apply, ← _root_.abs_mul_self, _root_.abs_mul, ←
@@ -216,7 +275,9 @@ theorem normSq_le_normSq_of_re_le_of_im_le {x y : ℂ} (hre : |x.re| ≤ |y.re|)
exact
add_le_add (mul_self_le_mul_self (abs_nonneg _) hre) (mul_self_le_mul_self (abs_nonneg _) him)
#align gaussian_int.norm_sq_le_norm_sq_of_re_le_of_im_le GaussianInt.normSq_le_normSq_of_re_le_of_im_le
+-/
+#print GaussianInt.normSq_div_sub_div_lt_one /-
theorem normSq_div_sub_div_lt_one (x y : ℤ[i]) : ((x / y : ℂ) - ((x / y : ℤ[i]) : ℂ)).normSq < 1 :=
calc
((x / y : ℂ) - ((x / y : ℤ[i]) : ℂ)).normSq =
@@ -234,14 +295,18 @@ theorem normSq_div_sub_div_lt_one (x y : ℤ[i]) : ((x / y : ℂ) - ((x / y :
simpa using abs_sub_round (x / y : ℂ).im))
_ < 1 := by simp [norm_sq] <;> norm_num
#align gaussian_int.norm_sq_div_sub_div_lt_one GaussianInt.normSq_div_sub_div_lt_one
+-/
instance : Mod ℤ[i] :=
⟨fun x y => x - y * (x / y)⟩
+#print GaussianInt.mod_def /-
theorem mod_def (x y : ℤ[i]) : x % y = x - y * (x / y) :=
rfl
#align gaussian_int.mod_def GaussianInt.mod_def
+-/
+#print GaussianInt.norm_mod_lt /-
theorem norm_mod_lt (x : ℤ[i]) {y : ℤ[i]} (hy : y ≠ 0) : (x % y).norm < y.norm :=
have : (y : ℂ) ≠ 0 := by rwa [Ne.def, ← to_complex_zero, to_complex_inj]
(@Int.cast_lt ℝ _ _ _ _).1 <|
@@ -253,12 +318,16 @@ theorem norm_mod_lt (x : ℤ[i]) {y : ℤ[i]} (hy : y ≠ 0) : (x % y).norm < y.
(mul_lt_mul_of_pos_left (normSq_div_sub_div_lt_one _ _) (normSq_pos.2 this))
_ = Zsqrtd.norm y := by simp
#align gaussian_int.norm_mod_lt GaussianInt.norm_mod_lt
+-/
+#print GaussianInt.natAbs_norm_mod_lt /-
theorem natAbs_norm_mod_lt (x : ℤ[i]) {y : ℤ[i]} (hy : y ≠ 0) :
(x % y).norm.natAbs < y.norm.natAbs :=
Int.ofNat_lt.1 (by simp [-Int.ofNat_lt, norm_mod_lt x hy])
#align gaussian_int.nat_abs_norm_mod_lt GaussianInt.natAbs_norm_mod_lt
+-/
+#print GaussianInt.norm_le_norm_mul_left /-
theorem norm_le_norm_mul_left (x : ℤ[i]) {y : ℤ[i]} (hy : y ≠ 0) :
(norm x).natAbs ≤ (norm (x * y)).natAbs := by
rw [Zsqrtd.norm_mul, Int.natAbs_mul] <;>
@@ -266,13 +335,14 @@ theorem norm_le_norm_mul_left (x : ℤ[i]) {y : ℤ[i]} (hy : y ≠ 0) :
le_mul_of_one_le_right (Nat.zero_le _)
(Int.ofNat_le.1 (by rw [abs_coe_nat_norm] <;> exact Int.add_one_le_of_lt (norm_pos.2 hy)))
#align gaussian_int.norm_le_norm_mul_left GaussianInt.norm_le_norm_mul_left
+-/
instance : Nontrivial ℤ[i] :=
⟨⟨0, 1, by decide⟩⟩
instance : EuclideanDomain ℤ[i] :=
- { GaussianInt.commRing,
- GaussianInt.nontrivial with
+ { GaussianInt.instCommRing,
+ GaussianInt.instNontrivial with
Quotient := (· / ·)
remainder := (· % ·)
quotient_zero := by simp [div_def]; rfl
@@ -284,6 +354,7 @@ instance : EuclideanDomain ℤ[i] :=
open PrincipalIdealRing
+#print GaussianInt.sq_add_sq_of_nat_prime_of_not_irreducible /-
theorem sq_add_sq_of_nat_prime_of_not_irreducible (p : ℕ) [hp : Fact p.Prime]
(hpi : ¬Irreducible (p : ℤ[i])) : ∃ a b, a ^ 2 + b ^ 2 = p :=
have hpu : ¬IsUnit (p : ℤ[i]) :=
@@ -298,6 +369,7 @@ theorem sq_add_sq_of_nat_prime_of_not_irreducible (p : ℕ) [hp : Fact p.Prime]
rw [← Int.coe_nat_inj', Int.coe_nat_pow, sq, ← @norm_nat_cast (-1), hpab] <;> simp).1
⟨a.re.natAbs, a.im.natAbs, by simpa [nat_abs_norm_eq, sq] using hnap⟩
#align gaussian_int.sq_add_sq_of_nat_prime_of_not_irreducible GaussianInt.sq_add_sq_of_nat_prime_of_not_irreducible
+-/
end GaussianInt
mathlib commit https://github.com/leanprover-community/mathlib/commit/893964fc28cefbcffc7cb784ed00a2895b4e65cf
@@ -4,14 +4,13 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
! This file was ported from Lean 3 source module number_theory.zsqrtd.gaussian_int
-! leanprover-community/mathlib commit e8638a0fcaf73e4500469f368ef9494e495099b3
+! leanprover-community/mathlib commit 5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathbin.NumberTheory.Zsqrtd.Basic
import Mathbin.Data.Complex.Basic
import Mathbin.RingTheory.PrincipalIdealDomain
-import Mathbin.NumberTheory.LegendreSymbol.QuadraticReciprocity
/-!
# Gaussian integers
@@ -25,10 +24,11 @@ The Euclidean domain structure on `ℤ[i]` is defined in this file.
The homomorphism `to_complex` into the complex numbers is also defined in this file.
-## Main statements
+## See also
-`prime_iff_mod_four_eq_three_of_nat_prime`
-A prime natural number is prime in `ℤ[i]` if and only if it is `3` mod `4`
+See `number_theory.zsqrtd.gaussian_int` for:
+* `prime_iff_mod_four_eq_three_of_nat_prime`:
+ A prime natural number is prime in `ℤ[i]` if and only if it is `3` mod `4`
## Notations
@@ -284,67 +284,6 @@ instance : EuclideanDomain ℤ[i] :=
open PrincipalIdealRing
-theorem mod_four_eq_three_of_nat_prime_of_prime (p : ℕ) [hp : Fact p.Prime]
- (hpi : Prime (p : ℤ[i])) : p % 4 = 3 :=
- hp.1.eq_two_or_odd.elim
- (fun hp2 =>
- absurd hpi
- (mt irreducible_iff_prime.2 fun ⟨hu, h⟩ =>
- by
- have := h ⟨1, 1⟩ ⟨1, -1⟩ (hp2.symm ▸ rfl)
- rw [← norm_eq_one_iff, ← norm_eq_one_iff] at this
- exact absurd this (by decide)))
- fun hp1 =>
- by_contradiction fun hp3 : p % 4 ≠ 3 =>
- by
- have hp41 : p % 4 = 1 :=
- by
- rw [← Nat.mod_mul_left_mod p 2 2, show 2 * 2 = 4 from rfl] at hp1
- have := Nat.mod_lt p (show 0 < 4 by decide)
- revert this hp3 hp1
- generalize p % 4 = m; decide!
- let ⟨k, hk⟩ := ZMod.exists_sq_eq_neg_one_iff.2 <| by rw [hp41] <;> exact by decide
- obtain ⟨k, k_lt_p, rfl⟩ : ∃ (k' : ℕ) (h : k' < p), (k' : ZMod p) = k := by
- refine' ⟨k.val, k.val_lt, ZMod.nat_cast_zmod_val k⟩
- have hpk : p ∣ k ^ 2 + 1 := by
- rw [pow_two, ← CharP.cast_eq_zero_iff (ZMod p) p, Nat.cast_add, Nat.cast_mul, Nat.cast_one,
- ← hk, add_left_neg]
- have hkmul : (k ^ 2 + 1 : ℤ[i]) = ⟨k, 1⟩ * ⟨k, -1⟩ := by simp [sq, Zsqrtd.ext]
- have hpne1 : p ≠ 1 := ne_of_gt hp.1.one_lt
- have hkltp : 1 + k * k < p * p :=
- calc
- 1 + k * k ≤ k + k * k :=
- add_le_add_right
- (Nat.pos_of_ne_zero fun hk0 => by clear_aux_decl <;> simp_all [pow_succ']) _
- _ = k * (k + 1) := by simp [add_comm, mul_add]
- _ < p * p := mul_lt_mul k_lt_p k_lt_p (Nat.succ_pos _) (Nat.zero_le _)
- have hpk₁ : ¬(p : ℤ[i]) ∣ ⟨k, -1⟩ := fun ⟨x, hx⟩ =>
- lt_irrefl (p * x : ℤ[i]).norm.natAbs <|
- calc
- (norm (p * x : ℤ[i])).natAbs = (Zsqrtd.norm ⟨k, -1⟩).natAbs := by rw [hx]
- _ < (norm (p : ℤ[i])).natAbs := by simpa [add_comm, Zsqrtd.norm] using hkltp
- _ ≤ (norm (p * x : ℤ[i])).natAbs :=
- norm_le_norm_mul_left _ fun hx0 =>
- show (-1 : ℤ) ≠ 0 by decide <| by simpa [hx0] using congr_arg Zsqrtd.im hx
- have hpk₂ : ¬(p : ℤ[i]) ∣ ⟨k, 1⟩ := fun ⟨x, hx⟩ =>
- lt_irrefl (p * x : ℤ[i]).norm.natAbs <|
- calc
- (norm (p * x : ℤ[i])).natAbs = (Zsqrtd.norm ⟨k, 1⟩).natAbs := by rw [hx]
- _ < (norm (p : ℤ[i])).natAbs := by simpa [add_comm, Zsqrtd.norm] using hkltp
- _ ≤ (norm (p * x : ℤ[i])).natAbs :=
- norm_le_norm_mul_left _ fun hx0 =>
- show (1 : ℤ) ≠ 0 by decide <| by simpa [hx0] using congr_arg Zsqrtd.im hx
- have hpu : ¬IsUnit (p : ℤ[i]) :=
- mt norm_eq_one_iff.2
- (by
- rw [norm_nat_cast, Int.natAbs_mul, mul_eq_one] <;>
- exact fun h => (ne_of_lt hp.1.one_lt).symm h.1)
- obtain ⟨y, hy⟩ := hpk
- have := hpi.2.2 ⟨k, 1⟩ ⟨k, -1⟩ ⟨y, by rw [← hkmul, ← Nat.cast_mul p, ← hy] <;> simp⟩
- clear_aux_decl
- tauto
-#align gaussian_int.mod_four_eq_three_of_nat_prime_of_prime GaussianInt.mod_four_eq_three_of_nat_prime_of_prime
-
theorem sq_add_sq_of_nat_prime_of_not_irreducible (p : ℕ) [hp : Fact p.Prime]
(hpi : ¬Irreducible (p : ℤ[i])) : ∃ a b, a ^ 2 + b ^ 2 = p :=
have hpu : ¬IsUnit (p : ℤ[i]) :=
@@ -360,21 +299,5 @@ theorem sq_add_sq_of_nat_prime_of_not_irreducible (p : ℕ) [hp : Fact p.Prime]
⟨a.re.natAbs, a.im.natAbs, by simpa [nat_abs_norm_eq, sq] using hnap⟩
#align gaussian_int.sq_add_sq_of_nat_prime_of_not_irreducible GaussianInt.sq_add_sq_of_nat_prime_of_not_irreducible
-theorem prime_of_nat_prime_of_mod_four_eq_three (p : ℕ) [hp : Fact p.Prime] (hp3 : p % 4 = 3) :
- Prime (p : ℤ[i]) :=
- irreducible_iff_prime.1 <|
- by_contradiction fun hpi =>
- let ⟨a, b, hab⟩ := sq_add_sq_of_nat_prime_of_not_irreducible p hpi
- have : ∀ a b : ZMod 4, a ^ 2 + b ^ 2 ≠ p := by
- erw [← ZMod.nat_cast_mod p 4, hp3] <;> exact by decide
- this a b (hab ▸ by simp)
-#align gaussian_int.prime_of_nat_prime_of_mod_four_eq_three GaussianInt.prime_of_nat_prime_of_mod_four_eq_three
-
-/-- A prime natural number is prime in `ℤ[i]` if and only if it is `3` mod `4` -/
-theorem prime_iff_mod_four_eq_three_of_nat_prime (p : ℕ) [hp : Fact p.Prime] :
- Prime (p : ℤ[i]) ↔ p % 4 = 3 :=
- ⟨mod_four_eq_three_of_nat_prime_of_prime p, prime_of_nat_prime_of_mod_four_eq_three p⟩
-#align gaussian_int.prime_iff_mod_four_eq_three_of_nat_prime GaussianInt.prime_iff_mod_four_eq_three_of_nat_prime
-
end GaussianInt
mathlib commit https://github.com/leanprover-community/mathlib/commit/9fb8964792b4237dac6200193a0d533f1b3f7423
@@ -52,7 +52,6 @@ def GaussianInt : Type :=
Zsqrtd (-1)
#align gaussian_int GaussianInt
--- mathport name: «exprℤ[i]»
local notation "ℤ[i]" => GaussianInt
namespace GaussianInt
mathlib commit https://github.com/leanprover-community/mathlib/commit/7e5137f579de09a059a5ce98f364a04e221aabf0
@@ -234,7 +234,6 @@ theorem normSq_div_sub_div_lt_one (x y : ℤ[i]) : ((x / y : ℂ) - ((x / y :
rw [to_complex_div_im] <;> simp [norm_sq, this] <;>
simpa using abs_sub_round (x / y : ℂ).im))
_ < 1 := by simp [norm_sq] <;> norm_num
-
#align gaussian_int.norm_sq_div_sub_div_lt_one GaussianInt.normSq_div_sub_div_lt_one
instance : Mod ℤ[i] :=
@@ -254,7 +253,6 @@ theorem norm_mod_lt (x : ℤ[i]) {y : ℤ[i]} (hy : y ≠ 0) : (x % y).norm < y.
_ < (y : ℂ).normSq * 1 :=
(mul_lt_mul_of_pos_left (normSq_div_sub_div_lt_one _ _) (normSq_pos.2 this))
_ = Zsqrtd.norm y := by simp
-
#align gaussian_int.norm_mod_lt GaussianInt.norm_mod_lt
theorem natAbs_norm_mod_lt (x : ℤ[i]) {y : ℤ[i]} (hy : y ≠ 0) :
@@ -321,7 +319,6 @@ theorem mod_four_eq_three_of_nat_prime_of_prime (p : ℕ) [hp : Fact p.Prime]
(Nat.pos_of_ne_zero fun hk0 => by clear_aux_decl <;> simp_all [pow_succ']) _
_ = k * (k + 1) := by simp [add_comm, mul_add]
_ < p * p := mul_lt_mul k_lt_p k_lt_p (Nat.succ_pos _) (Nat.zero_le _)
-
have hpk₁ : ¬(p : ℤ[i]) ∣ ⟨k, -1⟩ := fun ⟨x, hx⟩ =>
lt_irrefl (p * x : ℤ[i]).norm.natAbs <|
calc
@@ -330,7 +327,6 @@ theorem mod_four_eq_three_of_nat_prime_of_prime (p : ℕ) [hp : Fact p.Prime]
_ ≤ (norm (p * x : ℤ[i])).natAbs :=
norm_le_norm_mul_left _ fun hx0 =>
show (-1 : ℤ) ≠ 0 by decide <| by simpa [hx0] using congr_arg Zsqrtd.im hx
-
have hpk₂ : ¬(p : ℤ[i]) ∣ ⟨k, 1⟩ := fun ⟨x, hx⟩ =>
lt_irrefl (p * x : ℤ[i]).norm.natAbs <|
calc
@@ -339,7 +335,6 @@ theorem mod_four_eq_three_of_nat_prime_of_prime (p : ℕ) [hp : Fact p.Prime]
_ ≤ (norm (p * x : ℤ[i])).natAbs :=
norm_le_norm_mul_left _ fun hx0 =>
show (1 : ℤ) ≠ 0 by decide <| by simpa [hx0] using congr_arg Zsqrtd.im hx
-
have hpu : ¬IsUnit (p : ℤ[i]) :=
mt norm_eq_one_iff.2
(by
mathlib commit https://github.com/leanprover-community/mathlib/commit/cca40788df1b8755d5baf17ab2f27dacc2e17acb
@@ -295,19 +295,19 @@ theorem mod_four_eq_three_of_nat_prime_of_prime (p : ℕ) [hp : Fact p.Prime]
(mt irreducible_iff_prime.2 fun ⟨hu, h⟩ =>
by
have := h ⟨1, 1⟩ ⟨1, -1⟩ (hp2.symm ▸ rfl)
- rw [← norm_eq_one_iff, ← norm_eq_one_iff] at this
+ rw [← norm_eq_one_iff, ← norm_eq_one_iff] at this
exact absurd this (by decide)))
fun hp1 =>
by_contradiction fun hp3 : p % 4 ≠ 3 =>
by
have hp41 : p % 4 = 1 :=
by
- rw [← Nat.mod_mul_left_mod p 2 2, show 2 * 2 = 4 from rfl] at hp1
+ rw [← Nat.mod_mul_left_mod p 2 2, show 2 * 2 = 4 from rfl] at hp1
have := Nat.mod_lt p (show 0 < 4 by decide)
revert this hp3 hp1
generalize p % 4 = m; decide!
let ⟨k, hk⟩ := ZMod.exists_sq_eq_neg_one_iff.2 <| by rw [hp41] <;> exact by decide
- obtain ⟨k, k_lt_p, rfl⟩ : ∃ (k' : ℕ)(h : k' < p), (k' : ZMod p) = k := by
+ obtain ⟨k, k_lt_p, rfl⟩ : ∃ (k' : ℕ) (h : k' < p), (k' : ZMod p) = k := by
refine' ⟨k.val, k.val_lt, ZMod.nat_cast_zmod_val k⟩
have hpk : p ∣ k ^ 2 + 1 := by
rw [pow_two, ← CharP.cast_eq_zero_iff (ZMod p) p, Nat.cast_add, Nat.cast_mul, Nat.cast_one,
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -44,7 +44,7 @@ and definitions about `zsqrtd` can easily be used.
open Zsqrtd Complex
-open ComplexConjugate
+open scoped ComplexConjugate
/-- The Gaussian integers, defined as `ℤ√(-1)`. -/
@[reducible]
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -278,9 +278,7 @@ instance : EuclideanDomain ℤ[i] :=
GaussianInt.nontrivial with
Quotient := (· / ·)
remainder := (· % ·)
- quotient_zero := by
- simp [div_def]
- rfl
+ quotient_zero := by simp [div_def]; rfl
quotient_mul_add_remainder_eq := fun _ _ => by simp [mod_def]
R := _
r_wellFounded := measure_wf (Int.natAbs ∘ norm)
mathlib commit https://github.com/leanprover-community/mathlib/commit/06a655b5fcfbda03502f9158bbf6c0f1400886f9
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
! This file was ported from Lean 3 source module number_theory.zsqrtd.gaussian_int
-! leanprover-community/mathlib commit 2af0836443b4cfb5feda0df0051acdb398304931
+! leanprover-community/mathlib commit e8638a0fcaf73e4500469f368ef9494e495099b3
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -345,7 +345,7 @@ theorem mod_four_eq_three_of_nat_prime_of_prime (p : ℕ) [hp : Fact p.Prime]
have hpu : ¬IsUnit (p : ℤ[i]) :=
mt norm_eq_one_iff.2
(by
- rw [norm_nat_cast, Int.natAbs_mul, Nat.mul_eq_one_iff] <;>
+ rw [norm_nat_cast, Int.natAbs_mul, mul_eq_one] <;>
exact fun h => (ne_of_lt hp.1.one_lt).symm h.1)
obtain ⟨y, hy⟩ := hpk
have := hpi.2.2 ⟨k, 1⟩ ⟨k, -1⟩ ⟨y, by rw [← hkmul, ← Nat.cast_mul p, ← hy] <;> simp⟩
@@ -357,7 +357,7 @@ theorem sq_add_sq_of_nat_prime_of_not_irreducible (p : ℕ) [hp : Fact p.Prime]
(hpi : ¬Irreducible (p : ℤ[i])) : ∃ a b, a ^ 2 + b ^ 2 = p :=
have hpu : ¬IsUnit (p : ℤ[i]) :=
mt norm_eq_one_iff.2 <| by
- rw [norm_nat_cast, Int.natAbs_mul, Nat.mul_eq_one_iff] <;>
+ rw [norm_nat_cast, Int.natAbs_mul, mul_eq_one] <;>
exact fun h => (ne_of_lt hp.1.one_lt).symm h.1
have hab : ∃ a b, (p : ℤ[i]) = a * b ∧ ¬IsUnit a ∧ ¬IsUnit b := by
simpa [irreducible_iff, hpu, not_forall, not_or] using hpi
mathlib commit https://github.com/leanprover-community/mathlib/commit/02ba8949f486ebecf93fe7460f1ed0564b5e442c
@@ -310,7 +310,7 @@ theorem mod_four_eq_three_of_nat_prime_of_prime (p : ℕ) [hp : Fact p.Prime]
generalize p % 4 = m; decide!
let ⟨k, hk⟩ := ZMod.exists_sq_eq_neg_one_iff.2 <| by rw [hp41] <;> exact by decide
obtain ⟨k, k_lt_p, rfl⟩ : ∃ (k' : ℕ)(h : k' < p), (k' : ZMod p) = k := by
- refine' ⟨k.val, k.val_lt, ZMod.nat_cast_zMod_val k⟩
+ refine' ⟨k.val, k.val_lt, ZMod.nat_cast_zmod_val k⟩
have hpk : p ∣ k ^ 2 + 1 := by
rw [pow_two, ← CharP.cast_eq_zero_iff (ZMod p) p, Nat.cast_add, Nat.cast_mul, Nat.cast_one,
← hk, add_left_neg]
mathlib commit https://github.com/leanprover-community/mathlib/commit/2af0836443b4cfb5feda0df0051acdb398304931
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
! This file was ported from Lean 3 source module number_theory.zsqrtd.gaussian_int
-! leanprover-community/mathlib commit e1bccd6e40ae78370f01659715d3c948716e3b7e
+! leanprover-community/mathlib commit 2af0836443b4cfb5feda0df0051acdb398304931
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -44,6 +44,8 @@ and definitions about `zsqrtd` can easily be used.
open Zsqrtd Complex
+open ComplexConjugate
+
/-- The Gaussian integers, defined as `ℤ√(-1)`. -/
@[reducible]
def GaussianInt : Type :=
@@ -133,6 +135,13 @@ theorem to_complex_sub (x y : ℤ[i]) : ((x - y : ℤ[i]) : ℂ) = x - y :=
toComplex.map_sub _ _
#align gaussian_int.to_complex_sub GaussianInt.to_complex_sub
+@[simp]
+theorem to_complex_star (x : ℤ[i]) : ((star x : ℤ[i]) : ℂ) = conj (x : ℂ) :=
+ by
+ rw [to_complex_def₂, to_complex_def₂]
+ exact congr_arg₂ _ rfl (Int.cast_neg _)
+#align gaussian_int.to_complex_star GaussianInt.to_complex_star
+
@[simp]
theorem to_complex_inj {x y : ℤ[i]} : (x : ℂ) = y ↔ x = y := by
cases x <;> cases y <;> simp [to_complex_def₂]
@@ -182,11 +191,11 @@ theorem natAbs_norm_eq (x : ℤ[i]) :
instance : Div ℤ[i] :=
⟨fun x y =>
let n := (norm y : ℚ)⁻¹
- let c := y.conj
+ let c := star y
⟨round ((x * c).re * n : ℚ), round ((x * c).im * n : ℚ)⟩⟩
theorem div_def (x y : ℤ[i]) :
- x / y = ⟨round ((x * conj y).re / norm y : ℚ), round ((x * conj y).im / norm y : ℚ)⟩ :=
+ x / y = ⟨round ((x * star y).re / norm y : ℚ), round ((x * star y).im / norm y : ℚ)⟩ :=
show Zsqrtd.mk _ _ = _ by simp [div_eq_mul_inv]
#align gaussian_int.div_def GaussianInt.div_def
mathlib commit https://github.com/leanprover-community/mathlib/commit/ddec54a71a0dd025c05445d467f1a2b7d586a3ba
@@ -68,7 +68,7 @@ attribute [-instance] Complex.field
-- Avoid making things noncomputable unnecessarily.
/-- The embedding of the Gaussian integers into the complex numbers, as a ring homomorphism. -/
def toComplex : ℤ[i] →+* ℂ :=
- Zsqrtd.lift ⟨i, by simp⟩
+ Zsqrtd.lift ⟨I, by simp⟩
#align gaussian_int.to_complex GaussianInt.toComplex
end
@@ -76,11 +76,11 @@ end
instance : Coe ℤ[i] ℂ :=
⟨toComplex⟩
-theorem to_complex_def (x : ℤ[i]) : (x : ℂ) = x.re + x.im * i :=
+theorem to_complex_def (x : ℤ[i]) : (x : ℂ) = x.re + x.im * I :=
rfl
#align gaussian_int.to_complex_def GaussianInt.to_complex_def
-theorem to_complex_def' (x y : ℤ) : ((⟨x, y⟩ : ℤ[i]) : ℂ) = x + y * i := by simp [to_complex_def]
+theorem to_complex_def' (x y : ℤ) : ((⟨x, y⟩ : ℤ[i]) : ℂ) = x + y * I := by simp [to_complex_def]
#align gaussian_int.to_complex_def' GaussianInt.to_complex_def'
theorem to_complex_def₂ (x : ℤ[i]) : (x : ℂ) = ⟨x.re, x.im⟩ := by
@@ -212,10 +212,10 @@ theorem normSq_le_normSq_of_re_le_of_im_le {x y : ℂ} (hre : |x.re| ≤ |y.re|)
theorem normSq_div_sub_div_lt_one (x y : ℤ[i]) : ((x / y : ℂ) - ((x / y : ℤ[i]) : ℂ)).normSq < 1 :=
calc
((x / y : ℂ) - ((x / y : ℤ[i]) : ℂ)).normSq =
- ((x / y : ℂ).re - ((x / y : ℤ[i]) : ℂ).re + ((x / y : ℂ).im - ((x / y : ℤ[i]) : ℂ).im) * i :
+ ((x / y : ℂ).re - ((x / y : ℤ[i]) : ℂ).re + ((x / y : ℂ).im - ((x / y : ℤ[i]) : ℂ).im) * I :
ℂ).normSq :=
congr_arg _ <| by apply Complex.ext <;> simp
- _ ≤ (1 / 2 + 1 / 2 * i).normSq :=
+ _ ≤ (1 / 2 + 1 / 2 * I).normSq :=
(have : |(2⁻¹ : ℝ)| = 2⁻¹ := abs_of_nonneg (by norm_num)
normSq_le_normSq_of_re_le_of_im_le
(by
mathlib commit https://github.com/leanprover-community/mathlib/commit/4c586d291f189eecb9d00581aeb3dd998ac34442
@@ -216,14 +216,14 @@ theorem normSq_div_sub_div_lt_one (x y : ℤ[i]) : ((x / y : ℂ) - ((x / y :
ℂ).normSq :=
congr_arg _ <| by apply Complex.ext <;> simp
_ ≤ (1 / 2 + 1 / 2 * i).normSq :=
- have : |(2⁻¹ : ℝ)| = 2⁻¹ := abs_of_nonneg (by norm_num)
+ (have : |(2⁻¹ : ℝ)| = 2⁻¹ := abs_of_nonneg (by norm_num)
normSq_le_normSq_of_re_le_of_im_le
(by
rw [to_complex_div_re] <;> simp [norm_sq, this] <;>
simpa using abs_sub_round (x / y : ℂ).re)
(by
rw [to_complex_div_im] <;> simp [norm_sq, this] <;>
- simpa using abs_sub_round (x / y : ℂ).im)
+ simpa using abs_sub_round (x / y : ℂ).im))
_ < 1 := by simp [norm_sq] <;> norm_num
#align gaussian_int.norm_sq_div_sub_div_lt_one GaussianInt.normSq_div_sub_div_lt_one
@@ -243,7 +243,7 @@ theorem norm_mod_lt (x : ℤ[i]) {y : ℤ[i]} (hy : y ≠ 0) : (x % y).norm < y.
_ = (y : ℂ).normSq * (x / y - (x / y : ℤ[i]) : ℂ).normSq := by
rw [← norm_sq_mul, mul_sub, mul_div_cancel' _ this]
_ < (y : ℂ).normSq * 1 :=
- mul_lt_mul_of_pos_left (normSq_div_sub_div_lt_one _ _) (normSq_pos.2 this)
+ (mul_lt_mul_of_pos_left (normSq_div_sub_div_lt_one _ _) (normSq_pos.2 this))
_ = Zsqrtd.norm y := by simp
#align gaussian_int.norm_mod_lt GaussianInt.norm_mod_lt
mathlib commit https://github.com/leanprover-community/mathlib/commit/bd9851ca476957ea4549eb19b40e7b5ade9428cc
nat_cast
/int_cast
/rat_cast
to natCast
/intCast
/ratCast
(#11486)
Now that I am defining NNRat.cast
, I want a definitive answer to this naming issue. Plenty of lemmas in mathlib already use natCast
/intCast
/ratCast
over nat_cast
/int_cast
/rat_cast
, and this matches with the general expectation that underscore-separated name parts correspond to a single declaration.
@@ -149,14 +149,14 @@ theorem toComplex_eq_zero {x : ℤ[i]} : (x : ℂ) = 0 ↔ x = 0 := by
#align gaussian_int.to_complex_eq_zero GaussianInt.toComplex_eq_zero
@[simp]
-theorem int_cast_real_norm (x : ℤ[i]) : (x.norm : ℝ) = Complex.normSq (x : ℂ) := by
+theorem intCast_real_norm (x : ℤ[i]) : (x.norm : ℝ) = Complex.normSq (x : ℂ) := by
rw [Zsqrtd.norm, normSq]; simp
-#align gaussian_int.nat_cast_real_norm GaussianInt.int_cast_real_norm
+#align gaussian_int.nat_cast_real_norm GaussianInt.intCast_real_norm
@[simp]
-theorem int_cast_complex_norm (x : ℤ[i]) : (x.norm : ℂ) = Complex.normSq (x : ℂ) := by
+theorem intCast_complex_norm (x : ℤ[i]) : (x.norm : ℂ) = Complex.normSq (x : ℂ) := by
cases x; rw [Zsqrtd.norm, normSq]; simp
-#align gaussian_int.nat_cast_complex_norm GaussianInt.int_cast_complex_norm
+#align gaussian_int.nat_cast_complex_norm GaussianInt.intCast_complex_norm
theorem norm_nonneg (x : ℤ[i]) : 0 ≤ norm x :=
Zsqrtd.norm_nonneg (by norm_num) _
@@ -178,9 +178,9 @@ theorem abs_natCast_norm (x : ℤ[i]) : (x.norm.natAbs : ℤ) = x.norm :=
@[deprecated] alias abs_coe_nat_norm := abs_natCast_norm
@[simp]
-theorem nat_cast_natAbs_norm {α : Type*} [Ring α] (x : ℤ[i]) : (x.norm.natAbs : α) = x.norm := by
+theorem natCast_natAbs_norm {α : Type*} [Ring α] (x : ℤ[i]) : (x.norm.natAbs : α) = x.norm := by
rw [← Int.cast_natCast, abs_natCast_norm]
-#align gaussian_int.nat_cast_nat_abs_norm GaussianInt.nat_cast_natAbs_norm
+#align gaussian_int.nat_cast_nat_abs_norm GaussianInt.natCast_natAbs_norm
theorem natAbs_norm_eq (x : ℤ[i]) :
x.norm.natAbs = x.re.natAbs * x.re.natAbs + x.im.natAbs * x.im.natAbs :=
@@ -287,7 +287,7 @@ theorem sq_add_sq_of_nat_prime_of_not_irreducible (p : ℕ) [hp : Fact p.Prime]
(hpi : ¬Irreducible (p : ℤ[i])) : ∃ a b, a ^ 2 + b ^ 2 = p :=
have hpu : ¬IsUnit (p : ℤ[i]) :=
mt norm_eq_one_iff.2 <| by
- rw [norm_nat_cast, Int.natAbs_mul, mul_eq_one]
+ rw [norm_natCast, Int.natAbs_mul, mul_eq_one]
exact fun h => (ne_of_lt hp.1.one_lt).symm h.1
have hab : ∃ a b, (p : ℤ[i]) = a * b ∧ ¬IsUnit a ∧ ¬IsUnit b := by
-- Porting note: was
@@ -297,7 +297,7 @@ theorem sq_add_sq_of_nat_prime_of_not_irreducible (p : ℕ) [hp : Fact p.Prime]
let ⟨a, b, hpab, hau, hbu⟩ := hab
have hnap : (norm a).natAbs = p :=
((hp.1.mul_eq_prime_sq_iff (mt norm_eq_one_iff.1 hau) (mt norm_eq_one_iff.1 hbu)).1 <| by
- rw [← Int.natCast_inj, Int.coe_nat_pow, sq, ← @norm_nat_cast (-1), hpab]; simp).1
+ rw [← Int.natCast_inj, Int.coe_nat_pow, sq, ← @norm_natCast (-1), hpab]; simp).1
⟨a.re.natAbs, a.im.natAbs, by simpa [natAbs_norm_eq, sq] using hnap⟩
#align gaussian_int.sq_add_sq_of_nat_prime_of_not_irreducible GaussianInt.sq_add_sq_of_nat_prime_of_not_irreducible
@@ -170,13 +170,16 @@ theorem norm_pos {x : ℤ[i]} : 0 < norm x ↔ x ≠ 0 := by
rw [lt_iff_le_and_ne, Ne, eq_comm, norm_eq_zero]; simp [norm_nonneg]
#align gaussian_int.norm_pos GaussianInt.norm_pos
-theorem abs_coe_nat_norm (x : ℤ[i]) : (x.norm.natAbs : ℤ) = x.norm :=
+theorem abs_natCast_norm (x : ℤ[i]) : (x.norm.natAbs : ℤ) = x.norm :=
Int.natAbs_of_nonneg (norm_nonneg _)
-#align gaussian_int.abs_coe_nat_norm GaussianInt.abs_coe_nat_norm
+#align gaussian_int.abs_coe_nat_norm GaussianInt.abs_natCast_norm
+
+-- 2024-04-05
+@[deprecated] alias abs_coe_nat_norm := abs_natCast_norm
@[simp]
theorem nat_cast_natAbs_norm {α : Type*} [Ring α] (x : ℤ[i]) : (x.norm.natAbs : α) = x.norm := by
- rw [← Int.cast_natCast, abs_coe_nat_norm]
+ rw [← Int.cast_natCast, abs_natCast_norm]
#align gaussian_int.nat_cast_nat_abs_norm GaussianInt.nat_cast_natAbs_norm
theorem natAbs_norm_eq (x : ℤ[i]) :
@@ -258,7 +261,7 @@ theorem norm_le_norm_mul_left (x : ℤ[i]) {y : ℤ[i]} (hy : y ≠ 0) :
(norm x).natAbs ≤ (norm (x * y)).natAbs := by
rw [Zsqrtd.norm_mul, Int.natAbs_mul]
exact le_mul_of_one_le_right (Nat.zero_le _) (Int.ofNat_le.1 (by
- rw [abs_coe_nat_norm]
+ rw [abs_natCast_norm]
exact Int.add_one_le_of_lt (norm_pos.2 hy)))
#align gaussian_int.norm_le_norm_mul_left GaussianInt.norm_le_norm_mul_left
OfNat
and Nat.cast
lemmas (#11861)
This renames
Int.cast_ofNat
to Int.cast_natCast
Int.int_cast_ofNat
to Int.cast_ofNat
I think the history here is that this lemma was previously about Int.ofNat
, before we globally fixed the simp-normal form to be Nat.cast
.
Since the Int.cast_ofNat
name is repurposed, it can't be deprecated. Int.int_cast_ofNat
is such a wonky name that it was probably never used.
@@ -176,7 +176,7 @@ theorem abs_coe_nat_norm (x : ℤ[i]) : (x.norm.natAbs : ℤ) = x.norm :=
@[simp]
theorem nat_cast_natAbs_norm {α : Type*} [Ring α] (x : ℤ[i]) : (x.norm.natAbs : α) = x.norm := by
- rw [← Int.cast_ofNat, abs_coe_nat_norm]
+ rw [← Int.cast_natCast, abs_coe_nat_norm]
#align gaussian_int.nat_cast_nat_abs_norm GaussianInt.nat_cast_natAbs_norm
theorem natAbs_norm_eq (x : ℤ[i]) :
coe_nat
to natCast
(#11637)
Reduce the diff of #11499
All in the Int
namespace:
ofNat_eq_cast
→ ofNat_eq_natCast
cast_eq_cast_iff_Nat
→ natCast_inj
natCast_eq_ofNat
→ ofNat_eq_natCast
coe_nat_sub
→ natCast_sub
coe_nat_nonneg
→ natCast_nonneg
sign_coe_add_one
→ sign_natCast_add_one
nat_succ_eq_int_succ
→ natCast_succ
succ_neg_nat_succ
→ succ_neg_natCast_succ
coe_pred_of_pos
→ natCast_pred_of_pos
coe_nat_div
→ natCast_div
coe_nat_ediv
→ natCast_ediv
sign_coe_nat_of_nonzero
→ sign_natCast_of_ne_zero
toNat_coe_nat
→ toNat_natCast
toNat_coe_nat_add_one
→ toNat_natCast_add_one
coe_nat_dvd
→ natCast_dvd_natCast
coe_nat_dvd_left
→ natCast_dvd
coe_nat_dvd_right
→ dvd_natCast
le_coe_nat_sub
→ le_natCast_sub
succ_coe_nat_pos
→ succ_natCast_pos
coe_nat_modEq_iff
→ natCast_modEq_iff
coe_natAbs
→ natCast_natAbs
coe_nat_eq_zero
→ natCast_eq_zero
coe_nat_ne_zero
→ natCast_ne_zero
coe_nat_ne_zero_iff_pos
→ natCast_ne_zero_iff_pos
abs_coe_nat
→ abs_natCast
coe_nat_nonpos_iff
→ natCast_nonpos_iff
Also rename Nat.coe_nat_dvd
to Nat.cast_dvd_cast
@@ -294,7 +294,7 @@ theorem sq_add_sq_of_nat_prime_of_not_irreducible (p : ℕ) [hp : Fact p.Prime]
let ⟨a, b, hpab, hau, hbu⟩ := hab
have hnap : (norm a).natAbs = p :=
((hp.1.mul_eq_prime_sq_iff (mt norm_eq_one_iff.1 hau) (mt norm_eq_one_iff.1 hbu)).1 <| by
- rw [← Int.coe_nat_inj', Int.coe_nat_pow, sq, ← @norm_nat_cast (-1), hpab]; simp).1
+ rw [← Int.natCast_inj, Int.coe_nat_pow, sq, ← @norm_nat_cast (-1), hpab]; simp).1
⟨a.re.natAbs, a.im.natAbs, by simpa [natAbs_norm_eq, sq] using hnap⟩
#align gaussian_int.sq_add_sq_of_nat_prime_of_not_irreducible GaussianInt.sq_add_sq_of_nat_prime_of_not_irreducible
@@ -167,7 +167,7 @@ theorem norm_eq_zero {x : ℤ[i]} : norm x = 0 ↔ x = 0 := by rw [← @Int.cast
#align gaussian_int.norm_eq_zero GaussianInt.norm_eq_zero
theorem norm_pos {x : ℤ[i]} : 0 < norm x ↔ x ≠ 0 := by
- rw [lt_iff_le_and_ne, Ne.def, eq_comm, norm_eq_zero]; simp [norm_nonneg]
+ rw [lt_iff_le_and_ne, Ne, eq_comm, norm_eq_zero]; simp [norm_nonneg]
#align gaussian_int.norm_pos GaussianInt.norm_pos
theorem abs_coe_nat_norm (x : ℤ[i]) : (x.norm.natAbs : ℤ) = x.norm :=
@@ -238,7 +238,7 @@ theorem mod_def (x y : ℤ[i]) : x % y = x - y * (x / y) :=
#align gaussian_int.mod_def GaussianInt.mod_def
theorem norm_mod_lt (x : ℤ[i]) {y : ℤ[i]} (hy : y ≠ 0) : (x % y).norm < y.norm :=
- have : (y : ℂ) ≠ 0 := by rwa [Ne.def, ← toComplex_zero, toComplex_inj]
+ have : (y : ℂ) ≠ 0 := by rwa [Ne, ← toComplex_zero, toComplex_inj]
(@Int.cast_lt ℝ _ _ _ _).1 <|
calc
↑(Zsqrtd.norm (x % y)) = Complex.normSq (x - y * (x / y : ℤ[i]) : ℂ) := by simp [mod_def]
mul
-div
cancellation lemmas (#11530)
Lemma names around cancellation of multiplication and division are a mess.
This PR renames a handful of them according to the following table (each big row contains the multiplicative statement, then the three rows contain the GroupWithZero
lemma name, the Group
lemma, the AddGroup
lemma name).
| Statement | New name | Old name | |
@@ -243,7 +243,7 @@ theorem norm_mod_lt (x : ℤ[i]) {y : ℤ[i]} (hy : y ≠ 0) : (x % y).norm < y.
calc
↑(Zsqrtd.norm (x % y)) = Complex.normSq (x - y * (x / y : ℤ[i]) : ℂ) := by simp [mod_def]
_ = Complex.normSq (y : ℂ) * Complex.normSq (x / y - (x / y : ℤ[i]) : ℂ) := by
- rw [← normSq_mul, mul_sub, mul_div_cancel' _ this]
+ rw [← normSq_mul, mul_sub, mul_div_cancel₀ _ this]
_ < Complex.normSq (y : ℂ) * 1 :=
(mul_lt_mul_of_pos_left (normSq_div_sub_div_lt_one _ _) (normSq_pos.2 this))
_ = Zsqrtd.norm y := by simp
@@ -102,32 +102,32 @@ theorem toComplex_re (x y : ℤ) : ((⟨x, y⟩ : ℤ[i]) : ℂ).re = x := by si
theorem toComplex_im (x y : ℤ) : ((⟨x, y⟩ : ℤ[i]) : ℂ).im = y := by simp [toComplex_def]
#align gaussian_int.to_complex_im GaussianInt.toComplex_im
--- Porting note: @[simp] can prove this
+-- Porting note (#10618): @[simp] can prove this
theorem toComplex_add (x y : ℤ[i]) : ((x + y : ℤ[i]) : ℂ) = x + y :=
toComplex.map_add _ _
#align gaussian_int.to_complex_add GaussianInt.toComplex_add
--- Porting note: @[simp] can prove this
+-- Porting note (#10618): @[simp] can prove this
theorem toComplex_mul (x y : ℤ[i]) : ((x * y : ℤ[i]) : ℂ) = x * y :=
toComplex.map_mul _ _
#align gaussian_int.to_complex_mul GaussianInt.toComplex_mul
--- Porting note: @[simp] can prove this
+-- Porting note (#10618): @[simp] can prove this
theorem toComplex_one : ((1 : ℤ[i]) : ℂ) = 1 :=
toComplex.map_one
#align gaussian_int.to_complex_one GaussianInt.toComplex_one
--- Porting note: @[simp] can prove this
+-- Porting note (#10618): @[simp] can prove this
theorem toComplex_zero : ((0 : ℤ[i]) : ℂ) = 0 :=
toComplex.map_zero
#align gaussian_int.to_complex_zero GaussianInt.toComplex_zero
--- Porting note: @[simp] can prove this
+-- Porting note (#10618): @[simp] can prove this
theorem toComplex_neg (x : ℤ[i]) : ((-x : ℤ[i]) : ℂ) = -x :=
toComplex.map_neg _
#align gaussian_int.to_complex_neg GaussianInt.toComplex_neg
--- Porting note: @[simp] can prove this
+-- Porting note (#10618): @[simp] can prove this
theorem toComplex_sub (x y : ℤ[i]) : ((x - y : ℤ[i]) : ℂ) = x - y :=
toComplex.map_sub _ _
#align gaussian_int.to_complex_sub GaussianInt.toComplex_sub
@@ -4,8 +4,9 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
-/
import Mathlib.NumberTheory.Zsqrtd.Basic
-import Mathlib.Data.Complex.Abs
import Mathlib.RingTheory.PrincipalIdealDomain
+import Mathlib.Data.Complex.Basic
+import Mathlib.Data.Real.Archimedean
#align_import number_theory.zsqrtd.gaussian_int from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9"
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
-/
import Mathlib.NumberTheory.Zsqrtd.Basic
-import Mathlib.Data.Complex.Basic
+import Mathlib.Data.Complex.Abs
import Mathlib.RingTheory.PrincipalIdealDomain
#align_import number_theory.zsqrtd.gaussian_int from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9"
Type _
and Sort _
(#6499)
We remove all possible occurences of Type _
and Sort _
in favor of Type*
and Sort*
.
This has nice performance benefits.
@@ -174,7 +174,7 @@ theorem abs_coe_nat_norm (x : ℤ[i]) : (x.norm.natAbs : ℤ) = x.norm :=
#align gaussian_int.abs_coe_nat_norm GaussianInt.abs_coe_nat_norm
@[simp]
-theorem nat_cast_natAbs_norm {α : Type _} [Ring α] (x : ℤ[i]) : (x.norm.natAbs : α) = x.norm := by
+theorem nat_cast_natAbs_norm {α : Type*} [Ring α] (x : ℤ[i]) : (x.norm.natAbs : α) = x.norm := by
rw [← Int.cast_ofNat, abs_coe_nat_norm]
#align gaussian_int.nat_cast_nat_abs_norm GaussianInt.nat_cast_natAbs_norm
@@ -2,16 +2,13 @@
Copyright (c) 2019 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
-
-! This file was ported from Lean 3 source module number_theory.zsqrtd.gaussian_int
-! leanprover-community/mathlib commit 5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.NumberTheory.Zsqrtd.Basic
import Mathlib.Data.Complex.Basic
import Mathlib.RingTheory.PrincipalIdealDomain
+#align_import number_theory.zsqrtd.gaussian_int from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9"
+
/-!
# Gaussian integers
@@ -26,7 +26,7 @@ The homomorphism `GaussianInt.toComplex` into the complex numbers is also define
## See also
-See `number_theory.zsqrtd.gaussian_int` for:
+See `NumberTheory.Zsqrtd.QuadraticReciprocity` for:
* `prime_iff_mod_four_eq_three_of_nat_prime`:
A prime natural number is prime in `ℤ[i]` if and only if it is `3` mod `4`
The unported dependencies are
algebra.order.module
init.core
algebra.order.monoid.cancel.defs
algebra.abs
algebra.group_power.lemmas
init.data.list.basic
algebra.order.monoid.cancel.basic
init.data.list.default
topology.subset_properties
init.logic
The following 1 dependencies have changed in mathlib3 since they were ported, which may complicate porting this file