Skip to content

Commit

Permalink
feat: {Mv}Polynomial.algebraMap_apply simps (#11193)
Browse files Browse the repository at this point in the history
* Adds lemma `Polynomial.algebraMap_eq` analogous to `MvPolynomial.algebraMap_eq`
  * Adds some namespace disambiguations in various places to make this possible 
* Adds `simp` to these, and the related `{Mv}Polynomial.algebraMap_apply` lemmas.
  * Removes simp tag from later lemmas which linter says these additions now allow to be simp-proved




Co-authored-by: Floris van Doorn <fpvdoorn@gmail.com>
  • Loading branch information
BoltonBailey and fpvandoorn committed Apr 30, 2024
1 parent a41b81f commit a0c4507
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 19 deletions.
5 changes: 2 additions & 3 deletions Mathlib/Algebra/MvPolynomial/Basic.lean
Expand Up @@ -178,6 +178,7 @@ def C : R →+* MvPolynomial σ R :=

variable (R σ)

@[simp]
theorem algebraMap_eq : algebraMap R (MvPolynomial σ R) = C :=
rfl
#align mv_polynomial.algebra_map_eq MvPolynomial.algebraMap_eq
Expand Down Expand Up @@ -931,7 +932,6 @@ theorem constantCoeff_comp_C : constantCoeff.comp (C : R →+* MvPolynomial σ R
exact constantCoeff_C σ x
#align mv_polynomial.constant_coeff_comp_C MvPolynomial.constantCoeff_comp_C

@[simp]
theorem constantCoeff_comp_algebraMap :
constantCoeff.comp (algebraMap R (MvPolynomial σ R)) = RingHom.id R :=
constantCoeff_comp_C _ _
Expand Down Expand Up @@ -1459,6 +1459,7 @@ section Aeval
variable [Algebra R S₁] [CommSemiring S₂]
variable (f : σ → S₁)

@[simp]
theorem algebraMap_apply (r : R) : algebraMap R (MvPolynomial σ S₁) r = C (algebraMap R S₁ r) := rfl
#align mv_polynomial.algebra_map_apply MvPolynomial.algebraMap_apply

Expand Down Expand Up @@ -1642,12 +1643,10 @@ theorem aevalTower_comp_C : (aevalTower g y : MvPolynomial σ R →+* A).comp C
RingHom.ext <| aevalTower_C _ _
#align mv_polynomial.aeval_tower_comp_C MvPolynomial.aevalTower_comp_C

@[simp]
theorem aevalTower_algebraMap (x : R) : aevalTower g y (algebraMap R (MvPolynomial σ R) x) = g x :=
eval₂_C _ _ _
#align mv_polynomial.aeval_tower_algebra_map MvPolynomial.aevalTower_algebraMap

@[simp]
theorem aevalTower_comp_algebraMap :
(aevalTower g y : MvPolynomial σ R →+* A).comp (algebraMap R (MvPolynomial σ R)) = g :=
aevalTower_comp_C _ _
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Algebra/MvPolynomial/Equiv.lean
Expand Up @@ -287,7 +287,7 @@ polynomials with coefficients in `MvPolynomial S₁ R`.
def optionEquivLeft : MvPolynomial (Option S₁) R ≃ₐ[R] Polynomial (MvPolynomial S₁ R) :=
AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim Polynomial.X fun s => Polynomial.C (X s))
(Polynomial.aevalTower (MvPolynomial.rename some) (X none))
(by ext : 2 <;> simp [← Polynomial.C_eq_algebraMap]) (by ext i : 2; cases i <;> simp)
(by ext : 2 <;> simp) (by ext i : 2; cases i <;> simp)
#align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft

end
Expand Down
10 changes: 6 additions & 4 deletions Mathlib/Algebra/Polynomial/AlgebraMap.lean
Expand Up @@ -50,6 +50,7 @@ instance algebraOfAlgebra : Algebra R A[X]
toRingHom := C.comp (algebraMap R A)
#align polynomial.algebra_of_algebra Polynomial.algebraOfAlgebra

@[simp]
theorem algebraMap_apply (r : R) : algebraMap R A[X] r = C (algebraMap R A r) :=
rfl
#align polynomial.algebra_map_apply Polynomial.algebraMap_apply
Expand All @@ -75,6 +76,10 @@ theorem C_eq_algebraMap (r : R) : C r = algebraMap R R[X] r :=
set_option linter.uppercaseLean3 false in
#align polynomial.C_eq_algebra_map Polynomial.C_eq_algebraMap

@[simp]
theorem algebraMap_eq : algebraMap R R[X] = C :=
rfl

/-- `Polynomial.C` as an `AlgHom`. -/
@[simps! apply]
def CAlgHom : A →ₐ[R] A[X] where
Expand All @@ -99,8 +104,7 @@ implementation detail, but it can be useful to transfer results from `Finsupp` t
def toFinsuppIsoAlg : R[X] ≃ₐ[R] R[ℕ] :=
{ toFinsuppIso R with
commutes' := fun r => by
dsimp
exact toFinsupp_algebraMap _ }
dsimp }
#align polynomial.to_finsupp_iso_alg Polynomial.toFinsuppIsoAlg

