CS1022 Computer Programming & Principles

Slides:



Advertisements
Similar presentations
Date of Birth Design Problem
Advertisements

CSE 370 Sample Final Exam Questions. 1) Logic Minimization CD AB F = Σm(0,6,7,8,9,11,15) + d(1,13)
- 1 - Using an SMT Solver and Craig Interpolation to Detect and Remove Redundant Linear Constraints in Representations of Non-Convex Polyhedra Christoph.
Register Transfer and Microoperations Part2
1 Knowledge and reasoning – second part Knowledge representation Logic and representation Propositional (Boolean) logic Normal forms Inference in propositional.
Principles & Applications
Fast Algorithms for Finding Nearest Common Ancestors Dov Harel and Robert Endre Tarjan Fast Algorithms for Finding Nearest Common Ancestors SIAM J. COMPUT.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
Addition Facts
15 October 2013Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
A Simple ALU Binary Logic.
Monika Gope Lecturer IICT, KUET
Princess Sumaya University
Truth Tables & Logic Expressions
3 Logic The Study of What’s True or False or Somewhere in Between.
Truth Tables and Boolean Algebra Benchmark Companies Inc PO Box Aurora CO
Digital Systems Introduction Binary Quantities and Variables
Basics Combinational Circuits Sequential Circuits
Digital Logic Design Gate-Level Minimization
Charles Kime & Thomas Kaminski © 2004 Pearson Education, Inc. Terms of Use (Hyperlinks are active in View Show mode) Terms of Use Chapter 2 – Combinational.
Digital Electronics Lecture 2 Logic Gates. Lecture 2 outline Announcement:
Boolean Algebra and Logic Gates
(CSC 102) Discrete Structures Lecture 5.
1 Computer Programming Boolean Logic Copyright © Texas Education Agency, 2013.
Presented by: Ms. Maria Estrellita D. Hechanova, ECE
01 Introduction to Digital Logic
CS1022 Computer Programming & Principles Lecture 9.2 Boolean Algebra (2)
CS1022 Computer Programming & Principles Lecture 8.1 Digraphs (1)
CS1022 Computer Programming & Principles Lecture 7.1 Graphs (1)
Chapter 5 Test Review Sections 5-1 through 5-4.
Binary Lesson 3 Hexadecimal. Counting to 15 Base Base Base 16 Base Base Base 16 Two Ten (Hex) Two Ten (Hex)
Binary Lesson 3 Hexadecimal. Counting to 15 Base Base Base 16 Base Base Base 16 Two Ten (Hex) Two Ten (Hex)
Addition 1’s to 20.
Princess Sumaya University
25 seconds left…...
Digital Logic & Design Lecture No. 3. Number System Conversion Conversion between binary and octal can be carried out by inspection.  Each octal digit.
Finite-state Recognizers
Week 1.
Minimization of Circuits
ELECTRONICS TECHNOLOGY Digital Devices I Karnaugh Maps
Digital Logic Design Lecture 13. Announcements HW5 up on course webpage. Due on Tuesday, 10/21 in class. Upcoming: Exam on October 28. Will cover material.
and M-ary Quadrature Amplitude Modulation (M-QAM)
Internet Engineering Czesław Smutnicki Discrete Mathematics – Combinatorics.
Chapter 9: Boolean Algebra
Chapter 3 Introduction to Logic © 2008 Pearson Addison-Wesley. All rights reserved.
Course Outline Book: Discrete Mathematics by K. P. Bogart Topics:
Copyright © Curt Hill Truth Tables A way to show Boolean Operations.
Lecture 7 Topics –Boolean Algebra 1. Logic and Bits Operation Computers represent information by bit A bit has two possible values, namely zero and one.
Boolean Algebra and Computer Logic Mathematical Structures for Computer Science Chapter 7.1 – 7.2 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Boolean.
Discrete Mathematics CS 2610 February 12, Agenda Previously Finished functions Began Boolean algebras And now Continue with Boolean algebras.
Thinking Mathematically
Extra slides for Chapter 3: Propositional Calculus & Normal Forms Based on Prof. Lila Kari’s slides For CS2209A, 2009 By Dr. Charles Ling;
Laws of Boolean Algebra Commutative Law Associative Law Distributive Law Identity Law De Morgan's Theorem.
Symbolic Logic The Following slide were written using materials from the Book: The Following slide were written using materials from the Book: Discrete.
 2012 Pearson Education, Inc. Slide Chapter 3 Introduction to Logic.
