### Logic

What does logic mean to us and is that different to mathematical logic? We will explore these questions in this article.

### Logic, Truth Tables and Switching Circuits Challenge

Learn about the link between logical arguments and electronic circuits. Investigate the logical connectives by making and testing your own circuits and fill in the blanks in truth tables to record your findings.

# Truth Tables and Electronic Circuits

##### Stage: 2, 3 and 4

 Before we experiment with circuits we need to decide how to record what happens when we change the switches in the circuit from 0 to 1 or from 1 to 0. We use small letters $p$ and $q$ to represent the switches. These switches also represent statements that are true or false. A true statement has truth value 1 and a false statement has truth value 0. In circuit diagrams each switch is either 'on' (representing the number 1 or a true statement) or 'off' (representing the number 0 or a false statement). Combinations of switches called logical gates represent the logical connectives .

Logic is concerned with compound statements formed from given statements by means of the connectives 'not', 'and', 'or', 'if ... then' and combinations of these connectives. For example "Today is Tuesday" is a simple statement and "The sun is shining" is a simple statement. Both statements can be true or false. Combining these two statements will make a compound statement, for example "Today is Tuesday and the sun is shining".

Logical arguments are a combination of statements, and circuits are a combination of switches that control the flow of current. Modern computers store data in the form of '0's and '1's, and perform many operations on that data, including arithmetic. Studying the relation between truth tables and circuits will help us to understand a little of the underlying principles behind the design of computers.
 Fig. 1 gives a summary of the information you need to build your own circuits. Fig. 1

 First, connect a switch to a lamp as in Fig. 2 and click on the switch several times to change it from 1 to 0 and back to 1. Observe that the light goes on when the switch registers 1 and the light goes off when the switch registers 0. Fig. 2

 Fig. 3 Now put a NOT gate into the circuit between the switch and the lamp, as shown in Fig. 3, and observe what happens when you change the switch from 1 to 0.

Given a statement $p$, the negation not$p$, written $\neg p$, is demonstrated by this circuit and defined by the following truth table. $$\begin{array}[ p & \neg p \\ 1 & 0 \\ 0 & 1 \end{array}$$

And

The logical connective 'and' is used to make a compound statement from two simpler statements. For example if we speak the truth when we say "Today is Friday and it is raining" then "Today is Friday" must be true and " it is raining" must be true. If either or both are false then the compound statement is false.
 Make and test the circuit shown in Fig. 4 and fill in the truth table replacing question marks by 1 if the light goes on and zero if the light does not go on. Fig. 4 $$\begin{array}[ p &q & p\wedge q \\ 1 &1 &?\\ 1 &0 &?\\ 0 &1 &?\\ 0 &0 &? \\ \end{array}$$

If you want to check your work then you can click here.

Or

In everyday language we often use 'or' inclusively as in "If you want to buy cereals or soft drinks go to aisle 7 in the supermarket" when we expect people who want to buy both cereals and soft drinks to go to that aisle as well as people wanting to buy just one of them. On other occasions we use 'or' exclusively to offer two alternatives expecting the listener to choose just one of them as in "Do you want steak for dinner or chicken?". The meaning is usually clear from the context but to avoid any ambiguity in mathematics the logical connective 'or' is always used inclusively and never exclusively.

 Given any two statements$p$, $q$ then $p$ or $q$, (written $p \vee q$)is given in the truth table on the right. Make the circuit shown in Fig. 5 and replace the question marks by 1's and 0's according to whether the lamp lights up or not. Fig. 5 $$\begin{array}[ p &q & p\vee q \\ 1 &1 &?\\ 1 &0 &?\\ 0 &1 &?\\ 0 &0 &? \\ \end{array}$$
Again you can check your work by clicking here.

XOR, NAND, NOR and XNOR

Now experiment with the circuits for XOR, NAND, NOR and XNOR and replace the question marks in the following truth table. $$\begin{array}[ p &q &p XOR q & p NAND q &p NOR q & p XNOR q \\ 1 &1 &? &? &? &? \\ 1 &0 &? &? &? &? \\ 0 &1 &? &? &? &? \\ 0 &0 &? &? &? &? \\ \end{array}$$ Comparing these tables to what we have already discovered we see that p NOR q means 'not(p or q)'. Also p NAND q means 'not(p and q)'.

You can check the truth tables for XOR, NAND, NOR and XNOR by clicking here.

If you want to learn more about logic and circuits then read Logic, Truth Tables and Swirching Circuits which covers the content of this article and goes further to discuss tautologies, implication and the Sheffer stroke.