import OAI.AlgebraicGeometry.Resolution.Blowups.ControlledTransform import Mathlib.Algebra.Polynomial.Eval.Degree import Mathlib.Algebra.Polynomial.Derivative /-! # Residual Coefficient Transform -/ namespace OAI.AlgebraicGeometry.Resolution.Blowups.ResidualCoefficientTransform.Construction noncomputable section section /-! Coefficient compatibility with division by an exceptional parameter. -/ open _root_.Polynomial variable {R S : Type*} [CommRing R] [CommRing S] /-- Substituting `z = c * z'` and dividing by `c ^ b` divides the `j`th coefficient by `c ^ (b - j)` whenever `j ≤ b`. Regularity makes this division exact, including over coefficient rings with zero divisors. -/ theorem coefficient_controlledTransform (φ : R →+* S) (p : R[X]) (q : S[X]) (c : S) (b j : ℕ) (hc : IsRegular c) (hj : j ≤ b) (h : (p.map φ).comp (C c * X) = C (c ^ b) * q) : φ (p.coeff j) = c ^ (b - j) * q.coeff j := by have he := congrArg (fun f : S[X] => f.coeff j) h simp only [comp_C_mul_X_coeff, coeff_map, coeff_C_mul] at he apply (hc.pow j).left calc c ^ j * φ (p.coeff j) = φ (p.coeff j) * c ^ j := mul_comm _ _ _ = c ^ b * q.coeff j := he _ = c ^ j * (c ^ (b - j) * q.coeff j) := by rw [← mul_assoc, ← pow_add, Nat.add_sub_of_le hj] /-- For coefficients at or above the control exponent, the transformed coefficient instead gains the remaining exceptional power. -/ theorem coefficient_controlledTransform_above (φ : R →+* S) (p : R[X]) (q : S[X]) (c : S) (b j : ℕ) (hc : IsRegular c) (hj : b ≤ j) (h : (p.map φ).comp (C c * X) = C (c ^ b) * q) : q.coeff j = c ^ (j - b) * φ (p.coeff j) := by have he := congrArg (fun f : S[X] => f.coeff j) h simp only [comp_C_mul_X_coeff, coeff_map, coeff_C_mul] at he apply (hc.pow b).left calc c ^ b * q.coeff j = φ (p.coeff j) * c ^ j := he.symm _ = c ^ b * (c ^ (j - b) * φ (p.coeff j)) := by rw [← mul_assoc, ← pow_add, Nat.add_sub_of_le hj, mul_comm] /-- Multiplication by a regular principal ideal is exactly reversed by taking its ideal quotient. -/ theorem colon_principal_mul_of_regular (J : Ideal S) (c : S) (hc : IsRegular c) : (Ideal.span {c} * J).colon (Ideal.span {c}) = J := by ext x rw [Ideal.mem_colon_span_singleton, Ideal.mem_span_singleton_mul] constructor · rintro ⟨y, hy, he⟩ have hyx : y = x := hc.left (he.trans (mul_comm x c)) rwa [← hyx] · intro hx exact ⟨x, hx, mul_comm c x⟩ /-- The ideal generated by a family with a common factor is the product of the principal factor ideal and the ideal generated by the family. -/ theorem span_range_mul_left {ι : Type*} (c : S) (f : ι → S) : Ideal.span (Set.range (fun i => c * f i)) = Ideal.span {c} * Ideal.span (Set.range f) := by apply le_antisymm · apply Ideal.span_le.mpr rintro x ⟨i, rfl⟩ exact Ideal.mul_mem_mul (Ideal.subset_span (Set.mem_singleton c)) (Ideal.subset_span ⟨i, rfl⟩) · rw [Ideal.span_singleton_mul_le_iff] intro x hx refine Submodule.span_induction ?_ ?_ ?_ ?_ hx · rintro y ⟨i, rfl⟩ exact Ideal.subset_span ⟨i, rfl⟩ · simp · intro x y _ _ hx hy simpa only [mul_add] using Ideal.add_mem _ hx hy · intro r x _ hx simpa only [smul_eq_mul, mul_left_comm c r x] using Ideal.mul_mem_left _ r hx /-- For an arbitrary family of equations, the coefficient ideals satisfy the same exceptional-factor identity as the individual coefficients. -/ theorem coefficientIdeal_controlledTransform_factorization {ι : Type*} (φ : R →+* S) (p : ι → R[X]) (q : ι → S[X]) (c : S) (b j : ℕ) (hc : IsRegular c) (hj : j ≤ b) (h : ∀ t, ((p t).map φ).comp (C c * X) = C (c ^ b) * q t) : (Ideal.span (Set.range (fun t => (p t).coeff j))).map φ = Ideal.span {c ^ (b - j)} * Ideal.span (Set.range (fun t => (q t).coeff j)) := by rw [Ideal.map_span, ← Set.range_comp] have he : (φ ∘ fun t => (p t).coeff j) = fun t => c ^ (b - j) * (q t).coeff j := by funext t exact coefficient_controlledTransform φ (p t) (q t) c b j hc hj (h t) rw [he, span_range_mul_left] /-- Taking the controlled transform of a coefficient ideal gives exactly the ideal generated by the transformed coefficients. -/ theorem coefficientIdeal_controlledTransform {ι : Type*} (φ : R →+* S) (p : ι → R[X]) (q : ι → S[X]) (c : S) (b j : ℕ) (hc : IsRegular c) (hj : j ≤ b) (h : ∀ t, ((p t).map φ).comp (C c * X) = C (c ^ b) * q t) : ((Ideal.span (Set.range (fun t => (p t).coeff j))).map φ).colon (Ideal.span {c ^ (b - j)}) = Ideal.span (Set.range (fun t => (q t).coeff j)) := by rw [coefficientIdeal_controlledTransform_factorization φ p q c b j hc hj h, colon_principal_mul_of_regular _ _ (hc.pow (b - j))] /-- Repeated differentiation of a scaled-variable substitution contributes one factor of the scale for every derivative. -/ theorem iterate_derivative_comp_C_mul_X (p : S[X]) (c : S) (k : ℕ) : derivative^[k] (p.comp (C c * X)) = C (c ^ k) * (derivative^[k] p).comp (C c * X) := by induction k with | zero => simp | succ k ih => rw [Function.iterate_succ_apply', ih, derivative_C_mul, derivative_comp, derivative_C_mul_X, Function.iterate_succ_apply', pow_succ, map_mul] ring /-- Differentiating a transformed equation `k` times lowers its control exponent by `k`, for `k ≤ b`. -/ theorem iteratedDerivative_controlledTransform (φ : R →+* S) (p : R[X]) (q : S[X]) (c : S) (b k : ℕ) (hc : IsRegular c) (hk : k ≤ b) (h : (p.map φ).comp (C c * X) = C (c ^ b) * q) : ((derivative^[k] p).map φ).comp (C c * X) = C (c ^ (b - k)) * derivative^[k] q := by have he := congrArg (fun f : S[X] => derivative^[k] f) h rw [iterate_derivative_comp_C_mul_X, iterate_derivative_C_mul, iterate_derivative_map] at he ext j have hej := congrArg (fun f : S[X] => f.coeff j) he simp only [coeff_C_mul] at hej ⊢ apply (hc.pow k).left calc c ^ k * _ = c ^ b * (derivative^[k] q).coeff j := hej _ = c ^ k * (c ^ (b - k) * (derivative^[k] q).coeff j) := by rw [← mul_assoc, ← pow_add, Nat.add_sub_of_le hk] end section /-! Exact exceptional and residual factor bookkeeping on actual blowup charts. -/ variable {R : Type*} [CommRing R] /-- Factorwise center orders give the required total control. -/ theorem product_center_permissible (I J L : Ideal R) (u v b : ℕ) (hb : b ≤ u + v) (hJ : J ≤ I ^ u) (hL : L ≤ I ^ v) : J * L ≤ I ^ b := by have hprod : J * L ≤ I ^ (u + v) := by rw [pow_add] exact Ideal.mul_mono hJ hL exact hprod.trans (Ideal.pow_le_pow_right hb) /-- If the sum of the factor controls exceeds the total control, the unused exceptional power remains as an explicit monomial factor. -/ theorem blowup_product_controlledTransform (I J L : Ideal R) (a : I) (u v b : ℕ) (hb : b ≤ u + v) (hJ : J ≤ I ^ u) (hL : L ≤ I ^ v) : ControlledTransform.Construction.blowupControlledTransform I (J * L) b a = Ideal.span {(Blowup.Charts.Construction.blowupChartConstants I a a.val) ^ (u + v - b)} * (ControlledTransform.Construction.blowupControlledTransform I J u a * ControlledTransform.Construction.blowupControlledTransform I L v a) := by let t := Blowup.Charts.Construction.blowupChartConstants I a a.val have hfactor : (J * L).map (Blowup.Charts.Construction.blowupChartConstants I a) = Ideal.span {t ^ (u + v)} * (ControlledTransform.Construction.blowupControlledTransform I J u a * ControlledTransform.Construction.blowupControlledTransform I L v a) := by rw [Ideal.map_mul, ← ControlledTransform.Construction.blowup_controlledTransform_factorization I J u a hJ, ← ControlledTransform.Construction.blowup_controlledTransform_factorization I L v a hL, mul_mul_mul_comm, Ideal.span_singleton_mul_span_singleton, ← pow_add (Blowup.Charts.Construction.blowupChartConstants I a a.val) u v] have ht : Ideal.span {t ^ (u + v)} = Ideal.span {t ^ b} * Ideal.span {t ^ (u + v - b)} := by rw [Ideal.span_singleton_mul_span_singleton, ← pow_add t b (u + v - b), Nat.add_sub_of_le hb] change ((J * L).map (Blowup.Charts.Construction.blowupChartConstants I a)).colon (Ideal.span {t ^ b}) = _ rw [hfactor, ht, mul_assoc] exact colon_principal_mul_of_regular _ _ (IsRegular.pow (a := t) b (ExceptionalIdeal.Construction.blowupChart_exceptionalParameter_regular I a)) /-- At control zero, the controlled transform is simply the total transform. -/ theorem blowupControlledTransform_zero (I J : Ideal R) (a : I) : ControlledTransform.Construction.blowupControlledTransform I J 0 a = J.map (Blowup.Charts.Construction.blowupChartConstants I a) := by ext x simp only [ControlledTransform.Construction.blowupControlledTransform, Ideal.mem_colon_span_singleton] rw [pow_zero (Blowup.Charts.Construction.blowupChartConstants I a a.val), mul_one x] /-- When the residual control already exceeds the total control, its excess is transferred to the monomial factor. -/ theorem blowup_residual_control_excess (I M J : Ideal R) (a : I) (m b : ℕ) (hbm : b ≤ m) (hJ : J ≤ I ^ m) : ControlledTransform.Construction.blowupControlledTransform I (M * J) b a = Ideal.span {(Blowup.Charts.Construction.blowupChartConstants I a a.val) ^ (m - b)} * (M.map (Blowup.Charts.Construction.blowupChartConstants I a) * ControlledTransform.Construction.blowupControlledTransform I J m a) := by have hM : M ≤ I ^ 0 := by simp only [pow_zero, Ideal.one_eq_top, le_top] simpa only [zero_add, blowupControlledTransform_zero] using blowup_product_controlledTransform I M J a 0 m b (by simpa only [zero_add] using hbm) hM hJ end /-! One exact boundary-factor update covers both companion and excess residual controls. -/ variable {R : Type*} [CommRing R] def residualBoundaryFactorTransform (I M : Ideal R) (a : I) (m b : ℕ) : Ideal (Blowup.Charts.Construction.blowupChart I a) := Ideal.span {Blowup.Charts.Construction.blowupChartConstants I a a.val ^ (m - b)} * ControlledTransform.Construction.blowupControlledTransform I M (b - m) a theorem residualBoundaryFactorTransform_of_le (I M : Ideal R) (a : I) (m b : ℕ) (hmb : m ≤ b) : residualBoundaryFactorTransform I M a m b = ControlledTransform.Construction.blowupControlledTransform I M (b - m) a := by rw [residualBoundaryFactorTransform, Nat.sub_eq_zero_of_le hmb, pow_zero (Blowup.Charts.Construction.blowupChartConstants I a a.val), Ideal.span_singleton_one, Ideal.top_mul] theorem residualBoundaryFactorTransform_of_ge (I M : Ideal R) (a : I) (m b : ℕ) (hbm : b ≤ m) : residualBoundaryFactorTransform I M a m b = Ideal.span {Blowup.Charts.Construction.blowupChartConstants I a a.val ^ (m - b)} * M.map (Blowup.Charts.Construction.blowupChartConstants I a) := by rw [residualBoundaryFactorTransform, Nat.sub_eq_zero_of_le hbm, blowupControlledTransform_zero] theorem residual_boundary_product_controlledTransform (I M J : Ideal R) (a : I) (m b : ℕ) (hM : M ≤ I ^ (b - m)) (hJ : J ≤ I ^ m) : ControlledTransform.Construction.blowupControlledTransform I (M * J) b a = residualBoundaryFactorTransform I M a m b * ControlledTransform.Construction.blowupControlledTransform I J m a := by have h := blowup_product_controlledTransform I M J a (b - m) m b (by omega) hM hJ have he : b - m + m - b = m - b := by omega simpa only [he, residualBoundaryFactorTransform, mul_assoc] using h end end OAI.AlgebraicGeometry.Resolution.Blowups.ResidualCoefficientTransform.Construction