Associativity

Kapitoly: Commutativity, Associativity, Distributivity

Associativity is a property of operations such as addition or multiplication. Take a look at the following two addition notations:

$$(1 + 2) + 3\qquad \qquad 1 + (2 + 3)$$

The expressions differ only in where the parentheses are placed. But do the results differ? Both expressions lead to the same result; the sum is always equal to 6. If the placement of the parentheses does not affect the result, we say that the operation is associative. More precisely, we can write that the operation $a \circ b$ is associative if

$$(a \circ b) \circ c = a \circ (b \circ c)$$

Another operation that is associative is multiplication.

$$(2\cdot3)\cdot4 = 2\cdot(3\cdot4)=24$$

Operations that are not associative

Subtraction is not associative. For example, consider the expression (10 − 4) − 3. First, we calculate the difference in the brackets and obtain 6 − 3, which equals 3. However, if we try to calculate 10 − (4 − 3), we first evaluate the expression within the parentheses and get 10 − 1, which equals 9. This shows that changing the grouping of the numbers results in different outcomes, confirming that subtraction is not associative.

Similarly, the division operation is not associative. For example, consider the expression (64 / 4) / 2. We first calculate the expression inside the parenthesis and get 16/2, which equals 8. However, if we place the parenthesis differently, we get 64 / (4 / 2), and after calculating the expression in the parenthesis, we obtain 64 / 2, which equals 32. Therefore, the division operation is not associative.

Another typical operation that is not associative is the exponentiation.

$$\left(2^3\right)^4 \ne 2^{\left(3^4\right)}$$

Associativity refers to a single operation!

Note that associativity always refers to a single operation. If we had an expression with three numbers but different operations, we could not use the associative rule. For example:

$$(1+2)\cdot3$$

An expression contains two operations: addition and multiplication. Both operations are associative by themselves; however, we still can't use the associative rule at this point, nor can we modify it.

$$1+(2\cdot3)$$

Because the expression contains two different operations, to apply the associative rule, both operations must be either addition or multiplication.

Intersection and union

The intersection of sets is associative. For example:

$$(\left\{1{,}2,3\right\} \cap \left\{1{,}3,5\right\}) \cap \left\{1{,}5,7\right\}$$

We would first modify by computing the intersection of the sets in parentheses.

$$\left\{1{,}3\right\} \cap \left\{1{,}5,7\right\}$$

And the intersection of those sets equals {1}. If we swapped the parentheses, we would get

$$\left\{1{,}2,3\right\} \cap (\left\{1{,}3,5\right\} \cap \left\{1{,}5,7\right\})$$

and after adjusting the parentheses:

$$\left\{1{,}2,3\right\} \cap \left\{1{,}5\right\}$$

If we were to place the parentheses differently, we would again get {1}. We see that the placement of the parentheses does not matter and that the intersection of the sets is associative. Similarly, the union of sets is associative.

Word composition / concatenation

Imagine if we had a concatenation operation for parts of words, which would simply mean the concatenation of words. So "comp" + "uter" would equal "computer". Such an operation would be associative. For example, if we wrote ("com" + "pu") + "ter", we would first add the parentheses to get "compu" + "ter", which would give us the word "computer". If we swapped the parentheses to "com" + ("pu" + "ter"), we would get "com" + "puter" after adding in the parentheses, which in turn would give us the word "computer".

The maximum or minimum is associative

Consider the operation $a \lor b$, which returns the larger of the two numbers. Such an operation is associative. For example, we would modify $(5 \lor 10) \lor 7$ to $10 \lor 7$, which equals 10. Ten is the largest of the three numbers. If we rearranged the parentheses, we would get $5 \lor (10 \lor 7)$, which, after modification, is $5 \lor 10$, and that is also 10.

The minimum would behave exactly the same.