Grace/Cumulus/Algebra/Polynomial/Derivative.g17
Imports
Grace.Cumulus.Algebra.Polynomial.DerivativeCoefficients · Grace.Cumulus.Algebra.Polynomial.Bundled · Grace.Cumulus.Algebra.Polynomial.BundledCoefficients
Declarations
- partialDerivative def
- LeibnizRule predicate
- leibnizPolynomials def
- partialDerivative.function theorem derivation
- partialDerivative.apply theorem derivation
- partialDerivative.map_mem instance derivation
- partialDerivative.coefficient theorem derivation
- partialDerivative.add theorem derivation
- partialDerivative.neg theorem derivation
- partialDerivative.constant theorem derivation
- partialDerivative.X_self theorem derivation
- partialDerivative.X_other theorem derivation
- partialDerivative.constant_mul theorem derivation
- partialDerivative.X_self_mul theorem derivation
- partialDerivative.X_other_mul theorem derivation
- partialDerivative.mul theorem derivation
- partialDerivative.pow theorem derivation
Source
1-- Partial derivatives of polynomials: the formal derivative in one2-- variable as a function on the bundled polynomial ring, and the rules for3-- constants, variables, sums, negatives, products, and powers.4-- Part of Cumulus, the Grace17 mathematics library.5-- Copyright (c) 2026 Grant Passmore.6-- Released under the Apache License 2.0. See LICENSE in the repository root.7-- Authors: Grant Passmore89module Grace.Cumulus.Algebra.Polynomial.Derivative10import Grace.Cumulus.Algebra.Polynomial.DerivativeCoefficients11import Grace.Cumulus.Algebra.Polynomial.Bundled12import Grace.Cumulus.Algebra.Polynomial.BundledCoefficients1314-- The derivative in the variable i as a function on the polynomial ring.15def partialDerivative (R I i : Set) : Set :=16 { q ∈ Ring.carrier(polynomialRing(R, I)) ×17 Ring.carrier(polynomialRing(R, I)) |18 snd(q) = partialDerivativeOf(R, I, i, fst(q)) }1920-- The rules of differentiation. The derivative is a function on the21-- carrier with the coefficient formula; it is additive, kills constants,22-- sends Xᵢ to 1 and the other variables to 0, satisfies the Leibniz rule23-- (first against a constant and a variable, then for all polynomials by24-- generation), and so the power rule.25predicate LeibnizRule (R I i p : Set) :=26 ∀ q ∈ Ring.carrier(polynomialRing(R, I)),27 partialDerivative(R, I, i)(call2(Ring.mul(polynomialRing(R, I)), p, q)) =28 call2(Ring.add(polynomialRing(R, I)),29 call2(Ring.mul(polynomialRing(R, I)), partialDerivative(R, I, i)(p), q),30 call2(Ring.mul(polynomialRing(R, I)), p, partialDerivative(R, I, i)(q)))3132def leibnizPolynomials (R I i : Set) : Set :=33 { f ∈ polynomials(I, Ring.carrier(R), Ring.zero(R)) |34 LeibnizRule(R, I, i, f) }3536section Rules37variable (R I i : Set)38hypothesis ring : CommRing(R)39hypothesis polynomials : CommRing(polynomialRing(R, I))40hypothesis index : i ∈ I4142theorem partialDerivative.function43 shows partialDerivative(R, I, i) :44 Ring.carrier(polynomialRing(R, I)) → Ring.carrier(polynomialRing(R, I))45proof46 constructor47 . intros e he48 exact he.left49 constructor50 . intros x y relatedY z relatedZ51 obtain ⟨_, shapeY⟩ := relatedY52 obtain ⟨_, shapeZ⟩ := relatedZ53 simp [fst.pair, snd.pair] at shapeY, shapeZ54 cc55 . intros p hp56 have polynomial := polynomialRing.member_parts at R, I, p with *57 have derivative := partialDerivativeOf.member at R, I, i, p with *58 have inCarrier := polynomialRing.member_of_parts at R, I,59 partialDerivativeOf(R, I, i, p) with *60 refine ⟨partialDerivativeOf(R, I, i, p), inCarrier, _⟩61 apply partialDerivative.membership.backward62 refine ⟨(product.pair with hp, inCarrier), _⟩63 simp [fst.pair, snd.pair]6465theorem partialDerivative.apply (p : polynomialRing(R, I))66 shows partialDerivative(R, I, i)(p) = partialDerivativeOf(R, I, i, p)67proof68 have member : p ∈ Ring.carrier(polynomialRing(R, I)) by assumption69 have polynomial := polynomialRing.member_parts at R, I, p with *70 have function := partialDerivative.function at R, I, i with *71 have derivative := partialDerivativeOf.member at R, I, i, p with *72 have inCarrier := polynomialRing.member_of_parts at R, I,73 partialDerivativeOf(R, I, i, p) with *74 have related :75 relates(partialDerivative(R, I, i), p, partialDerivativeOf(R, I, i, p))76 apply partialDerivative.membership.backward77 refine ⟨(product.pair with member, inCarrier), _⟩78 simp [fst.pair, snd.pair]79 exact FunctionBetween.apply_value with function, member, related8081instance partialDerivative.map_mem (p : polynomialRing(R, I))82 shows partialDerivative(R, I, i)(p) ∈ polynomialRing(R, I)83proof84 have member : p ∈ Ring.carrier(polynomialRing(R, I)) by assumption85 have function := partialDerivative.function at R, I, i with *86 exact FunctionBetween.apply_closed with function, member8788theorem partialDerivative.coefficient (p : polynomialRing(R, I)) (m : Set)89 requires monomial : m ∈ monomials(I)90 shows partialDerivative(R, I, i)(p)(m) =91 call2(R.mul, ringNat(R.add, R.zero, R.one, succ(m(i))),92 p(shiftMonomial(I, m, i)))93proof94 have polynomial := polynomialRing.member_parts at R, I, p with *95 have value := partialDerivative.apply at R, I, i, p with *96 rw value97 exact partialDerivativeOf.coefficient at R, I, i, p, m with *9899theorem partialDerivative.add (p q : polynomialRing(R, I))100 shows partialDerivative(R, I, i)(p + q) =101 partialDerivative(R, I, i)(p) + partialDerivative(R, I, i)(q)102proof103 have sumIn : p + q ∈ polynomialRing(R, I) := Ring.add_mem with *104 have leftIn : partialDerivative(R, I, i)(p) ∈ polynomialRing(R, I) :=105 partialDerivative.map_mem at R, I, i, p with *106 have rightIn : partialDerivative(R, I, i)(q) ∈ polynomialRing(R, I) :=107 partialDerivative.map_mem at R, I, i, q with *108 have coefficients : ∀ m ∈ monomials(I),109 partialDerivative(R, I, i)(p + q)(m) =110 (partialDerivative(R, I, i)(p) + partialDerivative(R, I, i)(q))(m)111 intros m hm112 have shifted := shiftMonomial.member at I, i, m with *113 have numeral := partialDerivativeOf.numeral_mem at R, I, i, m with *114 have pIn :=115 polynomialRing.coefficient_mem at R, I, p, shiftMonomial(I, m, i) with *116 have qIn :=117 polynomialRing.coefficient_mem at R, I, q, shiftMonomial(I, m, i) with *118 have left := partialDerivative.coefficient at R, I, i, p + q, m with *119 have right := polynomialRing.coefficient_add at R, I,120 partialDerivative(R, I, i)(p), partialDerivative(R, I, i)(q), m with *121 have derivativeP := partialDerivative.coefficient at R, I, i, p, m with *122 have derivativeQ := partialDerivative.coefficient at R, I, i, q, m with *123 have sum := polynomialRing.coefficient_add at R, I, p, q,124 shiftMonomial(I, m, i) with *125 rw [left, right, derivativeP, derivativeQ, sum]126 ring127 exact polynomialRing.ext at R, I, partialDerivative(R, I, i)(p + q),128 partialDerivative(R, I, i)(p) + partialDerivative(R, I, i)(q) with *129130theorem partialDerivative.neg (p : polynomialRing(R, I))131 shows partialDerivative(R, I, i)(-p) = -partialDerivative(R, I, i)(p)132proof133 have negIn : -p ∈ polynomialRing(R, I) := Ring.neg_mem with *134 have derivativeIn : partialDerivative(R, I, i)(p) ∈ polynomialRing(R, I) :=135 partialDerivative.map_mem at R, I, i, p with *136 have coefficients : ∀ m ∈ monomials(I),137 partialDerivative(R, I, i)(-p)(m) = (-partialDerivative(R, I, i)(p))(m)138 intros m hm139 have shifted := shiftMonomial.member at I, i, m with *140 have numeral := partialDerivativeOf.numeral_mem at R, I, i, m with *141 have pIn :=142 polynomialRing.coefficient_mem at R, I, p, shiftMonomial(I, m, i) with *143 have left := partialDerivative.coefficient at R, I, i, -p, m with *144 have right := polynomialRing.coefficient_neg at R, I,145 partialDerivative(R, I, i)(p), m with *146 have derivativeP := partialDerivative.coefficient at R, I, i, p, m with *147 have negative := polynomialRing.coefficient_neg at R, I, p,148 shiftMonomial(I, m, i) with *149 rw [left, right, derivativeP, negative]150 ring151 exact polynomialRing.ext at R, I, partialDerivative(R, I, i)(-p),152 -partialDerivative(R, I, i)(p) with *153154theorem partialDerivative.constant (a : R)155 shows partialDerivative(R, I, i)(polynomialConstant(R, I)(a)) =156 Ring.zero(polynomialRing(R, I))157proof158 have aIn : a ∈ R by assumption159 have constantIn : polynomialConstant(R, I)(a) ∈ polynomialRing(R, I) :=160 polynomialConstant.mem at R, I, a with *161 have zeroPoly : Ring.zero(polynomialRing(R, I)) ∈ polynomialRing(R, I) :=162 Ring.zero_mem with *163 have coefficients : ∀ m ∈ monomials(I),164 partialDerivative(R, I, i)(polynomialConstant(R, I)(a))(m) =165 Ring.zero(polynomialRing(R, I))(m)166 intros m hm167 have shifted := shiftMonomial.member at I, i, m with *168 have numeral := partialDerivativeOf.numeral_mem at R, I, i, m with *169 have different := shiftMonomial.ne_one at I, i, m with *170 have left := partialDerivative.coefficient at R, I, i,171 polynomialConstant(R, I)(a), m with *172 have right := polynomialRing.coefficient_zero at R, I, m with *173 have vanishes := polynomialConstant.coefficient_other at R, I, a,174 shiftMonomial(I, m, i) with *175 rw [left, right, vanishes]176 ring177 exact polynomialRing.ext at R, I,178 partialDerivative(R, I, i)(polynomialConstant(R, I)(a)),179 Ring.zero(polynomialRing(R, I)) with *180181theorem partialDerivative.X_self182 shows partialDerivative(R, I, i)(X(R, I, i)) = Ring.one(polynomialRing(R, I))183proof184 have zeroIn : R[0] ∈ R := Ring.zero_mem with *185 have oneIn : R[1] ∈ R := Ring.one_mem with *186 have variableIn : X(R, I, i) ∈ polynomialRing(R, I) :=187 X.mem at R, I, i with *188 have onePoly : Ring.one(polynomialRing(R, I)) ∈ polynomialRing(R, I) :=189 Ring.one_mem with *190 have unit := monomialOne.member at I191 have variable := monomialVariable.member at I, i192 have shiftUnit : shiftMonomial(I, monomialOne(I), i) = monomialVariable(I, i)193 have product := shiftMonomial.product at I, i, monomialOne(I) with *194 have law := monomialProduct.one with variable195 cc196 have coefficients : ∀ m ∈ monomials(I),197 partialDerivative(R, I, i)(X(R, I, i))(m) =198 Ring.one(polynomialRing(R, I))(m)199 intros m hm200 have shifted := shiftMonomial.member at I, i, m with *201 have numeral := partialDerivativeOf.numeral_mem at R, I, i, m with *202 have left := partialDerivative.coefficient at R, I, i, X(R, I, i), m with *203 rw [left, polynomialRing.oneOf]204 have alternatives : m = monomialOne(I) ∨ m ≠ monomialOne(I) by tauto205 cases alternatives with same | different206 . rw same207 have variableValue := X.coefficient_same at R, I, i with *208 have constantValue :=209 polynomialConstant.coefficient at I, R.carrier, R.zero, R.one with *210 have unitExponent := monomialOne.value at I, i with index211 have zeroNat := Naturals.constructor.zero212 have step := ringNat.succ at R.add, R.zero, R.one, 0 with *213 have base := ringNat.zero at R.add, R.zero, R.one214 rw [shiftUnit, variableValue, constantValue, unitExponent, step, base]215 ring216 . have shiftDifferent : shiftMonomial(I, m, i) ≠ monomialVariable(I, i)217 intro equal218 rw ← shiftUnit at equal219 have same :=220 shiftMonomial.injective at I, i, m, monomialOne(I) with *221 exact different with same222 have variableValue :=223 X.coefficient_other at R, I, i, shiftMonomial(I, m, i) with *224 have selected :=225 polynomialConstant.value at I, R.carrier, R.zero, R.one, m with *226 have other :=227 singleValue.other at R.carrier, R.zero, R.one, monomialOne(I), m with *228 rw [variableValue, selected, other]229 ring230 exact polynomialRing.ext at R, I, partialDerivative(R, I, i)(X(R, I, i)),231 Ring.one(polynomialRing(R, I)) with *232233theorem partialDerivative.X_other (j : Set)234 requires other : j ∈ I235 requires apart : j ≠ i236 shows partialDerivative(R, I, i)(X(R, I, j)) = Ring.zero(polynomialRing(R, I))237proof238 have zeroIn : R[0] ∈ R := Ring.zero_mem with *239 have variableIn : X(R, I, j) ∈ polynomialRing(R, I) :=240 X.mem at R, I, j with *241 have zeroPoly : Ring.zero(polynomialRing(R, I)) ∈ polynomialRing(R, I) :=242 Ring.zero_mem with *243 have coefficients : ∀ m ∈ monomials(I),244 partialDerivative(R, I, i)(X(R, I, j))(m) =245 Ring.zero(polynomialRing(R, I))(m)246 intros m hm247 have shifted := shiftMonomial.member at I, i, m with *248 have numeral := partialDerivativeOf.numeral_mem at R, I, i, m with *249 have different := shiftMonomial.ne_variable at I, i, m, j with *250 have left := partialDerivative.coefficient at R, I, i, X(R, I, j), m with *251 have right := polynomialRing.coefficient_zero at R, I, m with *252 have variableValue :=253 X.coefficient_other at R, I, j, shiftMonomial(I, m, i) with *254 rw [left, right, variableValue]255 ring256 exact polynomialRing.ext at R, I, partialDerivative(R, I, i)(X(R, I, j)),257 Ring.zero(polynomialRing(R, I)) with *258259-- The Leibniz rule against a constant and against a variable.260theorem partialDerivative.constant_mul (a : R) (q : polynomialRing(R, I))261 shows partialDerivative(R, I, i)(polynomialConstant(R, I)(a) * q) =262 polynomialConstant(R, I)(a) * partialDerivative(R, I, i)(q)263proof264 have aIn : a ∈ R by assumption265 have constantIn : polynomialConstant(R, I)(a) ∈ polynomialRing(R, I) :=266 polynomialConstant.mem at R, I, a with *267 have productIn : polynomialConstant(R, I)(a) * q ∈ polynomialRing(R, I) :=268 Ring.mul_mem with *269 have derivativeIn : partialDerivative(R, I, i)(q) ∈ polynomialRing(R, I) :=270 partialDerivative.map_mem at R, I, i, q with *271 have rightIn : polynomialConstant(R, I)(a) * partialDerivative(R, I, i)(q) ∈272 polynomialRing(R, I) := Ring.mul_mem with *273 have coefficients : ∀ m ∈ monomials(I),274 partialDerivative(R, I, i)(polynomialConstant(R, I)(a) * q)(m) =275 (polynomialConstant(R, I)(a) * partialDerivative(R, I, i)(q))(m)276 intros m hm277 have shifted := shiftMonomial.member at I, i, m with *278 have numeral := partialDerivativeOf.numeral_mem at R, I, i, m with *279 have qIn :=280 polynomialRing.coefficient_mem at R, I, q, shiftMonomial(I, m, i) with *281 have left := partialDerivative.coefficient at R, I, i,282 polynomialConstant(R, I)(a) * q, m with *283 have productValue := polynomialRing.constant_mul at R, I, a, q,284 shiftMonomial(I, m, i) with *285 have right := polynomialRing.constant_mul at R, I, a,286 partialDerivative(R, I, i)(q), m with *287 have derivativeQ := partialDerivative.coefficient at R, I, i, q, m with *288 rw [left, productValue, right, derivativeQ]289 ring290 exact polynomialRing.ext at R, I,291 partialDerivative(R, I, i)(polynomialConstant(R, I)(a) * q),292 polynomialConstant(R, I)(a) * partialDerivative(R, I, i)(q) with *293294theorem partialDerivative.X_self_mul (q : polynomialRing(R, I))295 shows partialDerivative(R, I, i)(X(R, I, i) * q) =296 q + X(R, I, i) * partialDerivative(R, I, i)(q)297proof298 have qIn : q ∈ polynomialRing(R, I) by assumption299 have variableIn : X(R, I, i) ∈ polynomialRing(R, I) :=300 X.mem at R, I, i with *301 have productIn : X(R, I, i) * q ∈ polynomialRing(R, I) :=302 Ring.mul_mem with *303 have derivativeIn : partialDerivative(R, I, i)(q) ∈ polynomialRing(R, I) :=304 partialDerivative.map_mem at R, I, i, q with *305 have shiftedIn : X(R, I, i) * partialDerivative(R, I, i)(q) ∈306 polynomialRing(R, I) := Ring.mul_mem with *307 have rightIn : q + X(R, I, i) * partialDerivative(R, I, i)(q) ∈308 polynomialRing(R, I) := Ring.add_mem with *309 have coefficients : ∀ m ∈ monomials(I),310 partialDerivative(R, I, i)(X(R, I, i) * q)(m) =311 (q + X(R, I, i) * partialDerivative(R, I, i)(q))(m)312 intros m hm313 have shifted := shiftMonomial.member at I, i, m with *314 have numeral := partialDerivativeOf.numeral_mem at R, I, i, m with *315 have qValue := polynomialRing.coefficient_mem at R, I, q, m with *316 have left :=317 partialDerivative.coefficient at R, I, i, X(R, I, i) * q, m with *318 have productForm := shiftMonomial.product at I, i, m with *319 have productValue := polynomialRing.X_mul at R, I, i, q, m with *320 have right := polynomialRing.coefficient_add at R, I, q,321 X(R, I, i) * partialDerivative(R, I, i)(q), m with *322 rw [left, productForm, productValue, right]323 have alternatives : m(i) = 0 ∨ m(i) ≠ 0 by tauto324 cases alternatives with vanishes | nonzero325 . have shiftValue := polynomialRing.X_mul_zero at R, I, i,326 partialDerivative(R, I, i)(q), m with *327 have zeroNat := Naturals.constructor.zero328 have step := ringNat.succ at R.add, R.zero, R.one, 0 with *329 have base := ringNat.zero at R.add, R.zero, R.one330 rw [shiftValue, vanishes, step, base]331 ring332 . obtain ⟨n, hn, equal⟩ := monomials.unshift at I, i, m with *333 have shiftN := shiftMonomial.member at I, i, n with *334 have exponentN := monomials.exponent with hn, index335 have naturalN := Naturals.constructor.succ with exponentN336 have numeralN := partialDerivativeOf.numeral_mem at R, I, i, n with *337 have productN := shiftMonomial.product at I, i, n with *338 have exponentM : m(i) = succ(n(i))339 have same := shiftMonomial.same at I, i, n with *340 rw equal341 exact same342 have shiftValue : (X(R, I, i) * partialDerivative(R, I, i)(q))(m) =343 partialDerivative(R, I, i)(q)(n)344 have value := polynomialRing.X_mul at R, I, i,345 partialDerivative(R, I, i)(q), n with *346 rw [equal, productN]347 exact value348 have derivativeN := partialDerivative.coefficient at R, I, i, q, n with *349 have qShift : q(shiftMonomial(I, n, i)) = q(m)350 rw equal351 rfl352 have step := ringNat.succ at R.add, R.zero, R.one, succ(n(i)) with *353 rw [shiftValue, derivativeN, qShift, exponentM, step]354 ring355 exact polynomialRing.ext at R, I, partialDerivative(R, I, i)(X(R, I, i) * q),356 q + X(R, I, i) * partialDerivative(R, I, i)(q) with *357358theorem partialDerivative.X_other_mul (j : Set) (q : polynomialRing(R, I))359 requires other : j ∈ I360 requires apart : j ≠ i361 shows partialDerivative(R, I, i)(X(R, I, j) * q) =362 X(R, I, j) * partialDerivative(R, I, i)(q)363proof364 have qIn : q ∈ polynomialRing(R, I) by assumption365 have reverse : i ≠ j by cc366 have variableIn : X(R, I, j) ∈ polynomialRing(R, I) :=367 X.mem at R, I, j with *368 have productIn : X(R, I, j) * q ∈ polynomialRing(R, I) :=369 Ring.mul_mem with *370 have derivativeIn : partialDerivative(R, I, i)(q) ∈ polynomialRing(R, I) :=371 partialDerivative.map_mem at R, I, i, q with *372 have rightIn : X(R, I, j) * partialDerivative(R, I, i)(q) ∈373 polynomialRing(R, I) := Ring.mul_mem with *374 have variableI := monomialVariable.member at I, i375 have variableJ := monomialVariable.member at I, j376 have coefficients : ∀ m ∈ monomials(I),377 partialDerivative(R, I, i)(X(R, I, j) * q)(m) =378 (X(R, I, j) * partialDerivative(R, I, i)(q))(m)379 intros m hm380 have shifted := shiftMonomial.member at I, i, m with *381 have numeral := partialDerivativeOf.numeral_mem at R, I, i, m with *382 have left :=383 partialDerivative.coefficient at R, I, i, X(R, I, j) * q, m with *384 rw left385 have alternatives : m(j) = 0 ∨ m(j) ≠ 0 by tauto386 cases alternatives with vanishes | nonzero387 . have shiftExponent : shiftMonomial(I, m, i)(j) = 0388 have value := shiftMonomial.other at I, i, m, j with *389 rw value390 exact vanishes391 have productValue := polynomialRing.X_mul_zero at R, I, j, q,392 shiftMonomial(I, m, i) with *393 have right := polynomialRing.X_mul_zero at R, I, j,394 partialDerivative(R, I, i)(q), m with *395 rw [productValue, right]396 ring397 . obtain ⟨n, hn, equal⟩ := monomials.unshift at I, j, m with *398 have productN := shiftMonomial.product at I, j, n with *399 have shiftN := shiftMonomial.member at I, i, n with *400 have exponentM : m(i) = n(i)401 have value := shiftMonomial.other at I, j, n, i with *402 rw equal403 exact value404 have commute : shiftMonomial(I, m, i) =405 monomialProduct(I, monomialVariable(I, j), shiftMonomial(I, n, i))406 have productM := shiftMonomial.product at I, i, m with *407 have productIN := shiftMonomial.product at I, i, n with *408 have assocLeft :=409 monomialProduct.associative with variableI, variableJ, hn410 have swap := monomialProduct.commutative with variableI, variableJ411 have assocRight :=412 monomialProduct.associative with variableJ, variableI, hn413 cc414 have productValue :415 (X(R, I, j) * q)(shiftMonomial(I, m, i)) = q(shiftMonomial(I, n, i))416 have value :=417 polynomialRing.X_mul at R, I, j, q, shiftMonomial(I, n, i) with *418 rw commute419 exact value420 have right : (X(R, I, j) * partialDerivative(R, I, i)(q))(m) =421 partialDerivative(R, I, i)(q)(n)422 have value := polynomialRing.X_mul at R, I, j,423 partialDerivative(R, I, i)(q), n with *424 rw [equal, productN]425 exact value426 have derivativeN := partialDerivative.coefficient at R, I, i, q, n with *427 rw [productValue, right, derivativeN, exponentM]428 rfl429 exact polynomialRing.ext at R, I, partialDerivative(R, I, i)(X(R, I, j) * q),430 X(R, I, j) * partialDerivative(R, I, i)(q) with *431432-- The Leibniz rule for all polynomials, by generation: the set of the433-- polynomials satisfying it contains the constants and the variables and434-- is closed under sums and products.435theorem partialDerivative.mul (p q : polynomialRing(R, I))436 shows partialDerivative(R, I, i)(p * q) =437 partialDerivative(R, I, i)(p) * q + p * partialDerivative(R, I, i)(q)438proof439 have parts := CommRing.parts with ring440 have pParts := polynomialRing.member_parts at R, I, p with *441 have qIn : q ∈ Ring.carrier(polynomialRing(R, I)) by assumption442 have constants : ∀ a ∈ R.carrier,443 polynomialConstant(I, R.carrier, R.zero, a) ∈444 leibnizPolynomials(R, I, i)445 intros a ha446 have value := polynomialConstant.apply at R, I, a with *447 have constantIn : polynomialConstant(R, I)(a) ∈ polynomialRing(R, I) :=448 polynomialConstant.mem at R, I, a with *449 have constantParts := polynomialRing.member_parts at R, I,450 polynomialConstant(R, I)(a) with *451 rw ← value452 apply leibnizPolynomials.membership.backward453 refine ⟨constantParts, _⟩454 intros f hf455 have derivativeF : partialDerivative(R, I, i)(f) ∈ polynomialRing(R, I) :=456 partialDerivative.map_mem at R, I, i, f with *457 have scaled := partialDerivative.constant_mul at R, I, i, a, f with *458 have vanishes := partialDerivative.constant at R, I, i, a with *459 rw [scaled, vanishes]460 ring461 have variables : ∀ j ∈ I,462 polynomialVariable(I, R.carrier, R.zero, R.one, j) ∈463 leibnizPolynomials(R, I, i)464 intros j hj465 have variableIn : X(R, I, j) ∈ polynomialRing(R, I) :=466 X.mem at R, I, j with *467 have variableParts := polynomialRing.member_parts at R, I, X(R, I, j) with *468 rw ← X.value469 apply leibnizPolynomials.membership.backward470 refine ⟨variableParts, _⟩471 intros f hf472 have derivativeF : partialDerivative(R, I, i)(f) ∈ polynomialRing(R, I) :=473 partialDerivative.map_mem at R, I, i, f with *474 have alternatives : j = i ∨ j ≠ i by tauto475 cases alternatives with same | apart476 . rw same477 have variableI : X(R, I, i) ∈ polynomialRing(R, I) :=478 X.mem at R, I, i with *479 have rule := partialDerivative.X_self_mul at R, I, i, f with *480 have unit := partialDerivative.X_self at R, I, i with *481 rw [rule, unit]482 ring483 . have rule := partialDerivative.X_other_mul at R, I, i, j, f with *484 have vanishes := partialDerivative.X_other at R, I, i, j with *485 rw [rule, vanishes]486 ring487 have sums : ∀ f ∈ leibnizPolynomials(R, I, i),488 ∀ g ∈ leibnizPolynomials(R, I, i),489 coefficientAdd(monomials(I), R.carrier, R.add, R.zero, R.neg, R.mul,490 R.one, f, g) ∈ leibnizPolynomials(R, I, i)491 intros f hf g hg492 have dataF := leibnizPolynomials.membership.forward with hf493 have dataG := leibnizPolynomials.membership.forward with hg494 have fParts := dataF.left495 have fIn := polynomialRing.member_of_parts at R, I, f with *496 have gParts := dataG.left497 have gIn := polynomialRing.member_of_parts at R, I, g with *498 have sumForm := polynomialRing.add_apply at R, I, f, g with *499 have sumIn : f + g ∈ polynomialRing(R, I) := Ring.add_mem with *500 have sumParts := polynomialRing.member_parts at R, I, f + g with *501 rw ← sumForm502 apply leibnizPolynomials.membership.backward503 refine ⟨sumParts, _⟩504 intros h hh505 have fh : f * h ∈ polynomialRing(R, I) := Ring.mul_mem with *506 have gh : g * h ∈ polynomialRing(R, I) := Ring.mul_mem with *507 have derivativeF : partialDerivative(R, I, i)(f) ∈ polynomialRing(R, I) :=508 partialDerivative.map_mem at R, I, i, f with *509 have derivativeG : partialDerivative(R, I, i)(g) ∈ polynomialRing(R, I) :=510 partialDerivative.map_mem at R, I, i, g with *511 have derivativeH : partialDerivative(R, I, i)(h) ∈ polynomialRing(R, I) :=512 partialDerivative.map_mem at R, I, i, h with *513 have ruleF := dataF.right with h, hh514 have ruleG := dataG.right with h, hh515 have distribute : (f + g) * h = f * h + g * h by ring516 have additive := partialDerivative.add at R, I, i, f * h, g * h with *517 have additiveFG := partialDerivative.add at R, I, i, f, g with *518 rw [distribute, additive, ruleF, ruleG, additiveFG]519 ring520 have products : ∀ f ∈ leibnizPolynomials(R, I, i),521 ∀ g ∈ leibnizPolynomials(R, I, i),522 polynomialProduct(I, R.carrier, R.add, R.zero, R.neg, R.mul, R.one, f, g)523 ∈ leibnizPolynomials(R, I, i)524 intros f hf g hg525 have dataF := leibnizPolynomials.membership.forward with hf526 have dataG := leibnizPolynomials.membership.forward with hg527 have fParts := dataF.left528 have fIn := polynomialRing.member_of_parts at R, I, f with *529 have gParts := dataG.left530 have gIn := polynomialRing.member_of_parts at R, I, g with *531 have productForm := polynomialRing.mul_apply at R, I, f, g with *532 have productIn : f * g ∈ polynomialRing(R, I) := Ring.mul_mem with *533 have productParts := polynomialRing.member_parts at R, I, f * g with *534 rw ← productForm535 apply leibnizPolynomials.membership.backward536 refine ⟨productParts, _⟩537 intros h hh538 have gh : g * h ∈ polynomialRing(R, I) := Ring.mul_mem with *539 have derivativeF : partialDerivative(R, I, i)(f) ∈ polynomialRing(R, I) :=540 partialDerivative.map_mem at R, I, i, f with *541 have derivativeG : partialDerivative(R, I, i)(g) ∈ polynomialRing(R, I) :=542 partialDerivative.map_mem at R, I, i, g with *543 have derivativeH : partialDerivative(R, I, i)(h) ∈ polynomialRing(R, I) :=544 partialDerivative.map_mem at R, I, i, h with *545 have derivativeGH :546 partialDerivative(R, I, i)(g * h) ∈ polynomialRing(R, I) :=547 partialDerivative.map_mem at R, I, i, g * h with *548 have ruleF := dataF.right with g * h, gh549 have ruleG := dataG.right with h, hh550 have ruleFG := dataF.right with g, gIn551 have reassociate : (f * g) * h = f * (g * h) by ring552 rw [reassociate, ruleF, ruleG, ruleFG]553 ring554 have generated := polynomials.generated at I, R.carrier, R.add, R.zero,555 R.neg, R.mul, R.one, leibnizPolynomials(R, I, i), p556 with parts, pParts, constants, variables, sums, products557 have data := leibnizPolynomials.membership.forward with generated558 exact data.right with q, qIn559560theorem partialDerivative.pow (p : polynomialRing(R, I)) (n : Nat)561 shows partialDerivative(R, I, i)(p ^ (n + 1)) =562 ringNat(Ring.add(polynomialRing(R, I)), Ring.zero(polynomialRing(R, I)),563 Ring.one(polynomialRing(R, I)), n + 1) * p ^ n *564 partialDerivative(R, I, i)(p)565proof566 induction n567 | zero =>568 have pIn : p ∈ polynomialRing(R, I) by assumption569 have derivativeIn :570 partialDerivative(R, I, i)(p) ∈ polynomialRing(R, I) :=571 partialDerivative.map_mem at R, I, i, p with *572 have onePoly : Ring.one(polynomialRing(R, I)) ∈ polynomialRing(R, I) :=573 Ring.one_mem with *574 have plus := add.left_unit at 1575 have one := Ring.pow_one at polynomialRing(R, I), p with *576 have zeroPow := Ring.pow_zero at polynomialRing(R, I), p with *577 have numeralOne := IsRing.numeral_one with578 (Ring.parts with (CommRing.to_ring with polynomials))579 rw [plus, one, zeroPow, numeralOne]580 ring581 | succ(k) using ih =>582 have pIn : p ∈ polynomialRing(R, I) by assumption583 have derivativeIn :584 partialDerivative(R, I, i)(p) ∈ polynomialRing(R, I) :=585 partialDerivative.map_mem at R, I, i, p with *586 have shift := add.right_one at k with *587 rw ← shift588 have powerIn : p ^ (k + 1) ∈ polynomialRing(R, I) :=589 Ring.pow_mem at polynomialRing(R, I), p, k + 1 with *590 have powerK : p ^ k ∈ polynomialRing(R, I) :=591 Ring.pow_mem at polynomialRing(R, I), p, k with *592 have numeralIn : ringNat(Ring.add(polynomialRing(R, I)),593 Ring.zero(polynomialRing(R, I)), Ring.one(polynomialRing(R, I)), k + 1)594 ∈ polynomialRing(R, I) :=595 Ring.numeral_mem at polynomialRing(R, I), k + 1 with *596 have step := Ring.pow_succ at polynomialRing(R, I), p, k + 1 with *597 have product := partialDerivative.mul at R, I, i, p ^ (k + 1), p with *598 have powStep := Ring.pow_succ at polynomialRing(R, I), p, k with *599 have shiftOne := add.right_one at k + 1 with *600 have numeralStep := ringNat.succ at Ring.add(polynomialRing(R, I)),601 Ring.zero(polynomialRing(R, I)), Ring.one(polynomialRing(R, I)), k + 1602 with *603 rw [step, product, ih, shiftOne, numeralStep, powStep]604 ring605606end Rules607