Three-valued Boolean logic has the same operands and basic values as two-valued logic (i.e. with TRUE, FALSE) plus an additional value FAIL. Since two-valued logic is equivalent to arithmetic modulo 2 under some simple transformations, I wondered what transformations were needed to convert three-valued logic to arithmetic modulo 3.
This must have been done before, but I couldn't find anything on the net, so with a bit of help from Maple I figured it out. I started by assuming that xor mapped to multiplication as in arithmetic modulo 2. Now, x xor FAIL is FAIL for all x, so clearly if xor is multiplication, then FAIL must map to 0, the only number with this property.
Assuming FAIL is 0, then 1 and -1 are left for TRUE and FALSE. Since TRUE xor TRUE = FALSE then TRUE has to be -1 and FALSE has to be 1. This means not is just negation. We get iff with no more work as it's just the negation of xor.
At this point I wasn't sure of how to handle the rest, specifically and. Obviously addition had to be involved somewhere, since it's the other ring operation modulo 3. Straightforward addition is obviously wrong. I took a general linear function of two variables, and tried to solve it against the truth table for and using Maple's msolve command. No luck.
I realized then that since we're working modulo 3 rather than modulo 2, that we can't just discard squares like before; powers can go up to 2, but after that, they can be reduced by Fermat's Little Theorem. So I took a function of the form ax2y2+ bx2y+cxy2+ dx2+exy+fy2+ gx+hy+i and tried to solve it against the truth table for and, with success. The rest followed straightaway, since all the logical operations can be written in terms of and, or, and not.
So, to conclude: ternary logic is equivalent to arithmetic in the ring Z/3Z under the transformations:
Note that another nice fact is that since not is just negation, the dual of a boolean function f(x1,...,xn) is just -f(-x1,...,-xn).
There's a nice correspondence between multiplication and xor, but there's no nice boolean function g(x,y) which maps to x+y under these transformations, as far as I know. Is there one?