CS09 : Logical Methods

The other thing that computer do really well is logic. In this topic, you will learn about different logic operations and the ways in which they are implemented in computer systems and to interpret logical systems in different ways.

https://docs.google.com/presentation/d/1IlyP2PYE9YhJ77pELJ6BLDe3pdLvweQ3eWXGDJDXjgc/preview?slide=id.g3cb6bc7fc1_0_0Learning Outcomes
Logical Methods

We are learning ...
  • About logic, logic gates, truth table and logic circuits
So that we can ...
  • Understand why the output of any logic circuit is Boolean
  • Describe the logical operation of the seven standard logic gates
  • Draw and interpret truth tables for these logic gates
  • Produce logic circuit diagrams to solve a given problem using logic gate notation.
  • Produce logic circuit diagrams to implement a written logic circuit using logic gate notation.
  • Draw and interpret truth tables for combinations of logic gates (up to three inputs) using logic gate notation.

# Get Ready.png

https://docs.google.com/presentation/d/1IlyP2PYE9YhJ77pELJ6BLDe3pdLvweQ3eWXGDJDXjgc/preview?slide=id.g3df8b56503_0_5Activity 1
Building blocks 

All computer systems are built up from millions upon millions of tiny building blocks but what are they?

Task 1.1
 What is this?
Where we find out what the tiny switches that make computers are called and learn how to perform a reverse image search

Look carefully ...

Look carefully at the following image. Have you ever seen anything like this before? If you are into electronics, or you have studied Design Technology, you might recognise this.

Right click me and save me on your computer

Reverse image search

Perform a 'reverse image search' to find out what it is a picture of (HINT : Right click on the image and save it in your userspace. Visit Google Images and upload the image using the 'camera tool'). You should get around 25,000,000,000 search results (taking about 1 second!) Isn't Google wonderful?

In your notebooks / on paper

Now answer the following questions in your notebooks or on paper
  1. Can you name the device in the picture?
  2. Look down the list of search results and find the section called 'Pages that contain this image'. Find the link to the VOLTAGE LAB website. Use it to answer the rest of the questions.
  3. What are the two main uses of these devices?
  4. Describe the first use.
  5. Describe the second use.

Task 1.2
 Professor Chris Bishop is a lad
Where we learn about fundamental electronic behaviour from the legend that is Professor Chris Bishop!

Watch the video (on your own) ...

Now plug in your headphones and watch this video by clicking on the image (or alternatively, your teacher will show you it in class). It's by Professor Chris Bishop who is a legend, believe me. The video explains how computers work on a electronic level. Watch carefully ...

Click me to watch my Video, "Breaking the speed limit"
You can watch it on YouTube if it's slow ...

On the worksheet

