Go backward to 4.7.1 Minimum and MaximumGo up to 4.7 Arithmetic NotionsGo forward to 4.7.3 Binomials

### 4.7.2 Arithmetic Quantifiers

Frequently we want to construct the sum of a collection of values.

Definition 56 (Sum Quantifier) If x is a variable, F is a formula and T is a term, then the following is a term with bound variable x:
(sumx, F T).
The value of this term is 0, if F does not hold for any x; otherwise it is, for some x that satisfies F, the sum of the value of T and of the value of the term for all other x, i.e.,
 (forall x: ~F) => (sumx, F T) = 0; (forall y: F[x <- y] => (sumx, F T) = T[x <- y] + (sumx, F /\  x != y T)).

Please note that the value of the term is only defined if there do not exist infinitely many x such that F holds.

Usually F contains the condition x in N, which is therefore not written explicitly. Also the variable x is usually not written but has to be deduced from the context.

Example
(sum1 <= i <= n i2) = (sumi, (i in N /\  1 <= i /\  i <= n) i2);
(sum1 <= i <= 5 i2) = 12+22+32+42+52;
(sum1 <= i <= 0 i5) = 0;
(sum1 <= i <= 9 (x-i)2) = (x-1)2 + (sum2 <= i <= 9 (x-i)2)
(sum1 <= i <= n xi) = (sum1 <= i <= n /\  even(i) xi) + (sum1 <= i <= n /\  odd(i) xi)

Example  Let a := [3, 1, 2, 9, 0, 7]. We have
(sum0 <= i <= 5 ai*10i) = 709213.
In general, for any finite sequence d of "decimal digits" the term
(sum0 <= i < length(d) di*10i)
denotes the value of this sequence in the decimal number system. Likewise, for any finite sequence b of binary digits 0 and 1, the value
(sum0 <= i < length(b) bi*2i)
denotes the value of this sequence in the binary number system, e.g., the value of [0, 1, 1, 0, 1] is
1*24+0*23+1*22+1*21+0*20=22.

The quantifier may also bind multiple variables.

Example
(sum1 <= i <= 5, 1 <= j <= 3 i*j) = 1*1+1*2+1*3+ (sum2 <= i <= 5, 1 <= j <= 3 i*j)
(sum1 <= i <= 3, 1 <= j <= i i*j) = 1*1 + 2*1 + 2*2 + 3*1 + 3*2 +3*3.

We have a number of important identities.

Proposition 58 (Sum Quantifier) For all variables i and j and formulas F (in which j does not occur freely), G (in which i does not occur freely), and H and terms T and U we have:
(sumi, F T) * (sumj, G U) = (sumi, F (sumj, G T*U)).
(sumi, F (sumj, G T)) = (sumj, G (sumi, F T)) = (sumi, j, F /\  G T).
(sumi, F T) + (sumi, H T) = (sumi, F \/ H T) + (sumi, F /\  H T).
Furthermore, if term C is a term in which i does not occur freely, we have:
(sumi, F C*T) = C*(sumi, F T).
(sumi, F C) = n*C (where n is the number of i for which F holds).

Example
(sum1 <= i <= n xi) * (sum1 <= j <= m xj) = (sum1 <= i <= n (sum1 <= j <= m xi+j)) = (sum1 <= i <= n /\  1 <= j <= m xi+j).
(sum1 <= i <= n (sum1 <= j <= m i*xj)) = (sum1 <= i <= n (i*(sum1 <= j <= m xj))).

Likewise we often wish to construct the product of a collection of values.

Definition 57 (Product Quantifier) If x is a variable, F is a formula and T is a term, then the following is a term with bound variable x:
(prodx, F T).
The value of this term is 1, if F does not hold for any x; otherwise it is, for some x that satisfies F, the product of the value of T and of the value of the term for all other x, i.e.,
 (forall x: ~F) => (prodx, F T) = 1; (forall y: F[x <- y] => (prodx, F T) = T[x <- y] + (prodx, F /\  x != y T)).

The same remarks apply as for the definition of the sum quantifier.

Example
(prod1 <= i <= 0 i5) = 1;
(prod0 <= i <= 5 ai) = a0*a1*a2*a3*a4*a5
(prod0 <= i <= 100 ai) = a0*a1*a2* (prod3 <= i <= 100 ai)
(prod0 <= i <= 100 ai) = (prod0 <= i <= 50 ai) * (prod51 <= i <= 100 ai)
(prod1 <= i <= 3, 1 <= j <= i i+j) = (1+1)*(2+1)*(2+2)*(3+1)*(3+2)*(3+3).

We have the following identities.

Proposition 59 (Product Quantifier) For all variables i and j and formulas F (in which j does not occur freely), G (in which i does not occur freely), and H and terms T and U we have:
(prodi, F (prodj, G T)) = (prodj, G (prodi, F T)) = (prodi, j, F /\  G T).
(prodi, F T) * (prodi, H T) = (prodi, F \/ H T) * (prodi, F /\  H T).
Furthermore, if term C is a term in which i does not occur freely, we have:
(prodi, F C*T) = Cn(prodi, F T) (where n is the number of i for which F holds).
(prodi, F C) = Cn (where n is the number of i for which F holds)

With the help of the product quantifier we can now formulate the uniqueness of prime number composition stated in Section Natural Numbers.

Proposition 60 (Prime Number Factorization) For every natural number n != 0, there exists a unique prime number factorization:
forall n in N>0: (exists p: pf(n, p) /\  (forall q: pf(n, q) => p=q)).
A prime number factorization of n is a sequence of pairs (p, e) ordered by the primes p such that n is the product of all pe.
 pf(n, p) : <=> p: N -> N×N /\ (forall i in N: p(i)0 is prime  /\  p(i)0 < p(i+1)0) /\ (exists k in N: n = (prod0 <= i <= k p(i)0p(i)1) /\  forall i > k: p(i)1 = 0)

Example  Because 300=22*31*52, we have for 300 the prime number factorization
[<2, 2>, <3, 1>, <5, 2>, <7, 0>, <11, 0>, <13, 0>, ...].
Likewise, 1 has the prime number factorization
[<2, 0>, <3, 0>, <5, 0>, <7, 0>, <11, 0>, <13, 0>, ...].

Author: Wolfgang Schreiner
Last Modification: October 4, 1999