The AND and OR functions are "monotonic." By definition, this means that if you start with any setting of the input bits, then change one of the input bits from zero to one, the output can either remain unchanged or change from zero to one; he can never change from one to zero. You can prove it from the truth tables.
The composition of monotonic functions is a monotonic function. It is also easy to prove.
XOR is not a monotonous function. (Consider the binary input XOR, in which both inputs are equal to one, then change one to zero.)
Therefore, it is impossible to do what you ask.
source share