where operators with subscript Z denote the default operator of integers. the result of the operators will give a result as an integer within the range [−231,231]. For example the operators behave like the following table
a
b
a+b
a−b
a×b
ab
a/b
a∖b
a÷b
0
0
0
0
0
0
231
231
231
2
4
6
-2
8
16
1
0
1
1
3
4
-2
3
1
1
0
0
2
-4
-2
6
-8
0
0
-1
0
231
231
231
0
231
231
1
1
1
−231
231
0
−231
−231
231
-1
-1
-1
The question is, using any constant between [−231,231] and operators +,−,×,ab,/,∖,÷ defined above, construct all comparison and logic operators on integers between [−231,231] that will output 0,1 only, which represent a false or true result respectively. The operators to construct are ≡,≡,<,≤,≥,>,¬,∨,∧, which represent equals, not equals, less than, less than or equal, greater than or equal, greater than, logic not, logic or and logic and respectively, that is
a≡ba≡ba<ba≤ba≥ba>b¬aa∨ba∧b={10(a=b)(otherwise)={10(a=b)(otherwise)={10(a less than b)(otherwise)={10(a less than or equal b)(otherwise)={10(a greater than or equal b)(otherwise)={10(a greater than b)(otherwise)={10(a=0)(otherwise)={10(a=0 or b=0)(otherwise)={10(a=0 and b=0)(otherwise)
For example the operators should behave like the following table
a
b
a≡b
a≡b
a<b
a≤b
a≥b
a>b
¬a
a∨b
a∧b
0
0
1
0
0
1
1
0
1
0
0
0
-2
0
1
0
0
1
1
1
1
0
-2
2
0
1
1
1
0
0
0
1
1
-10
-10
1
0
0
1
1
0
0
1
1
Story behind
During secondary school I was making games using twf (an unofficial name I gave to the game making feature inside Twilight Wars, a Taiwan online flash game, where twf is the file extension it used), I developed quite a number of techniques to bypass its limitations and optimize the flow, and made a website twftechniques with my friends. In particular, there was a hack to do branching in twf since there was no if-else support until very late stage. For example when we are placing an NPC ch0001 depending on some boolean value x, that is x either 0 or 1, we can do it by
A.0 = (0,0)
A.1 = (1,1)
move ch0001 to A.{x}
Twf will replace the {x} with the actual value of x, so when x is 0, it will move ch0001 to (0,0), and when x is 1, it will move ch0001 to (1,1). See, no if is needed, but we achieved branching here!
However, twf only supported arithmetic operators on integers, we could not do arithmetics on comparison result nor logic calculation, there is no such thing bool b = z && (x > y) || (j != k) in twf, not even bool b = x == y , unlike what we can do in modern programming language. Therefore I developed some techniques to do boolean algebra in terms of integers and ordinary arithmetics only, and this is the origin of the question.