state
stringlengths
0
159k
srcUpToTactic
stringlengths
387
167k
nextTactic
stringlengths
3
9k
declUpToTactic
stringlengths
22
11.5k
declId
stringlengths
38
95
decl
stringlengths
16
1.89k
file_tag
stringlengths
17
73
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s✝ : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ s : Fin n → R y : R f : MvPolynomial (Fin (n + 1)) R ⊢ (eval (Fin.cons y s)) f = Polynomial.eval y (Polynomial.map (eval s) ((finSuccEquiv R n) f))
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom`
let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm }
theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom`
Mathlib.Data.MvPolynomial.Equiv.387_0.88gPfxLltQQTcHM
theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f))
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s✝ : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ s : Fin n → R y : R f : MvPolynomial (Fin (n + 1)) R src✝ : (MvPolynomial (Fin n) R)[X] →+* R[X] := mapRingHom (eval s) r : R ⊢ OneHom.toFun (↑↑{ toMonoidHom := ↑src✝, map_zero' := (_ : OneHom.toFun (↑↑src✝) 0 = 0), map_add' := (_ : ∀ (x y : (MvPolynomial (Fin n) R)[X]), OneHom.toFun (↑↑src✝) (x + y) = OneHom.toFun (↑↑src✝) x + OneHom.toFun (↑↑src✝) y) }) ((algebraMap R (MvPolynomial (Fin n) R)[X]) r) = (algebraMap R R[X]) r
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by
convert Polynomial.map_C (eval s)
theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by
Mathlib.Data.MvPolynomial.Equiv.387_0.88gPfxLltQQTcHM
theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f))
Mathlib_Data_MvPolynomial_Equiv
case h.e'_3.h.e'_6 R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s✝ : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ s : Fin n → R y : R f : MvPolynomial (Fin (n + 1)) R src✝ : (MvPolynomial (Fin n) R)[X] →+* R[X] := mapRingHom (eval s) r : R ⊢ r = (eval s) ((algebraMap R (MvPolynomial (Fin n) R)) r)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s)
exact (eval_C _).symm
theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s)
Mathlib.Data.MvPolynomial.Equiv.387_0.88gPfxLltQQTcHM
theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f))
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s✝ : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ s : Fin n → R y : R f : MvPolynomial (Fin (n + 1)) R φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := let src := mapRingHom (eval s); { toRingHom := { toMonoidHom := ↑src, map_zero' := (_ : OneHom.toFun (↑↑src) 0 = 0), map_add' := (_ : ∀ (x y : (MvPolynomial (Fin n) R)[X]), OneHom.toFun (↑↑src) (x + y) = OneHom.toFun (↑↑src) x + OneHom.toFun (↑↑src) y) }, commutes' := (_ : ∀ (r : R), OneHom.toFun (↑↑{ toMonoidHom := ↑src, map_zero' := (_ : OneHom.toFun (↑↑src) 0 = 0), map_add' := (_ : ∀ (x y : (MvPolynomial (Fin n) R)[X]), OneHom.toFun (↑↑src) (x + y) = OneHom.toFun (↑↑src) x + OneHom.toFun (↑↑src) y) }) ((algebraMap R (MvPolynomial (Fin n) R)[X]) r) = (algebraMap R R[X]) r) } ⊢ (eval (Fin.cons y s)) f = Polynomial.eval y (Polynomial.map (eval s) ((finSuccEquiv R n) f))
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm }
show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f
theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm }
Mathlib.Data.MvPolynomial.Equiv.387_0.88gPfxLltQQTcHM
theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f))
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s✝ : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ s : Fin n → R y : R f : MvPolynomial (Fin (n + 1)) R φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := let src := mapRingHom (eval s); { toRingHom := { toMonoidHom := ↑src, map_zero' := (_ : OneHom.toFun (↑↑src) 0 = 0), map_add' := (_ : ∀ (x y : (MvPolynomial (Fin n) R)[X]), OneHom.toFun (↑↑src) (x + y) = OneHom.toFun (↑↑src) x + OneHom.toFun (↑↑src) y) }, commutes' := (_ : ∀ (r : R), OneHom.toFun (↑↑{ toMonoidHom := ↑src, map_zero' := (_ : OneHom.toFun (↑↑src) 0 = 0), map_add' := (_ : ∀ (x y : (MvPolynomial (Fin n) R)[X]), OneHom.toFun (↑↑src) (x + y) = OneHom.toFun (↑↑src) x + OneHom.toFun (↑↑src) y) }) ((algebraMap R (MvPolynomial (Fin n) R)[X]) r) = (algebraMap R R[X]) r) } ⊢ (aeval (Fin.cons y s)) f = (AlgHom.comp (Polynomial.aeval y) (AlgHom.comp φ ↑(finSuccEquiv R n))) f
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f
congr 2
theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f
Mathlib.Data.MvPolynomial.Equiv.387_0.88gPfxLltQQTcHM
theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f))
Mathlib_Data_MvPolynomial_Equiv
case e_a R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s✝ : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ s : Fin n → R y : R f : MvPolynomial (Fin (n + 1)) R φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := let src := mapRingHom (eval s); { toRingHom := { toMonoidHom := ↑src, map_zero' := (_ : OneHom.toFun (↑↑src) 0 = 0), map_add' := (_ : ∀ (x y : (MvPolynomial (Fin n) R)[X]), OneHom.toFun (↑↑src) (x + y) = OneHom.toFun (↑↑src) x + OneHom.toFun (↑↑src) y) }, commutes' := (_ : ∀ (r : R), OneHom.toFun (↑↑{ toMonoidHom := ↑src, map_zero' := (_ : OneHom.toFun (↑↑src) 0 = 0), map_add' := (_ : ∀ (x y : (MvPolynomial (Fin n) R)[X]), OneHom.toFun (↑↑src) (x + y) = OneHom.toFun (↑↑src) x + OneHom.toFun (↑↑src) y) }) ((algebraMap R (MvPolynomial (Fin n) R)[X]) r) = (algebraMap R R[X]) r) } ⊢ aeval (Fin.cons y s) = AlgHom.comp (Polynomial.aeval y) (AlgHom.comp φ ↑(finSuccEquiv R n))
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2
apply MvPolynomial.algHom_ext
theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2
Mathlib.Data.MvPolynomial.Equiv.387_0.88gPfxLltQQTcHM
theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f))
Mathlib_Data_MvPolynomial_Equiv
case e_a.hf R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s✝ : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ s : Fin n → R y : R f : MvPolynomial (Fin (n + 1)) R φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := let src := mapRingHom (eval s); { toRingHom := { toMonoidHom := ↑src, map_zero' := (_ : OneHom.toFun (↑↑src) 0 = 0), map_add' := (_ : ∀ (x y : (MvPolynomial (Fin n) R)[X]), OneHom.toFun (↑↑src) (x + y) = OneHom.toFun (↑↑src) x + OneHom.toFun (↑↑src) y) }, commutes' := (_ : ∀ (r : R), OneHom.toFun (↑↑{ toMonoidHom := ↑src, map_zero' := (_ : OneHom.toFun (↑↑src) 0 = 0), map_add' := (_ : ∀ (x y : (MvPolynomial (Fin n) R)[X]), OneHom.toFun (↑↑src) (x + y) = OneHom.toFun (↑↑src) x + OneHom.toFun (↑↑src) y) }) ((algebraMap R (MvPolynomial (Fin n) R)[X]) r) = (algebraMap R R[X]) r) } ⊢ ∀ (i : Fin (n + 1)), (aeval (Fin.cons y s)) (X i) = (AlgHom.comp (Polynomial.aeval y) (AlgHom.comp φ ↑(finSuccEquiv R n))) (X i)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext
rw [Fin.forall_fin_succ]
theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext
Mathlib.Data.MvPolynomial.Equiv.387_0.88gPfxLltQQTcHM
theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f))
Mathlib_Data_MvPolynomial_Equiv
case e_a.hf R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s✝ : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ s : Fin n → R y : R f : MvPolynomial (Fin (n + 1)) R φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := let src := mapRingHom (eval s); { toRingHom := { toMonoidHom := ↑src, map_zero' := (_ : OneHom.toFun (↑↑src) 0 = 0), map_add' := (_ : ∀ (x y : (MvPolynomial (Fin n) R)[X]), OneHom.toFun (↑↑src) (x + y) = OneHom.toFun (↑↑src) x + OneHom.toFun (↑↑src) y) }, commutes' := (_ : ∀ (r : R), OneHom.toFun (↑↑{ toMonoidHom := ↑src, map_zero' := (_ : OneHom.toFun (↑↑src) 0 = 0), map_add' := (_ : ∀ (x y : (MvPolynomial (Fin n) R)[X]), OneHom.toFun (↑↑src) (x + y) = OneHom.toFun (↑↑src) x + OneHom.toFun (↑↑src) y) }) ((algebraMap R (MvPolynomial (Fin n) R)[X]) r) = (algebraMap R R[X]) r) } ⊢ (aeval (Fin.cons y s)) (X 0) = (AlgHom.comp (Polynomial.aeval y) (AlgHom.comp φ ↑(finSuccEquiv R n))) (X 0) ∧ ∀ (i : Fin n), (aeval (Fin.cons y s)) (X (Fin.succ i)) = (AlgHom.comp (Polynomial.aeval y) (AlgHom.comp φ ↑(finSuccEquiv R n))) (X (Fin.succ i))
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ]
simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe]
theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ]
Mathlib.Data.MvPolynomial.Equiv.387_0.88gPfxLltQQTcHM
theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f))
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ s' : Fin n → R f : (MvPolynomial (Fin n) R)[X] i : ℕ ⊢ Polynomial.coeff (Polynomial.map (eval s') f) i = (eval s') (Polynomial.coeff f i)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by
simp only [Polynomial.coeff_map]
theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by
Mathlib.Data.MvPolynomial.Equiv.411_0.88gPfxLltQQTcHM
theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i)
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ m : Fin n →₀ ℕ ⊢ m ∈ support (Polynomial.coeff ((finSuccEquiv R n) f) i) ↔ cons i m ∈ support f
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by
apply Iff.intro
theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by
Mathlib.Data.MvPolynomial.Equiv.416_0.88gPfxLltQQTcHM
theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support
Mathlib_Data_MvPolynomial_Equiv
case mp R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ m : Fin n →₀ ℕ ⊢ m ∈ support (Polynomial.coeff ((finSuccEquiv R n) f) i) → cons i m ∈ support f
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro ·
intro h
theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro ·
Mathlib.Data.MvPolynomial.Equiv.416_0.88gPfxLltQQTcHM
theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support
Mathlib_Data_MvPolynomial_Equiv
case mp R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ m : Fin n →₀ ℕ h : m ∈ support (Polynomial.coeff ((finSuccEquiv R n) f) i) ⊢ cons i m ∈ support f
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h
simpa [← finSuccEquiv_coeff_coeff] using h
theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h
Mathlib.Data.MvPolynomial.Equiv.416_0.88gPfxLltQQTcHM
theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support
Mathlib_Data_MvPolynomial_Equiv
case mpr R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ m : Fin n →₀ ℕ ⊢ cons i m ∈ support f → m ∈ support (Polynomial.coeff ((finSuccEquiv R n) f) i)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h ·
intro h
theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h ·
Mathlib.Data.MvPolynomial.Equiv.416_0.88gPfxLltQQTcHM
theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support
Mathlib_Data_MvPolynomial_Equiv
case mpr R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ m : Fin n →₀ ℕ h : cons i m ∈ support f ⊢ m ∈ support (Polynomial.coeff ((finSuccEquiv R n) f) i)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h
simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h
theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h
Mathlib.Data.MvPolynomial.Equiv.416_0.88gPfxLltQQTcHM
theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ hi : Polynomial.coeff ((finSuccEquiv R n) f) i ≠ 0 ⊢ totalDegree (Polynomial.coeff ((finSuccEquiv R n) f) i) + i ≤ totalDegree f
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by
have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi
/-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by
Mathlib.Data.MvPolynomial.Equiv.425_0.88gPfxLltQQTcHM
/-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ hi : Polynomial.coeff ((finSuccEquiv R n) f) i ≠ 0 ⊢ Finset.Nonempty (support (Polynomial.coeff ((finSuccEquiv R n) f) i))
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by
rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty]
/-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by
Mathlib.Data.MvPolynomial.Equiv.425_0.88gPfxLltQQTcHM
/-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ hi : Polynomial.coeff ((finSuccEquiv R n) f) i ≠ 0 ⊢ ¬Polynomial.coeff ((finSuccEquiv R n) f) i = 0
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty]
exact hi
/-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty]
Mathlib.Data.MvPolynomial.Equiv.425_0.88gPfxLltQQTcHM
/-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ hi : Polynomial.coeff ((finSuccEquiv R n) f) i ≠ 0 hf'_sup : Finset.Nonempty (support (Polynomial.coeff ((finSuccEquiv R n) f) i)) ⊢ totalDegree (Polynomial.coeff ((finSuccEquiv R n) f) i) + i ≤ totalDegree f
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree
have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e)
/-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree
Mathlib.Data.MvPolynomial.Equiv.425_0.88gPfxLltQQTcHM
/-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ✝ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ✝ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ hi : Polynomial.coeff ((finSuccEquiv R n) f) i ≠ 0 hf'_sup : Finset.Nonempty (support (Polynomial.coeff ((finSuccEquiv R n) f) i)) σ : Fin n →₀ ℕ hσ1 : σ ∈ support (Polynomial.coeff ((finSuccEquiv R n) f) i) hσ2 : (Finset.sup (support (Polynomial.coeff ((finSuccEquiv R n) f) i)) fun s => Finsupp.sum s fun x e => e) = Finsupp.sum σ fun x e => e ⊢ totalDegree (Polynomial.coeff ((finSuccEquiv R n) f) i) + i ≤ totalDegree f
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound
let σ' : Fin (n+1) →₀ ℕ := cons i σ
/-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound
Mathlib.Data.MvPolynomial.Equiv.425_0.88gPfxLltQQTcHM
/-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ✝ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ✝ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ hi : Polynomial.coeff ((finSuccEquiv R n) f) i ≠ 0 hf'_sup : Finset.Nonempty (support (Polynomial.coeff ((finSuccEquiv R n) f) i)) σ : Fin n →₀ ℕ hσ1 : σ ∈ support (Polynomial.coeff ((finSuccEquiv R n) f) i) hσ2 : (Finset.sup (support (Polynomial.coeff ((finSuccEquiv R n) f) i)) fun s => Finsupp.sum s fun x e => e) = Finsupp.sum σ fun x e => e σ' : Fin (n + 1) →₀ ℕ := cons i σ ⊢ totalDegree (Polynomial.coeff ((finSuccEquiv R n) f) i) + i ≤ totalDegree f
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ
convert le_totalDegree (s := σ') _
/-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ
Mathlib.Data.MvPolynomial.Equiv.425_0.88gPfxLltQQTcHM
/-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f
Mathlib_Data_MvPolynomial_Equiv
case h.e'_3 R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ✝ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ✝ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ hi : Polynomial.coeff ((finSuccEquiv R n) f) i ≠ 0 hf'_sup : Finset.Nonempty (support (Polynomial.coeff ((finSuccEquiv R n) f) i)) σ : Fin n →₀ ℕ hσ1 : σ ∈ support (Polynomial.coeff ((finSuccEquiv R n) f) i) hσ2 : (Finset.sup (support (Polynomial.coeff ((finSuccEquiv R n) f) i)) fun s => Finsupp.sum s fun x e => e) = Finsupp.sum σ fun x e => e σ' : Fin (n + 1) →₀ ℕ := cons i σ ⊢ totalDegree (Polynomial.coeff ((finSuccEquiv R n) f) i) + i = Finsupp.sum σ' fun x e => e
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ ·
rw [totalDegree, hσ2, sum_cons, add_comm]
/-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ ·
Mathlib.Data.MvPolynomial.Equiv.425_0.88gPfxLltQQTcHM
/-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f
Mathlib_Data_MvPolynomial_Equiv
case convert_4 R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ✝ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ✝ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ hi : Polynomial.coeff ((finSuccEquiv R n) f) i ≠ 0 hf'_sup : Finset.Nonempty (support (Polynomial.coeff ((finSuccEquiv R n) f) i)) σ : Fin n →₀ ℕ hσ1 : σ ∈ support (Polynomial.coeff ((finSuccEquiv R n) f) i) hσ2 : (Finset.sup (support (Polynomial.coeff ((finSuccEquiv R n) f) i)) fun s => Finsupp.sum s fun x e => e) = Finsupp.sum σ fun x e => e σ' : Fin (n + 1) →₀ ℕ := cons i σ ⊢ σ' ∈ support f
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] ·
rw [← support_coeff_finSuccEquiv]
/-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] ·
Mathlib.Data.MvPolynomial.Equiv.425_0.88gPfxLltQQTcHM
/-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f
Mathlib_Data_MvPolynomial_Equiv
case convert_4 R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ✝ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ✝ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ hi : Polynomial.coeff ((finSuccEquiv R n) f) i ≠ 0 hf'_sup : Finset.Nonempty (support (Polynomial.coeff ((finSuccEquiv R n) f) i)) σ : Fin n →₀ ℕ hσ1 : σ ∈ support (Polynomial.coeff ((finSuccEquiv R n) f) i) hσ2 : (Finset.sup (support (Polynomial.coeff ((finSuccEquiv R n) f) i)) fun s => Finsupp.sum s fun x e => e) = Finsupp.sum σ fun x e => e σ' : Fin (n + 1) →₀ ℕ := cons i σ ⊢ σ ∈ support (Polynomial.coeff ((finSuccEquiv R n) f) i)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv]
exact hσ1
/-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv]
Mathlib.Data.MvPolynomial.Equiv.425_0.88gPfxLltQQTcHM
/-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R ⊢ Polynomial.support ((finSuccEquiv R n) f) = Finset.image (fun m => m 0) (support f)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by
ext i
theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by
Mathlib.Data.MvPolynomial.Equiv.445_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support
Mathlib_Data_MvPolynomial_Equiv
case a R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ ⊢ i ∈ Polynomial.support ((finSuccEquiv R n) f) ↔ i ∈ Finset.image (fun m => m 0) (support f)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i
rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff]
theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i
Mathlib.Data.MvPolynomial.Equiv.445_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support
Mathlib_Data_MvPolynomial_Equiv
case a R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ ⊢ (∃ a, (Polynomial.coeff ((finSuccEquiv R n) f) i) a ≠ 0 a) ↔ ∃ a ∈ support f, a 0 = i
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff]
constructor
theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff]
Mathlib.Data.MvPolynomial.Equiv.445_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support
Mathlib_Data_MvPolynomial_Equiv
case a.mp R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ ⊢ (∃ a, (Polynomial.coeff ((finSuccEquiv R n) f) i) a ≠ 0 a) → ∃ a ∈ support f, a 0 = i
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor ·
rintro ⟨m, hm⟩
theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor ·
Mathlib.Data.MvPolynomial.Equiv.445_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support
Mathlib_Data_MvPolynomial_Equiv
case a.mp.intro R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ m : Fin n →₀ ℕ hm : (Polynomial.coeff ((finSuccEquiv R n) f) i) m ≠ 0 m ⊢ ∃ a ∈ support f, a 0 = i
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩
refine' ⟨cons i m, _, cons_zero _ _⟩
theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩
Mathlib.Data.MvPolynomial.Equiv.445_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support
Mathlib_Data_MvPolynomial_Equiv
case a.mp.intro R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ m : Fin n →₀ ℕ hm : (Polynomial.coeff ((finSuccEquiv R n) f) i) m ≠ 0 m ⊢ cons i m ∈ support f
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩
rw [← support_coeff_finSuccEquiv]
theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩
Mathlib.Data.MvPolynomial.Equiv.445_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support
Mathlib_Data_MvPolynomial_Equiv
case a.mp.intro R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ m : Fin n →₀ ℕ hm : (Polynomial.coeff ((finSuccEquiv R n) f) i) m ≠ 0 m ⊢ m ∈ support (Polynomial.coeff ((finSuccEquiv R n) f) i)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv]
simpa using hm
theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv]
Mathlib.Data.MvPolynomial.Equiv.445_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support
Mathlib_Data_MvPolynomial_Equiv
case a.mpr R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ ⊢ (∃ a ∈ support f, a 0 = i) → ∃ a, (Polynomial.coeff ((finSuccEquiv R n) f) i) a ≠ 0 a
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm ·
rintro ⟨m, h, rfl⟩
theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm ·
Mathlib.Data.MvPolynomial.Equiv.445_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support
Mathlib_Data_MvPolynomial_Equiv
case a.mpr.intro.intro R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R m : Fin (n + 1) →₀ ℕ h : m ∈ support f ⊢ ∃ a, (Polynomial.coeff ((finSuccEquiv R n) f) (m 0)) a ≠ 0 a
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩
refine' ⟨tail m, _⟩
theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩
Mathlib.Data.MvPolynomial.Equiv.445_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support
Mathlib_Data_MvPolynomial_Equiv
case a.mpr.intro.intro R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R m : Fin (n + 1) →₀ ℕ h : m ∈ support f ⊢ (Polynomial.coeff ((finSuccEquiv R n) f) (m 0)) (tail m) ≠ 0 (tail m)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩
rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail]
theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩
Mathlib.Data.MvPolynomial.Equiv.445_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ ⊢ Finset.image (cons i) (support (Polynomial.coeff ((finSuccEquiv R n) f) i)) = Finset.filter (fun m => m 0 = i) (support f)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by
ext m
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by
Mathlib.Data.MvPolynomial.Equiv.459_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i
Mathlib_Data_MvPolynomial_Equiv
case a R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ m : Fin (n + 1) →₀ ℕ ⊢ m ∈ Finset.image (cons i) (support (Polynomial.coeff ((finSuccEquiv R n) f) i)) ↔ m ∈ Finset.filter (fun m => m 0 = i) (support f)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m
rw [Finset.mem_filter, Finset.mem_image, mem_support_iff]
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m
Mathlib.Data.MvPolynomial.Equiv.459_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i
Mathlib_Data_MvPolynomial_Equiv
case a R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ m : Fin (n + 1) →₀ ℕ ⊢ (∃ a ∈ support (Polynomial.coeff ((finSuccEquiv R n) f) i), cons i a = m) ↔ coeff m f ≠ 0 ∧ m 0 = i
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff]
conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def]
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff]
Mathlib.Data.MvPolynomial.Equiv.459_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ m : Fin (n + 1) →₀ ℕ | ∃ a ∈ support (Polynomial.coeff ((finSuccEquiv R n) f) i), cons i a = m
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs =>
congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def]
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs =>
Mathlib.Data.MvPolynomial.Equiv.459_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ m : Fin (n + 1) →₀ ℕ | ∃ a ∈ support (Polynomial.coeff ((finSuccEquiv R n) f) i), cons i a = m
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs =>
congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def]
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs =>
Mathlib.Data.MvPolynomial.Equiv.459_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ m : Fin (n + 1) →₀ ℕ | ∃ a ∈ support (Polynomial.coeff ((finSuccEquiv R n) f) i), cons i a = m
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs =>
congr
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs =>
Mathlib.Data.MvPolynomial.Equiv.459_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i
Mathlib_Data_MvPolynomial_Equiv
case p R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ m : Fin (n + 1) →₀ ℕ | fun a => a ∈ support (Polynomial.coeff ((finSuccEquiv R n) f) i) ∧ cons i a = m
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr
ext
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr
Mathlib.Data.MvPolynomial.Equiv.459_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i
Mathlib_Data_MvPolynomial_Equiv
case p.h R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ m : Fin (n + 1) →₀ ℕ x✝ : Fin n →₀ ℕ | x✝ ∈ support (Polynomial.coeff ((finSuccEquiv R n) f) i) ∧ cons i x✝ = m
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext
rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def]
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext
Mathlib.Data.MvPolynomial.Equiv.459_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i
Mathlib_Data_MvPolynomial_Equiv
case a R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ m : Fin (n + 1) →₀ ℕ ⊢ (∃ x, ¬coeff (cons i x) f = 0 ∧ cons i x = m) ↔ coeff m f ≠ 0 ∧ m 0 = i
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def]
constructor
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def]
Mathlib.Data.MvPolynomial.Equiv.459_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i
Mathlib_Data_MvPolynomial_Equiv
case a.mp R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ m : Fin (n + 1) →₀ ℕ ⊢ (∃ x, ¬coeff (cons i x) f = 0 ∧ cons i x = m) → coeff m f ≠ 0 ∧ m 0 = i
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor ·
rintro ⟨m', ⟨h, hm'⟩⟩
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor ·
Mathlib.Data.MvPolynomial.Equiv.459_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i
Mathlib_Data_MvPolynomial_Equiv
case a.mp.intro.intro R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ m : Fin (n + 1) →₀ ℕ m' : Fin n →₀ ℕ h : ¬coeff (cons i m') f = 0 hm' : cons i m' = m ⊢ coeff m f ≠ 0 ∧ m 0 = i
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩
simp only [← hm']
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩
Mathlib.Data.MvPolynomial.Equiv.459_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i
Mathlib_Data_MvPolynomial_Equiv
case a.mp.intro.intro R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ m : Fin (n + 1) →₀ ℕ m' : Fin n →₀ ℕ h : ¬coeff (cons i m') f = 0 hm' : cons i m' = m ⊢ coeff (cons i m') f ≠ 0 ∧ (cons i m') 0 = i
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm']
exact ⟨h, by rw [cons_zero]⟩
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm']
Mathlib.Data.MvPolynomial.Equiv.459_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ m : Fin (n + 1) →₀ ℕ m' : Fin n →₀ ℕ h : ¬coeff (cons i m') f = 0 hm' : cons i m' = m ⊢ (cons i m') 0 = i
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by
rw [cons_zero]
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by
Mathlib.Data.MvPolynomial.Equiv.459_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i
Mathlib_Data_MvPolynomial_Equiv
case a.mpr R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ m : Fin (n + 1) →₀ ℕ ⊢ coeff m f ≠ 0 ∧ m 0 = i → ∃ x, ¬coeff (cons i x) f = 0 ∧ cons i x = m
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ ·
intro h
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ ·
Mathlib.Data.MvPolynomial.Equiv.459_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i
Mathlib_Data_MvPolynomial_Equiv
case a.mpr R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ m : Fin (n + 1) →₀ ℕ h : coeff m f ≠ 0 ∧ m 0 = i ⊢ ∃ x, ¬coeff (cons i x) f = 0 ∧ cons i x = m
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h
use tail m
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h
Mathlib.Data.MvPolynomial.Equiv.459_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i
Mathlib_Data_MvPolynomial_Equiv
case h R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ m : Fin (n + 1) →₀ ℕ h : coeff m f ≠ 0 ∧ m 0 = i ⊢ ¬coeff (cons i (tail m)) f = 0 ∧ cons i (tail m) = m
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m
rw [← h.2, cons_tail]
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m
Mathlib.Data.MvPolynomial.Equiv.459_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i
Mathlib_Data_MvPolynomial_Equiv
case h R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R i : ℕ m : Fin (n + 1) →₀ ℕ h : coeff m f ≠ 0 ∧ m 0 = i ⊢ ¬coeff m f = 0 ∧ m = m
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail]
simp [h.1]
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail]
Mathlib.Data.MvPolynomial.Equiv.459_0.88gPfxLltQQTcHM
theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R h : f ≠ 0 ⊢ Finset.Nonempty (Polynomial.support ((finSuccEquiv R n) f))
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail] simp [h.1] #align mv_polynomial.fin_succ_equiv_support' MvPolynomial.finSuccEquiv_support' theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by
simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty]
theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by
Mathlib.Data.MvPolynomial.Equiv.478_0.88gPfxLltQQTcHM
theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R h : f ≠ 0 ⊢ ¬(finSuccEquiv R n) f = 0
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail] simp [h.1] #align mv_polynomial.fin_succ_equiv_support' MvPolynomial.finSuccEquiv_support' theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty]
refine fun c => h ?_
theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty]
Mathlib.Data.MvPolynomial.Equiv.478_0.88gPfxLltQQTcHM
theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R h : f ≠ 0 c : (finSuccEquiv R n) f = 0 ⊢ f = 0
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail] simp [h.1] #align mv_polynomial.fin_succ_equiv_support' MvPolynomial.finSuccEquiv_support' theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_
let ii := (finSuccEquiv R n).symm
theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_
Mathlib.Data.MvPolynomial.Equiv.478_0.88gPfxLltQQTcHM
theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R h : f ≠ 0 c : (finSuccEquiv R n) f = 0 ii : (MvPolynomial (Fin n) R)[X] ≃ₐ[R] MvPolynomial (Fin (n + 1)) R := AlgEquiv.symm (finSuccEquiv R n) ⊢ f = 0
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail] simp [h.1] #align mv_polynomial.fin_succ_equiv_support' MvPolynomial.finSuccEquiv_support' theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_ let ii := (finSuccEquiv R n).symm
calc f = ii (finSuccEquiv R n f) := by simpa only [← AlgEquiv.invFun_eq_symm] using ((finSuccEquiv R n).left_inv f).symm _ = ii 0 := by rw [c] _ = 0 := by simp
theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_ let ii := (finSuccEquiv R n).symm
Mathlib.Data.MvPolynomial.Equiv.478_0.88gPfxLltQQTcHM
theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R h : f ≠ 0 c : (finSuccEquiv R n) f = 0 ii : (MvPolynomial (Fin n) R)[X] ≃ₐ[R] MvPolynomial (Fin (n + 1)) R := AlgEquiv.symm (finSuccEquiv R n) ⊢ f = ii ((finSuccEquiv R n) f)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail] simp [h.1] #align mv_polynomial.fin_succ_equiv_support' MvPolynomial.finSuccEquiv_support' theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_ let ii := (finSuccEquiv R n).symm calc f = ii (finSuccEquiv R n f) := by
simpa only [← AlgEquiv.invFun_eq_symm] using ((finSuccEquiv R n).left_inv f).symm
theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_ let ii := (finSuccEquiv R n).symm calc f = ii (finSuccEquiv R n f) := by
Mathlib.Data.MvPolynomial.Equiv.478_0.88gPfxLltQQTcHM
theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R h : f ≠ 0 c : (finSuccEquiv R n) f = 0 ii : (MvPolynomial (Fin n) R)[X] ≃ₐ[R] MvPolynomial (Fin (n + 1)) R := AlgEquiv.symm (finSuccEquiv R n) ⊢ ii ((finSuccEquiv R n) f) = ii 0
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail] simp [h.1] #align mv_polynomial.fin_succ_equiv_support' MvPolynomial.finSuccEquiv_support' theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_ let ii := (finSuccEquiv R n).symm calc f = ii (finSuccEquiv R n f) := by simpa only [← AlgEquiv.invFun_eq_symm] using ((finSuccEquiv R n).left_inv f).symm _ = ii 0 := by
rw [c]
theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_ let ii := (finSuccEquiv R n).symm calc f = ii (finSuccEquiv R n f) := by simpa only [← AlgEquiv.invFun_eq_symm] using ((finSuccEquiv R n).left_inv f).symm _ = ii 0 := by
Mathlib.Data.MvPolynomial.Equiv.478_0.88gPfxLltQQTcHM
theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R h : f ≠ 0 c : (finSuccEquiv R n) f = 0 ii : (MvPolynomial (Fin n) R)[X] ≃ₐ[R] MvPolynomial (Fin (n + 1)) R := AlgEquiv.symm (finSuccEquiv R n) ⊢ ii 0 = 0
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail] simp [h.1] #align mv_polynomial.fin_succ_equiv_support' MvPolynomial.finSuccEquiv_support' theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_ let ii := (finSuccEquiv R n).symm calc f = ii (finSuccEquiv R n f) := by simpa only [← AlgEquiv.invFun_eq_symm] using ((finSuccEquiv R n).left_inv f).symm _ = ii 0 := by rw [c] _ = 0 := by
simp
theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_ let ii := (finSuccEquiv R n).symm calc f = ii (finSuccEquiv R n f) := by simpa only [← AlgEquiv.invFun_eq_symm] using ((finSuccEquiv R n).left_inv f).symm _ = ii 0 := by rw [c] _ = 0 := by
Mathlib.Data.MvPolynomial.Equiv.478_0.88gPfxLltQQTcHM
theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R h : f ≠ 0 ⊢ degree ((finSuccEquiv R n) f) = ↑(degreeOf 0 f)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail] simp [h.1] #align mv_polynomial.fin_succ_equiv_support' MvPolynomial.finSuccEquiv_support' theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_ let ii := (finSuccEquiv R n).symm calc f = ii (finSuccEquiv R n f) := by simpa only [← AlgEquiv.invFun_eq_symm] using ((finSuccEquiv R n).left_inv f).symm _ = ii 0 := by rw [c] _ = 0 := by simp #align mv_polynomial.support_fin_succ_equiv_nonempty MvPolynomial.support_finSuccEquiv_nonempty theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f := by -- TODO: these should be lemmas
have h₀ : ∀ {α β : Type _} (f : α → β), (fun x => x) ∘ f = f := fun f => rfl
theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f := by -- TODO: these should be lemmas
Mathlib.Data.MvPolynomial.Equiv.490_0.88gPfxLltQQTcHM
theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R h : f ≠ 0 h₀ : ∀ {α : Type ?u.1456857} {β : Type ?u.1456860} (f : α → β), (fun x => x) ∘ f = f ⊢ degree ((finSuccEquiv R n) f) = ↑(degreeOf 0 f)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail] simp [h.1] #align mv_polynomial.fin_succ_equiv_support' MvPolynomial.finSuccEquiv_support' theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_ let ii := (finSuccEquiv R n).symm calc f = ii (finSuccEquiv R n f) := by simpa only [← AlgEquiv.invFun_eq_symm] using ((finSuccEquiv R n).left_inv f).symm _ = ii 0 := by rw [c] _ = 0 := by simp #align mv_polynomial.support_fin_succ_equiv_nonempty MvPolynomial.support_finSuccEquiv_nonempty theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f := by -- TODO: these should be lemmas have h₀ : ∀ {α β : Type _} (f : α → β), (fun x => x) ∘ f = f := fun f => rfl
have h₁ : ∀ {α β : Type _} (f : α → β), f ∘ (fun x => x) = f := fun f => rfl
theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f := by -- TODO: these should be lemmas have h₀ : ∀ {α β : Type _} (f : α → β), (fun x => x) ∘ f = f := fun f => rfl
Mathlib.Data.MvPolynomial.Equiv.490_0.88gPfxLltQQTcHM
theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R h : f ≠ 0 h₀ : ∀ {α : Type ?u.1456857} {β : Type ?u.1456860} (f : α → β), (fun x => x) ∘ f = f h₁ : ∀ {α : Type ?u.1456922} {β : Type ?u.1456925} (f : α → β), (f ∘ fun x => x) = f ⊢ degree ((finSuccEquiv R n) f) = ↑(degreeOf 0 f)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail] simp [h.1] #align mv_polynomial.fin_succ_equiv_support' MvPolynomial.finSuccEquiv_support' theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_ let ii := (finSuccEquiv R n).symm calc f = ii (finSuccEquiv R n f) := by simpa only [← AlgEquiv.invFun_eq_symm] using ((finSuccEquiv R n).left_inv f).symm _ = ii 0 := by rw [c] _ = 0 := by simp #align mv_polynomial.support_fin_succ_equiv_nonempty MvPolynomial.support_finSuccEquiv_nonempty theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f := by -- TODO: these should be lemmas have h₀ : ∀ {α β : Type _} (f : α → β), (fun x => x) ∘ f = f := fun f => rfl have h₁ : ∀ {α β : Type _} (f : α → β), f ∘ (fun x => x) = f := fun f => rfl
have h₂ : WithBot.some = Nat.cast := rfl
theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f := by -- TODO: these should be lemmas have h₀ : ∀ {α β : Type _} (f : α → β), (fun x => x) ∘ f = f := fun f => rfl have h₁ : ∀ {α β : Type _} (f : α → β), f ∘ (fun x => x) = f := fun f => rfl
Mathlib.Data.MvPolynomial.Equiv.490_0.88gPfxLltQQTcHM
theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R h : f ≠ 0 h₀ : ∀ {α : Type ?u.1456857} {β : Type ?u.1456860} (f : α → β), (fun x => x) ∘ f = f h₁ : ∀ {α : Type ?u.1456922} {β : Type ?u.1456925} (f : α → β), (f ∘ fun x => x) = f h₂ : WithBot.some = Nat.cast ⊢ degree ((finSuccEquiv R n) f) = ↑(degreeOf 0 f)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail] simp [h.1] #align mv_polynomial.fin_succ_equiv_support' MvPolynomial.finSuccEquiv_support' theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_ let ii := (finSuccEquiv R n).symm calc f = ii (finSuccEquiv R n f) := by simpa only [← AlgEquiv.invFun_eq_symm] using ((finSuccEquiv R n).left_inv f).symm _ = ii 0 := by rw [c] _ = 0 := by simp #align mv_polynomial.support_fin_succ_equiv_nonempty MvPolynomial.support_finSuccEquiv_nonempty theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f := by -- TODO: these should be lemmas have h₀ : ∀ {α β : Type _} (f : α → β), (fun x => x) ∘ f = f := fun f => rfl have h₁ : ∀ {α β : Type _} (f : α → β), f ∘ (fun x => x) = f := fun f => rfl have h₂ : WithBot.some = Nat.cast := rfl
have h' : ((finSuccEquiv R n f).support.sup fun x => x) = degreeOf 0 f := by rw [degreeOf_eq_sup, finSuccEquiv_support f, Finset.sup_image, h₀]
theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f := by -- TODO: these should be lemmas have h₀ : ∀ {α β : Type _} (f : α → β), (fun x => x) ∘ f = f := fun f => rfl have h₁ : ∀ {α β : Type _} (f : α → β), f ∘ (fun x => x) = f := fun f => rfl have h₂ : WithBot.some = Nat.cast := rfl
Mathlib.Data.MvPolynomial.Equiv.490_0.88gPfxLltQQTcHM
theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R h : f ≠ 0 h₀ : ∀ {α : Type ?u.1456857} {β : Type ?u.1456860} (f : α → β), (fun x => x) ∘ f = f h₁ : ∀ {α : Type ?u.1456922} {β : Type ?u.1456925} (f : α → β), (f ∘ fun x => x) = f h₂ : WithBot.some = Nat.cast ⊢ (Finset.sup (Polynomial.support ((finSuccEquiv R n) f)) fun x => x) = degreeOf 0 f
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail] simp [h.1] #align mv_polynomial.fin_succ_equiv_support' MvPolynomial.finSuccEquiv_support' theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_ let ii := (finSuccEquiv R n).symm calc f = ii (finSuccEquiv R n f) := by simpa only [← AlgEquiv.invFun_eq_symm] using ((finSuccEquiv R n).left_inv f).symm _ = ii 0 := by rw [c] _ = 0 := by simp #align mv_polynomial.support_fin_succ_equiv_nonempty MvPolynomial.support_finSuccEquiv_nonempty theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f := by -- TODO: these should be lemmas have h₀ : ∀ {α β : Type _} (f : α → β), (fun x => x) ∘ f = f := fun f => rfl have h₁ : ∀ {α β : Type _} (f : α → β), f ∘ (fun x => x) = f := fun f => rfl have h₂ : WithBot.some = Nat.cast := rfl have h' : ((finSuccEquiv R n f).support.sup fun x => x) = degreeOf 0 f := by
rw [degreeOf_eq_sup, finSuccEquiv_support f, Finset.sup_image, h₀]
theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f := by -- TODO: these should be lemmas have h₀ : ∀ {α β : Type _} (f : α → β), (fun x => x) ∘ f = f := fun f => rfl have h₁ : ∀ {α β : Type _} (f : α → β), f ∘ (fun x => x) = f := fun f => rfl have h₂ : WithBot.some = Nat.cast := rfl have h' : ((finSuccEquiv R n f).support.sup fun x => x) = degreeOf 0 f := by
Mathlib.Data.MvPolynomial.Equiv.490_0.88gPfxLltQQTcHM
theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R h : f ≠ 0 h₀ : ∀ {α β : Type} (f : α → β), (fun x => x) ∘ f = f h₁ : ∀ {α : Type ?u.1456922} {β : Type ?u.1456925} (f : α → β), (f ∘ fun x => x) = f h₂ : WithBot.some = Nat.cast h' : (Finset.sup (Polynomial.support ((finSuccEquiv R n) f)) fun x => x) = degreeOf 0 f ⊢ degree ((finSuccEquiv R n) f) = ↑(degreeOf 0 f)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail] simp [h.1] #align mv_polynomial.fin_succ_equiv_support' MvPolynomial.finSuccEquiv_support' theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_ let ii := (finSuccEquiv R n).symm calc f = ii (finSuccEquiv R n f) := by simpa only [← AlgEquiv.invFun_eq_symm] using ((finSuccEquiv R n).left_inv f).symm _ = ii 0 := by rw [c] _ = 0 := by simp #align mv_polynomial.support_fin_succ_equiv_nonempty MvPolynomial.support_finSuccEquiv_nonempty theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f := by -- TODO: these should be lemmas have h₀ : ∀ {α β : Type _} (f : α → β), (fun x => x) ∘ f = f := fun f => rfl have h₁ : ∀ {α β : Type _} (f : α → β), f ∘ (fun x => x) = f := fun f => rfl have h₂ : WithBot.some = Nat.cast := rfl have h' : ((finSuccEquiv R n f).support.sup fun x => x) = degreeOf 0 f := by rw [degreeOf_eq_sup, finSuccEquiv_support f, Finset.sup_image, h₀]
rw [Polynomial.degree, ← h', ← h₂, Finset.coe_sup_of_nonempty (support_finSuccEquiv_nonempty h), Finset.max_eq_sup_coe, h₁]
theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f := by -- TODO: these should be lemmas have h₀ : ∀ {α β : Type _} (f : α → β), (fun x => x) ∘ f = f := fun f => rfl have h₁ : ∀ {α β : Type _} (f : α → β), f ∘ (fun x => x) = f := fun f => rfl have h₂ : WithBot.some = Nat.cast := rfl have h' : ((finSuccEquiv R n f).support.sup fun x => x) = degreeOf 0 f := by rw [degreeOf_eq_sup, finSuccEquiv_support f, Finset.sup_image, h₀]
Mathlib.Data.MvPolynomial.Equiv.490_0.88gPfxLltQQTcHM
theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R ⊢ natDegree ((finSuccEquiv R n) f) = degreeOf 0 f
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail] simp [h.1] #align mv_polynomial.fin_succ_equiv_support' MvPolynomial.finSuccEquiv_support' theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_ let ii := (finSuccEquiv R n).symm calc f = ii (finSuccEquiv R n f) := by simpa only [← AlgEquiv.invFun_eq_symm] using ((finSuccEquiv R n).left_inv f).symm _ = ii 0 := by rw [c] _ = 0 := by simp #align mv_polynomial.support_fin_succ_equiv_nonempty MvPolynomial.support_finSuccEquiv_nonempty theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f := by -- TODO: these should be lemmas have h₀ : ∀ {α β : Type _} (f : α → β), (fun x => x) ∘ f = f := fun f => rfl have h₁ : ∀ {α β : Type _} (f : α → β), f ∘ (fun x => x) = f := fun f => rfl have h₂ : WithBot.some = Nat.cast := rfl have h' : ((finSuccEquiv R n f).support.sup fun x => x) = degreeOf 0 f := by rw [degreeOf_eq_sup, finSuccEquiv_support f, Finset.sup_image, h₀] rw [Polynomial.degree, ← h', ← h₂, Finset.coe_sup_of_nonempty (support_finSuccEquiv_nonempty h), Finset.max_eq_sup_coe, h₁] #align mv_polynomial.degree_fin_succ_equiv MvPolynomial.degree_finSuccEquiv theorem natDegree_finSuccEquiv (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).natDegree = degreeOf 0 f := by
by_cases c : f = 0
theorem natDegree_finSuccEquiv (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).natDegree = degreeOf 0 f := by
Mathlib.Data.MvPolynomial.Equiv.503_0.88gPfxLltQQTcHM
theorem natDegree_finSuccEquiv (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).natDegree = degreeOf 0 f
Mathlib_Data_MvPolynomial_Equiv
case pos R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R c : f = 0 ⊢ natDegree ((finSuccEquiv R n) f) = degreeOf 0 f
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail] simp [h.1] #align mv_polynomial.fin_succ_equiv_support' MvPolynomial.finSuccEquiv_support' theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_ let ii := (finSuccEquiv R n).symm calc f = ii (finSuccEquiv R n f) := by simpa only [← AlgEquiv.invFun_eq_symm] using ((finSuccEquiv R n).left_inv f).symm _ = ii 0 := by rw [c] _ = 0 := by simp #align mv_polynomial.support_fin_succ_equiv_nonempty MvPolynomial.support_finSuccEquiv_nonempty theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f := by -- TODO: these should be lemmas have h₀ : ∀ {α β : Type _} (f : α → β), (fun x => x) ∘ f = f := fun f => rfl have h₁ : ∀ {α β : Type _} (f : α → β), f ∘ (fun x => x) = f := fun f => rfl have h₂ : WithBot.some = Nat.cast := rfl have h' : ((finSuccEquiv R n f).support.sup fun x => x) = degreeOf 0 f := by rw [degreeOf_eq_sup, finSuccEquiv_support f, Finset.sup_image, h₀] rw [Polynomial.degree, ← h', ← h₂, Finset.coe_sup_of_nonempty (support_finSuccEquiv_nonempty h), Finset.max_eq_sup_coe, h₁] #align mv_polynomial.degree_fin_succ_equiv MvPolynomial.degree_finSuccEquiv theorem natDegree_finSuccEquiv (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).natDegree = degreeOf 0 f := by by_cases c : f = 0 ·
rw [c, (finSuccEquiv R n).map_zero, Polynomial.natDegree_zero, degreeOf_zero]
theorem natDegree_finSuccEquiv (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).natDegree = degreeOf 0 f := by by_cases c : f = 0 ·
Mathlib.Data.MvPolynomial.Equiv.503_0.88gPfxLltQQTcHM
theorem natDegree_finSuccEquiv (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).natDegree = degreeOf 0 f
Mathlib_Data_MvPolynomial_Equiv
case neg R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R c : ¬f = 0 ⊢ natDegree ((finSuccEquiv R n) f) = degreeOf 0 f
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail] simp [h.1] #align mv_polynomial.fin_succ_equiv_support' MvPolynomial.finSuccEquiv_support' theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_ let ii := (finSuccEquiv R n).symm calc f = ii (finSuccEquiv R n f) := by simpa only [← AlgEquiv.invFun_eq_symm] using ((finSuccEquiv R n).left_inv f).symm _ = ii 0 := by rw [c] _ = 0 := by simp #align mv_polynomial.support_fin_succ_equiv_nonempty MvPolynomial.support_finSuccEquiv_nonempty theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f := by -- TODO: these should be lemmas have h₀ : ∀ {α β : Type _} (f : α → β), (fun x => x) ∘ f = f := fun f => rfl have h₁ : ∀ {α β : Type _} (f : α → β), f ∘ (fun x => x) = f := fun f => rfl have h₂ : WithBot.some = Nat.cast := rfl have h' : ((finSuccEquiv R n f).support.sup fun x => x) = degreeOf 0 f := by rw [degreeOf_eq_sup, finSuccEquiv_support f, Finset.sup_image, h₀] rw [Polynomial.degree, ← h', ← h₂, Finset.coe_sup_of_nonempty (support_finSuccEquiv_nonempty h), Finset.max_eq_sup_coe, h₁] #align mv_polynomial.degree_fin_succ_equiv MvPolynomial.degree_finSuccEquiv theorem natDegree_finSuccEquiv (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).natDegree = degreeOf 0 f := by by_cases c : f = 0 · rw [c, (finSuccEquiv R n).map_zero, Polynomial.natDegree_zero, degreeOf_zero] ·
rw [Polynomial.natDegree, degree_finSuccEquiv (by simpa only [Ne.def] )]
theorem natDegree_finSuccEquiv (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).natDegree = degreeOf 0 f := by by_cases c : f = 0 · rw [c, (finSuccEquiv R n).map_zero, Polynomial.natDegree_zero, degreeOf_zero] ·
Mathlib.Data.MvPolynomial.Equiv.503_0.88gPfxLltQQTcHM
theorem natDegree_finSuccEquiv (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).natDegree = degreeOf 0 f
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R c : ¬f = 0 ⊢ f ≠ 0
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail] simp [h.1] #align mv_polynomial.fin_succ_equiv_support' MvPolynomial.finSuccEquiv_support' theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_ let ii := (finSuccEquiv R n).symm calc f = ii (finSuccEquiv R n f) := by simpa only [← AlgEquiv.invFun_eq_symm] using ((finSuccEquiv R n).left_inv f).symm _ = ii 0 := by rw [c] _ = 0 := by simp #align mv_polynomial.support_fin_succ_equiv_nonempty MvPolynomial.support_finSuccEquiv_nonempty theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f := by -- TODO: these should be lemmas have h₀ : ∀ {α β : Type _} (f : α → β), (fun x => x) ∘ f = f := fun f => rfl have h₁ : ∀ {α β : Type _} (f : α → β), f ∘ (fun x => x) = f := fun f => rfl have h₂ : WithBot.some = Nat.cast := rfl have h' : ((finSuccEquiv R n f).support.sup fun x => x) = degreeOf 0 f := by rw [degreeOf_eq_sup, finSuccEquiv_support f, Finset.sup_image, h₀] rw [Polynomial.degree, ← h', ← h₂, Finset.coe_sup_of_nonempty (support_finSuccEquiv_nonempty h), Finset.max_eq_sup_coe, h₁] #align mv_polynomial.degree_fin_succ_equiv MvPolynomial.degree_finSuccEquiv theorem natDegree_finSuccEquiv (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).natDegree = degreeOf 0 f := by by_cases c : f = 0 · rw [c, (finSuccEquiv R n).map_zero, Polynomial.natDegree_zero, degreeOf_zero] · rw [Polynomial.natDegree, degree_finSuccEquiv (by
simpa only [Ne.def]
theorem natDegree_finSuccEquiv (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).natDegree = degreeOf 0 f := by by_cases c : f = 0 · rw [c, (finSuccEquiv R n).map_zero, Polynomial.natDegree_zero, degreeOf_zero] · rw [Polynomial.natDegree, degree_finSuccEquiv (by
Mathlib.Data.MvPolynomial.Equiv.503_0.88gPfxLltQQTcHM
theorem natDegree_finSuccEquiv (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).natDegree = degreeOf 0 f
Mathlib_Data_MvPolynomial_Equiv
case neg R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R c : ¬f = 0 ⊢ WithBot.unbot' 0 ↑(degreeOf 0 f) = degreeOf 0 f
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail] simp [h.1] #align mv_polynomial.fin_succ_equiv_support' MvPolynomial.finSuccEquiv_support' theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_ let ii := (finSuccEquiv R n).symm calc f = ii (finSuccEquiv R n f) := by simpa only [← AlgEquiv.invFun_eq_symm] using ((finSuccEquiv R n).left_inv f).symm _ = ii 0 := by rw [c] _ = 0 := by simp #align mv_polynomial.support_fin_succ_equiv_nonempty MvPolynomial.support_finSuccEquiv_nonempty theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f := by -- TODO: these should be lemmas have h₀ : ∀ {α β : Type _} (f : α → β), (fun x => x) ∘ f = f := fun f => rfl have h₁ : ∀ {α β : Type _} (f : α → β), f ∘ (fun x => x) = f := fun f => rfl have h₂ : WithBot.some = Nat.cast := rfl have h' : ((finSuccEquiv R n f).support.sup fun x => x) = degreeOf 0 f := by rw [degreeOf_eq_sup, finSuccEquiv_support f, Finset.sup_image, h₀] rw [Polynomial.degree, ← h', ← h₂, Finset.coe_sup_of_nonempty (support_finSuccEquiv_nonempty h), Finset.max_eq_sup_coe, h₁] #align mv_polynomial.degree_fin_succ_equiv MvPolynomial.degree_finSuccEquiv theorem natDegree_finSuccEquiv (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).natDegree = degreeOf 0 f := by by_cases c : f = 0 · rw [c, (finSuccEquiv R n).map_zero, Polynomial.natDegree_zero, degreeOf_zero] · rw [Polynomial.natDegree, degree_finSuccEquiv (by simpa only [Ne.def] )]
erw [WithBot.unbot'_coe]
theorem natDegree_finSuccEquiv (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).natDegree = degreeOf 0 f := by by_cases c : f = 0 · rw [c, (finSuccEquiv R n).map_zero, Polynomial.natDegree_zero, degreeOf_zero] · rw [Polynomial.natDegree, degree_finSuccEquiv (by simpa only [Ne.def] )]
Mathlib.Data.MvPolynomial.Equiv.503_0.88gPfxLltQQTcHM
theorem natDegree_finSuccEquiv (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).natDegree = degreeOf 0 f
Mathlib_Data_MvPolynomial_Equiv
case neg R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ f : MvPolynomial (Fin (n + 1)) R c : ¬f = 0 ⊢ ↑(degreeOf 0 f) = degreeOf 0 f
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail] simp [h.1] #align mv_polynomial.fin_succ_equiv_support' MvPolynomial.finSuccEquiv_support' theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_ let ii := (finSuccEquiv R n).symm calc f = ii (finSuccEquiv R n f) := by simpa only [← AlgEquiv.invFun_eq_symm] using ((finSuccEquiv R n).left_inv f).symm _ = ii 0 := by rw [c] _ = 0 := by simp #align mv_polynomial.support_fin_succ_equiv_nonempty MvPolynomial.support_finSuccEquiv_nonempty theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f := by -- TODO: these should be lemmas have h₀ : ∀ {α β : Type _} (f : α → β), (fun x => x) ∘ f = f := fun f => rfl have h₁ : ∀ {α β : Type _} (f : α → β), f ∘ (fun x => x) = f := fun f => rfl have h₂ : WithBot.some = Nat.cast := rfl have h' : ((finSuccEquiv R n f).support.sup fun x => x) = degreeOf 0 f := by rw [degreeOf_eq_sup, finSuccEquiv_support f, Finset.sup_image, h₀] rw [Polynomial.degree, ← h', ← h₂, Finset.coe_sup_of_nonempty (support_finSuccEquiv_nonempty h), Finset.max_eq_sup_coe, h₁] #align mv_polynomial.degree_fin_succ_equiv MvPolynomial.degree_finSuccEquiv theorem natDegree_finSuccEquiv (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).natDegree = degreeOf 0 f := by by_cases c : f = 0 · rw [c, (finSuccEquiv R n).map_zero, Polynomial.natDegree_zero, degreeOf_zero] · rw [Polynomial.natDegree, degree_finSuccEquiv (by simpa only [Ne.def] )] erw [WithBot.unbot'_coe]
simp
theorem natDegree_finSuccEquiv (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).natDegree = degreeOf 0 f := by by_cases c : f = 0 · rw [c, (finSuccEquiv R n).map_zero, Polynomial.natDegree_zero, degreeOf_zero] · rw [Polynomial.natDegree, degree_finSuccEquiv (by simpa only [Ne.def] )] erw [WithBot.unbot'_coe]
Mathlib.Data.MvPolynomial.Equiv.503_0.88gPfxLltQQTcHM
theorem natDegree_finSuccEquiv (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).natDegree = degreeOf 0 f
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ p : MvPolynomial (Fin (n + 1)) R j : Fin n i : ℕ ⊢ degreeOf j (Polynomial.coeff ((finSuccEquiv R n) p) i) ≤ degreeOf (Fin.succ j) p
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail] simp [h.1] #align mv_polynomial.fin_succ_equiv_support' MvPolynomial.finSuccEquiv_support' theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_ let ii := (finSuccEquiv R n).symm calc f = ii (finSuccEquiv R n f) := by simpa only [← AlgEquiv.invFun_eq_symm] using ((finSuccEquiv R n).left_inv f).symm _ = ii 0 := by rw [c] _ = 0 := by simp #align mv_polynomial.support_fin_succ_equiv_nonempty MvPolynomial.support_finSuccEquiv_nonempty theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f := by -- TODO: these should be lemmas have h₀ : ∀ {α β : Type _} (f : α → β), (fun x => x) ∘ f = f := fun f => rfl have h₁ : ∀ {α β : Type _} (f : α → β), f ∘ (fun x => x) = f := fun f => rfl have h₂ : WithBot.some = Nat.cast := rfl have h' : ((finSuccEquiv R n f).support.sup fun x => x) = degreeOf 0 f := by rw [degreeOf_eq_sup, finSuccEquiv_support f, Finset.sup_image, h₀] rw [Polynomial.degree, ← h', ← h₂, Finset.coe_sup_of_nonempty (support_finSuccEquiv_nonempty h), Finset.max_eq_sup_coe, h₁] #align mv_polynomial.degree_fin_succ_equiv MvPolynomial.degree_finSuccEquiv theorem natDegree_finSuccEquiv (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).natDegree = degreeOf 0 f := by by_cases c : f = 0 · rw [c, (finSuccEquiv R n).map_zero, Polynomial.natDegree_zero, degreeOf_zero] · rw [Polynomial.natDegree, degree_finSuccEquiv (by simpa only [Ne.def] )] erw [WithBot.unbot'_coe] simp #align mv_polynomial.nat_degree_fin_succ_equiv MvPolynomial.natDegree_finSuccEquiv theorem degreeOf_coeff_finSuccEquiv (p : MvPolynomial (Fin (n + 1)) R) (j : Fin n) (i : ℕ) : degreeOf j (Polynomial.coeff (finSuccEquiv R n p) i) ≤ degreeOf j.succ p := by
rw [degreeOf_eq_sup, degreeOf_eq_sup, Finset.sup_le_iff]
theorem degreeOf_coeff_finSuccEquiv (p : MvPolynomial (Fin (n + 1)) R) (j : Fin n) (i : ℕ) : degreeOf j (Polynomial.coeff (finSuccEquiv R n p) i) ≤ degreeOf j.succ p := by
Mathlib.Data.MvPolynomial.Equiv.512_0.88gPfxLltQQTcHM
theorem degreeOf_coeff_finSuccEquiv (p : MvPolynomial (Fin (n + 1)) R) (j : Fin n) (i : ℕ) : degreeOf j (Polynomial.coeff (finSuccEquiv R n p) i) ≤ degreeOf j.succ p
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ p : MvPolynomial (Fin (n + 1)) R j : Fin n i : ℕ ⊢ ∀ b ∈ support (Polynomial.coeff ((finSuccEquiv R n) p) i), b j ≤ Finset.sup (support p) fun m => m (Fin.succ j)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail] simp [h.1] #align mv_polynomial.fin_succ_equiv_support' MvPolynomial.finSuccEquiv_support' theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_ let ii := (finSuccEquiv R n).symm calc f = ii (finSuccEquiv R n f) := by simpa only [← AlgEquiv.invFun_eq_symm] using ((finSuccEquiv R n).left_inv f).symm _ = ii 0 := by rw [c] _ = 0 := by simp #align mv_polynomial.support_fin_succ_equiv_nonempty MvPolynomial.support_finSuccEquiv_nonempty theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f := by -- TODO: these should be lemmas have h₀ : ∀ {α β : Type _} (f : α → β), (fun x => x) ∘ f = f := fun f => rfl have h₁ : ∀ {α β : Type _} (f : α → β), f ∘ (fun x => x) = f := fun f => rfl have h₂ : WithBot.some = Nat.cast := rfl have h' : ((finSuccEquiv R n f).support.sup fun x => x) = degreeOf 0 f := by rw [degreeOf_eq_sup, finSuccEquiv_support f, Finset.sup_image, h₀] rw [Polynomial.degree, ← h', ← h₂, Finset.coe_sup_of_nonempty (support_finSuccEquiv_nonempty h), Finset.max_eq_sup_coe, h₁] #align mv_polynomial.degree_fin_succ_equiv MvPolynomial.degree_finSuccEquiv theorem natDegree_finSuccEquiv (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).natDegree = degreeOf 0 f := by by_cases c : f = 0 · rw [c, (finSuccEquiv R n).map_zero, Polynomial.natDegree_zero, degreeOf_zero] · rw [Polynomial.natDegree, degree_finSuccEquiv (by simpa only [Ne.def] )] erw [WithBot.unbot'_coe] simp #align mv_polynomial.nat_degree_fin_succ_equiv MvPolynomial.natDegree_finSuccEquiv theorem degreeOf_coeff_finSuccEquiv (p : MvPolynomial (Fin (n + 1)) R) (j : Fin n) (i : ℕ) : degreeOf j (Polynomial.coeff (finSuccEquiv R n p) i) ≤ degreeOf j.succ p := by rw [degreeOf_eq_sup, degreeOf_eq_sup, Finset.sup_le_iff]
intro m hm
theorem degreeOf_coeff_finSuccEquiv (p : MvPolynomial (Fin (n + 1)) R) (j : Fin n) (i : ℕ) : degreeOf j (Polynomial.coeff (finSuccEquiv R n p) i) ≤ degreeOf j.succ p := by rw [degreeOf_eq_sup, degreeOf_eq_sup, Finset.sup_le_iff]
Mathlib.Data.MvPolynomial.Equiv.512_0.88gPfxLltQQTcHM
theorem degreeOf_coeff_finSuccEquiv (p : MvPolynomial (Fin (n + 1)) R) (j : Fin n) (i : ℕ) : degreeOf j (Polynomial.coeff (finSuccEquiv R n p) i) ≤ degreeOf j.succ p
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ p : MvPolynomial (Fin (n + 1)) R j : Fin n i : ℕ m : Fin n →₀ ℕ hm : m ∈ support (Polynomial.coeff ((finSuccEquiv R n) p) i) ⊢ m j ≤ Finset.sup (support p) fun m => m (Fin.succ j)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail] simp [h.1] #align mv_polynomial.fin_succ_equiv_support' MvPolynomial.finSuccEquiv_support' theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_ let ii := (finSuccEquiv R n).symm calc f = ii (finSuccEquiv R n f) := by simpa only [← AlgEquiv.invFun_eq_symm] using ((finSuccEquiv R n).left_inv f).symm _ = ii 0 := by rw [c] _ = 0 := by simp #align mv_polynomial.support_fin_succ_equiv_nonempty MvPolynomial.support_finSuccEquiv_nonempty theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f := by -- TODO: these should be lemmas have h₀ : ∀ {α β : Type _} (f : α → β), (fun x => x) ∘ f = f := fun f => rfl have h₁ : ∀ {α β : Type _} (f : α → β), f ∘ (fun x => x) = f := fun f => rfl have h₂ : WithBot.some = Nat.cast := rfl have h' : ((finSuccEquiv R n f).support.sup fun x => x) = degreeOf 0 f := by rw [degreeOf_eq_sup, finSuccEquiv_support f, Finset.sup_image, h₀] rw [Polynomial.degree, ← h', ← h₂, Finset.coe_sup_of_nonempty (support_finSuccEquiv_nonempty h), Finset.max_eq_sup_coe, h₁] #align mv_polynomial.degree_fin_succ_equiv MvPolynomial.degree_finSuccEquiv theorem natDegree_finSuccEquiv (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).natDegree = degreeOf 0 f := by by_cases c : f = 0 · rw [c, (finSuccEquiv R n).map_zero, Polynomial.natDegree_zero, degreeOf_zero] · rw [Polynomial.natDegree, degree_finSuccEquiv (by simpa only [Ne.def] )] erw [WithBot.unbot'_coe] simp #align mv_polynomial.nat_degree_fin_succ_equiv MvPolynomial.natDegree_finSuccEquiv theorem degreeOf_coeff_finSuccEquiv (p : MvPolynomial (Fin (n + 1)) R) (j : Fin n) (i : ℕ) : degreeOf j (Polynomial.coeff (finSuccEquiv R n p) i) ≤ degreeOf j.succ p := by rw [degreeOf_eq_sup, degreeOf_eq_sup, Finset.sup_le_iff] intro m hm
rw [← Finsupp.cons_succ j i m]
theorem degreeOf_coeff_finSuccEquiv (p : MvPolynomial (Fin (n + 1)) R) (j : Fin n) (i : ℕ) : degreeOf j (Polynomial.coeff (finSuccEquiv R n p) i) ≤ degreeOf j.succ p := by rw [degreeOf_eq_sup, degreeOf_eq_sup, Finset.sup_le_iff] intro m hm
Mathlib.Data.MvPolynomial.Equiv.512_0.88gPfxLltQQTcHM
theorem degreeOf_coeff_finSuccEquiv (p : MvPolynomial (Fin (n + 1)) R) (j : Fin n) (i : ℕ) : degreeOf j (Polynomial.coeff (finSuccEquiv R n p) i) ≤ degreeOf j.succ p
Mathlib_Data_MvPolynomial_Equiv
R : Type u S₁ : Type v S₂ : Type w S₃ : Type x σ : Type u_1 a a' a₁ a₂ : R e : ℕ s : σ →₀ ℕ inst✝ : CommSemiring R n : ℕ p : MvPolynomial (Fin (n + 1)) R j : Fin n i : ℕ m : Fin n →₀ ℕ hm : m ∈ support (Polynomial.coeff ((finSuccEquiv R n) p) i) ⊢ (cons i m) (Fin.succ j) ≤ Finset.sup (support p) fun m => m (Fin.succ j)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Data.MvPolynomial.Rename import Mathlib.Data.Polynomial.AlgebraMap import Mathlib.Data.MvPolynomial.Variables import Mathlib.Data.Finsupp.Fin import Mathlib.Logic.Equiv.Fin import Mathlib.Algebra.BigOperators.Fin #align_import data.mv_polynomial.equiv from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Equivalences between polynomial rings This file establishes a number of equivalences between polynomial rings, based on equivalences between the underlying types. ## Notation As in other polynomial files, we typically use the notation: + `σ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `a : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` ## Tags equivalence, isomorphism, morphism, ring hom, hom -/ noncomputable section open BigOperators Polynomial Set Function Finsupp AddMonoidAlgebra universe u v w x variable {R : Type u} {S₁ : Type v} {S₂ : Type w} {S₃ : Type x} namespace MvPolynomial variable {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {s : σ →₀ ℕ} section Equiv variable (R) [CommSemiring R] /-- The ring isomorphism between multivariable polynomials in a single variable and polynomials over the ground ring. -/ @[simps] def pUnitAlgEquiv : MvPolynomial PUnit R ≃ₐ[R] R[X] where toFun := eval₂ Polynomial.C fun _ => Polynomial.X invFun := Polynomial.eval₂ MvPolynomial.C (X PUnit.unit) left_inv := by let f : R[X] →+* MvPolynomial PUnit R := Polynomial.eval₂RingHom MvPolynomial.C (X PUnit.unit) let g : MvPolynomial PUnit R →+* R[X] := eval₂Hom Polynomial.C fun _ => Polynomial.X show ∀ p, f.comp g p = p apply is_id · ext a dsimp rw [eval₂_C, Polynomial.eval₂_C] · rintro ⟨⟩ dsimp rw [eval₂_X, Polynomial.eval₂_X] right_inv p := Polynomial.induction_on p (fun a => by rw [Polynomial.eval₂_C, MvPolynomial.eval₂_C]) (fun p q hp hq => by rw [Polynomial.eval₂_add, MvPolynomial.eval₂_add, hp, hq]) fun p n _ => by rw [Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, eval₂_mul, eval₂_C, eval₂_pow, eval₂_X] map_mul' _ _ := eval₂_mul _ _ map_add' _ _ := eval₂_add _ _ commutes' _ := eval₂_C _ _ _ #align mv_polynomial.punit_alg_equiv MvPolynomial.pUnitAlgEquiv section Map variable {R} (σ) /-- If `e : A ≃+* B` is an isomorphism of rings, then so is `map e`. -/ @[simps apply] def mapEquiv [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : MvPolynomial σ S₁ ≃+* MvPolynomial σ S₂ := { map (e : S₁ →+* S₂) with toFun := map (e : S₁ →+* S₂) invFun := map (e.symm : S₂ →+* S₁) left_inv := map_leftInverse e.left_inv right_inv := map_rightInverse e.right_inv } #align mv_polynomial.map_equiv MvPolynomial.mapEquiv @[simp] theorem mapEquiv_refl : mapEquiv σ (RingEquiv.refl R) = RingEquiv.refl _ := RingEquiv.ext map_id #align mv_polynomial.map_equiv_refl MvPolynomial.mapEquiv_refl @[simp] theorem mapEquiv_symm [CommSemiring S₁] [CommSemiring S₂] (e : S₁ ≃+* S₂) : (mapEquiv σ e).symm = mapEquiv σ e.symm := rfl #align mv_polynomial.map_equiv_symm MvPolynomial.mapEquiv_symm @[simp] theorem mapEquiv_trans [CommSemiring S₁] [CommSemiring S₂] [CommSemiring S₃] (e : S₁ ≃+* S₂) (f : S₂ ≃+* S₃) : (mapEquiv σ e).trans (mapEquiv σ f) = mapEquiv σ (e.trans f) := RingEquiv.ext fun p => by simp only [RingEquiv.coe_trans, comp_apply, mapEquiv_apply, RingEquiv.coe_ringHom_trans, map_map] #align mv_polynomial.map_equiv_trans MvPolynomial.mapEquiv_trans variable {A₁ A₂ A₃ : Type*} [CommSemiring A₁] [CommSemiring A₂] [CommSemiring A₃] variable [Algebra R A₁] [Algebra R A₂] [Algebra R A₃] /-- If `e : A ≃ₐ[R] B` is an isomorphism of `R`-algebras, then so is `map e`. -/ @[simps apply] def mapAlgEquiv (e : A₁ ≃ₐ[R] A₂) : MvPolynomial σ A₁ ≃ₐ[R] MvPolynomial σ A₂ := { mapAlgHom (e : A₁ →ₐ[R] A₂), mapEquiv σ (e : A₁ ≃+* A₂) with toFun := map (e : A₁ →+* A₂) } #align mv_polynomial.map_alg_equiv MvPolynomial.mapAlgEquiv @[simp] theorem mapAlgEquiv_refl : mapAlgEquiv σ (AlgEquiv.refl : A₁ ≃ₐ[R] A₁) = AlgEquiv.refl := AlgEquiv.ext map_id #align mv_polynomial.map_alg_equiv_refl MvPolynomial.mapAlgEquiv_refl @[simp] theorem mapAlgEquiv_symm (e : A₁ ≃ₐ[R] A₂) : (mapAlgEquiv σ e).symm = mapAlgEquiv σ e.symm := rfl #align mv_polynomial.map_alg_equiv_symm MvPolynomial.mapAlgEquiv_symm @[simp] theorem mapAlgEquiv_trans (e : A₁ ≃ₐ[R] A₂) (f : A₂ ≃ₐ[R] A₃) : (mapAlgEquiv σ e).trans (mapAlgEquiv σ f) = mapAlgEquiv σ (e.trans f) := by ext simp only [AlgEquiv.trans_apply, mapAlgEquiv_apply, map_map] rfl #align mv_polynomial.map_alg_equiv_trans MvPolynomial.mapAlgEquiv_trans end Map section variable (S₁ S₂ S₃) /-- The function from multivariable polynomials in a sum of two types, to multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. See `sumRingEquiv` for the ring isomorphism. -/ def sumToIter : MvPolynomial (Sum S₁ S₂) R →+* MvPolynomial S₁ (MvPolynomial S₂ R) := eval₂Hom (C.comp C) fun bc => Sum.recOn bc X (C ∘ X) #align mv_polynomial.sum_to_iter MvPolynomial.sumToIter @[simp] theorem sumToIter_C (a : R) : sumToIter R S₁ S₂ (C a) = C (C a) := eval₂_C _ _ a set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_C MvPolynomial.sumToIter_C @[simp] theorem sumToIter_Xl (b : S₁) : sumToIter R S₁ S₂ (X (Sum.inl b)) = X b := eval₂_X _ _ (Sum.inl b) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xl MvPolynomial.sumToIter_Xl @[simp] theorem sumToIter_Xr (c : S₂) : sumToIter R S₁ S₂ (X (Sum.inr c)) = C (X c) := eval₂_X _ _ (Sum.inr c) set_option linter.uppercaseLean3 false in #align mv_polynomial.sum_to_iter_Xr MvPolynomial.sumToIter_Xr /-- The function from multivariable polynomials in one type, with coefficients in multivariable polynomials in another type, to multivariable polynomials in the sum of the two types. See `sumRingEquiv` for the ring isomorphism. -/ def iterToSum : MvPolynomial S₁ (MvPolynomial S₂ R) →+* MvPolynomial (Sum S₁ S₂) R := eval₂Hom (eval₂Hom C (X ∘ Sum.inr)) (X ∘ Sum.inl) #align mv_polynomial.iter_to_sum MvPolynomial.iterToSum theorem iterToSum_C_C (a : R) : iterToSum R S₁ S₂ (C (C a)) = C a := Eq.trans (eval₂_C _ _ (C a)) (eval₂_C _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_C MvPolynomial.iterToSum_C_C theorem iterToSum_X (b : S₁) : iterToSum R S₁ S₂ (X b) = X (Sum.inl b) := eval₂_X _ _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_X MvPolynomial.iterToSum_X theorem iterToSum_C_X (c : S₂) : iterToSum R S₁ S₂ (C (X c)) = X (Sum.inr c) := Eq.trans (eval₂_C _ _ (X c)) (eval₂_X _ _ _) set_option linter.uppercaseLean3 false in #align mv_polynomial.iter_to_sum_C_X MvPolynomial.iterToSum_C_X variable (σ) /-- The algebra isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyAlgEquiv [he : IsEmpty σ] : MvPolynomial σ R ≃ₐ[R] R := AlgEquiv.ofAlgHom (aeval (IsEmpty.elim he)) (Algebra.ofId _ _) (by ext) (by ext i m exact IsEmpty.elim' he i) #align mv_polynomial.is_empty_alg_equiv MvPolynomial.isEmptyAlgEquiv /-- The ring isomorphism between multivariable polynomials in no variables and the ground ring. -/ @[simps!] def isEmptyRingEquiv [IsEmpty σ] : MvPolynomial σ R ≃+* R := (isEmptyAlgEquiv R σ).toRingEquiv #align mv_polynomial.is_empty_ring_equiv MvPolynomial.isEmptyRingEquiv variable {σ} /-- A helper function for `sumRingEquiv`. -/ @[simps] def mvPolynomialEquivMvPolynomial [CommSemiring S₃] (f : MvPolynomial S₁ R →+* MvPolynomial S₂ S₃) (g : MvPolynomial S₂ S₃ →+* MvPolynomial S₁ R) (hfgC : (f.comp g).comp C = C) (hfgX : ∀ n, f (g (X n)) = X n) (hgfC : (g.comp f).comp C = C) (hgfX : ∀ n, g (f (X n)) = X n) : MvPolynomial S₁ R ≃+* MvPolynomial S₂ S₃ where toFun := f invFun := g left_inv := is_id (RingHom.comp _ _) hgfC hgfX right_inv := is_id (RingHom.comp _ _) hfgC hfgX map_mul' := f.map_mul map_add' := f.map_add #align mv_polynomial.mv_polynomial_equiv_mv_polynomial MvPolynomial.mvPolynomialEquivMvPolynomial /-- The ring isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumRingEquiv : MvPolynomial (Sum S₁ S₂) R ≃+* MvPolynomial S₁ (MvPolynomial S₂ R) := by apply mvPolynomialEquivMvPolynomial R (Sum S₁ S₂) _ _ (sumToIter R S₁ S₂) (iterToSum R S₁ S₂) · refine RingHom.ext (hom_eq_hom _ _ ?hC ?hX) case hC => ext1; simp only [RingHom.comp_apply, iterToSum_C_C, sumToIter_C] case hX => intro; simp only [RingHom.comp_apply, iterToSum_C_X, sumToIter_Xr] · simp [iterToSum_X, sumToIter_Xl] · ext1; simp only [RingHom.comp_apply, sumToIter_C, iterToSum_C_C] · rintro ⟨⟩ <;> simp only [sumToIter_Xl, iterToSum_X, sumToIter_Xr, iterToSum_C_X] #align mv_polynomial.sum_ring_equiv MvPolynomial.sumRingEquiv /-- The algebra isomorphism between multivariable polynomials in a sum of two types, and multivariable polynomials in one of the types, with coefficients in multivariable polynomials in the other type. -/ def sumAlgEquiv : MvPolynomial (Sum S₁ S₂) R ≃ₐ[R] MvPolynomial S₁ (MvPolynomial S₂ R) := { sumRingEquiv R S₁ S₂ with commutes' := by intro r have A : algebraMap R (MvPolynomial S₁ (MvPolynomial S₂ R)) r = (C (C r) : _) := rfl have B : algebraMap R (MvPolynomial (Sum S₁ S₂) R) r = C r := rfl simp only [sumRingEquiv, mvPolynomialEquivMvPolynomial, Equiv.toFun_as_coe, Equiv.coe_fn_mk, B, sumToIter_C, A] } #align mv_polynomial.sum_alg_equiv MvPolynomial.sumAlgEquiv section -- this speeds up typeclass search in the lemma below attribute [local instance] IsScalarTower.right /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and polynomials with coefficients in `MvPolynomial S₁ R`. -/ @[simps!] 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) #align mv_polynomial.option_equiv_left MvPolynomial.optionEquivLeft end /-- The algebra isomorphism between multivariable polynomials in `Option S₁` and multivariable polynomials with coefficients in polynomials. -/ def optionEquivRight : MvPolynomial (Option S₁) R ≃ₐ[R] MvPolynomial S₁ R[X] := AlgEquiv.ofAlgHom (MvPolynomial.aeval fun o => o.elim (C Polynomial.X) X) (MvPolynomial.aevalTower (Polynomial.aeval (X none)) fun i => X (Option.some i)) (by ext : 2 <;> simp only [MvPolynomial.algebraMap_eq, Option.elim, AlgHom.coe_comp, AlgHom.id_comp, IsScalarTower.coe_toAlgHom', comp_apply, aevalTower_C, Polynomial.aeval_X, aeval_X, Option.elim', aevalTower_X, AlgHom.coe_id, id.def, eq_self_iff_true, imp_true_iff]) (by ext ⟨i⟩ : 2 <;> simp only [Option.elim, AlgHom.coe_comp, comp_apply, aeval_X, aevalTower_C, Polynomial.aeval_X, AlgHom.coe_id, id.def, aevalTower_X]) #align mv_polynomial.option_equiv_right MvPolynomial.optionEquivRight variable (n : ℕ) /-- The algebra isomorphism between multivariable polynomials in `Fin (n + 1)` and polynomials over multivariable polynomials in `Fin n`. -/ def finSuccEquiv : MvPolynomial (Fin (n + 1)) R ≃ₐ[R] Polynomial (MvPolynomial (Fin n) R) := (renameEquiv R (_root_.finSuccEquiv n)).trans (optionEquivLeft R (Fin n)) #align mv_polynomial.fin_succ_equiv MvPolynomial.finSuccEquiv theorem finSuccEquiv_eq : (finSuccEquiv R n : MvPolynomial (Fin (n + 1)) R →+* Polynomial (MvPolynomial (Fin n) R)) = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i := by ext i : 2 · simp only [finSuccEquiv, optionEquivLeft_apply, aeval_C, AlgEquiv.coe_trans, RingHom.coe_coe, coe_eval₂Hom, comp_apply, renameEquiv_apply, eval₂_C, RingHom.coe_comp, rename_C] rfl · refine' Fin.cases _ _ i <;> simp [finSuccEquiv] #align mv_polynomial.fin_succ_equiv_eq MvPolynomial.finSuccEquiv_eq @[simp] theorem finSuccEquiv_apply (p : MvPolynomial (Fin (n + 1)) R) : finSuccEquiv R n p = eval₂Hom (Polynomial.C.comp (C : R →+* MvPolynomial (Fin n) R)) (fun i : Fin (n + 1) => Fin.cases Polynomial.X (fun k => Polynomial.C (X k)) i) p := by rw [← finSuccEquiv_eq, RingHom.coe_coe] #align mv_polynomial.fin_succ_equiv_apply MvPolynomial.finSuccEquiv_apply theorem finSuccEquiv_comp_C_eq_C {R : Type u} [CommSemiring R] (n : ℕ) : (↑(MvPolynomial.finSuccEquiv R n).symm : Polynomial (MvPolynomial (Fin n) R) →+* _).comp (Polynomial.C.comp MvPolynomial.C) = (MvPolynomial.C : R →+* MvPolynomial (Fin n.succ) R) := by refine' RingHom.ext fun x => _ rw [RingHom.comp_apply] refine' (MvPolynomial.finSuccEquiv R n).injective (Trans.trans ((MvPolynomial.finSuccEquiv R n).apply_symm_apply _) _) simp only [MvPolynomial.finSuccEquiv_apply, MvPolynomial.eval₂Hom_C] set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_comp_C_eq_C MvPolynomial.finSuccEquiv_comp_C_eq_C variable {n} {R} theorem finSuccEquiv_X_zero : finSuccEquiv R n (X 0) = Polynomial.X := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_zero MvPolynomial.finSuccEquiv_X_zero theorem finSuccEquiv_X_succ {j : Fin n} : finSuccEquiv R n (X j.succ) = Polynomial.C (X j) := by simp set_option linter.uppercaseLean3 false in #align mv_polynomial.fin_succ_equiv_X_succ MvPolynomial.finSuccEquiv_X_succ /-- The coefficient of `m` in the `i`-th coefficient of `finSuccEquiv R n f` equals the coefficient of `Finsupp.cons i m` in `f`. -/ theorem finSuccEquiv_coeff_coeff (m : Fin n →₀ ℕ) (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) : coeff m (Polynomial.coeff (finSuccEquiv R n f) i) = coeff (m.cons i) f := by induction' f using MvPolynomial.induction_on' with j r p q hp hq generalizing i m swap · simp only [(finSuccEquiv R n).map_add, Polynomial.coeff_add, coeff_add, hp, hq] simp only [finSuccEquiv_apply, coe_eval₂Hom, eval₂_monomial, RingHom.coe_comp, prod_pow, Polynomial.coeff_C_mul, coeff_C_mul, coeff_monomial, Fin.prod_univ_succ, Fin.cases_zero, Fin.cases_succ, ← map_prod, ← RingHom.map_pow, Function.comp_apply] rw [← mul_boole, mul_comm (Polynomial.X ^ j 0), Polynomial.coeff_C_mul_X_pow]; congr 1 obtain rfl | hjmi := eq_or_ne j (m.cons i) · simpa only [cons_zero, cons_succ, if_pos rfl, monomial_eq, C_1, one_mul, prod_pow] using coeff_monomial m m (1 : R) · simp only [hjmi, if_false] obtain hij | rfl := ne_or_eq i (j 0) · simp only [hij, if_false, coeff_zero] simp only [eq_self_iff_true, if_true] have hmj : m ≠ j.tail := by rintro rfl rw [cons_tail] at hjmi contradiction simpa only [monomial_eq, C_1, one_mul, prod_pow, Finsupp.tail_apply, if_neg hmj.symm] using coeff_monomial m j.tail (1 : R) #align mv_polynomial.fin_succ_equiv_coeff_coeff MvPolynomial.finSuccEquiv_coeff_coeff theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin (n + 1)) R) : eval (Fin.cons y s : Fin (n + 1) → R) f = Polynomial.eval y (Polynomial.map (eval s) (finSuccEquiv R n f)) := by -- turn this into a def `Polynomial.mapAlgHom` let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by convert Polynomial.map_C (eval s) exact (eval_C _).symm } show aeval (Fin.cons y s : Fin (n + 1) → R) f = (Polynomial.aeval y).comp (φ.comp (finSuccEquiv R n).toAlgHom) f congr 2 apply MvPolynomial.algHom_ext rw [Fin.forall_fin_succ] simp only [aeval_X, Fin.cons_zero, AlgEquiv.toAlgHom_eq_coe, AlgHom.coe_comp, Polynomial.coe_aeval_eq_eval, Polynomial.map_C, AlgHom.coe_mk, RingHom.toFun_eq_coe, Polynomial.coe_mapRingHom, comp_apply, finSuccEquiv_apply, eval₂Hom_X', Fin.cases_zero, Polynomial.map_X, Polynomial.eval_X, Fin.cons_succ, Fin.cases_succ, eval_X, Polynomial.eval_C, RingHom.coe_mk, MonoidHom.coe_coe, AlgHom.coe_coe, implies_true, and_self, RingHom.toMonoidHom_eq_coe] #align mv_polynomial.eval_eq_eval_mv_eval' MvPolynomial.eval_eq_eval_mv_eval' theorem coeff_eval_eq_eval_coeff (s' : Fin n → R) (f : Polynomial (MvPolynomial (Fin n) R)) (i : ℕ) : Polynomial.coeff (Polynomial.map (eval s') f) i = eval s' (Polynomial.coeff f i) := by simp only [Polynomial.coeff_map] #align mv_polynomial.coeff_eval_eq_eval_coeff MvPolynomial.coeff_eval_eq_eval_coeff theorem support_coeff_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} {m : Fin n →₀ ℕ} : m ∈ (Polynomial.coeff ((finSuccEquiv R n) f) i).support ↔ Finsupp.cons i m ∈ f.support := by apply Iff.intro · intro h simpa [← finSuccEquiv_coeff_coeff] using h · intro h simpa [mem_support_iff, ← finSuccEquiv_coeff_coeff m f i] using h #align mv_polynomial.support_coeff_fin_succ_equiv MvPolynomial.support_coeff_finSuccEquiv /-- The `totalDegree` of a multivariable polynomial `p` is at least `i` more than the `totalDegree` of the `i`th coefficient of `finSuccEquiv` applied to `p`, if this is nonzero. -/ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) (i : ℕ) (hi : (finSuccEquiv R n f).coeff i ≠ 0) : totalDegree ((finSuccEquiv R n f).coeff i) + i ≤ totalDegree f := by have hf'_sup : ((finSuccEquiv R n f).coeff i).support.Nonempty := by rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty] exact hi -- Let σ be a monomial index of ((finSuccEquiv R n p).coeff i) of maximal total degree have ⟨σ, hσ1, hσ2⟩ := Finset.exists_mem_eq_sup (support _) hf'_sup (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n+1) →₀ ℕ := cons i σ convert le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← support_coeff_finSuccEquiv] exact hσ1 theorem finSuccEquiv_support (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).support = Finset.image (fun m : Fin (n + 1) →₀ ℕ => m 0) f.support := by ext i rw [Polynomial.mem_support_iff, Finset.mem_image, Finsupp.ne_iff] constructor · rintro ⟨m, hm⟩ refine' ⟨cons i m, _, cons_zero _ _⟩ rw [← support_coeff_finSuccEquiv] simpa using hm · rintro ⟨m, h, rfl⟩ refine' ⟨tail m, _⟩ rwa [← coeff, zero_apply, ← mem_support_iff, support_coeff_finSuccEquiv, cons_tail] #align mv_polynomial.fin_succ_equiv_support MvPolynomial.finSuccEquiv_support theorem finSuccEquiv_support' {f : MvPolynomial (Fin (n + 1)) R} {i : ℕ} : Finset.image (Finsupp.cons i) (Polynomial.coeff ((finSuccEquiv R n) f) i).support = f.support.filter fun m => m 0 = i := by ext m rw [Finset.mem_filter, Finset.mem_image, mem_support_iff] conv_lhs => congr ext rw [mem_support_iff, finSuccEquiv_coeff_coeff, Ne.def] constructor · rintro ⟨m', ⟨h, hm'⟩⟩ simp only [← hm'] exact ⟨h, by rw [cons_zero]⟩ · intro h use tail m rw [← h.2, cons_tail] simp [h.1] #align mv_polynomial.fin_succ_equiv_support' MvPolynomial.finSuccEquiv_support' theorem support_finSuccEquiv_nonempty {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).support.Nonempty := by simp only [Finset.nonempty_iff_ne_empty, Ne, Polynomial.support_eq_empty] refine fun c => h ?_ let ii := (finSuccEquiv R n).symm calc f = ii (finSuccEquiv R n f) := by simpa only [← AlgEquiv.invFun_eq_symm] using ((finSuccEquiv R n).left_inv f).symm _ = ii 0 := by rw [c] _ = 0 := by simp #align mv_polynomial.support_fin_succ_equiv_nonempty MvPolynomial.support_finSuccEquiv_nonempty theorem degree_finSuccEquiv {f : MvPolynomial (Fin (n + 1)) R} (h : f ≠ 0) : (finSuccEquiv R n f).degree = degreeOf 0 f := by -- TODO: these should be lemmas have h₀ : ∀ {α β : Type _} (f : α → β), (fun x => x) ∘ f = f := fun f => rfl have h₁ : ∀ {α β : Type _} (f : α → β), f ∘ (fun x => x) = f := fun f => rfl have h₂ : WithBot.some = Nat.cast := rfl have h' : ((finSuccEquiv R n f).support.sup fun x => x) = degreeOf 0 f := by rw [degreeOf_eq_sup, finSuccEquiv_support f, Finset.sup_image, h₀] rw [Polynomial.degree, ← h', ← h₂, Finset.coe_sup_of_nonempty (support_finSuccEquiv_nonempty h), Finset.max_eq_sup_coe, h₁] #align mv_polynomial.degree_fin_succ_equiv MvPolynomial.degree_finSuccEquiv theorem natDegree_finSuccEquiv (f : MvPolynomial (Fin (n + 1)) R) : (finSuccEquiv R n f).natDegree = degreeOf 0 f := by by_cases c : f = 0 · rw [c, (finSuccEquiv R n).map_zero, Polynomial.natDegree_zero, degreeOf_zero] · rw [Polynomial.natDegree, degree_finSuccEquiv (by simpa only [Ne.def] )] erw [WithBot.unbot'_coe] simp #align mv_polynomial.nat_degree_fin_succ_equiv MvPolynomial.natDegree_finSuccEquiv theorem degreeOf_coeff_finSuccEquiv (p : MvPolynomial (Fin (n + 1)) R) (j : Fin n) (i : ℕ) : degreeOf j (Polynomial.coeff (finSuccEquiv R n p) i) ≤ degreeOf j.succ p := by rw [degreeOf_eq_sup, degreeOf_eq_sup, Finset.sup_le_iff] intro m hm rw [← Finsupp.cons_succ j i m]
exact Finset.le_sup (f := fun (g : Fin (Nat.succ n) →₀ ℕ) => g (Fin.succ j)) (support_coeff_finSuccEquiv.1 hm)
theorem degreeOf_coeff_finSuccEquiv (p : MvPolynomial (Fin (n + 1)) R) (j : Fin n) (i : ℕ) : degreeOf j (Polynomial.coeff (finSuccEquiv R n p) i) ≤ degreeOf j.succ p := by rw [degreeOf_eq_sup, degreeOf_eq_sup, Finset.sup_le_iff] intro m hm rw [← Finsupp.cons_succ j i m]
Mathlib.Data.MvPolynomial.Equiv.512_0.88gPfxLltQQTcHM
theorem degreeOf_coeff_finSuccEquiv (p : MvPolynomial (Fin (n + 1)) R) (j : Fin n) (i : ℕ) : degreeOf j (Polynomial.coeff (finSuccEquiv R n p) i) ≤ degreeOf j.succ p
Mathlib_Data_MvPolynomial_Equiv
C : Type u inst✝² : Category.{v, u} C inst✝¹ : HasColimits C X Y Z : TopCat F : Presheaf C X U V : Opens ↑X i : U ⟶ V x : ↥U inst✝ : ConcreteCategory C s : (forget C).obj (F.obj (op V)) ⊢ (germ F x) ((F.map i.op) s) = (germ F ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑V) }) x)) s
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by
rw [← comp_apply, germ_res]
theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by
Mathlib.Topology.Sheaves.Stalks.114_0.hsVUPKIHRY0xmFk
theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s
Mathlib_Topology_Sheaves_Stalks
C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y✝ Z : TopCat F : Presheaf C X x : ↑X Y : C f₁ f₂ : stalk F x ⟶ Y ih : ∀ (U : Opens ↑X) (hxU : x ∈ U), germ F { val := x, property := hxU } ≫ f₁ = germ F { val := x, property := hxU } ≫ f₂ U : (OpenNhds x)ᵒᵖ ⊢ colimit.ι (((whiskeringLeft (OpenNhds x)ᵒᵖ (Opens ↑X)ᵒᵖ C).obj (OpenNhds.inclusion x).op).obj F) U ≫ f₁ = colimit.ι (((whiskeringLeft (OpenNhds x)ᵒᵖ (Opens ↑X)ᵒᵖ C).obj (OpenNhds.inclusion x).op).obj F) U ≫ f₂
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by
induction' U using Opposite.rec with U
/-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by
Mathlib.Topology.Sheaves.Stalks.119_0.hsVUPKIHRY0xmFk
/-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂
Mathlib_Topology_Sheaves_Stalks
case mk C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y✝ Z : TopCat F : Presheaf C X x : ↑X Y : C f₁ f₂ : stalk F x ⟶ Y ih : ∀ (U : Opens ↑X) (hxU : x ∈ U), germ F { val := x, property := hxU } ≫ f₁ = germ F { val := x, property := hxU } ≫ f₂ U : OpenNhds x ⊢ colimit.ι (((whiskeringLeft (OpenNhds x)ᵒᵖ (Opens ↑X)ᵒᵖ C).obj (OpenNhds.inclusion x).op).obj F) { unop := U } ≫ f₁ = colimit.ι (((whiskeringLeft (OpenNhds x)ᵒᵖ (Opens ↑X)ᵒᵖ C).obj (OpenNhds.inclusion x).op).obj F) { unop := U } ≫ f₂
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U;
cases' U with U hxU
/-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U;
Mathlib.Topology.Sheaves.Stalks.119_0.hsVUPKIHRY0xmFk
/-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂
Mathlib_Topology_Sheaves_Stalks
case mk.mk C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y✝ Z : TopCat F : Presheaf C X x : ↑X Y : C f₁ f₂ : stalk F x ⟶ Y ih : ∀ (U : Opens ↑X) (hxU : x ∈ U), germ F { val := x, property := hxU } ≫ f₁ = germ F { val := x, property := hxU } ≫ f₂ U : Opens ↑X hxU : x ∈ U ⊢ colimit.ι (((whiskeringLeft (OpenNhds x)ᵒᵖ (Opens ↑X)ᵒᵖ C).obj (OpenNhds.inclusion x).op).obj F) { unop := { obj := U, property := hxU } } ≫ f₁ = colimit.ι (((whiskeringLeft (OpenNhds x)ᵒᵖ (Opens ↑X)ᵒᵖ C).obj (OpenNhds.inclusion x).op).obj F) { unop := { obj := U, property := hxU } } ≫ f₂
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU;
exact ih U hxU
/-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU;
Mathlib.Topology.Sheaves.Stalks.119_0.hsVUPKIHRY0xmFk
/-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂
Mathlib_Topology_Sheaves_Stalks
C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y Z : TopCat f : X ⟶ Y F : Presheaf C X x : ↑X ⊢ stalk (f _* F) (f x) ⟶ stalk F x
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU; exact ih U hxU set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_hom_ext TopCat.Presheaf.stalk_hom_ext @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : U) (f : F ⟶ G) : germ F x ≫ (stalkFunctor C x.1).map f = f.app (op U) ≫ germ G x := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x.1).op f) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_map_germ TopCat.Presheaf.stalkFunctor_map_germ variable (C) /-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing.
refine' ?_ ≫ colimit.pre _ (OpenNhds.map f x).op
/-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing.
Mathlib.Topology.Sheaves.Stalks.139_0.hsVUPKIHRY0xmFk
/-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x
Mathlib_Topology_Sheaves_Stalks
C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y Z : TopCat f : X ⟶ Y F : Presheaf C X x : ↑X ⊢ stalk (f _* F) (f x) ⟶ colimit ((OpenNhds.map f x).op ⋙ ((whiskeringLeft (OpenNhds x)ᵒᵖ (Opens ↑X)ᵒᵖ C).obj (OpenNhds.inclusion x).op).obj F)
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU; exact ih U hxU set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_hom_ext TopCat.Presheaf.stalk_hom_ext @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : U) (f : F ⟶ G) : germ F x ≫ (stalkFunctor C x.1).map f = f.app (op U) ≫ germ G x := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x.1).op f) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_map_germ TopCat.Presheaf.stalkFunctor_map_germ variable (C) /-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing. refine' ?_ ≫ colimit.pre _ (OpenNhds.map f x).op
exact colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) F)
/-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing. refine' ?_ ≫ colimit.pre _ (OpenNhds.map f x).op
Mathlib.Topology.Sheaves.Stalks.139_0.hsVUPKIHRY0xmFk
/-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x
Mathlib_Topology_Sheaves_Stalks
C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y Z : TopCat f : X ⟶ Y F : Presheaf C X U : Opens ↑Y x : ↥((Opens.map f).obj U) ⊢ germ (f _* F) { val := f ↑x, property := (_ : ↑x ∈ (Opens.map f).obj U) } ≫ stalkPushforward C f F ↑x = germ F x
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU; exact ih U hxU set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_hom_ext TopCat.Presheaf.stalk_hom_ext @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : U) (f : F ⟶ G) : germ F x ≫ (stalkFunctor C x.1).map f = f.app (op U) ≫ germ G x := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x.1).op f) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_map_germ TopCat.Presheaf.stalkFunctor_map_germ variable (C) /-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing. refine' ?_ ≫ colimit.pre _ (OpenNhds.map f x).op exact colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) F) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward TopCat.Presheaf.stalkPushforward @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y) (x : (Opens.map f).obj U) : (f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by
rw [stalkPushforward, germ, colimit.ι_map_assoc, colimit.ι_pre, whiskerRight_app]
@[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y) (x : (Opens.map f).obj U) : (f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by
Mathlib.Topology.Sheaves.Stalks.150_0.hsVUPKIHRY0xmFk
@[reassoc (attr
Mathlib_Topology_Sheaves_Stalks
C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y Z : TopCat f : X ⟶ Y F : Presheaf C X U : Opens ↑Y x : ↥((Opens.map f).obj U) ⊢ F.map ((NatTrans.op (OpenNhds.inclusionMapIso f ↑x).inv).app (op { obj := U, property := (_ : ↑{ val := f ↑x, property := (_ : ↑x ∈ (Opens.map f).obj U) } ∈ U) })) ≫ colimit.ι (((whiskeringLeft (OpenNhds ↑x)ᵒᵖ (Opens ↑X)ᵒᵖ C).obj (OpenNhds.inclusion ↑x).op).obj F) ((OpenNhds.map f ↑x).op.obj (op { obj := U, property := (_ : ↑{ val := f ↑x, property := (_ : ↑x ∈ (Opens.map f).obj U) } ∈ U) })) = germ F x
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU; exact ih U hxU set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_hom_ext TopCat.Presheaf.stalk_hom_ext @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : U) (f : F ⟶ G) : germ F x ≫ (stalkFunctor C x.1).map f = f.app (op U) ≫ germ G x := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x.1).op f) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_map_germ TopCat.Presheaf.stalkFunctor_map_germ variable (C) /-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing. refine' ?_ ≫ colimit.pre _ (OpenNhds.map f x).op exact colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) F) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward TopCat.Presheaf.stalkPushforward @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y) (x : (Opens.map f).obj U) : (f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by rw [stalkPushforward, germ, colimit.ι_map_assoc, colimit.ι_pre, whiskerRight_app]
erw [CategoryTheory.Functor.map_id, Category.id_comp]
@[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y) (x : (Opens.map f).obj U) : (f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by rw [stalkPushforward, germ, colimit.ι_map_assoc, colimit.ι_pre, whiskerRight_app]
Mathlib.Topology.Sheaves.Stalks.150_0.hsVUPKIHRY0xmFk
@[reassoc (attr
Mathlib_Topology_Sheaves_Stalks
C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y Z : TopCat f : X ⟶ Y F : Presheaf C X U : Opens ↑Y x : ↥((Opens.map f).obj U) ⊢ colimit.ι (((whiskeringLeft (OpenNhds ↑x)ᵒᵖ (Opens ↑X)ᵒᵖ C).obj (OpenNhds.inclusion ↑x).op).obj F) ((OpenNhds.map f ↑x).op.obj (op { obj := U, property := (_ : ↑{ val := f ↑x, property := (_ : ↑x ∈ (Opens.map f).obj U) } ∈ U) })) = germ F x
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU; exact ih U hxU set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_hom_ext TopCat.Presheaf.stalk_hom_ext @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : U) (f : F ⟶ G) : germ F x ≫ (stalkFunctor C x.1).map f = f.app (op U) ≫ germ G x := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x.1).op f) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_map_germ TopCat.Presheaf.stalkFunctor_map_germ variable (C) /-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing. refine' ?_ ≫ colimit.pre _ (OpenNhds.map f x).op exact colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) F) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward TopCat.Presheaf.stalkPushforward @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y) (x : (Opens.map f).obj U) : (f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by rw [stalkPushforward, germ, colimit.ι_map_assoc, colimit.ι_pre, whiskerRight_app] erw [CategoryTheory.Functor.map_id, Category.id_comp]
rfl
@[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y) (x : (Opens.map f).obj U) : (f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by rw [stalkPushforward, germ, colimit.ι_map_assoc, colimit.ι_pre, whiskerRight_app] erw [CategoryTheory.Functor.map_id, Category.id_comp]
Mathlib.Topology.Sheaves.Stalks.150_0.hsVUPKIHRY0xmFk
@[reassoc (attr
Mathlib_Topology_Sheaves_Stalks
C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y Z : TopCat ℱ : Presheaf C X x : ↑X ⊢ stalkPushforward C (𝟙 X) ℱ x = (stalkFunctor C x).map (Pushforward.id ℱ).hom
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU; exact ih U hxU set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_hom_ext TopCat.Presheaf.stalk_hom_ext @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : U) (f : F ⟶ G) : germ F x ≫ (stalkFunctor C x.1).map f = f.app (op U) ≫ germ G x := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x.1).op f) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_map_germ TopCat.Presheaf.stalkFunctor_map_germ variable (C) /-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing. refine' ?_ ≫ colimit.pre _ (OpenNhds.map f x).op exact colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) F) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward TopCat.Presheaf.stalkPushforward @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y) (x : (Opens.map f).obj U) : (f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by rw [stalkPushforward, germ, colimit.ι_map_assoc, colimit.ι_pre, whiskerRight_app] erw [CategoryTheory.Functor.map_id, Category.id_comp] rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward_germ TopCat.Presheaf.stalkPushforward_germ -- Here are two other potential solutions, suggested by @fpvandoorn at -- <https://github.com/leanprover-community/mathlib/pull/1018#discussion_r283978240> -- However, I can't get the subsequent two proofs to work with either one. -- def stalkPushforward'' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- colim.map ((Functor.associator _ _ _).inv ≫ -- whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op -- def stalkPushforward''' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- (colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) : -- colim.obj ((OpenNhds.inclusion (f x) ⋙ Opens.map f).op ⋙ ℱ) ⟶ _) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op namespace stalkPushforward @[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by -- Porting note: We need to this to help ext tactic.
change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _)
@[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by -- Porting note: We need to this to help ext tactic.
Mathlib.Topology.Sheaves.Stalks.176_0.hsVUPKIHRY0xmFk
@[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom
Mathlib_Topology_Sheaves_Stalks
C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y Z : TopCat ℱ : Presheaf C X x : ↑X ⊢ stalkPushforward C (𝟙 X) ℱ x = (stalkFunctor C x).map (Pushforward.id ℱ).hom
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU; exact ih U hxU set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_hom_ext TopCat.Presheaf.stalk_hom_ext @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : U) (f : F ⟶ G) : germ F x ≫ (stalkFunctor C x.1).map f = f.app (op U) ≫ germ G x := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x.1).op f) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_map_germ TopCat.Presheaf.stalkFunctor_map_germ variable (C) /-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing. refine' ?_ ≫ colimit.pre _ (OpenNhds.map f x).op exact colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) F) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward TopCat.Presheaf.stalkPushforward @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y) (x : (Opens.map f).obj U) : (f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by rw [stalkPushforward, germ, colimit.ι_map_assoc, colimit.ι_pre, whiskerRight_app] erw [CategoryTheory.Functor.map_id, Category.id_comp] rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward_germ TopCat.Presheaf.stalkPushforward_germ -- Here are two other potential solutions, suggested by @fpvandoorn at -- <https://github.com/leanprover-community/mathlib/pull/1018#discussion_r283978240> -- However, I can't get the subsequent two proofs to work with either one. -- def stalkPushforward'' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- colim.map ((Functor.associator _ _ _).inv ≫ -- whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op -- def stalkPushforward''' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- (colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) : -- colim.obj ((OpenNhds.inclusion (f x) ⋙ Opens.map f).op ⋙ ℱ) ⟶ _) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op namespace stalkPushforward @[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by -- Porting note: We need to this to help ext tactic. change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _)
ext1 j
@[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by -- Porting note: We need to this to help ext tactic. change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _)
Mathlib.Topology.Sheaves.Stalks.176_0.hsVUPKIHRY0xmFk
@[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom
Mathlib_Topology_Sheaves_Stalks
case w C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y Z : TopCat ℱ : Presheaf C X x : ↑X j : (OpenNhds ((𝟙 X) x))ᵒᵖ ⊢ colimit.ι (((whiskeringLeft (OpenNhds ((𝟙 X) x))ᵒᵖ (Opens ↑X)ᵒᵖ C).obj (OpenNhds.inclusion ((𝟙 X) x)).op).obj (𝟙 X _* ℱ)) j ≫ stalkPushforward C (𝟙 X) ℱ x = colimit.ι (((whiskeringLeft (OpenNhds ((𝟙 X) x))ᵒᵖ (Opens ↑X)ᵒᵖ C).obj (OpenNhds.inclusion ((𝟙 X) x)).op).obj (𝟙 X _* ℱ)) j ≫ (stalkFunctor C x).map (Pushforward.id ℱ).hom
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU; exact ih U hxU set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_hom_ext TopCat.Presheaf.stalk_hom_ext @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : U) (f : F ⟶ G) : germ F x ≫ (stalkFunctor C x.1).map f = f.app (op U) ≫ germ G x := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x.1).op f) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_map_germ TopCat.Presheaf.stalkFunctor_map_germ variable (C) /-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing. refine' ?_ ≫ colimit.pre _ (OpenNhds.map f x).op exact colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) F) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward TopCat.Presheaf.stalkPushforward @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y) (x : (Opens.map f).obj U) : (f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by rw [stalkPushforward, germ, colimit.ι_map_assoc, colimit.ι_pre, whiskerRight_app] erw [CategoryTheory.Functor.map_id, Category.id_comp] rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward_germ TopCat.Presheaf.stalkPushforward_germ -- Here are two other potential solutions, suggested by @fpvandoorn at -- <https://github.com/leanprover-community/mathlib/pull/1018#discussion_r283978240> -- However, I can't get the subsequent two proofs to work with either one. -- def stalkPushforward'' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- colim.map ((Functor.associator _ _ _).inv ≫ -- whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op -- def stalkPushforward''' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- (colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) : -- colim.obj ((OpenNhds.inclusion (f x) ⋙ Opens.map f).op ⋙ ℱ) ⟶ _) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op namespace stalkPushforward @[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by -- Porting note: We need to this to help ext tactic. change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext1 j
induction' j with j
@[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by -- Porting note: We need to this to help ext tactic. change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext1 j
Mathlib.Topology.Sheaves.Stalks.176_0.hsVUPKIHRY0xmFk
@[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom
Mathlib_Topology_Sheaves_Stalks
case w.h C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y Z : TopCat ℱ : Presheaf C X x : ↑X j : OpenNhds ((𝟙 X) x) ⊢ colimit.ι (((whiskeringLeft (OpenNhds ((𝟙 X) x))ᵒᵖ (Opens ↑X)ᵒᵖ C).obj (OpenNhds.inclusion ((𝟙 X) x)).op).obj (𝟙 X _* ℱ)) (op j) ≫ stalkPushforward C (𝟙 X) ℱ x = colimit.ι (((whiskeringLeft (OpenNhds ((𝟙 X) x))ᵒᵖ (Opens ↑X)ᵒᵖ C).obj (OpenNhds.inclusion ((𝟙 X) x)).op).obj (𝟙 X _* ℱ)) (op j) ≫ (stalkFunctor C x).map (Pushforward.id ℱ).hom
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU; exact ih U hxU set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_hom_ext TopCat.Presheaf.stalk_hom_ext @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : U) (f : F ⟶ G) : germ F x ≫ (stalkFunctor C x.1).map f = f.app (op U) ≫ germ G x := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x.1).op f) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_map_germ TopCat.Presheaf.stalkFunctor_map_germ variable (C) /-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing. refine' ?_ ≫ colimit.pre _ (OpenNhds.map f x).op exact colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) F) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward TopCat.Presheaf.stalkPushforward @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y) (x : (Opens.map f).obj U) : (f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by rw [stalkPushforward, germ, colimit.ι_map_assoc, colimit.ι_pre, whiskerRight_app] erw [CategoryTheory.Functor.map_id, Category.id_comp] rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward_germ TopCat.Presheaf.stalkPushforward_germ -- Here are two other potential solutions, suggested by @fpvandoorn at -- <https://github.com/leanprover-community/mathlib/pull/1018#discussion_r283978240> -- However, I can't get the subsequent two proofs to work with either one. -- def stalkPushforward'' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- colim.map ((Functor.associator _ _ _).inv ≫ -- whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op -- def stalkPushforward''' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- (colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) : -- colim.obj ((OpenNhds.inclusion (f x) ⋙ Opens.map f).op ⋙ ℱ) ⟶ _) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op namespace stalkPushforward @[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by -- Porting note: We need to this to help ext tactic. change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext1 j induction' j with j
rcases j with ⟨⟨_, _⟩, _⟩
@[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by -- Porting note: We need to this to help ext tactic. change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext1 j induction' j with j
Mathlib.Topology.Sheaves.Stalks.176_0.hsVUPKIHRY0xmFk
@[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom
Mathlib_Topology_Sheaves_Stalks
case w.h.mk.mk C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y Z : TopCat ℱ : Presheaf C X x : ↑X carrier✝ : Set ↑X is_open'✝ : IsOpen carrier✝ property✝ : (𝟙 X) x ∈ { carrier := carrier✝, is_open' := is_open'✝ } ⊢ colimit.ι (((whiskeringLeft (OpenNhds ((𝟙 X) x))ᵒᵖ (Opens ↑X)ᵒᵖ C).obj (OpenNhds.inclusion ((𝟙 X) x)).op).obj (𝟙 X _* ℱ)) (op { obj := { carrier := carrier✝, is_open' := is_open'✝ }, property := property✝ }) ≫ stalkPushforward C (𝟙 X) ℱ x = colimit.ι (((whiskeringLeft (OpenNhds ((𝟙 X) x))ᵒᵖ (Opens ↑X)ᵒᵖ C).obj (OpenNhds.inclusion ((𝟙 X) x)).op).obj (𝟙 X _* ℱ)) (op { obj := { carrier := carrier✝, is_open' := is_open'✝ }, property := property✝ }) ≫ (stalkFunctor C x).map (Pushforward.id ℱ).hom
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU; exact ih U hxU set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_hom_ext TopCat.Presheaf.stalk_hom_ext @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : U) (f : F ⟶ G) : germ F x ≫ (stalkFunctor C x.1).map f = f.app (op U) ≫ germ G x := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x.1).op f) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_map_germ TopCat.Presheaf.stalkFunctor_map_germ variable (C) /-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing. refine' ?_ ≫ colimit.pre _ (OpenNhds.map f x).op exact colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) F) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward TopCat.Presheaf.stalkPushforward @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y) (x : (Opens.map f).obj U) : (f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by rw [stalkPushforward, germ, colimit.ι_map_assoc, colimit.ι_pre, whiskerRight_app] erw [CategoryTheory.Functor.map_id, Category.id_comp] rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward_germ TopCat.Presheaf.stalkPushforward_germ -- Here are two other potential solutions, suggested by @fpvandoorn at -- <https://github.com/leanprover-community/mathlib/pull/1018#discussion_r283978240> -- However, I can't get the subsequent two proofs to work with either one. -- def stalkPushforward'' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- colim.map ((Functor.associator _ _ _).inv ≫ -- whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op -- def stalkPushforward''' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- (colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) : -- colim.obj ((OpenNhds.inclusion (f x) ⋙ Opens.map f).op ⋙ ℱ) ⟶ _) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op namespace stalkPushforward @[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by -- Porting note: We need to this to help ext tactic. change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext1 j induction' j with j rcases j with ⟨⟨_, _⟩, _⟩
erw [colimit.ι_map_assoc]
@[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by -- Porting note: We need to this to help ext tactic. change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext1 j induction' j with j rcases j with ⟨⟨_, _⟩, _⟩
Mathlib.Topology.Sheaves.Stalks.176_0.hsVUPKIHRY0xmFk
@[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom
Mathlib_Topology_Sheaves_Stalks
case w.h.mk.mk C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y Z : TopCat ℱ : Presheaf C X x : ↑X carrier✝ : Set ↑X is_open'✝ : IsOpen carrier✝ property✝ : (𝟙 X) x ∈ { carrier := carrier✝, is_open' := is_open'✝ } ⊢ (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso (𝟙 X) x).inv) ℱ).app (op { obj := { carrier := carrier✝, is_open' := is_open'✝ }, property := property✝ }) ≫ colimit.ι ((OpenNhds.map (𝟙 X) x).op ⋙ ((whiskeringLeft (OpenNhds x)ᵒᵖ (Opens ↑X)ᵒᵖ C).obj (OpenNhds.inclusion x).op).obj ℱ) (op { obj := { carrier := carrier✝, is_open' := is_open'✝ }, property := property✝ }) ≫ colimit.pre (((whiskeringLeft (OpenNhds x)ᵒᵖ (Opens ↑X)ᵒᵖ C).obj (OpenNhds.inclusion x).op).obj ℱ) (OpenNhds.map (𝟙 X) x).op = colimit.ι (((whiskeringLeft (OpenNhds ((𝟙 X) x))ᵒᵖ (Opens ↑X)ᵒᵖ C).obj (OpenNhds.inclusion ((𝟙 X) x)).op).obj (𝟙 X _* ℱ)) (op { obj := { carrier := carrier✝, is_open' := is_open'✝ }, property := property✝ }) ≫ (stalkFunctor C x).map (Pushforward.id ℱ).hom
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU; exact ih U hxU set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_hom_ext TopCat.Presheaf.stalk_hom_ext @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : U) (f : F ⟶ G) : germ F x ≫ (stalkFunctor C x.1).map f = f.app (op U) ≫ germ G x := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x.1).op f) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_map_germ TopCat.Presheaf.stalkFunctor_map_germ variable (C) /-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing. refine' ?_ ≫ colimit.pre _ (OpenNhds.map f x).op exact colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) F) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward TopCat.Presheaf.stalkPushforward @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y) (x : (Opens.map f).obj U) : (f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by rw [stalkPushforward, germ, colimit.ι_map_assoc, colimit.ι_pre, whiskerRight_app] erw [CategoryTheory.Functor.map_id, Category.id_comp] rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward_germ TopCat.Presheaf.stalkPushforward_germ -- Here are two other potential solutions, suggested by @fpvandoorn at -- <https://github.com/leanprover-community/mathlib/pull/1018#discussion_r283978240> -- However, I can't get the subsequent two proofs to work with either one. -- def stalkPushforward'' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- colim.map ((Functor.associator _ _ _).inv ≫ -- whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op -- def stalkPushforward''' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- (colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) : -- colim.obj ((OpenNhds.inclusion (f x) ⋙ Opens.map f).op ⋙ ℱ) ⟶ _) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op namespace stalkPushforward @[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by -- Porting note: We need to this to help ext tactic. change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext1 j induction' j with j rcases j with ⟨⟨_, _⟩, _⟩ erw [colimit.ι_map_assoc]
simp [stalkFunctor, stalkPushforward]
@[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by -- Porting note: We need to this to help ext tactic. change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext1 j induction' j with j rcases j with ⟨⟨_, _⟩, _⟩ erw [colimit.ι_map_assoc]
Mathlib.Topology.Sheaves.Stalks.176_0.hsVUPKIHRY0xmFk
@[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom
Mathlib_Topology_Sheaves_Stalks
C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y Z : TopCat ℱ : Presheaf C X f : X ⟶ Y g : Y ⟶ Z x : ↑X ⊢ stalkPushforward C (f ≫ g) ℱ x = stalkPushforward C g (f _* ℱ) (f x) ≫ stalkPushforward C f ℱ x
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU; exact ih U hxU set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_hom_ext TopCat.Presheaf.stalk_hom_ext @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : U) (f : F ⟶ G) : germ F x ≫ (stalkFunctor C x.1).map f = f.app (op U) ≫ germ G x := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x.1).op f) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_map_germ TopCat.Presheaf.stalkFunctor_map_germ variable (C) /-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing. refine' ?_ ≫ colimit.pre _ (OpenNhds.map f x).op exact colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) F) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward TopCat.Presheaf.stalkPushforward @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y) (x : (Opens.map f).obj U) : (f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by rw [stalkPushforward, germ, colimit.ι_map_assoc, colimit.ι_pre, whiskerRight_app] erw [CategoryTheory.Functor.map_id, Category.id_comp] rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward_germ TopCat.Presheaf.stalkPushforward_germ -- Here are two other potential solutions, suggested by @fpvandoorn at -- <https://github.com/leanprover-community/mathlib/pull/1018#discussion_r283978240> -- However, I can't get the subsequent two proofs to work with either one. -- def stalkPushforward'' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- colim.map ((Functor.associator _ _ _).inv ≫ -- whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op -- def stalkPushforward''' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- (colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) : -- colim.obj ((OpenNhds.inclusion (f x) ⋙ Opens.map f).op ⋙ ℱ) ⟶ _) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op namespace stalkPushforward @[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by -- Porting note: We need to this to help ext tactic. change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext1 j induction' j with j rcases j with ⟨⟨_, _⟩, _⟩ erw [colimit.ι_map_assoc] simp [stalkFunctor, stalkPushforward] set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward.id TopCat.Presheaf.stalkPushforward.id -- This proof is sadly not at all robust: -- having to use `erw` at all is a bad sign. @[simp] theorem comp (ℱ : X.Presheaf C) (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : ℱ.stalkPushforward C (f ≫ g) x = (f _* ℱ).stalkPushforward C g (f x) ≫ ℱ.stalkPushforward C f x := by
change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _)
@[simp] theorem comp (ℱ : X.Presheaf C) (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : ℱ.stalkPushforward C (f ≫ g) x = (f _* ℱ).stalkPushforward C g (f x) ≫ ℱ.stalkPushforward C f x := by
Mathlib.Topology.Sheaves.Stalks.191_0.hsVUPKIHRY0xmFk
@[simp] theorem comp (ℱ : X.Presheaf C) (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : ℱ.stalkPushforward C (f ≫ g) x = (f _* ℱ).stalkPushforward C g (f x) ≫ ℱ.stalkPushforward C f x
Mathlib_Topology_Sheaves_Stalks
C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y Z : TopCat ℱ : Presheaf C X f : X ⟶ Y g : Y ⟶ Z x : ↑X ⊢ stalkPushforward C (f ≫ g) ℱ x = stalkPushforward C g (f _* ℱ) (f x) ≫ stalkPushforward C f ℱ x
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU; exact ih U hxU set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_hom_ext TopCat.Presheaf.stalk_hom_ext @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : U) (f : F ⟶ G) : germ F x ≫ (stalkFunctor C x.1).map f = f.app (op U) ≫ germ G x := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x.1).op f) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_map_germ TopCat.Presheaf.stalkFunctor_map_germ variable (C) /-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing. refine' ?_ ≫ colimit.pre _ (OpenNhds.map f x).op exact colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) F) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward TopCat.Presheaf.stalkPushforward @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y) (x : (Opens.map f).obj U) : (f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by rw [stalkPushforward, germ, colimit.ι_map_assoc, colimit.ι_pre, whiskerRight_app] erw [CategoryTheory.Functor.map_id, Category.id_comp] rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward_germ TopCat.Presheaf.stalkPushforward_germ -- Here are two other potential solutions, suggested by @fpvandoorn at -- <https://github.com/leanprover-community/mathlib/pull/1018#discussion_r283978240> -- However, I can't get the subsequent two proofs to work with either one. -- def stalkPushforward'' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- colim.map ((Functor.associator _ _ _).inv ≫ -- whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op -- def stalkPushforward''' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- (colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) : -- colim.obj ((OpenNhds.inclusion (f x) ⋙ Opens.map f).op ⋙ ℱ) ⟶ _) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op namespace stalkPushforward @[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by -- Porting note: We need to this to help ext tactic. change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext1 j induction' j with j rcases j with ⟨⟨_, _⟩, _⟩ erw [colimit.ι_map_assoc] simp [stalkFunctor, stalkPushforward] set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward.id TopCat.Presheaf.stalkPushforward.id -- This proof is sadly not at all robust: -- having to use `erw` at all is a bad sign. @[simp] theorem comp (ℱ : X.Presheaf C) (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : ℱ.stalkPushforward C (f ≫ g) x = (f _* ℱ).stalkPushforward C g (f x) ≫ ℱ.stalkPushforward C f x := by change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _)
ext U
@[simp] theorem comp (ℱ : X.Presheaf C) (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : ℱ.stalkPushforward C (f ≫ g) x = (f _* ℱ).stalkPushforward C g (f x) ≫ ℱ.stalkPushforward C f x := by change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _)
Mathlib.Topology.Sheaves.Stalks.191_0.hsVUPKIHRY0xmFk
@[simp] theorem comp (ℱ : X.Presheaf C) (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : ℱ.stalkPushforward C (f ≫ g) x = (f _* ℱ).stalkPushforward C g (f x) ≫ ℱ.stalkPushforward C f x
Mathlib_Topology_Sheaves_Stalks
case w C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y Z : TopCat ℱ : Presheaf C X f : X ⟶ Y g : Y ⟶ Z x : ↑X U : (OpenNhds ((f ≫ g) x))ᵒᵖ ⊢ colimit.ι (((whiskeringLeft (OpenNhds ((f ≫ g) x))ᵒᵖ (Opens ↑Z)ᵒᵖ C).obj (OpenNhds.inclusion ((f ≫ g) x)).op).obj ((f ≫ g) _* ℱ)) U ≫ stalkPushforward C (f ≫ g) ℱ x = colimit.ι (((whiskeringLeft (OpenNhds ((f ≫ g) x))ᵒᵖ (Opens ↑Z)ᵒᵖ C).obj (OpenNhds.inclusion ((f ≫ g) x)).op).obj ((f ≫ g) _* ℱ)) U ≫ stalkPushforward C g (f _* ℱ) (f x) ≫ stalkPushforward C f ℱ x
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU; exact ih U hxU set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_hom_ext TopCat.Presheaf.stalk_hom_ext @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : U) (f : F ⟶ G) : germ F x ≫ (stalkFunctor C x.1).map f = f.app (op U) ≫ germ G x := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x.1).op f) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_map_germ TopCat.Presheaf.stalkFunctor_map_germ variable (C) /-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing. refine' ?_ ≫ colimit.pre _ (OpenNhds.map f x).op exact colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) F) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward TopCat.Presheaf.stalkPushforward @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y) (x : (Opens.map f).obj U) : (f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by rw [stalkPushforward, germ, colimit.ι_map_assoc, colimit.ι_pre, whiskerRight_app] erw [CategoryTheory.Functor.map_id, Category.id_comp] rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward_germ TopCat.Presheaf.stalkPushforward_germ -- Here are two other potential solutions, suggested by @fpvandoorn at -- <https://github.com/leanprover-community/mathlib/pull/1018#discussion_r283978240> -- However, I can't get the subsequent two proofs to work with either one. -- def stalkPushforward'' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- colim.map ((Functor.associator _ _ _).inv ≫ -- whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op -- def stalkPushforward''' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- (colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) : -- colim.obj ((OpenNhds.inclusion (f x) ⋙ Opens.map f).op ⋙ ℱ) ⟶ _) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op namespace stalkPushforward @[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by -- Porting note: We need to this to help ext tactic. change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext1 j induction' j with j rcases j with ⟨⟨_, _⟩, _⟩ erw [colimit.ι_map_assoc] simp [stalkFunctor, stalkPushforward] set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward.id TopCat.Presheaf.stalkPushforward.id -- This proof is sadly not at all robust: -- having to use `erw` at all is a bad sign. @[simp] theorem comp (ℱ : X.Presheaf C) (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : ℱ.stalkPushforward C (f ≫ g) x = (f _* ℱ).stalkPushforward C g (f x) ≫ ℱ.stalkPushforward C f x := by change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext U
rcases U with ⟨⟨_, _⟩, _⟩
@[simp] theorem comp (ℱ : X.Presheaf C) (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : ℱ.stalkPushforward C (f ≫ g) x = (f _* ℱ).stalkPushforward C g (f x) ≫ ℱ.stalkPushforward C f x := by change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext U
Mathlib.Topology.Sheaves.Stalks.191_0.hsVUPKIHRY0xmFk
@[simp] theorem comp (ℱ : X.Presheaf C) (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : ℱ.stalkPushforward C (f ≫ g) x = (f _* ℱ).stalkPushforward C g (f x) ≫ ℱ.stalkPushforward C f x
Mathlib_Topology_Sheaves_Stalks
case w.mk.mk.mk C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y Z : TopCat ℱ : Presheaf C X f : X ⟶ Y g : Y ⟶ Z x : ↑X carrier✝ : Set ↑Z is_open'✝ : IsOpen carrier✝ property✝ : (f ≫ g) x ∈ { carrier := carrier✝, is_open' := is_open'✝ } ⊢ colimit.ι (((whiskeringLeft (OpenNhds ((f ≫ g) x))ᵒᵖ (Opens ↑Z)ᵒᵖ C).obj (OpenNhds.inclusion ((f ≫ g) x)).op).obj ((f ≫ g) _* ℱ)) { unop := { obj := { carrier := carrier✝, is_open' := is_open'✝ }, property := property✝ } } ≫ stalkPushforward C (f ≫ g) ℱ x = colimit.ι (((whiskeringLeft (OpenNhds ((f ≫ g) x))ᵒᵖ (Opens ↑Z)ᵒᵖ C).obj (OpenNhds.inclusion ((f ≫ g) x)).op).obj ((f ≫ g) _* ℱ)) { unop := { obj := { carrier := carrier✝, is_open' := is_open'✝ }, property := property✝ } } ≫ stalkPushforward C g (f _* ℱ) (f x) ≫ stalkPushforward C f ℱ x
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU; exact ih U hxU set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_hom_ext TopCat.Presheaf.stalk_hom_ext @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : U) (f : F ⟶ G) : germ F x ≫ (stalkFunctor C x.1).map f = f.app (op U) ≫ germ G x := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x.1).op f) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_map_germ TopCat.Presheaf.stalkFunctor_map_germ variable (C) /-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing. refine' ?_ ≫ colimit.pre _ (OpenNhds.map f x).op exact colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) F) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward TopCat.Presheaf.stalkPushforward @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y) (x : (Opens.map f).obj U) : (f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by rw [stalkPushforward, germ, colimit.ι_map_assoc, colimit.ι_pre, whiskerRight_app] erw [CategoryTheory.Functor.map_id, Category.id_comp] rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward_germ TopCat.Presheaf.stalkPushforward_germ -- Here are two other potential solutions, suggested by @fpvandoorn at -- <https://github.com/leanprover-community/mathlib/pull/1018#discussion_r283978240> -- However, I can't get the subsequent two proofs to work with either one. -- def stalkPushforward'' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- colim.map ((Functor.associator _ _ _).inv ≫ -- whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op -- def stalkPushforward''' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- (colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) : -- colim.obj ((OpenNhds.inclusion (f x) ⋙ Opens.map f).op ⋙ ℱ) ⟶ _) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op namespace stalkPushforward @[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by -- Porting note: We need to this to help ext tactic. change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext1 j induction' j with j rcases j with ⟨⟨_, _⟩, _⟩ erw [colimit.ι_map_assoc] simp [stalkFunctor, stalkPushforward] set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward.id TopCat.Presheaf.stalkPushforward.id -- This proof is sadly not at all robust: -- having to use `erw` at all is a bad sign. @[simp] theorem comp (ℱ : X.Presheaf C) (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : ℱ.stalkPushforward C (f ≫ g) x = (f _* ℱ).stalkPushforward C g (f x) ≫ ℱ.stalkPushforward C f x := by change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext U rcases U with ⟨⟨_, _⟩, _⟩
simp [stalkFunctor, stalkPushforward]
@[simp] theorem comp (ℱ : X.Presheaf C) (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : ℱ.stalkPushforward C (f ≫ g) x = (f _* ℱ).stalkPushforward C g (f x) ≫ ℱ.stalkPushforward C f x := by change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext U rcases U with ⟨⟨_, _⟩, _⟩
Mathlib.Topology.Sheaves.Stalks.191_0.hsVUPKIHRY0xmFk
@[simp] theorem comp (ℱ : X.Presheaf C) (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : ℱ.stalkPushforward C (f ≫ g) x = (f _* ℱ).stalkPushforward C g (f x) ≫ ℱ.stalkPushforward C f x
Mathlib_Topology_Sheaves_Stalks
C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y Z : TopCat f : X ⟶ Y hf : OpenEmbedding ⇑f F : Presheaf C X x : ↑X ⊢ IsIso (stalkPushforward C f F x)
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU; exact ih U hxU set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_hom_ext TopCat.Presheaf.stalk_hom_ext @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : U) (f : F ⟶ G) : germ F x ≫ (stalkFunctor C x.1).map f = f.app (op U) ≫ germ G x := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x.1).op f) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_map_germ TopCat.Presheaf.stalkFunctor_map_germ variable (C) /-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing. refine' ?_ ≫ colimit.pre _ (OpenNhds.map f x).op exact colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) F) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward TopCat.Presheaf.stalkPushforward @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y) (x : (Opens.map f).obj U) : (f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by rw [stalkPushforward, germ, colimit.ι_map_assoc, colimit.ι_pre, whiskerRight_app] erw [CategoryTheory.Functor.map_id, Category.id_comp] rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward_germ TopCat.Presheaf.stalkPushforward_germ -- Here are two other potential solutions, suggested by @fpvandoorn at -- <https://github.com/leanprover-community/mathlib/pull/1018#discussion_r283978240> -- However, I can't get the subsequent two proofs to work with either one. -- def stalkPushforward'' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- colim.map ((Functor.associator _ _ _).inv ≫ -- whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op -- def stalkPushforward''' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- (colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) : -- colim.obj ((OpenNhds.inclusion (f x) ⋙ Opens.map f).op ⋙ ℱ) ⟶ _) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op namespace stalkPushforward @[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by -- Porting note: We need to this to help ext tactic. change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext1 j induction' j with j rcases j with ⟨⟨_, _⟩, _⟩ erw [colimit.ι_map_assoc] simp [stalkFunctor, stalkPushforward] set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward.id TopCat.Presheaf.stalkPushforward.id -- This proof is sadly not at all robust: -- having to use `erw` at all is a bad sign. @[simp] theorem comp (ℱ : X.Presheaf C) (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : ℱ.stalkPushforward C (f ≫ g) x = (f _* ℱ).stalkPushforward C g (f x) ≫ ℱ.stalkPushforward C f x := by change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext U rcases U with ⟨⟨_, _⟩, _⟩ simp [stalkFunctor, stalkPushforward] set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward.comp TopCat.Presheaf.stalkPushforward.comp theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x) := by
haveI := Functor.initial_of_adjunction (hf.isOpenMap.adjunctionNhds x)
theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x) := by
Mathlib.Topology.Sheaves.Stalks.202_0.hsVUPKIHRY0xmFk
theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x)
Mathlib_Topology_Sheaves_Stalks
C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y Z : TopCat f : X ⟶ Y hf : OpenEmbedding ⇑f F : Presheaf C X x : ↑X this : Functor.Initial (IsOpenMap.functorNhds (_ : IsOpenMap ⇑f) x) ⊢ IsIso (stalkPushforward C f F x)
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU; exact ih U hxU set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_hom_ext TopCat.Presheaf.stalk_hom_ext @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : U) (f : F ⟶ G) : germ F x ≫ (stalkFunctor C x.1).map f = f.app (op U) ≫ germ G x := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x.1).op f) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_map_germ TopCat.Presheaf.stalkFunctor_map_germ variable (C) /-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing. refine' ?_ ≫ colimit.pre _ (OpenNhds.map f x).op exact colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) F) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward TopCat.Presheaf.stalkPushforward @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y) (x : (Opens.map f).obj U) : (f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by rw [stalkPushforward, germ, colimit.ι_map_assoc, colimit.ι_pre, whiskerRight_app] erw [CategoryTheory.Functor.map_id, Category.id_comp] rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward_germ TopCat.Presheaf.stalkPushforward_germ -- Here are two other potential solutions, suggested by @fpvandoorn at -- <https://github.com/leanprover-community/mathlib/pull/1018#discussion_r283978240> -- However, I can't get the subsequent two proofs to work with either one. -- def stalkPushforward'' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- colim.map ((Functor.associator _ _ _).inv ≫ -- whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op -- def stalkPushforward''' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- (colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) : -- colim.obj ((OpenNhds.inclusion (f x) ⋙ Opens.map f).op ⋙ ℱ) ⟶ _) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op namespace stalkPushforward @[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by -- Porting note: We need to this to help ext tactic. change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext1 j induction' j with j rcases j with ⟨⟨_, _⟩, _⟩ erw [colimit.ι_map_assoc] simp [stalkFunctor, stalkPushforward] set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward.id TopCat.Presheaf.stalkPushforward.id -- This proof is sadly not at all robust: -- having to use `erw` at all is a bad sign. @[simp] theorem comp (ℱ : X.Presheaf C) (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : ℱ.stalkPushforward C (f ≫ g) x = (f _* ℱ).stalkPushforward C g (f x) ≫ ℱ.stalkPushforward C f x := by change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext U rcases U with ⟨⟨_, _⟩, _⟩ simp [stalkFunctor, stalkPushforward] set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward.comp TopCat.Presheaf.stalkPushforward.comp theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x) := by haveI := Functor.initial_of_adjunction (hf.isOpenMap.adjunctionNhds x)
convert IsIso.of_iso ((Functor.Final.colimitIso (hf.isOpenMap.functorNhds x).op ((OpenNhds.inclusion (f x)).op ⋙ f _* F) : _).symm ≪≫ colim.mapIso _)
theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x) := by haveI := Functor.initial_of_adjunction (hf.isOpenMap.adjunctionNhds x)
Mathlib.Topology.Sheaves.Stalks.202_0.hsVUPKIHRY0xmFk
theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x)
Mathlib_Topology_Sheaves_Stalks
case h.e'_5.h C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y Z : TopCat f : X ⟶ Y hf : OpenEmbedding ⇑f F : Presheaf C X x : ↑X this : Functor.Initial (IsOpenMap.functorNhds (_ : IsOpenMap ⇑f) x) e_3✝ : stalk (f _* F) (f x) = colimit ((OpenNhds.inclusion (f x)).op ⋙ f _* F) e_4✝ : stalk F x = colim.obj (((whiskeringLeft (OpenNhds x)ᵒᵖ (Opens ↑X)ᵒᵖ C).obj (OpenNhds.inclusion x).op).obj F) ⊢ stalkPushforward C f F x = ((Functor.Final.colimitIso (IsOpenMap.functorNhds (_ : IsOpenMap ⇑f) x).op ((OpenNhds.inclusion (f x)).op ⋙ f _* F)).symm ≪≫ colim.mapIso ?convert_2).hom case convert_2 C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y Z : TopCat f : X ⟶ Y hf : OpenEmbedding ⇑f F : Presheaf C X x : ↑X this : Functor.Initial (IsOpenMap.functorNhds (_ : IsOpenMap ⇑f) x) ⊢ (IsOpenMap.functorNhds (_ : IsOpenMap ⇑f) x).op ⋙ (OpenNhds.inclusion (f x)).op ⋙ f _* F ≅ ((whiskeringLeft (OpenNhds x)ᵒᵖ (Opens ↑X)ᵒᵖ C).obj (OpenNhds.inclusion x).op).obj F
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU; exact ih U hxU set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_hom_ext TopCat.Presheaf.stalk_hom_ext @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : U) (f : F ⟶ G) : germ F x ≫ (stalkFunctor C x.1).map f = f.app (op U) ≫ germ G x := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x.1).op f) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_map_germ TopCat.Presheaf.stalkFunctor_map_germ variable (C) /-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing. refine' ?_ ≫ colimit.pre _ (OpenNhds.map f x).op exact colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) F) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward TopCat.Presheaf.stalkPushforward @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y) (x : (Opens.map f).obj U) : (f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by rw [stalkPushforward, germ, colimit.ι_map_assoc, colimit.ι_pre, whiskerRight_app] erw [CategoryTheory.Functor.map_id, Category.id_comp] rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward_germ TopCat.Presheaf.stalkPushforward_germ -- Here are two other potential solutions, suggested by @fpvandoorn at -- <https://github.com/leanprover-community/mathlib/pull/1018#discussion_r283978240> -- However, I can't get the subsequent two proofs to work with either one. -- def stalkPushforward'' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- colim.map ((Functor.associator _ _ _).inv ≫ -- whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op -- def stalkPushforward''' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- (colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) : -- colim.obj ((OpenNhds.inclusion (f x) ⋙ Opens.map f).op ⋙ ℱ) ⟶ _) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op namespace stalkPushforward @[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by -- Porting note: We need to this to help ext tactic. change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext1 j induction' j with j rcases j with ⟨⟨_, _⟩, _⟩ erw [colimit.ι_map_assoc] simp [stalkFunctor, stalkPushforward] set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward.id TopCat.Presheaf.stalkPushforward.id -- This proof is sadly not at all robust: -- having to use `erw` at all is a bad sign. @[simp] theorem comp (ℱ : X.Presheaf C) (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : ℱ.stalkPushforward C (f ≫ g) x = (f _* ℱ).stalkPushforward C g (f x) ≫ ℱ.stalkPushforward C f x := by change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext U rcases U with ⟨⟨_, _⟩, _⟩ simp [stalkFunctor, stalkPushforward] set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward.comp TopCat.Presheaf.stalkPushforward.comp theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x) := by haveI := Functor.initial_of_adjunction (hf.isOpenMap.adjunctionNhds x) convert IsIso.of_iso ((Functor.Final.colimitIso (hf.isOpenMap.functorNhds x).op ((OpenNhds.inclusion (f x)).op ⋙ f _* F) : _).symm ≪≫ colim.mapIso _)
swap
theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x) := by haveI := Functor.initial_of_adjunction (hf.isOpenMap.adjunctionNhds x) convert IsIso.of_iso ((Functor.Final.colimitIso (hf.isOpenMap.functorNhds x).op ((OpenNhds.inclusion (f x)).op ⋙ f _* F) : _).symm ≪≫ colim.mapIso _)
Mathlib.Topology.Sheaves.Stalks.202_0.hsVUPKIHRY0xmFk
theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x)
Mathlib_Topology_Sheaves_Stalks
case convert_2 C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y Z : TopCat f : X ⟶ Y hf : OpenEmbedding ⇑f F : Presheaf C X x : ↑X this : Functor.Initial (IsOpenMap.functorNhds (_ : IsOpenMap ⇑f) x) ⊢ (IsOpenMap.functorNhds (_ : IsOpenMap ⇑f) x).op ⋙ (OpenNhds.inclusion (f x)).op ⋙ f _* F ≅ ((whiskeringLeft (OpenNhds x)ᵒᵖ (Opens ↑X)ᵒᵖ C).obj (OpenNhds.inclusion x).op).obj F
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU; exact ih U hxU set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_hom_ext TopCat.Presheaf.stalk_hom_ext @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : U) (f : F ⟶ G) : germ F x ≫ (stalkFunctor C x.1).map f = f.app (op U) ≫ germ G x := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x.1).op f) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_map_germ TopCat.Presheaf.stalkFunctor_map_germ variable (C) /-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing. refine' ?_ ≫ colimit.pre _ (OpenNhds.map f x).op exact colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) F) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward TopCat.Presheaf.stalkPushforward @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y) (x : (Opens.map f).obj U) : (f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by rw [stalkPushforward, germ, colimit.ι_map_assoc, colimit.ι_pre, whiskerRight_app] erw [CategoryTheory.Functor.map_id, Category.id_comp] rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward_germ TopCat.Presheaf.stalkPushforward_germ -- Here are two other potential solutions, suggested by @fpvandoorn at -- <https://github.com/leanprover-community/mathlib/pull/1018#discussion_r283978240> -- However, I can't get the subsequent two proofs to work with either one. -- def stalkPushforward'' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- colim.map ((Functor.associator _ _ _).inv ≫ -- whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op -- def stalkPushforward''' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- (colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) : -- colim.obj ((OpenNhds.inclusion (f x) ⋙ Opens.map f).op ⋙ ℱ) ⟶ _) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op namespace stalkPushforward @[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by -- Porting note: We need to this to help ext tactic. change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext1 j induction' j with j rcases j with ⟨⟨_, _⟩, _⟩ erw [colimit.ι_map_assoc] simp [stalkFunctor, stalkPushforward] set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward.id TopCat.Presheaf.stalkPushforward.id -- This proof is sadly not at all robust: -- having to use `erw` at all is a bad sign. @[simp] theorem comp (ℱ : X.Presheaf C) (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : ℱ.stalkPushforward C (f ≫ g) x = (f _* ℱ).stalkPushforward C g (f x) ≫ ℱ.stalkPushforward C f x := by change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext U rcases U with ⟨⟨_, _⟩, _⟩ simp [stalkFunctor, stalkPushforward] set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward.comp TopCat.Presheaf.stalkPushforward.comp theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x) := by haveI := Functor.initial_of_adjunction (hf.isOpenMap.adjunctionNhds x) convert IsIso.of_iso ((Functor.Final.colimitIso (hf.isOpenMap.functorNhds x).op ((OpenNhds.inclusion (f x)).op ⋙ f _* F) : _).symm ≪≫ colim.mapIso _) swap ·
fapply NatIso.ofComponents
theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x) := by haveI := Functor.initial_of_adjunction (hf.isOpenMap.adjunctionNhds x) convert IsIso.of_iso ((Functor.Final.colimitIso (hf.isOpenMap.functorNhds x).op ((OpenNhds.inclusion (f x)).op ⋙ f _* F) : _).symm ≪≫ colim.mapIso _) swap ·
Mathlib.Topology.Sheaves.Stalks.202_0.hsVUPKIHRY0xmFk
theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x)
Mathlib_Topology_Sheaves_Stalks
case convert_2.app C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y Z : TopCat f : X ⟶ Y hf : OpenEmbedding ⇑f F : Presheaf C X x : ↑X this : Functor.Initial (IsOpenMap.functorNhds (_ : IsOpenMap ⇑f) x) ⊢ (X_1 : (OpenNhds x)ᵒᵖ) → ((IsOpenMap.functorNhds (_ : IsOpenMap ⇑f) x).op ⋙ (OpenNhds.inclusion (f x)).op ⋙ f _* F).obj X_1 ≅ (((whiskeringLeft (OpenNhds x)ᵒᵖ (Opens ↑X)ᵒᵖ C).obj (OpenNhds.inclusion x).op).obj F).obj X_1
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU; exact ih U hxU set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_hom_ext TopCat.Presheaf.stalk_hom_ext @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : U) (f : F ⟶ G) : germ F x ≫ (stalkFunctor C x.1).map f = f.app (op U) ≫ germ G x := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x.1).op f) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_map_germ TopCat.Presheaf.stalkFunctor_map_germ variable (C) /-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing. refine' ?_ ≫ colimit.pre _ (OpenNhds.map f x).op exact colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) F) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward TopCat.Presheaf.stalkPushforward @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y) (x : (Opens.map f).obj U) : (f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by rw [stalkPushforward, germ, colimit.ι_map_assoc, colimit.ι_pre, whiskerRight_app] erw [CategoryTheory.Functor.map_id, Category.id_comp] rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward_germ TopCat.Presheaf.stalkPushforward_germ -- Here are two other potential solutions, suggested by @fpvandoorn at -- <https://github.com/leanprover-community/mathlib/pull/1018#discussion_r283978240> -- However, I can't get the subsequent two proofs to work with either one. -- def stalkPushforward'' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- colim.map ((Functor.associator _ _ _).inv ≫ -- whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op -- def stalkPushforward''' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- (colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) : -- colim.obj ((OpenNhds.inclusion (f x) ⋙ Opens.map f).op ⋙ ℱ) ⟶ _) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op namespace stalkPushforward @[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by -- Porting note: We need to this to help ext tactic. change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext1 j induction' j with j rcases j with ⟨⟨_, _⟩, _⟩ erw [colimit.ι_map_assoc] simp [stalkFunctor, stalkPushforward] set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward.id TopCat.Presheaf.stalkPushforward.id -- This proof is sadly not at all robust: -- having to use `erw` at all is a bad sign. @[simp] theorem comp (ℱ : X.Presheaf C) (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : ℱ.stalkPushforward C (f ≫ g) x = (f _* ℱ).stalkPushforward C g (f x) ≫ ℱ.stalkPushforward C f x := by change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext U rcases U with ⟨⟨_, _⟩, _⟩ simp [stalkFunctor, stalkPushforward] set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward.comp TopCat.Presheaf.stalkPushforward.comp theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x) := by haveI := Functor.initial_of_adjunction (hf.isOpenMap.adjunctionNhds x) convert IsIso.of_iso ((Functor.Final.colimitIso (hf.isOpenMap.functorNhds x).op ((OpenNhds.inclusion (f x)).op ⋙ f _* F) : _).symm ≪≫ colim.mapIso _) swap · fapply NatIso.ofComponents ·
intro U
theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x) := by haveI := Functor.initial_of_adjunction (hf.isOpenMap.adjunctionNhds x) convert IsIso.of_iso ((Functor.Final.colimitIso (hf.isOpenMap.functorNhds x).op ((OpenNhds.inclusion (f x)).op ⋙ f _* F) : _).symm ≪≫ colim.mapIso _) swap · fapply NatIso.ofComponents ·
Mathlib.Topology.Sheaves.Stalks.202_0.hsVUPKIHRY0xmFk
theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x)
Mathlib_Topology_Sheaves_Stalks
case convert_2.app C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y Z : TopCat f : X ⟶ Y hf : OpenEmbedding ⇑f F : Presheaf C X x : ↑X this : Functor.Initial (IsOpenMap.functorNhds (_ : IsOpenMap ⇑f) x) U : (OpenNhds x)ᵒᵖ ⊢ ((IsOpenMap.functorNhds (_ : IsOpenMap ⇑f) x).op ⋙ (OpenNhds.inclusion (f x)).op ⋙ f _* F).obj U ≅ (((whiskeringLeft (OpenNhds x)ᵒᵖ (Opens ↑X)ᵒᵖ C).obj (OpenNhds.inclusion x).op).obj F).obj U
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU; exact ih U hxU set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_hom_ext TopCat.Presheaf.stalk_hom_ext @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : U) (f : F ⟶ G) : germ F x ≫ (stalkFunctor C x.1).map f = f.app (op U) ≫ germ G x := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x.1).op f) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_map_germ TopCat.Presheaf.stalkFunctor_map_germ variable (C) /-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing. refine' ?_ ≫ colimit.pre _ (OpenNhds.map f x).op exact colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) F) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward TopCat.Presheaf.stalkPushforward @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y) (x : (Opens.map f).obj U) : (f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by rw [stalkPushforward, germ, colimit.ι_map_assoc, colimit.ι_pre, whiskerRight_app] erw [CategoryTheory.Functor.map_id, Category.id_comp] rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward_germ TopCat.Presheaf.stalkPushforward_germ -- Here are two other potential solutions, suggested by @fpvandoorn at -- <https://github.com/leanprover-community/mathlib/pull/1018#discussion_r283978240> -- However, I can't get the subsequent two proofs to work with either one. -- def stalkPushforward'' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- colim.map ((Functor.associator _ _ _).inv ≫ -- whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op -- def stalkPushforward''' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- (colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) : -- colim.obj ((OpenNhds.inclusion (f x) ⋙ Opens.map f).op ⋙ ℱ) ⟶ _) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op namespace stalkPushforward @[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by -- Porting note: We need to this to help ext tactic. change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext1 j induction' j with j rcases j with ⟨⟨_, _⟩, _⟩ erw [colimit.ι_map_assoc] simp [stalkFunctor, stalkPushforward] set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward.id TopCat.Presheaf.stalkPushforward.id -- This proof is sadly not at all robust: -- having to use `erw` at all is a bad sign. @[simp] theorem comp (ℱ : X.Presheaf C) (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : ℱ.stalkPushforward C (f ≫ g) x = (f _* ℱ).stalkPushforward C g (f x) ≫ ℱ.stalkPushforward C f x := by change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext U rcases U with ⟨⟨_, _⟩, _⟩ simp [stalkFunctor, stalkPushforward] set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward.comp TopCat.Presheaf.stalkPushforward.comp theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x) := by haveI := Functor.initial_of_adjunction (hf.isOpenMap.adjunctionNhds x) convert IsIso.of_iso ((Functor.Final.colimitIso (hf.isOpenMap.functorNhds x).op ((OpenNhds.inclusion (f x)).op ⋙ f _* F) : _).symm ≪≫ colim.mapIso _) swap · fapply NatIso.ofComponents · intro U
refine' F.mapIso (eqToIso _)
theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x) := by haveI := Functor.initial_of_adjunction (hf.isOpenMap.adjunctionNhds x) convert IsIso.of_iso ((Functor.Final.colimitIso (hf.isOpenMap.functorNhds x).op ((OpenNhds.inclusion (f x)).op ⋙ f _* F) : _).symm ≪≫ colim.mapIso _) swap · fapply NatIso.ofComponents · intro U
Mathlib.Topology.Sheaves.Stalks.202_0.hsVUPKIHRY0xmFk
theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x)
Mathlib_Topology_Sheaves_Stalks
case convert_2.app C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y Z : TopCat f : X ⟶ Y hf : OpenEmbedding ⇑f F : Presheaf C X x : ↑X this : Functor.Initial (IsOpenMap.functorNhds (_ : IsOpenMap ⇑f) x) U : (OpenNhds x)ᵒᵖ ⊢ (Opens.map f).op.obj ((OpenNhds.inclusion (f x)).op.obj ((IsOpenMap.functorNhds (_ : IsOpenMap ⇑f) x).op.obj U)) = (OpenNhds.inclusion x).op.obj U
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU; exact ih U hxU set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_hom_ext TopCat.Presheaf.stalk_hom_ext @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : U) (f : F ⟶ G) : germ F x ≫ (stalkFunctor C x.1).map f = f.app (op U) ≫ germ G x := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x.1).op f) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_map_germ TopCat.Presheaf.stalkFunctor_map_germ variable (C) /-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing. refine' ?_ ≫ colimit.pre _ (OpenNhds.map f x).op exact colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) F) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward TopCat.Presheaf.stalkPushforward @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y) (x : (Opens.map f).obj U) : (f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by rw [stalkPushforward, germ, colimit.ι_map_assoc, colimit.ι_pre, whiskerRight_app] erw [CategoryTheory.Functor.map_id, Category.id_comp] rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward_germ TopCat.Presheaf.stalkPushforward_germ -- Here are two other potential solutions, suggested by @fpvandoorn at -- <https://github.com/leanprover-community/mathlib/pull/1018#discussion_r283978240> -- However, I can't get the subsequent two proofs to work with either one. -- def stalkPushforward'' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- colim.map ((Functor.associator _ _ _).inv ≫ -- whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op -- def stalkPushforward''' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- (colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) : -- colim.obj ((OpenNhds.inclusion (f x) ⋙ Opens.map f).op ⋙ ℱ) ⟶ _) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op namespace stalkPushforward @[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by -- Porting note: We need to this to help ext tactic. change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext1 j induction' j with j rcases j with ⟨⟨_, _⟩, _⟩ erw [colimit.ι_map_assoc] simp [stalkFunctor, stalkPushforward] set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward.id TopCat.Presheaf.stalkPushforward.id -- This proof is sadly not at all robust: -- having to use `erw` at all is a bad sign. @[simp] theorem comp (ℱ : X.Presheaf C) (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : ℱ.stalkPushforward C (f ≫ g) x = (f _* ℱ).stalkPushforward C g (f x) ≫ ℱ.stalkPushforward C f x := by change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext U rcases U with ⟨⟨_, _⟩, _⟩ simp [stalkFunctor, stalkPushforward] set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward.comp TopCat.Presheaf.stalkPushforward.comp theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x) := by haveI := Functor.initial_of_adjunction (hf.isOpenMap.adjunctionNhds x) convert IsIso.of_iso ((Functor.Final.colimitIso (hf.isOpenMap.functorNhds x).op ((OpenNhds.inclusion (f x)).op ⋙ f _* F) : _).symm ≪≫ colim.mapIso _) swap · fapply NatIso.ofComponents · intro U refine' F.mapIso (eqToIso _)
dsimp only [Functor.op]
theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x) := by haveI := Functor.initial_of_adjunction (hf.isOpenMap.adjunctionNhds x) convert IsIso.of_iso ((Functor.Final.colimitIso (hf.isOpenMap.functorNhds x).op ((OpenNhds.inclusion (f x)).op ⋙ f _* F) : _).symm ≪≫ colim.mapIso _) swap · fapply NatIso.ofComponents · intro U refine' F.mapIso (eqToIso _)
Mathlib.Topology.Sheaves.Stalks.202_0.hsVUPKIHRY0xmFk
theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x)
Mathlib_Topology_Sheaves_Stalks
case convert_2.app C : Type u inst✝¹ : Category.{v, u} C inst✝ : HasColimits C X Y Z : TopCat f : X ⟶ Y hf : OpenEmbedding ⇑f F : Presheaf C X x : ↑X this : Functor.Initial (IsOpenMap.functorNhds (_ : IsOpenMap ⇑f) x) U : (OpenNhds x)ᵒᵖ ⊢ op ((Opens.map f).obj (op ((OpenNhds.inclusion (f x)).obj (op ((IsOpenMap.functorNhds (_ : IsOpenMap ⇑f) x).obj U.unop)).unop)).unop) = op ((OpenNhds.inclusion x).obj U.unop)
/- Copyright (c) 2019 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison, Justus Springer -/ import Mathlib.Topology.Category.TopCat.OpenNhds import Mathlib.Topology.Sheaves.Presheaf import Mathlib.Topology.Sheaves.SheafCondition.UniqueGluing import Mathlib.CategoryTheory.Adjunction.Evaluation import Mathlib.CategoryTheory.Limits.Types import Mathlib.CategoryTheory.Limits.Preserves.Filtered import Mathlib.CategoryTheory.Limits.Final import Mathlib.Tactic.CategoryTheory.Elementwise import Mathlib.Algebra.Category.Ring.Colimits import Mathlib.CategoryTheory.Sites.Pullback #align_import topology.sheaves.stalks from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" /-! # Stalks For a presheaf `F` on a topological space `X`, valued in some category `C`, the *stalk* of `F` at the point `x : X` is defined as the colimit of the composition of the inclusion of categories `(OpenNhds x)ᵒᵖ ⥤ (Opens X)ᵒᵖ` and the functor `F : (Opens X)ᵒᵖ ⥤ C`. For an open neighborhood `U` of `x`, we define the map `F.germ x : F.obj (op U) ⟶ F.stalk x` as the canonical morphism into this colimit. Taking stalks is functorial: For every point `x : X` we define a functor `stalkFunctor C x`, sending presheaves on `X` to objects of `C`. Furthermore, for a map `f : X ⟶ Y` between topological spaces, we define `stalkPushforward` as the induced map on the stalks `(f _* ℱ).stalk (f x) ⟶ ℱ.stalk x`. Some lemmas about stalks and germs only hold for certain classes of concrete categories. A basic property of forgetful functors of categories of algebraic structures (like `MonCat`, `CommRingCat`,...) is that they preserve filtered colimits. Since stalks are filtered colimits, this ensures that the stalks of presheaves valued in these categories behave exactly as for `Type`-valued presheaves. For example, in `germ_exist` we prove that in such a category, every element of the stalk is the germ of a section. Furthermore, if we require the forgetful functor to reflect isomorphisms and preserve limits (as is the case for most algebraic structures), we have access to the unique gluing API and can prove further properties. Most notably, in `is_iso_iff_stalk_functor_map_iso`, we prove that in such a category, a morphism of sheaves is an isomorphism if and only if all of its stalk maps are isomorphisms. See also the definition of "algebraic structures" in the stacks project: https://stacks.math.columbia.edu/tag/007L -/ noncomputable section universe v u v' u' open CategoryTheory open TopCat open CategoryTheory.Limits open TopologicalSpace open Opposite variable {C : Type u} [Category.{v} C] variable [HasColimits.{v} C] variable {X Y Z : TopCat.{v}} namespace TopCat.Presheaf variable (C) /-- Stalks are functorial with respect to morphisms of presheaves over a fixed `X`. -/ def stalkFunctor (x : X) : X.Presheaf C ⥤ C := (whiskeringLeft _ _ C).obj (OpenNhds.inclusion x).op ⋙ colim set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor TopCat.Presheaf.stalkFunctor variable {C} /-- The stalk of a presheaf `F` at a point `x` is calculated as the colimit of the functor nbhds x ⥤ opens F.X ⥤ C -/ def stalk (ℱ : X.Presheaf C) (x : X) : C := (stalkFunctor C x).obj ℱ set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk TopCat.Presheaf.stalk -- -- colimit ((open_nhds.inclusion x).op ⋙ ℱ) @[simp] theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x := rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_obj TopCat.Presheaf.stalkFunctor_obj /-- The germ of a section of a presheaf over an open at a point of that open. -/ def germ (F : X.Presheaf C) {U : Opens X} (x : U) : F.obj (op U) ⟶ stalk F x := colimit.ι ((OpenNhds.inclusion x.1).op ⋙ F) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.germ TopCat.Presheaf.germ theorem germ_res (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) : F.map i.op ≫ germ F x = germ F (i x : V) := let i' : (⟨U, x.2⟩ : OpenNhds x.1) ⟶ ⟨V, (i x : V).2⟩ := i colimit.w ((OpenNhds.inclusion x.1).op ⋙ F) i'.op set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res TopCat.Presheaf.germ_res -- Porting note : `@[elementwise]` did not generate the best lemma when applied to `germ_res` theorem germ_res_apply (F : X.Presheaf C) {U V : Opens X} (i : U ⟶ V) (x : U) [ConcreteCategory C] (s) : germ F x (F.map i.op s) = germ F (i x) s := by rw [← comp_apply, germ_res] set_option linter.uppercaseLean3 false in #align Top.presheaf.germ_res_apply TopCat.Presheaf.germ_res_apply /-- A morphism from the stalk of `F` at `x` to some object `Y` is completely determined by its composition with the `germ` morphisms. -/ @[ext] theorem stalk_hom_ext (F : X.Presheaf C) {x} {Y : C} {f₁ f₂ : F.stalk x ⟶ Y} (ih : ∀ (U : Opens X) (hxU : x ∈ U), F.germ ⟨x, hxU⟩ ≫ f₁ = F.germ ⟨x, hxU⟩ ≫ f₂) : f₁ = f₂ := colimit.hom_ext fun U => by induction' U using Opposite.rec with U; cases' U with U hxU; exact ih U hxU set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_hom_ext TopCat.Presheaf.stalk_hom_ext @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : U) (f : F ⟶ G) : germ F x ≫ (stalkFunctor C x.1).map f = f.app (op U) ≫ germ G x := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x.1).op f) (op ⟨U, x.2⟩) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_functor_map_germ TopCat.Presheaf.stalkFunctor_map_germ variable (C) /-- For a presheaf `F` on a space `X`, a continuous map `f : X ⟶ Y` induces a morphisms between the stalk of `f _ * F` at `f x` and the stalk of `F` at `x`. -/ def stalkPushforward (f : X ⟶ Y) (F : X.Presheaf C) (x : X) : (f _* F).stalk (f x) ⟶ F.stalk x := by -- This is a hack; Lean doesn't like to elaborate the term written directly. -- Porting note: The original proof was `trans; swap`, but `trans` does nothing. refine' ?_ ≫ colimit.pre _ (OpenNhds.map f x).op exact colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) F) set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward TopCat.Presheaf.stalkPushforward @[reassoc (attr := simp), elementwise (attr := simp)] theorem stalkPushforward_germ (f : X ⟶ Y) (F : X.Presheaf C) (U : Opens Y) (x : (Opens.map f).obj U) : (f _* F).germ ⟨(f : X → Y) (x : X), x.2⟩ ≫ F.stalkPushforward C f x = F.germ x := by rw [stalkPushforward, germ, colimit.ι_map_assoc, colimit.ι_pre, whiskerRight_app] erw [CategoryTheory.Functor.map_id, Category.id_comp] rfl set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward_germ TopCat.Presheaf.stalkPushforward_germ -- Here are two other potential solutions, suggested by @fpvandoorn at -- <https://github.com/leanprover-community/mathlib/pull/1018#discussion_r283978240> -- However, I can't get the subsequent two proofs to work with either one. -- def stalkPushforward'' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- colim.map ((Functor.associator _ _ _).inv ≫ -- whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op -- def stalkPushforward''' (f : X ⟶ Y) (ℱ : X.Presheaf C) (x : X) : -- (f _* ℱ).stalk (f x) ⟶ ℱ.stalk x := -- (colim.map (whiskerRight (NatTrans.op (OpenNhds.inclusionMapIso f x).inv) ℱ) : -- colim.obj ((OpenNhds.inclusion (f x) ⋙ Opens.map f).op ⋙ ℱ) ⟶ _) ≫ -- colimit.pre ((OpenNhds.inclusion x).op ⋙ ℱ) (OpenNhds.map f x).op namespace stalkPushforward @[simp] theorem id (ℱ : X.Presheaf C) (x : X) : ℱ.stalkPushforward C (𝟙 X) x = (stalkFunctor C x).map (Pushforward.id ℱ).hom := by -- Porting note: We need to this to help ext tactic. change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext1 j induction' j with j rcases j with ⟨⟨_, _⟩, _⟩ erw [colimit.ι_map_assoc] simp [stalkFunctor, stalkPushforward] set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward.id TopCat.Presheaf.stalkPushforward.id -- This proof is sadly not at all robust: -- having to use `erw` at all is a bad sign. @[simp] theorem comp (ℱ : X.Presheaf C) (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : ℱ.stalkPushforward C (f ≫ g) x = (f _* ℱ).stalkPushforward C g (f x) ≫ ℱ.stalkPushforward C f x := by change (_ : colimit _ ⟶ _) = (_ : colimit _ ⟶ _) ext U rcases U with ⟨⟨_, _⟩, _⟩ simp [stalkFunctor, stalkPushforward] set_option linter.uppercaseLean3 false in #align Top.presheaf.stalk_pushforward.comp TopCat.Presheaf.stalkPushforward.comp theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x) := by haveI := Functor.initial_of_adjunction (hf.isOpenMap.adjunctionNhds x) convert IsIso.of_iso ((Functor.Final.colimitIso (hf.isOpenMap.functorNhds x).op ((OpenNhds.inclusion (f x)).op ⋙ f _* F) : _).symm ≪≫ colim.mapIso _) swap · fapply NatIso.ofComponents · intro U refine' F.mapIso (eqToIso _) dsimp only [Functor.op]
exact congr_arg op (Opens.ext <| Set.preimage_image_eq (unop U).1.1 hf.inj)
theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x) := by haveI := Functor.initial_of_adjunction (hf.isOpenMap.adjunctionNhds x) convert IsIso.of_iso ((Functor.Final.colimitIso (hf.isOpenMap.functorNhds x).op ((OpenNhds.inclusion (f x)).op ⋙ f _* F) : _).symm ≪≫ colim.mapIso _) swap · fapply NatIso.ofComponents · intro U refine' F.mapIso (eqToIso _) dsimp only [Functor.op]
Mathlib.Topology.Sheaves.Stalks.202_0.hsVUPKIHRY0xmFk
theorem stalkPushforward_iso_of_openEmbedding {f : X ⟶ Y} (hf : OpenEmbedding f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x)
Mathlib_Topology_Sheaves_Stalks