# Represent addition or subtraction of two non-negative integers without using the + or - operators

This is more of a fun puzzle than a problem born out of necessity, but I would like to know if there is a way to represent the more fundamental operations of addition and subtraction without using the operators + and -, or some "coverup" function that does just that behind the scenes, so to speak.

One way I could think of was finding out the cardinal number of a set of all integers from the negative of the first addend up till the second addend like so:-

\begin{align} &A = { \{x : x \in \mathbb{Z}, -b \leq x < a\} } \\ &n(A) = a + b \end{align}

Similarly for subtraction, \begin{align} &B = { \{x : x \in \mathbb{Z}, b \leq x < a\} } \\ &n(B) = a - b \end{align}

But I am curious if there is a better, cleverer, more elegant solution to this.

• It feels like cheating a bit, but you could always take the Peano arithmetic approach and define a Successor function for example S(2)=3, S(S(2))=4 etc and then define the inverse function to obtain a form of subtraction...? Commented May 1 at 6:54
• What operations are allowed? Commented May 1 at 6:58
• @RedFive, I had thought of recursion, and the successor function in particular, but I did not think it to be valid because S(x) feels like addition in disguise, albeit, I should have made it clearer in the post. Commented May 1 at 7:05
• @ultralegend5385, I have edited the question :) Commented May 1 at 7:09
• This question is ill-posed. What do you actually mean by "using" the addition or subtraction operations, and how would an equivalent operation avoid that use? Because of its equivalence, any operation will necessarily be "covering up" ordinary addition. This seems like avoiding counting using the ordinary natural numbers 1, 2, 3, 4,... by using variables a, b, c, d,... and an equivalent arithmetic structure (a+a=b, a+b=c, ...). If its structure is no different, is that really any different from the natural numbers?
– Jam
Commented May 5 at 14:16

Electronic circuitry accomplishes addition (usually of numbers represented in base 2) with a composition of these strictly simpler logical operations:

$$\begin{array}{ccc} \begin{array}{c|cc} \oplus & 0 & 1 \\ \hline 0 & 0 & 1 \\ 1 & 1 & 0 \end{array} & \begin{array}{c|cc} \land & 0 & 1 \\ \hline 0 & 0 & 0 \\ 1 & 0 & 1 \end{array} & \begin{array}{c|cc} \lor & 0 & 1 \\ \hline 0 & 0 & 1 \\ 1 & 1 & 1 \end{array} \end{array}$$

Then if one wants to add

$$\begin{array}{cccccc} && a_n & a_{n-1} & \cdots & a_1 & a_0 \\ + && b_n & b_{n-1} & \cdots & b_1 & b_0 \\ \hline & c_{n+1} & s_n & s_{n-1} & \cdots & s_1 & s_0 \end{array}$$

one obtains $$s_i = (a_i \oplus b_i) \oplus c_i\\$$

where $$c_0 = 0$$ and

$$c_i = (a_{i-1} \land b_{i-1})\; \lor \;(c_{i-1}\land (a_{i-1}\oplus b_{i-1}))$$

when $$i>0$$.

For engineering reasons, $$\oplus, \land$$, and $$\lor$$ are usually themselves constructed from the single operation $$\def\nand{\bar\land}\nand$$:

$$\begin{array}{c|cc} \nand & 0 & 1 \\ \hline 0 & 1 & 1 \\ 1 & 1 & 0 \end{array}$$

Subtraction is accomplished very similarly, using two's-complement arithmetic.

Something similar can be done even with base-10 numerals.

You can compute $$a+b = \log e^ae^b$$

using a multiplication to replace the addition.

Normally we use this trick in reverse, to replace multiplication with addition, because addition is easier. But it works just as well if for some reason you want to go to other way.