cse 311: foundations of computing Spring 2015 Lecture 3: Logic and Boolean algebra

Similar documents
CSE 311: Foundations of Computing. Lecture 2: More Logic, Equivalence & Digital Circuits

CSE 311: Foundations of Computing. Lecture 2: More Logic, Equivalence & Digital Circuits

CSE 311: Foundations of Computing. Lecture 3: Digital Circuits & Equivalence

CSC Discrete Math I, Spring Propositional Logic

CSE 20 DISCRETE MATH. Fall

COSC 243. Introduction to Logic And Combinatorial Logic. Lecture 4 - Introduction to Logic and Combinatorial Logic. COSC 243 (Computer Architecture)

Lab 1 starts this week: go to your session

Math.3336: Discrete Mathematics. Propositional Equivalences

Compound Propositions

Outline. EECS150 - Digital Design Lecture 4 - Boolean Algebra I (Representations of Combinational Logic Circuits) Combinational Logic (CL) Defined

Switches: basic element of physical implementations

CSE 20: Discrete Mathematics

XOR - XNOR Gates. The graphic symbol and truth table of XOR gate is shown in the figure.

We last time we began introducing equivalency laws.

CSE 20 DISCRETE MATH WINTER

2.2: Logical Equivalence: The Laws of Logic

Tautologies, Contradictions, and Contingencies

EECS150 - Digital Design Lecture 4 - Boolean Algebra I (Representations of Combinational Logic Circuits)

Boolean algebra. Examples of these individual laws of Boolean, rules and theorems for Boolean algebra are given in the following table.

EEE130 Digital Electronics I Lecture #4

HW1 graded review form? HW2 released CSE 20 DISCRETE MATH. Fall

About the course. CSE 321 Discrete Structures. Why this material is important. Topic List. Propositional Logic. Administration. From the CSE catalog:

Propositional Equivalence

COS 140: Foundations of Computer Science

CS/COE1541: Introduction to Computer Architecture. Logic Design Review. Sangyeun Cho. Computer Science Department University of Pittsburgh

Boolean Algebra, Gates and Circuits

Propositional Logic: Equivalence

CSE 20 DISCRETE MATH WINTER

Doc112: Hardware. Department of Computing, Imperial College London. Doc112: Hardware Lecture 1 Slide 1

Chapter 2: Switching Algebra and Logic Circuits

Logic and Boolean algebra

CSE370: Introduction to Digital Design

Digital Logic (2) Boolean Algebra

Announcements. CS311H: Discrete Mathematics. Propositional Logic II. Inverse of an Implication. Converse of a Implication

Ex: Boolean expression for majority function F = A'BC + AB'C + ABC ' + ABC.

Part I: Propositional Calculus

Definition 2. Conjunction of p and q

Discrete Mathematics and Applications COT3100

Discrete Mathematics. CS204: Spring, Jong C. Park Computer Science Department KAIST

CprE 281: Digital Logic

CprE 281: Digital Logic

CprE 281: Digital Logic

Section 1.2 Propositional Equivalences. A tautology is a proposition which is always true. A contradiction is a proposition which is always false.

4 Switching Algebra 4.1 Axioms; Signals and Switching Algebra

KP/Worksheets: Propositional Logic, Boolean Algebra and Computer Hardware Page 1 of 8

cse 311: foundations of computing Fall 2015 Lecture 6: Predicate Logic, Logical Inference

Discrete Structures & Algorithms. Propositional Logic EECE 320 // UBC

CSE20: Discrete Mathematics for Computer Science. Lecture Unit 2: Boolan Functions, Logic Circuits, and Implication

XI STANDARD [ COMPUTER SCIENCE ] 5 MARKS STUDY MATERIAL.

MAT2345 Discrete Math

Logic design? Transistor as a switch. Layered design approach. CS/COE1541: Introduction to Computer Architecture. Logic Design Review.

Discrete Structures of Computer Science Propositional Logic III Rules of Inference

BOOLEAN LOGIC. By- Neha Tyagi PGT CS KV 5 Jaipur II Shift, Jaipur Region. Based on CBSE curriculum Class 11. Neha Tyagi, KV 5 Jaipur II Shift

