ring_theory.polynomial.gauss_lemmaMathlib.RingTheory.Polynomial.GaussLemma

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)

(last sync)

chore(field_theory/splitting_field): refactor splitting_field (#19178)

We refactor the definition of splitting_field. The main motivation is to backport 4#4891 since the is seems very problematic to port the current design.

Zulip discussion relevant to this PR: https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/!4.234891.20.20FieldTheory.2ESplittingField

Diff
@@ -51,7 +51,6 @@ theorem integral_closure.mem_lifts_of_monic_of_dvd_map
   {f : R[X]} (hf : f.monic) {g : K[X]} (hg : g.monic) (hd : g ∣ f.map (algebra_map R K)) :
   g ∈ lifts (algebra_map (integral_closure R K) K) :=
 begin
-  haveI : is_scalar_tower R K g.splitting_field := splitting_field_aux.is_scalar_tower _ _ _,
   have := mem_lift_of_splits_of_roots_mem_range (integral_closure R g.splitting_field)
     ((splits_id_iff_splits _).2 $ splitting_field.splits g) (hg.map _)
     (λ a ha, (set_like.ext_iff.mp (integral_closure R g.splitting_field).range_algebra_map _).mpr $
@@ -67,7 +66,7 @@ begin
   refine multiset.mem_of_le (roots.le_of_dvd ((hf.map _).map _).ne_zero _) ha,
   { apply_instance },
   { exact map_dvd (algebra_map K g.splitting_field) hd },
-  { apply splitting_field_aux.is_scalar_tower },
+  { apply_instance }
 end
 
 variables [is_domain R] [is_fraction_ring R K]

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(first ported)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -64,11 +64,11 @@ theorem integralClosure.mem_lifts_of_monic_of_dvd_map {f : R[X]} (hf : f.Monic)
       ((splits_id_iff_splits _).2 <| splitting_field.splits g) (hg.map _) fun a ha =>
       (set_like.ext_iff.mp (integralClosure R g.splitting_field).range_algebraMap _).mpr <|
         roots_mem_integralClosure hf _
-  · rw [lifts_iff_coeff_lifts, ← RingHom.coe_range, Subalgebra.range_algebraMap] at this 
+  · rw [lifts_iff_coeff_lifts, ← RingHom.coe_range, Subalgebra.range_algebraMap] at this
     refine' (lifts_iff_coeff_lifts _).2 fun n => _
     rw [← RingHom.coe_range, Subalgebra.range_algebraMap]
     obtain ⟨p, hp, he⟩ := set_like.mem_coe.mp (this n); use p, hp
-    rw [IsScalarTower.algebraMap_eq R K, coeff_map, ← eval₂_map, eval₂_at_apply] at he 
+    rw [IsScalarTower.algebraMap_eq R K, coeff_map, ← eval₂_map, eval₂_at_apply] at he
     rw [eval₂_eq_eval_map]; apply (injective_iff_map_eq_zero _).1 _ _ he
     · apply RingHom.injective
   rw [IsScalarTower.algebraMap_eq R K _, ← map_map]
@@ -131,7 +131,7 @@ theorem IsPrimitive.isUnit_iff_isUnit_map_of_injective : IsUnit f ↔ IsUnit (ma
   refine' ⟨(map_ring_hom φ).isUnit_map, fun h => _⟩
   rcases is_unit_iff.1 h with ⟨_, ⟨u, rfl⟩, hu⟩
   have hdeg := degree_C u.ne_zero
-  rw [hu, degree_map_eq_of_injective hinj] at hdeg 
+  rw [hu, degree_map_eq_of_injective hinj] at hdeg
   rw [eq_C_of_degree_eq_zero hdeg] at hf ⊢
   exact is_unit_C.mpr (is_primitive_iff_is_unit_of_C_dvd.mp hf (f.coeff 0) dvd_rfl)
 #align polynomial.is_primitive.is_unit_iff_is_unit_map_of_injective Polynomial.IsPrimitive.isUnit_iff_isUnit_map_of_injective
@@ -189,7 +189,7 @@ theorem Monic.irreducible_iff_irreducible_map_fraction_map [IsIntegrallyClosed R
   have : a.leading_coeff * b.leading_coeff = 1 := by
     rw [← leading_coeff_mul, ← H, monic.leading_coeff (h.map <| algebraMap R K)]
   rw [← ha, ← hb, mul_comm _ (C b.leading_coeff), mul_assoc, ← mul_assoc (C a.leading_coeff), ←
-    C_mul, this, C_1, one_mul, ← Polynomial.map_mul] at H 
+    C_mul, this, C_1, one_mul, ← Polynomial.map_mul] at H
   rw [← hb, ← Polynomial.coe_mapRingHom]
   refine'
     IsUnit.mul (IsUnit.map _ (Or.resolve_left (hp.is_unit_or_is_unit _) (show ¬IsUnit a' from _)))
@@ -232,8 +232,8 @@ theorem Monic.dvd_of_fraction_map_dvd_fraction_map [IsIntegrallyClosed R] {p q :
   by
   obtain ⟨r, hr⟩ := h
   obtain ⟨d', hr'⟩ := IsIntegrallyClosed.eq_map_mul_C_of_dvd K hp (dvd_of_mul_left_eq _ hr.symm)
-  rw [monic.leading_coeff, C_1, mul_one] at hr' 
-  rw [← hr', ← Polynomial.map_mul] at hr 
+  rw [monic.leading_coeff, C_1, mul_one] at hr'
+  rw [← hr', ← Polynomial.map_mul] at hr
   exact dvd_of_mul_right_eq _ (Polynomial.map_injective _ (IsFractionRing.injective R K) hr.symm)
   · exact monic.of_mul_monic_left (hq.map (algebraMap R K)) (by simpa [← hr] using hp.map _)
 #align polynomial.monic.dvd_of_fraction_map_dvd_fraction_map Polynomial.Monic.dvd_of_fraction_map_dvd_fraction_map
@@ -261,7 +261,7 @@ theorem isUnit_or_eq_zero_of_isUnit_integerNormalization_primPart {p : K[X]} (h0
   by
   rcases is_unit_iff.1 h with ⟨_, ⟨u, rfl⟩, hu⟩
   obtain ⟨⟨c, c0⟩, hc⟩ := integer_normalization_map_to_map R⁰ p
-  rw [Subtype.coe_mk, Algebra.smul_def, algebraMap_apply] at hc 
+  rw [Subtype.coe_mk, Algebra.smul_def, algebraMap_apply] at hc
   apply isUnit_of_mul_isUnit_right
   rw [← hc, (integer_normalization R⁰ p).eq_C_content_mul_primPart, ← hu, ← RingHom.map_mul,
     is_unit_iff]
@@ -269,7 +269,7 @@ theorem isUnit_or_eq_zero_of_isUnit_integerNormalization_primPart {p : K[X]} (h0
     ⟨algebraMap R K ((integer_normalization R⁰ p).content * ↑u), isUnit_iff_ne_zero.2 fun con => _,
       by simp⟩
   replace con := (injective_iff_map_eq_zero (algebraMap R K)).1 (IsFractionRing.injective _ _) _ Con
-  rw [mul_eq_zero, content_eq_zero_iff, IsFractionRing.integerNormalization_eq_zero_iff] at con 
+  rw [mul_eq_zero, content_eq_zero_iff, IsFractionRing.integerNormalization_eq_zero_iff] at con
   rcases Con with (con | con)
   · apply h0 Con
   · apply Units.ne_zero _ Con
@@ -287,10 +287,10 @@ theorem IsPrimitive.irreducible_iff_irreducible_map_fraction_map {p : R[X]} (hp
       hp.irreducible_of_irreducible_map_of_injective (IsFractionRing.injective _ _)⟩
   obtain ⟨⟨c, c0⟩, hc⟩ := integer_normalization_map_to_map R⁰ a
   obtain ⟨⟨d, d0⟩, hd⟩ := integer_normalization_map_to_map R⁰ b
-  rw [Algebra.smul_def, algebraMap_apply, Subtype.coe_mk] at hc hd 
-  rw [mem_nonZeroDivisors_iff_ne_zero] at c0 d0 
+  rw [Algebra.smul_def, algebraMap_apply, Subtype.coe_mk] at hc hd
+  rw [mem_nonZeroDivisors_iff_ne_zero] at c0 d0
   have hcd0 : c * d ≠ 0 := mul_ne_zero c0 d0
-  rw [Ne.def, ← C_eq_zero] at hcd0 
+  rw [Ne.def, ← C_eq_zero] at hcd0
   have h1 : C c * C d * p = integer_normalization R⁰ a * integer_normalization R⁰ b :=
     by
     apply map_injective (algebraMap R K) (IsFractionRing.injective _ _) _
@@ -307,7 +307,7 @@ theorem IsPrimitive.irreducible_iff_irreducible_map_fraction_map {p : R[X]} (hp
   rw [← RingHom.map_mul, eq_comm, (integer_normalization R⁰ a).eq_C_content_mul_primPart,
     (integer_normalization R⁰ b).eq_C_content_mul_primPart, mul_assoc, mul_comm _ (C _ * _), ←
     mul_assoc, ← mul_assoc, ← RingHom.map_mul, ← hu, RingHom.map_mul, mul_assoc, mul_assoc, ←
-    mul_assoc (C ↑u)] at h1 
+    mul_assoc (C ↑u)] at h1
   have h0 : a ≠ 0 ∧ b ≠ 0 := by
     classical
     rw [Ne.def, Ne.def, ← Decidable.not_or_iff_and_not, ← mul_eq_zero, ← hab]
@@ -330,13 +330,13 @@ theorem IsPrimitive.dvd_of_fraction_map_dvd_fraction_map {p q : R[X]} (hp : p.Is
   by
   rcases h_dvd with ⟨r, hr⟩
   obtain ⟨⟨s, s0⟩, hs⟩ := integer_normalization_map_to_map R⁰ r
-  rw [Subtype.coe_mk, Algebra.smul_def, algebraMap_apply] at hs 
+  rw [Subtype.coe_mk, Algebra.smul_def, algebraMap_apply] at hs
   have h : p ∣ q * C s := by
     use integer_normalization R⁰ r
     apply map_injective (algebraMap R K) (IsFractionRing.injective _ _)
     rw [Polynomial.map_mul, Polynomial.map_mul, hs, hr, mul_assoc, mul_comm r]
     simp
-  rw [← hp.dvd_prim_part_iff_dvd, prim_part_mul, hq.prim_part_eq, Associated.dvd_iff_dvd_right] at h 
+  rw [← hp.dvd_prim_part_iff_dvd, prim_part_mul, hq.prim_part_eq, Associated.dvd_iff_dvd_right] at h
   · exact h
   · symm
     rcases is_unit_prim_part_C s with ⟨u, hu⟩
Diff
@@ -308,7 +308,12 @@ theorem IsPrimitive.irreducible_iff_irreducible_map_fraction_map {p : R[X]} (hp
     (integer_normalization R⁰ b).eq_C_content_mul_primPart, mul_assoc, mul_comm _ (C _ * _), ←
     mul_assoc, ← mul_assoc, ← RingHom.map_mul, ← hu, RingHom.map_mul, mul_assoc, mul_assoc, ←
     mul_assoc (C ↑u)] at h1 
-  have h0 : a ≠ 0 ∧ b ≠ 0 := by classical
+  have h0 : a ≠ 0 ∧ b ≠ 0 := by
+    classical
+    rw [Ne.def, Ne.def, ← Decidable.not_or_iff_and_not, ← mul_eq_zero, ← hab]
+    intro con
+    apply hp.ne_zero (map_injective (algebraMap R K) (IsFractionRing.injective _ _) _)
+    simp [Con]
   rcases hi.is_unit_or_is_unit (mul_left_cancel₀ hcd0 h1).symm with (h | h)
   · right
     apply
Diff
@@ -308,12 +308,7 @@ theorem IsPrimitive.irreducible_iff_irreducible_map_fraction_map {p : R[X]} (hp
     (integer_normalization R⁰ b).eq_C_content_mul_primPart, mul_assoc, mul_comm _ (C _ * _), ←
     mul_assoc, ← mul_assoc, ← RingHom.map_mul, ← hu, RingHom.map_mul, mul_assoc, mul_assoc, ←
     mul_assoc (C ↑u)] at h1 
-  have h0 : a ≠ 0 ∧ b ≠ 0 := by
-    classical
-    rw [Ne.def, Ne.def, ← Decidable.not_or_iff_and_not, ← mul_eq_zero, ← hab]
-    intro con
-    apply hp.ne_zero (map_injective (algebraMap R K) (IsFractionRing.injective _ _) _)
-    simp [Con]
+  have h0 : a ≠ 0 ∧ b ≠ 0 := by classical
   rcases hi.is_unit_or_is_unit (mul_left_cancel₀ hcd0 h1).symm with (h | h)
   · right
     apply
Diff
@@ -3,10 +3,10 @@ Copyright (c) 2020 Aaron Anderson. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Aaron Anderson
 -/
-import Mathbin.FieldTheory.SplittingField.Construction
-import Mathbin.RingTheory.Int.Basic
-import Mathbin.RingTheory.Localization.Integral
-import Mathbin.RingTheory.IntegrallyClosed
+import FieldTheory.SplittingField.Construction
+import RingTheory.Int.Basic
+import RingTheory.Localization.Integral
+import RingTheory.IntegrallyClosed
 
 #align_import ring_theory.polynomial.gauss_lemma from "leanprover-community/mathlib"@"2a0ce625dbb0ffbc7d1316597de0b25c1ec75303"
 
Diff
@@ -2,17 +2,14 @@
 Copyright (c) 2020 Aaron Anderson. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Aaron Anderson
-
-! This file was ported from Lean 3 source module ring_theory.polynomial.gauss_lemma
-! leanprover-community/mathlib commit 2a0ce625dbb0ffbc7d1316597de0b25c1ec75303
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.FieldTheory.SplittingField.Construction
 import Mathbin.RingTheory.Int.Basic
 import Mathbin.RingTheory.Localization.Integral
 import Mathbin.RingTheory.IntegrallyClosed
 
+#align_import ring_theory.polynomial.gauss_lemma from "leanprover-community/mathlib"@"2a0ce625dbb0ffbc7d1316597de0b25c1ec75303"
+
 /-!
 # Gauss's Lemma
 
Diff
@@ -57,6 +57,7 @@ open IsIntegrallyClosed
 
 variable (K : Type _) [Field K] [Algebra R K]
 
+#print integralClosure.mem_lifts_of_monic_of_dvd_map /-
 theorem integralClosure.mem_lifts_of_monic_of_dvd_map {f : R[X]} (hf : f.Monic) {g : K[X]}
     (hg : g.Monic) (hd : g ∣ f.map (algebraMap R K)) :
     g ∈ lifts (algebraMap (integralClosure R K) K) :=
@@ -79,12 +80,14 @@ theorem integralClosure.mem_lifts_of_monic_of_dvd_map {f : R[X]} (hf : f.Monic)
   · exact map_dvd (algebraMap K g.splitting_field) hd
   · infer_instance
 #align integral_closure.mem_lifts_of_monic_of_dvd_map integralClosure.mem_lifts_of_monic_of_dvd_map
+-/
 
 variable [IsDomain R] [IsFractionRing R K]
 
+#print IsIntegrallyClosed.eq_map_mul_C_of_dvd /-
 /-- If `K = Frac(R)` and `g : K[X]` divides a monic polynomial with coefficients in `R`, then
     `g * (C g.leading_coeff⁻¹)` has coefficients in `R` -/
-theorem IsIntegrallyClosed.eq_map_mul_c_of_dvd [IsIntegrallyClosed R] {f : R[X]} (hf : f.Monic)
+theorem IsIntegrallyClosed.eq_map_mul_C_of_dvd [IsIntegrallyClosed R] {f : R[X]} (hf : f.Monic)
     {g : K[X]} (hg : g ∣ f.map (algebraMap R K)) :
     ∃ g' : R[X], g'.map (algebraMap R K) * (C <| leadingCoeff g) = g :=
   by
@@ -112,7 +115,8 @@ theorem IsIntegrallyClosed.eq_map_mul_c_of_dvd [IsIntegrallyClosed R] {f : R[X]}
   use Classical.choose H
   rw [map_map, this]
   exact Classical.choose_spec H
-#align is_integrally_closed.eq_map_mul_C_of_dvd IsIntegrallyClosed.eq_map_mul_c_of_dvd
+#align is_integrally_closed.eq_map_mul_C_of_dvd IsIntegrallyClosed.eq_map_mul_C_of_dvd
+-/
 
 end IsIntegrallyClosed
 
@@ -124,6 +128,7 @@ variable {S : Type _} [CommRing S] [IsDomain S]
 
 variable {φ : R →+* S} (hinj : Function.Injective φ) {f : R[X]} (hf : f.IsPrimitive)
 
+#print Polynomial.IsPrimitive.isUnit_iff_isUnit_map_of_injective /-
 theorem IsPrimitive.isUnit_iff_isUnit_map_of_injective : IsUnit f ↔ IsUnit (map φ f) :=
   by
   refine' ⟨(map_ring_hom φ).isUnit_map, fun h => _⟩
@@ -133,7 +138,9 @@ theorem IsPrimitive.isUnit_iff_isUnit_map_of_injective : IsUnit f ↔ IsUnit (ma
   rw [eq_C_of_degree_eq_zero hdeg] at hf ⊢
   exact is_unit_C.mpr (is_primitive_iff_is_unit_of_C_dvd.mp hf (f.coeff 0) dvd_rfl)
 #align polynomial.is_primitive.is_unit_iff_is_unit_map_of_injective Polynomial.IsPrimitive.isUnit_iff_isUnit_map_of_injective
+-/
 
+#print Polynomial.IsPrimitive.irreducible_of_irreducible_map_of_injective /-
 theorem IsPrimitive.irreducible_of_irreducible_map_of_injective (h_irr : Irreducible (map φ f)) :
     Irreducible f :=
   by
@@ -143,6 +150,7 @@ theorem IsPrimitive.irreducible_of_irreducible_map_of_injective (h_irr : Irreduc
   all_goals apply ((is_primitive_of_dvd hf _).isUnit_iff_isUnit_map_of_injective hinj).mpr
   exacts [Dvd.intro _ h.symm, Dvd.intro_left _ h.symm]
 #align polynomial.is_primitive.irreducible_of_irreducible_map_of_injective Polynomial.IsPrimitive.irreducible_of_irreducible_map_of_injective
+-/
 
 end
 
@@ -150,10 +158,12 @@ section FractionMap
 
 variable {K : Type _} [Field K] [Algebra R K] [IsFractionRing R K]
 
+#print Polynomial.IsPrimitive.isUnit_iff_isUnit_map /-
 theorem IsPrimitive.isUnit_iff_isUnit_map {p : R[X]} (hp : p.IsPrimitive) :
     IsUnit p ↔ IsUnit (p.map (algebraMap R K)) :=
   hp.isUnit_iff_isUnit_map_of_injective (IsFractionRing.injective _ _)
 #align polynomial.is_primitive.is_unit_iff_is_unit_map Polynomial.IsPrimitive.isUnit_iff_isUnit_map
+-/
 
 variable [IsDomain R]
 
@@ -161,6 +171,7 @@ section IsIntegrallyClosed
 
 open IsIntegrallyClosed
 
+#print Polynomial.Monic.irreducible_iff_irreducible_map_fraction_map /-
 /-- **Gauss's Lemma** for integrally closed domains states that a monic polynomial is irreducible
   iff it is irreducible in the fraction field. -/
 theorem Monic.irreducible_iff_irreducible_map_fraction_map [IsIntegrallyClosed R] {p : R[X]}
@@ -196,7 +207,9 @@ theorem Monic.irreducible_iff_irreducible_map_fraction_map [IsIntegrallyClosed R
         (is_unit_iff_exists_inv.mpr
           (Exists.intro (C b.leading_coeff) <| by rwa [← C_mul, this, C_1]))
 #align polynomial.monic.irreducible_iff_irreducible_map_fraction_map Polynomial.Monic.irreducible_iff_irreducible_map_fraction_map
+-/
 
+#print Polynomial.isIntegrallyClosed_iff' /-
 /-- Integrally closed domains are precisely the domains for in which Gauss's lemma holds
     for monic polynomials -/
 theorem isIntegrallyClosed_iff' :
@@ -214,23 +227,28 @@ theorem isIntegrallyClosed_iff' :
       degree_eq_one_of_irreducible_of_root ((H _ <| minpoly.monic hx).mp (minpoly.irreducible hx))
     rw [is_root, eval_map, ← aeval_def, minpoly.aeval R x]
 #align polynomial.is_integrally_closed_iff' Polynomial.isIntegrallyClosed_iff'
+-/
 
+#print Polynomial.Monic.dvd_of_fraction_map_dvd_fraction_map /-
 theorem Monic.dvd_of_fraction_map_dvd_fraction_map [IsIntegrallyClosed R] {p q : R[X]}
     (hp : p.Monic) (hq : q.Monic) (h : q.map (algebraMap R K) ∣ p.map (algebraMap R K)) : q ∣ p :=
   by
   obtain ⟨r, hr⟩ := h
-  obtain ⟨d', hr'⟩ := IsIntegrallyClosed.eq_map_mul_c_of_dvd K hp (dvd_of_mul_left_eq _ hr.symm)
+  obtain ⟨d', hr'⟩ := IsIntegrallyClosed.eq_map_mul_C_of_dvd K hp (dvd_of_mul_left_eq _ hr.symm)
   rw [monic.leading_coeff, C_1, mul_one] at hr' 
   rw [← hr', ← Polynomial.map_mul] at hr 
   exact dvd_of_mul_right_eq _ (Polynomial.map_injective _ (IsFractionRing.injective R K) hr.symm)
   · exact monic.of_mul_monic_left (hq.map (algebraMap R K)) (by simpa [← hr] using hp.map _)
 #align polynomial.monic.dvd_of_fraction_map_dvd_fraction_map Polynomial.Monic.dvd_of_fraction_map_dvd_fraction_map
+-/
 
+#print Polynomial.Monic.dvd_iff_fraction_map_dvd_fraction_map /-
 theorem Monic.dvd_iff_fraction_map_dvd_fraction_map [IsIntegrallyClosed R] {p q : R[X]}
     (hp : p.Monic) (hq : q.Monic) : q.map (algebraMap R K) ∣ p.map (algebraMap R K) ↔ q ∣ p :=
   ⟨fun h => hp.dvd_of_fraction_map_dvd_fraction_map hq h, fun ⟨a, b⟩ =>
     ⟨a.map (algebraMap R K), b.symm ▸ Polynomial.map_mul (algebraMap R K)⟩⟩
 #align polynomial.monic.dvd_iff_fraction_map_dvd_fraction_map Polynomial.Monic.dvd_iff_fraction_map_dvd_fraction_map
+-/
 
 end IsIntegrallyClosed
 
@@ -240,6 +258,7 @@ section NormalizedGCDMonoid
 
 variable [NormalizedGCDMonoid R]
 
+#print Polynomial.isUnit_or_eq_zero_of_isUnit_integerNormalization_primPart /-
 theorem isUnit_or_eq_zero_of_isUnit_integerNormalization_primPart {p : K[X]} (h0 : p ≠ 0)
     (h : IsUnit (integerNormalization R⁰ p).primPart) : IsUnit p :=
   by
@@ -258,7 +277,9 @@ theorem isUnit_or_eq_zero_of_isUnit_integerNormalization_primPart {p : K[X]} (h0
   · apply h0 Con
   · apply Units.ne_zero _ Con
 #align polynomial.is_unit_or_eq_zero_of_is_unit_integer_normalization_prim_part Polynomial.isUnit_or_eq_zero_of_isUnit_integerNormalization_primPart
+-/
 
+#print Polynomial.IsPrimitive.irreducible_iff_irreducible_map_fraction_map /-
 /-- **Gauss's Lemma** for GCD domains states that a primitive polynomial is irreducible iff it is
   irreducible in the fraction field. -/
 theorem IsPrimitive.irreducible_iff_irreducible_map_fraction_map {p : R[X]} (hp : p.IsPrimitive) :
@@ -304,7 +325,9 @@ theorem IsPrimitive.irreducible_iff_irreducible_map_fraction_map {p : R[X]} (hp
   · left
     apply is_unit_or_eq_zero_of_is_unit_integer_normalization_prim_part h0.1 h
 #align polynomial.is_primitive.irreducible_iff_irreducible_map_fraction_map Polynomial.IsPrimitive.irreducible_iff_irreducible_map_fraction_map
+-/
 
+#print Polynomial.IsPrimitive.dvd_of_fraction_map_dvd_fraction_map /-
 theorem IsPrimitive.dvd_of_fraction_map_dvd_fraction_map {p q : R[X]} (hp : p.IsPrimitive)
     (hq : q.IsPrimitive) (h_dvd : p.map (algebraMap R K) ∣ q.map (algebraMap R K)) : p ∣ q :=
   by
@@ -328,30 +351,37 @@ theorem IsPrimitive.dvd_of_fraction_map_dvd_fraction_map {p q : R[X]} (hp : p.Is
     contrapose! s0
     simp [s0, mem_nonZeroDivisors_iff_ne_zero]
 #align polynomial.is_primitive.dvd_of_fraction_map_dvd_fraction_map Polynomial.IsPrimitive.dvd_of_fraction_map_dvd_fraction_map
+-/
 
 variable (K)
 
+#print Polynomial.IsPrimitive.dvd_iff_fraction_map_dvd_fraction_map /-
 theorem IsPrimitive.dvd_iff_fraction_map_dvd_fraction_map {p q : R[X]} (hp : p.IsPrimitive)
     (hq : q.IsPrimitive) : p ∣ q ↔ p.map (algebraMap R K) ∣ q.map (algebraMap R K) :=
   ⟨fun ⟨a, b⟩ => ⟨a.map (algebraMap R K), b.symm ▸ Polynomial.map_mul (algebraMap R K)⟩, fun h =>
     hp.dvd_of_fraction_map_dvd_fraction_map hq h⟩
 #align polynomial.is_primitive.dvd_iff_fraction_map_dvd_fraction_map Polynomial.IsPrimitive.dvd_iff_fraction_map_dvd_fraction_map
+-/
 
 end NormalizedGCDMonoid
 
 end FractionMap
 
+#print Polynomial.IsPrimitive.Int.irreducible_iff_irreducible_map_cast /-
 /-- **Gauss's Lemma** for `ℤ` states that a primitive integer polynomial is irreducible iff it is
   irreducible over `ℚ`. -/
 theorem IsPrimitive.Int.irreducible_iff_irreducible_map_cast {p : ℤ[X]} (hp : p.IsPrimitive) :
     Irreducible p ↔ Irreducible (p.map (Int.castRingHom ℚ)) :=
   hp.irreducible_iff_irreducible_map_fraction_map
 #align polynomial.is_primitive.int.irreducible_iff_irreducible_map_cast Polynomial.IsPrimitive.Int.irreducible_iff_irreducible_map_cast
+-/
 
+#print Polynomial.IsPrimitive.Int.dvd_iff_map_cast_dvd_map_cast /-
 theorem IsPrimitive.Int.dvd_iff_map_cast_dvd_map_cast (p q : ℤ[X]) (hp : p.IsPrimitive)
     (hq : q.IsPrimitive) : p ∣ q ↔ p.map (Int.castRingHom ℚ) ∣ q.map (Int.castRingHom ℚ) :=
   hp.dvd_iff_fraction_map_dvd_fraction_map ℚ hq
 #align polynomial.is_primitive.int.dvd_iff_map_cast_dvd_map_cast Polynomial.IsPrimitive.Int.dvd_iff_map_cast_dvd_map_cast
+-/
 
 end Polynomial
 
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Aaron Anderson
 
 ! This file was ported from Lean 3 source module ring_theory.polynomial.gauss_lemma
-! leanprover-community/mathlib commit e3f4be1fcb5376c4948d7f095bec45350bfb9d1a
+! leanprover-community/mathlib commit 2a0ce625dbb0ffbc7d1316597de0b25c1ec75303
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -16,6 +16,9 @@ import Mathbin.RingTheory.IntegrallyClosed
 /-!
 # Gauss's Lemma
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 Gauss's Lemma is one of a few results pertaining to irreducibility of primitive polynomials.
 
 ## Main Results
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Aaron Anderson
 
 ! This file was ported from Lean 3 source module ring_theory.polynomial.gauss_lemma
-! leanprover-community/mathlib commit df76f43357840485b9d04ed5dee5ab115d420e87
+! leanprover-community/mathlib commit e3f4be1fcb5376c4948d7f095bec45350bfb9d1a
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -58,7 +58,6 @@ theorem integralClosure.mem_lifts_of_monic_of_dvd_map {f : R[X]} (hf : f.Monic)
     (hg : g.Monic) (hd : g ∣ f.map (algebraMap R K)) :
     g ∈ lifts (algebraMap (integralClosure R K) K) :=
   by
-  haveI : IsScalarTower R K g.splitting_field := splitting_field_aux.is_scalar_tower _ _ _
   have :=
     mem_lift_of_splits_of_roots_mem_range (integralClosure R g.splitting_field)
       ((splits_id_iff_splits _).2 <| splitting_field.splits g) (hg.map _) fun a ha =>
@@ -75,7 +74,7 @@ theorem integralClosure.mem_lifts_of_monic_of_dvd_map {f : R[X]} (hf : f.Monic)
   refine' Multiset.mem_of_le (roots.le_of_dvd ((hf.map _).map _).NeZero _) ha
   · infer_instance
   · exact map_dvd (algebraMap K g.splitting_field) hd
-  · apply splitting_field_aux.is_scalar_tower
+  · infer_instance
 #align integral_closure.mem_lifts_of_monic_of_dvd_map integralClosure.mem_lifts_of_monic_of_dvd_map
 
 variable [IsDomain R] [IsFractionRing R K]
Diff
@@ -122,8 +122,6 @@ variable {S : Type _} [CommRing S] [IsDomain S]
 
 variable {φ : R →+* S} (hinj : Function.Injective φ) {f : R[X]} (hf : f.IsPrimitive)
 
-include hinj hf
-
 theorem IsPrimitive.isUnit_iff_isUnit_map_of_injective : IsUnit f ↔ IsUnit (map φ f) :=
   by
   refine' ⟨(map_ring_hom φ).isUnit_map, fun h => _⟩
Diff
@@ -4,11 +4,11 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Aaron Anderson
 
 ! This file was ported from Lean 3 source module ring_theory.polynomial.gauss_lemma
-! leanprover-community/mathlib commit d35b4ff446f1421bd551fafa4b8efd98ac3ac408
+! leanprover-community/mathlib commit df76f43357840485b9d04ed5dee5ab115d420e87
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
-import Mathbin.FieldTheory.SplittingField
+import Mathbin.FieldTheory.SplittingField.Construction
 import Mathbin.RingTheory.Int.Basic
 import Mathbin.RingTheory.Localization.Integral
 import Mathbin.RingTheory.IntegrallyClosed
Diff
@@ -292,10 +292,10 @@ theorem IsPrimitive.irreducible_iff_irreducible_map_fraction_map {p : R[X]} (hp
     mul_assoc (C ↑u)] at h1 
   have h0 : a ≠ 0 ∧ b ≠ 0 := by
     classical
-      rw [Ne.def, Ne.def, ← Decidable.not_or_iff_and_not, ← mul_eq_zero, ← hab]
-      intro con
-      apply hp.ne_zero (map_injective (algebraMap R K) (IsFractionRing.injective _ _) _)
-      simp [Con]
+    rw [Ne.def, Ne.def, ← Decidable.not_or_iff_and_not, ← mul_eq_zero, ← hab]
+    intro con
+    apply hp.ne_zero (map_injective (algebraMap R K) (IsFractionRing.injective _ _) _)
+    simp [Con]
   rcases hi.is_unit_or_is_unit (mul_left_cancel₀ hcd0 h1).symm with (h | h)
   · right
     apply
Diff
@@ -4,10 +4,11 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Aaron Anderson
 
 ! This file was ported from Lean 3 source module ring_theory.polynomial.gauss_lemma
-! leanprover-community/mathlib commit f0c8bf9245297a541f468be517f1bde6195105e9
+! leanprover-community/mathlib commit d35b4ff446f1421bd551fafa4b8efd98ac3ac408
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
+import Mathbin.FieldTheory.SplittingField
 import Mathbin.RingTheory.Int.Basic
 import Mathbin.RingTheory.Localization.Integral
 import Mathbin.RingTheory.IntegrallyClosed
@@ -18,6 +19,9 @@ import Mathbin.RingTheory.IntegrallyClosed
 Gauss's Lemma is one of a few results pertaining to irreducibility of primitive polynomials.
 
 ## Main Results
+ - `is_integrally_closed.eq_map_mul_C_of_dvd`: if `R` is integrally closed, `K = Frac(R)` and
+  `g : K[X]` divides a monic polynomial with coefficients in `R`, then `g * (C g.leading_coeff⁻¹)`
+  has coefficients in `R`
  - `polynomial.monic.irreducible_iff_irreducible_map_fraction_map`:
   A monic polynomial over an integrally closed domain is irreducible iff it is irreducible in a
     fraction field
@@ -40,6 +44,76 @@ open scoped nonZeroDivisors Polynomial
 
 variable {R : Type _} [CommRing R]
 
+section IsIntegrallyClosed
+
+open Polynomial
+
+open integralClosure
+
+open IsIntegrallyClosed
+
+variable (K : Type _) [Field K] [Algebra R K]
+
+theorem integralClosure.mem_lifts_of_monic_of_dvd_map {f : R[X]} (hf : f.Monic) {g : K[X]}
+    (hg : g.Monic) (hd : g ∣ f.map (algebraMap R K)) :
+    g ∈ lifts (algebraMap (integralClosure R K) K) :=
+  by
+  haveI : IsScalarTower R K g.splitting_field := splitting_field_aux.is_scalar_tower _ _ _
+  have :=
+    mem_lift_of_splits_of_roots_mem_range (integralClosure R g.splitting_field)
+      ((splits_id_iff_splits _).2 <| splitting_field.splits g) (hg.map _) fun a ha =>
+      (set_like.ext_iff.mp (integralClosure R g.splitting_field).range_algebraMap _).mpr <|
+        roots_mem_integralClosure hf _
+  · rw [lifts_iff_coeff_lifts, ← RingHom.coe_range, Subalgebra.range_algebraMap] at this 
+    refine' (lifts_iff_coeff_lifts _).2 fun n => _
+    rw [← RingHom.coe_range, Subalgebra.range_algebraMap]
+    obtain ⟨p, hp, he⟩ := set_like.mem_coe.mp (this n); use p, hp
+    rw [IsScalarTower.algebraMap_eq R K, coeff_map, ← eval₂_map, eval₂_at_apply] at he 
+    rw [eval₂_eq_eval_map]; apply (injective_iff_map_eq_zero _).1 _ _ he
+    · apply RingHom.injective
+  rw [IsScalarTower.algebraMap_eq R K _, ← map_map]
+  refine' Multiset.mem_of_le (roots.le_of_dvd ((hf.map _).map _).NeZero _) ha
+  · infer_instance
+  · exact map_dvd (algebraMap K g.splitting_field) hd
+  · apply splitting_field_aux.is_scalar_tower
+#align integral_closure.mem_lifts_of_monic_of_dvd_map integralClosure.mem_lifts_of_monic_of_dvd_map
+
+variable [IsDomain R] [IsFractionRing R K]
+
+/-- If `K = Frac(R)` and `g : K[X]` divides a monic polynomial with coefficients in `R`, then
+    `g * (C g.leading_coeff⁻¹)` has coefficients in `R` -/
+theorem IsIntegrallyClosed.eq_map_mul_c_of_dvd [IsIntegrallyClosed R] {f : R[X]} (hf : f.Monic)
+    {g : K[X]} (hg : g ∣ f.map (algebraMap R K)) :
+    ∃ g' : R[X], g'.map (algebraMap R K) * (C <| leadingCoeff g) = g :=
+  by
+  have g_ne_0 : g ≠ 0 := ne_zero_of_dvd_ne_zero (monic.ne_zero <| hf.map (algebraMap R K)) hg
+  suffices lem : ∃ g' : R[X], g'.map (algebraMap R K) = g * C g.leading_coeff⁻¹
+  · obtain ⟨g', hg'⟩ := lem
+    use g'
+    rw [hg', mul_assoc, ← C_mul, inv_mul_cancel (leading_coeff_ne_zero.mpr g_ne_0), C_1, mul_one]
+  have g_mul_dvd : g * C g.leading_coeff⁻¹ ∣ f.map (algebraMap R K) :=
+    by
+    rwa [Associated.dvd_iff_dvd_left (show Associated (g * C g.leading_coeff⁻¹) g from _)]
+    rw [associated_mul_isUnit_left_iff]
+    exact is_unit_C.mpr (inv_ne_zero <| leading_coeff_ne_zero.mpr g_ne_0).IsUnit
+  let algeq :=
+    (Subalgebra.equivOfEq _ _ <| integral_closure_eq_bot R _).trans
+      (Algebra.botEquivOfInjective <| IsFractionRing.injective R <| K)
+  have :
+    (algebraMap R _).comp algeq.to_alg_hom.to_ring_hom = (integralClosure R _).toSubring.Subtype :=
+    by ext; conv_rhs => rw [← algeq.symm_apply_apply x]; rfl
+  have H :=
+    (mem_lifts _).1
+      (integralClosure.mem_lifts_of_monic_of_dvd_map K hf (monic_mul_leading_coeff_inv g_ne_0)
+        g_mul_dvd)
+  refine' ⟨map algeq.to_alg_hom.to_ring_hom _, _⟩
+  use Classical.choose H
+  rw [map_map, this]
+  exact Classical.choose_spec H
+#align is_integrally_closed.eq_map_mul_C_of_dvd IsIntegrallyClosed.eq_map_mul_c_of_dvd
+
+end IsIntegrallyClosed
+
 namespace Polynomial
 
 section
Diff
@@ -55,8 +55,8 @@ theorem IsPrimitive.isUnit_iff_isUnit_map_of_injective : IsUnit f ↔ IsUnit (ma
   refine' ⟨(map_ring_hom φ).isUnit_map, fun h => _⟩
   rcases is_unit_iff.1 h with ⟨_, ⟨u, rfl⟩, hu⟩
   have hdeg := degree_C u.ne_zero
-  rw [hu, degree_map_eq_of_injective hinj] at hdeg
-  rw [eq_C_of_degree_eq_zero hdeg] at hf⊢
+  rw [hu, degree_map_eq_of_injective hinj] at hdeg 
+  rw [eq_C_of_degree_eq_zero hdeg] at hf ⊢
   exact is_unit_C.mpr (is_primitive_iff_is_unit_of_C_dvd.mp hf (f.coeff 0) dvd_rfl)
 #align polynomial.is_primitive.is_unit_iff_is_unit_map_of_injective Polynomial.IsPrimitive.isUnit_iff_isUnit_map_of_injective
 
@@ -67,7 +67,7 @@ theorem IsPrimitive.irreducible_of_irreducible_map_of_injective (h_irr : Irreduc
     ⟨fun h => h_irr.not_unit (IsUnit.map (map_ring_hom φ) h), fun a b h =>
       (h_irr.is_unit_or_is_unit <| by rw [h, Polynomial.map_mul]).imp _ _⟩
   all_goals apply ((is_primitive_of_dvd hf _).isUnit_iff_isUnit_map_of_injective hinj).mpr
-  exacts[Dvd.intro _ h.symm, Dvd.intro_left _ h.symm]
+  exacts [Dvd.intro _ h.symm, Dvd.intro_left _ h.symm]
 #align polynomial.is_primitive.irreducible_of_irreducible_map_of_injective Polynomial.IsPrimitive.irreducible_of_irreducible_map_of_injective
 
 end
@@ -107,7 +107,7 @@ theorem Monic.irreducible_iff_irreducible_map_fraction_map [IsIntegrallyClosed R
   have : a.leading_coeff * b.leading_coeff = 1 := by
     rw [← leading_coeff_mul, ← H, monic.leading_coeff (h.map <| algebraMap R K)]
   rw [← ha, ← hb, mul_comm _ (C b.leading_coeff), mul_assoc, ← mul_assoc (C a.leading_coeff), ←
-    C_mul, this, C_1, one_mul, ← Polynomial.map_mul] at H
+    C_mul, this, C_1, one_mul, ← Polynomial.map_mul] at H 
   rw [← hb, ← Polynomial.coe_mapRingHom]
   refine'
     IsUnit.mul (IsUnit.map _ (Or.resolve_left (hp.is_unit_or_is_unit _) (show ¬IsUnit a' from _)))
@@ -146,8 +146,8 @@ theorem Monic.dvd_of_fraction_map_dvd_fraction_map [IsIntegrallyClosed R] {p q :
   by
   obtain ⟨r, hr⟩ := h
   obtain ⟨d', hr'⟩ := IsIntegrallyClosed.eq_map_mul_c_of_dvd K hp (dvd_of_mul_left_eq _ hr.symm)
-  rw [monic.leading_coeff, C_1, mul_one] at hr'
-  rw [← hr', ← Polynomial.map_mul] at hr
+  rw [monic.leading_coeff, C_1, mul_one] at hr' 
+  rw [← hr', ← Polynomial.map_mul] at hr 
   exact dvd_of_mul_right_eq _ (Polynomial.map_injective _ (IsFractionRing.injective R K) hr.symm)
   · exact monic.of_mul_monic_left (hq.map (algebraMap R K)) (by simpa [← hr] using hp.map _)
 #align polynomial.monic.dvd_of_fraction_map_dvd_fraction_map Polynomial.Monic.dvd_of_fraction_map_dvd_fraction_map
@@ -171,7 +171,7 @@ theorem isUnit_or_eq_zero_of_isUnit_integerNormalization_primPart {p : K[X]} (h0
   by
   rcases is_unit_iff.1 h with ⟨_, ⟨u, rfl⟩, hu⟩
   obtain ⟨⟨c, c0⟩, hc⟩ := integer_normalization_map_to_map R⁰ p
-  rw [Subtype.coe_mk, Algebra.smul_def, algebraMap_apply] at hc
+  rw [Subtype.coe_mk, Algebra.smul_def, algebraMap_apply] at hc 
   apply isUnit_of_mul_isUnit_right
   rw [← hc, (integer_normalization R⁰ p).eq_C_content_mul_primPart, ← hu, ← RingHom.map_mul,
     is_unit_iff]
@@ -179,7 +179,7 @@ theorem isUnit_or_eq_zero_of_isUnit_integerNormalization_primPart {p : K[X]} (h0
     ⟨algebraMap R K ((integer_normalization R⁰ p).content * ↑u), isUnit_iff_ne_zero.2 fun con => _,
       by simp⟩
   replace con := (injective_iff_map_eq_zero (algebraMap R K)).1 (IsFractionRing.injective _ _) _ Con
-  rw [mul_eq_zero, content_eq_zero_iff, IsFractionRing.integerNormalization_eq_zero_iff] at con
+  rw [mul_eq_zero, content_eq_zero_iff, IsFractionRing.integerNormalization_eq_zero_iff] at con 
   rcases Con with (con | con)
   · apply h0 Con
   · apply Units.ne_zero _ Con
@@ -195,10 +195,10 @@ theorem IsPrimitive.irreducible_iff_irreducible_map_fraction_map {p : R[X]} (hp
       hp.irreducible_of_irreducible_map_of_injective (IsFractionRing.injective _ _)⟩
   obtain ⟨⟨c, c0⟩, hc⟩ := integer_normalization_map_to_map R⁰ a
   obtain ⟨⟨d, d0⟩, hd⟩ := integer_normalization_map_to_map R⁰ b
-  rw [Algebra.smul_def, algebraMap_apply, Subtype.coe_mk] at hc hd
-  rw [mem_nonZeroDivisors_iff_ne_zero] at c0 d0
+  rw [Algebra.smul_def, algebraMap_apply, Subtype.coe_mk] at hc hd 
+  rw [mem_nonZeroDivisors_iff_ne_zero] at c0 d0 
   have hcd0 : c * d ≠ 0 := mul_ne_zero c0 d0
-  rw [Ne.def, ← C_eq_zero] at hcd0
+  rw [Ne.def, ← C_eq_zero] at hcd0 
   have h1 : C c * C d * p = integer_normalization R⁰ a * integer_normalization R⁰ b :=
     by
     apply map_injective (algebraMap R K) (IsFractionRing.injective _ _) _
@@ -215,7 +215,7 @@ theorem IsPrimitive.irreducible_iff_irreducible_map_fraction_map {p : R[X]} (hp
   rw [← RingHom.map_mul, eq_comm, (integer_normalization R⁰ a).eq_C_content_mul_primPart,
     (integer_normalization R⁰ b).eq_C_content_mul_primPart, mul_assoc, mul_comm _ (C _ * _), ←
     mul_assoc, ← mul_assoc, ← RingHom.map_mul, ← hu, RingHom.map_mul, mul_assoc, mul_assoc, ←
-    mul_assoc (C ↑u)] at h1
+    mul_assoc (C ↑u)] at h1 
   have h0 : a ≠ 0 ∧ b ≠ 0 := by
     classical
       rw [Ne.def, Ne.def, ← Decidable.not_or_iff_and_not, ← mul_eq_zero, ← hab]
@@ -236,13 +236,13 @@ theorem IsPrimitive.dvd_of_fraction_map_dvd_fraction_map {p q : R[X]} (hp : p.Is
   by
   rcases h_dvd with ⟨r, hr⟩
   obtain ⟨⟨s, s0⟩, hs⟩ := integer_normalization_map_to_map R⁰ r
-  rw [Subtype.coe_mk, Algebra.smul_def, algebraMap_apply] at hs
+  rw [Subtype.coe_mk, Algebra.smul_def, algebraMap_apply] at hs 
   have h : p ∣ q * C s := by
     use integer_normalization R⁰ r
     apply map_injective (algebraMap R K) (IsFractionRing.injective _ _)
     rw [Polynomial.map_mul, Polynomial.map_mul, hs, hr, mul_assoc, mul_comm r]
     simp
-  rw [← hp.dvd_prim_part_iff_dvd, prim_part_mul, hq.prim_part_eq, Associated.dvd_iff_dvd_right] at h
+  rw [← hp.dvd_prim_part_iff_dvd, prim_part_mul, hq.prim_part_eq, Associated.dvd_iff_dvd_right] at h 
   · exact h
   · symm
     rcases is_unit_prim_part_C s with ⟨u, hu⟩
Diff
@@ -36,7 +36,7 @@ Gauss's Lemma is one of a few results pertaining to irreducibility of primitive
 -/
 
 
-open nonZeroDivisors Polynomial
+open scoped nonZeroDivisors Polynomial
 
 variable {R : Type _} [CommRing R]
 
Diff
@@ -130,9 +130,7 @@ theorem isIntegrallyClosed_iff' :
       ∀ p : R[X], p.Monic → (Irreducible p ↔ Irreducible (p.map <| algebraMap R K)) :=
   by
   constructor
-  · intro hR p hp
-    letI := hR
-    exact monic.irreducible_iff_irreducible_map_fraction_map hp
+  · intro hR p hp; letI := hR; exact monic.irreducible_iff_irreducible_map_fraction_map hp
   · intro H
     refine'
       (isIntegrallyClosed_iff K).mpr fun x hx =>
Diff
@@ -173,7 +173,7 @@ theorem isUnit_or_eq_zero_of_isUnit_integerNormalization_primPart {p : K[X]} (h0
   by
   rcases is_unit_iff.1 h with ⟨_, ⟨u, rfl⟩, hu⟩
   obtain ⟨⟨c, c0⟩, hc⟩ := integer_normalization_map_to_map R⁰ p
-  rw [Subtype.coe_mk, Algebra.smul_def, algebra_map_apply] at hc
+  rw [Subtype.coe_mk, Algebra.smul_def, algebraMap_apply] at hc
   apply isUnit_of_mul_isUnit_right
   rw [← hc, (integer_normalization R⁰ p).eq_C_content_mul_primPart, ← hu, ← RingHom.map_mul,
     is_unit_iff]
@@ -197,7 +197,7 @@ theorem IsPrimitive.irreducible_iff_irreducible_map_fraction_map {p : R[X]} (hp
       hp.irreducible_of_irreducible_map_of_injective (IsFractionRing.injective _ _)⟩
   obtain ⟨⟨c, c0⟩, hc⟩ := integer_normalization_map_to_map R⁰ a
   obtain ⟨⟨d, d0⟩, hd⟩ := integer_normalization_map_to_map R⁰ b
-  rw [Algebra.smul_def, algebra_map_apply, Subtype.coe_mk] at hc hd
+  rw [Algebra.smul_def, algebraMap_apply, Subtype.coe_mk] at hc hd
   rw [mem_nonZeroDivisors_iff_ne_zero] at c0 d0
   have hcd0 : c * d ≠ 0 := mul_ne_zero c0 d0
   rw [Ne.def, ← C_eq_zero] at hcd0
@@ -238,7 +238,7 @@ theorem IsPrimitive.dvd_of_fraction_map_dvd_fraction_map {p q : R[X]} (hp : p.Is
   by
   rcases h_dvd with ⟨r, hr⟩
   obtain ⟨⟨s, s0⟩, hs⟩ := integer_normalization_map_to_map R⁰ r
-  rw [Subtype.coe_mk, Algebra.smul_def, algebra_map_apply] at hs
+  rw [Subtype.coe_mk, Algebra.smul_def, algebraMap_apply] at hs
   have h : p ∣ q * C s := by
     use integer_normalization R⁰ r
     apply map_injective (algebraMap R K) (IsFractionRing.injective _ _)
Diff
@@ -4,12 +4,11 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Aaron Anderson
 
 ! This file was ported from Lean 3 source module ring_theory.polynomial.gauss_lemma
-! leanprover-community/mathlib commit cbdf7b565832144d024caa5a550117c6df0204a5
+! leanprover-community/mathlib commit f0c8bf9245297a541f468be517f1bde6195105e9
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
 import Mathbin.RingTheory.Int.Basic
-import Mathbin.FieldTheory.SplittingField
 import Mathbin.RingTheory.Localization.Integral
 import Mathbin.RingTheory.IntegrallyClosed
 
Diff
@@ -176,7 +176,7 @@ theorem isUnit_or_eq_zero_of_isUnit_integerNormalization_primPart {p : K[X]} (h0
   obtain ⟨⟨c, c0⟩, hc⟩ := integer_normalization_map_to_map R⁰ p
   rw [Subtype.coe_mk, Algebra.smul_def, algebra_map_apply] at hc
   apply isUnit_of_mul_isUnit_right
-  rw [← hc, (integer_normalization R⁰ p).eq_c_content_mul_primPart, ← hu, ← RingHom.map_mul,
+  rw [← hc, (integer_normalization R⁰ p).eq_C_content_mul_primPart, ← hu, ← RingHom.map_mul,
     is_unit_iff]
   refine'
     ⟨algebraMap R K ((integer_normalization R⁰ p).content * ↑u), isUnit_iff_ne_zero.2 fun con => _,
@@ -215,8 +215,8 @@ theorem IsPrimitive.irreducible_iff_irreducible_map_fraction_map {p : R[X]} (hp
       normalize.map_mul, normalize_content, normalize_content, ←
       mul_one (normalize c * normalize d), ← hp.content_eq_one, ← content_C, ← content_C, ←
       content_mul, ← content_mul, ← content_mul, h1]
-  rw [← RingHom.map_mul, eq_comm, (integer_normalization R⁰ a).eq_c_content_mul_primPart,
-    (integer_normalization R⁰ b).eq_c_content_mul_primPart, mul_assoc, mul_comm _ (C _ * _), ←
+  rw [← RingHom.map_mul, eq_comm, (integer_normalization R⁰ a).eq_C_content_mul_primPart,
+    (integer_normalization R⁰ b).eq_C_content_mul_primPart, mul_assoc, mul_comm _ (C _ * _), ←
     mul_assoc, ← mul_assoc, ← RingHom.map_mul, ← hu, RingHom.map_mul, mul_assoc, mul_assoc, ←
     mul_assoc (C ↑u)] at h1
   have h0 : a ≠ 0 ∧ b ≠ 0 := by

Changes in mathlib4

mathlib3
mathlib4
chore: avoid Ne.def (adaptation for nightly-2024-03-27) (#11813)
Diff
@@ -257,7 +257,7 @@ theorem IsPrimitive.irreducible_iff_irreducible_map_fraction_map {p : R[X]} (hp
   rw [Algebra.smul_def, algebraMap_apply, Subtype.coe_mk] at hc hd
   rw [mem_nonZeroDivisors_iff_ne_zero] at c0 d0
   have hcd0 : c * d ≠ 0 := mul_ne_zero c0 d0
-  rw [Ne.def, ← C_eq_zero] at hcd0
+  rw [Ne, ← C_eq_zero] at hcd0
   have h1 : C c * C d * p = integerNormalization R⁰ a * integerNormalization R⁰ b := by
     apply map_injective (algebraMap R K) (IsFractionRing.injective _ _) _
     rw [Polynomial.map_mul, Polynomial.map_mul, Polynomial.map_mul, hc, hd, map_C, map_C, hab]
@@ -275,7 +275,7 @@ theorem IsPrimitive.irreducible_iff_irreducible_map_fraction_map {p : R[X]} (hp
     mul_assoc (C (u : R))] at h1
   have h0 : a ≠ 0 ∧ b ≠ 0 := by
     classical
-    rw [Ne.def, Ne.def, ← not_or, ← mul_eq_zero, ← hab]
+    rw [Ne, Ne, ← not_or, ← mul_eq_zero, ← hab]
     intro con
     apply hp.ne_zero (map_injective (algebraMap R K) (IsFractionRing.injective _ _) _)
     simp [con]
@@ -306,7 +306,7 @@ theorem IsPrimitive.dvd_of_fraction_map_dvd_fraction_map {p q : R[X]} (hp : p.Is
     rw [hu]
   iterate 2
     apply mul_ne_zero hq.ne_zero
-    rw [Ne.def, C_eq_zero]
+    rw [Ne, C_eq_zero]
     contrapose! s0
     simp [s0, mem_nonZeroDivisors_iff_ne_zero]
 #align polynomial.is_primitive.dvd_of_fraction_map_dvd_fraction_map Polynomial.IsPrimitive.dvd_of_fraction_map_dvd_fraction_map
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
@@ -110,7 +110,6 @@ namespace Polynomial
 section
 
 variable {S : Type*} [CommRing S] [IsDomain S]
-
 variable {φ : R →+* S} (hinj : Function.Injective φ) {f : R[X]} (hf : f.IsPrimitive)
 
 theorem IsPrimitive.isUnit_iff_isUnit_map_of_injective : IsUnit f ↔ IsUnit (map φ f) := by
chore: remove stream-of-consciousness uses of have, replace and suffices (#10640)

No changes to tactic file, it's just boring fixes throughout the library.

This follows on from #6964.

Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -78,8 +78,8 @@ theorem IsIntegrallyClosed.eq_map_mul_C_of_dvd [IsIntegrallyClosed R] {f : R[X]}
     {g : K[X]} (hg : g ∣ f.map (algebraMap R K)) :
     ∃ g' : R[X], g'.map (algebraMap R K) * (C <| leadingCoeff g) = g := by
   have g_ne_0 : g ≠ 0 := ne_zero_of_dvd_ne_zero (Monic.ne_zero <| hf.map (algebraMap R K)) hg
-  suffices lem : ∃ g' : R[X], g'.map (algebraMap R K) = g * C g.leadingCoeff⁻¹
-  · obtain ⟨g', hg'⟩ := lem
+  suffices lem : ∃ g' : R[X], g'.map (algebraMap R K) = g * C g.leadingCoeff⁻¹ by
+    obtain ⟨g', hg'⟩ := lem
     use g'
     rw [hg', mul_assoc, ← C_mul, inv_mul_cancel (leadingCoeff_ne_zero.mpr g_ne_0), C_1, mul_one]
   have g_mul_dvd : g * C g.leadingCoeff⁻¹ ∣ f.map (algebraMap R K) := by
chore(*): replace $ with <| (#9319)

See Zulip thread for the discussion.

Diff
@@ -153,7 +153,7 @@ open IsIntegrallyClosed
 theorem Monic.irreducible_iff_irreducible_map_fraction_map [IsIntegrallyClosed R] {p : R[X]}
     (h : p.Monic) : Irreducible p ↔ Irreducible (p.map <| algebraMap R K) := by
   /- The ← direction follows from `IsPrimitive.irreducible_of_irreducible_map_of_injective`.
-       For the → direction, it is enought to show that if `(p.map $ algebraMap R K) = a * b` and
+       For the → direction, it is enought to show that if `(p.map <| algebraMap R K) = a * b` and
        `a` is not a unit then `b` is a unit -/
   refine'
     ⟨fun hp =>
feat: roots in an algebra (#6740)

Co-authored-by: Ruben Van de Velde <65514131+Ruben-VandeVelde@users.noreply.github.com>

Diff
@@ -65,7 +65,7 @@ theorem integralClosure.mem_lifts_of_monic_of_dvd_map {f : R[X]} (hf : f.Monic)
     rw [IsScalarTower.algebraMap_eq R K, coeff_map, ← eval₂_map, eval₂_at_apply] at he
     rw [eval₂_eq_eval_map]; apply (injective_iff_map_eq_zero _).1 _ _ he
     · apply RingHom.injective
-  rw [IsScalarTower.algebraMap_eq R K _, ← map_map]
+  rw [aroots_def, IsScalarTower.algebraMap_eq R K _, ← map_map]
   refine' Multiset.mem_of_le (roots.le_of_dvd ((hf.map _).map _).ne_zero _) ha
   exact map_dvd (algebraMap K g.SplittingField) hd
 #align integral_closure.mem_lifts_of_monic_of_dvd_map integralClosure.mem_lifts_of_monic_of_dvd_map
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
@@ -39,7 +39,7 @@ Gauss's Lemma is one of a few results pertaining to irreducibility of primitive
 
 open scoped nonZeroDivisors Polynomial
 
-variable {R : Type _} [CommRing R]
+variable {R : Type*} [CommRing R]
 
 section IsIntegrallyClosed
 
@@ -49,7 +49,7 @@ open integralClosure
 
 open IsIntegrallyClosed
 
-variable (K : Type _) [Field K] [Algebra R K]
+variable (K : Type*) [Field K] [Algebra R K]
 
 theorem integralClosure.mem_lifts_of_monic_of_dvd_map {f : R[X]} (hf : f.Monic) {g : K[X]}
     (hg : g.Monic) (hd : g ∣ f.map (algebraMap R K)) :
@@ -109,7 +109,7 @@ namespace Polynomial
 
 section
 
-variable {S : Type _} [CommRing S] [IsDomain S]
+variable {S : Type*} [CommRing S] [IsDomain S]
 
 variable {φ : R →+* S} (hinj : Function.Injective φ) {f : R[X]} (hf : f.IsPrimitive)
 
@@ -135,7 +135,7 @@ end
 
 section FractionMap
 
-variable {K : Type _} [Field K] [Algebra R K] [IsFractionRing R K]
+variable {K : Type*} [Field K] [Algebra R K] [IsFractionRing R K]
 
 theorem IsPrimitive.isUnit_iff_isUnit_map {p : R[X]} (hp : p.IsPrimitive) :
     IsUnit p ↔ IsUnit (p.map (algebraMap R K)) :=
fix: let use provide last constructor argument, introduce mathlib3-like flattening use! (#5350)

Changes:

  • use now by default discharges with try with_reducible use_discharger with a custom discharger tactic rather than try with_reducible rfl, which makes it be closer to exists and the use in mathlib3. It doesn't go so far as to do try with_reducible trivial since that involves the contradiction tactic.
  • this discharger is configurable with use (discharger := tacticSeq...)
  • the use evaluation loop will try refining after constructor failure, so it can be used to fill in all arguments rather than all but the last, like in mathlib3 (closes #5072) but with the caveat that it only works so long as the last argument is not an inductive type (like Eq).
  • adds use!, which is nearly the same as the mathlib3 use and fills in constructor arguments along the nodes and leaves of the nested constructor expressions. This version tries refining before applying constructors, so it can be used like exact for the last argument.

The difference between mathlib3 use and this use! is that (1) use! uses a different tactic to discharge goals (mathlib3 used trivial', which did reducible refl, but also contradiction, which we don't emulate) (2) it does not rewrite using exists_prop. Regarding 2, this feature seems to be less useful now that bounded existentials encode the bound using a conjunction rather than with nested existentials. We do have exists_prop as part of use_discharger however.

Co-authored-by: Floris van Doorn <fpvdoorn@gmail.com>

Diff
@@ -97,8 +97,7 @@ theorem IsIntegrallyClosed.eq_map_mul_C_of_dvd [IsIntegrallyClosed R] {f : R[X]}
       (integralClosure.mem_lifts_of_monic_of_dvd_map K hf (monic_mul_leadingCoeff_inv g_ne_0)
         g_mul_dvd)
   refine' ⟨map algeq.toAlgHom.toRingHom _, _⟩
-  · -- Porting note(https://github.com/leanprover-community/mathlib4/issues/5072): was `use`
-    exact Classical.choose H
+  · use! Classical.choose H
   · rw [map_map, this]
     exact Classical.choose_spec H
 set_option linter.uppercaseLean3 false in
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,17 +2,14 @@
 Copyright (c) 2020 Aaron Anderson. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Aaron Anderson
-
-! This file was ported from Lean 3 source module ring_theory.polynomial.gauss_lemma
-! leanprover-community/mathlib commit e3f4be1fcb5376c4948d7f095bec45350bfb9d1a
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.FieldTheory.SplittingField.Construction
 import Mathlib.RingTheory.Int.Basic
 import Mathlib.RingTheory.Localization.Integral
 import Mathlib.RingTheory.IntegrallyClosed
 
+#align_import ring_theory.polynomial.gauss_lemma from "leanprover-community/mathlib"@"e3f4be1fcb5376c4948d7f095bec45350bfb9d1a"
+
 /-!
 # Gauss's Lemma
 
chore: forward port leanprover-community/mathlib#19178 (#5112)

Which really only consists of a SHA update.

Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Aaron Anderson
 
 ! This file was ported from Lean 3 source module ring_theory.polynomial.gauss_lemma
-! leanprover-community/mathlib commit df76f43357840485b9d04ed5dee5ab115d420e87
+! leanprover-community/mathlib commit e3f4be1fcb5376c4948d7f095bec45350bfb9d1a
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -57,11 +57,8 @@ variable (K : Type _) [Field K] [Algebra R K]
 theorem integralClosure.mem_lifts_of_monic_of_dvd_map {f : R[X]} (hf : f.Monic) {g : K[X]}
     (hg : g.Monic) (hd : g ∣ f.map (algebraMap R K)) :
     g ∈ lifts (algebraMap (integralClosure R K) K) := by
-  -- Porting note: the next line was ` := polynomial.splitting_field_aux.is_scalar_tower`
-  haveI : IsScalarTower R K g.SplittingField := IsScalarTower.of_algebraMap_eq (congrFun rfl)
-  have :=
-    mem_lift_of_splits_of_roots_mem_range (integralClosure R g.SplittingField)
-      ((splits_id_iff_splits _).2 <| SplittingField.splits g) (hg.map _) fun a ha =>
+  have := mem_lift_of_splits_of_roots_mem_range (integralClosure R g.SplittingField)
+    ((splits_id_iff_splits _).2 <| SplittingField.splits g) (hg.map _) fun a ha =>
       (SetLike.ext_iff.mp (integralClosure R g.SplittingField).range_algebraMap _).mpr <|
         roots_mem_integralClosure hf ?_
   · rw [lifts_iff_coeff_lifts, ← RingHom.coe_range, Subalgebra.range_algebraMap] at this
feat: port RingTheory.Polynomial.GaussLemma (#5069)

Co-authored-by: Moritz Firsching <firsching@google.com> Co-authored-by: Riccardo Brasca <riccardo.brasca@gmail.com>

Dependencies 10 + 659

660 files ported (98.5%)
274131 lines ported (98.8%)
Show graph

The unported dependencies are