We will take the following as a general definition of
multiple-valued logic:
\begin{definition}
A multiple-valued logic is a tuple $L=(D, \wedge, 1, \vee, 0, \justconsteq)$
where:
\begin{itemize}
\item $D$ is a finite set of truth values $\{d_1, \ldots, d_m\}$.
\item $\wedge$ is an associative, commutative binary operation on $D$, with identity 1;
\item $\vee$ is an associative, commutative binary operation on $D$, and 0 is its identity;
\item $x \wedge 0 = 0$ and $x \vee 1=1$ (base laws)
\item $\justconsteq:D \times D \rightarrow D$ is an equality operator:
$\consteq{x}{y}=1$ if $x=y$, 0 otherwise. Note that this is not the ordinary
equality predicate, since it maps back into the set $D$ of logic values. Also,
in formulae, we constrain the second argument always to be a literal,
never an expression.
\end{itemize}
\end{definition}
\begin{example}
Ordinary boolean logic is defined by the tuple $(\{0,1\}, \wedge, 1, \vee, 0,
\justconsteq)$. In general, for some propositional variable
$x$, we write $\phi_1(x)$ simply as $x$ (since $\phi_1$ is the
identity function), and $\phi_0(x)$ as $\neg x$.
So the exclusive-or function can be written in full as
$x \oplus y = (\consteq{x}{1}) \wedge (\consteq{y}{0}) \vee (\consteq{x}{0}
\wedge \consteq{y}{1})$ or
just, in the more familiar notation, as $x\wedge\neg y \vee \neg x \wedge y$.
\end{example}
For any multiple-valued logic $L$, we can define a {\bf case}-statement:
$$
case(x, y_1, \ldots, y_m)=(\consteq{x}{d_1})\wedge y_1 \vee \cdots \vee
(\consteq{x}{d_m})\wedge y_m$$
which is equivalent to the usual imperative presentation of a {\bf case}-statement:
\begin{verbatim}
switch(x) {
case d1:
return y1;
break;
...
case dm;
return ym;
break;
}
\end{verbatim}
A non-boolean example illustrates why, in general, the $\justconsteq$
is needed as well as the usual boolean connectives.
\begin{example}
A three-valued logic can be defined over the truth values $\{T,M,F\}$ for
true, maybe, and false. These truth-tables give the definition of $\vee$
and $\wedge$: SHOW TRUTH TABLES.
Negation is defined as follows:
$\neg T = F, \neg M = M, \neg F = T$. The function $f(x)$ which maps T and
M to T cannot be written symbolically using only $\wedge, \vee$, and $\neg$: but
it can be expressed as $\consteq{x}{M} \vee \consteq{x}{T}$.
\end{example}