ICS141: Discrete Mathematics for Computer Science I

Introduction to Computer Engineering ECE 203

Consider the following propositions: p: lecture has started q: If I have a banana, then I have a pear r: I finished this problem

Announcements. CS243: Discrete Structures. Propositional Logic II. Review. Operator Precedence. Operator Precedence, cont. Operator Precedence Example

Propositional Logic Logical Implication (4A) Young W. Lim 4/11/17

CSE 20. Lecture 4: Introduction to Boolean algebra. CSE 20: Lecture4

Truth-Functional Logic

CS/COE0447: Computer Organization and Assembly Language

CS 226: Digital Logic Design

Logic Design. Chapter 2: Introduction to Logic Circuits

CS 173 Lecture 2: Propositional Logic

Set Theory Basics of Set Theory. mjarrar Watch this lecture and download the slides

LAGUARDIA COMMUNITY COLLEGE CITY UNIVERSITY OF NEW YORK NATURAL SCIENCES DEPARTMENT. SCC105: Introduction to Chemistry Fall I 2014

Lecture 2. Logic Compound Statements Conditional Statements Valid & Invalid Arguments Digital Logic Circuits. Reading (Epp s textbook)

CS/COE0447: Computer Organization

CpE358/CS381. Switching Theory and Logical Design. Summer

Computer Organization: Boolean Logic

Lecture 2 Review on Digital Logic (Part 1)

Logic Gates and Boolean Algebra

1.3 Propositional Equivalences

Numbers and Arithmetic

Lecture A: Logic Design and Gates

General Info. Grading

Adequate set of connectives, logic gates and circuits

Floating Point Representation and Digital Logic. Lecture 11 CS301

ECE 545 Digital System Design with VHDL Lecture 1. Digital Logic Refresher Part A Combinational Logic Building Blocks

Solutions to Homework I (1.1)

Combinational Logic. Review of Combinational Logic 1

EECS 1028 M: Discrete Mathematics for Engineers

Propositional Logic Logical Implication (4A) Young W. Lim 4/21/17

Note: The area of logic that deals with propositions is called the propositional calculus or propositional logic.

Combinational logic. Possible logic functions of two variables. Minimal set of functions. Cost of different logic functions.

2/13/2012. Logic: Truth Tables. CS160 Rosen Chapter 1. Logic?

Boolean Algebra. Philipp Koehn. 9 September 2016

Logic Synthesis and Verification

ECE 545 Digital System Design with VHDL Lecture 1A. Digital Logic Refresher Part A Combinational Logic Building Blocks

Announcement. Homework 1

The Logic of Compound Statements cont.

Fundamentals of Digital Design

CS/COE0447: Computer Organization

Overview, cont. Overview, cont. Logistics. Optional Reference #1. Optional Reference #2. Workload and Grading

Chapter 4, Logic using Propositional Calculus Handout

CISC-102 Winter 2016 Lecture 17

1. Name the person who developed Boolean algebra

UC Berkeley College of Engineering, EECS Department CS61C: Representations of Combinational Logic Circuits

Numbers & Arithmetic. Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University. See: P&H Chapter , 3.2, C.5 C.

Sample Problems for all sections of CMSC250, Midterm 1 Fall 2014

Transcription:

cse 311: foundations of computing Spring 2015 Lecture 3: Logic and Boolean algebra

gradescope Homework #1 is up (and has been since Friday). It is due Friday, October 9 th at 11:59pm. You should have received (i) An invitation from Gradescope [if not, email cse311-staff ASAP] (ii) An email from me about (i) [if not, go to the course web page and sign up for the class email list] Note: Homework and extra credit are separate assignments.

1 more gates NAND (X Y) X Y Z X Y Z 0 0 1 0 1 1 1 0 1 1 1 0 NOR (X Y) X Y Z X Y Z 0 0 1 0 1 0 1 0 0 1 1 0 XOR X Y X Y Z X 0 Y 0 Z 0 0 1 1 1 1 0 1 1 0 XNOR X Y, X = Y X Y Z X Y Z 0 0 1 0 1 0 1 1 0 1 0 1

