diff --git a/Electronics_and_Hardware/Digital_circuits/Logic_gates.md b/Electronics_and_Hardware/Digital_circuits/Logic_gates.md index f88db6a..fcaf06f 100644 --- a/Electronics_and_Hardware/Digital_circuits/Logic_gates.md +++ b/Electronics_and_Hardware/Digital_circuits/Logic_gates.md @@ -8,9 +8,12 @@ tags: [logic-gates, binary] # Logic gates -> [A logic gate consists in] three connections where there may or may not be some electricity. Two of those connections are places where electricity may be put into the device, and the third connection is a place where electricity may come out of the device. (Scott, 2009 p.21) +> [A logic gate consists in] three connections where there may or may not be some electricity. Two of those connections are places where electricity may be put into the device, and the third connection is a place where electricity may come out of the device. + +[J.C. Scott. 2009. **But How Do It Know? The Basics of Computers for Everyone**, 21] + +Logic gates are the basic building blocks of digital computing. **A logic gate is an electrical circuit that has one or more than one input and only one output.** The input controls the output and the logic determining which types of input (on/off) lead to specific outputs (on/off) is identical to the truth-conditions of the [Boolean connectives](/Logic/Truth-functional_connectives.md) specifiable in terms of [truth tables](/Logic/Truth-tables.md). -Logic gates are the basic building blocks of digital computing. **A logic gate is an electrical circuit that has one or more than one input and only one output.** The input controls the output and the logic determining which types of input (on/off) lead to specific outputs (on/off) is identical to the truth-conditions of the [Boolean connectives](/Logic/Truth-functional_connectives.md) specifiable in terms of [truth-tables](/Logic/Truth-tables.md). Physically, what 'travels through' the gates is electrical current and what constitutes the 'gate' is a [transistor](/Electronics_and_Hardware/Digital_circuits/Transistors.md) responding to the current. At the next level of abstraction it is bits that go into the gate and bits which come out: binary information that may be either 1 or 0. ## NOT gate @@ -23,10 +26,10 @@ Physically, what 'travels through' the gates is electrical current and what cons ### Truth conditions -| P | ~ P | -| --- | --- | -| T | F | -| F | T | +| $P$ | $\lnot P$ | +| --- | --------- | +| 1 | 0 | +| 0 | 1 | ### Interactive circuit @@ -40,12 +43,12 @@ Physically, what 'travels through' the gates is electrical current and what cons ### Truth conditions -| P | Q | P & Q | -| --- | --- | ----- | -| T | T | T | -| T | F | F | -| F | T | F | -| F | F | F | +| $P$ | $Q$ | $P \land Q$ | +| --- | --- | ----------- | +| 1 | 1 | 1 | +| 1 | 0 | 0 | +| 0 | 0 | 0 | +| 0 | 0 | 0 | ### Interactive circuit @@ -59,12 +62,12 @@ Physically, what 'travels through' the gates is electrical current and what cons ### Truth conditions -| P | Q | ~(P & Q) | -| --- | --- | -------- | -| T | T | F | -| T | F | F | -| F | T | F | -| F | F | T | +| $P$ | $Q$ | $\lnot(P \land Q)$ | +| --- | --- | ------------------ | +| 1 | 1 | 0 | +| 1 | 0 | 0 | +| 0 | 1 | 0 | +| 0 | 0 | 1 | ### Interactive circuit @@ -80,12 +83,12 @@ NAND is a **universal logic gate**: equipped with just a NAND we can represent e ### Truth conditions -| P | Q | P v Q | -| --- | --- | ----- | -| T | T | T | -| T | F | T | -| F | T | T | -| F | F | F | +| $P$ | $Q$ | $P \lor Q$ | +| --- | --- | ---------- | +| 1 | 1 | 1 | +| 1 | 0 | 1 | +| 0 | 1 | 1 | +| 0 | 0 | 0 | ### Interactive circuit @@ -99,12 +102,12 @@ NAND is a **universal logic gate**: equipped with just a NAND we can represent e ### Truth conditions -| P | Q | ~(P <> Q) | -| --- | --- | --------- | -| T | T | F | -| T | F | T | -| F | T | T | -| F | F | F | +| $P$ | $Q$ | $\lnot(P \Leftrightarrow Q)$ | +| --- | --- | ---------------------------- | +| 1 | 1 | 0 | +| 1 | 0 | 1 | +| 0 | 1 | 1 | +| 0 | 0 | 0 | ### Interactive circuit @@ -118,15 +121,11 @@ NAND is a **universal logic gate**: equipped with just a NAND we can represent e ### Truth conditions -| P | Q | P v Q | -| --- | --- | ----- | -| T | T | F | -| T | F | F | -| F | T | F | -| F | F | T | +| $P$ | $Q$ | $P \lor Q$ | +| --- | --- | ---------- | +| 1 | 1 | 0 | +| 1 | 0 | 0 | +| 0 | 1 | 0 | +| 0 | 0 | 1 | ### Interactive circuit - -## References - -Scott, J. Clark. 2009. _But how do it know?: the basic principles of computers for everyone_. Self-published. diff --git a/Logic/Propositional_logic/Boolean_function_synthesis.md b/Logic/Propositional_logic/Boolean_function_synthesis.md index 4c0b55f..500b629 100644 --- a/Logic/Propositional_logic/Boolean_function_synthesis.md +++ b/Logic/Propositional_logic/Boolean_function_synthesis.md @@ -9,7 +9,9 @@ tags: [logic, propositional-logic, nand-to-tetris] When we looked at [boolean functions](/Logic/Propositional_logic/Boolean_functions.md) we were working in a particular direction: from a function to a truth table. When we do Boolean function synthesis we work in the opposite direction: from a truth table to a function. -This is an important skill that we will use when constructing [logic circuits](/Electronics_and_Hardware/Digital_circuits/Digital_circuits.md). We will go from truth conditions (i.e. what we want the circuit to do and when we want it to do it) to a function expression which is then reduced to its simplest form and implemented with [logic gates](/Electronics_and_Hardware/Digital_circuits/Logic_gates.md). +This is an important skill that we will use when constructing [logic circuits](/Electronics_and_Hardware/Digital_circuits/Digital_circuits.md). We will go from truth conditions (i.e. what we want the circuit to do and when we want it to do it) to a function expression which is then reduced to its simplest form and implemented with [logic gates](/Electronics_and_Hardware/Digital_circuits/Logic_gates.md). Specifically, NAND gates. + +We will show here that a complex logical expression can be reduced to an equivalent expression that uses only the NAND operator. ## The process @@ -81,7 +83,7 @@ The upshot is that we now have a simpler expression that uses only NOT, OR and A But even this is too complex. We could get rid of the OR and just use AND and NOT: -We can prove this theorem with the following transformation: +We can prove this theorem by showing that an expression with AND, NOT, and OR can be formulated as an equivalent expression using just NOT and AND: $$ x \lor y = \lnot(\lnot(x) \land \lnot(y)) @@ -94,8 +96,18 @@ $$ | 1 | 0 | 1 | 1 | | 1 | 1 | 1 | 1 | -Finally, we can simplify even further by doing away with AND and NOT and using a single [NAND gate](/Electronics_and_Hardware/Digital_circuits/Logic_gates.md#nand-gate) which embodies the logic of both, being true in all instances where AND would be false: +Finally, we can simplify even further by doing away with AND and NOT and using a single [NAND gate](/Electronics_and_Hardware/Digital_circuits/Logic_gates.md#nand-gate) which embodies the logic of both, being true in all instances where AND would be false: $\lnot (x \land y)$. + +Let's prove the theorem that every logical expression can be formulated as a NAND function. To do this we need to show that both NOT and AND can be converted to NAND. + +NOT: $$ - \lnot (x \land y) + \lnot(x) = x \lnot\land x +$$ + +AND: + +$$ + x \land y = \lnot(x \lnot\land y) $$