Foundations of Discrete Mathematics Chapter 1 By Dr. Dalia M. Gil, Ph.D.
Introduction to Logic © 2008 Pearson Addison-Wesley.
CS1022 Computer Programming & Principles
The Foundations: Logic and Proofs
Thinking Mathematically
Truth Tables and Equivalent Statements
CHAPTER 2 Boolean Algebra
Digital Logic.
TN 221: DIGITAL ELECTRONICS 1
Jeremy R. Johnson Wed. Sept. 29, 1999
Propositional Calculus: Boolean Algebra and Simplification
Chapter 3 Introduction to Logic 2012 Pearson Education, Inc.
Foundations of Discrete Mathematics
Presentation transcript:

CS1022 Computer Programming & Principles Lecture 9.1 Boolean Algebra (1)

Plan of lecture Introduction Boolean operations Boolean algebra vs. logic Boolean expressions Laws of Boolean algebra Boolean functions Disjunctive normal form CS1022

Introduction Boolean algebra Is a logical calculus Structures and rules applied to logical symbols Just like ordinary algebra is applied to numbers Uses a two-valued set {0, 1} Operations: conjunction, disjunction and negation Is related with Propositional logic and Algebra of sets Underpins logical circuits (electronic components) CS1022

Boolean operations (1)  1  1 1 0 1 Boolean algebra uses set B  0, 1 of values Operations: Disjunction (), Conjunction () and Negation ()  1  1 1 0 1 CS1022

Boolean operations (2) p q p  q p  q 1 p p 1 If p and q are Boolean variables “Variables” because they vary over set B  0, 1 That is, p, q  B We can build the following tables: p q p  q p  q 1 p p 1 CS1022

Boolean algebra vs. logic Boolean algebra is similar to propositional logic Boolean variables p, q,... like propositions P, Q,... Values B  0, 1 like F (false) and T (true) Operators are similar: p  q similar to P or Q p  q similar to P and Q p similar to not P Tables also called “truth tables” (as in logic) CS1022

Boolean expressions As in logic, we can build more complex constructs from basic variables and operators ,  and  Complex constructs are called Boolean expressions A recursive definition for Boolean expressions: All Boolean variables (p, q, r, s, etc.) are Boolean exprns. If α and β are Boolean expressions then α is a Boolean expression (and so is β) (α  β) is a Boolean expression (α  β) is a Boolean expression Example: ((p  q)  (r  s)) CS1022

Equivalence of expressions Two Boolean expressions are equivalent if they have the same truth table The final outcome of the expressions are the same, for any value the variables have We can prove mechanically if any two expressions are equivalent or not “Mechanic” means “a machine (computer) can do it” No need to be creative, clever, etc. An algorithm explains how to prove equivalence CS1022

Laws of Boolean algebra (1) Some equivalences are very useful They simplify expressions, making life easier They allow us to manipulate expressions Some equivalences are “laws of Boolean algebra” We have, in addition to truth-tables, means to operate on expressions Because equivalence is guaranteed we won’t need to worry about changing the meaning CS1022

Laws of Boolean algebra (2) Commutative Laws p  q  q  p p  q  q  p Associativity Laws p  (q  r)  (p  q)  r p  (q  r)  (p  q)  r Distributive Laws p  (q  r)  (p  q)  (p  r) p  (q  r)  (p  q)  (p  r) Idempotent Laws p  p  p p  p  p Absorption Laws p  (p  q)  p p  (p  q)  p De Morgan’s Laws (p  q)  p  q (p  q)  p  q CS1022