To make sure you have paid attention (why wouldn't you of?), I would like you to write a video review using the worksheet 'Video Review' to help you.

The whole point of this is to convince you that there are only two possible 'states' of any electrical circuit ...

Can you think of any more?

Variables and constants, which have only two possible values, are known as a Boolean variables, Booleans or flags (because they are used to signal or flag whether something has happened or not).

It's a flag, see?

https://docs.google.com/presentation/d/1IlyP2PYE9YhJ77pELJ6BLDe3pdLvweQ3eWXGDJDXjgc/preview?slide=id.g41ee50d5d8_0_9Activity 2
Why 'Boolean'? 

In the middle of the 19th Century (around 1850), an English mathematician called George Boole invented a system for representing logic and doing maths with it. We name this system after him - Boolean Algebra.

Picture of George Boole 1815-1864
'I was born in Lincoln, England and was the son of a shoemaker'

Task 2.1
 Stand up, Sit down!
Where we learn about how combinations of logical statements can be used to make complex decisions super easy

I warned you ...

In your notebooks / on paper

Write a paragraph which explains what you have learnt from this activity. If you can, try to come up with some interesting examples which illustrate the concept of AND, OR and NOT.

One way of representing the logical decisions is by writing a truth table. A truth table will also tell us exactly what chance there is that the logical decision will end up being TRUE. Consider this example ...

Click to engage

The truth table lists all the possible combinations of the inputs (think binary). You then work out the nature of the output by using the logic of the statement you are testing - AND, OR or NOT.

Task 2.2
 Truth Tables
Where we learn how to draw truth tables for one and two input decisions

In your notebook / on paper

Consider the following scenarios. Using the example above to help you ...
  • Identify the input(s) and the output
  • Create a truth table which lists the inputs, any processing which is required and finally the output.
  1. I will only go to the party on Friday if Peter OR Katy is going.
  2. I will only go to University to study Computer Science if I pass my A Levels AND the University accepts me.
  3. I will only have dessert if I enjoyed the starter AND the main course does NOT fill me up.

https://docs.google.com/presentation/d/1IlyP2PYE9YhJ77pELJ6BLDe3pdLvweQ3eWXGDJDXjgc/preview?slide=id.g41ee50d5d8_0_22Activity 3
Logic gates and truth tables

Logic gates model the behaviour of these logic operations using transistors. There are three basic logic gates ...
  • NOT gate which takes a single input and inverts it;
  • AND gate which takes two inputs but only gives an output if both inputs are on;
  • OR gate which takes two inputs and gives an output if either or both inputs are on;
... and four advanced logic gates (NAND, NOR, XOR and XNOR).

Notice that AND and OR both have two inputs and NOT only has one

Logic gates allow the computer to perform mathematical
functions like add, subtract, divide and multiply as well
as make logical decisions?

Task 3.1 Practical(ish) logic gates
Where we will learn how basic logic gates behave

On the worksheet

Download yourself a copy of the worksheet 'Basic Logic Gates' and save a copy in your user space. Read the instructions on the worksheet carefully and complete the tasks by clicking on and replacing the blue writing. 

# Faster Workers.png

On the worksheet

Download yourself a copy of the worksheet 'Advanced Logic Gates' and save a copy in your user space. Read the instructions on the worksheet carefully and complete the tasks by clicking on and replacing the blue writing.

https://docs.google.com/presentation/d/1IlyP2PYE9YhJ77pELJ6BLDe3pdLvweQ3eWXGDJDXjgc/preview?slide=id.g41ee50d5d8_0_34Activity 4
Logic circuits 

Instead of writing / drawing the logic gate symbols, computer scientists usually use the names of the logic operation or special symbols and write them as Logic Expressions. You can represent the logical operations using their names (AND, OR, NOT) or using special symbols (¬) It's important that you know how to convert from written Boolean expressions into logic circuits and vice versa.

Like in maths, there are precedence rules for Boolean operations (brackets > NOT > AND > OR), however, brackets are normally used around expressions to force precedence where it may be ambiguous.

BracketsNOT > AND > OR
Brackets > ¬ >  > 

Add an activity comparing logic precedence to mathematical precedence

Task 4.1 Converting compound logic expressions to logic gate circuits
Where we will learn to convert between Boolean expressions and logic circuits

In your notebooks / on paper

Under a suitable title in your notebooks / on paper, write down the precedence rules for logic operations. Use a highlighter pen to outline this so that it stands out in your notes. Can you see the relationship with the precedence rules for mathematical operators?

Open up the Logicly Demo

To help us to complete this task, we'll use an online application called Logicly ...

Logicly Demo - show your support by buying a copy!

Practice with gates you already know!

Use Logicly to practise making the three basic logic gate circuits and make sure that you follow how they work. Each of the gates has one or more 'toggle switches' which are used to represent the INPUT values and are labelled ABC and so on. The output of the gate is used to light up a 'bulb' and is labelled Q - this is generally used to represent the output of a logic circuit.

The following animations might help you to visualise what's going on. Watch carefully ...

Optimistic OR gate - happy most of the time! Click to engage

Pessimistic AND gate - unhappy most of the time! Click to engage

Argumentative NOT gate - always disagreeing! Click to engage

Expression to circuit (using Logicly)

Now let's try combining multiple logic gates and see how they behave! Use Logicly Demo to construct the following logic expressions as logic gate circuits. Create a word processed document and, for each one ...
  • write down the logic expression;
  • draw the logic circuit you have made in Logicly;
  • construct a suitable Truth table using Logicly to help you.
Remember to follow the precedence rules you wrote down earlier.

1 Q = (NOT A) OR B
2 Inputs, 2 Logic Gates
2 Q = NOT (A AND B) 2 Inputs, 2 Logic Gates
3 Q = (A AND B) AND C 3 Inputs, 2 Logic Gates
4 Q = (A AND B) OR (NOT C) 3 Inputs, 3 Logic Gates
5 Q = (A OR (B AND C)) OR NOT A 3 Inputs, 4 Logic Gates

OK - for a logic circuit with two inputs (A and B), the truth table would have 4 lines in it because there are 4 valid combinations of two switches ...

The input section for a 2 input logic circuit

For logic circuits with three inputs (AB and C), the truth table would have 8 lines in it because there are 8 valid combinations of three switches ...

The input section for a 3 input logic circuit

For those who are interested, the answer is 16 ...

Circuit to expression

Let's have a go at the following examples without using Logicly to help us. If we are given the circuit first, we should be able to write the logical expression - easy! Deriving the truth table is sometimes a little more tricky if you have got more than one gate but it's easy if you deal with one gate at a time and include extra 'processing' columns in your table - look back at what we did in Task 2.2 to refresh your memory ...

Try the following exercises. For each one, sketch the circuit in your notebooks / on paper, write the logic expression underneath and derive the truth table - you need one processing column for every gate before you reach the last one (the output of the last gate is always Q). I've done the first one for you ...

Circuit 1 - Click for a hint


That looks like the same table as I got in Question 3 in Step 4
but I've derived it in a different way! Cool!

Circuit 2 - Click for a hint

Circuit 3 - Click for a hint

Quite often, computer scientists abbreviate the logic operation using symbols.

The AND operation, known as conjunction, is abbreviated using a wedge sign,
The OR operation, known as disjunction, is abbreviated using a vee-sign,
The NOT operation, known as negation, is abbreviated using a not-sign¬

You need to learn these!

Task 4.2 Learn a new way!
Where we learn an alternative (and a bit weird) alternative way of representing Boolean expressions

In your notebooks / on paper

Rewrite the equations from Task 4.1 using these abbreviated symbols. For instance ...

Q = NOT (A OR (B AND C)) ... would be abbreviated to ... Q = ¬ (A ⋁ (B ⋀ C))

Add this new way of writing the logical expressions onto the work you did in Task 4.1. Remember that in an examination, you could be given Boolean expressions using either type of notation.

Expression to circuit

On paper or in your notebooks, draw logic circuit diagrams and truth tables for the following expressions. Don't use Logicly to help you, work them out yourself!
  • A ⋀ (B ⋁ C)
  • (A ⋀ B) ⋀ C
  • ¬ (A ⋀ B
  • ¬ ((A ⋀ B) ⋁ ¬ C)
  • (A ⋁ ¬ B) ⋁ (¬ A ⋀ B)

Circuit to expression

Convert the following logic circuits into Boolean expressions using the ⋀, ⋁ and ¬ symbols. For each one, derive a truth table as well - remember, you need one processing column for the output of each gate before you reach the last one ...

Circuit 1 - No hints :(

Circuit 2 - No hints :(

Assessment Task (Homework)

It is quite possible to use logic gates to represent real world scenarios like the ones we met in Activity 2. The presentation shows you three worked examples and then gives you a number of real world scenarios which can be represented by logic circuits.

Draw logic circuits for the seven situations on paper, draw a truth table for each one and represent each one using a Boolean expression using words (AND, OR and NOT) and using symbols (⋀, ⋁ and ¬)

Grading rubric

MASTER : You have accurately drawn suitable logic circuits for each of the seven real world scenarios, shown their behaviour using truth tables and represented them with Boolean expressions in both forms. You are a computer.
APPRENTICE : You have attempted to draw the logic circuits and most of them are correct but I wouldn't trust you with the keys to a nuclear missile or leave you in charge of my pets whilst I'm on holiday.
NOVICE : You have completely missed the point and have copied the examples from the presentation down including the box with the question mark in it. You've tried the truth tables but the inputs are in the wrong order. You don't know what an oven is.

# Flash cards.png
Click to load key word list to help you make your own flash cards 

Hungry for more?

BBC Education

There is a great revision resource on the BBC Education page on Boolean Logic with a quiz at the end. Have a go!

Circuit scramble and logic circuit challenges

Grab yourself a copy of Circuit Scramble and solve logic gate puzzles on your phone. If you can't (or wont), you can download a Logisim circuit 'Logic circuit challenges' which contains versions of the first 14 challenges. Ask your teacher how this works - you need to use Logism software to open it.

Poster time

Create a poster on the history of the transistor and the effect this had on the development of the modern computer. Include a potential 'future of' section as well to help encourage ideas beyond current technology.

Not Logicly

This is a alternative logic circuit simulator - have a go!

Half and full adders

One basic real world application of logic gates is the half and full adder. In fact, all computational circuits are made from combinations of transistors / logic gates ...

What's inside a microchip ? (7:21)

FAQ (Frequently Asked Questions)

Q : How often are we going to use this in our computing careers?
A : Logical decisions are really important in computer science and are the basis of all computer programs. However, logic gates are only really important if you are going to move towards the microelectronics / circuit design side of things.

Q : What are logic gates used for?
A : On a fundamental level, all computer systems are made of logic gates, so, yeah, computers.

Q : How are you?
A : Very well, thank you for asking.