KS4J277 2.4 26 min read 10 question quiz 19 exam marks

Boolean Logic

AND, OR and NOT gates, drawing and reading logic diagrams, and completing truth tables for combined circuits without making arithmetic slips.

The three gates

NOT

NOT inverts the input. Output is the opposite of the input.

ANOT A
01
10

Symbol: a triangle with a small circle on the output.

AND

AND outputs 1 only when both inputs are 1.

ABA AND B
000
010
100
111

Symbol: a D shape.

Think of two switches in series. The light only comes on if both are closed.

OR

OR outputs 1 when at least one input is 1.

ABA OR B
000
011
101
111

Symbol: a curved shield shape.

Think of two switches in parallel. The light comes on if either one is closed.

The one line summary

AND needs both. OR needs at least one. NOT flips it.

The six logic gates with symbols, expressions and truth tablesSix logic gates, each with its British Standard symbol, its Boolean expression and its truth table. AND, written Q equals A dot B, gives 1 only when both inputs are 1. OR, written Q equals A plus B, gives 1 when at least one input is 1. NOT, a triangle with a small circle, inverts its single input, so 0 becomes 1 and 1 becomes 0. XOR, exclusive or, gives 1 when the inputs are different and 0 when they are the same. NAND is AND followed by an inverting circle, so it gives 0 only when both inputs are 1 and 1 otherwise. NOR is OR followed by an inverting circle, so it gives 1 only when both inputs are 0.ANDQ = A . BABQABQ000010100111ORQ = A + BABQABQ000011101111NOTQ = NOT AAQAQ0110XORQ = A xor BABQABQ000011101110NANDQ = NOT (A . B)ABQABQ001011101110NORQ = NOT (A + B)ABQABQ001010100110
The small circle on a symbol always means invert. Learn AND, OR and NOT, then NAND, NOR and XNOR are just those with a circle added.

Truth tables for combined circuits

When gates are combined, build the truth table one column at a time.

Method

  1. List every input combination. With 2 inputs there are 4 rows, with 3 inputs there are 8 rows.
  2. Add a column for each intermediate output, not just the final one.
  3. Work through the circuit in the order the signals flow.

Getting the input combinations in a reliable order matters. For three inputs, count in binary from 000 to 111:

000, 001, 010, 011, 100, 101, 110, 111

Worked example

Complete a truth table for Q = (A AND B) OR (NOT C)

ABCA AND BNOT CQ
000011
001000
010011
011000
100011
101000
110111
111101

Notice the intermediate columns. Without them, the last two rows are very easy to get wrong.

Intermediate columns earn method marks

Even if the final column contains an error, correct intermediate columns show your working and usually score.

A worked logic circuit and its full truth tableA circuit for Q equals A AND B, OR NOT C. Inputs A and B feed an AND gate. Input C feeds a NOT gate. The outputs of the AND gate and the NOT gate feed an OR gate, whose output is Q. The truth table has eight rows and shows the intermediate columns. With A, B and C as 0, 0, 0: A AND B is 0, NOT C is 1, Q is 1. With 0, 0, 1: 0 and 0, Q is 0. With 0, 1, 0: 0 and 1, Q is 1. With 0, 1, 1: 0 and 0, Q is 0. With 1, 0, 0: 0 and 1, Q is 1. With 1, 0, 1: 0 and 0, Q is 0. With 1, 1, 0: 1 and 1, Q is 1. With 1, 1, 1: 1 and 0, Q is 1. So Q is 1 in five of the eight rows.Q = (A . B) + (NOT C)ABCANDNOTORQABCA.BC'Q000011001000010011011000100011101000110111111101work out the middle columns first
Add a column for every gate output, not just the final one. The marks for method are in those middle columns.

Logic gate simulator

Build a circuit from gates, wire it up, and see the truth table fill in as you go. This tool needs JavaScript, so turn it on to use it. Everything you need to answer the exam question is explained in the text above.

Tracing a signal through a logic circuitA circuit with two inputs, A and B, feeding an AND gate whose output feeds a NOT gate, which produces the output Q, drawn twice. Every wire carries a 1 or a 0, written on it, and a wire carrying a 1 is drawn lit. In the first case A is 1 and B is 0. The AND gate outputs 1 only when both its inputs are 1, so it outputs 0. The NOT gate inverts whatever it is given, so that 0 becomes a 1 and Q is 1, and the bulb is on. In the second case both A and B are 1, so the AND gate outputs 1, the NOT gate inverts it, and Q becomes 0 and the bulb is off. A truth table beside the circuit lists all four combinations, with Q equal to 1 in every row except the one where both inputs are 1. The whole circuit is Q equals NOT, bracket, A AND B, bracket, and a combination that common has its own name and symbol: it is a NAND gate. When reading a circuit in an exam, work left to right and write the value on every wire as you go, because the marks are for the intermediate columns as much as the answer.A = 1, B = 0ABANDNOT1001Q = 1A = 1, B = 1ABANDNOT1110Q = 0Truth tableABANDQ0001010110011110Q is 1 every timeexcept when A and Bare both 1Q = NOT (A AND B)that is a NAND gate12345
  1. Two inputs, one AND gate, one NOT gate, one output.
  2. A = 1 and B = 0. AND needs both, so it gives 0.
  3. NOT flips it, so Q becomes 1.
  4. A = 1 and B = 1. AND gives 1, NOT flips it, Q is 0.
  5. Q = NOT (A AND B). That is a NAND gate, written out.