review: logical equivalence Terminology: A compound proposition is a Tautology if it is always true Contradiction if it is always false Contingency if it can be either true or false p p p p (p q) p Tautology! Contradiction! Contingency! (p q) (p q) ( p q) ( p q) Tautology!

logical equivalence A and B are logically equivalent if and only if A B is a tautology i.e. A and B have the same truth table The notation A B denotes A and B are logically equivalent. Example: p p p p p p p T F T T F T F T

p q p q p q p q review: de Morgan s laws if!(front!= null && value > front.data) front = new ListNode(value, front); else { ListNode current = front; while!(current.next == null current.next.data >= value) current = current.next; current.next = new ListNode(value, current.next); } This code inserts value into a sorted linked list. The first if runs when: front is null or value is smaller than the first item. The while loop stops when: we ve reached the end of the list or the next value is bigger.

review: law of implication p q ( p q) p q p q p p q (p q) ( p q) T T T F T T T F F F F T F T T T T T F F T T T T

computing equivalence Describe an algorithm for computing if two logical expressions/circuits are equivalent. What is the run time of the algorithm? Compute the entire truth table for both of them! There are 2 n entries in the column for n variables.

some familiar properties of arithmetic x + y = y + x p q q p p q q p (commutativity) x y + z = x y + x z p q r p q (p r) p q r p q (p r) (distributivity) x + y + z = x + (y + z) (associativity) p q r p q r p q r p (q r)

properties of logical connectives Identity p T p p F p Domination p T T p F F Idempotent p p p p p p You will always get this list. Associative p q r p q r p q r p q r Distributive p q r p q (p r) p q r p q (p r) Absorption p p q p p p q p Commutative p q q p p q q p Negation p p T p p F

Reflect basic rules of reasoning and logic Allow manipulation of logical formulas Simplification Testing for equivalence Applications Query optimization Search optimization and caching Artificial intelligence / machine learning Program verification understanding connectives

equivalences related to implication p q p q p q q p p q p q (q p) p q p q

logical proofs To show P is equivalent to Q Apply a series of logical equivalences to sub-expressions to convert P to Q To show P is a tautology Apply a series of logical equivalences to sub-expressions to convert P to T

prove this is a tautology p q (p q)

prove this is a tautology (p (p q)) q

prove these are equivalent (p q) r p (q r)

prove these are not equivalent (p q) r p (q r)

Boolean logic Combinational Logic output = F(input) Sequential Logic output t = F(output t-1, input t ) output dependent on history concept of a time step (clock, t) Boolean Algebra consisting of a set of elements B = {0, 1} binary operations { +, } (OR, AND) and a unary operation { } (NOT) George homeopathy Boole

a combinatorial logic example Sessions of class: We would like to compute the number of lectures or quiz sections remaining at the start of a given day of the week. Inputs: Day of the Week, Lecture/Section flag Output: Number of sessions left Examples: Input: (Wednesday, Lecture) Output: 2 Input: (Monday, Section) Output: 1

implementation in software public int classesleft (weekday, lecture_flag) { switch (day) { case SUNDAY: case MONDAY: return lecture_flag? 3 : 1; case TUESDAY: case WEDNESDAY: return lecture_flag? 2 : 1; case THURSDAY: return lecture_flag? 1 : 1; case FRIDAY: return lecture_flag? 1 : 0; case SATURDAY: return lecture_flag? 0 : 0; } }

implementation with combinational logic Encoding: How many bits for each input/output? Binary number for weekday One bit for each possible output Weekday Lecture? 0 1 2 3

defining our inputs public int classesleft (weekday, lecture_flag) { switch (day) { case SUNDAY: case MONDAY: return lecture_flag? 3 : 1; case TUESDAY: case WEDNESDAY: return lecture_flag? 2 : 1; case THURSDAY: return lecture_flag? 1 : 1; case FRIDAY: return lecture_flag? 1 : 0; case SATURDAY: return lecture_flag? 0 : 0; } } Weekday Number Binary Sunday 0 (000) 2 Monday 1 (001) 2 Tuesday 2 (010) 2 Wednesday 3 (011) 2 Thursday 4 (100) 2 Friday 5 (101) 2 Saturday 6 (110) 2