Laws of Boolean algebra (3) Do they look familiar? Logics, sets & Boolean algebra are all related Summary of correspondence: Logical operation Set operation Boolean operation not   or   and   CS1022

Laws of Boolean algebra (4) Very important: Laws shown with Boolean variables (p, q, r, etc.) However, each Boolean variable stand for an expression Wherever you see p, q, r, etc., you should think of “place holders” for any complex expression A more “correct” way to represent e.g. idempotent law:      CS1022

Laws of Boolean algebra (5) What do we mean by “place holders”? The laws are “templates” which can be used in many different situations For example: ((p  q)  (q  s))  ((p  q)  (q  s))     ((p  q)  (q  s)) CS1022

Laws of Boolean algebra (6) We should be able to prove all laws We know how to build truth tables (lectures 2.1 & 2.2) Could you work out an algorithm to do this? There is help at hand... CS1022

Laws of Boolean algebra (7) Using the laws of Boolean algebra, show that (p  q)  (p  q) is equivalent to p Solution: (p  q)  (p  q)  (p  q)  (p  q) De Morgan’s  (p  q)  (p  q) since p  p  p  (q  q) Distr. Law  p  0 since (q q)  0  p from def. of  CS1022

Boolean functions (1) A Boolean function of n variables p1, p2, ..., pn is A function f : Bn  B Such that f(p1, p2, ..., pn) is a Boolean expression Any Boolean expression can be represented in an equivalent standard format The so-called disjunctive normal form Format to make it easier to “process” expressions Simpler, fewer operators, etc. CS1022

Boolean functions (2) Example: function minterm m(p, q, r) It has precisely one “1” in the final column of truth table m(p, q, r)  1 if p  0, q  1 and r  1 We can define m(p, q, r)  p q  r The expression p q  r is the product representation of the minterm m p q r m 1 CS1022

Boolean functions (3) p q r m 1 Any minterm m(p1, p2, ..., pr) can be represented as a conjunction of the variables pi or their negations Here’s how: Look at row where m takes value 1 If pi  1, then pi is in the product representation of m If pi  0, then pi is in the product representation of m We thus have m(p, q, r)  p q  r p q r m 1 CS1022

Disjunctive normal form (1) We can express any Boolean function uniquely as a disjunction (a sequence of “”) of minterms This is the disjunctive normal form The idea is simple: Each minterm is a conjunction (sequence of “”) which, if all holds, then we have output (result) “1” The disjunction of minterms lists all cases which, if at least one holds, then we have output (result) “1” In other words: we list all cases when it should be “1” and say “at least one of these is 1” CS1022

Disjunctive normal form (2) Find disjunctive normal form for (p  q)  (q r) Let f  (p  q)  (q r). Its truth table is as below The minterms are (rows with f  1) p  q r p  q r p  q  r p  q  r Disjunctive normal form is (p  q r)  (p  q r)  (p  q  r)  (p  q  r) p q r f 1 p q r f 1 p q r f 1 p q r f 1 p q r f 1 p q r f 1 CS1022

Minimal set of operators Any Boolean function can be represented with Boolean operators , ,  This is a complete set of operators “Complete” = “we can represent anything we need” It is not minimal, though: De Morgan’s (p  q)  p  q, so (p  q)  (p  q) We can define “” in terms of ,  Minimal set of Boolean operators: ,  or ,  Actually, any two operators suffice Minimality comes at a price: expressions become very complex and convoluted CS1022

Further reading R. Haggarty. “Discrete Mathematics for Computing”. Pearson Education Ltd. 2002. (Chapter 9) Wikipedia’s entry on Boolean algebra Wikibooks entry on Boolean algebra CS1022