Programming for GCSE Topic 3.3: Boolean Logic and Truth Tables

Slides:



Advertisements
Similar presentations
Logic Gates.
Advertisements

Programming for GCSE Topic 9.1: Logic Circuits T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary.
INTRODUCTION LOGICAL OPERATIONS TRUTH TABLE AND RULES.
Presented by: Ms. Maria Estrellita D. Hechanova, ECE
Programming for GCSE Topic 3.1: If Statements in Python T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science.
D IGITAL L OGIC Number Systems By: Safwan Mawlood Digital Principles and Logic Design, A.Saha &N.Manna.
Iteration & Branching CSC 171 FALL 2001 LECTURE 5.
Lecture 2 Dr Richard Reilly Dept. of Electronic & Electrical Engineering Room 153, Engineering Building To insert your company logo on this slide From.
1 Inference Rules and Proofs Z: Inference Rules and Proofs.
BOOLEAN LOGIC CSC 171 FALL 2004 LECTURE 7. ASSIGNMENT Review Quiz # 2 Start reading Chapter 5.
Propositional Calculus Math Foundations of Computer Science.
Circuit Simplification: Boolean Algebra
Boolean Algebra. Introduction 1854: Logical algebra was published by George Boole  known today as “Boolean Algebra” 1854: Logical algebra was published.
Boolean Logic & Truth Tables In today’s lesson we will look at: a reminder about truth values and NOT, AND, OR and EOR truth tables operator precedence.
Computer Science 101 Boolean Algebra. What’s next? A new type of algebra – Helps us A new type of algebra – Helps us With logical reasoningWith logical.
22C:19 Discrete Math Boolean Algebra & Digital Logic Fall 2010 Sukumar Ghosh.
CHAPTER 2 Boolean Algebra
Systems Architecture I1 Propositional Calculus Objective: To provide students with the concepts and techniques from propositional calculus so that they.
OCR GCSE Computing © Hodder Education 2013 Slide 1 OCR GCSE Computing Chapter 2: Binary Logic.
1 Fundamentals of Computer Science Propositional Logic (Boolean Algebra)
CSC 107 – Programming For Science. Follow-Up From Last Lecture.
CSC Intro. to Computing Lecture 5: Boolean Logic, Gates, & Circuits.
CS1502 Formal Methods in Computer Science
Computer Science 210 Computer Organization Introduction to Boolean Algebra.
CSC Intro. to Computing Lecture 5: Boolean Logic, Gates, & Circuits.
Discrete Mathematics and Its Applications.  The English mathematician George Boole ( ) sought to give symbolic form to Aristotle's system of.
A-Level Computing#BristolMet Session Objectives#6 MUST understand and produce simple logic diagrams using the operations NOT, AND and OR SHOULD explain.
CSC 107 – Programming For Science. George Boole  Mathematician from English middle-class  Lived from 1815 – 1864  Started work at age 16 as a teaching.
Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
Teaching Computing to GCSE Level with Python Session 3.
Figure 2.6. A truth table for the AND and OR operations. 2.3 Truth Tables 1.
Section 3.4 Boolean Algebra. A link between:  Section 1.3: Logic Systems  Section 3.3: Set Systems Application:  Section 3.5: Logic Circuits in Computer.
13 October 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
Laws of Boolean Algebra Commutative Law Associative Law Distributive Law Identity Law De Morgan's Theorem.
Chapter 4 Fundamentals of Computer Logic 1 Chapter 4: Fundamental of Computer Logic - IE337.
Booleans Lecture 26. Summary of previous lecture In the previous lecture, we have been learnt,  The if statement  The else statement  Cascaded if 
ECE DIGITAL LOGIC LECTURE 6: BOOLEAN ALGEBRA Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 02/01/2016.
Boolean Algebra Boolean algebra was introduced by George Boole in his first book The Mathematical Analysis of Logic (1847), perfected in the late 19th.
Logic Simplification-Using Boolean Laws Logic Design Laboratory EE 2121 Lectures By Manesh T EE2121-In Charge
DIGITAL ELECTRONICS. Everything in digital world is based on binary system. Numerically it involves only two symbols 0 or 1. –0 = False = No –1 = True.
Logic Gates and Boolean Algebra Introduction to Logic II.
Chapter 3 Boolean Algebra and Digital Logic T103: Computer architecture, logic and information processing.
Programming for GCSE Topic 9.2: Circuits for Adding T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen.
Computer Programming Boolean Logic.
CPS120 Introduction to Computer Science
Lecture 4 Topics Boolean Algebra Huntington’s Postulates Truth Tables
Digital Logic.
Computer Science 210 Computer Organization
Section 7.1 Logical Operators
CHAPTER 2 Boolean Algebra
Logic Gates.
CHAPTER 2 Boolean Algebra This chapter in the book includes:
Boolean Algebra.
Boolean Algebra.
Propositional Calculus: Boolean Algebra and Simplification
Boolean Algebra Digital Electronics
Lecture 4 Topics Boolean Algebra Huntington’s Postulates Truth Tables
Computer Science 210 Computer Organization
Logic Gates.
Boolean Algebra.
GCSE Computer Science – Logic Gates & Boolean Expressions
ECB2212-Digital Electronics Boolean algebra
ECS15 boolean.
Truth tables Mrs. Palmer.
Introductory Concepts
BOOLEAN ALGEBRA.
Computer Programming Boolean Logic Trade & Industrial Education
ECE Digital Electronics
Conditionals.
Presentation transcript:

