I realize I'm a 'little' late, but here goes for future generations:
In order to avoid the exponential expension described in the question we have to introduce new variables and make two expressions 1) make expression that encodes a number 2) make an expression that can compare against the encoding
I'm using binary encoding here so 3 -> 11 and 9 -> 1001, this should be familiar to programmers
Now let's introduce a full adder (google this). This will add three bits returning two new variables 'sum' and 'carry'
Sum is 1 only if an odd number of bits are 1: (Sum & ((a&-b&-c)|(-a&b&-c)|(-a&-b&c)|(a&b&c))) | (-sum & -((a&-b&-c)|(-a&b&-c)|(-a&-b&c)|(a&b&c)))
Carry is 1 if at least 2 bits are 1: (Carry & ((a&b)|(a&c)|(c&b))|( -Carry & -((a&b)|(a&c)|(c&b)))
This now encodes the sum of two variables. This principle can be chained in order to add any number it variables (Google that too)
For comparison e.g. with 3 where ex is the encoded number: -En&...-E2&E1&E0 (because three is ...000011 in binary)
I hope it helps somebody, cheers!