4 ms·
These are helpful and show how any gate can be made from NAND: https://en.wikipedia.org/wiki/NAND_logic https://en.wikipedia.org/wiki/NAND_logic https://www.n
by Aardwolf 5y ago
These are helpful and show how any gate can be made from NAND:
https://en.wikipedia.org/wiki/NAND_logic https://en.wikipedia.org/wiki/NAND_logic
https://www.nand2tetris.org/ https://www.nand2tetris.org/
- pbsd 5y agoAny boolean function can be represented as a polynomial over the integers modulo 2 (that is, its algebraic normal form). Modulo 2, AND is multiplication and XOR is addition. We also have the useful properties 1+1=0, x+x=0, and x^2 = x. Thus: NAND(0, 0) = 0*0 + 1 = 1 NAND(x, y) = x*y + 1 AND(x, y) = NAND(NAND(x, y), NAND(x, y)) = (x*y + 1)*(x*y + 1) + 1 = x*y + x*y + x*y + 1 + 1 = x*y XOR(x, y) = NAND(NAND(x, NAND(x, y)), NAND(y, NAND(x, y))) = (x * (x*y + 1) + 1) * (y * (x*y + 1) + 1) + 1 = (x*y + x + 1) * (x*y + y + 1) + 1 = x*y + x*y + x*y + x*y + x*y + x + x*y + y + 1 + 1 = x + y Since both AND and XOR can be obtained from NAND, any polynomial can be constructed. It also becomes obvious that you can't get x*y from x+y and vice-versa, so neither XOR nor AND can be universal gates on their own. NOR's algebraic form is x*y + x + y + 1, from which you can similarly derive AND and XOR. XNOR is x + y + 1, from which AND cannot be obtained.
- eynsham 5y agoAh yes, this is probably a more intuitive way of doing things than in my comment (though of course we prove different things).⁰ I should add that for those interested, the SEP page on algebraic propositional logic is quite interesting, although I regrettably have not actually gotten round to working through it.¹ 0: https://news.ycombinator.com/item?id=28756727 https://news.ycombinator.com/item?id=28756727 1: https://plato.stanford.edu/entries/logic-algebraic-propositional https://plato.stanford.edu/entries/logic-algebraic-propositi...
- mynameismon 5y agoIs there an explanation as to why can we do this? i.e. Why can NAND and NOR be used to form all other gates? And why not AND, say?
- goohle 5y agoIt's not possible to implement inversion using AND or OR.
- amalcon 5y agoYou need a function of more inputs than outputs in order to compose into a function of multiple inputs and a single output. This rules out NOT. Then, we just need to rule out all functions that can't build NOT (i.e. invert one of their inputs). AND and OR obviously can't do this. XOR and XNOR can, but only if you can guarantee a consistent synthetic input, which is not a good requirement from either a theoretical or practical perspective. NAND and NOR can implement NOT by just repeating the same input twice.
- cevi 5y agoThis is the topic of "clone theory": the study of which (multivariable) operations can be created by composing together a starting collection of operations. Post's lattice is a complete description of which gates can be generated from which other gates in two-valued logic, but the subject becomes much more difficult in multivalued logic. If you are just interested in whether a given gate would allow you to generate all possible operations in a multivalued logic, then there is a nice result called the Rosenberg Completeness Theorem that says, roughly speaking, that any operation which doesn't have a nice property (from a certain explicit list of nice properties, such as monotonicity, linearity, etc.) will generate all other operations. To answer your question, NAND is special because it isn't monotone, isn't linear (in the sense of not being a linear function modulo 2), isn't self-dual, doesn't send all-0s to 0, and doesn't send all-1s to 1.
- goto11 5y agoThe important quality of NAND and NOR gates is they can be used as inverters. Send the same value to both inputs and the output will be the inverse. Without an inverter you can't really get anywhere. There are 8 possible truth tables for two inputs, so we have 8 possible gates. But two of them are obviously useless, the one which yield true for any input and one which yield false for any input. So we have 6 useful gates. These are AND, OR, XOR, NAND, NOR and XNOR. Of these, only NAND and NOR can be used as inverters. Given an inverter and any of the gates you can build any other. E.g AND with an inverted output is NAND, NAND with inverted inputs are OR, OR with inverted output is NOR. XOR can be build by combining NAND and OR.