Programming for GCSE Topic 3.3: Boolean Logic and Truth Tables Teaching London Computing Programming for GCSE Topic 3.3: Boolean Logic and Truth Tables William Marsh School of Electronic Engineering and Computer Science Queen Mary University of London

Aims Introduce the study of logic 'Logic gates' are covered later Introduction to logic Truth tables Logic and programming Writing logic – Boolean algebra … 'Logic gates' are covered later

Teaching Issue How to provide a coherent, joined up view Some curricula include logic circuits but it is not related to operation of a computer Abstraction e.g. 'X and Y' Best way in? Notation? Unfortunately, several used

Introduction to Logic True and False

Some History George Boole Claude Shannon Invented ‘Boolean Algebra’ Makes 'logic' into mathematics "An Investigation of the Laws of Thought", 1854 Claude Shannon A Symbolic Analysis of Relay and Switching Circuits, 1938 Based on his master’s thesis. In 1932 he entered the University of Michigan, where he took a course that introduced him to the works of George Boole. He graduated in 1936 with two bachelor's degrees, one in electrical engineering and one in mathematics, then began graduate study at the Massachusetts Institute of Technology, where he worked on Vannevar Bush's differential analyzer, an analog computer. While studying the complicated ad hoc circuits of the differential analyzer, Shannon saw that Boole's concepts could be used to great utility. A paper drawn from his 1937 master's thesis, A Symbolic Analysis of Relay and Switching Circuits, was published in the 1938 issue of the Transactions of the American Institute of Electrical Engineers. It also earned Shannon the Alfred Noble American Institute of American Engineers Award in 1940. Howard Gardner, of Harvard University, called Shannon's thesis "possibly the most important, and also the most famous, master's thesis of the century". In this work, Shannon proved that Boolean algebra and binary arithmetic could be used to simplify the arrangement of the electromechanical relays then used in telephone routing switches, then turned the concept upside down and also proved that it should be possible to use arrangements of relays to solve Boolean algebra problems. Exploiting this property of electrical switches to do logic is the basic concept that underlies all electronic digital computers. Shannon's work became the foundation of practical digital circuit design when it became widely known among the electrical engineering community during and after World War II. The theoretical rigor of Shannon's work completely replaced the ad hoc methods that had previously prevailed.

