In the Semigroup theory we introduced a notion of \( \text{SetFold}(f,a,\Lambda ,r) \) that represents the sum of values of some function \(a\) valued in a semigroup where the arguments of that function vary over some set \(\Lambda\). Using the additive notation something like this would be expressed as \(\sum_{x\in \Lambda} f(x)\) in informal mathematics. This theory considers an alternative to that notion that is more specific to commutative semigroups.
The \(r\) parameter in the definition of \( \text{SetFold}(f,a,\Lambda ,r) \) (from Semigroup_ZF) represents a linear order relation on \(\Lambda\) that is needed to indicate in what order we are summing the values \(f(x)\). If the semigroup operation is commutative the order does not matter and the relation \(r\) is not needed. In this section we define a notion of summing up values of some function \(a : X \rightarrow G\) over a finite set of indices \(\Gamma \subseteq X\), without using any order relation on \(X\).
We define the sum of values of a function \(a: X\rightarrow G\) over a set \(\Lambda\) as the only element of the set of sums of lists that are bijections between the number of values in \(\Lambda\) (which is a natural number \(n = \{0,1, .. , n-1\}\) if \(\Lambda\) is finite) and \(\Lambda\). The notion of \( \text{Fold1}(f,c) \) is defined in Semigroup_ZF as the fold (sum) of the list \(c\) starting from the first element of that list. The intention is to use the fact that since the result of summing up a list does not depend on the order, the set \( \{ \text{Fold1}(f,a\circ b).\ b \in \text{bij}( |\Lambda |, \Lambda )\} \) is a singleton and we can extract its only value by taking its union.
definition
\( \text{CommSetFold}(f,a,\Lambda ) = \bigcup \{ \text{Fold1}(f,a\circ b).\ b \in \text{bij}(|\Lambda |, \Lambda )\} \)
the next locale sets up notation for writing about summation in commutative semigroups. We define two kinds of sums. One is the sum of elements of a list (which are just functions defined on a natural number) and the second one represents a more general notion the sum of values of a semigroup valued function over some set of arguments. Since those two types of sums are different notions they are represented by different symbols. However in the presentations they are both intended to be printed as \(\sum \).
locale commsemigr
assumes csgassoc: \( f \text{ is associative on } G \)
assumes csgcomm: \( f \text{ is commutative on } G \)
defines \( x + y \equiv f\langle x,y\rangle \)
assumes csgaisfun: \( a : X \rightarrow G \)
defines \( \sum k \equiv \text{Fold1}(f,k) \)
defines \( \sum (A,h) \equiv \text{CommSetFold}(f,h,A) \)
Definition of a sum of function over a set in notation defined in the commsemigr locale.
lemma (in commsemigr) CommSetFolddef:
shows \( (\sum (A,a)) = (\bigcup \{\sum (a\circ b).\ b \in \text{bij}(|A|, A)\}) \) using CommSetFold_defThe next lemma states that the result of a sum does not depend on the order we calculate it. This is similar to lemma prod_order_irr in the Semigroup theory, except that the semigr1 locale assumes that the domain of the function we sum up is linearly ordered, while in commsemigr we don't have this assumption.
lemma (in commsemigr) sum_over_set_bij:
assumes A1: \( A \in \text{FinPow}(X) \), \( A \neq 0 \) and A2: \( b \in \text{bij}(|A|,A) \)
shows \( (\sum (A,a)) = (\sum (a\circ b)) \)proofThe result of a sum is in the semigroup. Also, as the second assertion we show that every semigroup valued function generates a homomorphism between the finite subsets of a semigroup and the semigroup. Adding an element to a set coresponds to adding a value.
lemma (in commsemigr) sum_over_set_add_point:
assumes A1: \( A \in \text{FinPow}(X) \), \( A \neq 0 \)
shows \( \sum (A,a) \in G \) and \( \forall x \in X-A.\ \sum (A \cup \{x\},a) = (\sum (A,a)) + a(x) \)proofassumes \( A \in \text{FinPow}(X) \)
shows \( |A| \in nat \) and \( A \approx |A| \)assumes \( n \in nat \)
shows \( \text{IsLinOrder}(n,Le) \)assumes \( f \in \text{bij}(A,B) \) and \( \text{IsLinOrder}(B,R) \)
shows \( \text{IsLinOrder}(A, \text{InducedRelation}(f,R)) \)assumes \( f:X\rightarrow Y \) and \( A\subseteq X \)
shows \( \text{restrict}(f,A) : A \rightarrow Y \)assumes \( f \text{ is commutative on } G \) and \( A \in \text{FinPow}(X) \), \( A \neq 0 \) and \( b \in \text{bij}(|A|,A) \), \( c \in \text{bij}(|A|,A) \)
shows \( (\prod (a\circ b)) = (\prod (a\circ c)) \)assumes \( f : A\rightarrow B \) and \( g : X \rightarrow C \) and \( B\subseteq X \)
shows \( g\circ f = \text{restrict}(g,B)\circ f \)assumes \( y\in X \) and \( \forall x\in X.\ \forall y\in X.\ P(x) = P(y) \)
shows \( (\bigcup \{P(x).\ x\in X\}) = P(y) \)assumes \( A \in \text{FinPow}(X) \)
shows \( \exists b.\ b \in \text{bij}(|A|, A) \)assumes \( A \in \text{FinPow}(X) \), \( A \neq 0 \) and \( b \in \text{bij}(|A|,A) \)
shows \( (\sum (A,a)) = (\sum (a\circ b)) \)assumes \( A \in \text{FinPow}(X) \) and \( A \neq 0 \)
shows \( \exists n \in nat.\ |A| = succ(n) \)assumes \( g:A\rightarrow B \) and \( f:C\rightarrow D \) and \( B \subseteq C \)
shows \( f\circ g : A \rightarrow D \)assumes \( n \in nat \) and \( a : succ(n) \rightarrow G \)
shows \( (\prod a) \in G \)assumes \( x \in X \)
shows \( \{x\} \in \text{FinPow}(X) \)assumes \( A \in \text{FinPow}(X) \) and \( B \in \text{FinPow}(X) \)
shows \( A \cup B \in \text{FinPow}(X) \)assumes \( n \in nat \) and \( b \in \text{bij}(n,X) \) and \( x \notin X \)
shows \( \text{Append}(b,x) \in \text{bij}(succ(n), X \cup \{x\}) \)assumes \( A \in \text{FinPow}(X) \) and \( a \in X-A \)
shows \( |A \cup \{a\}| = succ( |A| ) \), \( |A \cup \{a\}| = |A| \cup \{|A|\} \)assumes \( f:X\rightarrow Y \) and \( Y\subseteq Z \)
shows \( f:X\rightarrow Z \)assumes \( n \in nat \) and \( a : n \rightarrow X \) and \( x \in X \) and \( c : X \rightarrow Y \)
shows \( c\circ \text{Append}(a,x) : succ(n) \rightarrow Y \), \( c\circ \text{Append}(a,x) = \text{Append}(c\circ a, c(x)) \)assumes \( n \in nat \) and \( a : succ(n) \rightarrow G \) and \( x\in G \)
shows \( (\prod a\hookleftarrow x) = (\prod a) \cdot x \)