Label every wire as you go. An intermediate column in a truth table is a mark, and it is also how you catch your own mistake.

Reading and writing logic diagrams

From a diagram to an expression

Work from the inputs towards the output, naming each intermediate signal as you go.

If A and B both go into an AND gate, and that output goes into an OR gate with C, then:

Q = (A AND B) OR C

From an expression to a diagram

Work inside out, exactly like brackets in maths.

For Q = NOT (A OR B):

  1. Draw an OR gate with inputs A and B.
  2. Feed its output into a NOT gate.
  3. The NOT gate's output is Q.

Order of operations

Brackets first, then NOT, then AND, then OR.

A OR B AND C means A OR (B AND C).

Always use brackets in your answers

Even where the precedence rules make them unnecessary, brackets remove all ambiguity and cost you nothing.

Applying logic to real situations

Exam questions often describe a real system and ask for the expression.

Example 1

An alarm sounds if the door sensor is triggered AND the system is armed.

Alarm = Door AND Armed

Example 2

A greenhouse fan turns on if the temperature is too high OR the humidity is too high, but only when the system is switched on.

Fan = (Temp OR Humidity) AND SystemOn

Example 3

A car will only start if the key is present, the brake is pressed, and the bonnet is NOT open.

Start = Key AND Brake AND (NOT Bonnet)

Reading the wording

WordingGate
both, and, as well asAND
either, or, at least oneOR
not, unless, withoutNOT
Translate the sentence literally

Underline every and, or and not in the description, then build the expression around them. The wording almost always maps directly.

Key terms you must be able to define

Boolean logic
A system of logic in which every value is either true or false, represented as 1 or 0.
AND gate
A logic gate whose output is 1 only when all of its inputs are 1.
OR gate
A logic gate whose output is 1 when at least one of its inputs is 1.
NOT gate
A logic gate that inverts its input, also called an inverter.
Truth table
A table showing the output of a logic expression for every possible combination of inputs.
Logic diagram
A drawing showing how logic gates are connected together.
Logic gate
An electronic component that performs a Boolean operation on one or more inputs.

Flashcards

Say the definition out loud before you flip the card. Retrieving it from memory is what builds recall, reading it again is not.

DefineBoolean logic
AnswerA system of logic in which every value is either true or false, represented as 1 or 0.
DefineAND gate
AnswerA logic gate whose output is 1 only when all of its inputs are 1.
DefineOR gate
AnswerA logic gate whose output is 1 when at least one of its inputs is 1.
DefineNOT gate
AnswerA logic gate that inverts its input, also called an inverter.
DefineTruth table
AnswerA table showing the output of a logic expression for every possible combination of inputs.
DefineLogic diagram
AnswerA drawing showing how logic gates are connected together.
DefineLogic gate
AnswerAn electronic component that performs a Boolean operation on one or more inputs.

Reach the top grade on this topic

Everything on this topic is achievable, so the goal is to get every mark, every time.

Never do a truth table in your head. Write out every row and every intermediate column. It costs thirty seconds and prevents the errors that lose whole questions.

Get the input combinations right. Count in binary. For three inputs that is 000 through to 111, which gives eight rows in a reliable order with nothing missed.

Use brackets in every expression you write. They cost nothing and remove all ambiguity from your answer.

For scenario questions, underline the logic words in the description first. Every and, or and not maps almost directly onto a gate.

  • Complete an eight row truth table with two intermediate columns in under four minutes
  • Convert any logic diagram into an expression, and any expression into a diagram
  • Write a Boolean expression from a written description of a real system
  • Recall all three gate symbols and all three truth tables from memory

Mistakes that cost marks here

Avoid these
  • Missing input combinations in a truth table. Two inputs give four rows, three inputs give eight.
  • Skipping intermediate columns, then making an error that could not be spotted or credited.
  • Confusing the AND and OR truth tables, particularly the row where both inputs are 1.
  • Applying NOT to the wrong part of an expression because brackets were left out.
  • Reading 'either' as AND. Either means OR.
Fun fact

Boolean algebra was published by George Boole in 1854 as pure mathematics with no practical use in sight. Eighty four years later Claude Shannon realised it described electrical switching circuits exactly, and the entire digital age followed from that connection.

Knowledge check

