# Mathematical operation to simulate logical OR with boolean values $\textsf{false} = 0,\ \textsf{true} = \mathbb{R}^*$

The other day I was playing around with some equations I wanted to combine and came across this problem : Let's say I have two mathematical quantities $A,B \in \mathbb{R}$. Both can be either $= 0$ or $\neq 0$. Let's define the value $\textsf{true}$ to be "$\neq 0$" and $\textsf{false}$ to be "$=0$". So $A$ and $B$ now represent boolean value.

It is easy to mathematically simulate the AND operator by multiplying $A \cdot B$ since $A\cdot B\neq 0 = \textsf{true}$ iff $A \neq 0 = \textsf{true}$ and $B \neq 0 = \textsf{true}$

But how can we simulate the OR operator using only standard functions. (Typically not "case"-functions or piecewise-function) ?

I was thinking about using DeMorgan's Law and writing $A\vee B = \neg(\neg A \wedge \neg B)$, but now we need to mathematically write "$\neg$". The hard part here is that $\textsf{true}$ can be any number except $0$, not a fixed one. I also tried to "normalize" the variable, for example by dividing it by itself but this then raises the problem of $0/0$ for $\textsf{false}$ variable. Ideally we would need an operation $F$ such that $$F(A) = \begin{cases} C & \text{if } A \neq 0 \\ 0 & \text{else} \end{cases}$$ (for some constant $C$).

Then $\neg A$ would simply be $C-F(A)$.

Thanks :)

• Do you actually need every nonzero value to be recognized as "true"? That's going to make it difficult to find a natural arithmetic representation of negation because negation would need to be discontinuous at $0$, which probably won't be possible in a way that will satisfy your ambition of avoiding definitions by cases. On the other hand, representing truth by $1$ always (and falsehoods by $0$) would allow all the boolean operations to be simple polynomials. Apr 3, 2017 at 9:47
• You can write things like $$\mathit{Neg}(A) = \left\lfloor \frac{1}{1+A^2} \right\rfloor$$ where $\lfloor \cdots\rfloor$ is the integer-part function -- but that doesn't really seem to have any real advantages over an honest definition by cases. Apr 3, 2017 at 9:49
• Or even $$\mathit{Neg}(A) = \lim_{n\to \infty} e^{-nA^2}$$ which is better at avoiding definition by cases, but even worse at conveying understanding of what you do. Apr 3, 2017 at 9:53
• @HenningMakholm Yes, you're right, negation might be really hard to achieve using "standard" functions. So we are stuck with AND and OR :| Apr 3, 2017 at 10:15

Note that the problem disappears when you consider only non-negative real numbers instead of all real numbers: in that case you could just use '$+$' for OR.

So one way of reducing your situation to this one is by squaring the variables before adding them: $x \vee y := x^2 + y^2$.

(Perhaps you heard about the polynomial in 26 variables whose only output (if you feed it 26 integers) are prime numbers? It was produced by translating the concept of 'being a prime number' to relations between polynomials in pretty much the same way we are discussing here.)

EDITTED IN: a bit more about the prime polynomial can be found here: https://mathoverflow.net/q/132954/41139. Apparently I misremembered and the output (on integer inputs) may be either a negative number or a prime number but it is still pretty amazing that whenever the outcome is positive it is prime (and every prime appears in this way).

• You are a second faster than I. Very good ;) Apr 3, 2017 at 9:05
• Of course... I feel dumb now... Thanks for your answer and thanks even more for the anecdote ! Apr 3, 2017 at 10:09

Use $X \vee Y = |X|+|Y|$ where $|X|$ is the absolute value of X
$\neg A = 1 -sign(|A|)$