True or False? Logic view: true or false 'My name is David' 'Today is a Tuesday' Proposition: a statement that is true or false In reality, some statements are more complex 'That colour suits you' 'You are the most beautiful girl in the world'

Writing Logic Boolean Algebra

Logical / Boolean Variables X, Y - (an uppercase letter) A variable that may be true of false A proposition

Writing Logic Python Logic Gates Maths X and Y X . Y x  y X or Y not X True False ‘X’, ‘Y’ are Boolean variables X . Y X + Y X 1 x  y x  y x true false

Truth Tables: AND, OR, NOT

Truth Tables Table of all variables in a Boolean formula 2 variables Each row has a possible combination of X and Y Table covers all possibilities X Y Result 1

AND, OR OR AND X Y X or Y 0 0 0 0 1 1 1 0 1 1 1 1 X Y X and Y 0 0 0 True when either X or Y true OR AND X Y X or Y 0 0 0 0 1 1 1 0 1 1 1 1 True when both X and Y true X Y X and Y 0 0 0 0 1 0 1 0 0 1 1 1

NOT X not X 0 1 1 0

Logic and Boolean Expressions … Python programming

Boolean Expressions Combine conditions If A, B are conditions – true or false Expression Description A and B Both A true and B true A or B Either A true or B true not A True when A is false

Examples What are the values of the following? Expression True or False? 10 > 5 or "hello"[1] == "e" 2 + 3 < 10 and 6 != 6 10 != 11 or 5 != 5 10 < 10 and "world"[1:3] == "or" not (10 >= 11)

Compare these programs: if age >= 21 and age <= 25: print("Great age") else: print("Not so good! ") if age >= 21: if age <= 25: print("Great age") else: print("Not so good!") Equivalent Nested 'if' statement

Using Truth Tables to Check Equivalence

Truth Tables Table of all variables in a boolean formula 2 variables 4 row 3 variables 8 rows 4 variables 16 rows Two formula same if (and only if) same truth table X Y Z Result 1

Comparing Formulae using Truth Table Use a truth table to check equivalence Are the two formula the same: not (A and B) (not A) or (not B) ( A . B ) = A + B A B NOT(A . B) (NOT A) + (NOT B) 0 0 0 1 1 0 1 1

Comparing Formulae using Truth Table Use a truth table to check equivalence ( A . B ) = A + B A B NOT(A . B) (NOT A) + (NOT B) 0 0 0 1 1 0 1 0 1 0 1 0 0 0 1 1 1 1 0 0

Comparing Formulae using Truth Table Use a truth table to check equivalence ( A . B ) = A + B A B NOT(A . B) (NOT A) + (NOT B) 0 0 1 0 1 1 1 0 1 1 0 1 1 0 1 0 1 0 0 1 1 1 1 0 1 0 0 0

QUIZ: Are these the same? if age >= 20 and age <= 25: print("Great age") else: print("Not so good! ") if age < 20 or age > 25: print("Not so good!") else: print("Great age")

Comparing Formulae using Truth Table QUIZ: use a truth table to check ( A + B ) = A . B A B NOT(A + B) (NOT A) . (NOT B) 0 0 0 1 1 0 1 1

Rules of Boolean Algebra

Boolean Algebra Rules Rules for NOT A . A = 0 never A and not A Associative rules A . A = 0 never A and not A A+A = 1 always A or not A Draw the associative laws as circuits A.(B.C) = (A.B).C and associative A+(B+C) = (A+B)+C or associative

De-Morgan’s Laws Important law for exchanging AND with OR ‘A and B’ is false when either A is false or B is false ( A . B ) = A + B ‘A or B’ is false when both A is false and B is false ( A + B ) = A . B

Summary Logical expressions Logic and programming Truth table AND, OR, NOT Logic and programming Reasoning about conditions Truth table Equivalence of expressions Boolean expression (formula) Algebraic rules Next stop: logic circuits