Given a set $X$, write $\mathrm{heaps}(X)$ for the set of all finite heaps (or 'multisets', if you prefer) on $X$.
Under this definition, it is well-known that if a binary operation $*$ on a set $X$ is
- commutative
- associative
- and has an identity
then this operation gives rise to a function $\Phi : \mathrm{heaps}(X) \rightarrow X$ in a natural way.
For example, the operation $+$ on the real numbers gives rise to the function $\sum,$ defined on finite heaps of real numbers. Similarly, $\times$ gives rise to $\prod,$ etc.
In particular, if we write $\uplus$ for the heapic sum, then $\Phi$ can be characterized as the unique function satisfying $$\Phi(H \uplus I) = \Phi(H) * \Phi(I)$$ for all $H,I \in \mathrm{heaps}(X).$
Now let $X =$ the Boolean domain, which we will denote $\mathbb{B}.$
It is a surprising fact that the operators IFF (denoted $\leftrightarrow$) and XOR (denoted $\not\leftrightarrow$) satisfy conditions 1,2 and 3, at least in classical logic. In particular, they're associative, which I don't find at all intuitive.
Anyway, it follows that $\leftrightarrow$ and $\not \leftrightarrow$ each yield a function $\mathrm{heaps}(\mathbb{B}) \rightarrow \mathbb{B}.$
I'm interested in these functions from both a logical, and an algebraic point of view.
Where can I learn more?
Discussion. Lets denote them as follows.
- The function obtained from $\leftrightarrow,$ lets denote $\mathrm{ef}.$
- The function obtained from $\not\leftrightarrow,$ lets denote $\mathrm{ot}.$
These names are motivated as follows. For $H \in \mathrm{heaps}(\mathbb{B}),$ we have that $\mathrm{ef}(H)$ is true iff an even number of elements of $H$ are false; similarly, $\mathrm{ot}(H)$ is true iff an odd number of elements of $H$ are true.
Anyway, the functions $\mathrm{ef}$ and $\mathrm{ot}$ have some seriously neat properties.
Here's what I've got so far.
Firstly, we can negate pairs without changing anything. $$\mathrm{ef}(H \uplus \{x,y\}) = \mathrm{ef}(H \uplus \{\neg x, \neg y\}),\;\; \mathrm{ot}(H \uplus \{x,y\}) = \mathrm{ot}(H \uplus \{\neg x, \neg y\})$$
Secondly, negation passes straight through uninhibited.
$$\mathrm{ef}(H \uplus \{\neg x\}) = \neg\mathrm{ef}(H \uplus \{ x\}),\;\; \mathrm{ot}(H \uplus \{\neg x\}) = \neg\mathrm{ot}(H \uplus \{ x\})$$
Thirdly, repeated variables annihilate as follows.
$$\mathrm{ef}(H \uplus \{x,x\}) = \mathrm{ef}(H),\;\; \mathrm{ot}(H \uplus \{x,x\}) = \mathrm{ot}(H)$$
Fourthly, $$\mathrm{ef}(\emptyset) = \top,\;\; \mathrm{ot}(\emptyset) = \bot$$
Fifthly, they're equal precisely when the cardinality of $H$ is odd.
$$|H| \;\mathrm{odd} \implies \mathrm{ef}(H) = \mathrm{ot}(H)$$ $$|H| \;\mathrm{even} \implies \mathrm{ef}(H) \neq \mathrm{ot}(H)$$
Sixthly, they interact nicely.
$$\mathrm{ef}(H \uplus \mathrm{ot}(I)) = \mathrm{ot}(\mathrm{ef}(H) \uplus I)$$
Seventhly, we can split into cases as follows.
$$\mathrm{ef}(H \uplus I) = [\mathrm{ef}(H) \wedge \mathrm{ef}(I)] \vee [\neg\mathrm{ot}(H) \wedge \neg\mathrm{ot}(I)]$$
$$\mathrm{ot}(H \uplus I) = [\mathrm{ot}(H) \wedge \neg\mathrm{ef}(I)] \vee [\neg\mathrm{ef}(H) \wedge \mathrm{ot}(I)]$$
Dualising the above expressions:
$$\mathrm{ot}(H \uplus I) = [\mathrm{ot}(H) \vee \mathrm{ot}(I)] \wedge [\neg\mathrm{ef}(H) \vee \neg\mathrm{ef}(I)]$$
$$\mathrm{ef}(H \uplus I) = [\mathrm{ef}(H) \vee \neg\mathrm{ot}(I)] \wedge [\neg\mathrm{ot}(H) \vee \mathrm{ef}(I)]$$
Algebraically, XOR is more usually viewed as the addition in $\mathbb Z_2$ (where 0 corresponds to false and 1 to true), which accounts for many of its nice properties -- in particular for the fact that it's associative. In this role it is often notated $\oplus$, so the multiset extension would be $\bigoplus$.
The multiplication in $\mathbb Z_2$ is just $\land$ under the same identification, so algebra and logic align nicely here. (In fact we can recover the entire logical structure from the ring operations since $A\lor B = A \oplus B \oplus (A\land B)$ and $\neg A=1\oplus B$ -- this provides the correspondence between a Boolean algebra and a Boolean ring, which is any ring in which $x^2=x$ for all $x$).
IFF is simply the De Morgan dual of $\oplus$, so it is associative (etc) as well. Alternatively we can write $(A\leftrightarrow B)=A\oplus B\oplus 1$, so by associativity and commutativity, $$ a_1 \leftrightarrow a_2 \leftrightarrow \cdots \leftrightarrow a_n = a_1 \oplus a_2 \oplus \cdots \oplus a_n \oplus \underbrace{1\oplus\cdots\oplus1}_{n-1\text{ ones}}$$ where the underbraced part is either $0$ or $1$ according to whether $n$ is odd or even.
The fact that negation "passes through" these operators can be explained by the fact that $\neg A = 1\oplus A$, and the "lifting" of negations out of $\oplus$ is then just associativity. Since $1\oplus 1=0$, an even number of negations cancel each other out.