Simplify (a + b) XOR (c + b) [closed]
Asked Answered
C

2

6

Is it possible to simplify (a+b)xor(c+b)? What is the contribution of b to the final result? Note that I'm mixing boolean algebra with arithmetic, xor is a bitwise exclusive or on corresponding bits and + is a standard addition on 8 bits, that wraps around when overflown. a, b, c are unsigned char;

Chalcopyrite answered 5/3, 2014 at 15:41 Comment(1)
Unlikely, since XOR is purely bitwise, whereas addition affects adjacent bits.Campanulaceous
N
5

We can use an SMT solver to test our hypothesis that your formula can be simplified. You can head over to http://rise4fun.com:

x = BitVec('x', 8)
y = BitVec('y', 8)
z = BitVec('z', 8)

print simplify((x + z) ^ (y + z))

and the result, anticlimactically, is:

x + z ^ y + z

Which means your formula cannot be further simplified.

Naval answered 5/3, 2014 at 16:15 Comment(3)
I don't see any hypothesis in the question!Cassiodorus
This result does not make sense x + z ^ y + z . Original sum is symmetrical around x and y, whereas a result is not.Hargeisa
@SalvadorDali: It does make sense if you consider Python operator precedence, which Z3 uses: docs.python.org/3/reference/expressions.html#index-77Naval
P
3
(a+b)xor(c+b) 
--------------
=((not(a+b))*(c+b))+((a+b)*(not(c+b))) 
-----------------------
=((not a)*(not b)*(c+b))+((a+b)*(not c)*(not b)) 
----
=((not a)(not b)*c) + (a*(not c)(not b)) 
----
=(not b)((not a)c + a(not c)) 
----
=(not b)(a xor c)
----
Pasia answered 8/5, 2020 at 11:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.