Median algebra

In mathematics, a median algebra is a set with a ternary operation &lt; x,y,z &gt; satisfying a set of axioms which generalise the notion of median, or majority vote, as a Boolean function.

The axioms are
 * 1)   &lt; x,y,y &gt; = y
 * 2)   &lt; x,y,z &gt; = &lt; z,x,y &gt;
 * 3)   &lt; x,y,z &gt; = &lt; x,z,y &gt;
 * 4)   &lt; &lt; x,w,y &gt; ,w,z &gt; = &lt; x,w, &lt; y,w,z &gt; &gt;

The second and third axioms imply commutativity: it is possible (but not easy) to show that in the presence of the other three, axiom (3) is redundant. The fourth axiom implies associativity. There are other possible axiom systems: for example the two also suffice.
 * &lt; x,y,y &gt; = y
 * &lt; u,v, &lt; u,w,x &gt; &gt; = &lt; u,x, &lt; w,u,v &gt; &gt;

In a Boolean algebra the median function $$\langle x,y,z \rangle = (x \vee y) \wedge (y \vee z) \wedge (z \vee x)$$ satisfies these axioms, so that every Boolean algebra is a median algebra.

Birkhoff and Kiss showed that a median algebra with elements 0 and 1 satisfying &lt; 0,x,1 &gt; = x is a distributive lattice.