Grace/Cumulus/Algebra/Ring/IdentitySum.g17
Imports
Grace.Cumulus.Algebra.Ring.IndexedSum
Declarations
- indexedRingSum.identity_mem theorem derivation
- indexedRingSum.identity_bilinear theorem derivation
- indexedRingSum.identity_add theorem derivation
- indexedRingSum.identity_zero theorem derivation
- indexedRingSum.identity_single theorem derivation
- RingHom.sum_zero theorem derivation
Source
1-- Finite sums of the values of a graph on n in a bundled ring, with the2-- identity as the weight: membership, bilinear combinations and sums,3-- vanishing, a sum with a single nonzero term, and the image of a sum4-- under a ring homomorphism killing every term.5-- Part of Cumulus, the Grace17 mathematics library.6-- Copyright (c) 2026 Grant Passmore.7-- Released under the Apache License 2.0. See LICENSE in the repository root.8-- Authors: Grant Passmore910module Grace.Cumulus.Algebra.Ring.IdentitySum11import Grace.Cumulus.Algebra.Ring.IndexedSum1213-- Finite sums of the values of a graph on n in a bundled ring, with the14-- identity as the weight: membership, bilinear combinations and sums,15-- vanishing, and a sum with a single nonzero term.16section Sums17variable (S : Set)18hypothesis comm : CommRing(S)1920theorem indexedRingSum.identity_mem (g : Set, n : Nat)21 shows (∀ k ∈ n, g(k) ∈ Ring.carrier(S)) →22 indexedRingSum(identity(Ring.carrier(S)), g, Ring.add(S), Ring.zero(S), n)23 ∈ Ring.carrier(S)24proof25 intro values26 have parts := CommRing.parts with comm27 have weighted :28 WeightedValues(identity(Ring.carrier(S)), g, Ring.carrier(S), n)29 intros k hk30 have member := values with k, hk31 have value := identity.apply at g(k), Ring.carrier(S) with member32 rw value33 exact member34 exact indexedRingSum.closed at S.carrier, S.add, S.zero, S.neg, S.mul, S.one,35 identity(Ring.carrier(S)), g, n with parts, weighted3637theorem indexedRingSum.identity_bilinear (g h s a b : Set, n : Nat)38 requires left : a ∈ Ring.carrier(S)39 requires right : b ∈ Ring.carrier(S)40 shows (∀ k ∈ n, g(k) ∈ Ring.carrier(S)) →41 (∀ k ∈ n, h(k) ∈ Ring.carrier(S)) →42 (∀ k ∈ n, s(k) = call2(Ring.add(S), call2(Ring.mul(S), g(k), b),43 call2(Ring.mul(S), a, h(k)))) →44 indexedRingSum(identity(Ring.carrier(S)), s, Ring.add(S), Ring.zero(S), n) =45 call2(Ring.add(S),46 call2(Ring.mul(S), indexedRingSum(identity(Ring.carrier(S)), g,47 Ring.add(S), Ring.zero(S), n), b),48 call2(Ring.mul(S), a, indexedRingSum(identity(Ring.carrier(S)), h,49 Ring.add(S), Ring.zero(S), n)))50proof51 induction n52 | zero =>53 intros valuesG valuesH equations54 have zeroIn : S[0] ∈ S := Ring.zero_mem with *55 simp [indexedRingSum]56 ring57 | succ(k) using ih =>58 intros valuesG valuesH equations59 have prefixG : ∀ l ∈ k, g(l) ∈ Ring.carrier(S)60 intros l hl61 have next := membership.into_successor at l, k with hl62 exact valuesG with l, next63 have prefixH : ∀ l ∈ k, h(l) ∈ Ring.carrier(S)64 intros l hl65 have next := membership.into_successor at l, k with hl66 exact valuesH with l, next67 have prefixS : ∀ l ∈ k, s(l) = call2(Ring.add(S),68 call2(Ring.mul(S), g(l), b), call2(Ring.mul(S), a, h(l)))69 intros l hl70 have next := membership.into_successor at l, k with hl71 exact equations with l, next72 have lastG := valuesG with k, membership.self_successor at k with *73 have lastH := valuesH with k, membership.self_successor at k with *74 have lastS := equations with k, membership.self_successor at k with *75 have previous := ih with prefixG, prefixH, prefixS76 have sumG := indexedRingSum.identity_mem at S, g, k with *, prefixG77 have sumH := indexedRingSum.identity_mem at S, h, k with *, prefixH78 have leftIn : call2(Ring.mul(S), g(k), b) ∈ Ring.carrier(S) :=79 Ring.mul_mem with *80 have rightIn : call2(Ring.mul(S), a, h(k)) ∈ Ring.carrier(S) :=81 Ring.mul_mem with *82 have sumIn : call2(Ring.add(S), call2(Ring.mul(S), g(k), b),83 call2(Ring.mul(S), a, h(k))) ∈ Ring.carrier(S) :=84 Ring.add_mem with *85 have sIn : s(k) ∈ Ring.carrier(S)86 rw lastS87 exact sumIn88 have valueG := identity.apply at g(k), Ring.carrier(S) with lastG89 have valueH := identity.apply at h(k), Ring.carrier(S) with lastH90 have valueS := identity.apply at s(k), Ring.carrier(S) with sIn91 rw [indexedRingSum, indexedRingSum, indexedRingSum, previous,92 valueG, valueH, valueS, lastS]93 ring9495-- A sum of sums is the bilinear combination with both scalars one.96theorem indexedRingSum.identity_add (g h s : Set, n : Nat)97 shows (∀ k ∈ n, g(k) ∈ Ring.carrier(S)) →98 (∀ k ∈ n, h(k) ∈ Ring.carrier(S)) →99 (∀ k ∈ n, s(k) = call2(Ring.add(S), g(k), h(k))) →100 indexedRingSum(identity(Ring.carrier(S)), s, Ring.add(S), Ring.zero(S), n) =101 call2(Ring.add(S),102 indexedRingSum(identity(Ring.carrier(S)), g, Ring.add(S), Ring.zero(S),103 n),104 indexedRingSum(identity(Ring.carrier(S)), h, Ring.add(S), Ring.zero(S),105 n))106proof107 intros valuesG valuesH equations108 have oneIn : S[1] ∈ S := Ring.one_mem with *109 have scaled : ∀ k ∈ n, s(k) = call2(Ring.add(S),110 call2(Ring.mul(S), g(k), S[1]), call2(Ring.mul(S), S[1], h(k)))111 intros k hk112 have gIn := valuesG with k, hk113 have hIn := valuesH with k, hk114 have sum := equations with k, hk115 rw sum116 ring117 have sumG := indexedRingSum.identity_mem at S, g, n with *, valuesG118 have sumH := indexedRingSum.identity_mem at S, h, n with *, valuesH119 have bilinear := indexedRingSum.identity_bilinear at S, g, h, s, S[1], S[1], n120 with comm, oneIn, oneIn, valuesG, valuesH, scaled121 rw bilinear122 ring123124theorem indexedRingSum.identity_zero (g : Set, n : Nat)125 shows (∀ k ∈ n, g(k) = Ring.zero(S)) →126 indexedRingSum(identity(Ring.carrier(S)), g, Ring.add(S), Ring.zero(S), n)127 = Ring.zero(S)128proof129 induction n130 | zero =>131 intro values132 rw indexedRingSum133 rfl134 | succ(k) using ih =>135 intro values136 have prefix : ∀ l ∈ k, g(l) = Ring.zero(S)137 intros l hl138 have next := membership.into_successor at l, k with hl139 exact values with l, next140 have last := values with k, membership.self_successor at k with *141 have previous := ih with prefix142 have zeroIn : S[0] ∈ S := Ring.zero_mem with *143 have value := identity.apply at Ring.zero(S), Ring.carrier(S) with zeroIn144 rw [indexedRingSum, previous, last, value]145 ring146147theorem indexedRingSum.identity_single (g m v : Set, n : Nat)148 requires value : v ∈ Ring.carrier(S)149 shows m ∈ n → (∀ k ∈ n, k ≠ m → g(k) = Ring.zero(S)) →150 g(m) = v →151 indexedRingSum(identity(Ring.carrier(S)), g, Ring.add(S), Ring.zero(S), n)152 = v153proof154 induction n155 | zero =>156 intros position others same157 exfalso158 rw nat.zero at position159 exact set.empty with position160 | succ(k) using ih =>161 intros position others same162 have zeroIn : S[0] ∈ S := Ring.zero_mem with *163 have valueZero :=164 identity.apply at Ring.zero(S), Ring.carrier(S) with zeroIn165 have shape := membership.successor_forward{n := k} with position166 cases shape with inside | atLast167 . have prefixOthers : ∀ l ∈ k, l ≠ m → g(l) = Ring.zero(S)168 intros l hl different169 have next := membership.into_successor at l, k with hl170 have step := others with l, next171 exact step with different172 have previous := ih with inside, prefixOthers, same173 have different : k ≠ m174 intro equal175 rw equal at inside176 exact membership.irreflexive with inside177 have step := others with k, membership.self_successor at k with *178 have last := step with different179 rw [indexedRingSum, previous, last, valueZero]180 ring181 . have prefixZero : ∀ l ∈ k, g(l) = Ring.zero(S)182 intros l hl183 have next := membership.into_successor at l, k with hl184 have different : l ≠ m185 intro equal186 rw [equal, atLast] at hl187 exact membership.irreflexive with hl188 have step := others with l, next189 exact step with different190 have vanishing :=191 indexedRingSum.identity_zero at S, g, k with *, prefixZero192 have valueV := identity.apply at v, Ring.carrier(S) with value193 have last : g(k) = v194 rw ← atLast195 exact same196 rw [indexedRingSum, vanishing, last, valueV]197 ring198199end Sums200201-- A ring homomorphism kills a sum all of whose terms it kills.202theorem RingHom.sum_zero (S T f g : Set, m : Nat)203 requires sourceRing : CommRing(S)204 requires targetRing : CommRing(T)205 requires hom : f : S →+* T206 shows (∀ k ∈ m, g(k) ∈ Ring.carrier(S)) →207 (∀ k ∈ m, f(g(k)) = Ring.zero(T)) →208 f(indexedRingSum(identity(Ring.carrier(S)), g, Ring.add(S), Ring.zero(S),209 m)) = Ring.zero(T)210proof211 induction m212 | zero =>213 intros values zeros214 rw indexedRingSum215 exact RingHom.map_zero with hom216 | succ(k) using ih =>217 intros values zeros218 have prefix : ∀ l ∈ k, g(l) ∈ Ring.carrier(S)219 intros l hl220 have next := membership.into_successor at l, k with hl221 exact values with l, next222 have prefixZeros : ∀ l ∈ k, f(g(l)) = Ring.zero(T)223 intros l hl224 have next := membership.into_successor at l, k with hl225 exact zeros with l, next226 have last := values with k, membership.self_successor at k with *227 have lastZero := zeros with k, membership.self_successor at k with *228 have previous := ih with prefix, prefixZeros229 have sumIn := indexedRingSum.identity_mem at S, g, k with sourceRing, prefix230 have value := identity.apply at g(k), Ring.carrier(S) with last231 have mapped := RingHom.map_add at f, S, T,232 indexedRingSum(identity(Ring.carrier(S)), g, Ring.add(S), Ring.zero(S),233 k), g(k) with *234 rw [indexedRingSum, value, mapped, previous, lastZero]235 ring236