converting to a truth table Weekday Number Binary Sunday 0 (000) 2 Monday 1 (001) 2 Tuesday 2 (010) 2 Wednesday 3 (011) 2 Thursday 4 (100) 2 Friday 5 (101) 2 Saturday 6 (110) 2 Weekday Lecture? c0 c1 c2 c3 000 0 0 1 0 0 000 1 0 0 0 1 001 0 0 1 0 0 001 1 0 0 0 1 010 0 0 1 0 0 010 1 0 0 1 0 011 0 0 1 0 0 011 1 0 0 1 0 100-0 1 0 0 101 0 1 0 0 0 101 1 0 1 0 0 110-1 0 0 0 111 - - - - -

truth table logic (part one) DAY d2d1d0 L c0 c1 c2 c3 SunS 000 0 0 1 0 0 SunL 000 1 0 0 0 1 MonS 001 0 0 1 0 0 MonL 001 1 0 0 0 1 TueS 010 0 0 1 0 0 TueL 010 1 0 0 1 0 c3 = (DAY == SUN and LEC) or (DAY == MON and LEC) c3 = (d2 == 0 && d1 == 0 && d0 == 0 && L == 1) (d2 == 0 && d1 == 0 && d0 == 1 && L == 1) c3 = d2 d1 d0 L + d2 d1 d0 L WedS 011 0 0 1 0 0 WedL 011 1 0 0 1 0 Thu 100-0 1 0 0 FriS 101 0 1 0 0 0 FriL 101 1 0 1 0 0 Sat 110-1 0 0 0-111 - - - - -

truth table logic (part two) DAY d2d1d0 L c0 c1 c2 c3 SunS 000 0 0 1 0 0 SunL 000 1 0 0 0 1 MonS 001 0 0 1 0 0 MonL 001 1 0 0 0 1 TueS 010 0 0 1 0 0 TueL 010 1 0 0 1 0 c3 = d2 d1 d0 L + d2 d1 d0 L WedS 011 0 0 1 0 0 WedL 011 1 0 0 1 0 c2 = (DAY == TUE and LEC) or (DAY == WED and LEC) c2 = d2 d1 d0 L + d2 d1 d0 L Thu 100-0 1 0 0 FriS 101 0 1 0 0 0 FriL 101 1 0 1 0 0 Sat 110-1 0 0 0-111 - - - - -

truth table logic (part three) DAY d2d1d0 L c0 c1 c2 c3 SunS 000 0 0 1 0 0 SunL 000 1 0 0 0 1 MonS 001 0 0 1 0 0 MonL 001 1 0 0 0 1 TueS 010 0 0 1 0 0 c3 = d2 d1 d0 L + d2 d1 d0 L c2 = d2 d1 d0 L + d2 d1 d0 L TueL 010 1 0 0 1 0 WedS 011 0 0 1 0 0 WedL 011 1 0 0 1 0 c1 = [you do this one] Thu 100-0 1 0 0 FriS 101 0 1 0 0 0 FriL 101 1 0 1 0 0 c0 = d2 d1 d0 L + d2 d1 d0 Sat 110-1 0 0 0-111 - - - - -

logic gates d2 d1 d0 L c3 = d2 d1 d0 L + d2 d1 d0 L NOT NOT NOT AND AND (multiple input AND gates) [LEVEL UP] OR DAY d2d1d0 L c0 c1 c2 c3 SunS 000 0 0 1 0 0 SunL 000 1 0 0 0 1 MonS 001 0 0 1 0 0 MonL 001 1 0 0 0 1 TueS 010 0 0 1 0 0 TueL 010 1 0 0 1 0 WedS 011 0 0 1 0 0 WedL 011 1 0 0 1 0 Thu 100-0 1 0 0 FriS 101 0 1 0 0 0 FriL 101 1 0 1 0 0 Sat 110-1 0 0 0-111 - - - - -