This theory consider properties of sums of monoid elements, similar to the ones formalized in the Semigroup_ZF theory for sums of semigroup elements. The main difference is that since each monoid has a neutral element it makes sense to define a sum of an empty list of monoid elements. In multiplicative notation the properties considered here can be applied to natural powers of elements (\(x^n, n\in \mathbb{N}\)) in group or ring theory or, when written additively, to natural multiplicities \(n\cdot x, n\in \mathbb{N}\)).
In this section we setup a contex (locale) with notation for sums of lists of monoid elements and prove basic properties of those sums in terms of that notation.
The locale (context) monoid1 extends the locale monoid1, adding the notation for the neutral element as \(0\) and the sum of a list of monoid elements. It also defines a notation for natural multiple of an element of a monoid, i.e. \(n\cdot x = x\oplus x\oplus ... \oplus x\) (n times).
locale monoid1 = monoid0 +
defines \( 0 \equiv \text{ TheNeutralElement}(G,f) \)
defines \( \sum s \equiv \text{Fold}(f, 0 ,s) \)
defines \( n\cdot x \equiv \sum \{\langle k,x\rangle .\ k\in n\} \)
Let's recall that the neutral element of the monoid is an element of the monoid (carrier) \(G\) and the monoid operation (\(f\) in our notation) is a function that maps \(G\times G\) to \(G\).
lemma (in monoid1) zero_monoid_oper:
shows \( 0 \in G \) and \( f:G\times G \rightarrow G \) using monoidAssum, unit_is_neutral unfolding IsAmonoid_def, IsAssociative_defThe sum of a list of monoid elements is a monoid element.
lemma (in monoid1) sum_in_mono:
assumes \( n\in nat \), \( \forall k\in n.\ q(k)\in G \)
shows \( (\sum \{\langle k,q(k)\rangle .\ k\in n\}) \in G \)proofThe reason we start from \(0\) in the definition of the summation sign in the monoid1 locale is that we want to be able to sum the empty list. Such sum of the empty list is \(0\).
lemma (in monoid1) sum_empty:
assumes \( s:0\rightarrow G \)
shows \( (\sum s) = 0 \) using assms, zero_monoid_oper, fold_empty, group0_1_L3AFor nonempty lists our \(\Sigma\) is the same as Fold1.
lemma (in monoid1) sum_nonempty:
assumes \( n \in nat \), \( s:succ(n)\rightarrow G \)
shows \( (\sum s) = \text{Fold}(f,s(0), \text{Tail}(s)) \), \( (\sum s) = \text{Fold1}(f,s) \)proofWe can pull the first component of a sum of a nonempty list of monoid elements before the summation sign.
lemma (in monoid1) seq_sum_pull_first0:
assumes \( n \in nat \), \( s:succ(n)\rightarrow G \)
shows \( (\sum s) = s(0) \oplus (\sum \text{Tail}(s)) \)proofThe first assertion of the next theorem is similar in content to seq_sum_pull_first0 formulated in terms of the expression defining the list of monoid elements. The second one shows the dual statement: the last element of a sequence can be pulled out of the sequence and put after the summation sign. So, we are showing here that \(\sum_{k=0}^{n} q_k = q_0 \oplus \sum_{k=0}^{n-1} q_{k+1} = (\sum_{k=0}^{n-1} q_k) \oplus q_n. \)
theorem (in monoid1) seq_sum_pull_one_elem:
assumes \( n \in nat \), \( \forall k\in n + 1.\ q(k) \in G \)
shows \( (\sum \{\langle k,q(k)\rangle .\ k\in n + 1\}) = q(0) \oplus (\sum \{\langle k,q(k + 1)\rangle .\ k\in n\}) \), \( (\sum \{\langle k,q(k)\rangle .\ k\in n + 1\}) = (\sum \{\langle k,q(k)\rangle .\ k\in n\}) \oplus q(n) \)proofThe sum of a singleton list is its only element,
lemma (in monoid1) seq_sum_singleton:
assumes \( q(0) \in G \)
shows \( (\sum \{\langle k,q(k)\rangle .\ k\in 1\}) = q(0) \)proofIf the monoid operation is commutative, then the sum of a nonempty sequence added to another sum of a nonempty sequence of the same length is equal to the sum of pointwise sums of the sequence elements. This is the same as the theorem prod_comm_distrib from the Semigroup_ZF theory, just written in the notation used in the monoid1 locale.
lemma (in monoid1) sum_comm_distrib0:
assumes \( f \text{ is commutative on } G \), \( n\in nat \) and \( a : n + 1 \rightarrow G \), \( b : n + 1 \rightarrow G \), \( c : n + 1 \rightarrow G \) and \( \forall j\in n + 1.\ c(j) = a(j) \oplus b(j) \)
shows \( (\sum c) = (\sum a) \oplus (\sum b) \) using assms, succ_add_one(1), sum_nonempty, semigr0_valid_in_monoid0, prod_comm_distribAnother version of sum_comm_distrib0 written in terms of the expressions defining the sequences, shows that for commutative monoids we have \(\sum_{k=0}^{n-1}q(k) \oplus p(k) = (\sum_{k=0}^{n-1} p(k))\oplus (\sum_{k=0}^{n-1} q(k))\).
theorem (in monoid1) sum_comm_distrib:
assumes \( f \text{ is commutative on } G \), \( n\in nat \) and \( \forall k\in n.\ p(k) \in G \), \( \forall k\in n.\ q(k) \in G \)
shows \( (\sum \{\langle k,p(k)\oplus q(k)\rangle .\ k\in n\}) = (\sum \{\langle k,p(k)\rangle .\ k\in n\}) \oplus (\sum \{\langle k,q(k)\rangle .\ k\in n\}) \)proofA special case of summing (or, using more notation-neutral term folding) a list of monoid elements is taking a natural multiple of a single element. This can be applied to various monoids embedded in other algebraic structures. For example a ring is a monoid with addition as the operation, so the notion of natural multiple directly transfers there. Another monoid in a ring is formed by its multiplication operation. In that case the natural multiple maps into natural powers of a ring element.
The zero's multiple of a monoid element is its neutral element.
lemma (in monoid1) nat_mult_zero:
shows \( 0\cdot x = 0 \) using sum_emptyAny multiple of a monoid element is a monoid element.
lemma (in monoid1) nat_mult_type:
assumes \( n\in nat \), \( x\in G \)
shows \( n\cdot x \in G \) using assms, sum_in_monoTaking one more multiple of \(x\) adds \(x\).
lemma (in monoid1) nat_mult_add_one:
assumes \( n\in nat \), \( x\in G \)
shows \( (n + 1)\cdot x = n\cdot x \oplus x \) and \( (n + 1)\cdot x = x \oplus n\cdot x \)proofOne element of a monoid is that element.
lemma (in monoid1) nat_mult_one:
assumes \( x\in G \)
shows \( 1\cdot x = x \)proofMultiplication of \(x\) by a natural number induces a homomorphism between natural numbers with addition and and the natural multiples of \(x\).
lemma (in monoid1) nat_mult_add:
assumes \( n\in nat \), \( m\in nat \), \( x\in G \)
shows \( (n + m)\cdot x = n\cdot x \oplus m\cdot x \)proofassumes \( e = \text{ TheNeutralElement}(G,f) \)
shows \( e \in G \wedge (\forall g\in G.\ e \oplus g = g \wedge g \oplus e = g) \)assumes \( \forall x\in X.\ b(x) \in Y \)
shows \( \{\langle x,b(x)\rangle .\ x\in X\} : X\rightarrow Y \)assumes \( n \in nat \) and \( f : X\times Y \rightarrow X \), \( a:n \rightarrow Y \), \( x\in X \), \( Y\neq 0 \)
shows \( \text{Fold}(f,x,a) = \text{FoldSeq}(f,x,a)(n) \) and \( \text{Fold}(f,x,a) \in X \)assumes \( f : X\times Y \rightarrow X \) and \( a:0\rightarrow Y \), \( x\in X \), \( Y\neq 0 \)
shows \( \text{Fold}(f,x,a) = x \)assumes \( n \in nat \)
shows \( 0 \in succ(n) \)assumes \( n \in nat \), \( f : X\times Y \rightarrow X \), \( y:succ(n)\rightarrow Y \), \( x\in X \)
shows \( \text{Fold}(f,x,y) = \text{Fold}(f,f\langle x,y(0)\rangle , \text{Tail}(y)) \)assumes \( n \in nat \) and \( a: succ(n) \rightarrow X \)
shows \( \text{Tail}(a) : n \rightarrow X \), \( \forall k \in n.\ \text{Tail}(a)(k) = a(succ(k)) \)assumes \( n \in nat \), \( s:succ(n)\rightarrow G \)
shows \( (\sum s) = \text{Fold}(f,s(0), \text{Tail}(s)) \), \( (\sum s) = \text{Fold1}(f,s) \)assumes \( s:0\rightarrow G \)
shows \( (\sum s) = 0 \)assumes \( n \in nat \) and \( n\neq 0 \)
shows \( \exists k\in nat.\ n = succ(k) \)assumes \( y \in Y \)
shows \( \{\langle x,y\rangle \} : \{x\} \rightarrow Y \)assumes \( n \in nat \), \( k \in nat \) and \( a : succ(n) \rightarrow G \), \( b: succ(k) \rightarrow G \)
shows \( (\prod a) \cdot (\prod b) = \prod (a \sqcup b) \)assumes \( a: 1 \rightarrow G \)
shows \( (\prod a) = a(0) \)assumes \( n \in nat \), \( s:succ(n)\rightarrow G \)
shows \( (\sum s) = \text{Fold}(f,s(0), \text{Tail}(s)) \), \( (\sum s) = \text{Fold1}(f,s) \)assumes \( n\in nat \), \( a:succ(n)\rightarrow X \)
shows \( a = \text{Concat}(\{\langle 0,a(0)\rangle \}, \text{Tail}(a)) \)assumes \( n\in nat \)
shows \( n + 1 = succ(n) \), \( n + 1 \in nat \), \( \{0\} + n = succ(n) \), \( n + \{0\} = succ(n) \), \( succ(n) \in nat \), \( 0 \in n + 1 \), \( n \subseteq n + 1 \)assumes \( x\in X \)
shows \( \{\langle x,b(x)\rangle .\ x\in X\}(x)=b(x) \)assumes \( n \in nat \), \( s:succ(n)\rightarrow G \)
shows \( (\sum s) = s(0) \oplus (\sum \text{Tail}(s)) \)assumes \( n \in nat \) and \( \forall k \in n + 1.\ q(k) \in X \)
shows \( \text{Tail}(\{\langle k,q(k)\rangle .\ k \in n + 1\}) = \{\langle k,q(k + 1)\rangle .\ k \in n\} \)assumes \( n \in nat \), \( f : X\times Y \rightarrow X \), \( x\in X \), \( \forall k\in n + 1.\ q(k) \in Y \)
shows \( \text{Fold}(f,x,\{\langle k,q(k)\rangle .\ k\in n + 1\}) = f\langle \text{Fold}(f,x,\{\langle k,q(k)\rangle .\ k\in n\}), q(n)\rangle \)assumes \( n \in nat \), \( \forall k\in n + 1.\ q(k) \in G \)
shows \( (\sum \{\langle k,q(k)\rangle .\ k\in n + 1\}) = q(0) \oplus (\sum \{\langle k,q(k + 1)\rangle .\ k\in n\}) \), \( (\sum \{\langle k,q(k)\rangle .\ k\in n + 1\}) = (\sum \{\langle k,q(k)\rangle .\ k\in n\}) \oplus q(n) \)assumes \( n \in nat \), \( s:succ(n)\rightarrow G \)
shows \( (\sum s) = \text{Fold}(f,s(0), \text{Tail}(s)) \), \( (\sum s) = \text{Fold1}(f,s) \)assumes \( f \text{ is commutative on } G \) and \( n\in nat \) and \( a : succ(n)\rightarrow G \), \( b : succ(n)\rightarrow G \), \( c : succ(n)\rightarrow G \) and \( \forall j\in succ(n).\ c(j) = a(j) \cdot b(j) \)
shows \( (\prod c) = (\prod a) \cdot (\prod b) \)assumes \( n\in nat \), \( n\neq 0 \)
shows \( \exists m\in nat.\ n = m #+1 \)assumes \( a\in G \), \( b\in G \)
shows \( a\oplus b \in G \)assumes \( f \text{ is commutative on } G \), \( n\in nat \) and \( a : n + 1 \rightarrow G \), \( b : n + 1 \rightarrow G \), \( c : n + 1 \rightarrow G \) and \( \forall j\in n + 1.\ c(j) = a(j) \oplus b(j) \)
shows \( (\sum c) = (\sum a) \oplus (\sum b) \)assumes \( n\in nat \), \( \forall k\in n.\ q(k)\in G \)
shows \( (\sum \{\langle k,q(k)\rangle .\ k\in n\}) \in G \)assumes \( n\in nat \), \( x\in G \)
shows \( (n + 1)\cdot x = n\cdot x \oplus x \) and \( (n + 1)\cdot x = x \oplus n\cdot x \)assumes \( n\in nat \), \( x\in G \)
shows \( n\cdot x \in G \)assumes \( a\in G \), \( b\in G \), \( c\in G \)
shows \( (a\oplus b)\oplus c = a\oplus (b\oplus c) \)assumes \( n\in nat \) and \( P(0) \) and \( \forall k\in nat.\ P(k)\longrightarrow P(k + 1) \)
shows \( P(n) \)