0 of 10 answered
1What is the output of 1 AND 0?
2What is the output of 0 OR 1?
3How many rows does a truth table for three inputs have?
4What is the output of NOT (1 AND 1)?
5Which expression describes: the heater turns on if it is cold AND the system is switched on?
6For Q = (A OR B) AND NOT C, what is Q when A=0, B=1, C=0?
7Which gate is described as an inverter?
8In A OR B AND C, which operation is carried out first?
9A door unlocks if the correct code is entered AND the card is valid, OR if the override switch is on. Which expression is correct?
10What is the output of NOT 0 AND NOT 1?
Score 0 / 10

Exam-style questions

Five written questions in the style of the real paper. Write a full answer, then let the marker check it against the mark scheme.

19 marks
1Complete a truth table for the expression Q = A AND NOT B, showing all input combinations.4 marks
Complete

Mark scheme0 / 4
  • LIncludes all four input combinations for A and B
  • LIncludes an intermediate column for NOT B
  • LQ is 1 only when A is 1 and B is 0
  • LQ is 0 for all other combinations
Model answer

With A and B as inputs there are four combinations. When A is 0 and B is 0, NOT B is 1 and Q is 0 AND 1 which is 0. When A is 0 and B is 1, NOT B is 0 and Q is 0. When A is 1 and B is 0, NOT B is 1 and Q is 1 AND 1 which is 1. When A is 1 and B is 1, NOT B is 0 and Q is 1 AND 0 which is 0. So Q is 1 only in the single case where A is 1 and B is 0, and 0 in every other case.

The marker looks for key phrases. If you said it another way and it is still right, give yourself the mark.
2A security light switches on when a movement sensor is triggered AND it is dark. Write a Boolean expression for this system.2 marks
Write

Mark scheme0 / 2
  • LUses AND to combine the two conditions
  • LCorrect expression such as Light = Movement AND Dark
Model answer

Light = Movement AND Dark. Both conditions must be satisfied for the light to switch on, so the two inputs are combined with an AND gate: the movement sensor must be triggered and it must also be dark.

The marker looks for key phrases. If you said it another way and it is still right, give yourself the mark.
3Explain the difference between an AND gate and an OR gate.3 marks
Explain

Mark scheme0 / 3
  • LAn AND gate outputs 1 only when all inputs are 1
  • LAn OR gate outputs 1 when at least one input is 1
  • LRefers to the difference in the case where only one input is 1
Model answer

An AND gate produces an output of 1 only when every one of its inputs is 1, so with two inputs it outputs 1 in just one of the four possible cases. An OR gate produces an output of 1 whenever at least one of its inputs is 1, so with two inputs it outputs 1 in three of the four cases. The gates therefore differ in exactly those cases where only one input is 1: an AND gate outputs 0 while an OR gate outputs 1. They agree only when both inputs are 0, giving 0, and when both are 1, giving 1.

The marker looks for key phrases. If you said it another way and it is still right, give yourself the mark.
4A machine will only operate if the guard is closed AND either the foot pedal is pressed OR the hand button is pressed. Write a Boolean expression and state what the output would be if the guard is open and the foot pedal is pressed.4 marks
Write

Mark scheme0 / 4
  • LCorrectly groups the pedal and button with OR
  • LCombines that result with the guard using AND
  • LFull expression such as Operate = Guard AND (Pedal OR Button)
  • LStates the output is 0, because the guard is open so the AND cannot be satisfied
Model answer

Operate = Guard AND (Pedal OR Button). The pedal and the hand button are alternatives, so they are combined with an OR gate, and the result of that must be combined with the guard using AND because the guard must be closed in every case. If the guard is open then Guard is 0, and regardless of whether the pedal or the button is pressed the OR gate output is ANDed with 0, so the final output is 0 and the machine will not operate. This is the correct and intended safety behaviour.

The marker looks for key phrases. If you said it another way and it is still right, give yourself the mark.
5Complete a truth table for Q = (A OR B) AND NOT C for all eight input combinations.6 marks
Complete

Mark scheme0 / 6
  • LLists all eight combinations of A, B and C
  • LIncludes an intermediate column for A OR B
  • LIncludes an intermediate column for NOT C
  • LQ is 0 for every row where C is 1
  • LQ is 0 when A and B are both 0
  • LQ is 1 for the rows 010, 100 and 110
Model answer

There are eight input combinations, counting in binary from 000 to 111. The intermediate column A OR B is 0 only when both A and B are 0, and 1 otherwise. The intermediate column NOT C is 1 whenever C is 0 and 0 whenever C is 1. Q is the AND of those two columns, so Q is 1 only when at least one of A and B is 1 and C is 0. That gives Q equal to 1 for the input combinations 010, 100 and 110, and Q equal to 0 for the other five combinations, namely 000, 001, 011, 101 and 111.

The marker looks for key phrases. If you said it another way and it is still right, give yourself the mark.
Machine mark 0 / 19