# Full-subtractor boolean expression minimization

I'm looking at the standard full subtractor circuit and have been trying to understand how the circuit is derived/synthesized based on a web tutorial.

I can follow the derivation of the truth table in the image below:

Which subsequently leads to the first boolean expression in the next image below. However I can't figure out how to minimize the expression to the exclusive OR format.

I've tried re-arranging the equation such that it looks like D = B(!X!Y + XY) + !B(!XY + X!Y). I think the first section of the expression in brackets corresponds to the truth table of an EX-NOR gate and the second section of the expression in brackets corresponds to the truth table of an XOR gate.....any tips on how to proceed or an explanation of the minimization would be greatly appreciated!

You can pretty much see by inspection of the truth table that the sum (difference) is just a 3-input XOR.

Consider:

• With B-in = 0, Diff = X XOR Y
• With B-in = 1, Diff = X XNOR Y = !(X XOR Y)

B-in = 1 inverts X XOR Y, while B-in = 0 does not. Thus, we have:

• Diff = B-in XOR (X XOR Y).

Some things I'll pile on here.

First, https://math.stackexchange.com/questions/2480640/boolean-expression-of-3-input-xor-gate This answer shows some worked examples in how to render the 3-input XOR as min terms. The key is that XOR is associative, you can rearrange the inputs. You can decompose each XOR as a product-of-sum or sum-of-products and rearrange accordingly.

Second, want really minimal? Consider transmission gates: https://ieeexplore.ieee.org/document/9864422

Third, just for grins, here's the 3-input XOR rendered as two 2 cascaded XORs in transmission gate logic (simulate it here):

By my reckoning, that's just 12 transistors for that function, the same as three 2-input gates. No ‘regular’ logic minimization (that is, one that doesn’t use T-gates) is going to yield that.

If !X and !Y were available, the two inverters could be dropped, reducing the transistor count to just 8.

• Thank you for your response hacktastical, much appreciated! That does make sense when looking at the truth table and attempting to solve it through inspection; However do you have any insight into using boolean minimization to solve the equation? Commented Aug 3, 2023 at 17:45
• It depends on what kind of minimization you're looking for. Using XOR is the fewest number of gates, and arguably the fewest number of transistors. You could render this function as product terms (you need 4) then work on it that way. Anyway, have a look at what Wolfram Alpha does to it: wolframalpha.com/… Commented Aug 3, 2023 at 18:10
• Thank you for the quick reply! The link to the math stack exchange problem was exactly what I was looking for and I can now see in reverse how the solution is found with the associative and distributive laws. I wasn't aware that wolfram worked with this kind of logical equation, thanks for the tip and again thank you for the assistance! Commented Aug 3, 2023 at 19:47
• @DriedApple If you can afford a home or student version of Mathematica, you may be amazed at what’s possible in terms of operating on all sorts of symbolic formulas, including ones that have domain of booleans. Wolfram language is 35 years old now, and the kernel “knows” of all the basic theorems out there and can apply them. There probably is a logic minimization example notebook if you look for it. Commented Aug 3, 2023 at 20:58