# Addition and subtraction with “?” and “!”

The symbols "!" and "?" stands for addition and subtraction, (not necessarily in that order) but for subtraction it can be the left argument subtract for the right or vice versa. e.g. a!b can be a-b, a+b or b-a. Variables and brackets can be used as usual. How to write $20a-18b$ for sure, with 'a' and 'b'?

My attempt: in the contest I found an expression that equals to 2(a-b), but I can't remember what it was. It's like ((a!b)?a)!((b?a)!b) or something like that. But I don't know how to add two different things in general.

Is it possible to form an expression that represent a+b?

Edit: $(a!a?a)?[(a!a)?(a!a)]=a$

• Can you explain the rules here more precisely? Are we looking for an expression that has a fixed meaning, no matter how ! and ? are interpreted (with one being addition and the other being subtraction in some order)? Does each symbol always have to be interpreted with the same meaning? – Eric Wofsey May 6 '18 at 23:08
• The same symbol has to have the same meaning. – abc... May 6 '18 at 23:09
• One example is that $(a!b)?(b!a)=0$. If $!$ is minus, the two parenthesized things are negatives and we add them. If $!$ is plus the two parenthesized strings are both $a+b$ and we subtract them. – Ross Millikan May 6 '18 at 23:12
• @abc...: I thought it showed the general approach that is needed for the problem. We need to find clever ways to combine the operators so we get the same answer despite the swapping of the meanings. – Ross Millikan May 6 '18 at 23:14
• @MishaLavrov Tournament of the Towns 2018 A level Q7 – abc... May 6 '18 at 23:38

Let me write the interpretations of any string using ? and ! as a 4-tuple. The first entry is the interpretation where ? is addition and ! is subtraction, the second is where ? is addition and ! is reversed subtraction, the third is where ? is subtraction and ! is addition, and the fourth is where ? is reversed subtraction and ! is addition. So for instance, I will write $$a?b=(a+b,a+b,a-b,b-a)$$ and $$a!b=(a-b,b-a,a+b,a+b).$$
The key trick is that we can negate one entry of a tuple at a time. Indeed, notice first that $$(a!a)?(a!a)=(0,0,0,0)$$ (and so I will subsequently abbreviate this string as just $0$). Therefore $$0!a=(-a,a,a,a),$$ $$a!0=(a,-a,a,a),$$ $$0?a=(a,a,-a,a),$$ and $$a?0=(a,a,a,-a).$$ Let me write the above four expressions as $F_1(a)$, $F_2(a)$, $F_3(a)$, and $F_4(a)$ (so $F_i$ just negates the $i$th coordinate).
It is now easy to make addition and negation. The addition $a+b$ can be made as $$F_4(a)?F_3(b)=(a+b,a+b,a-(-b),b-(-a))=(a+b,a+b,a+b,a+b).$$ We can also make $-a$ as $F_1(F_2(F_3(F_4(a))))$. By composing addition and negation, we can now easily represent $ma+nb$ for any integers $m$ and $n$.