number_theory.number_field.embeddingsMathlib.NumberTheory.NumberField.Embeddings

This file has been ported!

Changes since the initial port

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.

Changes in mathlib3

(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)

(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)

(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)

(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)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -603,7 +603,7 @@ theorem prod_eq_abs_norm (x : K) :
               (congr_fun (congr_arg coeFn (Finset.mem_filter.1 hφ).2) x),
           Finset.prod_const, mk_complex.filter_card K w]
         rfl
-  · rw [eq_ratCast, ← Complex.abs_ofReal, Complex.ofReal_rat_cast]
+  · rw [eq_ratCast, ← Complex.abs_ofReal, Complex.ofReal_ratCast]
 #align number_field.infinite_place.prod_eq_abs_norm NumberField.InfinitePlace.prod_eq_abs_norm
 -/
 
Diff
@@ -100,7 +100,7 @@ theorem coeff_bdd_of_norm_le {B : ℝ} {x : K} (h : ∀ φ : K →+* A, ‖φ x
     coeff_bdd_of_roots_le _ (minpoly.monic hx) (IsAlgClosed.splits_codomain _)
       (minpoly.natDegree_le hx) (fun z hz => _) i
   classical
-  rw [← Multiset.mem_toFinset] at hz 
+  rw [← Multiset.mem_toFinset] at hz
   obtain ⟨φ, rfl⟩ := (range_eval_eq_root_set_minpoly K A x).symm.Subset hz
   exact h φ
 #align number_field.embeddings.coeff_bdd_of_norm_le NumberField.Embeddings.coeff_bdd_of_norm_le
@@ -137,10 +137,10 @@ theorem pow_eq_one_of_norm_eq_one {x : K} (hxi : IsIntegral ℤ x) (hx : ∀ φ
   · wlog hlt : b < a
     · exact this hxi hx b a habne.symm h.symm (habne.lt_or_lt.resolve_right hlt)
     refine' ⟨a - b, tsub_pos_of_lt hlt, _⟩
-    rw [← Nat.sub_add_cancel hlt.le, pow_add, mul_left_eq_self₀] at h 
+    rw [← Nat.sub_add_cancel hlt.le, pow_add, mul_left_eq_self₀] at h
     refine' h.resolve_right fun hp => _
     specialize hx (IsAlgClosed.lift (NumberField.isAlgebraic K)).toRingHom
-    rw [pow_eq_zero hp, map_zero, norm_zero] at hx ; norm_num at hx 
+    rw [pow_eq_zero hp, map_zero, norm_zero] at hx; norm_num at hx
   · exact fun a _ => ⟨hxi.pow a, fun φ => by simp only [hx φ, norm_pow, one_pow, map_pow]⟩
 #align number_field.embeddings.pow_eq_one_of_norm_eq_one NumberField.Embeddings.pow_eq_one_of_norm_eq_one
 -/
@@ -232,7 +232,7 @@ theorem IsReal.coe_embedding_apply {φ : K →+* ℂ} (hφ : IsReal φ) (x : K)
     (hφ.Embedding x : ℂ) = φ x := by
   ext; · rfl
   · rw [of_real_im, eq_comm, ← Complex.conj_eq_iff_im]
-    rw [is_real] at hφ 
+    rw [is_real] at hφ
     exact RingHom.congr_fun hφ x
 #align number_field.complex_embedding.is_real.coe_embedding_apply NumberField.ComplexEmbedding.IsReal.coe_embedding_apply
 -/
@@ -407,7 +407,7 @@ theorem NumberField.InfinitePlace.embedding_mk_eq_of_isReal {φ : K →+* ℂ}
     (h : ComplexEmbedding.IsReal φ) : embedding (mk φ) = φ :=
   by
   have := mk_eq_iff.mp (mk_embedding (mk φ)).symm
-  rwa [complex_embedding.is_real_iff.mp h, or_self_iff, eq_comm] at this 
+  rwa [complex_embedding.is_real_iff.mp h, or_self_iff, eq_comm] at this
 #align number_field.complex_embeddings.is_real.embedding_mk NumberField.InfinitePlace.embedding_mk_eq_of_isReal
 -/
 
@@ -430,7 +430,7 @@ theorem isComplex_iff {w : InfinitePlace K} :
     contrapose! hφ
     cases mk_eq_iff.mp (mk_embedding (mk φ))
     · rwa [← h]
-    · rw [← complex_embedding.is_real_conjugate_iff] at hφ 
+    · rw [← complex_embedding.is_real_conjugate_iff] at hφ
       rwa [← h]
   · exact fun h => ⟨Embedding w, h, mk_embedding w⟩
 #align number_field.infinite_place.is_complex_iff NumberField.InfinitePlace.isComplex_iff
Diff
@@ -100,6 +100,9 @@ theorem coeff_bdd_of_norm_le {B : ℝ} {x : K} (h : ∀ φ : K →+* A, ‖φ x
     coeff_bdd_of_roots_le _ (minpoly.monic hx) (IsAlgClosed.splits_codomain _)
       (minpoly.natDegree_le hx) (fun z hz => _) i
   classical
+  rw [← Multiset.mem_toFinset] at hz 
+  obtain ⟨φ, rfl⟩ := (range_eval_eq_root_set_minpoly K A x).symm.Subset hz
+  exact h φ
 #align number_field.embeddings.coeff_bdd_of_norm_le NumberField.Embeddings.coeff_bdd_of_norm_le
 -/
 
Diff
@@ -100,9 +100,6 @@ theorem coeff_bdd_of_norm_le {B : ℝ} {x : K} (h : ∀ φ : K →+* A, ‖φ x
     coeff_bdd_of_roots_le _ (minpoly.monic hx) (IsAlgClosed.splits_codomain _)
       (minpoly.natDegree_le hx) (fun z hz => _) i
   classical
-  rw [← Multiset.mem_toFinset] at hz 
-  obtain ⟨φ, rfl⟩ := (range_eval_eq_root_set_minpoly K A x).symm.Subset hz
-  exact h φ
 #align number_field.embeddings.coeff_bdd_of_norm_le NumberField.Embeddings.coeff_bdd_of_norm_le
 -/
 
Diff
@@ -556,7 +556,7 @@ theorem mkComplex.filter_card (w : { w : InfinitePlace K // w.IsComplex }) :
   by
   rw [mk_complex.filter]
   exact
-    Finset.card_doubleton
+    Finset.card_pair
       (subtype.mk_eq_mk.not.2 <|
         ne_comm.1 <| complex_embedding.is_real_iff.not.1 <| is_complex_iff.1 w.2)
 #align number_field.infinite_place.mk_complex.filter_card NumberField.InfinitePlace.mkComplex.filter_card
Diff
@@ -443,10 +443,12 @@ theorem not_isReal_iff_isComplex {w : InfinitePlace K} : ¬IsReal w ↔ IsComple
 #align number_field.infinite_place.not_is_real_iff_is_complex NumberField.InfinitePlace.not_isReal_iff_isComplex
 -/
 
+#print NumberField.InfinitePlace.not_isComplex_iff_isReal /-
 @[simp]
 theorem not_isComplex_iff_isReal {w : InfinitePlace K} : ¬IsComplex w ↔ IsReal w := by
   rw [← not_is_real_iff_is_complex, Classical.not_not]
 #align number_field.infinite_place.not_is_complex_iff_is_real NumberField.InfinitePlace.not_isComplex_iff_isReal
+-/
 
 #print NumberField.InfinitePlace.isReal_or_isComplex /-
 theorem isReal_or_isComplex (w : InfinitePlace K) : IsReal w ∨ IsComplex w := by
Diff
@@ -119,7 +119,7 @@ theorem finite_of_norm_le (B : ℝ) : {x : K | IsIntegral ℤ x ∧ ∀ φ : K 
   have h_map_ℚ_minpoly := minpoly.isIntegrallyClosed_eq_field_fractions' ℚ hx.1
   refine' ⟨_, ⟨_, fun i => _⟩, mem_root_set.2 ⟨minpoly.ne_zero hx.1, minpoly.aeval ℤ x⟩⟩
   · rw [← (minpoly.monic hx.1).natDegree_map (algebraMap ℤ ℚ), ← h_map_ℚ_minpoly]
-    exact minpoly.natDegree_le (isIntegral_of_isScalarTower hx.1)
+    exact minpoly.natDegree_le (IsIntegral.tower_top hx.1)
   rw [mem_Icc, ← abs_le, ← @Int.cast_le ℝ]
   refine' (Eq.trans_le _ <| coeff_bdd_of_norm_le hx.2 i).trans (Nat.le_ceil _)
   rw [h_map_ℚ_minpoly, coeff_map, eq_intCast, Int.norm_cast_rat, Int.norm_eq_abs, Int.cast_abs]
Diff
@@ -3,11 +3,11 @@ Copyright (c) 2022 Xavier Roblot. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alex J. Best, Xavier Roblot
 -/
-import Mathbin.Analysis.Complex.Polynomial
-import Mathbin.FieldTheory.Minpoly.IsIntegrallyClosed
-import Mathbin.NumberTheory.NumberField.Basic
-import Mathbin.RingTheory.Norm
-import Mathbin.Topology.Instances.Complex
+import Analysis.Complex.Polynomial
+import FieldTheory.Minpoly.IsIntegrallyClosed
+import NumberTheory.NumberField.Basic
+import RingTheory.Norm
+import Topology.Instances.Complex
 
 #align_import number_theory.number_field.embeddings from "leanprover-community/mathlib"@"5d0c76894ada7940957143163d7b921345474cbc"
 
Diff
@@ -285,7 +285,7 @@ instance : MonoidWithZeroHomClass (InfinitePlace K) K ℝ
     where
   coe w x := w.1 x
   coe_injective' _ _ h := Subtype.eq (AbsoluteValue.ext fun x => congr_fun h x)
-  map_mul w _ _ := w.1.map_mul _ _
+  map_hMul w _ _ := w.1.map_hMul _ _
   map_one w := w.1.map_one
   map_zero w := w.1.map_zero
 
Diff
@@ -237,12 +237,10 @@ theorem IsReal.coe_embedding_apply {φ : K →+* ℂ} (hφ : IsReal φ) (x : K)
 #align number_field.complex_embedding.is_real.coe_embedding_apply NumberField.ComplexEmbedding.IsReal.coe_embedding_apply
 -/
 
-#print NumberField.ComplexEmbedding.IsReal.place_embedding /-
 theorem IsReal.place_embedding {φ : K →+* ℂ} (hφ : IsReal φ) : place hφ.Embedding = place φ := by
   ext x;
   simp only [place_apply, Real.norm_eq_abs, ← abs_of_real, norm_eq_abs, hφ.coe_embedding_apply x]
 #align number_field.complex_embedding.is_real.place_embedding NumberField.ComplexEmbedding.IsReal.place_embedding
--/
 
 #print NumberField.ComplexEmbedding.isReal_conjugate_iff /-
 theorem isReal_conjugate_iff {φ : K →+* ℂ} : IsReal (conjugate φ) ↔ IsReal φ :=
@@ -297,11 +295,9 @@ instance : NonnegHomClass (InfinitePlace K) K ℝ
   coe_injective' _ _ h := Subtype.eq (AbsoluteValue.ext fun x => congr_fun h x)
   map_nonneg w x := w.1.NonNeg _
 
-#print NumberField.InfinitePlace.coe_mk /-
 theorem coe_mk (φ : K →+* ℂ) : ⇑(mk φ) = place φ :=
   rfl
 #align number_field.infinite_place.coe_mk NumberField.InfinitePlace.coe_mk
--/
 
 #print NumberField.InfinitePlace.apply /-
 theorem apply (φ : K →+* ℂ) (x : K) : (mk φ) x = Complex.abs (φ x) :=
@@ -323,12 +319,10 @@ theorem mk_embedding (w : InfinitePlace K) : mk (embedding w) = w :=
 #align number_field.infinite_place.mk_embedding NumberField.InfinitePlace.mk_embedding
 -/
 
-#print NumberField.InfinitePlace.abs_embedding /-
 @[simp]
 theorem abs_embedding (w : InfinitePlace K) (x : K) : Complex.abs (embedding w x) = w x :=
   congr_fun (congr_arg coeFn w.2.choose_spec) x
 #align number_field.infinite_place.abs_embedding NumberField.InfinitePlace.abs_embedding
--/
 
 #print NumberField.InfinitePlace.eq_iff_eq /-
 theorem eq_iff_eq (x : K) (r : ℝ) : (∀ w : InfinitePlace K, w x = r) ↔ ∀ φ : K →+* ℂ, ‖φ x‖ = r :=
@@ -407,14 +401,14 @@ def IsComplex (w : InfinitePlace K) : Prop :=
 #align number_field.infinite_place.is_complex NumberField.InfinitePlace.IsComplex
 -/
 
-#print NumberField.ComplexEmbeddings.IsReal.embedding_mk /-
+#print NumberField.InfinitePlace.embedding_mk_eq_of_isReal /-
 @[simp]
-theorem NumberField.ComplexEmbeddings.IsReal.embedding_mk {φ : K →+* ℂ}
+theorem NumberField.InfinitePlace.embedding_mk_eq_of_isReal {φ : K →+* ℂ}
     (h : ComplexEmbedding.IsReal φ) : embedding (mk φ) = φ :=
   by
   have := mk_eq_iff.mp (mk_embedding (mk φ)).symm
   rwa [complex_embedding.is_real_iff.mp h, or_self_iff, eq_comm] at this 
-#align number_field.complex_embeddings.is_real.embedding_mk NumberField.ComplexEmbeddings.IsReal.embedding_mk
+#align number_field.complex_embeddings.is_real.embedding_mk NumberField.InfinitePlace.embedding_mk_eq_of_isReal
 -/
 
 #print NumberField.InfinitePlace.isReal_iff /-
@@ -449,12 +443,10 @@ theorem not_isReal_iff_isComplex {w : InfinitePlace K} : ¬IsReal w ↔ IsComple
 #align number_field.infinite_place.not_is_real_iff_is_complex NumberField.InfinitePlace.not_isReal_iff_isComplex
 -/
 
-#print NumberField.InfinitePlace.not_isComplex_iff_isReal /-
 @[simp]
 theorem not_isComplex_iff_isReal {w : InfinitePlace K} : ¬IsComplex w ↔ IsReal w := by
   rw [← not_is_real_iff_is_complex, Classical.not_not]
 #align number_field.infinite_place.not_is_complex_iff_is_real NumberField.InfinitePlace.not_isComplex_iff_isReal
--/
 
 #print NumberField.InfinitePlace.isReal_or_isComplex /-
 theorem isReal_or_isComplex (w : InfinitePlace K) : IsReal w ∨ IsComplex w := by
@@ -462,29 +454,27 @@ theorem isReal_or_isComplex (w : InfinitePlace K) : IsReal w ∨ IsComplex w :=
 #align number_field.infinite_place.is_real_or_is_complex NumberField.InfinitePlace.isReal_or_isComplex
 -/
 
-#print NumberField.InfinitePlace.IsReal.embedding /-
+#print NumberField.InfinitePlace.embedding_of_isReal /-
 /-- For `w` a real infinite place, return the corresponding embedding as a morphism `K →+* ℝ`. -/
-noncomputable def IsReal.embedding {w : InfinitePlace K} (hw : IsReal w) : K →+* ℝ :=
+noncomputable def NumberField.InfinitePlace.embedding_of_isReal {w : InfinitePlace K}
+    (hw : IsReal w) : K →+* ℝ :=
   (isReal_iff.mp hw).Embedding
-#align number_field.infinite_place.is_real.embedding NumberField.InfinitePlace.IsReal.embedding
+#align number_field.infinite_place.is_real.embedding NumberField.InfinitePlace.embedding_of_isReal
 -/
 
-#print NumberField.InfinitePlace.IsReal.place_embedding_apply /-
 @[simp]
-theorem IsReal.place_embedding_apply {w : InfinitePlace K} (hw : IsReal w) (x : K) :
-    place (IsReal.embedding hw) x = w x :=
+theorem IsReal.place_embedding_of_isReal_apply {w : InfinitePlace K} (hw : IsReal w) (x : K) :
+    place (NumberField.InfinitePlace.embedding_of_isReal hw) x = w x :=
   by
   rw [is_real.embedding, complex_embedding.is_real.place_embedding, ← coe_mk]
   exact congr_fun (congr_arg coeFn (mk_embedding w)) x
-#align number_field.infinite_place.is_real.place_embedding_apply NumberField.InfinitePlace.IsReal.place_embedding_apply
--/
+#align number_field.infinite_place.is_real.place_embedding_apply NumberField.InfinitePlace.IsReal.place_embedding_of_isReal_apply
 
-#print NumberField.InfinitePlace.IsReal.abs_embedding_apply /-
 @[simp]
-theorem IsReal.abs_embedding_apply {w : InfinitePlace K} (hw : IsReal w) (x : K) :
-    |IsReal.embedding hw x| = w x := by rw [← is_real.place_embedding_apply hw x]; congr
-#align number_field.infinite_place.is_real.abs_embedding_apply NumberField.InfinitePlace.IsReal.abs_embedding_apply
--/
+theorem IsReal.abs_embedding_of_isReal_apply {w : InfinitePlace K} (hw : IsReal w) (x : K) :
+    |NumberField.InfinitePlace.embedding_of_isReal hw x| = w x := by
+  rw [← is_real.place_embedding_apply hw x]; congr
+#align number_field.infinite_place.is_real.abs_embedding_apply NumberField.InfinitePlace.IsReal.abs_embedding_of_isReal_apply
 
 variable (K)
 
@@ -495,7 +485,7 @@ noncomputable def mkReal :
     where
   toFun := Subtype.map mk fun φ hφ => ⟨φ, hφ, rfl⟩
   invFun w := ⟨w.1.Embedding, isReal_iff.1 w.2⟩
-  left_inv φ := Subtype.ext_iff.2 (NumberField.ComplexEmbeddings.IsReal.embedding_mk φ.2)
+  left_inv φ := Subtype.ext_iff.2 (NumberField.InfinitePlace.embedding_mk_eq_of_isReal φ.2)
   right_inv w := Subtype.ext_iff.2 (mk_embedding w.1)
 #align number_field.infinite_place.mk_real NumberField.InfinitePlace.mkReal
 -/
@@ -508,7 +498,6 @@ noncomputable def mkComplex :
 #align number_field.infinite_place.mk_complex NumberField.InfinitePlace.mkComplex
 -/
 
-#print NumberField.InfinitePlace.mkComplex_embedding /-
 theorem mkComplex_embedding (φ : { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ }) :
     (mkComplex K φ : InfinitePlace K).Embedding = φ ∨
       (mkComplex K φ : InfinitePlace K).Embedding = ComplexEmbedding.conjugate φ :=
@@ -516,7 +505,6 @@ theorem mkComplex_embedding (φ : { φ : K →+* ℂ // ¬ComplexEmbedding.IsRea
   rw [@eq_comm _ _ ↑φ, @eq_comm _ _ (complex_embedding.conjugate ↑φ), ← mk_eq_iff, mk_embedding]
   rfl
 #align number_field.infinite_place.mk_complex_embedding NumberField.InfinitePlace.mkComplex_embedding
--/
 
 #print NumberField.InfinitePlace.mkReal_coe /-
 @[simp]
@@ -534,25 +522,20 @@ theorem mkComplex_coe (φ : { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ }
 #align number_field.infinite_place.mk_complex_coe NumberField.InfinitePlace.mkComplex_coe
 -/
 
-#print NumberField.InfinitePlace.mkReal.apply /-
 @[simp]
 theorem mkReal.apply (φ : { φ : K →+* ℂ // ComplexEmbedding.IsReal φ }) (x : K) :
     mkReal K φ x = Complex.abs (φ x) :=
   apply φ x
 #align number_field.infinite_place.mk_real.apply NumberField.InfinitePlace.mkReal.apply
--/
 
-#print NumberField.InfinitePlace.mkComplex.apply /-
 @[simp]
 theorem mkComplex.apply (φ : { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ }) (x : K) :
     mkComplex K φ x = Complex.abs (φ x) :=
   apply φ x
 #align number_field.infinite_place.mk_complex.apply NumberField.InfinitePlace.mkComplex.apply
--/
 
 variable [NumberField K]
 
-#print NumberField.InfinitePlace.mkComplex.filter /-
 theorem mkComplex.filter (w : { w : InfinitePlace K // w.IsComplex }) :
     (Finset.univ.filterₓ fun φ => mkComplex K φ = w) =
       {⟨w.1.Embedding, isComplex_iff.1 w.2⟩,
@@ -565,9 +548,7 @@ theorem mkComplex.filter (w : { w : InfinitePlace K // w.IsComplex }) :
     mk_eq_iff, mk_embedding, @eq_comm _ _ w.val]
   simpa only [Finset.mem_univ, true_and_iff]
 #align number_field.infinite_place.mk_complex.filter NumberField.InfinitePlace.mkComplex.filter
--/
 
-#print NumberField.InfinitePlace.mkComplex.filter_card /-
 theorem mkComplex.filter_card (w : { w : InfinitePlace K // w.IsComplex }) :
     (Finset.univ.filterₓ fun φ => mkComplex K φ = w).card = 2 :=
   by
@@ -577,7 +558,6 @@ theorem mkComplex.filter_card (w : { w : InfinitePlace K // w.IsComplex }) :
       (subtype.mk_eq_mk.not.2 <|
         ne_comm.1 <| complex_embedding.is_real_iff.not.1 <| is_complex_iff.1 w.2)
 #align number_field.infinite_place.mk_complex.filter_card NumberField.InfinitePlace.mkComplex.filter_card
--/
 
 #print NumberField.InfinitePlace.NumberField.InfinitePlace.fintype /-
 noncomputable instance NumberField.InfinitePlace.fintype : Fintype (InfinitePlace K) :=
Diff
@@ -98,7 +98,7 @@ theorem coeff_bdd_of_norm_le {B : ℝ} {x : K} (h : ∀ φ : K →+* A, ‖φ x
   rw [← norm_algebraMap' A, ← coeff_map (algebraMap ℚ A)]
   refine'
     coeff_bdd_of_roots_le _ (minpoly.monic hx) (IsAlgClosed.splits_codomain _)
-      (IntermediateField.minpoly.natDegree_le hx) (fun z hz => _) i
+      (minpoly.natDegree_le hx) (fun z hz => _) i
   classical
   rw [← Multiset.mem_toFinset] at hz 
   obtain ⟨φ, rfl⟩ := (range_eval_eq_root_set_minpoly K A x).symm.Subset hz
@@ -119,7 +119,7 @@ theorem finite_of_norm_le (B : ℝ) : {x : K | IsIntegral ℤ x ∧ ∀ φ : K 
   have h_map_ℚ_minpoly := minpoly.isIntegrallyClosed_eq_field_fractions' ℚ hx.1
   refine' ⟨_, ⟨_, fun i => _⟩, mem_root_set.2 ⟨minpoly.ne_zero hx.1, minpoly.aeval ℤ x⟩⟩
   · rw [← (minpoly.monic hx.1).natDegree_map (algebraMap ℤ ℚ), ← h_map_ℚ_minpoly]
-    exact IntermediateField.minpoly.natDegree_le (isIntegral_of_isScalarTower hx.1)
+    exact minpoly.natDegree_le (isIntegral_of_isScalarTower hx.1)
   rw [mem_Icc, ← abs_le, ← @Int.cast_le ℝ]
   refine' (Eq.trans_le _ <| coeff_bdd_of_norm_le hx.2 i).trans (Nat.le_ceil _)
   rw [h_map_ℚ_minpoly, coeff_map, eq_intCast, Int.norm_cast_rat, Int.norm_eq_abs, Int.cast_abs]
Diff
@@ -2,11 +2,6 @@
 Copyright (c) 2022 Xavier Roblot. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alex J. Best, Xavier Roblot
-
-! This file was ported from Lean 3 source module number_theory.number_field.embeddings
-! 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.Analysis.Complex.Polynomial
 import Mathbin.FieldTheory.Minpoly.IsIntegrallyClosed
@@ -14,6 +9,8 @@ import Mathbin.NumberTheory.NumberField.Basic
 import Mathbin.RingTheory.Norm
 import Mathbin.Topology.Instances.Complex
 
+#align_import number_theory.number_field.embeddings from "leanprover-community/mathlib"@"5d0c76894ada7940957143163d7b921345474cbc"
+
 /-!
 # Embeddings of number fields
 
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alex J. Best, Xavier Roblot
 
 ! This file was ported from Lean 3 source module number_theory.number_field.embeddings
-! leanprover-community/mathlib commit caa58cbf5bfb7f81ccbaca4e8b8ac4bc2b39cc1c
+! leanprover-community/mathlib commit 5d0c76894ada7940957143163d7b921345474cbc
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -16,6 +16,9 @@ import Mathbin.Topology.Instances.Complex
 
 /-!
 # Embeddings of number fields
+
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
 This file defines the embeddings of a number field into an algebraic closed field.
 
 ## Main Results
Diff
@@ -48,10 +48,12 @@ noncomputable instance : Fintype (K →+* A) :=
 
 variable [IsAlgClosed A]
 
+#print NumberField.Embeddings.card /-
 /-- The number of embeddings of a number field is equal to its finrank. -/
 theorem card : Fintype.card (K →+* A) = finrank ℚ K := by
   rw [Fintype.ofEquiv_card ring_hom.equiv_rat_alg_hom.symm, AlgHom.card]
 #align number_field.embeddings.card NumberField.Embeddings.card
+-/
 
 instance : Nonempty (K →+* A) :=
   by
@@ -66,6 +68,7 @@ open Set Polynomial
 
 variable (K A : Type _) [Field K] [NumberField K] [Field A] [Algebra ℚ A] [IsAlgClosed A] (x : K)
 
+#print NumberField.Embeddings.range_eval_eq_rootSet_minpoly /-
 /-- Let `A` be an algebraically closed field and let `x ∈ K`, with `K` a number field.
 The images of `x` by the embeddings of `K` in `A` are exactly the roots in `A` of
 the minimal polynomial of `x` over `ℚ`. -/
@@ -75,6 +78,7 @@ theorem range_eval_eq_rootSet_minpoly : (range fun φ : K →+* A => φ x) = (mi
   ext a
   exact ⟨fun ⟨φ, hφ⟩ => ⟨φ.toRatAlgHom, hφ⟩, fun ⟨φ, hφ⟩ => ⟨φ.toRingHom, hφ⟩⟩
 #align number_field.embeddings.range_eval_eq_root_set_minpoly NumberField.Embeddings.range_eval_eq_rootSet_minpoly
+-/
 
 end Roots
 
@@ -86,6 +90,7 @@ variable {K : Type _} [Field K] [NumberField K]
 
 variable {A : Type _} [NormedField A] [IsAlgClosed A] [NormedAlgebra ℚ A]
 
+#print NumberField.Embeddings.coeff_bdd_of_norm_le /-
 theorem coeff_bdd_of_norm_le {B : ℝ} {x : K} (h : ∀ φ : K →+* A, ‖φ x‖ ≤ B) (i : ℕ) :
     ‖(minpoly ℚ x).coeff i‖ ≤ max B 1 ^ finrank ℚ K * (finrank ℚ K).choose (finrank ℚ K / 2) :=
   by
@@ -99,9 +104,11 @@ theorem coeff_bdd_of_norm_le {B : ℝ} {x : K} (h : ∀ φ : K →+* A, ‖φ x
   obtain ⟨φ, rfl⟩ := (range_eval_eq_root_set_minpoly K A x).symm.Subset hz
   exact h φ
 #align number_field.embeddings.coeff_bdd_of_norm_le NumberField.Embeddings.coeff_bdd_of_norm_le
+-/
 
 variable (K A)
 
+#print NumberField.Embeddings.finite_of_norm_le /-
 /-- Let `B` be a real number. The set of algebraic integers in `K` whose conjugates are all
 smaller in norm than `B` is finite. -/
 theorem finite_of_norm_le (B : ℝ) : {x : K | IsIntegral ℤ x ∧ ∀ φ : K →+* A, ‖φ x‖ ≤ B}.Finite :=
@@ -117,7 +124,9 @@ theorem finite_of_norm_le (B : ℝ) : {x : K | IsIntegral ℤ x ∧ ∀ φ : K 
   refine' (Eq.trans_le _ <| coeff_bdd_of_norm_le hx.2 i).trans (Nat.le_ceil _)
   rw [h_map_ℚ_minpoly, coeff_map, eq_intCast, Int.norm_cast_rat, Int.norm_eq_abs, Int.cast_abs]
 #align number_field.embeddings.finite_of_norm_le NumberField.Embeddings.finite_of_norm_le
+-/
 
+#print NumberField.Embeddings.pow_eq_one_of_norm_eq_one /-
 /-- An algebraic integer whose conjugates are all of norm one is a root of unity. -/
 theorem pow_eq_one_of_norm_eq_one {x : K} (hxi : IsIntegral ℤ x) (hx : ∀ φ : K →+* A, ‖φ x‖ = 1) :
     ∃ (n : ℕ) (hn : 0 < n), x ^ n = 1 :=
@@ -134,6 +143,7 @@ theorem pow_eq_one_of_norm_eq_one {x : K} (hxi : IsIntegral ℤ x) (hx : ∀ φ
     rw [pow_eq_zero hp, map_zero, norm_zero] at hx ; norm_num at hx 
   · exact fun a _ => ⟨hxi.pow a, fun φ => by simp only [hx φ, norm_pow, one_pow, map_pow]⟩
 #align number_field.embeddings.pow_eq_one_of_norm_eq_one NumberField.Embeddings.pow_eq_one_of_norm_eq_one
+-/
 
 end Bounded
 
@@ -143,15 +153,19 @@ section Place
 
 variable {K : Type _} [Field K] {A : Type _} [NormedDivisionRing A] [Nontrivial A] (φ : K →+* A)
 
+#print NumberField.place /-
 /-- An embedding into a normed division ring defines a place of `K` -/
 def NumberField.place : AbsoluteValue K ℝ :=
   (IsAbsoluteValue.toAbsoluteValue (norm : A → ℝ)).comp φ.Injective
 #align number_field.place NumberField.place
+-/
 
+#print NumberField.place_apply /-
 @[simp]
 theorem NumberField.place_apply (x : K) : (NumberField.place φ) x = norm (φ x) :=
   rfl
 #align number_field.place_apply NumberField.place_apply
+-/
 
 end Place
 
@@ -163,31 +177,42 @@ open scoped ComplexConjugate
 
 variable {K : Type _} [Field K]
 
+#print NumberField.ComplexEmbedding.conjugate /-
 /-- The conjugate of a complex embedding as a complex embedding. -/
 @[reducible]
 def conjugate (φ : K →+* ℂ) : K →+* ℂ :=
   star φ
 #align number_field.complex_embedding.conjugate NumberField.ComplexEmbedding.conjugate
+-/
 
+#print NumberField.ComplexEmbedding.conjugate_coe_eq /-
 @[simp]
 theorem conjugate_coe_eq (φ : K →+* ℂ) (x : K) : (conjugate φ) x = conj (φ x) :=
   rfl
 #align number_field.complex_embedding.conjugate_coe_eq NumberField.ComplexEmbedding.conjugate_coe_eq
+-/
 
+#print NumberField.ComplexEmbedding.place_conjugate /-
 theorem place_conjugate (φ : K →+* ℂ) : place (conjugate φ) = place φ := by ext;
   simp only [place_apply, norm_eq_abs, abs_conj, conjugate_coe_eq]
 #align number_field.complex_embedding.place_conjugate NumberField.ComplexEmbedding.place_conjugate
+-/
 
+#print NumberField.ComplexEmbedding.IsReal /-
 /-- A embedding into `ℂ` is real if it is fixed by complex conjugation. -/
 @[reducible]
 def IsReal (φ : K →+* ℂ) : Prop :=
   IsSelfAdjoint φ
 #align number_field.complex_embedding.is_real NumberField.ComplexEmbedding.IsReal
+-/
 
+#print NumberField.ComplexEmbedding.isReal_iff /-
 theorem isReal_iff {φ : K →+* ℂ} : IsReal φ ↔ conjugate φ = φ :=
   isSelfAdjoint_iff
 #align number_field.complex_embedding.is_real_iff NumberField.ComplexEmbedding.isReal_iff
+-/
 
+#print NumberField.ComplexEmbedding.IsReal.embedding /-
 /-- A real embedding as a ring homomorphism from `K` to `ℝ` . -/
 def IsReal.embedding {φ : K →+* ℂ} (hφ : IsReal φ) : K →+* ℝ
     where
@@ -199,7 +224,9 @@ def IsReal.embedding {φ : K →+* ℂ} (hφ : IsReal φ) : K →+* ℝ
   map_zero' := by simp only [map_zero, zero_re]
   map_add' := by simp only [map_add, add_re, eq_self_iff_true, forall_const]
 #align number_field.complex_embedding.is_real.embedding NumberField.ComplexEmbedding.IsReal.embedding
+-/
 
+#print NumberField.ComplexEmbedding.IsReal.coe_embedding_apply /-
 @[simp]
 theorem IsReal.coe_embedding_apply {φ : K →+* ℂ} (hφ : IsReal φ) (x : K) :
     (hφ.Embedding x : ℂ) = φ x := by
@@ -208,15 +235,20 @@ theorem IsReal.coe_embedding_apply {φ : K →+* ℂ} (hφ : IsReal φ) (x : K)
     rw [is_real] at hφ 
     exact RingHom.congr_fun hφ x
 #align number_field.complex_embedding.is_real.coe_embedding_apply NumberField.ComplexEmbedding.IsReal.coe_embedding_apply
+-/
 
+#print NumberField.ComplexEmbedding.IsReal.place_embedding /-
 theorem IsReal.place_embedding {φ : K →+* ℂ} (hφ : IsReal φ) : place hφ.Embedding = place φ := by
   ext x;
   simp only [place_apply, Real.norm_eq_abs, ← abs_of_real, norm_eq_abs, hφ.coe_embedding_apply x]
 #align number_field.complex_embedding.is_real.place_embedding NumberField.ComplexEmbedding.IsReal.place_embedding
+-/
 
+#print NumberField.ComplexEmbedding.isReal_conjugate_iff /-
 theorem isReal_conjugate_iff {φ : K →+* ℂ} : IsReal (conjugate φ) ↔ IsReal φ :=
   IsSelfAdjoint.star_iff
 #align number_field.complex_embedding.is_real_conjugate_iff NumberField.ComplexEmbedding.isReal_conjugate_iff
+-/
 
 end NumberField.ComplexEmbedding
 
@@ -226,20 +258,24 @@ open NumberField
 
 variable (K : Type _) [Field K]
 
+#print NumberField.InfinitePlace /-
 /-- An infinite place of a number field `K` is a place associated to a complex embedding. -/
 def NumberField.InfinitePlace :=
   { w : AbsoluteValue K ℝ // ∃ φ : K →+* ℂ, place φ = w }
 #align number_field.infinite_place NumberField.InfinitePlace
+-/
 
 instance [NumberField K] : Nonempty (NumberField.InfinitePlace K) :=
   Set.range.nonempty _
 
 variable {K}
 
+#print NumberField.InfinitePlace.mk /-
 /-- Return the infinite place defined by a complex embedding `φ`. -/
 noncomputable def NumberField.InfinitePlace.mk (φ : K →+* ℂ) : NumberField.InfinitePlace K :=
   ⟨place φ, ⟨φ, rfl⟩⟩
 #align number_field.infinite_place.mk NumberField.InfinitePlace.mk
+-/
 
 namespace NumberField.InfinitePlace
 
@@ -261,48 +297,67 @@ instance : NonnegHomClass (InfinitePlace K) K ℝ
   coe_injective' _ _ h := Subtype.eq (AbsoluteValue.ext fun x => congr_fun h x)
   map_nonneg w x := w.1.NonNeg _
 
+#print NumberField.InfinitePlace.coe_mk /-
 theorem coe_mk (φ : K →+* ℂ) : ⇑(mk φ) = place φ :=
   rfl
 #align number_field.infinite_place.coe_mk NumberField.InfinitePlace.coe_mk
+-/
 
+#print NumberField.InfinitePlace.apply /-
 theorem apply (φ : K →+* ℂ) (x : K) : (mk φ) x = Complex.abs (φ x) :=
   rfl
 #align number_field.infinite_place.apply NumberField.InfinitePlace.apply
+-/
 
+#print NumberField.InfinitePlace.embedding /-
 /-- For an infinite place `w`, return an embedding `φ` such that `w = infinite_place φ` . -/
 noncomputable def embedding (w : InfinitePlace K) : K →+* ℂ :=
   w.2.some
 #align number_field.infinite_place.embedding NumberField.InfinitePlace.embedding
+-/
 
+#print NumberField.InfinitePlace.mk_embedding /-
 @[simp]
 theorem mk_embedding (w : InfinitePlace K) : mk (embedding w) = w :=
   Subtype.ext w.2.choose_spec
 #align number_field.infinite_place.mk_embedding NumberField.InfinitePlace.mk_embedding
+-/
 
+#print NumberField.InfinitePlace.abs_embedding /-
 @[simp]
 theorem abs_embedding (w : InfinitePlace K) (x : K) : Complex.abs (embedding w x) = w x :=
   congr_fun (congr_arg coeFn w.2.choose_spec) x
 #align number_field.infinite_place.abs_embedding NumberField.InfinitePlace.abs_embedding
+-/
 
+#print NumberField.InfinitePlace.eq_iff_eq /-
 theorem eq_iff_eq (x : K) (r : ℝ) : (∀ w : InfinitePlace K, w x = r) ↔ ∀ φ : K →+* ℂ, ‖φ x‖ = r :=
   ⟨fun hw φ => hw (mk φ), fun hφ ⟨w, ⟨φ, rfl⟩⟩ => hφ φ⟩
 #align number_field.infinite_place.eq_iff_eq NumberField.InfinitePlace.eq_iff_eq
+-/
 
+#print NumberField.InfinitePlace.le_iff_le /-
 theorem le_iff_le (x : K) (r : ℝ) : (∀ w : InfinitePlace K, w x ≤ r) ↔ ∀ φ : K →+* ℂ, ‖φ x‖ ≤ r :=
   ⟨fun hw φ => hw (mk φ), fun hφ ⟨w, ⟨φ, rfl⟩⟩ => hφ φ⟩
 #align number_field.infinite_place.le_iff_le NumberField.InfinitePlace.le_iff_le
+-/
 
+#print NumberField.InfinitePlace.pos_iff /-
 theorem pos_iff {w : InfinitePlace K} {x : K} : 0 < w x ↔ x ≠ 0 :=
   AbsoluteValue.pos_iff w.1
 #align number_field.infinite_place.pos_iff NumberField.InfinitePlace.pos_iff
+-/
 
+#print NumberField.InfinitePlace.mk_conjugate_eq /-
 @[simp]
 theorem mk_conjugate_eq (φ : K →+* ℂ) : mk (ComplexEmbedding.conjugate φ) = mk φ :=
   by
   ext x
   exact congr_fun (congr_arg coeFn (complex_embedding.place_conjugate φ)) x
 #align number_field.infinite_place.mk_conjugate_eq NumberField.InfinitePlace.mk_conjugate_eq
+-/
 
+#print NumberField.InfinitePlace.mk_eq_iff /-
 @[simp]
 theorem mk_eq_iff {φ ψ : K →+* ℂ} : mk φ = mk ψ ↔ φ = ψ ∨ ComplexEmbedding.conjugate φ = ψ :=
   by
@@ -336,17 +391,23 @@ theorem mk_eq_iff {φ ψ : K →+* ℂ} : mk φ = mk ψ ↔ φ = ψ ∨ ComplexE
     · rw [← mk_conjugate_eq]
       exact congr_arg mk h
 #align number_field.infinite_place.mk_eq_iff NumberField.InfinitePlace.mk_eq_iff
+-/
 
+#print NumberField.InfinitePlace.IsReal /-
 /-- An infinite place is real if it is defined by a real embedding. -/
 def IsReal (w : InfinitePlace K) : Prop :=
   ∃ φ : K →+* ℂ, ComplexEmbedding.IsReal φ ∧ mk φ = w
 #align number_field.infinite_place.is_real NumberField.InfinitePlace.IsReal
+-/
 
+#print NumberField.InfinitePlace.IsComplex /-
 /-- An infinite place is complex if it is defined by a complex (ie. not real) embedding. -/
 def IsComplex (w : InfinitePlace K) : Prop :=
   ∃ φ : K →+* ℂ, ¬ComplexEmbedding.IsReal φ ∧ mk φ = w
 #align number_field.infinite_place.is_complex NumberField.InfinitePlace.IsComplex
+-/
 
+#print NumberField.ComplexEmbeddings.IsReal.embedding_mk /-
 @[simp]
 theorem NumberField.ComplexEmbeddings.IsReal.embedding_mk {φ : K →+* ℂ}
     (h : ComplexEmbedding.IsReal φ) : embedding (mk φ) = φ :=
@@ -354,7 +415,9 @@ theorem NumberField.ComplexEmbeddings.IsReal.embedding_mk {φ : K →+* ℂ}
   have := mk_eq_iff.mp (mk_embedding (mk φ)).symm
   rwa [complex_embedding.is_real_iff.mp h, or_self_iff, eq_comm] at this 
 #align number_field.complex_embeddings.is_real.embedding_mk NumberField.ComplexEmbeddings.IsReal.embedding_mk
+-/
 
+#print NumberField.InfinitePlace.isReal_iff /-
 theorem isReal_iff {w : InfinitePlace K} : IsReal w ↔ ComplexEmbedding.IsReal (embedding w) :=
   by
   constructor
@@ -362,7 +425,9 @@ theorem isReal_iff {w : InfinitePlace K} : IsReal w ↔ ComplexEmbedding.IsReal
     rwa [_root_.number_field.complex_embeddings.is_real.embedding_mk hφ]
   · exact fun h => ⟨Embedding w, h, mk_embedding w⟩
 #align number_field.infinite_place.is_real_iff NumberField.InfinitePlace.isReal_iff
+-/
 
+#print NumberField.InfinitePlace.isComplex_iff /-
 theorem isComplex_iff {w : InfinitePlace K} :
     IsComplex w ↔ ¬ComplexEmbedding.IsReal (embedding w) :=
   by
@@ -375,26 +440,36 @@ theorem isComplex_iff {w : InfinitePlace K} :
       rwa [← h]
   · exact fun h => ⟨Embedding w, h, mk_embedding w⟩
 #align number_field.infinite_place.is_complex_iff NumberField.InfinitePlace.isComplex_iff
+-/
 
+#print NumberField.InfinitePlace.not_isReal_iff_isComplex /-
 @[simp]
 theorem not_isReal_iff_isComplex {w : InfinitePlace K} : ¬IsReal w ↔ IsComplex w := by
   rw [is_complex_iff, is_real_iff]
 #align number_field.infinite_place.not_is_real_iff_is_complex NumberField.InfinitePlace.not_isReal_iff_isComplex
+-/
 
+#print NumberField.InfinitePlace.not_isComplex_iff_isReal /-
 @[simp]
 theorem not_isComplex_iff_isReal {w : InfinitePlace K} : ¬IsComplex w ↔ IsReal w := by
   rw [← not_is_real_iff_is_complex, Classical.not_not]
 #align number_field.infinite_place.not_is_complex_iff_is_real NumberField.InfinitePlace.not_isComplex_iff_isReal
+-/
 
+#print NumberField.InfinitePlace.isReal_or_isComplex /-
 theorem isReal_or_isComplex (w : InfinitePlace K) : IsReal w ∨ IsComplex w := by
   rw [← not_is_real_iff_is_complex]; exact em _
 #align number_field.infinite_place.is_real_or_is_complex NumberField.InfinitePlace.isReal_or_isComplex
+-/
 
+#print NumberField.InfinitePlace.IsReal.embedding /-
 /-- For `w` a real infinite place, return the corresponding embedding as a morphism `K →+* ℝ`. -/
 noncomputable def IsReal.embedding {w : InfinitePlace K} (hw : IsReal w) : K →+* ℝ :=
   (isReal_iff.mp hw).Embedding
 #align number_field.infinite_place.is_real.embedding NumberField.InfinitePlace.IsReal.embedding
+-/
 
+#print NumberField.InfinitePlace.IsReal.place_embedding_apply /-
 @[simp]
 theorem IsReal.place_embedding_apply {w : InfinitePlace K} (hw : IsReal w) (x : K) :
     place (IsReal.embedding hw) x = w x :=
@@ -402,14 +477,18 @@ theorem IsReal.place_embedding_apply {w : InfinitePlace K} (hw : IsReal w) (x :
   rw [is_real.embedding, complex_embedding.is_real.place_embedding, ← coe_mk]
   exact congr_fun (congr_arg coeFn (mk_embedding w)) x
 #align number_field.infinite_place.is_real.place_embedding_apply NumberField.InfinitePlace.IsReal.place_embedding_apply
+-/
 
+#print NumberField.InfinitePlace.IsReal.abs_embedding_apply /-
 @[simp]
 theorem IsReal.abs_embedding_apply {w : InfinitePlace K} (hw : IsReal w) (x : K) :
     |IsReal.embedding hw x| = w x := by rw [← is_real.place_embedding_apply hw x]; congr
 #align number_field.infinite_place.is_real.abs_embedding_apply NumberField.InfinitePlace.IsReal.abs_embedding_apply
+-/
 
 variable (K)
 
+#print NumberField.InfinitePlace.mkReal /-
 /-- The map from real embeddings to real infinite places as an equiv -/
 noncomputable def mkReal :
     { φ : K →+* ℂ // ComplexEmbedding.IsReal φ } ≃ { w : InfinitePlace K // IsReal w }
@@ -419,13 +498,17 @@ noncomputable def mkReal :
   left_inv φ := Subtype.ext_iff.2 (NumberField.ComplexEmbeddings.IsReal.embedding_mk φ.2)
   right_inv w := Subtype.ext_iff.2 (mk_embedding w.1)
 #align number_field.infinite_place.mk_real NumberField.InfinitePlace.mkReal
+-/
 
+#print NumberField.InfinitePlace.mkComplex /-
 /-- The map from nonreal embeddings to complex infinite places -/
 noncomputable def mkComplex :
     { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ } → { w : InfinitePlace K // IsComplex w } :=
   Subtype.map mk fun φ hφ => ⟨φ, hφ, rfl⟩
 #align number_field.infinite_place.mk_complex NumberField.InfinitePlace.mkComplex
+-/
 
+#print NumberField.InfinitePlace.mkComplex_embedding /-
 theorem mkComplex_embedding (φ : { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ }) :
     (mkComplex K φ : InfinitePlace K).Embedding = φ ∨
       (mkComplex K φ : InfinitePlace K).Embedding = ComplexEmbedding.conjugate φ :=
@@ -433,33 +516,43 @@ theorem mkComplex_embedding (φ : { φ : K →+* ℂ // ¬ComplexEmbedding.IsRea
   rw [@eq_comm _ _ ↑φ, @eq_comm _ _ (complex_embedding.conjugate ↑φ), ← mk_eq_iff, mk_embedding]
   rfl
 #align number_field.infinite_place.mk_complex_embedding NumberField.InfinitePlace.mkComplex_embedding
+-/
 
+#print NumberField.InfinitePlace.mkReal_coe /-
 @[simp]
 theorem mkReal_coe (φ : { φ : K →+* ℂ // ComplexEmbedding.IsReal φ }) :
     (mkReal K φ : InfinitePlace K) = mk (φ : K →+* ℂ) :=
   rfl
 #align number_field.infinite_place.mk_real_coe NumberField.InfinitePlace.mkReal_coe
+-/
 
+#print NumberField.InfinitePlace.mkComplex_coe /-
 @[simp]
 theorem mkComplex_coe (φ : { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ }) :
     (mkComplex K φ : InfinitePlace K) = mk (φ : K →+* ℂ) :=
   rfl
 #align number_field.infinite_place.mk_complex_coe NumberField.InfinitePlace.mkComplex_coe
+-/
 
+#print NumberField.InfinitePlace.mkReal.apply /-
 @[simp]
 theorem mkReal.apply (φ : { φ : K →+* ℂ // ComplexEmbedding.IsReal φ }) (x : K) :
     mkReal K φ x = Complex.abs (φ x) :=
   apply φ x
 #align number_field.infinite_place.mk_real.apply NumberField.InfinitePlace.mkReal.apply
+-/
 
+#print NumberField.InfinitePlace.mkComplex.apply /-
 @[simp]
 theorem mkComplex.apply (φ : { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ }) (x : K) :
     mkComplex K φ x = Complex.abs (φ x) :=
   apply φ x
 #align number_field.infinite_place.mk_complex.apply NumberField.InfinitePlace.mkComplex.apply
+-/
 
 variable [NumberField K]
 
+#print NumberField.InfinitePlace.mkComplex.filter /-
 theorem mkComplex.filter (w : { w : InfinitePlace K // w.IsComplex }) :
     (Finset.univ.filterₓ fun φ => mkComplex K φ = w) =
       {⟨w.1.Embedding, isComplex_iff.1 w.2⟩,
@@ -472,7 +565,9 @@ theorem mkComplex.filter (w : { w : InfinitePlace K // w.IsComplex }) :
     mk_eq_iff, mk_embedding, @eq_comm _ _ w.val]
   simpa only [Finset.mem_univ, true_and_iff]
 #align number_field.infinite_place.mk_complex.filter NumberField.InfinitePlace.mkComplex.filter
+-/
 
+#print NumberField.InfinitePlace.mkComplex.filter_card /-
 theorem mkComplex.filter_card (w : { w : InfinitePlace K // w.IsComplex }) :
     (Finset.univ.filterₓ fun φ => mkComplex K φ = w).card = 2 :=
   by
@@ -482,11 +577,15 @@ theorem mkComplex.filter_card (w : { w : InfinitePlace K // w.IsComplex }) :
       (subtype.mk_eq_mk.not.2 <|
         ne_comm.1 <| complex_embedding.is_real_iff.not.1 <| is_complex_iff.1 w.2)
 #align number_field.infinite_place.mk_complex.filter_card NumberField.InfinitePlace.mkComplex.filter_card
+-/
 
+#print NumberField.InfinitePlace.NumberField.InfinitePlace.fintype /-
 noncomputable instance NumberField.InfinitePlace.fintype : Fintype (InfinitePlace K) :=
   Set.fintypeRange _
 #align number_field.infinite_place.number_field.infinite_place.fintype NumberField.InfinitePlace.NumberField.InfinitePlace.fintype
+-/
 
+#print NumberField.InfinitePlace.prod_eq_abs_norm /-
 /-- The infinite part of the product formula : for `x ∈ K`, we have `Π_w ‖x‖_w = |norm(x)|` where
 `‖·‖_w` is the normalized absolute value for `w`.  -/
 theorem prod_eq_abs_norm (x : K) :
@@ -524,14 +623,18 @@ theorem prod_eq_abs_norm (x : K) :
         rfl
   · rw [eq_ratCast, ← Complex.abs_ofReal, Complex.ofReal_rat_cast]
 #align number_field.infinite_place.prod_eq_abs_norm NumberField.InfinitePlace.prod_eq_abs_norm
+-/
 
 open Fintype
 
+#print NumberField.InfinitePlace.card_real_embeddings /-
 theorem card_real_embeddings :
     card { φ : K →+* ℂ // ComplexEmbedding.IsReal φ } = card { w : InfinitePlace K // IsReal w } :=
   by convert (Fintype.ofEquiv_card (mk_real K)).symm
 #align number_field.infinite_place.card_real_embeddings NumberField.InfinitePlace.card_real_embeddings
+-/
 
+#print NumberField.InfinitePlace.card_complex_embeddings /-
 theorem card_complex_embeddings :
     card { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ } =
       2 * card { w : InfinitePlace K // IsComplex w } :=
@@ -546,6 +649,7 @@ theorem card_complex_embeddings :
   simp_rw [Finset.card_eq_sum_ones]
   exact (Finset.sum_fiberwise Finset.univ (fun φ => mk_complex K φ) fun φ => 1).symm
 #align number_field.infinite_place.card_complex_embeddings NumberField.InfinitePlace.card_complex_embeddings
+-/
 
 end NumberField.InfinitePlace
 
Diff
@@ -93,7 +93,7 @@ theorem coeff_bdd_of_norm_le {B : ℝ} {x : K} (h : ∀ φ : K →+* A, ‖φ x
   rw [← norm_algebraMap' A, ← coeff_map (algebraMap ℚ A)]
   refine'
     coeff_bdd_of_roots_le _ (minpoly.monic hx) (IsAlgClosed.splits_codomain _)
-      (minpoly.natDegree_le hx) (fun z hz => _) i
+      (IntermediateField.minpoly.natDegree_le hx) (fun z hz => _) i
   classical
   rw [← Multiset.mem_toFinset] at hz 
   obtain ⟨φ, rfl⟩ := (range_eval_eq_root_set_minpoly K A x).symm.Subset hz
@@ -112,7 +112,7 @@ theorem finite_of_norm_le (B : ℝ) : {x : K | IsIntegral ℤ x ∧ ∀ φ : K 
   have h_map_ℚ_minpoly := minpoly.isIntegrallyClosed_eq_field_fractions' ℚ hx.1
   refine' ⟨_, ⟨_, fun i => _⟩, mem_root_set.2 ⟨minpoly.ne_zero hx.1, minpoly.aeval ℤ x⟩⟩
   · rw [← (minpoly.monic hx.1).natDegree_map (algebraMap ℤ ℚ), ← h_map_ℚ_minpoly]
-    exact minpoly.natDegree_le (isIntegral_of_isScalarTower hx.1)
+    exact IntermediateField.minpoly.natDegree_le (isIntegral_of_isScalarTower hx.1)
   rw [mem_Icc, ← abs_le, ← @Int.cast_le ℝ]
   refine' (Eq.trans_le _ <| coeff_bdd_of_norm_le hx.2 i).trans (Nat.le_ceil _)
   rw [h_map_ℚ_minpoly, coeff_map, eq_intCast, Int.norm_cast_rat, Int.norm_eq_abs, Int.cast_abs]
Diff
@@ -71,7 +71,7 @@ The images of `x` by the embeddings of `K` in `A` are exactly the roots in `A` o
 the minimal polynomial of `x` over `ℚ`. -/
 theorem range_eval_eq_rootSet_minpoly : (range fun φ : K →+* A => φ x) = (minpoly ℚ x).rootSet A :=
   by
-  convert(NumberField.isAlgebraic K).range_eval_eq_rootSet_minpoly A x using 1
+  convert (NumberField.isAlgebraic K).range_eval_eq_rootSet_minpoly A x using 1
   ext a
   exact ⟨fun ⟨φ, hφ⟩ => ⟨φ.toRatAlgHom, hφ⟩, fun ⟨φ, hφ⟩ => ⟨φ.toRingHom, hφ⟩⟩
 #align number_field.embeddings.range_eval_eq_root_set_minpoly NumberField.Embeddings.range_eval_eq_rootSet_minpoly
@@ -95,16 +95,16 @@ theorem coeff_bdd_of_norm_le {B : ℝ} {x : K} (h : ∀ φ : K →+* A, ‖φ x
     coeff_bdd_of_roots_le _ (minpoly.monic hx) (IsAlgClosed.splits_codomain _)
       (minpoly.natDegree_le hx) (fun z hz => _) i
   classical
-    rw [← Multiset.mem_toFinset] at hz 
-    obtain ⟨φ, rfl⟩ := (range_eval_eq_root_set_minpoly K A x).symm.Subset hz
-    exact h φ
+  rw [← Multiset.mem_toFinset] at hz 
+  obtain ⟨φ, rfl⟩ := (range_eval_eq_root_set_minpoly K A x).symm.Subset hz
+  exact h φ
 #align number_field.embeddings.coeff_bdd_of_norm_le NumberField.Embeddings.coeff_bdd_of_norm_le
 
 variable (K A)
 
 /-- Let `B` be a real number. The set of algebraic integers in `K` whose conjugates are all
 smaller in norm than `B` is finite. -/
-theorem finite_of_norm_le (B : ℝ) : { x : K | IsIntegral ℤ x ∧ ∀ φ : K →+* A, ‖φ x‖ ≤ B }.Finite :=
+theorem finite_of_norm_le (B : ℝ) : {x : K | IsIntegral ℤ x ∧ ∀ φ : K →+* A, ‖φ x‖ ≤ B}.Finite :=
   by
   let C := Nat.ceil (max B 1 ^ finrank ℚ K * (finrank ℚ K).choose (finrank ℚ K / 2))
   have := bUnion_roots_finite (algebraMap ℤ K) (finrank ℚ K) (finite_Icc (-C : ℤ) C)
@@ -326,10 +326,10 @@ theorem mk_eq_iff {φ ψ : K →+* ℂ} : mk φ = mk ψ ↔ φ = ψ ∨ ComplexE
       exact congr_fun (congr_arg coeFn h₀) _
     cases Complex.uniformContinuous_ringHom_eq_id_or_conj φ.field_range hlip.uniform_continuous
     · left; ext1 x
-      convert(congr_fun h (ι x)).symm
+      convert (congr_fun h (ι x)).symm
       exact (RingEquiv.apply_symm_apply ι.symm x).symm
     · right; ext1 x
-      convert(congr_fun h (ι x)).symm
+      convert (congr_fun h (ι x)).symm
       exact (RingEquiv.apply_symm_apply ι.symm x).symm
   · rintro (⟨h⟩ | ⟨h⟩)
     · exact congr_arg mk h
@@ -493,7 +493,7 @@ theorem prod_eq_abs_norm (x : K) :
     (Finset.univ.Prod fun w : InfinitePlace K => ite w.IsReal (w x) (w x ^ 2)) =
       abs (Algebra.norm ℚ x) :=
   by
-  convert(congr_arg Complex.abs (@Algebra.norm_eq_prod_embeddings ℚ _ _ _ _ ℂ _ _ _ _ _ x)).symm
+  convert (congr_arg Complex.abs (@Algebra.norm_eq_prod_embeddings ℚ _ _ _ _ ℂ _ _ _ _ _ x)).symm
   · rw [map_prod, ←
       Equiv.prod_comp' RingHom.equivRatAlgHom (fun f => Complex.abs (f x))
         (fun φ => Complex.abs (φ x)) fun _ => by simpa only [RingHom.equivRatAlgHom_apply]]
@@ -509,7 +509,7 @@ theorem prod_eq_abs_norm (x : K) :
     rw [Finset.prod_ite, Finset.prod_ite]
     refine' congr (congr_arg Mul.mul _) _
     · rw [← Finset.prod_subtype_eq_prod_filter, ← Finset.prod_subtype_eq_prod_filter]
-      convert(Equiv.prod_comp' (mk_real K) (fun φ => Complex.abs (φ x)) (fun w => w x) _).symm
+      convert (Equiv.prod_comp' (mk_real K) (fun φ => Complex.abs (φ x)) (fun w => w x) _).symm
       any_goals ext; simp only [Finset.mem_subtype, Finset.mem_univ]
       exact fun φ => mk_real.apply K φ x
     · rw [Finset.filter_congr fun (w : infinite_place K) _ => @not_is_real_iff_is_complex K _ w, ←
@@ -529,7 +529,7 @@ open Fintype
 
 theorem card_real_embeddings :
     card { φ : K →+* ℂ // ComplexEmbedding.IsReal φ } = card { w : InfinitePlace K // IsReal w } :=
-  by convert(Fintype.ofEquiv_card (mk_real K)).symm
+  by convert (Fintype.ofEquiv_card (mk_real K)).symm
 #align number_field.infinite_place.card_real_embeddings NumberField.InfinitePlace.card_real_embeddings
 
 theorem card_complex_embeddings :
Diff
@@ -95,7 +95,7 @@ theorem coeff_bdd_of_norm_le {B : ℝ} {x : K} (h : ∀ φ : K →+* A, ‖φ x
     coeff_bdd_of_roots_le _ (minpoly.monic hx) (IsAlgClosed.splits_codomain _)
       (minpoly.natDegree_le hx) (fun z hz => _) i
   classical
-    rw [← Multiset.mem_toFinset] at hz
+    rw [← Multiset.mem_toFinset] at hz 
     obtain ⟨φ, rfl⟩ := (range_eval_eq_root_set_minpoly K A x).symm.Subset hz
     exact h φ
 #align number_field.embeddings.coeff_bdd_of_norm_le NumberField.Embeddings.coeff_bdd_of_norm_le
@@ -120,7 +120,7 @@ theorem finite_of_norm_le (B : ℝ) : { x : K | IsIntegral ℤ x ∧ ∀ φ : K
 
 /-- An algebraic integer whose conjugates are all of norm one is a root of unity. -/
 theorem pow_eq_one_of_norm_eq_one {x : K} (hxi : IsIntegral ℤ x) (hx : ∀ φ : K →+* A, ‖φ x‖ = 1) :
-    ∃ (n : ℕ)(hn : 0 < n), x ^ n = 1 :=
+    ∃ (n : ℕ) (hn : 0 < n), x ^ n = 1 :=
   by
   obtain ⟨a, -, b, -, habne, h⟩ :=
     @Set.Infinite.exists_ne_map_eq_of_mapsTo _ _ _ _ ((· ^ ·) x : ℕ → K) Set.infinite_univ _
@@ -128,10 +128,10 @@ theorem pow_eq_one_of_norm_eq_one {x : K} (hxi : IsIntegral ℤ x) (hx : ∀ φ
   · wlog hlt : b < a
     · exact this hxi hx b a habne.symm h.symm (habne.lt_or_lt.resolve_right hlt)
     refine' ⟨a - b, tsub_pos_of_lt hlt, _⟩
-    rw [← Nat.sub_add_cancel hlt.le, pow_add, mul_left_eq_self₀] at h
+    rw [← Nat.sub_add_cancel hlt.le, pow_add, mul_left_eq_self₀] at h 
     refine' h.resolve_right fun hp => _
     specialize hx (IsAlgClosed.lift (NumberField.isAlgebraic K)).toRingHom
-    rw [pow_eq_zero hp, map_zero, norm_zero] at hx; norm_num at hx
+    rw [pow_eq_zero hp, map_zero, norm_zero] at hx ; norm_num at hx 
   · exact fun a _ => ⟨hxi.pow a, fun φ => by simp only [hx φ, norm_pow, one_pow, map_pow]⟩
 #align number_field.embeddings.pow_eq_one_of_norm_eq_one NumberField.Embeddings.pow_eq_one_of_norm_eq_one
 
@@ -205,7 +205,7 @@ theorem IsReal.coe_embedding_apply {φ : K →+* ℂ} (hφ : IsReal φ) (x : K)
     (hφ.Embedding x : ℂ) = φ x := by
   ext; · rfl
   · rw [of_real_im, eq_comm, ← Complex.conj_eq_iff_im]
-    rw [is_real] at hφ
+    rw [is_real] at hφ 
     exact RingHom.congr_fun hφ x
 #align number_field.complex_embedding.is_real.coe_embedding_apply NumberField.ComplexEmbedding.IsReal.coe_embedding_apply
 
@@ -352,7 +352,7 @@ theorem NumberField.ComplexEmbeddings.IsReal.embedding_mk {φ : K →+* ℂ}
     (h : ComplexEmbedding.IsReal φ) : embedding (mk φ) = φ :=
   by
   have := mk_eq_iff.mp (mk_embedding (mk φ)).symm
-  rwa [complex_embedding.is_real_iff.mp h, or_self_iff, eq_comm] at this
+  rwa [complex_embedding.is_real_iff.mp h, or_self_iff, eq_comm] at this 
 #align number_field.complex_embeddings.is_real.embedding_mk NumberField.ComplexEmbeddings.IsReal.embedding_mk
 
 theorem isReal_iff {w : InfinitePlace K} : IsReal w ↔ ComplexEmbedding.IsReal (embedding w) :=
@@ -371,7 +371,7 @@ theorem isComplex_iff {w : InfinitePlace K} :
     contrapose! hφ
     cases mk_eq_iff.mp (mk_embedding (mk φ))
     · rwa [← h]
-    · rw [← complex_embedding.is_real_conjugate_iff] at hφ
+    · rw [← complex_embedding.is_real_conjugate_iff] at hφ 
       rwa [← h]
   · exact fun h => ⟨Embedding w, h, mk_embedding w⟩
 #align number_field.infinite_place.is_complex_iff NumberField.InfinitePlace.isComplex_iff
@@ -496,7 +496,7 @@ theorem prod_eq_abs_norm (x : K) :
   convert(congr_arg Complex.abs (@Algebra.norm_eq_prod_embeddings ℚ _ _ _ _ ℂ _ _ _ _ _ x)).symm
   · rw [map_prod, ←
       Equiv.prod_comp' RingHom.equivRatAlgHom (fun f => Complex.abs (f x))
-        (fun φ => Complex.abs (φ x)) fun _ => by simpa only [RingHom.equivRatAlgHom_apply] ]
+        (fun φ => Complex.abs (φ x)) fun _ => by simpa only [RingHom.equivRatAlgHom_apply]]
     dsimp only
     conv =>
       rhs
Diff
@@ -30,7 +30,7 @@ number field, embeddings, places, infinite places
 -/
 
 
-open Classical
+open scoped Classical
 
 namespace NumberField.Embeddings
 
@@ -159,7 +159,7 @@ namespace NumberField.ComplexEmbedding
 
 open Complex NumberField
 
-open ComplexConjugate
+open scoped ComplexConjugate
 
 variable {K : Type _} [Field K]
 
Diff
@@ -131,8 +131,7 @@ theorem pow_eq_one_of_norm_eq_one {x : K} (hxi : IsIntegral ℤ x) (hx : ∀ φ
     rw [← Nat.sub_add_cancel hlt.le, pow_add, mul_left_eq_self₀] at h
     refine' h.resolve_right fun hp => _
     specialize hx (IsAlgClosed.lift (NumberField.isAlgebraic K)).toRingHom
-    rw [pow_eq_zero hp, map_zero, norm_zero] at hx
-    norm_num at hx
+    rw [pow_eq_zero hp, map_zero, norm_zero] at hx; norm_num at hx
   · exact fun a _ => ⟨hxi.pow a, fun φ => by simp only [hx φ, norm_pow, one_pow, map_pow]⟩
 #align number_field.embeddings.pow_eq_one_of_norm_eq_one NumberField.Embeddings.pow_eq_one_of_norm_eq_one
 
@@ -175,9 +174,7 @@ theorem conjugate_coe_eq (φ : K →+* ℂ) (x : K) : (conjugate φ) x = conj (
   rfl
 #align number_field.complex_embedding.conjugate_coe_eq NumberField.ComplexEmbedding.conjugate_coe_eq
 
-theorem place_conjugate (φ : K →+* ℂ) : place (conjugate φ) = place φ :=
-  by
-  ext
+theorem place_conjugate (φ : K →+* ℂ) : place (conjugate φ) = place φ := by ext;
   simp only [place_apply, norm_eq_abs, abs_conj, conjugate_coe_eq]
 #align number_field.complex_embedding.place_conjugate NumberField.ComplexEmbedding.place_conjugate
 
@@ -212,9 +209,8 @@ theorem IsReal.coe_embedding_apply {φ : K →+* ℂ} (hφ : IsReal φ) (x : K)
     exact RingHom.congr_fun hφ x
 #align number_field.complex_embedding.is_real.coe_embedding_apply NumberField.ComplexEmbedding.IsReal.coe_embedding_apply
 
-theorem IsReal.place_embedding {φ : K →+* ℂ} (hφ : IsReal φ) : place hφ.Embedding = place φ :=
-  by
-  ext x
+theorem IsReal.place_embedding {φ : K →+* ℂ} (hφ : IsReal φ) : place hφ.Embedding = place φ := by
+  ext x;
   simp only [place_apply, Real.norm_eq_abs, ← abs_of_real, norm_eq_abs, hφ.coe_embedding_apply x]
 #align number_field.complex_embedding.is_real.place_embedding NumberField.ComplexEmbedding.IsReal.place_embedding
 
@@ -329,12 +325,10 @@ theorem mk_eq_iff {φ ψ : K →+* ℂ} : mk φ = mk ψ ↔ φ = ψ ∨ ComplexE
         rfl
       exact congr_fun (congr_arg coeFn h₀) _
     cases Complex.uniformContinuous_ringHom_eq_id_or_conj φ.field_range hlip.uniform_continuous
-    · left
-      ext1 x
+    · left; ext1 x
       convert(congr_fun h (ι x)).symm
       exact (RingEquiv.apply_symm_apply ι.symm x).symm
-    · right
-      ext1 x
+    · right; ext1 x
       convert(congr_fun h (ι x)).symm
       exact (RingEquiv.apply_symm_apply ι.symm x).symm
   · rintro (⟨h⟩ | ⟨h⟩)
@@ -392,10 +386,8 @@ theorem not_isComplex_iff_isReal {w : InfinitePlace K} : ¬IsComplex w ↔ IsRea
   rw [← not_is_real_iff_is_complex, Classical.not_not]
 #align number_field.infinite_place.not_is_complex_iff_is_real NumberField.InfinitePlace.not_isComplex_iff_isReal
 
-theorem isReal_or_isComplex (w : InfinitePlace K) : IsReal w ∨ IsComplex w :=
-  by
-  rw [← not_is_real_iff_is_complex]
-  exact em _
+theorem isReal_or_isComplex (w : InfinitePlace K) : IsReal w ∨ IsComplex w := by
+  rw [← not_is_real_iff_is_complex]; exact em _
 #align number_field.infinite_place.is_real_or_is_complex NumberField.InfinitePlace.isReal_or_isComplex
 
 /-- For `w` a real infinite place, return the corresponding embedding as a morphism `K →+* ℝ`. -/
@@ -413,10 +405,7 @@ theorem IsReal.place_embedding_apply {w : InfinitePlace K} (hw : IsReal w) (x :
 
 @[simp]
 theorem IsReal.abs_embedding_apply {w : InfinitePlace K} (hw : IsReal w) (x : K) :
-    |IsReal.embedding hw x| = w x :=
-  by
-  rw [← is_real.place_embedding_apply hw x]
-  congr
+    |IsReal.embedding hw x| = w x := by rw [← is_real.place_embedding_apply hw x]; congr
 #align number_field.infinite_place.is_real.abs_embedding_apply NumberField.InfinitePlace.IsReal.abs_embedding_apply
 
 variable (K)
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alex J. Best, Xavier Roblot
 
 ! This file was ported from Lean 3 source module number_theory.number_field.embeddings
-! leanprover-community/mathlib commit 60da01b41bbe4206f05d34fd70c8dd7498717a30
+! leanprover-community/mathlib commit caa58cbf5bfb7f81ccbaca4e8b8ac4bc2b39cc1c
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -197,7 +197,7 @@ def IsReal.embedding {φ : K →+* ℂ} (hφ : IsReal φ) : K →+* ℝ
   toFun x := (φ x).re
   map_one' := by simp only [map_one, one_re]
   map_mul' := by
-    simp only [complex.eq_conj_iff_im.mp (RingHom.congr_fun hφ _), map_mul, mul_re,
+    simp only [complex.conj_eq_iff_im.mp (RingHom.congr_fun hφ _), map_mul, mul_re,
       MulZeroClass.mul_zero, tsub_zero, eq_self_iff_true, forall_const]
   map_zero' := by simp only [map_zero, zero_re]
   map_add' := by simp only [map_add, add_re, eq_self_iff_true, forall_const]
@@ -207,7 +207,7 @@ def IsReal.embedding {φ : K →+* ℂ} (hφ : IsReal φ) : K →+* ℝ
 theorem IsReal.coe_embedding_apply {φ : K →+* ℂ} (hφ : IsReal φ) (x : K) :
     (hφ.Embedding x : ℂ) = φ x := by
   ext; · rfl
-  · rw [of_real_im, eq_comm, ← Complex.eq_conj_iff_im]
+  · rw [of_real_im, eq_comm, ← Complex.conj_eq_iff_im]
     rw [is_real] at hφ
     exact RingHom.congr_fun hφ x
 #align number_field.complex_embedding.is_real.coe_embedding_apply NumberField.ComplexEmbedding.IsReal.coe_embedding_apply
Diff
@@ -90,7 +90,7 @@ theorem coeff_bdd_of_norm_le {B : ℝ} {x : K} (h : ∀ φ : K →+* A, ‖φ x
     ‖(minpoly ℚ x).coeff i‖ ≤ max B 1 ^ finrank ℚ K * (finrank ℚ K).choose (finrank ℚ K / 2) :=
   by
   have hx := IsSeparable.isIntegral ℚ x
-  rw [← norm_algebra_map' A, ← coeff_map (algebraMap ℚ A)]
+  rw [← norm_algebraMap' A, ← coeff_map (algebraMap ℚ A)]
   refine'
     coeff_bdd_of_roots_le _ (minpoly.monic hx) (IsAlgClosed.splits_codomain _)
       (minpoly.natDegree_le hx) (fun z hz => _) i
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alex J. Best, Xavier Roblot
 
 ! This file was ported from Lean 3 source module number_theory.number_field.embeddings
-! leanprover-community/mathlib commit 271bf175e6c51b8d31d6c0107b7bb4a967c7277e
+! leanprover-community/mathlib commit 60da01b41bbe4206f05d34fd70c8dd7498717a30
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -382,10 +382,22 @@ theorem isComplex_iff {w : InfinitePlace K} :
   · exact fun h => ⟨Embedding w, h, mk_embedding w⟩
 #align number_field.infinite_place.is_complex_iff NumberField.InfinitePlace.isComplex_iff
 
+@[simp]
 theorem not_isReal_iff_isComplex {w : InfinitePlace K} : ¬IsReal w ↔ IsComplex w := by
   rw [is_complex_iff, is_real_iff]
 #align number_field.infinite_place.not_is_real_iff_is_complex NumberField.InfinitePlace.not_isReal_iff_isComplex
 
+@[simp]
+theorem not_isComplex_iff_isReal {w : InfinitePlace K} : ¬IsComplex w ↔ IsReal w := by
+  rw [← not_is_real_iff_is_complex, Classical.not_not]
+#align number_field.infinite_place.not_is_complex_iff_is_real NumberField.InfinitePlace.not_isComplex_iff_isReal
+
+theorem isReal_or_isComplex (w : InfinitePlace K) : IsReal w ∨ IsComplex w :=
+  by
+  rw [← not_is_real_iff_is_complex]
+  exact em _
+#align number_field.infinite_place.is_real_or_is_complex NumberField.InfinitePlace.isReal_or_isComplex
+
 /-- For `w` a real infinite place, return the corresponding embedding as a morphism `K →+* ℝ`. -/
 noncomputable def IsReal.embedding {w : InfinitePlace K} (hw : IsReal w) : K →+* ℝ :=
   (isReal_iff.mp hw).Embedding
@@ -399,6 +411,14 @@ theorem IsReal.place_embedding_apply {w : InfinitePlace K} (hw : IsReal w) (x :
   exact congr_fun (congr_arg coeFn (mk_embedding w)) x
 #align number_field.infinite_place.is_real.place_embedding_apply NumberField.InfinitePlace.IsReal.place_embedding_apply
 
+@[simp]
+theorem IsReal.abs_embedding_apply {w : InfinitePlace K} (hw : IsReal w) (x : K) :
+    |IsReal.embedding hw x| = w x :=
+  by
+  rw [← is_real.place_embedding_apply hw x]
+  congr
+#align number_field.infinite_place.is_real.abs_embedding_apply NumberField.InfinitePlace.IsReal.abs_embedding_apply
+
 variable (K)
 
 /-- The map from real embeddings to real infinite places as an equiv -/
Diff
@@ -71,7 +71,7 @@ The images of `x` by the embeddings of `K` in `A` are exactly the roots in `A` o
 the minimal polynomial of `x` over `ℚ`. -/
 theorem range_eval_eq_rootSet_minpoly : (range fun φ : K →+* A => φ x) = (minpoly ℚ x).rootSet A :=
   by
-  convert (NumberField.isAlgebraic K).range_eval_eq_rootSet_minpoly A x using 1
+  convert(NumberField.isAlgebraic K).range_eval_eq_rootSet_minpoly A x using 1
   ext a
   exact ⟨fun ⟨φ, hφ⟩ => ⟨φ.toRatAlgHom, hφ⟩, fun ⟨φ, hφ⟩ => ⟨φ.toRingHom, hφ⟩⟩
 #align number_field.embeddings.range_eval_eq_root_set_minpoly NumberField.Embeddings.range_eval_eq_rootSet_minpoly
@@ -331,11 +331,11 @@ theorem mk_eq_iff {φ ψ : K →+* ℂ} : mk φ = mk ψ ↔ φ = ψ ∨ ComplexE
     cases Complex.uniformContinuous_ringHom_eq_id_or_conj φ.field_range hlip.uniform_continuous
     · left
       ext1 x
-      convert (congr_fun h (ι x)).symm
+      convert(congr_fun h (ι x)).symm
       exact (RingEquiv.apply_symm_apply ι.symm x).symm
     · right
       ext1 x
-      convert (congr_fun h (ι x)).symm
+      convert(congr_fun h (ι x)).symm
       exact (RingEquiv.apply_symm_apply ι.symm x).symm
   · rintro (⟨h⟩ | ⟨h⟩)
     · exact congr_arg mk h
@@ -484,7 +484,7 @@ theorem prod_eq_abs_norm (x : K) :
     (Finset.univ.Prod fun w : InfinitePlace K => ite w.IsReal (w x) (w x ^ 2)) =
       abs (Algebra.norm ℚ x) :=
   by
-  convert (congr_arg Complex.abs (@Algebra.norm_eq_prod_embeddings ℚ _ _ _ _ ℂ _ _ _ _ _ x)).symm
+  convert(congr_arg Complex.abs (@Algebra.norm_eq_prod_embeddings ℚ _ _ _ _ ℂ _ _ _ _ _ x)).symm
   · rw [map_prod, ←
       Equiv.prod_comp' RingHom.equivRatAlgHom (fun f => Complex.abs (f x))
         (fun φ => Complex.abs (φ x)) fun _ => by simpa only [RingHom.equivRatAlgHom_apply] ]
@@ -500,7 +500,7 @@ theorem prod_eq_abs_norm (x : K) :
     rw [Finset.prod_ite, Finset.prod_ite]
     refine' congr (congr_arg Mul.mul _) _
     · rw [← Finset.prod_subtype_eq_prod_filter, ← Finset.prod_subtype_eq_prod_filter]
-      convert (Equiv.prod_comp' (mk_real K) (fun φ => Complex.abs (φ x)) (fun w => w x) _).symm
+      convert(Equiv.prod_comp' (mk_real K) (fun φ => Complex.abs (φ x)) (fun w => w x) _).symm
       any_goals ext; simp only [Finset.mem_subtype, Finset.mem_univ]
       exact fun φ => mk_real.apply K φ x
     · rw [Finset.filter_congr fun (w : infinite_place K) _ => @not_is_real_iff_is_complex K _ w, ←
@@ -520,7 +520,7 @@ open Fintype
 
 theorem card_real_embeddings :
     card { φ : K →+* ℂ // ComplexEmbedding.IsReal φ } = card { w : InfinitePlace K // IsReal w } :=
-  by convert (Fintype.ofEquiv_card (mk_real K)).symm
+  by convert(Fintype.ofEquiv_card (mk_real K)).symm
 #align number_field.infinite_place.card_real_embeddings NumberField.InfinitePlace.card_real_embeddings
 
 theorem card_complex_embeddings :
Diff
@@ -269,7 +269,7 @@ theorem coe_mk (φ : K →+* ℂ) : ⇑(mk φ) = place φ :=
   rfl
 #align number_field.infinite_place.coe_mk NumberField.InfinitePlace.coe_mk
 
-theorem apply (φ : K →+* ℂ) (x : K) : (mk φ) x = Complex.AbsTheory.Complex.abs (φ x) :=
+theorem apply (φ : K →+* ℂ) (x : K) : (mk φ) x = Complex.abs (φ x) :=
   rfl
 #align number_field.infinite_place.apply NumberField.InfinitePlace.apply
 
@@ -284,8 +284,7 @@ theorem mk_embedding (w : InfinitePlace K) : mk (embedding w) = w :=
 #align number_field.infinite_place.mk_embedding NumberField.InfinitePlace.mk_embedding
 
 @[simp]
-theorem abs_embedding (w : InfinitePlace K) (x : K) :
-    Complex.AbsTheory.Complex.abs (embedding w x) = w x :=
+theorem abs_embedding (w : InfinitePlace K) (x : K) : Complex.abs (embedding w x) = w x :=
   congr_fun (congr_arg coeFn w.2.choose_spec) x
 #align number_field.infinite_place.abs_embedding NumberField.InfinitePlace.abs_embedding
 
@@ -440,13 +439,13 @@ theorem mkComplex_coe (φ : { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ }
 
 @[simp]
 theorem mkReal.apply (φ : { φ : K →+* ℂ // ComplexEmbedding.IsReal φ }) (x : K) :
-    mkReal K φ x = Complex.AbsTheory.Complex.abs (φ x) :=
+    mkReal K φ x = Complex.abs (φ x) :=
   apply φ x
 #align number_field.infinite_place.mk_real.apply NumberField.InfinitePlace.mkReal.apply
 
 @[simp]
 theorem mkComplex.apply (φ : { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ }) (x : K) :
-    mkComplex K φ x = Complex.AbsTheory.Complex.abs (φ x) :=
+    mkComplex K φ x = Complex.abs (φ x) :=
   apply φ x
 #align number_field.infinite_place.mk_complex.apply NumberField.InfinitePlace.mkComplex.apply
 
@@ -485,13 +484,10 @@ theorem prod_eq_abs_norm (x : K) :
     (Finset.univ.Prod fun w : InfinitePlace K => ite w.IsReal (w x) (w x ^ 2)) =
       abs (Algebra.norm ℚ x) :=
   by
-  convert
-    (congr_arg Complex.AbsTheory.Complex.abs
-        (@Algebra.norm_eq_prod_embeddings ℚ _ _ _ _ ℂ _ _ _ _ _ x)).symm
+  convert (congr_arg Complex.abs (@Algebra.norm_eq_prod_embeddings ℚ _ _ _ _ ℂ _ _ _ _ _ x)).symm
   · rw [map_prod, ←
-      Equiv.prod_comp' RingHom.equivRatAlgHom (fun f => Complex.AbsTheory.Complex.abs (f x))
-        (fun φ => Complex.AbsTheory.Complex.abs (φ x)) fun _ => by
-        simpa only [RingHom.equivRatAlgHom_apply] ]
+      Equiv.prod_comp' RingHom.equivRatAlgHom (fun f => Complex.abs (f x))
+        (fun φ => Complex.abs (φ x)) fun _ => by simpa only [RingHom.equivRatAlgHom_apply] ]
     dsimp only
     conv =>
       rhs
@@ -499,22 +495,17 @@ theorem prod_eq_abs_norm (x : K) :
       skip
       ext
       rw [(by simp only [if_t_t] :
-          Complex.AbsTheory.Complex.abs (f x) =
-            ite (complex_embedding.is_real f) (Complex.AbsTheory.Complex.abs (f x))
-              (Complex.AbsTheory.Complex.abs (f x)))]
+          Complex.abs (f x) =
+            ite (complex_embedding.is_real f) (Complex.abs (f x)) (Complex.abs (f x)))]
     rw [Finset.prod_ite, Finset.prod_ite]
     refine' congr (congr_arg Mul.mul _) _
     · rw [← Finset.prod_subtype_eq_prod_filter, ← Finset.prod_subtype_eq_prod_filter]
-      convert
-        (Equiv.prod_comp' (mk_real K) (fun φ => Complex.AbsTheory.Complex.abs (φ x)) (fun w => w x)
-            _).symm
+      convert (Equiv.prod_comp' (mk_real K) (fun φ => Complex.abs (φ x)) (fun w => w x) _).symm
       any_goals ext; simp only [Finset.mem_subtype, Finset.mem_univ]
       exact fun φ => mk_real.apply K φ x
     · rw [Finset.filter_congr fun (w : infinite_place K) _ => @not_is_real_iff_is_complex K _ w, ←
         Finset.prod_subtype_eq_prod_filter, ← Finset.prod_subtype_eq_prod_filter]
-      convert
-        Finset.prod_fiberwise Finset.univ (fun φ => mk_complex K φ) fun φ =>
-          Complex.AbsTheory.Complex.abs (φ x)
+      convert Finset.prod_fiberwise Finset.univ (fun φ => mk_complex K φ) fun φ => Complex.abs (φ x)
       any_goals ext; simp only [Finset.mem_subtype, Finset.mem_univ, not_is_real_iff_is_complex]
       · ext w
         rw [@Finset.prod_congr _ _ _ _ _ (fun φ => w x) _ (Eq.refl _) fun φ hφ =>
Diff
@@ -197,8 +197,8 @@ def IsReal.embedding {φ : K →+* ℂ} (hφ : IsReal φ) : K →+* ℝ
   toFun x := (φ x).re
   map_one' := by simp only [map_one, one_re]
   map_mul' := by
-    simp only [complex.eq_conj_iff_im.mp (RingHom.congr_fun hφ _), map_mul, mul_re, mul_zero,
-      tsub_zero, eq_self_iff_true, forall_const]
+    simp only [complex.eq_conj_iff_im.mp (RingHom.congr_fun hφ _), map_mul, mul_re,
+      MulZeroClass.mul_zero, tsub_zero, eq_self_iff_true, forall_const]
   map_zero' := by simp only [map_zero, zero_re]
   map_add' := by simp only [map_add, add_re, eq_self_iff_true, forall_const]
 #align number_field.complex_embedding.is_real.embedding NumberField.ComplexEmbedding.IsReal.embedding
Diff
@@ -269,7 +269,7 @@ theorem coe_mk (φ : K →+* ℂ) : ⇑(mk φ) = place φ :=
   rfl
 #align number_field.infinite_place.coe_mk NumberField.InfinitePlace.coe_mk
 
-theorem apply (φ : K →+* ℂ) (x : K) : (mk φ) x = Complex.abs (φ x) :=
+theorem apply (φ : K →+* ℂ) (x : K) : (mk φ) x = Complex.AbsTheory.Complex.abs (φ x) :=
   rfl
 #align number_field.infinite_place.apply NumberField.InfinitePlace.apply
 
@@ -284,7 +284,8 @@ theorem mk_embedding (w : InfinitePlace K) : mk (embedding w) = w :=
 #align number_field.infinite_place.mk_embedding NumberField.InfinitePlace.mk_embedding
 
 @[simp]
-theorem abs_embedding (w : InfinitePlace K) (x : K) : Complex.abs (embedding w x) = w x :=
+theorem abs_embedding (w : InfinitePlace K) (x : K) :
+    Complex.AbsTheory.Complex.abs (embedding w x) = w x :=
   congr_fun (congr_arg coeFn w.2.choose_spec) x
 #align number_field.infinite_place.abs_embedding NumberField.InfinitePlace.abs_embedding
 
@@ -439,13 +440,13 @@ theorem mkComplex_coe (φ : { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ }
 
 @[simp]
 theorem mkReal.apply (φ : { φ : K →+* ℂ // ComplexEmbedding.IsReal φ }) (x : K) :
-    mkReal K φ x = Complex.abs (φ x) :=
+    mkReal K φ x = Complex.AbsTheory.Complex.abs (φ x) :=
   apply φ x
 #align number_field.infinite_place.mk_real.apply NumberField.InfinitePlace.mkReal.apply
 
 @[simp]
 theorem mkComplex.apply (φ : { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ }) (x : K) :
-    mkComplex K φ x = Complex.abs (φ x) :=
+    mkComplex K φ x = Complex.AbsTheory.Complex.abs (φ x) :=
   apply φ x
 #align number_field.infinite_place.mk_complex.apply NumberField.InfinitePlace.mkComplex.apply
 
@@ -484,10 +485,13 @@ theorem prod_eq_abs_norm (x : K) :
     (Finset.univ.Prod fun w : InfinitePlace K => ite w.IsReal (w x) (w x ^ 2)) =
       abs (Algebra.norm ℚ x) :=
   by
-  convert (congr_arg Complex.abs (@Algebra.norm_eq_prod_embeddings ℚ _ _ _ _ ℂ _ _ _ _ _ x)).symm
+  convert
+    (congr_arg Complex.AbsTheory.Complex.abs
+        (@Algebra.norm_eq_prod_embeddings ℚ _ _ _ _ ℂ _ _ _ _ _ x)).symm
   · rw [map_prod, ←
-      Equiv.prod_comp' RingHom.equivRatAlgHom (fun f => Complex.abs (f x))
-        (fun φ => Complex.abs (φ x)) fun _ => by simpa only [RingHom.equivRatAlgHom_apply] ]
+      Equiv.prod_comp' RingHom.equivRatAlgHom (fun f => Complex.AbsTheory.Complex.abs (f x))
+        (fun φ => Complex.AbsTheory.Complex.abs (φ x)) fun _ => by
+        simpa only [RingHom.equivRatAlgHom_apply] ]
     dsimp only
     conv =>
       rhs
@@ -495,17 +499,22 @@ theorem prod_eq_abs_norm (x : K) :
       skip
       ext
       rw [(by simp only [if_t_t] :
-          Complex.abs (f x) =
-            ite (complex_embedding.is_real f) (Complex.abs (f x)) (Complex.abs (f x)))]
+          Complex.AbsTheory.Complex.abs (f x) =
+            ite (complex_embedding.is_real f) (Complex.AbsTheory.Complex.abs (f x))
+              (Complex.AbsTheory.Complex.abs (f x)))]
     rw [Finset.prod_ite, Finset.prod_ite]
     refine' congr (congr_arg Mul.mul _) _
     · rw [← Finset.prod_subtype_eq_prod_filter, ← Finset.prod_subtype_eq_prod_filter]
-      convert (Equiv.prod_comp' (mk_real K) (fun φ => Complex.abs (φ x)) (fun w => w x) _).symm
+      convert
+        (Equiv.prod_comp' (mk_real K) (fun φ => Complex.AbsTheory.Complex.abs (φ x)) (fun w => w x)
+            _).symm
       any_goals ext; simp only [Finset.mem_subtype, Finset.mem_univ]
       exact fun φ => mk_real.apply K φ x
     · rw [Finset.filter_congr fun (w : infinite_place K) _ => @not_is_real_iff_is_complex K _ w, ←
         Finset.prod_subtype_eq_prod_filter, ← Finset.prod_subtype_eq_prod_filter]
-      convert Finset.prod_fiberwise Finset.univ (fun φ => mk_complex K φ) fun φ => Complex.abs (φ x)
+      convert
+        Finset.prod_fiberwise Finset.univ (fun φ => mk_complex K φ) fun φ =>
+          Complex.AbsTheory.Complex.abs (φ x)
       any_goals ext; simp only [Finset.mem_subtype, Finset.mem_univ, not_is_real_iff_is_complex]
       · ext w
         rw [@Finset.prod_congr _ _ _ _ _ (fun φ => w x) _ (Eq.refl _) fun φ hφ =>
@@ -513,7 +522,7 @@ theorem prod_eq_abs_norm (x : K) :
               (congr_fun (congr_arg coeFn (Finset.mem_filter.1 hφ).2) x),
           Finset.prod_const, mk_complex.filter_card K w]
         rfl
-  · rw [eq_ratCast, ← Complex.abs_of_real, Complex.of_real_rat_cast]
+  · rw [eq_ratCast, ← Complex.abs_ofReal, Complex.ofReal_rat_cast]
 #align number_field.infinite_place.prod_eq_abs_norm NumberField.InfinitePlace.prod_eq_abs_norm
 
 open Fintype
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alex J. Best, Xavier Roblot
 
 ! This file was ported from Lean 3 source module number_theory.number_field.embeddings
-! leanprover-community/mathlib commit ff6bde6f523f6228d5d3d90ffd915624da72a2ab
+! leanprover-community/mathlib commit 271bf175e6c51b8d31d6c0107b7bb4a967c7277e
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -278,11 +278,25 @@ noncomputable def embedding (w : InfinitePlace K) : K →+* ℂ :=
   w.2.some
 #align number_field.infinite_place.embedding NumberField.InfinitePlace.embedding
 
+@[simp]
 theorem mk_embedding (w : InfinitePlace K) : mk (embedding w) = w :=
   Subtype.ext w.2.choose_spec
 #align number_field.infinite_place.mk_embedding NumberField.InfinitePlace.mk_embedding
 
-theorem pos_iff (w : InfinitePlace K) (x : K) : 0 < w x ↔ x ≠ 0 :=
+@[simp]
+theorem abs_embedding (w : InfinitePlace K) (x : K) : Complex.abs (embedding w x) = w x :=
+  congr_fun (congr_arg coeFn w.2.choose_spec) x
+#align number_field.infinite_place.abs_embedding NumberField.InfinitePlace.abs_embedding
+
+theorem eq_iff_eq (x : K) (r : ℝ) : (∀ w : InfinitePlace K, w x = r) ↔ ∀ φ : K →+* ℂ, ‖φ x‖ = r :=
+  ⟨fun hw φ => hw (mk φ), fun hφ ⟨w, ⟨φ, rfl⟩⟩ => hφ φ⟩
+#align number_field.infinite_place.eq_iff_eq NumberField.InfinitePlace.eq_iff_eq
+
+theorem le_iff_le (x : K) (r : ℝ) : (∀ w : InfinitePlace K, w x ≤ r) ↔ ∀ φ : K →+* ℂ, ‖φ x‖ ≤ r :=
+  ⟨fun hw φ => hw (mk φ), fun hφ ⟨w, ⟨φ, rfl⟩⟩ => hφ φ⟩
+#align number_field.infinite_place.le_iff_le NumberField.InfinitePlace.le_iff_le
+
+theorem pos_iff {w : InfinitePlace K} {x : K} : 0 < w x ↔ x ≠ 0 :=
   AbsoluteValue.pos_iff w.1
 #align number_field.infinite_place.pos_iff NumberField.InfinitePlace.pos_iff
 
@@ -339,6 +353,7 @@ def IsComplex (w : InfinitePlace K) : Prop :=
   ∃ φ : K →+* ℂ, ¬ComplexEmbedding.IsReal φ ∧ mk φ = w
 #align number_field.infinite_place.is_complex NumberField.InfinitePlace.IsComplex
 
+@[simp]
 theorem NumberField.ComplexEmbeddings.IsReal.embedding_mk {φ : K →+* ℂ}
     (h : ComplexEmbedding.IsReal φ) : embedding (mk φ) = φ :=
   by
@@ -402,15 +417,35 @@ noncomputable def mkComplex :
   Subtype.map mk fun φ hφ => ⟨φ, hφ, rfl⟩
 #align number_field.infinite_place.mk_complex NumberField.InfinitePlace.mkComplex
 
+theorem mkComplex_embedding (φ : { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ }) :
+    (mkComplex K φ : InfinitePlace K).Embedding = φ ∨
+      (mkComplex K φ : InfinitePlace K).Embedding = ComplexEmbedding.conjugate φ :=
+  by
+  rw [@eq_comm _ _ ↑φ, @eq_comm _ _ (complex_embedding.conjugate ↑φ), ← mk_eq_iff, mk_embedding]
+  rfl
+#align number_field.infinite_place.mk_complex_embedding NumberField.InfinitePlace.mkComplex_embedding
+
+@[simp]
+theorem mkReal_coe (φ : { φ : K →+* ℂ // ComplexEmbedding.IsReal φ }) :
+    (mkReal K φ : InfinitePlace K) = mk (φ : K →+* ℂ) :=
+  rfl
+#align number_field.infinite_place.mk_real_coe NumberField.InfinitePlace.mkReal_coe
+
+@[simp]
+theorem mkComplex_coe (φ : { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ }) :
+    (mkComplex K φ : InfinitePlace K) = mk (φ : K →+* ℂ) :=
+  rfl
+#align number_field.infinite_place.mk_complex_coe NumberField.InfinitePlace.mkComplex_coe
+
 @[simp]
 theorem mkReal.apply (φ : { φ : K →+* ℂ // ComplexEmbedding.IsReal φ }) (x : K) :
-    Complex.abs (φ x) = mkReal K φ x :=
+    mkReal K φ x = Complex.abs (φ x) :=
   apply φ x
 #align number_field.infinite_place.mk_real.apply NumberField.InfinitePlace.mkReal.apply
 
 @[simp]
 theorem mkComplex.apply (φ : { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ }) (x : K) :
-    Complex.abs (φ x) = mkComplex K φ x :=
+    mkComplex K φ x = Complex.abs (φ x) :=
   apply φ x
 #align number_field.infinite_place.mk_complex.apply NumberField.InfinitePlace.mkComplex.apply
 
@@ -474,7 +509,7 @@ theorem prod_eq_abs_norm (x : K) :
       any_goals ext; simp only [Finset.mem_subtype, Finset.mem_univ, not_is_real_iff_is_complex]
       · ext w
         rw [@Finset.prod_congr _ _ _ _ _ (fun φ => w x) _ (Eq.refl _) fun φ hφ =>
-            (mk_complex.apply K φ x).trans
+            (mk_complex.apply K φ x).symm.trans
               (congr_fun (congr_arg coeFn (Finset.mem_filter.1 hφ).2) x),
           Finset.prod_const, mk_complex.filter_card K w]
         rfl

Changes in mathlib4

mathlib3
mathlib4
chore: adapt to multiple goal linter 2 (#12361)

A PR analogous to #12338: reformatting proofs following the multiple goals linter of #12339.

Diff
@@ -661,7 +661,8 @@ lemma comap_surjective [Algebra k K] (h : Algebra.IsAlgebraic k K) :
 lemma mult_comap_le (f : k →+* K) (w : InfinitePlace K) : mult (w.comap f) ≤ mult w := by
   rw [mult, mult]
   split_ifs with h₁ h₂ h₂
-  pick_goal 3; exact (h₁ (h₂.comap _)).elim
+  pick_goal 3
+  · exact (h₁ (h₂.comap _)).elim
   all_goals decide
 
 variable [Algebra k K] [Algebra k F] [Algebra K F] [IsScalarTower k K F]
@@ -956,18 +957,18 @@ lemma card_isUnramified [NumberField k] [IsGalois k K] :
   rw [← IsGalois.card_aut_eq_finrank,
     Finset.card_eq_sum_card_fiberwise (f := (comap · (algebraMap k K)))
     (t := (univ.filter <| IsUnramifiedIn K (k := k))), ← smul_eq_mul, ← sum_const]
-  refine sum_congr rfl (fun w hw ↦ ?_)
-  obtain ⟨w, rfl⟩ := comap_surjective (Normal.isAlgebraic' (K := K)) w
-  simp only [mem_univ, forall_true_left, mem_filter, true_and] at hw
-  trans Finset.card (MulAction.orbit (K ≃ₐ[k] K) w).toFinset
-  · congr; ext w'
-    simp only [mem_univ, forall_true_left, filter_congr_decidable, mem_filter, true_and,
-      Set.mem_toFinset, mem_orbit_iff, @eq_comm _ (comap w' _), and_iff_right_iff_imp]
-    intro e; rwa [← isUnramifiedIn_comap, ← e]
-  · rw [← MulAction.card_orbit_mul_card_stabilizer_eq_card_group _ w,
-      ← Nat.card_eq_fintype_card (α := Stab w), card_stabilizer, if_pos,
-      mul_one, Set.toFinset_card]
-    rwa [← isUnramifiedIn_comap]
+  · refine sum_congr rfl (fun w hw ↦ ?_)
+    obtain ⟨w, rfl⟩ := comap_surjective (Normal.isAlgebraic' (K := K)) w
+    simp only [mem_univ, forall_true_left, mem_filter, true_and] at hw
+    trans Finset.card (MulAction.orbit (K ≃ₐ[k] K) w).toFinset
+    · congr; ext w'
+      simp only [mem_univ, forall_true_left, filter_congr_decidable, mem_filter, true_and,
+        Set.mem_toFinset, mem_orbit_iff, @eq_comm _ (comap w' _), and_iff_right_iff_imp]
+      intro e; rwa [← isUnramifiedIn_comap, ← e]
+    · rw [← MulAction.card_orbit_mul_card_stabilizer_eq_card_group _ w,
+        ← Nat.card_eq_fintype_card (α := Stab w), card_stabilizer, if_pos,
+        mul_one, Set.toFinset_card]
+      rwa [← isUnramifiedIn_comap]
   · simp [isUnramifiedIn_comap]
 
 open Finset BigOperators in
@@ -978,18 +979,18 @@ lemma card_isUnramified_compl [NumberField k] [IsGalois k K] :
   rw [← IsGalois.card_aut_eq_finrank,
     Finset.card_eq_sum_card_fiberwise (f := (comap · (algebraMap k K)))
     (t := (univ.filter <| IsUnramifiedIn K (k := k))ᶜ), ← smul_eq_mul, ← sum_const]
-  refine sum_congr rfl (fun w hw ↦ ?_)
-  obtain ⟨w, rfl⟩ := comap_surjective (Normal.isAlgebraic' (K := K)) w
-  simp only [mem_univ, forall_true_left, compl_filter, not_not, mem_filter, true_and] at hw
-  trans Finset.card (MulAction.orbit (K ≃ₐ[k] K) w).toFinset
-  · congr; ext w'
-    simp only [compl_filter, filter_congr_decidable, mem_filter, mem_univ, true_and,
-      @eq_comm _ (comap w' _), Set.mem_toFinset, mem_orbit_iff, and_iff_right_iff_imp]
-    intro e; rwa [← isUnramifiedIn_comap, ← e]
-  · rw [← MulAction.card_orbit_mul_card_stabilizer_eq_card_group _ w,
-      ← Nat.card_eq_fintype_card (α := Stab w), InfinitePlace.card_stabilizer, if_neg,
-      Nat.mul_div_cancel _ zero_lt_two, Set.toFinset_card]
-    rwa [← isUnramifiedIn_comap]
+  · refine sum_congr rfl (fun w hw ↦ ?_)
+    obtain ⟨w, rfl⟩ := comap_surjective (Normal.isAlgebraic' (K := K)) w
+    simp only [mem_univ, forall_true_left, compl_filter, not_not, mem_filter, true_and] at hw
+    trans Finset.card (MulAction.orbit (K ≃ₐ[k] K) w).toFinset
+    · congr; ext w'
+      simp only [compl_filter, filter_congr_decidable, mem_filter, mem_univ, true_and,
+        @eq_comm _ (comap w' _), Set.mem_toFinset, mem_orbit_iff, and_iff_right_iff_imp]
+      intro e; rwa [← isUnramifiedIn_comap, ← e]
+    · rw [← MulAction.card_orbit_mul_card_stabilizer_eq_card_group _ w,
+        ← Nat.card_eq_fintype_card (α := Stab w), InfinitePlace.card_stabilizer, if_neg,
+        Nat.mul_div_cancel _ zero_lt_two, Set.toFinset_card]
+      rwa [← isUnramifiedIn_comap]
   · simp [isUnramifiedIn_comap]
 
 lemma card_eq_card_isUnramifiedIn [NumberField k] [IsGalois k K] :
feat: Add mixedEmbedding.norm (#12249)

Define a norm of the mixed space ℝ^r₁ × ℂ^r₂ associated to a number field K of signature (r₁, r₂). The norm is defined such that the norm of mixedEmbedding K a for a : K is equal to the absolute value of the norm of a over .

This norm will be used in a future PR about the quotient of the mixed space by the action of the units of K.

Co-authored-by: Xavier Roblot <46200072+xroblot@users.noreply.github.com>

Diff
@@ -430,6 +430,10 @@ theorem embedding_of_isReal_apply {w : InfinitePlace K} (hw : IsReal w) (x : K)
     ((embedding_of_isReal hw) x : ℂ) = (embedding w) x :=
   ComplexEmbedding.IsReal.coe_embedding_apply (isReal_iff.mp hw) x
 
+theorem norm_embedding_of_isReal {w : InfinitePlace K} (hw : IsReal w) (x : K) :
+    ‖embedding_of_isReal hw x‖ = w x := by
+  rw [← norm_embedding_eq, ← embedding_of_isReal_apply hw, Complex.norm_real]
+
 @[simp]
 theorem isReal_of_mk_isReal {φ : K →+* ℂ} (h : IsReal (mk φ)) :
     ComplexEmbedding.IsReal φ := by
chore: Rename 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.

Diff
@@ -523,7 +523,7 @@ theorem prod_eq_abs_norm (x : K) :
       rw [← (Finset.mem_filter.mp hφ).2]
       rfl
     simp_rw [Finset.prod_congr rfl (this _), Finset.prod_const, card_filter_mk_eq]
-  · rw [eq_ratCast, Rat.cast_abs, ← Complex.abs_ofReal, Complex.ofReal_rat_cast]
+  · rw [eq_ratCast, Rat.cast_abs, ← Complex.abs_ofReal, Complex.ofReal_ratCast]
 #align number_field.infinite_place.prod_eq_abs_norm NumberField.InfinitePlace.prod_eq_abs_norm
 
 theorem one_le_of_lt_one {w : InfinitePlace K} {a : (𝓞 K)} (ha : a ≠ 0)
fix: align Int.norm_eq_abs with its mathlib3 meaning (#11841)
Diff
@@ -112,7 +112,7 @@ theorem finite_of_norm_le (B : ℝ) : {x : K | IsIntegral ℤ x ∧ ∀ φ : K 
     exact minpoly.natDegree_le x
   rw [mem_Icc, ← abs_le, ← @Int.cast_le ℝ]
   refine (Eq.trans_le ?_ <| coeff_bdd_of_norm_le hx.2 i).trans (Nat.le_ceil _)
-  rw [h_map_ℚ_minpoly, coeff_map, eq_intCast, Int.norm_cast_rat, Int.norm_eq_abs]
+  rw [h_map_ℚ_minpoly, coeff_map, eq_intCast, Int.norm_cast_rat, Int.norm_eq_abs, Int.cast_abs]
 #align number_field.embeddings.finite_of_norm_le NumberField.Embeddings.finite_of_norm_le
 
 /-- An algebraic integer whose conjugates are all of norm one is a root of unity. -/
chore: avoid Ne.def (adaptation for nightly-2024-03-27) (#11813)
Diff
@@ -465,7 +465,7 @@ theorem card_filter_mk_eq [NumberField K] (w : InfinitePlace K) :
   · rw [ComplexEmbedding.isReal_iff.mp (isReal_iff.mp hw), Finset.union_idempotent,
       Finset.card_singleton]
   · refine Finset.card_pair ?_
-    rwa [Ne.def, eq_comm, ← ComplexEmbedding.isReal_iff, ← isReal_iff]
+    rwa [Ne, eq_comm, ← ComplexEmbedding.isReal_iff, ← isReal_iff]
 
 open scoped BigOperators
 
feat: add card_eq_NrRealPlaces_add_NrComplexPlaces (#11745)

We add card_eq_NrRealPlaces_add_NrComplexPlaces: Fintype.card (InfinitePlace K).card = NrRealPlaces K + NrComplexPlaces K for a number field K.

Diff
@@ -415,6 +415,11 @@ theorem isReal_or_isComplex (w : InfinitePlace K) : IsReal w ∨ IsComplex w :=
 theorem ne_of_isReal_isComplex {w w' : InfinitePlace K} (h : IsReal w) (h' : IsComplex w') :
     w ≠ w' := fun h_eq ↦ not_isReal_iff_isComplex.mpr h' (h_eq ▸ h)
 
+variable (K) in
+theorem disjoint_isReal_isComplex :
+    Disjoint {(w : InfinitePlace K) | IsReal w} {(w : InfinitePlace K) | IsComplex w} :=
+  Set.disjoint_iff.2 <| fun _ hw ↦ not_isReal_iff_isComplex.2 hw.2 hw.1
+
 /-- The real embedding associated to a real infinite place. -/
 noncomputable def embedding_of_isReal {w : InfinitePlace K} (hw : IsReal w) : K →+* ℝ :=
   ComplexEmbedding.IsReal.embedding (isReal_iff.mp hw)
@@ -581,6 +586,12 @@ theorem card_real_embeddings :
     card { φ : K →+* ℂ // ComplexEmbedding.IsReal φ } = NrRealPlaces K := Fintype.card_congr mkReal
 #align number_field.infinite_place.card_real_embeddings NumberField.InfinitePlace.card_real_embeddings
 
+theorem card_eq_nrRealPlaces_add_nrComplexPlaces :
+    Fintype.card (InfinitePlace K) = NrRealPlaces K + NrComplexPlaces K := by
+  convert Fintype.card_subtype_or_disjoint (IsReal (K := K)) (IsComplex (K := K))
+    (disjoint_isReal_isComplex K) using 1
+  exact (Fintype.card_of_subtype _ (fun w ↦ ⟨fun _ ↦ isReal_or_isComplex w, fun _ ↦ by simp⟩)).symm
+
 theorem card_complex_embeddings :
     card { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ } = 2 * NrComplexPlaces K := by
   suffices ∀ w : { w : InfinitePlace K // IsComplex w }, (Finset.univ.filter
chore: avoid some unused variables (#11594)

These will be caught by the linter in a future lean version.

Diff
@@ -547,17 +547,17 @@ theorem _root_.NumberField.is_primitive_element_of_infinitePlace_lt {x : 𝓞 K}
       contrapose! h
       exact h₂ h.symm
     rw [(mk_embedding w).symm, mk_eq_iff] at main
-    by_cases hw : IsReal w
-    · rw [conjugate_embedding_eq_of_isReal hw, or_self] at main
+    cases h₃ with
+    | inl hw =>
+      rw [conjugate_embedding_eq_of_isReal hw, or_self] at main
       exact congr_arg RingHom.toRatAlgHom main
-    · refine congr_arg RingHom.toRatAlgHom (main.resolve_right fun h' ↦ ?_)
+    | inr hw =>
+      refine congr_arg RingHom.toRatAlgHom (main.resolve_right fun h' ↦ hw.not_le ?_)
       have : (embedding w x).im = 0 := by
         erw [← Complex.conj_eq_iff_im, RingHom.congr_fun h' x]
         exact hψ.symm
-      contrapose! h
-      rw [← norm_embedding_eq, ← Complex.re_add_im (embedding w x), this, Complex.ofReal_zero,
-        zero_mul, add_zero, Complex.norm_eq_abs, Complex.abs_ofReal]
-      exact h₃.resolve_left hw
+      rwa [← norm_embedding_eq, ← Complex.re_add_im (embedding w x), this, Complex.ofReal_zero,
+        zero_mul, add_zero, Complex.norm_eq_abs, Complex.abs_ofReal] at h
   · exact fun x ↦ IsAlgClosed.splits_codomain (minpoly ℚ x)
 
 theorem _root_.NumberField.adjoin_eq_top_of_infinitePlace_lt {x : 𝓞 K} {w : InfinitePlace K}
chore: Rename cat_coe_nat/cast_coe_int to cast_natCast/cast_intCast (#11552)

Reduce the diff of #11499

Diff
@@ -532,7 +532,7 @@ theorem one_le_of_lt_one {w : InfinitePlace K} {a : (𝓞 K)} (ha : a ≠ 0)
       by_cases hz : z = w
       · rwa [hz]
       · exact h hz
-  rw [← Algebra.coe_norm_int, ← Int.cast_one, ← Int.cast_abs, Rat.cast_coe_int, Int.cast_le]
+  rw [← Algebra.coe_norm_int, ← Int.cast_one, ← Int.cast_abs, Rat.cast_intCast, Int.cast_le]
   exact Int.one_le_abs (Algebra.norm_ne_zero_iff.mpr ha)
 
 open scoped IntermediateField in
chore: tidy various files (#11490)
Diff
@@ -277,9 +277,9 @@ namespace NumberField.InfinitePlace
 
 open NumberField
 
-instance {K : Type*} [Field K] : FunLike (InfinitePlace K) K ℝ :=
-{ coe := fun w x => w.1 x
-  coe_injective' := fun _ _ h => Subtype.eq (AbsoluteValue.ext fun x => congr_fun h x)}
+instance {K : Type*} [Field K] : FunLike (InfinitePlace K) K ℝ where
+  coe w x := w.1 x
+  coe_injective' := fun _ _ h => Subtype.eq (AbsoluteValue.ext fun x => congr_fun h x)
 
 instance : MonoidWithZeroHomClass (InfinitePlace K) K ℝ where
   map_mul w _ _ := w.1.map_mul _ _
@@ -1057,12 +1057,12 @@ theorem nrRealPlaces_eq_zero_of_two_lt (hk : 2 < k) (hζ : IsPrimitiveRoot ζ k)
   let f := w.embedding
   have hζ' : IsPrimitiveRoot (f ζ) k := hζ.map_of_injective f.injective
   have him : (f ζ).im = 0 := by
-    · rw [← Complex.conj_eq_iff_im, ← NumberField.ComplexEmbedding.conjugate_coe_eq]
-      congr
+    rw [← Complex.conj_eq_iff_im, ← NumberField.ComplexEmbedding.conjugate_coe_eq]
+    congr
   have hre : (f ζ).re = 1 ∨ (f ζ).re = -1 := by
-    · rw [← Complex.abs_re_eq_abs] at him
-      have := Complex.norm_eq_one_of_pow_eq_one hζ'.pow_eq_one (by linarith)
-      rwa [Complex.norm_eq_abs, ← him, ← abs_one, abs_eq_abs] at this
+    rw [← Complex.abs_re_eq_abs] at him
+    have := Complex.norm_eq_one_of_pow_eq_one hζ'.pow_eq_one (by linarith)
+    rwa [Complex.norm_eq_abs, ← him, ← abs_one, abs_eq_abs] at this
   cases hre with
   | inl hone =>
     exact hζ'.ne_one (by linarith) <| Complex.ext (by simp [hone]) (by simp [him])
chore(*): remove empty lines between variable statements (#11418)

Empty lines were removed by executing the following Python script twice

import os
import re


# Loop through each file in the repository
for dir_path, dirs, files in os.walk('.'):
  for filename in files:
    if filename.endswith('.lean'):
      file_path = os.path.join(dir_path, filename)

      # Open the file and read its contents
      with open(file_path, 'r') as file:
        content = file.read()

      # Use a regular expression to replace sequences of "variable" lines separated by empty lines
      # with sequences without empty lines
      modified_content = re.sub(r'(variable.*\n)\n(variable(?! .* in))', r'\1\2', content)

      # Write the modified content back to the file
      with open(file_path, 'w') as file:
        file.write(modified_content)
Diff
@@ -42,7 +42,6 @@ section Fintype
 open FiniteDimensional
 
 variable (K : Type*) [Field K] [NumberField K]
-
 variable (A : Type*) [Field A] [CharZero A]
 
 /-- There are finitely many embeddings of a number field. -/
@@ -85,7 +84,6 @@ section Bounded
 open FiniteDimensional Polynomial Set
 
 variable {K : Type*} [Field K] [NumberField K]
-
 variable {A : Type*} [NormedField A] [IsAlgClosed A] [NormedAlgebra ℚ A]
 
 theorem coeff_bdd_of_norm_le {B : ℝ} {x : K} (h : ∀ φ : K →+* A, ‖φ x‖ ≤ B) (i : ℕ) :
@@ -653,7 +651,6 @@ lemma mult_comap_le (f : k →+* K) (w : InfinitePlace K) : mult (w.comap f) ≤
 
 variable [Algebra k K] [Algebra k F] [Algebra K F] [IsScalarTower k K F]
 variable (σ : K ≃ₐ[k] K) (w : InfinitePlace K)
-
 variable (k K)
 
 lemma card_mono [NumberField k] [NumberField K] :
feat: cyclotomic fields are totally complex (#10502)

We prove that cyclotomic fields are totally complex.

From flt-regular.

Diff
@@ -5,7 +5,10 @@ Authors: Alex J. Best, Xavier Roblot
 -/
 import Mathlib.Analysis.Complex.Polynomial
 import Mathlib.NumberTheory.NumberField.Norm
+import Mathlib.NumberTheory.NumberField.Basic
+import Mathlib.RingTheory.Norm
 import Mathlib.Topology.Instances.Complex
+import Mathlib.RingTheory.RootsOfUnity.Basic
 
 #align_import number_theory.number_field.embeddings from "leanprover-community/mathlib"@"caa58cbf5bfb7f81ccbaca4e8b8ac4bc2b39cc1c"
 
@@ -606,6 +609,14 @@ theorem card_add_two_mul_card_eq_rank :
 
 variable {K}
 
+theorem nrComplexPlaces_eq_zero_of_finrank_eq_one (h : finrank ℚ K = 1) :
+    NrComplexPlaces K = 0 := by linarith [card_add_two_mul_card_eq_rank K]
+
+theorem nrRealPlaces_eq_one_of_finrank_eq_one (h : finrank ℚ K = 1) :
+    NrRealPlaces K = 1 := by
+  have := card_add_two_mul_card_eq_rank K
+  rwa [nrComplexPlaces_eq_zero_of_finrank_eq_one h, h, mul_zero, add_zero] at this
+
 /-- The restriction of an infinite place along an embedding. -/
 def comap (w : InfinitePlace K) (f : k →+* K) : InfinitePlace k :=
   ⟨w.1.comp f.injective, w.embedding.comp f,
@@ -1037,3 +1048,31 @@ lemma IsUnramifiedAtInfinitePlaces.card_infinitePlace [NumberField k] [NumberFie
   exact InfinitePlace.isUnramifiedIn K
 
 end InfinitePlace
+
+namespace IsPrimitiveRoot
+
+variable {K : Type*} [Field K] [NumberField K] {ζ : K} {k : ℕ}
+
+theorem nrRealPlaces_eq_zero_of_two_lt (hk : 2 < k) (hζ : IsPrimitiveRoot ζ k) :
+    NumberField.InfinitePlace.NrRealPlaces K = 0 := by
+  refine (@Fintype.card_eq_zero_iff _ (_)).2 ⟨fun ⟨w, hwreal⟩ ↦ ?_⟩
+  rw [NumberField.InfinitePlace.isReal_iff] at hwreal
+  let f := w.embedding
+  have hζ' : IsPrimitiveRoot (f ζ) k := hζ.map_of_injective f.injective
+  have him : (f ζ).im = 0 := by
+    · rw [← Complex.conj_eq_iff_im, ← NumberField.ComplexEmbedding.conjugate_coe_eq]
+      congr
+  have hre : (f ζ).re = 1 ∨ (f ζ).re = -1 := by
+    · rw [← Complex.abs_re_eq_abs] at him
+      have := Complex.norm_eq_one_of_pow_eq_one hζ'.pow_eq_one (by linarith)
+      rwa [Complex.norm_eq_abs, ← him, ← abs_one, abs_eq_abs] at this
+  cases hre with
+  | inl hone =>
+    exact hζ'.ne_one (by linarith) <| Complex.ext (by simp [hone]) (by simp [him])
+  | inr hnegone =>
+    replace hζ' := hζ'.eq_orderOf
+    simp only [show f ζ = -1 from Complex.ext (by simp [hnegone]) (by simp [him]),
+      orderOf_neg_one, ringChar.eq_zero, OfNat.zero_ne_ofNat, ↓reduceIte] at hζ'
+    linarith
+
+end IsPrimitiveRoot
feat: Proof of Hermite theorem on number fields of bounded discriminant (#10030)

Let N be an integer. Then there are only finitely many number fields (in some fixed extension of ) of discriminant bounded in absolute value by N.

Diff
@@ -411,6 +411,9 @@ theorem isReal_or_isComplex (w : InfinitePlace K) : IsReal w ∨ IsComplex w :=
   rw [← not_isReal_iff_isComplex]; exact em _
 #align number_field.infinite_place.is_real_or_is_complex NumberField.InfinitePlace.isReal_or_isComplex
 
+theorem ne_of_isReal_isComplex {w w' : InfinitePlace K} (h : IsReal w) (h' : IsComplex w') :
+    w ≠ w' := fun h_eq ↦ not_isReal_iff_isComplex.mpr h' (h_eq ▸ h)
+
 /-- The real embedding associated to a real infinite place. -/
 noncomputable def embedding_of_isReal {w : InfinitePlace K} (hw : IsReal w) : K →+* ℝ :=
   ComplexEmbedding.IsReal.embedding (isReal_iff.mp hw)
chore: Remove unnecessary "rw"s (#10704)

Remove unnecessary "rw"s.

Diff
@@ -111,7 +111,7 @@ theorem finite_of_norm_le (B : ℝ) : {x : K | IsIntegral ℤ x ∧ ∀ φ : K 
     exact minpoly.natDegree_le x
   rw [mem_Icc, ← abs_le, ← @Int.cast_le ℝ]
   refine (Eq.trans_le ?_ <| coeff_bdd_of_norm_le hx.2 i).trans (Nat.le_ceil _)
-  rw [h_map_ℚ_minpoly, coeff_map, eq_intCast, Int.norm_cast_rat, Int.norm_eq_abs, Int.cast_abs]
+  rw [h_map_ℚ_minpoly, coeff_map, eq_intCast, Int.norm_cast_rat, Int.norm_eq_abs]
 #align number_field.embeddings.finite_of_norm_le NumberField.Embeddings.finite_of_norm_le
 
 /-- An algebraic integer whose conjugates are all of norm one is a root of unity. -/
feat: Add NumberField.is_primitive_element_of_infinitePlace_lt (#10033)

Prove the following

theorem NumberField.is_primitive_element_of_infinitePlace_lt (x : 𝓞 K)
     {w : InfinitePlace K} (h₁ : x ≠ 0) (h₂ : ∀ ⦃w'⦄, w' ≠ w → w' x < 1)
     (h₃ : IsReal w ∨ |(w.embedding x).re| < 1) : ℚ⟮(x:K)⟯ = ⊤ := by

If the place w is not real, we need the condition |(w.embedding x).re| < 1 to ensure x is not a real number at the place w.

Diff
@@ -4,9 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alex J. Best, Xavier Roblot
 -/
 import Mathlib.Analysis.Complex.Polynomial
-import Mathlib.FieldTheory.Minpoly.IsIntegrallyClosed
-import Mathlib.NumberTheory.NumberField.Basic
-import Mathlib.RingTheory.Norm
+import Mathlib.NumberTheory.NumberField.Norm
 import Mathlib.Topology.Instances.Complex
 
 #align_import number_theory.number_field.embeddings from "leanprover-community/mathlib"@"caa58cbf5bfb7f81ccbaca4e8b8ac4bc2b39cc1c"
@@ -519,6 +517,52 @@ theorem prod_eq_abs_norm (x : K) :
   · rw [eq_ratCast, Rat.cast_abs, ← Complex.abs_ofReal, Complex.ofReal_rat_cast]
 #align number_field.infinite_place.prod_eq_abs_norm NumberField.InfinitePlace.prod_eq_abs_norm
 
+theorem one_le_of_lt_one {w : InfinitePlace K} {a : (𝓞 K)} (ha : a ≠ 0)
+    (h : ∀ ⦃z⦄, z ≠ w → z a < 1) : 1 ≤ w a := by
+  suffices (1:ℝ) ≤ |(Algebra.norm ℚ) (a:K)| by
+    contrapose! this
+    rw [← InfinitePlace.prod_eq_abs_norm, ← Finset.prod_const_one]
+    refine Finset.prod_lt_prod_of_nonempty (fun _ _ ↦ ?_) (fun z _ ↦ ?_) Finset.univ_nonempty
+    · exact pow_pos (pos_iff.mpr ((Subalgebra.coe_eq_zero _).not.mpr ha)) _
+    · refine pow_lt_one (apply_nonneg _ _) ?_ (by rw [mult]; split_ifs <;> norm_num)
+      by_cases hz : z = w
+      · rwa [hz]
+      · exact h hz
+  rw [← Algebra.coe_norm_int, ← Int.cast_one, ← Int.cast_abs, Rat.cast_coe_int, Int.cast_le]
+  exact Int.one_le_abs (Algebra.norm_ne_zero_iff.mpr ha)
+
+open scoped IntermediateField in
+theorem _root_.NumberField.is_primitive_element_of_infinitePlace_lt {x : 𝓞 K}
+    {w : InfinitePlace K} (h₁ : x ≠ 0) (h₂ : ∀ ⦃w'⦄, w' ≠ w → w' x < 1)
+    (h₃ : IsReal w ∨ |(w.embedding x).re| < 1) : ℚ⟮(x:K)⟯ = ⊤ := by
+  rw [Field.primitive_element_iff_algHom_eq_of_eval ℚ ℂ ?_ _ w.embedding.toRatAlgHom]
+  · intro ψ hψ
+    have h : 1 ≤ w x := one_le_of_lt_one h₁ h₂
+    have main : w = InfinitePlace.mk ψ.toRingHom := by
+      erw [← norm_embedding_eq, hψ] at h
+      contrapose! h
+      exact h₂ h.symm
+    rw [(mk_embedding w).symm, mk_eq_iff] at main
+    by_cases hw : IsReal w
+    · rw [conjugate_embedding_eq_of_isReal hw, or_self] at main
+      exact congr_arg RingHom.toRatAlgHom main
+    · refine congr_arg RingHom.toRatAlgHom (main.resolve_right fun h' ↦ ?_)
+      have : (embedding w x).im = 0 := by
+        erw [← Complex.conj_eq_iff_im, RingHom.congr_fun h' x]
+        exact hψ.symm
+      contrapose! h
+      rw [← norm_embedding_eq, ← Complex.re_add_im (embedding w x), this, Complex.ofReal_zero,
+        zero_mul, add_zero, Complex.norm_eq_abs, Complex.abs_ofReal]
+      exact h₃.resolve_left hw
+  · exact fun x ↦ IsAlgClosed.splits_codomain (minpoly ℚ x)
+
+theorem _root_.NumberField.adjoin_eq_top_of_infinitePlace_lt {x : 𝓞 K} {w : InfinitePlace K}
+    (h₁ : x ≠ 0) (h₂ : ∀ ⦃w'⦄, w' ≠ w → w' x < 1) (h₃ : IsReal w ∨ |(w.embedding x).re| < 1) :
+    Algebra.adjoin ℚ {(x:K)} = ⊤ := by
+  rw [← IntermediateField.adjoin_simple_toSubalgebra_of_integral (IsIntegral.of_finite ℚ _)]
+  exact congr_arg IntermediateField.toSubalgebra <|
+    NumberField.is_primitive_element_of_infinitePlace_lt h₁ h₂ h₃
+
 open Fintype FiniteDimensional
 
 variable (K)
chore(NonnegHomClass): rename map_nonneg to apply_nonneg (#10507)

... to avoid conflict with _root_.map_nonneg, see Zulip.

Diff
@@ -288,7 +288,7 @@ instance : MonoidWithZeroHomClass (InfinitePlace K) K ℝ where
   map_zero w := w.1.map_zero
 
 instance : NonnegHomClass (InfinitePlace K) K ℝ where
-  map_nonneg w _ := w.1.nonneg _
+  apply_nonneg w _ := w.1.nonneg _
 
 @[simp]
 theorem apply (φ : K →+* ℂ) (x : K) : (mk φ) x = Complex.abs (φ x) := rfl
chore: tidy various files (#10311)
Diff
@@ -792,10 +792,11 @@ lemma nat_card_stabilizer_eq_one_or_two :
     · right; simp [*]
   · push_neg at h
     left
-    convert show Nat.card ({1} : Set (K ≃ₐ[k] K)) = 1 by simp
-    ext
-    simp only [SetLike.mem_coe, mem_stabilizer_mk_iff, Set.mem_singleton_iff, or_iff_left_iff_imp]
-    exact fun x ↦ (h _ x).elim
+    trans Nat.card ({1} : Set (K ≃ₐ[k] K))
+    · congr with x
+      simp only [SetLike.mem_coe, mem_stabilizer_mk_iff, Set.mem_singleton_iff, or_iff_left_iff_imp,
+        h x, IsEmpty.forall_iff]
+    · simp
 
 variable {k w}
 
refactor(Data/FunLike): use unbundled inheritance from FunLike (#8386)

The FunLike hierarchy is very big and gets scanned through each time we need a coercion (via the CoeFun instance). It looks like unbundled inheritance suits Lean 4 better here. The only class that still extends FunLike is EquivLike, since that has a custom coe_injective' field that is easier to implement. All other classes should take FunLike or EquivLike as a parameter.

Zulip thread

Important changes

Previously, morphism classes would be Type-valued and extend FunLike:

/-- `MyHomClass F A B` states that `F` is a type of `MyClass.op`-preserving morphisms.
You should extend this class when you extend `MyHom`. -/
class MyHomClass (F : Type*) (A B : outParam <| Type*) [MyClass A] [MyClass B]
  extends FunLike F A B :=
(map_op : ∀ (f : F) (x y : A), f (MyClass.op x y) = MyClass.op (f x) (f y))

After this PR, they should be Prop-valued and take FunLike as a parameter:

/-- `MyHomClass F A B` states that `F` is a type of `MyClass.op`-preserving morphisms.
You should extend this class when you extend `MyHom`. -/
class MyHomClass (F : Type*) (A B : outParam <| Type*) [MyClass A] [MyClass B]
  [FunLike F A B] : Prop :=
(map_op : ∀ (f : F) (x y : A), f (MyClass.op x y) = MyClass.op (f x) (f y))

(Note that A B stay marked as outParam even though they are not purely required to be so due to the FunLike parameter already filling them in. This is required to see through type synonyms, which is important in the category theory library. Also, I think keeping them as outParam is slightly faster.)

Similarly, MyEquivClass should take EquivLike as a parameter.

As a result, every mention of [MyHomClass F A B] should become [FunLike F A B] [MyHomClass F A B].

Remaining issues

Slower (failing) search

While overall this gives some great speedups, there are some cases that are noticeably slower. In particular, a failing application of a lemma such as map_mul is more expensive. This is due to suboptimal processing of arguments. For example:

variable [FunLike F M N] [Mul M] [Mul N] (f : F) (x : M) (y : M)

theorem map_mul [MulHomClass F M N] : f (x * y) = f x * f y

example [AddHomClass F A B] : f (x * y) = f x * f y := map_mul f _ _

Before this PR, applying map_mul f gives the goals [Mul ?M] [Mul ?N] [MulHomClass F ?M ?N]. Since M and N are out_params, [MulHomClass F ?M ?N] is synthesized first, supplies values for ?M and ?N and then the Mul M and Mul N instances can be found.

After this PR, the goals become [FunLike F ?M ?N] [Mul ?M] [Mul ?N] [MulHomClass F ?M ?N]. Now [FunLike F ?M ?N] is synthesized first, supplies values for ?M and ?N and then the Mul M and Mul N instances can be found, before trying MulHomClass F M N which fails. Since the Mul hierarchy is very big, this can be slow to fail, especially when there is no such Mul instance.

A long-term but harder to achieve solution would be to specify the order in which instance goals get solved. For example, we'd like to change the arguments to map_mul to look like [FunLike F M N] [Mul M] [Mul N] [highPriority <| MulHomClass F M N] because MulHomClass fails or succeeds much faster than the others.

As a consequence, the simpNF linter is much slower since by design it tries and fails to apply many map_ lemmas. The same issue occurs a few times in existing calls to simp [map_mul], where map_mul is tried "too soon" and fails. Thanks to the speedup of leanprover/lean4#2478 the impact is very limited, only in files that already were close to the timeout.

simp not firing sometimes

This affects map_smulₛₗ and related definitions. For simp lemmas Lean apparently uses a slightly different mechanism to find instances, so that rw can find every argument to map_smulₛₗ successfully but simp can't: leanprover/lean4#3701.

Missing instances due to unification failing

Especially in the category theory library, we might sometimes have a type A which is also accessible as a synonym (Bundled A hA).1. Instance synthesis doesn't always work if we have f : A →* B but x * y : (Bundled A hA).1 or vice versa. This seems to be mostly fixed by keeping A B as outParams in MulHomClass F A B. (Presumably because Lean will do a definitional check A =?= (Bundled A hA).1 instead of using the syntax in the discrimination tree.)

Workaround for issues

The timeouts can be worked around for now by specifying which map_mul we mean, either as map_mul f for some explicit f, or as e.g. MonoidHomClass.map_mul.

map_smulₛₗ not firing as simp lemma can be worked around by going back to the pre-FunLike situation and making LinearMap.map_smulₛₗ a simp lemma instead of the generic map_smulₛₗ. Writing simp [map_smulₛₗ _] also works.

Co-authored-by: Matthew Ballard <matt@mrb.email> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Scott Morrison <scott@tqft.net> Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>

Diff
@@ -283,15 +283,11 @@ instance {K : Type*} [Field K] : FunLike (InfinitePlace K) K ℝ :=
   coe_injective' := fun _ _ h => Subtype.eq (AbsoluteValue.ext fun x => congr_fun h x)}
 
 instance : MonoidWithZeroHomClass (InfinitePlace K) K ℝ where
-  coe w x := w.1 x
-  coe_injective' _ _ h := Subtype.eq (AbsoluteValue.ext fun x => congr_fun h x)
   map_mul w _ _ := w.1.map_mul _ _
   map_one w := w.1.map_one
   map_zero w := w.1.map_zero
 
 instance : NonnegHomClass (InfinitePlace K) K ℝ where
-  coe w x := w x
-  coe_injective' _ _ h := Subtype.eq (AbsoluteValue.ext fun x => congr_fun h x)
   map_nonneg w _ := w.1.nonneg _
 
 @[simp]
refactor(*): abbreviation for non-dependent FunLike (#9833)

This follows up from #9785, which renamed FunLike to DFunLike, by introducing a new abbreviation FunLike F α β := DFunLike F α (fun _ => β), to make the non-dependent use of FunLike easier.

I searched for the pattern DFunLike.*fun and DFunLike.*λ in all files to replace expressions of the form DFunLike F α (fun _ => β) with FunLike F α β. I did this everywhere except for extends clauses for two reasons: it would conflict with #8386, and more importantly extends must directly refer to a structure with no unfolding of defs or abbrevs.

Diff
@@ -278,7 +278,7 @@ namespace NumberField.InfinitePlace
 
 open NumberField
 
-instance {K : Type*} [Field K] : DFunLike (InfinitePlace K) K (fun _ => ℝ) :=
+instance {K : Type*} [Field K] : FunLike (InfinitePlace K) K ℝ :=
 { coe := fun w x => w.1 x
   coe_injective' := fun _ _ h => Subtype.eq (AbsoluteValue.ext fun x => congr_fun h x)}
 
chore(*): rename FunLike to DFunLike (#9785)

This prepares for the introduction of a non-dependent synonym of FunLike, which helps a lot with keeping #8386 readable.

This is entirely search-and-replace in 680197f combined with manual fixes in 4145626, e900597 and b8428f8. The commands that generated this change:

sed -i 's/\bFunLike\b/DFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\btoFunLike\b/toDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/import Mathlib.Data.DFunLike/import Mathlib.Data.FunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\bHom_FunLike\b/Hom_DFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean     
sed -i 's/\binstFunLike\b/instDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\bfunLike\b/instDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\btoo many metavariables to apply `fun_like.has_coe_to_fun`/too many metavariables to apply `DFunLike.hasCoeToFun`/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean

Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>

Diff
@@ -278,7 +278,7 @@ namespace NumberField.InfinitePlace
 
 open NumberField
 
-instance {K : Type*} [Field K] : FunLike (InfinitePlace K) K (fun _ => ℝ) :=
+instance {K : Type*} [Field K] : DFunLike (InfinitePlace K) K (fun _ => ℝ) :=
 { coe := fun w x => w.1 x
   coe_injective' := fun _ _ h => Subtype.eq (AbsoluteValue.ext fun x => congr_fun h x)}
 
@@ -308,7 +308,7 @@ theorem mk_embedding (w : InfinitePlace K) : mk (embedding w) = w := Subtype.ext
 
 @[simp]
 theorem mk_conjugate_eq (φ : K →+* ℂ) : mk (ComplexEmbedding.conjugate φ) = mk φ := by
-  refine FunLike.ext _ _ (fun x => ?_)
+  refine DFunLike.ext _ _ (fun x => ?_)
   rw [apply, apply, ComplexEmbedding.conjugate_coe_eq, Complex.abs_conj]
 #align number_field.infinite_place.mk_conjugate_eq NumberField.InfinitePlace.mk_conjugate_eq
 
feat: Define IsUnramifiedAtInfinitePlaces. (#9293)

Co-authored-by: Andrew Yang <36414270+erdOne@users.noreply.github.com>

Diff
@@ -571,6 +571,8 @@ def comap (w : InfinitePlace K) (f : k →+* K) : InfinitePlace k :=
 @[simp]
 lemma comap_mk (φ : K →+* ℂ) (f : k →+* K) : (mk φ).comap f = mk (φ.comp f) := rfl
 
+lemma comap_id (w : InfinitePlace K) : w.comap (RingHom.id K) = w := rfl
+
 lemma comap_comp (w : InfinitePlace K) (f : F →+* K) (g : k →+* F) :
     w.comap (f.comp g) = (w.comap f).comap g := rfl
 
@@ -589,7 +591,23 @@ lemma comap_surjective [Algebra k K] (h : Algebra.IsAlgebraic k K) :
   letI := w.embedding.toAlgebra
   ⟨mk (IsAlgClosed.lift (M := ℂ) h), by simp [comap_mk, RingHom.algebraMap_toAlgebra]⟩
 
-variable [Algebra k K] (σ : K ≃ₐ[k] K) (w : InfinitePlace K)
+lemma mult_comap_le (f : k →+* K) (w : InfinitePlace K) : mult (w.comap f) ≤ mult w := by
+  rw [mult, mult]
+  split_ifs with h₁ h₂ h₂
+  pick_goal 3; exact (h₁ (h₂.comap _)).elim
+  all_goals decide
+
+variable [Algebra k K] [Algebra k F] [Algebra K F] [IsScalarTower k K F]
+variable (σ : K ≃ₐ[k] K) (w : InfinitePlace K)
+
+variable (k K)
+
+lemma card_mono [NumberField k] [NumberField K] :
+    card (InfinitePlace k) ≤ card (InfinitePlace K) :=
+  have := Module.Finite.of_restrictScalars_finite ℚ k K
+  Fintype.card_le_of_surjective _ (comap_surjective (Algebra.IsAlgebraic.of_finite k K))
+
+variable {k K}
 
 /-- The action of the galois group on infinite places. -/
 @[simps! smul_coe_apply]
@@ -669,7 +687,37 @@ An infinite place is unramified in a field extension if the restriction has the
 -/
 def IsUnramified : Prop := mult (w.comap (algebraMap k K)) = mult w
 
-variable {k w}
+variable {k}
+
+lemma isUnramified_self : IsUnramified K w := rfl
+
+variable {w}
+
+lemma IsUnramified.eq (h : IsUnramified k w) : mult (w.comap (algebraMap k K)) = mult w := h
+
+lemma isUnramified_iff_mult_le :
+    IsUnramified k w ↔ mult w ≤ mult (w.comap (algebraMap k K)) := by
+  rw [IsUnramified, le_antisymm_iff, and_iff_right]
+  exact mult_comap_le _ _
+
+lemma IsUnramified.comap_algHom {w : InfinitePlace F} (h : IsUnramified k w) (f : K →ₐ[k] F) :
+    IsUnramified k (w.comap (f : K →+* F)) := by
+  rw [InfinitePlace.isUnramified_iff_mult_le, ← InfinitePlace.comap_comp, f.comp_algebraMap, h.eq]
+  exact InfinitePlace.mult_comap_le _ _
+
+variable (K)
+
+lemma IsUnramified.of_restrictScalars {w : InfinitePlace F} (h : IsUnramified k w) :
+    IsUnramified K w := by
+  rw [InfinitePlace.isUnramified_iff_mult_le, ← h.eq, IsScalarTower.algebraMap_eq k K F,
+    InfinitePlace.comap_comp]
+  exact InfinitePlace.mult_comap_le _ _
+
+lemma IsUnramified.comap {w : InfinitePlace F} (h : IsUnramified k w) :
+    IsUnramified k (w.comap (algebraMap K F)) :=
+  h.comap_algHom (IsScalarTower.toAlgHom k K F)
+
+variable {K}
 
 lemma not_isUnramified_iff :
     ¬ IsUnramified k w ↔ IsComplex w ∧ IsReal (w.comap (algebraMap k K)) := by
@@ -885,4 +933,63 @@ lemma card_eq_card_isUnramifiedIn [NumberField k] [IsGalois k K] :
 
 end NumberField.InfinitePlace
 
+variable (k K F)
+variable [Algebra k K] [Algebra k F] [Algebra K F] [IsScalarTower k K F]
+
+/-- A field extension is unramified at infinite places if every infinite place is unramified. -/
+class IsUnramifiedAtInfinitePlaces : Prop where
+  isUnramified : ∀ w : InfinitePlace K, w.IsUnramified k
+
+instance IsUnramifiedAtInfinitePlaces.id : IsUnramifiedAtInfinitePlaces K K where
+  isUnramified w := w.isUnramified_self
+
+lemma IsUnramifiedAtInfinitePlaces.trans
+    [h₁ : IsUnramifiedAtInfinitePlaces k K] [h₂ : IsUnramifiedAtInfinitePlaces K F] :
+    IsUnramifiedAtInfinitePlaces k F where
+  isUnramified w :=
+    Eq.trans (IsScalarTower.algebraMap_eq k K F ▸ h₁.1 (w.comap (algebraMap _ _))) (h₂.1 w)
+
+lemma IsUnramifiedAtInfinitePlaces.top [h : IsUnramifiedAtInfinitePlaces k F] :
+    IsUnramifiedAtInfinitePlaces K F where
+  isUnramified w := (h.1 w).of_restrictScalars K
+
+lemma IsUnramifiedAtInfinitePlaces.bot [h₁ : IsUnramifiedAtInfinitePlaces k F]
+    (h : Algebra.IsAlgebraic K F) :
+    IsUnramifiedAtInfinitePlaces k K where
+  isUnramified w := by
+    obtain ⟨w, rfl⟩ := InfinitePlace.comap_surjective h w
+    exact (h₁.1 w).comap K
+
+variable {K}
+
+lemma NumberField.InfinitePlace.isUnramified [IsUnramifiedAtInfinitePlaces k K]
+    (w : InfinitePlace K) : IsUnramified k w := IsUnramifiedAtInfinitePlaces.isUnramified w
+
+variable {k} (K)
+
+lemma NumberField.InfinitePlace.isUnramifiedIn [IsUnramifiedAtInfinitePlaces k K]
+    (w : InfinitePlace k) : IsUnramifiedIn K w := fun v _ ↦ v.isUnramified k
+
+variable {K}
+
+lemma IsUnramifiedAtInfinitePlaces_of_odd_card_aut [IsGalois k K] [FiniteDimensional k K]
+    (h : Odd (Fintype.card <| K ≃ₐ[k] K)) : IsUnramifiedAtInfinitePlaces k K :=
+  ⟨fun _ ↦ not_not.mp (Nat.odd_iff_not_even.mp h ∘ InfinitePlace.even_card_aut_of_not_isUnramified)⟩
+
+lemma IsUnramifiedAtInfinitePlaces_of_odd_finrank [IsGalois k K]
+    (h : Odd (FiniteDimensional.finrank k K)) : IsUnramifiedAtInfinitePlaces k K :=
+  ⟨fun _ ↦ not_not.mp (Nat.odd_iff_not_even.mp h ∘ InfinitePlace.even_finrank_of_not_isUnramified)⟩
+
+variable (k K)
+
+open FiniteDimensional in
+lemma IsUnramifiedAtInfinitePlaces.card_infinitePlace [NumberField k] [NumberField K]
+    [IsGalois k K] [IsUnramifiedAtInfinitePlaces k K] :
+    Fintype.card (InfinitePlace K) = Fintype.card (InfinitePlace k) * finrank k K := by
+  rw [InfinitePlace.card_eq_card_isUnramifiedIn (k := k) (K := K), Finset.filter_true_of_mem,
+    Finset.card_univ, Finset.card_eq_zero.mpr, zero_mul, add_zero]
+  · exact Finset.compl_univ
+  simp only [Finset.mem_univ, forall_true_left, Finset.filter_eq_empty_iff]
+  exact InfinitePlace.isUnramifiedIn K
+
 end InfinitePlace
chore: rename Finset.card_doubleton to Finset.card_pair (#9379)
Diff
@@ -461,7 +461,7 @@ theorem card_filter_mk_eq [NumberField K] (w : InfinitePlace K) :
   split_ifs with hw
   · rw [ComplexEmbedding.isReal_iff.mp (isReal_iff.mp hw), Finset.union_idempotent,
       Finset.card_singleton]
-  · refine Finset.card_doubleton ?_
+  · refine Finset.card_pair ?_
     rwa [Ne.def, eq_comm, ← ComplexEmbedding.isReal_iff, ← isReal_iff]
 
 open scoped BigOperators
chore(*): drop $/<| before fun (#9361)

Subset of #9319

Diff
@@ -652,7 +652,7 @@ noncomputable
 def orbitRelEquiv [IsGalois k K] :
     Quotient (MulAction.orbitRel (K ≃ₐ[k] K) (InfinitePlace K)) ≃ InfinitePlace k := by
   refine Equiv.ofBijective (Quotient.lift (comap · (algebraMap k K))
-    <| fun _ _ e ↦ (mem_orbit_iff.mp e).symm) ⟨?_, ?_⟩
+    fun _ _ e ↦ (mem_orbit_iff.mp e).symm) ⟨?_, ?_⟩
   · rintro ⟨w⟩ ⟨w'⟩ e
     exact Quotient.sound (mem_orbit_iff.mpr e.symm)
   · intro w
feat: Better lemmas for transferring finite sums along equivalences (#9237)

Lemmas around this were a mess, throth in terms of names, statement and location. This PR standardises everything to be in Algebra.BigOperators.Basic and changes the lemmas to take in InjOn and SurjOn assumptions where possible (and where impossible make sure the hypotheses are taken in the correct order) and moves the equality of functions hypothesis last.

Also add a few lemmas that help fix downstream uses by golfing.

From LeanAPAP and LeanCamCombi

Diff
@@ -511,7 +511,7 @@ open scoped BigOperators
 theorem prod_eq_abs_norm (x : K) :
     ∏ w : InfinitePlace K, w x ^ mult w = abs (Algebra.norm ℚ x) := by
   convert (congr_arg Complex.abs (@Algebra.norm_eq_prod_embeddings ℚ _ _ _ _ ℂ _ _ _ _ _ x)).symm
-  · rw [map_prod, ← Equiv.prod_comp' RingHom.equivRatAlgHom (fun f => Complex.abs (f x))
+  · rw [map_prod, ← Fintype.prod_equiv RingHom.equivRatAlgHom (fun f => Complex.abs (f x))
       (fun φ => Complex.abs (φ x)) fun _ => by simp [RingHom.equivRatAlgHom_apply]; rfl]
     rw [← Finset.prod_fiberwise Finset.univ (fun φ => mk φ) (fun φ => Complex.abs (φ x))]
     have : ∀ w : InfinitePlace K, ∀ φ ∈ Finset.filter (fun a ↦ mk a = w) Finset.univ,
feat: Define IsUnramified for infinite places (#9285)
Diff
@@ -221,13 +221,45 @@ lemma exists_comp_symm_eq_of_comp_eq [Algebra k K] [IsGalois k K] (φ ψ : K →
   ext1 x
   exact AlgHom.restrictNormal_commutes ψ' K x
 
+variable [Algebra k K] (φ : K →+* ℂ) (σ : K ≃ₐ[k] K)
+
+/--
+`IsConj φ σ` states that `σ : K ≃ₐ[k] K` is the conjugation under the embedding `φ : K →+* ℂ`.
+-/
+def IsConj : Prop := conjugate φ = φ.comp σ
+
+variable {φ σ}
+
+lemma IsConj.eq (h : IsConj φ σ) (x) : φ (σ x) = star (φ x) := RingHom.congr_fun h.symm x
+
+lemma IsConj.ext {σ₁ σ₂ : K ≃ₐ[k] K} (h₁ : IsConj φ σ₁) (h₂ : IsConj φ σ₂) : σ₁ = σ₂ :=
+  AlgEquiv.ext fun x ↦ φ.injective ((h₁.eq x).trans (h₂.eq x).symm)
+
+lemma IsConj.ext_iff {σ₁ σ₂ : K ≃ₐ[k] K} (h₁ : IsConj φ σ₁) : σ₁ = σ₂ ↔ IsConj φ σ₂ :=
+  ⟨fun e ↦ e ▸ h₁, h₁.ext⟩
+
+lemma IsConj.isReal_comp (h : IsConj φ σ) : IsReal (φ.comp (algebraMap k K)) := by
+  ext1 x
+  simp only [conjugate_coe_eq, RingHom.coe_comp, Function.comp_apply, ← h.eq,
+    starRingEnd_apply, AlgEquiv.commutes]
+
+lemma isConj_one_iff : IsConj φ (1 : K ≃ₐ[k] K) ↔ IsReal φ := Iff.rfl
+
+alias ⟨_, IsReal.isConjGal_one⟩ := ComplexEmbedding.isConj_one_iff
+
+lemma IsConj.symm (hσ : IsConj φ σ) :
+    IsConj φ σ.symm := RingHom.ext fun x ↦ by simpa using congr_arg star (hσ.eq (σ.symm x))
+
+lemma isConj_symm : IsConj φ σ.symm ↔ IsConj φ σ :=
+  ⟨IsConj.symm, IsConj.symm⟩
+
 end NumberField.ComplexEmbedding
 
 section InfinitePlace
 
 open NumberField
 
-variable (K : Type*) [Field K] {k : Type*} [Field k] {F : Type*} [Field F]
+variable {k : Type*} [Field k] (K : Type*) [Field K] {F : Type*} [Field F]
 
 /-- An infinite place of a number field `K` is a place associated to a complex embedding. -/
 def NumberField.InfinitePlace := { w : AbsoluteValue K ℝ // ∃ φ : K →+* ℂ, place φ = w }
@@ -377,6 +409,10 @@ theorem not_isReal_iff_isComplex {w : InfinitePlace K} : ¬IsReal w ↔ IsComple
   rw [isComplex_iff, isReal_iff]
 #align number_field.infinite_place.not_is_real_iff_is_complex NumberField.InfinitePlace.not_isReal_iff_isComplex
 
+@[simp]
+theorem not_isComplex_iff_isReal {w : InfinitePlace K} : ¬IsComplex w ↔ IsReal w := by
+  rw [isComplex_iff, isReal_iff, not_not]
+
 theorem isReal_or_isComplex (w : InfinitePlace K) : IsReal w ∨ IsComplex w := by
   rw [← not_isReal_iff_isComplex]; exact em _
 #align number_field.infinite_place.is_real_or_is_complex NumberField.InfinitePlace.isReal_or_isComplex
@@ -588,7 +624,7 @@ lemma ComplexEmbedding.exists_comp_symm_eq_of_comp_eq [Algebra k K] [IsGalois k
   ext1 x
   exact AlgHom.restrictNormal_commutes ψ' K x
 
-lemma exists_smul_eq_of_comap_eq [Algebra k K] [IsGalois k K] (w w' : InfinitePlace K)
+lemma exists_smul_eq_of_comap_eq [Algebra k K] [IsGalois k K] {w w' : InfinitePlace K}
     (h : w.comap (algebraMap k K) = w'.comap (algebraMap k K)) : ∃ σ : K ≃ₐ[k] K, σ • w = w' := by
   rw [← mk_embedding w, ← mk_embedding w', comap_mk, comap_mk, mk_eq_iff] at h
   cases h with
@@ -605,7 +641,7 @@ lemma exists_smul_eq_of_comap_eq [Algebra k K] [IsGalois k K] (w w' : InfinitePl
 
 lemma mem_orbit_iff [IsGalois k K] {w w' : InfinitePlace K} :
     w' ∈ MulAction.orbit (K ≃ₐ[k] K) w ↔ w.comap (algebraMap k K) = w'.comap (algebraMap k K) := by
-  refine ⟨?_, exists_smul_eq_of_comap_eq w w'⟩
+  refine ⟨?_, exists_smul_eq_of_comap_eq⟩
   rintro ⟨σ, rfl : σ • w = w'⟩
   rw [← mk_embedding w, comap_mk, smul_mk, comap_mk]
   congr 1; ext1; simp
@@ -626,6 +662,227 @@ def orbitRelEquiv [IsGalois k K] :
 lemma orbitRelEquiv_apply_mk'' [IsGalois k K] (w : InfinitePlace K) :
     orbitRelEquiv (Quotient.mk'' w) = comap w (algebraMap k K) := rfl
 
+variable (k w)
+
+/--
+An infinite place is unramified in a field extension if the restriction has the same multiplicity.
+-/
+def IsUnramified : Prop := mult (w.comap (algebraMap k K)) = mult w
+
+variable {k w}
+
+lemma not_isUnramified_iff :
+    ¬ IsUnramified k w ↔ IsComplex w ∧ IsReal (w.comap (algebraMap k K)) := by
+  rw [IsUnramified, mult, mult, ← not_isReal_iff_isComplex]
+  split_ifs with h₁ h₂ h₂ <;>
+    simp only [not_true_eq_false, false_iff, and_self, forall_true_left, IsEmpty.forall_iff,
+      not_and, OfNat.one_ne_ofNat, not_false_eq_true, true_iff, OfNat.ofNat_ne_one, h₁, h₂]
+  exact h₁ (h₂.comap _)
+
+lemma isUnramified_iff :
+    IsUnramified k w ↔ IsReal w ∨ IsComplex (w.comap (algebraMap k K)) := by
+  rw [← not_iff_not, not_isUnramified_iff, not_or,
+    not_isReal_iff_isComplex, not_isComplex_iff_isReal]
+
+variable (k)
+
+lemma IsReal.isUnramified (h : IsReal w) : IsUnramified k w := isUnramified_iff.mpr (Or.inl h)
+
+variable {k}
+
+lemma _root_.NumberField.ComplexEmbedding.IsConj.isUnramified_mk_iff
+    {φ : K →+* ℂ} (h : ComplexEmbedding.IsConj φ σ) :
+    IsUnramified k (mk φ) ↔ σ = 1 := by
+  rw [h.ext_iff, ComplexEmbedding.isConj_one_iff, ← not_iff_not, not_isUnramified_iff,
+    ← not_isReal_iff_isComplex, comap_mk, isReal_mk_iff, isReal_mk_iff, eq_true h.isReal_comp,
+    and_true]
+
+lemma isUnramified_mk_iff_forall_isConj [IsGalois k K] {φ : K →+* ℂ} :
+    IsUnramified k (mk φ) ↔ ∀ σ : K ≃ₐ[k] K, ComplexEmbedding.IsConj φ σ → σ = 1 := by
+  refine ⟨fun H σ hσ ↦ hσ.isUnramified_mk_iff.mp H,
+    fun H ↦ ?_⟩
+  by_contra hφ
+  rw [not_isUnramified_iff] at hφ
+  rw [comap_mk, isReal_mk_iff, ← not_isReal_iff_isComplex, isReal_mk_iff,
+    ← ComplexEmbedding.isConj_one_iff (k := k)] at hφ
+  letI := (φ.comp (algebraMap k K)).toAlgebra
+  letI := φ.toAlgebra
+  have : IsScalarTower k K ℂ := IsScalarTower.of_algebraMap_eq' rfl
+  let φ' : K →ₐ[k] ℂ := { star φ with commutes' := fun r ↦ by simpa using RingHom.congr_fun hφ.2 r }
+  have : ComplexEmbedding.IsConj φ (AlgHom.restrictNormal' φ' K) :=
+    (RingHom.ext <| AlgHom.restrictNormal_commutes φ' K).symm
+  exact hφ.1 (H _ this ▸ this)
+
+local notation "Stab" => MulAction.stabilizer (K ≃ₐ[k] K)
+
+lemma mem_stabilizer_mk_iff (φ : K →+* ℂ) (σ : K ≃ₐ[k] K) :
+    σ ∈ Stab (mk φ) ↔ σ = 1 ∨ ComplexEmbedding.IsConj φ σ := by
+  simp only [MulAction.mem_stabilizer_iff, smul_mk, mk_eq_iff]
+  rw [← ComplexEmbedding.isConj_symm, ComplexEmbedding.conjugate, star_eq_iff_star_eq]
+  refine or_congr ⟨fun H ↦ ?_, fun H ↦ H ▸ rfl⟩ Iff.rfl
+  exact congr_arg AlgEquiv.symm
+    (AlgEquiv.ext (g := AlgEquiv.refl) fun x ↦ φ.injective (RingHom.congr_fun H x))
+
+lemma IsUnramified.stabilizer_eq_bot (h : IsUnramified k w) : Stab w = ⊥ := by
+  rw [eq_bot_iff, ← mk_embedding w, SetLike.le_def]
+  simp only [mem_stabilizer_mk_iff, Subgroup.mem_bot, forall_eq_or_imp, true_and]
+  exact fun σ hσ ↦ hσ.isUnramified_mk_iff.mp ((mk_embedding w).symm ▸ h)
+
+lemma _root_.NumberField.ComplexEmbedding.IsConj.coe_stabilzer_mk
+    {φ : K →+* ℂ} (h : ComplexEmbedding.IsConj φ σ) :
+    (Stab (mk φ) : Set (K ≃ₐ[k] K)) = {1, σ} := by
+  ext
+  rw [SetLike.mem_coe, mem_stabilizer_mk_iff, Set.mem_insert_iff, Set.mem_singleton_iff,
+    ← h.ext_iff, eq_comm (a := σ)]
+
+variable (k w)
+
+lemma nat_card_stabilizer_eq_one_or_two :
+    Nat.card (Stab w) = 1 ∨ Nat.card (Stab w) = 2 := by
+  rw [← SetLike.coe_sort_coe, ← mk_embedding w]
+  by_cases h : ∃ σ, ComplexEmbedding.IsConj (k := k) (embedding w) σ
+  · obtain ⟨σ, hσ⟩ := h
+    simp only [hσ.coe_stabilzer_mk, Nat.card_eq_fintype_card, card_ofFinset, Set.toFinset_singleton]
+    by_cases 1 = σ
+    · left; simp [*]
+    · right; simp [*]
+  · push_neg at h
+    left
+    convert show Nat.card ({1} : Set (K ≃ₐ[k] K)) = 1 by simp
+    ext
+    simp only [SetLike.mem_coe, mem_stabilizer_mk_iff, Set.mem_singleton_iff, or_iff_left_iff_imp]
+    exact fun x ↦ (h _ x).elim
+
+variable {k w}
+
+lemma isUnramified_iff_stabilizer_eq_bot [IsGalois k K] : IsUnramified k w ↔ Stab w = ⊥ := by
+  rw [← mk_embedding w, isUnramified_mk_iff_forall_isConj]
+  simp only [eq_bot_iff, SetLike.le_def, mem_stabilizer_mk_iff,
+    Subgroup.mem_bot, forall_eq_or_imp, true_and]
+
+lemma isUnramified_iff_card_stabilizer_eq_one [IsGalois k K] :
+    IsUnramified k w ↔ Nat.card (Stab w) = 1 := by
+  rw [isUnramified_iff_stabilizer_eq_bot, Subgroup.card_eq_one]
+
+lemma not_isUnramified_iff_card_stabilizer_eq_two [IsGalois k K] :
+    ¬ IsUnramified k w ↔ Nat.card (Stab w) = 2 := by
+  rw [isUnramified_iff_card_stabilizer_eq_one]
+  obtain (e|e) := nat_card_stabilizer_eq_one_or_two k w <;> rw [e] <;> decide
+
+lemma card_stabilizer [IsGalois k K] :
+    Nat.card (Stab w) = if IsUnramified k w then 1 else 2 := by
+  split
+  · rwa [← isUnramified_iff_card_stabilizer_eq_one]
+  · rwa [← not_isUnramified_iff_card_stabilizer_eq_two]
+
+lemma even_nat_card_aut_of_not_isUnramified [IsGalois k K] (hw : ¬ IsUnramified k w) :
+    Even (Nat.card <| K ≃ₐ[k] K) := by
+  by_cases H : Finite (K ≃ₐ[k] K)
+  · cases nonempty_fintype (K ≃ₐ[k] K)
+    rw [even_iff_two_dvd, Nat.card_eq_fintype_card,
+      ← not_isUnramified_iff_card_stabilizer_eq_two.mp hw, Nat.card_eq_fintype_card]
+    exact Subgroup.card_subgroup_dvd_card (Stab w)
+  · convert even_zero
+    by_contra e
+    exact H (Nat.finite_of_card_ne_zero e)
+
+lemma even_card_aut_of_not_isUnramified [IsGalois k K] [FiniteDimensional k K]
+    (hw : ¬ IsUnramified k w) :
+    Even (Fintype.card <| K ≃ₐ[k] K) :=
+  Nat.card_eq_fintype_card (α := K ≃ₐ[k] K) ▸ even_nat_card_aut_of_not_isUnramified hw
+
+lemma even_finrank_of_not_isUnramified [IsGalois k K]
+    (hw : ¬ IsUnramified k w) : Even (finrank k K) := by
+  by_cases FiniteDimensional k K
+  · exact IsGalois.card_aut_eq_finrank k K ▸ even_card_aut_of_not_isUnramified hw
+  · exact finrank_of_not_finite ‹_› ▸ even_zero
+
+lemma isUnramified_smul_iff :
+    IsUnramified k (σ • w) ↔ IsUnramified k w := by
+  rw [isUnramified_iff, isUnramified_iff, isReal_smul_iff, comap_smul,
+    ← AlgEquiv.toAlgHom_toRingHom, AlgHom.comp_algebraMap]
+
+variable (K)
+
+/-- A infinite place of the base field is unramified in a field extension if every
+infinite place over it is unramified. -/
+def IsUnramifiedIn (w : InfinitePlace k) : Prop :=
+  ∀ v, comap v (algebraMap k K) = w → IsUnramified k v
+
+variable {K}
+
+lemma isUnramifiedIn_comap [IsGalois k K] {w : InfinitePlace K} :
+    (w.comap (algebraMap k K)).IsUnramifiedIn K ↔ w.IsUnramified k := by
+  refine ⟨fun H ↦ H _ rfl, fun H v hv ↦ ?_⟩
+  obtain ⟨σ, rfl⟩ := exists_smul_eq_of_comap_eq hv
+  rwa [isUnramified_smul_iff] at H
+
+lemma even_card_aut_of_not_isUnramifiedIn [IsGalois k K] [FiniteDimensional k K]
+    {w : InfinitePlace k} (hw : ¬ w.IsUnramifiedIn K) :
+    Even (Fintype.card <| K ≃ₐ[k] K) := by
+  obtain ⟨v, rfl⟩ := comap_surjective (Normal.isAlgebraic' (K := K)) w
+  rw [isUnramifiedIn_comap] at hw
+  exact even_card_aut_of_not_isUnramified hw
+
+lemma even_finrank_of_not_isUnramifiedIn
+    [IsGalois k K] {w : InfinitePlace k} (hw : ¬ w.IsUnramifiedIn K) :
+    Even (finrank k K) := by
+  obtain ⟨v, rfl⟩ := comap_surjective (Normal.isAlgebraic' (K := K)) w
+  rw [isUnramifiedIn_comap] at hw
+  exact even_finrank_of_not_isUnramified hw
+
+variable (k K)
+
+open Finset BigOperators in
+lemma card_isUnramified [NumberField k] [IsGalois k K] :
+    Finset.card (univ.filter <| IsUnramified k (K := K)) =
+      Finset.card (univ.filter <| IsUnramifiedIn K (k := k)) * (finrank k K) := by
+  letI := Module.Finite.of_restrictScalars_finite ℚ k K
+  rw [← IsGalois.card_aut_eq_finrank,
+    Finset.card_eq_sum_card_fiberwise (f := (comap · (algebraMap k K)))
+    (t := (univ.filter <| IsUnramifiedIn K (k := k))), ← smul_eq_mul, ← sum_const]
+  refine sum_congr rfl (fun w hw ↦ ?_)
+  obtain ⟨w, rfl⟩ := comap_surjective (Normal.isAlgebraic' (K := K)) w
+  simp only [mem_univ, forall_true_left, mem_filter, true_and] at hw
+  trans Finset.card (MulAction.orbit (K ≃ₐ[k] K) w).toFinset
+  · congr; ext w'
+    simp only [mem_univ, forall_true_left, filter_congr_decidable, mem_filter, true_and,
+      Set.mem_toFinset, mem_orbit_iff, @eq_comm _ (comap w' _), and_iff_right_iff_imp]
+    intro e; rwa [← isUnramifiedIn_comap, ← e]
+  · rw [← MulAction.card_orbit_mul_card_stabilizer_eq_card_group _ w,
+      ← Nat.card_eq_fintype_card (α := Stab w), card_stabilizer, if_pos,
+      mul_one, Set.toFinset_card]
+    rwa [← isUnramifiedIn_comap]
+  · simp [isUnramifiedIn_comap]
+
+open Finset BigOperators in
+lemma card_isUnramified_compl [NumberField k] [IsGalois k K] :
+    Finset.card (univ.filter <| IsUnramified k (K := K))ᶜ =
+      Finset.card (univ.filter <| IsUnramifiedIn K (k := k))ᶜ * (finrank k K / 2) := by
+  letI := Module.Finite.of_restrictScalars_finite ℚ k K
+  rw [← IsGalois.card_aut_eq_finrank,
+    Finset.card_eq_sum_card_fiberwise (f := (comap · (algebraMap k K)))
+    (t := (univ.filter <| IsUnramifiedIn K (k := k))ᶜ), ← smul_eq_mul, ← sum_const]
+  refine sum_congr rfl (fun w hw ↦ ?_)
+  obtain ⟨w, rfl⟩ := comap_surjective (Normal.isAlgebraic' (K := K)) w
+  simp only [mem_univ, forall_true_left, compl_filter, not_not, mem_filter, true_and] at hw
+  trans Finset.card (MulAction.orbit (K ≃ₐ[k] K) w).toFinset
+  · congr; ext w'
+    simp only [compl_filter, filter_congr_decidable, mem_filter, mem_univ, true_and,
+      @eq_comm _ (comap w' _), Set.mem_toFinset, mem_orbit_iff, and_iff_right_iff_imp]
+    intro e; rwa [← isUnramifiedIn_comap, ← e]
+  · rw [← MulAction.card_orbit_mul_card_stabilizer_eq_card_group _ w,
+      ← Nat.card_eq_fintype_card (α := Stab w), InfinitePlace.card_stabilizer, if_neg,
+      Nat.mul_div_cancel _ zero_lt_two, Set.toFinset_card]
+    rwa [← isUnramifiedIn_comap]
+  · simp [isUnramifiedIn_comap]
+
+lemma card_eq_card_isUnramifiedIn [NumberField k] [IsGalois k K] :
+    Fintype.card (InfinitePlace K) =
+      Finset.card (Finset.univ.filter <| IsUnramifiedIn K (k := k)) * finrank k K +
+      Finset.card (Finset.univ.filter <| IsUnramifiedIn K (k := k))ᶜ * (finrank k K / 2) := by
+  rw [← card_isUnramified, ← card_isUnramified_compl, Finset.card_add_card_compl]
+
 end NumberField.InfinitePlace
 
 end InfinitePlace
feat: The galois group acts on infinite places. (#9280)
Diff
@@ -156,7 +156,7 @@ open Complex NumberField
 
 open scoped ComplexConjugate
 
-variable {K : Type*} [Field K]
+variable {K : Type*} [Field K] {k : Type*} [Field k]
 
 /-- The conjugate of a complex embedding as a complex embedding. -/
 @[reducible]
@@ -203,13 +203,31 @@ theorem IsReal.coe_embedding_apply {φ : K →+* ℂ} (hφ : IsReal φ) (x : K)
     exact RingHom.congr_fun hφ x
 #align number_field.complex_embedding.is_real.coe_embedding_apply NumberField.ComplexEmbedding.IsReal.coe_embedding_apply
 
+lemma IsReal.comp (f : k →+* K) {φ : K →+* ℂ} (hφ : IsReal φ) :
+    IsReal (φ.comp f) := by ext1 x; simpa using RingHom.congr_fun hφ (f x)
+
+lemma isReal_comp_iff {f : k ≃+* K} {φ : K →+* ℂ} :
+    IsReal (φ.comp (f : k →+* K)) ↔ IsReal φ :=
+  ⟨fun H ↦ by convert H.comp f.symm.toRingHom; ext1; simp, IsReal.comp _⟩
+
+lemma exists_comp_symm_eq_of_comp_eq [Algebra k K] [IsGalois k K] (φ ψ : K →+* ℂ)
+    (h : φ.comp (algebraMap k K) = ψ.comp (algebraMap k K)) :
+    ∃ σ : K ≃ₐ[k] K, φ.comp σ.symm = ψ := by
+  letI := (φ.comp (algebraMap k K)).toAlgebra
+  letI := φ.toAlgebra
+  have : IsScalarTower k K ℂ := IsScalarTower.of_algebraMap_eq' rfl
+  let ψ' : K →ₐ[k] ℂ := { ψ with commutes' := fun r ↦ (RingHom.congr_fun h r).symm }
+  use (AlgHom.restrictNormal' ψ' K).symm
+  ext1 x
+  exact AlgHom.restrictNormal_commutes ψ' K x
+
 end NumberField.ComplexEmbedding
 
 section InfinitePlace
 
 open NumberField
 
-variable (K : Type*) [Field K]
+variable (K : Type*) [Field K] {k : Type*} [Field k] {F : Type*} [Field F]
 
 /-- An infinite place of a number field `K` is a place associated to a complex embedding. -/
 def NumberField.InfinitePlace := { w : AbsoluteValue K ℝ // ∃ φ : K →+* ℂ, place φ = w }
@@ -380,12 +398,17 @@ theorem isReal_of_mk_isReal {φ : K →+* ℂ} (h : IsReal (mk φ)) :
   rw [not_isReal_iff_isComplex]
   exact ⟨φ, h, rfl⟩
 
+lemma isReal_mk_iff {φ : K →+* ℂ} :
+    IsReal (mk φ) ↔ ComplexEmbedding.IsReal φ :=
+  ⟨isReal_of_mk_isReal, fun H ↦ ⟨_, H, rfl⟩⟩
+
+lemma isComplex_mk_iff {φ : K →+* ℂ} :
+    IsComplex (mk φ) ↔ ¬ ComplexEmbedding.IsReal φ :=
+  not_isReal_iff_isComplex.symm.trans isReal_mk_iff.not
+
 @[simp]
 theorem not_isReal_of_mk_isComplex {φ : K →+* ℂ} (h : IsComplex (mk φ)) :
-    ¬ ComplexEmbedding.IsReal φ := by
-  contrapose! h
-  rw [← not_isReal_iff_isComplex.not, not_not]
-  exact ⟨φ, h, rfl⟩
+    ¬ ComplexEmbedding.IsReal φ := by rwa [← isComplex_mk_iff]
 
 /-- The multiplicity of an infinite place, that is the number of distinct complex embeddings that
 define it, see `card_filter_mk_eq`. -/
@@ -502,6 +525,107 @@ theorem card_add_two_mul_card_eq_rank :
     ← Embeddings.card K ℂ, Nat.add_sub_of_le]
   exact Fintype.card_subtype_le _
 
+variable {K}
+
+/-- The restriction of an infinite place along an embedding. -/
+def comap (w : InfinitePlace K) (f : k →+* K) : InfinitePlace k :=
+  ⟨w.1.comp f.injective, w.embedding.comp f,
+    by { ext x; show _ = w.1 (f x); rw [← w.2.choose_spec]; rfl }⟩
+
+@[simp]
+lemma comap_mk (φ : K →+* ℂ) (f : k →+* K) : (mk φ).comap f = mk (φ.comp f) := rfl
+
+lemma comap_comp (w : InfinitePlace K) (f : F →+* K) (g : k →+* F) :
+    w.comap (f.comp g) = (w.comap f).comap g := rfl
+
+lemma IsReal.comap (f : k →+* K) {w : InfinitePlace K} (hφ : IsReal w) :
+    IsReal (w.comap f) := by
+  rw [← mk_embedding w, comap_mk, isReal_mk_iff]
+  rw [← mk_embedding w, isReal_mk_iff] at hφ
+  exact hφ.comp f
+
+lemma isReal_comap_iff (f : k ≃+* K) {w : InfinitePlace K} :
+    IsReal (w.comap (f : k →+* K)) ↔ IsReal w := by
+  rw [← mk_embedding w, comap_mk, isReal_mk_iff, isReal_mk_iff, ComplexEmbedding.isReal_comp_iff]
+
+lemma comap_surjective [Algebra k K] (h : Algebra.IsAlgebraic k K) :
+    Function.Surjective (comap · (algebraMap k K)) := fun w ↦
+  letI := w.embedding.toAlgebra
+  ⟨mk (IsAlgClosed.lift (M := ℂ) h), by simp [comap_mk, RingHom.algebraMap_toAlgebra]⟩
+
+variable [Algebra k K] (σ : K ≃ₐ[k] K) (w : InfinitePlace K)
+
+/-- The action of the galois group on infinite places. -/
+@[simps! smul_coe_apply]
+instance : MulAction (K ≃ₐ[k] K) (InfinitePlace K) where
+  smul := fun σ w ↦ w.comap σ.symm
+  one_smul := fun _ ↦ rfl
+  mul_smul := fun _ _ _ ↦ rfl
+
+lemma smul_eq_comap : σ • w = w.comap σ.symm := rfl
+
+@[simp] lemma smul_apply (x) : (σ • w) x = w (σ.symm x) := rfl
+
+@[simp] lemma smul_mk (φ : K →+* ℂ) : σ • mk φ = mk (φ.comp σ.symm) := rfl
+
+lemma comap_smul {f : F →+* K} : (σ • w).comap f = w.comap (RingHom.comp σ.symm f) := rfl
+
+variable {σ w}
+
+lemma isReal_smul_iff : IsReal (σ • w) ↔ IsReal w := isReal_comap_iff (f := σ.symm.toRingEquiv)
+
+lemma isComplex_smul_iff : IsComplex (σ • w) ↔ IsComplex w := by
+  rw [← not_isReal_iff_isComplex, ← not_isReal_iff_isComplex, isReal_smul_iff]
+
+lemma ComplexEmbedding.exists_comp_symm_eq_of_comp_eq [Algebra k K] [IsGalois k K] (φ ψ : K →+* ℂ)
+    (h : φ.comp (algebraMap k K) = ψ.comp (algebraMap k K)) :
+    ∃ σ : K ≃ₐ[k] K, φ.comp σ.symm = ψ := by
+  letI := (φ.comp (algebraMap k K)).toAlgebra
+  letI := φ.toAlgebra
+  have : IsScalarTower k K ℂ := IsScalarTower.of_algebraMap_eq' rfl
+  let ψ' : K →ₐ[k] ℂ := { ψ with commutes' := fun r ↦ (RingHom.congr_fun h r).symm }
+  use (AlgHom.restrictNormal' ψ' K).symm
+  ext1 x
+  exact AlgHom.restrictNormal_commutes ψ' K x
+
+lemma exists_smul_eq_of_comap_eq [Algebra k K] [IsGalois k K] (w w' : InfinitePlace K)
+    (h : w.comap (algebraMap k K) = w'.comap (algebraMap k K)) : ∃ σ : K ≃ₐ[k] K, σ • w = w' := by
+  rw [← mk_embedding w, ← mk_embedding w', comap_mk, comap_mk, mk_eq_iff] at h
+  cases h with
+  | inl h =>
+    obtain ⟨σ, hσ⟩ := ComplexEmbedding.exists_comp_symm_eq_of_comp_eq w.embedding w'.embedding h
+    use σ
+    rw [← mk_embedding w, ← mk_embedding w', smul_mk, hσ]
+  | inr h =>
+    obtain ⟨σ, hσ⟩ := ComplexEmbedding.exists_comp_symm_eq_of_comp_eq
+      ((starRingEnd ℂ).comp (embedding w)) w'.embedding h
+    use σ
+    rw [← mk_embedding w, ← mk_embedding w', smul_mk, mk_eq_iff]
+    exact Or.inr hσ
+
+lemma mem_orbit_iff [IsGalois k K] {w w' : InfinitePlace K} :
+    w' ∈ MulAction.orbit (K ≃ₐ[k] K) w ↔ w.comap (algebraMap k K) = w'.comap (algebraMap k K) := by
+  refine ⟨?_, exists_smul_eq_of_comap_eq w w'⟩
+  rintro ⟨σ, rfl : σ • w = w'⟩
+  rw [← mk_embedding w, comap_mk, smul_mk, comap_mk]
+  congr 1; ext1; simp
+
+/-- The orbits of infinite places under the action of the galois group are indexed by
+the infinite places of the base field. -/
+noncomputable
+def orbitRelEquiv [IsGalois k K] :
+    Quotient (MulAction.orbitRel (K ≃ₐ[k] K) (InfinitePlace K)) ≃ InfinitePlace k := by
+  refine Equiv.ofBijective (Quotient.lift (comap · (algebraMap k K))
+    <| fun _ _ e ↦ (mem_orbit_iff.mp e).symm) ⟨?_, ?_⟩
+  · rintro ⟨w⟩ ⟨w'⟩ e
+    exact Quotient.sound (mem_orbit_iff.mpr e.symm)
+  · intro w
+    obtain ⟨w', hw⟩ := comap_surjective (Normal.isAlgebraic' (K := K)) w
+    exact ⟨⟦w'⟧, hw⟩
+
+lemma orbitRelEquiv_apply_mk'' [IsGalois k K] (w : InfinitePlace K) :
+    orbitRelEquiv (Quotient.mk'' w) = comap w (algebraMap k K) := rfl
+
 end NumberField.InfinitePlace
 
 end InfinitePlace
chore: make Complex.ext only a local ext lemma (#9010)

In accordance with this Zulip thread, this remove Complex.ext from the global ext attribute list and only enables it locally in certain files.

Diff
@@ -197,7 +197,7 @@ def IsReal.embedding {φ : K →+* ℂ} (hφ : IsReal φ) : K →+* ℝ where
 @[simp]
 theorem IsReal.coe_embedding_apply {φ : K →+* ℂ} (hφ : IsReal φ) (x : K) :
     (hφ.embedding x : ℂ) = φ x := by
-  ext
+  apply Complex.ext
   · rfl
   · rw [ofReal_im, eq_comm, ← Complex.conj_eq_iff_im]
     exact RingHom.congr_fun hφ x
chore: Replace (· op ·) a by (a op ·) (#8843)

I used the regex \(\(· (.) ·\) (.)\), replacing with ($2 $1 ·).

Diff
@@ -120,12 +120,11 @@ theorem finite_of_norm_le (B : ℝ) : {x : K | IsIntegral ℤ x ∧ ∀ φ : K 
 theorem pow_eq_one_of_norm_eq_one {x : K} (hxi : IsIntegral ℤ x) (hx : ∀ φ : K →+* A, ‖φ x‖ = 1) :
     ∃ (n : ℕ) (_ : 0 < n), x ^ n = 1 := by
   obtain ⟨a, -, b, -, habne, h⟩ :=
-    @Set.Infinite.exists_ne_map_eq_of_mapsTo _ _ _ _ ((· ^ ·) x : ℕ → K) Set.infinite_univ
+    @Set.Infinite.exists_ne_map_eq_of_mapsTo _ _ _ _ (x ^ · : ℕ → K) Set.infinite_univ
       (by exact fun a _ => ⟨hxi.pow a, fun φ => by simp [hx φ]⟩) (finite_of_norm_le K A (1 : ℝ))
   · wlog hlt : b < a
     · exact this K A hxi hx b a habne.symm h.symm (habne.lt_or_lt.resolve_right hlt)
     refine ⟨a - b, tsub_pos_of_lt hlt, ?_⟩
-    dsimp at h -- Porting note: added dsimp
     rw [← Nat.sub_add_cancel hlt.le, pow_add, mul_left_eq_self₀] at h
     refine h.resolve_right fun hp => ?_
     specialize hx (IsAlgClosed.lift (NumberField.isAlgebraic K)).toRingHom
chore: bump to v4.3.0-rc2 (#8366)

PR contents

This is the supremum of

along with some minor fixes from failures on nightly-testing as Mathlib master is merged into it.

Note that some PRs for changes that are already compatible with the current toolchain and will be necessary have already been split out: #8380.

I am hopeful that in future we will be able to progressively merge adaptation PRs into a bump/v4.X.0 branch, so we never end up with a "big merge" like this. However one of these adaptation PRs (#8056) predates my new scheme for combined CI, and it wasn't possible to keep that PR viable in the meantime.

Lean PRs involved in this bump

In particular this includes adjustments for the Lean PRs

leanprover/lean4#2778

We can get rid of all the

local macro_rules | `($x ^ $y) => `(HPow.hPow $x $y) -- Porting note: See issue [lean4#2220](https://github.com/leanprover/lean4/pull/2220)

macros across Mathlib (and in any projects that want to write natural number powers of reals).

leanprover/lean4#2722

Changes the default behaviour of simp to (config := {decide := false}). This makes simp (and consequentially norm_num) less powerful, but also more consistent, and less likely to blow up in long failures. This requires a variety of changes: changing some previously by simp or norm_num to decide or rfl, or adding (config := {decide := true}).

leanprover/lean4#2783

This changed the behaviour of simp so that simp [f] will only unfold "fully applied" occurrences of f. The old behaviour can be recovered with simp (config := { unfoldPartialApp := true }). We may in future add a syntax for this, e.g. simp [!f]; please provide feedback! In the meantime, we have made the following changes:

  • switching to using explicit lemmas that have the intended level of application
  • (config := { unfoldPartialApp := true }) in some places, to recover the old behaviour
  • Using @[eqns] to manually adjust the equation lemmas for a particular definition, recovering the old behaviour just for that definition. See #8371, where we do this for Function.comp and Function.flip.

This change in Lean may require further changes down the line (e.g. adding the !f syntax, and/or upstreaming the special treatment for Function.comp and Function.flip, and/or removing this special treatment). Please keep an open and skeptical mind about these changes!

Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Mauricio Collares <mauricio@collares.org>

Diff
@@ -32,8 +32,6 @@ for `x ∈ K`, we have `Π_w ‖x‖_w = |norm(x)|` where the product is over th
 number field, embeddings, places, infinite places
 -/
 
-local macro_rules | `($x ^ $y) => `(HPow.hPow $x $y) -- Porting note: See issue lean4#2220
-
 open scoped Classical
 
 namespace NumberField.Embeddings
@@ -496,7 +494,7 @@ theorem card_complex_embeddings :
     · rwa [Subtype.mk_eq_mk, ← Subtype.ext_iff, ← Subtype.ext_iff] at h
     · refine ⟨⟨⟨φ, not_isReal_of_mk_isComplex (hφ.symm ▸ hw)⟩, ?_⟩, rfl⟩
       rwa [Subtype.ext_iff, mkComplex_coe]
-  · simp_rw [mult, not_isReal_iff_isComplex.mpr hw]
+  · simp_rw [mult, not_isReal_iff_isComplex.mpr hw, ite_false]
 #align number_field.infinite_place.card_complex_embeddings NumberField.InfinitePlace.card_complex_embeddings
 
 theorem card_add_two_mul_card_eq_rank :
feat: explicit volume computations in NumberTheory.NumberField.CanonicalEmbedding (#6886)

We compute the values of the volumes used in CanonicalEmbedding. In particular, we prove that

volume (fundamentalDomain (latticeBasis K)) =
       (2 : ℝ≥0∞)⁻¹ ^ (NrComplexPlaces K) * NNReal.sqrt ‖discr K‖₊

This will be useful later on to prove Hermite and Hermite-Minkowski theorems.

Diff
@@ -352,6 +352,11 @@ theorem isComplex_iff {w : InfinitePlace K} :
   | inr h => rwa [← ComplexEmbedding.isReal_conjugate_iff, h] at hφ
 #align number_field.infinite_place.is_complex_iff NumberField.InfinitePlace.isComplex_iff
 
+@[simp]
+theorem conjugate_embedding_eq_of_isReal {w : InfinitePlace K} (h : IsReal w) :
+    ComplexEmbedding.conjugate (embedding w) = embedding w :=
+  ComplexEmbedding.isReal_iff.mpr (isReal_iff.mp h)
+
 @[simp]
 theorem not_isReal_iff_isComplex {w : InfinitePlace K} : ¬IsReal w ↔ IsComplex w := by
   rw [isComplex_iff, isReal_iff]
@@ -464,14 +469,20 @@ theorem prod_eq_abs_norm (x : K) :
 
 open Fintype FiniteDimensional
 
+variable (K)
+
+/-- The number of infinite real places of the number field `K`. -/
+noncomputable abbrev NrRealPlaces := card { w : InfinitePlace K // IsReal w }
+
+/-- The number of infinite complex places of the number field `K`. -/
+noncomputable abbrev NrComplexPlaces := card { w : InfinitePlace K // IsComplex w }
+
 theorem card_real_embeddings :
-    card { φ : K →+* ℂ // ComplexEmbedding.IsReal φ }
-      = card { w : InfinitePlace K // IsReal w } := Fintype.card_congr mkReal
+    card { φ : K →+* ℂ // ComplexEmbedding.IsReal φ } = NrRealPlaces K := Fintype.card_congr mkReal
 #align number_field.infinite_place.card_real_embeddings NumberField.InfinitePlace.card_real_embeddings
 
 theorem card_complex_embeddings :
-    card { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ } =
-      2 * card { w : InfinitePlace K // IsComplex w } := by
+    card { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ } = 2 * NrComplexPlaces K := by
   suffices ∀ w : { w : InfinitePlace K // IsComplex w }, (Finset.univ.filter
       fun φ : { φ // ¬ ComplexEmbedding.IsReal φ } => mkComplex φ = w).card = 2 by
     rw [Fintype.card, Finset.card_eq_sum_ones, ← Finset.sum_fiberwise _ (fun φ => mkComplex φ)]
@@ -489,8 +500,7 @@ theorem card_complex_embeddings :
 #align number_field.infinite_place.card_complex_embeddings NumberField.InfinitePlace.card_complex_embeddings
 
 theorem card_add_two_mul_card_eq_rank :
-    card { w : InfinitePlace K // IsReal w } + 2 * card { w : InfinitePlace K // IsComplex w } =
-      finrank ℚ K := by
+    NrRealPlaces K + 2 * NrComplexPlaces K = finrank ℚ K := by
   rw [← card_real_embeddings, ← card_complex_embeddings, Fintype.card_subtype_compl,
     ← Embeddings.card K ℂ, Nat.add_sub_of_le]
   exact Fintype.card_subtype_le _
feat: use Minkowski's theorem to prove the existence of algebraic integers of small norm (#8128)

We define the convex body convexBodySum and prove the following

theorem exists_ne_zero_mem_ringOfIntegers_of_norm_le {B : ℝ}
     (h : (minkowskiBound K) < volume (convexBodySum K B)) :
     ∃ (a : 𝓞 K), a ≠ 0 ∧ |Algebra.norm ℚ (a:K)| ≤ ((finrank ℚ K : ℝ)⁻¹ * B) ^ (finrank ℚ K) 

Computation of the volume (convexBodySum K B)) and applications of the result are coming in a following PR.

Diff
@@ -403,6 +403,19 @@ theorem card_filter_mk_eq [NumberField K] (w : InfinitePlace K) :
   · refine Finset.card_doubleton ?_
     rwa [Ne.def, eq_comm, ← ComplexEmbedding.isReal_iff, ← isReal_iff]
 
+open scoped BigOperators
+
+noncomputable instance NumberField.InfinitePlace.fintype [NumberField K] :
+    Fintype (InfinitePlace K) := Set.fintypeRange _
+#align number_field.infinite_place.number_field.infinite_place.fintype NumberField.InfinitePlace.NumberField.InfinitePlace.fintype
+
+theorem sum_mult_eq [NumberField K] :
+    ∑ w : InfinitePlace K, mult w = FiniteDimensional.finrank ℚ K := by
+  rw [← Embeddings.card K ℂ, Fintype.card, Finset.card_eq_sum_ones, ← Finset.univ.sum_fiberwise
+    (fun φ => InfinitePlace.mk φ)]
+  exact Finset.sum_congr rfl
+    (fun _ _ => by rw [Finset.sum_const, smul_eq_mul, mul_one, card_filter_mk_eq])
+
 /-- The map from real embeddings to real infinite places as an equiv -/
 noncomputable def mkReal :
     { φ : K →+* ℂ // ComplexEmbedding.IsReal φ } ≃ { w : InfinitePlace K // IsReal w } := by
@@ -430,10 +443,6 @@ theorem mkComplex_coe (φ : { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ }
 
 variable [NumberField K]
 
-noncomputable instance NumberField.InfinitePlace.fintype : Fintype (InfinitePlace K) :=
-  Set.fintypeRange _
-#align number_field.infinite_place.number_field.infinite_place.fintype NumberField.InfinitePlace.NumberField.InfinitePlace.fintype
-
 open scoped BigOperators
 
 /-- The infinite part of the product formula : for `x ∈ K`, we have `Π_w ‖x‖_w = |norm(x)|` where
@@ -482,8 +491,8 @@ theorem card_complex_embeddings :
 theorem card_add_two_mul_card_eq_rank :
     card { w : InfinitePlace K // IsReal w } + 2 * card { w : InfinitePlace K // IsComplex w } =
       finrank ℚ K := by
-  rw [← card_real_embeddings, ← card_complex_embeddings]
-  rw [Fintype.card_subtype_compl, ← Embeddings.card K ℂ, Nat.add_sub_of_le]
+  rw [← card_real_embeddings, ← card_complex_embeddings, Fintype.card_subtype_compl,
+    ← Embeddings.card K ℂ, Nat.add_sub_of_le]
   exact Fintype.card_subtype_le _
 
 end NumberField.InfinitePlace
chore: drop MulZeroClass. in mul_zero/zero_mul (#6682)

Search&replace MulZeroClass.mul_zero -> mul_zero, MulZeroClass.zero_mul -> zero_mul.

These were introduced by Mathport, as the full name of mul_zero is actually MulZeroClass.mul_zero (it's exported with the short name).

Diff
@@ -192,7 +192,7 @@ def IsReal.embedding {φ : K →+* ℂ} (hφ : IsReal φ) : K →+* ℝ where
   map_one' := by simp only [map_one, one_re]
   map_mul' := by
     simp only [Complex.conj_eq_iff_im.mp (RingHom.congr_fun hφ _), map_mul, mul_re,
-      MulZeroClass.mul_zero, tsub_zero, eq_self_iff_true, forall_const]
+      mul_zero, tsub_zero, eq_self_iff_true, forall_const]
   map_zero' := by simp only [map_zero, zero_re]
   map_add' := by simp only [map_add, add_re, eq_self_iff_true, forall_const]
 #align number_field.complex_embedding.is_real.embedding NumberField.ComplexEmbedding.IsReal.embedding
chore: remove unused simps (#6632)

Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -449,8 +449,7 @@ theorem prod_eq_abs_norm (x : K) :
       intro _ _ hφ
       rw [← (Finset.mem_filter.mp hφ).2]
       rfl
-    simp_rw [Finset.prod_congr rfl (this _), Finset.mem_univ, forall_true_left, Finset.prod_const,
-      card_filter_mk_eq]
+    simp_rw [Finset.prod_congr rfl (this _), Finset.prod_const, card_filter_mk_eq]
   · rw [eq_ratCast, Rat.cast_abs, ← Complex.abs_ofReal, Complex.ofReal_rat_cast]
 #align number_field.infinite_place.prod_eq_abs_norm NumberField.InfinitePlace.prod_eq_abs_norm
 
chore: banish Type _ and Sort _ (#6499)

We remove all possible occurences of Type _ and Sort _ in favor of Type* and Sort*.

This has nice performance benefits.

Diff
@@ -42,9 +42,9 @@ section Fintype
 
 open FiniteDimensional
 
-variable (K : Type _) [Field K] [NumberField K]
+variable (K : Type*) [Field K] [NumberField K]
 
-variable (A : Type _) [Field A] [CharZero A]
+variable (A : Type*) [Field A] [CharZero A]
 
 /-- There are finitely many embeddings of a number field. -/
 noncomputable instance : Fintype (K →+* A) :=
@@ -67,7 +67,7 @@ section Roots
 
 open Set Polynomial
 
-variable (K A : Type _) [Field K] [NumberField K] [Field A] [Algebra ℚ A] [IsAlgClosed A] (x : K)
+variable (K A : Type*) [Field K] [NumberField K] [Field A] [Algebra ℚ A] [IsAlgClosed A] (x : K)
 
 /-- Let `A` be an algebraically closed field and let `x ∈ K`, with `K` a number field.
 The images of `x` by the embeddings of `K` in `A` are exactly the roots in `A` of
@@ -85,9 +85,9 @@ section Bounded
 
 open FiniteDimensional Polynomial Set
 
-variable {K : Type _} [Field K] [NumberField K]
+variable {K : Type*} [Field K] [NumberField K]
 
-variable {A : Type _} [NormedField A] [IsAlgClosed A] [NormedAlgebra ℚ A]
+variable {A : Type*} [NormedField A] [IsAlgClosed A] [NormedAlgebra ℚ A]
 
 theorem coeff_bdd_of_norm_le {B : ℝ} {x : K} (h : ∀ φ : K →+* A, ‖φ x‖ ≤ B) (i : ℕ) :
     ‖(minpoly ℚ x).coeff i‖ ≤ max B 1 ^ finrank ℚ K * (finrank ℚ K).choose (finrank ℚ K / 2) := by
@@ -140,7 +140,7 @@ end NumberField.Embeddings
 
 section Place
 
-variable {K : Type _} [Field K] {A : Type _} [NormedDivisionRing A] [Nontrivial A] (φ : K →+* A)
+variable {K : Type*} [Field K] {A : Type*} [NormedDivisionRing A] [Nontrivial A] (φ : K →+* A)
 
 /-- An embedding into a normed division ring defines a place of `K` -/
 def NumberField.place : AbsoluteValue K ℝ :=
@@ -159,7 +159,7 @@ open Complex NumberField
 
 open scoped ComplexConjugate
 
-variable {K : Type _} [Field K]
+variable {K : Type*} [Field K]
 
 /-- The conjugate of a complex embedding as a complex embedding. -/
 @[reducible]
@@ -212,7 +212,7 @@ section InfinitePlace
 
 open NumberField
 
-variable (K : Type _) [Field K]
+variable (K : Type*) [Field K]
 
 /-- An infinite place of a number field `K` is a place associated to a complex embedding. -/
 def NumberField.InfinitePlace := { w : AbsoluteValue K ℝ // ∃ φ : K →+* ℂ, place φ = w }
@@ -231,7 +231,7 @@ namespace NumberField.InfinitePlace
 
 open NumberField
 
-instance {K : Type _} [Field K] : FunLike (InfinitePlace K) K (fun _ => ℝ) :=
+instance {K : Type*} [Field K] : FunLike (InfinitePlace K) K (fun _ => ℝ) :=
 { coe := fun w x => w.1 x
   coe_injective' := fun _ _ h => Subtype.eq (AbsoluteValue.ext fun x => congr_fun h x)}
 
chore: ensure all instances referred to directly have explicit names (#6423)

Per https://github.com/leanprover/lean4/issues/2343, we are going to need to change the automatic generation of instance names, as they become too long.

This PR ensures that everywhere in Mathlib that refers to an instance by name, that name is given explicitly, rather than being automatically generated.

There are four exceptions, which are now commented, with links to https://github.com/leanprover/lean4/issues/2343.

This was implemented by running Mathlib against a modified Lean that appended _ᾰ to all automatically generated names, and fixing everything.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -218,7 +218,7 @@ variable (K : Type _) [Field K]
 def NumberField.InfinitePlace := { w : AbsoluteValue K ℝ // ∃ φ : K →+* ℂ, place φ = w }
 #align number_field.infinite_place NumberField.InfinitePlace
 
-instance [NumberField K] : Nonempty (NumberField.InfinitePlace K) := Set.instNonemptyElemRange _
+instance [NumberField K] : Nonempty (NumberField.InfinitePlace K) := Set.instNonemptyRange _
 
 variable {K}
 
chore: regularize HPow.hPow porting notes (#6465)
Diff
@@ -32,8 +32,7 @@ for `x ∈ K`, we have `Π_w ‖x‖_w = |norm(x)|` where the product is over th
 number field, embeddings, places, infinite places
 -/
 
--- Porting note: see https://github.com/leanprover/lean4/issues/2220
-local macro_rules | `($x ^ $y)   => `(HPow.hPow $x $y)
+local macro_rules | `($x ^ $y) => `(HPow.hPow $x $y) -- Porting note: See issue lean4#2220
 
 open scoped Classical
 
refactor of NumberTheory.NumberField.Embeddings (#6164)

Remove unnecessary or redundant results and golf some proofs.

Diff
@@ -15,12 +15,18 @@ import Mathlib.Topology.Instances.Complex
 # Embeddings of number fields
 This file defines the embeddings of a number field into an algebraic closed field.
 
-## Main Results
+## Main Definitions and Results
 * `NumberField.Embeddings.range_eval_eq_rootSet_minpoly`: let `x ∈ K` with `K` number field and
   let `A` be an algebraic closed field of char. 0, then the images of `x` by the embeddings of `K`
    in `A` are exactly the roots in `A` of the minimal polynomial of `x` over `ℚ`.
 * `NumberField.Embeddings.pow_eq_one_of_norm_eq_one`: an algebraic integer whose conjugates are
   all of norm one is a root of unity.
+* `NumberField.InfinitePlace`: the type of infinite places of a number field `K`.
+* `NumberField.InfinitePlace.mk_eq_iff`: two complex embeddings define the same infinite place iff
+they are equal or complex conjugates.
+* `NumberField.InfinitePlace.prod_eq_abs_norm`: the infinite part of the product formula, that is
+for `x ∈ K`, we have `Π_w ‖x‖_w = |norm(x)|` where the product is over the infinite place `w` and
+`‖·‖_w` is the normalized absolute value for `w`.
 
 ## Tags
 number field, embeddings, places, infinite places
@@ -158,8 +164,7 @@ variable {K : Type _} [Field K]
 
 /-- The conjugate of a complex embedding as a complex embedding. -/
 @[reducible]
-def conjugate (φ : K →+* ℂ) : K →+* ℂ :=
-    star φ
+def conjugate (φ : K →+* ℂ) : K →+* ℂ := star φ
 #align number_field.complex_embedding.conjugate NumberField.ComplexEmbedding.conjugate
 
 @[simp]
@@ -172,13 +177,16 @@ theorem place_conjugate (φ : K →+* ℂ) : place (conjugate φ) = place φ :=
 
 /-- An embedding into `ℂ` is real if it is fixed by complex conjugation. -/
 @[reducible]
-def IsReal (φ : K →+* ℂ) : Prop :=
-  IsSelfAdjoint φ
+def IsReal (φ : K →+* ℂ) : Prop := IsSelfAdjoint φ
 #align number_field.complex_embedding.is_real NumberField.ComplexEmbedding.IsReal
 
 theorem isReal_iff {φ : K →+* ℂ} : IsReal φ ↔ conjugate φ = φ := isSelfAdjoint_iff
 #align number_field.complex_embedding.is_real_iff NumberField.ComplexEmbedding.isReal_iff
 
+theorem isReal_conjugate_iff {φ : K →+* ℂ} : IsReal (conjugate φ) ↔ IsReal φ :=
+  IsSelfAdjoint.star_iff
+#align number_field.complex_embedding.is_real_conjugate_iff NumberField.ComplexEmbedding.isReal_conjugate_iff
+
 /-- A real embedding as a ring homomorphism from `K` to `ℝ` . -/
 def IsReal.embedding {φ : K →+* ℂ} (hφ : IsReal φ) : K →+* ℝ where
   toFun x := (φ x).re
@@ -199,15 +207,6 @@ theorem IsReal.coe_embedding_apply {φ : K →+* ℂ} (hφ : IsReal φ) (x : K)
     exact RingHom.congr_fun hφ x
 #align number_field.complex_embedding.is_real.coe_embedding_apply NumberField.ComplexEmbedding.IsReal.coe_embedding_apply
 
-theorem IsReal.place_embedding {φ : K →+* ℂ} (hφ : IsReal φ) : place hφ.embedding = place φ := by
-  ext x
-  simp only [place_apply, Real.norm_eq_abs, ← abs_ofReal, norm_eq_abs, hφ.coe_embedding_apply x]
-#align number_field.complex_embedding.is_real.place_embedding NumberField.ComplexEmbedding.IsReal.place_embedding
-
-theorem isReal_conjugate_iff {φ : K →+* ℂ} : IsReal (conjugate φ) ↔ IsReal φ :=
-  IsSelfAdjoint.star_iff
-#align number_field.complex_embedding.is_real_conjugate_iff NumberField.ComplexEmbedding.isReal_conjugate_iff
-
 end NumberField.ComplexEmbedding
 
 section InfinitePlace
@@ -217,12 +216,10 @@ open NumberField
 variable (K : Type _) [Field K]
 
 /-- An infinite place of a number field `K` is a place associated to a complex embedding. -/
-def NumberField.InfinitePlace :=
-  { w : AbsoluteValue K ℝ // ∃ φ : K →+* ℂ, place φ = w }
+def NumberField.InfinitePlace := { w : AbsoluteValue K ℝ // ∃ φ : K →+* ℂ, place φ = w }
 #align number_field.infinite_place NumberField.InfinitePlace
 
-instance [NumberField K] : Nonempty (NumberField.InfinitePlace K) :=
-  Set.instNonemptyElemRange _
+instance [NumberField K] : Nonempty (NumberField.InfinitePlace K) := Set.instNonemptyElemRange _
 
 variable {K}
 
@@ -235,7 +232,9 @@ namespace NumberField.InfinitePlace
 
 open NumberField
 
-instance : CoeFun (InfinitePlace K) fun _ => K → ℝ where coe w := w.1
+instance {K : Type _} [Field K] : FunLike (InfinitePlace K) K (fun _ => ℝ) :=
+{ coe := fun w x => w.1 x
+  coe_injective' := fun _ _ h => Subtype.eq (AbsoluteValue.ext fun x => congr_fun h x)}
 
 instance : MonoidWithZeroHomClass (InfinitePlace K) K ℝ where
   coe w x := w.1 x
@@ -249,54 +248,40 @@ instance : NonnegHomClass (InfinitePlace K) K ℝ where
   coe_injective' _ _ h := Subtype.eq (AbsoluteValue.ext fun x => congr_fun h x)
   map_nonneg w _ := w.1.nonneg _
 
--- Porting note: new
-@[ext]
-theorem ext {w z : InfinitePlace K} (h : ∀ x, w x = z x) : w = z := FunLike.ext _ _ h
-
-theorem coe_mk (φ : K →+* ℂ) : ⇑(mk φ) = place φ := rfl
-#align number_field.infinite_place.coe_mk NumberField.InfinitePlace.coe_mk
-
+@[simp]
 theorem apply (φ : K →+* ℂ) (x : K) : (mk φ) x = Complex.abs (φ x) := rfl
 #align number_field.infinite_place.apply NumberField.InfinitePlace.apply
 
 /-- For an infinite place `w`, return an embedding `φ` such that `w = infinite_place φ` . -/
-noncomputable def embedding (w : InfinitePlace K) : K →+* ℂ :=
-  w.2.choose
+noncomputable def embedding (w : InfinitePlace K) : K →+* ℂ := w.2.choose
 #align number_field.infinite_place.embedding NumberField.InfinitePlace.embedding
 
 @[simp]
-theorem mk_embedding (w : InfinitePlace K) : mk (embedding w) = w :=
-  Subtype.ext w.2.choose_spec
+theorem mk_embedding (w : InfinitePlace K) : mk (embedding w) = w := Subtype.ext w.2.choose_spec
 #align number_field.infinite_place.mk_embedding NumberField.InfinitePlace.mk_embedding
 
 @[simp]
-theorem abs_embedding (w : InfinitePlace K) (x : K) : Complex.abs (embedding w x) = w x :=
-  congr_fun (congr_arg (↑) w.2.choose_spec) x
-#align number_field.infinite_place.abs_embedding NumberField.InfinitePlace.abs_embedding
+theorem mk_conjugate_eq (φ : K →+* ℂ) : mk (ComplexEmbedding.conjugate φ) = mk φ := by
+  refine FunLike.ext _ _ (fun x => ?_)
+  rw [apply, apply, ComplexEmbedding.conjugate_coe_eq, Complex.abs_conj]
+#align number_field.infinite_place.mk_conjugate_eq NumberField.InfinitePlace.mk_conjugate_eq
+
+theorem norm_embedding_eq (w : InfinitePlace K) (x : K) :
+    ‖(embedding w) x‖ = w x := by
+  nth_rewrite 2 [← mk_embedding w]
+  rfl
 
 theorem eq_iff_eq (x : K) (r : ℝ) : (∀ w : InfinitePlace K, w x = r) ↔ ∀ φ : K →+* ℂ, ‖φ x‖ = r :=
--- Porting note: original proof was:  ⟨fun hw φ => hw (mk φ), fun hφ ⟨w, ⟨φ, rfl⟩⟩ => hφ φ⟩
--- but `rfl` does not work here anymore
   ⟨fun hw φ => hw (mk φ), by rintro hφ ⟨w, ⟨φ, rfl⟩⟩; exact hφ φ⟩
-
 #align number_field.infinite_place.eq_iff_eq NumberField.InfinitePlace.eq_iff_eq
 
 theorem le_iff_le (x : K) (r : ℝ) : (∀ w : InfinitePlace K, w x ≤ r) ↔ ∀ φ : K →+* ℂ, ‖φ x‖ ≤ r :=
--- Porting note: original proof was:  ⟨fun hw φ => hw (mk φ), fun hφ ⟨w, ⟨φ, rfl⟩⟩ => hφ φ⟩
--- but `rfl` does not work here anymore
   ⟨fun hw φ => hw (mk φ), by rintro hφ ⟨w, ⟨φ, rfl⟩⟩; exact hφ φ⟩
 #align number_field.infinite_place.le_iff_le NumberField.InfinitePlace.le_iff_le
 
-theorem pos_iff {w : InfinitePlace K} {x : K} : 0 < w x ↔ x ≠ 0 :=
-  AbsoluteValue.pos_iff w.1
+theorem pos_iff {w : InfinitePlace K} {x : K} : 0 < w x ↔ x ≠ 0 := AbsoluteValue.pos_iff w.1
 #align number_field.infinite_place.pos_iff NumberField.InfinitePlace.pos_iff
 
-@[simp]
-theorem mk_conjugate_eq (φ : K →+* ℂ) : mk (ComplexEmbedding.conjugate φ) = mk φ := by
-  ext x
-  exact congr_fun (congr_arg (↑) (ComplexEmbedding.place_conjugate φ)) x
-#align number_field.infinite_place.mk_conjugate_eq NumberField.InfinitePlace.mk_conjugate_eq
-
 @[simp]
 theorem mk_eq_iff {φ ψ : K →+* ℂ} : mk φ = mk ψ ↔ φ = ψ ∨ ComplexEmbedding.conjugate φ = ψ := by
   constructor
@@ -315,23 +300,17 @@ theorem mk_eq_iff {φ ψ : K →+* ℂ} : mk φ = mk ψ ↔ φ = ψ ∨ ComplexE
       suffices ‖φ (ι.symm (x - y))‖ = ‖ψ (ι.symm (x - y))‖ by
         rw [← this, ← RingEquiv.ofLeftInverse_apply hiφ _, RingEquiv.apply_symm_apply ι _]
         rfl
-      exact congr_fun (congr_arg (↑) h₀) _
-    cases'
-      Complex.uniformContinuous_ringHom_eq_id_or_conj φ.fieldRange hlip.uniformContinuous with h h
-    · left; ext1 x
-      -- Porting note: original proof was just
-      -- convert (congr_fun h (ι x)).symm
-      have := (congr_fun h (ι x)).symm
-      dsimp at this
-      convert this
-      exact (RingEquiv.apply_symm_apply ι.symm x).symm
-    · right; ext1 x
-      -- Porting note: original proof was just
-      -- convert (congr_fun h (ι x)).symm
-      have := (congr_fun h (ι x)).symm
-      dsimp at this
-      convert this
-      exact (RingEquiv.apply_symm_apply ι.symm x).symm
+      exact congrFun (congrArg (↑) h₀) _
+    cases
+      Complex.uniformContinuous_ringHom_eq_id_or_conj φ.fieldRange hlip.uniformContinuous with
+    | inl h =>
+        left; ext1 x
+        conv_rhs => rw [← hiφ x]
+        exact (congrFun h (ι x)).symm
+    | inr h =>
+        right; ext1 x
+        conv_rhs => rw [← hiφ x]
+        exact (congrFun h (ι x)).symm
   · rintro (⟨h⟩ | ⟨h⟩)
     · exact congr_arg mk h
     · rw [← mk_conjugate_eq]
@@ -339,39 +318,39 @@ theorem mk_eq_iff {φ ψ : K →+* ℂ} : mk φ = mk ψ ↔ φ = ψ ∨ ComplexE
 #align number_field.infinite_place.mk_eq_iff NumberField.InfinitePlace.mk_eq_iff
 
 /-- An infinite place is real if it is defined by a real embedding. -/
-def IsReal (w : InfinitePlace K) : Prop :=
-  ∃ φ : K →+* ℂ, ComplexEmbedding.IsReal φ ∧ mk φ = w
+def IsReal (w : InfinitePlace K) : Prop := ∃ φ : K →+* ℂ, ComplexEmbedding.IsReal φ ∧ mk φ = w
 #align number_field.infinite_place.is_real NumberField.InfinitePlace.IsReal
 
 /-- An infinite place is complex if it is defined by a complex (ie. not real) embedding. -/
-def IsComplex (w : InfinitePlace K) : Prop :=
-  ∃ φ : K →+* ℂ, ¬ComplexEmbedding.IsReal φ ∧ mk φ = w
+def IsComplex (w : InfinitePlace K) : Prop := ∃ φ : K →+* ℂ, ¬ComplexEmbedding.IsReal φ ∧ mk φ = w
 #align number_field.infinite_place.is_complex NumberField.InfinitePlace.IsComplex
 
-@[simp]
-theorem _root_.NumberField.ComplexEmbeddings.IsReal.embedding_mk {φ : K →+* ℂ}
-    (h : ComplexEmbedding.IsReal φ) : embedding (mk φ) = φ := by
-  have := mk_eq_iff.mp (mk_embedding (mk φ)).symm
-  rwa [ComplexEmbedding.isReal_iff.mp h, or_self_iff, eq_comm] at this
-#align number_field.complex_embeddings.is_real.embedding_mk NumberField.ComplexEmbeddings.IsReal.embedding_mk
+theorem embedding_mk_eq (φ : K →+* ℂ) :
+    embedding (mk φ) = φ ∨ embedding (mk φ) = ComplexEmbedding.conjugate φ := by
+  rw [@eq_comm _ _ φ, @eq_comm _ _ (ComplexEmbedding.conjugate φ), ← mk_eq_iff, mk_embedding]
 
-theorem isReal_iff {w : InfinitePlace K} : IsReal w ↔ ComplexEmbedding.IsReal (embedding w) := by
-  constructor
-  · rintro ⟨φ, ⟨hφ, rfl⟩⟩
-    rwa [_root_.NumberField.ComplexEmbeddings.IsReal.embedding_mk hφ]
-  · exact fun h => ⟨embedding w, h, mk_embedding w⟩
+@[simp]
+theorem embedding_mk_eq_of_isReal {φ : K →+* ℂ} (h : ComplexEmbedding.IsReal φ) :
+    embedding (mk φ) = φ := by
+  have := embedding_mk_eq φ
+  rwa [ComplexEmbedding.isReal_iff.mp h, or_self] at this
+#align number_field.complex_embeddings.is_real.embedding_mk NumberField.InfinitePlace.embedding_mk_eq_of_isReal
+
+theorem isReal_iff {w : InfinitePlace K} :
+    IsReal w ↔ ComplexEmbedding.IsReal (embedding w) := by
+  refine ⟨?_, fun h => ⟨embedding w, h, mk_embedding w⟩⟩
+  rintro ⟨φ, ⟨hφ, rfl⟩⟩
+  rwa [embedding_mk_eq_of_isReal hφ]
 #align number_field.infinite_place.is_real_iff NumberField.InfinitePlace.isReal_iff
 
 theorem isComplex_iff {w : InfinitePlace K} :
     IsComplex w ↔ ¬ComplexEmbedding.IsReal (embedding w) := by
-  constructor
-  · rintro ⟨φ, ⟨hφ, rfl⟩⟩
-    contrapose! hφ
-    cases mk_eq_iff.mp (mk_embedding (mk φ)) with
-    | inl h => rwa [← h]
-    | inr h => rw [← ComplexEmbedding.isReal_conjugate_iff] at hφ
-               rwa [← h]
-  · exact fun h => ⟨embedding w, h, mk_embedding w⟩
+  refine ⟨?_, fun h => ⟨embedding w, h, mk_embedding w⟩⟩
+  rintro ⟨φ, ⟨hφ, rfl⟩⟩
+  contrapose! hφ
+  cases mk_eq_iff.mp (mk_embedding (mk φ)) with
+  | inl h => rwa [h] at hφ
+  | inr h => rwa [← ComplexEmbedding.isReal_conjugate_iff, h] at hφ
 #align number_field.infinite_place.is_complex_iff NumberField.InfinitePlace.isComplex_iff
 
 @[simp]
@@ -379,43 +358,60 @@ theorem not_isReal_iff_isComplex {w : InfinitePlace K} : ¬IsReal w ↔ IsComple
   rw [isComplex_iff, isReal_iff]
 #align number_field.infinite_place.not_is_real_iff_is_complex NumberField.InfinitePlace.not_isReal_iff_isComplex
 
-@[simp]
-theorem not_isComplex_iff_isReal {w : InfinitePlace K} : ¬IsComplex w ↔ IsReal w := by
-  rw [← not_isReal_iff_isComplex, Classical.not_not]
-#align number_field.infinite_place.not_is_complex_iff_is_real NumberField.InfinitePlace.not_isComplex_iff_isReal
-
 theorem isReal_or_isComplex (w : InfinitePlace K) : IsReal w ∨ IsComplex w := by
   rw [← not_isReal_iff_isComplex]; exact em _
 #align number_field.infinite_place.is_real_or_is_complex NumberField.InfinitePlace.isReal_or_isComplex
 
-/-- For `w` a real infinite place, return the corresponding embedding as a morphism `K →+* ℝ`. -/
-noncomputable def IsReal.embedding {w : InfinitePlace K} (hw : IsReal w) : K →+* ℝ :=
-  (isReal_iff.mp hw).embedding
-#align number_field.infinite_place.is_real.embedding NumberField.InfinitePlace.IsReal.embedding
+/-- The real embedding associated to a real infinite place. -/
+noncomputable def embedding_of_isReal {w : InfinitePlace K} (hw : IsReal w) : K →+* ℝ :=
+  ComplexEmbedding.IsReal.embedding (isReal_iff.mp hw)
+#align number_field.infinite_place.is_real.embedding NumberField.InfinitePlace.embedding_of_isReal
 
-@[simp, nolint simpNF] -- Porting note: simp cannot prove this
-theorem IsReal.place_embedding_apply {w : InfinitePlace K} (hw : IsReal w) (x : K) :
-    place (IsReal.embedding hw) x = w x := by
-  rw [IsReal.embedding, ComplexEmbedding.IsReal.place_embedding, ← coe_mk]
-  exact congr_fun (congr_arg (↑) (mk_embedding w)) x
-#align number_field.infinite_place.is_real.place_embedding_apply NumberField.InfinitePlace.IsReal.place_embedding_apply
+@[simp]
+theorem embedding_of_isReal_apply {w : InfinitePlace K} (hw : IsReal w) (x : K) :
+    ((embedding_of_isReal hw) x : ℂ) = (embedding w) x :=
+  ComplexEmbedding.IsReal.coe_embedding_apply (isReal_iff.mp hw) x
 
 @[simp]
-theorem IsReal.abs_embedding_apply {w : InfinitePlace K} (hw : IsReal w) (x : K) :
-    |IsReal.embedding hw x| = w x := by
-  rw [← IsReal.place_embedding_apply hw x]; congr 1
-#align number_field.infinite_place.is_real.abs_embedding_apply NumberField.InfinitePlace.IsReal.abs_embedding_apply
+theorem isReal_of_mk_isReal {φ : K →+* ℂ} (h : IsReal (mk φ)) :
+    ComplexEmbedding.IsReal φ := by
+  contrapose! h
+  rw [not_isReal_iff_isComplex]
+  exact ⟨φ, h, rfl⟩
 
-variable (K)
+@[simp]
+theorem not_isReal_of_mk_isComplex {φ : K →+* ℂ} (h : IsComplex (mk φ)) :
+    ¬ ComplexEmbedding.IsReal φ := by
+  contrapose! h
+  rw [← not_isReal_iff_isComplex.not, not_not]
+  exact ⟨φ, h, rfl⟩
+
+/-- The multiplicity of an infinite place, that is the number of distinct complex embeddings that
+define it, see `card_filter_mk_eq`. -/
+noncomputable def mult (w : InfinitePlace K) : ℕ := if (IsReal w) then 1 else 2
+
+theorem card_filter_mk_eq [NumberField K] (w : InfinitePlace K) :
+    (Finset.univ.filter fun φ => mk φ = w).card = mult w := by
+  conv_lhs =>
+    congr; congr; ext
+    rw [← mk_embedding w, mk_eq_iff, ComplexEmbedding.conjugate, star_involutive.eq_iff]
+  simp_rw [Finset.filter_or, Finset.filter_eq' _ (embedding w),
+    Finset.filter_eq' _ (ComplexEmbedding.conjugate (embedding w)),
+    Finset.mem_univ, ite_true, mult]
+  split_ifs with hw
+  · rw [ComplexEmbedding.isReal_iff.mp (isReal_iff.mp hw), Finset.union_idempotent,
+      Finset.card_singleton]
+  · refine Finset.card_doubleton ?_
+    rwa [Ne.def, eq_comm, ← ComplexEmbedding.isReal_iff, ← isReal_iff]
 
 /-- The map from real embeddings to real infinite places as an equiv -/
 noncomputable def mkReal :
-    { φ : K →+* ℂ // ComplexEmbedding.IsReal φ } ≃ { w : InfinitePlace K // IsReal w } where
-  toFun := Subtype.map mk fun φ hφ => ⟨φ, hφ, rfl⟩
-  invFun w := ⟨w.1.embedding, isReal_iff.1 w.2⟩
-  left_inv φ := Subtype.ext_iff.2 (NumberField.ComplexEmbeddings.IsReal.embedding_mk φ.2)
-  right_inv w := Subtype.ext_iff.2 (mk_embedding w.1)
-#align number_field.infinite_place.mk_real NumberField.InfinitePlace.mkReal
+    { φ : K →+* ℂ // ComplexEmbedding.IsReal φ } ≃ { w : InfinitePlace K // IsReal w } := by
+  refine (Equiv.ofBijective (fun φ => ⟨mk φ, ?_⟩) ⟨fun φ ψ h => ?_, fun w => ?_⟩)
+  · exact ⟨φ, φ.prop, rfl⟩
+  · rwa [Subtype.mk.injEq, mk_eq_iff, ComplexEmbedding.isReal_iff.mp φ.prop, or_self,
+      ← Subtype.ext_iff] at h
+  · exact ⟨⟨embedding w, isReal_iff.mp w.prop⟩, by simp⟩
 
 /-- The map from nonreal embeddings to complex infinite places -/
 noncomputable def mkComplex :
@@ -423,111 +419,75 @@ noncomputable def mkComplex :
   Subtype.map mk fun φ hφ => ⟨φ, hφ, rfl⟩
 #align number_field.infinite_place.mk_complex NumberField.InfinitePlace.mkComplex
 
-theorem mkComplex_embedding (φ : { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ }) :
-    (mkComplex K φ : InfinitePlace K).embedding = φ ∨
-      (mkComplex K φ : InfinitePlace K).embedding = ComplexEmbedding.conjugate φ := by
-  rw [@eq_comm _ _ φ.val, @eq_comm _ _ (ComplexEmbedding.conjugate φ.val), ← mk_eq_iff,
-    mk_embedding]
-  rfl
-#align number_field.infinite_place.mk_complex_embedding NumberField.InfinitePlace.mkComplex_embedding
-
 @[simp]
 theorem mkReal_coe (φ : { φ : K →+* ℂ // ComplexEmbedding.IsReal φ }) :
-    (mkReal K φ : InfinitePlace K) = mk (φ : K →+* ℂ) := rfl
+    (mkReal φ : InfinitePlace K) = mk (φ : K →+* ℂ) := rfl
 #align number_field.infinite_place.mk_real_coe NumberField.InfinitePlace.mkReal_coe
 
 @[simp]
 theorem mkComplex_coe (φ : { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ }) :
-    (mkComplex K φ : InfinitePlace K) = mk (φ : K →+* ℂ) := rfl
+    (mkComplex φ : InfinitePlace K) = mk (φ : K →+* ℂ) := rfl
 #align number_field.infinite_place.mk_complex_coe NumberField.InfinitePlace.mkComplex_coe
 
--- @[simp] -- Porting note: not in simpNF
-theorem mkReal.apply (φ : { φ : K →+* ℂ // ComplexEmbedding.IsReal φ }) (x : K) :
-    (mkReal K φ).val x = Complex.abs (φ.val x) := rfl
-#align number_field.infinite_place.mk_real.apply NumberField.InfinitePlace.mkReal.apply
-
--- @[simp] -- Porting note: not in simpNF
-theorem mkComplex.apply (φ : { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ }) (x : K) :
-    (mkComplex K φ).val x = Complex.abs (φ.val x) := rfl
-#align number_field.infinite_place.mk_complex.apply NumberField.InfinitePlace.mkComplex.apply
-
 variable [NumberField K]
 
-theorem mkComplex.filter (w : { w : InfinitePlace K // w.IsComplex }) :
-    (Finset.univ.filter fun φ => mkComplex K φ = w) =
-      {⟨w.1.embedding, isComplex_iff.1 w.2⟩,
-        ⟨ComplexEmbedding.conjugate w.1.embedding,
-          ComplexEmbedding.isReal_conjugate_iff.not.2 (isComplex_iff.1 w.2)⟩} := by
-  ext φ
-  simp_rw [Finset.mem_filter, Finset.mem_insert, Finset.mem_singleton,
-    @Subtype.ext_iff_val (InfinitePlace K), @Subtype.ext_iff_val (K →+* ℂ), @eq_comm _ φ.val, ←
-    mk_eq_iff, mk_embedding, @eq_comm _ _ w.val]
-  simp only [Finset.mem_univ, mkComplex_coe, true_and]
-#align number_field.infinite_place.mk_complex.filter NumberField.InfinitePlace.mkComplex.filter
-
-theorem mkComplex.filter_card (w : { w : InfinitePlace K // w.IsComplex }) :
-    (Finset.univ.filter fun φ => mkComplex K φ = w).card = 2 := by
-  rw [mkComplex.filter]
-  exact Finset.card_doubleton
-      (Subtype.mk_eq_mk.not.2 <|
-        ne_comm.1 <| ComplexEmbedding.isReal_iff.not.1 <| isComplex_iff.1 w.2)
-#align number_field.infinite_place.mk_complex.filter_card NumberField.InfinitePlace.mkComplex.filter_card
-
 noncomputable instance NumberField.InfinitePlace.fintype : Fintype (InfinitePlace K) :=
   Set.fintypeRange _
 #align number_field.infinite_place.number_field.infinite_place.fintype NumberField.InfinitePlace.NumberField.InfinitePlace.fintype
 
+open scoped BigOperators
+
 /-- The infinite part of the product formula : for `x ∈ K`, we have `Π_w ‖x‖_w = |norm(x)|` where
 `‖·‖_w` is the normalized absolute value for `w`.  -/
 theorem prod_eq_abs_norm (x : K) :
-    (Finset.univ.prod fun w : InfinitePlace K => ite w.IsReal (w x) (w x ^ 2)) =
-      abs (Algebra.norm ℚ x) := by
+    ∏ w : InfinitePlace K, w x ^ mult w = abs (Algebra.norm ℚ x) := by
   convert (congr_arg Complex.abs (@Algebra.norm_eq_prod_embeddings ℚ _ _ _ _ ℂ _ _ _ _ _ x)).symm
   · rw [map_prod, ← Equiv.prod_comp' RingHom.equivRatAlgHom (fun f => Complex.abs (f x))
-        (fun φ => Complex.abs (φ x)) fun _ => by simp [RingHom.equivRatAlgHom_apply]; rfl]
-    conv =>
-      rhs; congr; next => skip
-      ext f
-      rw [show Complex.abs (f x) =
-            ite (ComplexEmbedding.IsReal f) (Complex.abs (f x)) (Complex.abs (f x)) by simp]
-    rw [Finset.prod_ite, Finset.prod_ite]
-    refine congr (congr_arg Mul.mul ?_) ?_
-    · rw [← Finset.prod_subtype_eq_prod_filter, ← Finset.prod_subtype_eq_prod_filter]
-      convert (Equiv.prod_comp' (mkReal K) (fun φ => Complex.abs (φ.val x))
-        (fun w => w.val x) _).symm
-      any_goals ext; simp only [Finset.mem_subtype, Finset.mem_univ]
-      exact fun φ => mkReal.apply K φ x
-    · rw [Finset.filter_congr fun (w : InfinitePlace K) _ => @not_isReal_iff_isComplex K _ w,
-        ← Finset.prod_subtype_eq_prod_filter, ← Finset.prod_subtype_eq_prod_filter]
-      convert Finset.prod_fiberwise Finset.univ (fun φ => mkComplex K φ)
-        (fun φ => Complex.abs (φ.val x)) using 2 with w
-      · ext; simp only [Finset.mem_subtype, Finset.mem_univ, not_isReal_iff_isComplex]
-      · rw [@Finset.prod_congr _ _ _ _ _ (fun _ => w.val x) _ (Eq.refl _) fun φ hφ =>
-            (mkComplex.apply K φ x).symm.trans ?_, Finset.prod_const, mkComplex.filter_card K w]
-        rw [congr_arg Subtype.val (Finset.mem_filter.1 hφ).2]
-      · ext; simp only [Finset.mem_subtype, Finset.mem_univ]
+      (fun φ => Complex.abs (φ x)) fun _ => by simp [RingHom.equivRatAlgHom_apply]; rfl]
+    rw [← Finset.prod_fiberwise Finset.univ (fun φ => mk φ) (fun φ => Complex.abs (φ x))]
+    have : ∀ w : InfinitePlace K, ∀ φ ∈ Finset.filter (fun a ↦ mk a = w) Finset.univ,
+        Complex.abs (φ x) = w x := by
+      intro _ _ hφ
+      rw [← (Finset.mem_filter.mp hφ).2]
+      rfl
+    simp_rw [Finset.prod_congr rfl (this _), Finset.mem_univ, forall_true_left, Finset.prod_const,
+      card_filter_mk_eq]
   · rw [eq_ratCast, Rat.cast_abs, ← Complex.abs_ofReal, Complex.ofReal_rat_cast]
 #align number_field.infinite_place.prod_eq_abs_norm NumberField.InfinitePlace.prod_eq_abs_norm
 
-open Fintype
+open Fintype FiniteDimensional
 
 theorem card_real_embeddings :
-    card { φ : K →+* ℂ // ComplexEmbedding.IsReal φ } = card { w : InfinitePlace K // IsReal w } :=
-  by convert (Fintype.ofEquiv_card (mkReal K)).symm
+    card { φ : K →+* ℂ // ComplexEmbedding.IsReal φ }
+      = card { w : InfinitePlace K // IsReal w } := Fintype.card_congr mkReal
 #align number_field.infinite_place.card_real_embeddings NumberField.InfinitePlace.card_real_embeddings
 
 theorem card_complex_embeddings :
     card { φ : K →+* ℂ // ¬ComplexEmbedding.IsReal φ } =
       2 * card { w : InfinitePlace K // IsComplex w } := by
-  rw [Fintype.card, Fintype.card, mul_comm, ← Algebra.id.smul_eq_mul, ← Finset.sum_const]
-  conv =>
-    rhs; congr; next => skip
-    ext x
-    rw [← mkComplex.filter_card K x]
-  simp_rw [Finset.card_eq_sum_ones]
-  exact (Finset.sum_fiberwise Finset.univ (fun φ => mkComplex K φ) fun _ => 1).symm
+  suffices ∀ w : { w : InfinitePlace K // IsComplex w }, (Finset.univ.filter
+      fun φ : { φ // ¬ ComplexEmbedding.IsReal φ } => mkComplex φ = w).card = 2 by
+    rw [Fintype.card, Finset.card_eq_sum_ones, ← Finset.sum_fiberwise _ (fun φ => mkComplex φ)]
+    simp_rw [Finset.sum_const, this, smul_eq_mul, mul_one, Fintype.card, Finset.card_eq_sum_ones,
+      Finset.mul_sum]
+  rintro ⟨w, hw⟩
+  convert card_filter_mk_eq w
+  · rw [← Fintype.card_subtype, ← Fintype.card_subtype]
+    refine Fintype.card_congr (Equiv.ofBijective ?_ ⟨fun _ _ h => ?_, fun ⟨φ, hφ⟩ => ?_⟩)
+    · exact fun ⟨φ, hφ⟩ => ⟨φ.val, by rwa [Subtype.ext_iff] at hφ⟩
+    · rwa [Subtype.mk_eq_mk, ← Subtype.ext_iff, ← Subtype.ext_iff] at h
+    · refine ⟨⟨⟨φ, not_isReal_of_mk_isComplex (hφ.symm ▸ hw)⟩, ?_⟩, rfl⟩
+      rwa [Subtype.ext_iff, mkComplex_coe]
+  · simp_rw [mult, not_isReal_iff_isComplex.mpr hw]
 #align number_field.infinite_place.card_complex_embeddings NumberField.InfinitePlace.card_complex_embeddings
 
+theorem card_add_two_mul_card_eq_rank :
+    card { w : InfinitePlace K // IsReal w } + 2 * card { w : InfinitePlace K // IsComplex w } =
+      finrank ℚ K := by
+  rw [← card_real_embeddings, ← card_complex_embeddings]
+  rw [Fintype.card_subtype_compl, ← Embeddings.card K ℂ, Nat.add_sub_of_le]
+  exact Fintype.card_subtype_le _
+
 end NumberField.InfinitePlace
 
 end InfinitePlace
chore(FieldTheory/Adjoin): remove unnecessary assumptions in minpolynatDegree_le and minpoly.degree_le (#6152)

Also

  • fix the names of minpoly.natDegree_le and minpoly.degree_le
  • rename minpoly.ne_zero_of_finite_field_extension to minpoly.ne_zero_of_finite
  • reduce typeclass assumptions of some lemmas in RingTheory/Algebraic
  • add two lemmas isIntegral_of_finite and isAlgebraic_of_finite
  • move Algebra.isIntegral_of_finite to RingTheory/IntegralClosure
Diff
@@ -89,7 +89,7 @@ theorem coeff_bdd_of_norm_le {B : ℝ} {x : K} (h : ∀ φ : K →+* A, ‖φ x
   have hx := IsSeparable.isIntegral ℚ x
   rw [← norm_algebraMap' A, ← coeff_map (algebraMap ℚ A)]
   refine coeff_bdd_of_roots_le _ (minpoly.monic hx)
-      (IsAlgClosed.splits_codomain _) (IntermediateField.minpoly.natDegree_le hx) (fun z hz => ?_) i
+      (IsAlgClosed.splits_codomain _) (minpoly.natDegree_le x) (fun z hz => ?_) i
   classical
   rw [← Multiset.mem_toFinset] at hz
   obtain ⟨φ, rfl⟩ := (range_eval_eq_rootSet_minpoly K A x).symm.subset hz
@@ -107,7 +107,7 @@ theorem finite_of_norm_le (B : ℝ) : {x : K | IsIntegral ℤ x ∧ ∀ φ : K 
   have h_map_ℚ_minpoly := minpoly.isIntegrallyClosed_eq_field_fractions' ℚ hx.1
   refine ⟨_, ⟨?_, fun i => ?_⟩, mem_rootSet.2 ⟨minpoly.ne_zero hx.1, minpoly.aeval ℤ x⟩⟩
   · rw [← (minpoly.monic hx.1).natDegree_map (algebraMap ℤ ℚ), ← h_map_ℚ_minpoly]
-    exact IntermediateField.minpoly.natDegree_le (isIntegral_of_isScalarTower hx.1)
+    exact minpoly.natDegree_le x
   rw [mem_Icc, ← abs_le, ← @Int.cast_le ℝ]
   refine (Eq.trans_le ?_ <| coeff_bdd_of_norm_le hx.2 i).trans (Nat.le_ceil _)
   rw [h_map_ℚ_minpoly, coeff_map, eq_intCast, Int.norm_cast_rat, Int.norm_eq_abs, Int.cast_abs]
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,11 +2,6 @@
 Copyright (c) 2022 Xavier Roblot. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Alex J. Best, Xavier Roblot
-
-! This file was ported from Lean 3 source module number_theory.number_field.embeddings
-! leanprover-community/mathlib commit caa58cbf5bfb7f81ccbaca4e8b8ac4bc2b39cc1c
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Analysis.Complex.Polynomial
 import Mathlib.FieldTheory.Minpoly.IsIntegrallyClosed
@@ -14,6 +9,8 @@ import Mathlib.NumberTheory.NumberField.Basic
 import Mathlib.RingTheory.Norm
 import Mathlib.Topology.Instances.Complex
 
+#align_import number_theory.number_field.embeddings from "leanprover-community/mathlib"@"caa58cbf5bfb7f81ccbaca4e8b8ac4bc2b39cc1c"
+
 /-!
 # Embeddings of number fields
 This file defines the embeddings of a number field into an algebraic closed field.
chore: remove occurrences of semicolon after space (#5713)

This is the second half of the changes originally in #5699, removing all occurrences of ; after a space and implementing a linter rule to enforce it.

In most cases this 2-character substring has a space after it, so the following command was run first:

find . -type f -name "*.lean" -exec sed -i -E 's/ ; /; /g' {} \;

The remaining cases were few enough in number that they were done manually.

Diff
@@ -129,7 +129,7 @@ theorem pow_eq_one_of_norm_eq_one {x : K} (hxi : IsIntegral ℤ x) (hx : ∀ φ
     rw [← Nat.sub_add_cancel hlt.le, pow_add, mul_left_eq_self₀] at h
     refine h.resolve_right fun hp => ?_
     specialize hx (IsAlgClosed.lift (NumberField.isAlgebraic K)).toRingHom
-    rw [pow_eq_zero hp, map_zero, norm_zero] at hx ; norm_num at hx
+    rw [pow_eq_zero hp, map_zero, norm_zero] at hx; norm_num at hx
 #align number_field.embeddings.pow_eq_one_of_norm_eq_one NumberField.Embeddings.pow_eq_one_of_norm_eq_one
 
 end Bounded
chore: fix grammar in docs (#5668)
Diff
@@ -173,7 +173,7 @@ theorem place_conjugate (φ : K →+* ℂ) : place (conjugate φ) = place φ :=
   ext; simp only [place_apply, norm_eq_abs, abs_conj, conjugate_coe_eq]
 #align number_field.complex_embedding.place_conjugate NumberField.ComplexEmbedding.place_conjugate
 
-/-- A embedding into `ℂ` is real if it is fixed by complex conjugation. -/
+/-- An embedding into `ℂ` is real if it is fixed by complex conjugation. -/
 @[reducible]
 def IsReal (φ : K →+* ℂ) : Prop :=
   IsSelfAdjoint φ
chore: tidy various files (#5449)
Diff
@@ -29,6 +29,8 @@ This file defines the embeddings of a number field into an algebraic closed fiel
 number field, embeddings, places, infinite places
 -/
 
+-- Porting note: see https://github.com/leanprover/lean4/issues/2220
+local macro_rules | `($x ^ $y)   => `(HPow.hPow $x $y)
 
 open scoped Classical
 
@@ -79,9 +81,6 @@ end Roots
 
 section Bounded
 
--- Porting note: see https://github.com/leanprover/lean4/issues/2220
-local macro_rules | `($x ^ $y)   => `(HPow.hPow $x $y)
-
 open FiniteDimensional Polynomial Set
 
 variable {K : Type _} [Field K] [NumberField K]
@@ -305,7 +304,7 @@ theorem mk_conjugate_eq (φ : K →+* ℂ) : mk (ComplexEmbedding.conjugate φ)
 theorem mk_eq_iff {φ ψ : K →+* ℂ} : mk φ = mk ψ ↔ φ = ψ ∨ ComplexEmbedding.conjugate φ = ψ := by
   constructor
   · -- We prove that the map ψ ∘ φ⁻¹ between φ(K) and ℂ is uniform continuous, thus it is either the
-    -- inclusion or the complex conjugation using complex.uniform_continuous_ring_hom_eq_id_or_conj
+    -- inclusion or the complex conjugation using `Complex.uniformContinuous_ringHom_eq_id_or_conj`
     intro h₀
     obtain ⟨j, hiφ⟩ := (φ.injective).hasLeftInverse
     let ι := RingEquiv.ofLeftInverse hiφ
@@ -504,13 +503,10 @@ theorem prod_eq_abs_norm (x : K) :
     · rw [Finset.filter_congr fun (w : InfinitePlace K) _ => @not_isReal_iff_isComplex K _ w,
         ← Finset.prod_subtype_eq_prod_filter, ← Finset.prod_subtype_eq_prod_filter]
       convert Finset.prod_fiberwise Finset.univ (fun φ => mkComplex K φ)
-        (fun φ => Complex.abs (φ.val x)) using 2
+        (fun φ => Complex.abs (φ.val x)) using 2 with w
       · ext; simp only [Finset.mem_subtype, Finset.mem_univ, not_isReal_iff_isComplex]
-      · rename_i w _ -- Porting note : need to recover the name of the variable
-                     -- generated automatically by the `convert`
-        rw [@Finset.prod_congr _ _ _ _ _ (fun _ => w.val x) _ (Eq.refl _) fun φ hφ =>
+      · rw [@Finset.prod_congr _ _ _ _ _ (fun _ => w.val x) _ (Eq.refl _) fun φ hφ =>
             (mkComplex.apply K φ x).symm.trans ?_, Finset.prod_const, mkComplex.filter_card K w]
-        norm_num
         rw [congr_arg Subtype.val (Finset.mem_filter.1 hφ).2]
       · ext; simp only [Finset.mem_subtype, Finset.mem_univ]
   · rw [eq_ratCast, Rat.cast_abs, ← Complex.abs_ofReal, Complex.ofReal_rat_cast]
feat: port NumberTheory.NumberField.Embeddings (#5367)

Dependencies 12 + 1174

1175 files ported (99.0%)
516613 lines ported (98.9%)
Show graph

The unported dependencies are

The following 1 dependencies have changed in mathlib3 since they were ported, which may complicate porting this file