variable {R}
Expand Down Expand Up @@ -450,12 +454,10 @@ theorem aevalTower_comp_C : (aevalTower g y : R[X] →+* A').comp C = g :=
set_option linter.uppercaseLean3 false in
#align polynomial.aeval_tower_comp_C Polynomial.aevalTower_comp_C

@[simp]
theorem aevalTower_algebraMap (x : R) : aevalTower g y (algebraMap R R[X] x) = g x :=
eval₂_C _ _
#align polynomial.aeval_tower_algebra_map Polynomial.aevalTower_algebraMap

@[simp]
theorem aevalTower_comp_algebraMap : (aevalTower g y : R[X] →+* A').comp (algebraMap R R[X]) = g :=
aevalTower_comp_C _ _
#align polynomial.aeval_tower_comp_algebra_map Polynomial.aevalTower_comp_algebraMap
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/FieldTheory/IsAlgClosed/AlgebraicClosure.lean
Expand Up @@ -78,7 +78,7 @@ def toSplittingField (s : Finset (MonicIrreducible k)) :
theorem toSplittingField_evalXSelf {s : Finset (MonicIrreducible k)} {f} (hf : f ∈ s) :
toSplittingField k s (evalXSelf k f) = 0 := by
rw [toSplittingField, evalXSelf, ← AlgHom.coe_toRingHom, hom_eval₂, AlgHom.coe_toRingHom,
MvPolynomial.aeval_X, dif_pos hf, ← algebraMap_eq, AlgHom.comp_algebraMap]
MvPolynomial.aeval_X, dif_pos hf, ← MvPolynomial.algebraMap_eq, AlgHom.comp_algebraMap]
exact map_rootOfSplits _ _ _
set_option linter.uppercaseLean3 false in
#align algebraic_closure.to_splitting_field_eval_X_self AlgebraicClosure.toSplittingField_evalXSelf
Expand Down
18 changes: 10 additions & 8 deletions Mathlib/FieldTheory/KummerExtension.lean
Expand Up @@ -258,7 +258,8 @@ theorem Polynomial.separable_X_pow_sub_C_of_irreducible : (X ^ n - C a).Separabl
have ⟨ζ, hζ⟩ := hζ
rw [mem_primitiveRoots (Nat.pos_of_ne_zero <| ne_zero_of_irreducible_X_pow_sub_C H)] at hζ
rw [← separable_map (algebraMap K K[n√a]), Polynomial.map_sub, Polynomial.map_pow, map_C, map_X,
algebraMap_eq, X_pow_sub_C_eq_prod (hζ.map_of_injective (algebraMap K _).injective) hn
AdjoinRoot.algebraMap_eq,
X_pow_sub_C_eq_prod (hζ.map_of_injective (algebraMap K _).injective) hn
(root_X_pow_sub_C_pow n a), separable_prod_X_sub_C_iff']
exact (hζ.map_of_injective (algebraMap K K[n√a]).injective).injOn_pow_mul
(root_X_pow_sub_C_ne_zero (lt_of_le_of_ne (show 1 ≤ n from hn) (Ne.symm hn')) _)
Expand Down Expand Up @@ -305,7 +306,7 @@ def AdjoinRootXPowSubCEquivToRootsOfUnity (σ : K[n√a] ≃ₐ[K] K[n√a]) :
split
· exact one_pow _
rw [div_pow, ← map_pow]
simp only [PNat.mk_coe, root_X_pow_sub_C_pow, ← algebraMap_eq, AlgEquiv.commutes]
simp only [PNat.mk_coe, root_X_pow_sub_C_pow, ← AdjoinRoot.algebraMap_eq, AlgEquiv.commutes]
rw [div_self]
rwa [Ne, map_eq_zero_iff _ (algebraMap K _).injective]))

Expand All @@ -323,7 +324,7 @@ def autAdjoinRootXPowSubCEquiv :
apply (rootsOfUnityEquivOfPrimitiveRoots
(n := ⟨n, hn⟩) (algebraMap K K[n√a]).injective hζ).injective
ext
simp only [algebraMap_eq, OneHom.toFun_eq_coe, MonoidHom.toOneHom_coe,
simp only [AdjoinRoot.algebraMap_eq, OneHom.toFun_eq_coe, MonoidHom.toOneHom_coe,
autAdjoinRootXPowSubC_root, Algebra.smul_def, ne_eq, MulEquiv.apply_symm_apply,
rootsOfUnity.val_mkOfPowEq_coe, val_rootsOfUnityEquivOfPrimitiveRoots_apply_coe,
AdjoinRootXPowSubCEquivToRootsOfUnity]
Expand All @@ -338,14 +339,14 @@ def autAdjoinRootXPowSubCEquiv :
letI : Algebra K K[n√a] := inferInstance
apply AlgEquiv.coe_algHom_injective
apply AdjoinRoot.algHom_ext
simp only [algebraMap_eq, OneHom.toFun_eq_coe, MonoidHom.toOneHom_coe, AlgHom.coe_coe,
autAdjoinRootXPowSubC_root, Algebra.smul_def, PNat.mk_coe,
simp only [AdjoinRoot.algebraMap_eq, OneHom.toFun_eq_coe, MonoidHom.toOneHom_coe,
AlgHom.coe_coe, autAdjoinRootXPowSubC_root, Algebra.smul_def, PNat.mk_coe,
AdjoinRootXPowSubCEquivToRootsOfUnity]
rw [rootsOfUnityEquivOfPrimitiveRoots_symm_apply, rootsOfUnity.val_mkOfPowEq_coe]
split_ifs with h
· obtain rfl := not_imp_not.mp (fun hn ↦ ne_zero_of_irreducible_X_pow_sub_C' hn H) h
rw [(pow_one _).symm.trans (root_X_pow_sub_C_pow 1 a), one_mul,
← algebraMap_eq, AlgEquiv.commutes]
AdjoinRoot.algebraMap_eq, AlgEquiv.commutes]
· refine div_mul_cancel₀ _ (root_X_pow_sub_C_ne_zero' hn h)

lemma autAdjoinRootXPowSubCEquiv_root (η) :
Expand All @@ -358,8 +359,9 @@ lemma autAdjoinRootXPowSubCEquiv_symm_smul (σ) :
have := Fact.mk H
simp only [autAdjoinRootXPowSubCEquiv, OneHom.toFun_eq_coe, MonoidHom.toOneHom_coe,
MulEquiv.symm_mk, MulEquiv.coe_mk, Equiv.coe_fn_symm_mk, AdjoinRootXPowSubCEquivToRootsOfUnity,
algebraMap_eq, Units.smul_def, Algebra.smul_def, rootsOfUnityEquivOfPrimitiveRoots_symm_apply,
rootsOfUnity.mkOfPowEq, PNat.mk_coe, Units.val_ofPowEqOne, ite_mul, one_mul, ne_eq]
AdjoinRoot.algebraMap_eq, Units.smul_def, Algebra.smul_def,
rootsOfUnityEquivOfPrimitiveRoots_symm_apply, rootsOfUnity.mkOfPowEq, PNat.mk_coe,
Units.val_ofPowEqOne, ite_mul, one_mul, ne_eq]
simp_rw [← root_X_pow_sub_C_eq_zero_iff H]
split_ifs with h
· rw [h, mul_zero, map_zero]
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/RingTheory/AlgebraicIndependent.lean
Expand Up @@ -102,7 +102,7 @@ namespace AlgebraicIndependent
variable (hx : AlgebraicIndependent R x)

theorem algebraMap_injective : Injective (algebraMap R A) := by
simpa [← MvPolynomial.algebraMap_eq, Function.comp] using
simpa [Function.comp] using
(Injective.of_comp_iff (algebraicIndependent_iff_injective_aeval.1 hx) MvPolynomial.C).2
(MvPolynomial.C_injective _ _)
#align algebraic_independent.algebra_map_injective AlgebraicIndependent.algebraMap_injective
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/RingTheory/FinitePresentation.lean
Expand Up @@ -281,7 +281,7 @@ theorem of_restrict_scalars_finitePresentation [Algebra A B] [IsScalarTower R A
rw [← ht''] at this
refine adjoin_induction this ?_ ?_ ?_ ?_
· rintro _ (⟨x, hx, rfl⟩ | ⟨i, rfl⟩)
· rw [algebraMap_eq, ← sub_add_cancel (MvPolynomial.C x)
· rw [MvPolynomial.algebraMap_eq, ← sub_add_cancel (MvPolynomial.C x)
(map (algebraMap R A) (t' ⟨x, hx⟩)), add_comm]
apply AddSubmonoid.add_mem_sup
· exact Set.mem_range_self _
Expand Down

0 comments on commit a0c4507

Please sign in to comment.