CS203 Discrete Mathematical Structures Logic (2).

Slides:



Advertisements
Similar presentations
Logic Gates.
Advertisements

Section 1.3. More Logical Equivalences Constructing New Logical Equivalences We can show that two expressions are logically equivalent by developing.
Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 1: (Part 2): The Foundations: Logic and Proofs.
L41 Lecture 2: Predicates and Quantifiers.. L42 Agenda Predicates and Quantifiers –Existential Quantifier  –Universal Quantifier 
Discrete Structures Chapter 1 Part B Fundamentals of Logic Nurul Amelina Nasharuddin Multimedia Department 1.
Basic Logic Gates and De Morgan's Theorem Discussion D5.1 Appendix D.
CMSC 250 Discrete Structures Exam #1 Review. 21 June 2007Exam #1 Review2 Symbols & Definitions for Compound Statements pq p  qp  qp  qp  qp  q 11.
Chapter 4 Logic Gates and Boolean Algebra. Introduction Logic gates are the actual physical implementations of the logical operators. These gates form.
CSE115/ENGR160 Discrete Mathematics 01/20/11 Ming-Hsuan Yang UC Merced 1.
1 Predicates and Quantifiers CS 202, Spring 2007 Epp, Sections 2.1 and 2.2 Aaron Bloomfield.
Predicates and Quantifiers
Chapter 1: The Foundations: Logic and Proofs
CSci 2011 Discrete Mathematics Lecture 3 CSci 2011.
The Foundations: Logic and Proofs
Logical Circuit Design Week 5: Combinational Logic Circuits Mentor Hamiti, MSc Office ,
Discrete Mathematics. Propositional Logic 10/8/2015 What’s a proposition? PropositionsNot Propositions = 32Bring me coffee! CS173 is Bryan’s favorite.
(CSC 102) Lecture 7 Discrete Structures. Previous Lectures Summary Predicates Set Notation Universal and Existential Statement Translating between formal.
COMPSCI 210 Semester Tutorial 2: Logic Gates.
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
Lecture 1.2: Equivalences, and Predicate Logic* CS 250, Discrete Structures, Fall 2011 Nitesh Saxena *Adopted from previous lectures by Cinda Heeren, Zeph.
January 30, 2002Applied Discrete Mathematics Week 1: Logic and Sets 1 Let’s Talk About Logic Logic is a system based on propositions.Logic is a system.
Hazırlayan DISCRETE COMPUTATIONAL STRUCTURES Propositional Logic PROF. DR. YUSUF OYSAL.
Discrete Mathematics. Predicates - the universal quantifier 11/28/2015 Suppose P(x) is a predicate on some universe of discourse. Ex. B(x) = “x is carrying.
(CSC 102) Lecture 8 Discrete Structures. Previous Lectures Summary Predicates Set Notation Universal and Existential Statement Translating between formal.
1 Introduction to Abstract Mathematics Predicate Logic Instructor: Hayk Melikya Purpose of Section: To introduce predicate logic (or.
Lecture Predicates and Quantifiers 1.4 Nested Quantifiers.
Lecture 7 – Jan 28, Chapter 2 The Logic of Quantified Statements.
Discrete Mathematics CS 2610 August 22, Agenda Last class Propositional logic Logical equivalences This week Predicate logic & rules of inference.
Lecture 8 Predicate Logic TF4233 Mathematical Logic Semester 2, 2006/2007 Dr. Rolly Intan & Cherry Ballangan, MAIT Informatics Department, Petra Christian.
Discrete Structures – CNS 2300
CS 285- Discrete Mathematics Lecture 4. Section 1.3 Predicate logic Predicate logic is an extension of propositional logic that permits concisely reasoning.
Discrete Structures Predicate Logic 1 Dr. Muhammad Humayoun Assistant Professor COMSATS Institute of Computer Science, Lahore.
Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions.
5 - Digital Logic with Boolean Algebra
Chapter-3: BOOLEAN ALGEBRA & LOGIC GATES Analysis and logical design.
Lecture 1.2: Equivalences, and Predicate Logic CS 250, Discrete Structures, Fall 2015 Nitesh Saxena Adopted from previous lectures by Cinda Heeren, Zeph.
321 Section, Week 2 Natalie Linnell. Extra Credit problem.
Department of Preparatory Year, Umm Al Qura University CSCI 240 Digital Logic.
Basic Logic Gates By : Ashima Wadhwa Assistant Professor (giBS)
Boolean Algebra. BOOLEAN ALGEBRA Formal logic: In formal logic, a statement (proposition) is a declarative sentence that is either true(1) or false (0).
PREDICATES AND QUANTIFIERS COSC-1321 Discrete Structures 1.
Mathematics for Comter I Lecture 3: Logic (2) Propositional Equivalences Predicates and Quantifiers.
Section 1.4. Propositional Functions Propositional functions become propositions (and have truth values) when their variables are each replaced by a value.
Discrete Mathematical الرياضيات المتقطعة. Example 12 June OR Q(x,y): x+y=x-y a) Q(1,1): 2=0 False b) Q(2,0): 2+0=2-0 True c) Q(1,y): 1+y=1-y False(take.
Introduction to Discrete Mathematics Discrete Mathematics: is the part of mathematics devoted to the study of discrete objects. Discrete Mathematics is.
Digital Logic. Boolean Algebra to Logic Gates Logic circuits are built from components called logic gates. The logic gates correspond to Boolean operations.
Lecture 1.2: Equivalences, and Predicate Logic
Logic Gates and Boolean Algebra
Semantic Web Logic.
Applied Discrete Mathematics Week 5: Mathematical Reasoning
Logic Gates.
Discussion D5.1 Section Sections 13-3, 13-4
CS203 Discrete Mathematical Structures
Chapter 1 The Foundations: Logic and Proofs
CS201: Data Structures and Discrete Mathematics I
1.4 Predicates and Quantifiers
Boolean Algebra & Logic Circuits
CS 220: Discrete Structures and their Applications
CHAPTER 1: LOGICS AND PROOF
Logic Gates.
Introduction to Predicates and Quantified Statements II
Introduction to Predicates and Quantified Statements I
Discussion D5.1 Section Sections 13-3, 13-4
Applied Discrete Mathematics Week 2: Proofs
Discussion D5.1 Section Sections 13-3, 13-4
Basic Logic Gates.
Basic Logic Gates.
Predicates and Quantifiers
CS201: Data Structures and Discrete Mathematics I
Presentation transcript:

CS203 Discrete Mathematical Structures Logic (2)

Predicate Logic - everybody loves somebody Proposition, YES or NO? = 5 X + 2 = 5 X + 2 = 5 for any choice of X in {1, 2, 3} X + 2 = 5 for some X in {1, 2, 3} YESNO YES

Predicates Ahmed eats pizza at least once a week. Define: EP(x) = “x eats pizza at least once a week.” Universe of Discourse - x is a student in CS203 A predicate is a function that takes some variable(s) as arguments and returns True or False. Note that EP(x) is not a proposition, EP(Hassan) is. …

Predicates A predicate is a property or description of subjects in the universe of discourse. The following predicates are all italicized : –Johnny is tall. –The bridge is structurally sound. –17 is a prime number. Java: predicates are boolean- valued method calls- –someLinkedList.isEmpty() –isPrime(17)

Quantifiers There are two quantifiers Existential Quantifier “  ” reads “ there exists ” Universal Quantifier “  ” reads “ for all ” Each is placed in front of a propositional function and binds it to obtain a proposition with semantic value.

Predicates - the universal quantifier Suppose P(x) is a predicate on some universe of discourse. Ex. B(x) = “x is carrying a backpack,” x is set of CS203 students. The universal quantifier of P(x) is the proposition: “P(x) is true for all x in the universe of discourse.” We write it  x P(x), and say “for all x, P(x)”  x P(x) is TRUE if P(x) is true for every single x.  x P(x) is FALSE if there is an x for which P(x) is false.  x B(x)?

Predicates - the existential quantifier Suppose P(x) is a predicate on some universe of discourse. Ex. C(x) = “x has a cat,” x is set of CS203 students. The existential quantifier of P(x) is the proposition: “P(x) is true for some x in the universe of discourse.” We write it  x P(x), and say “for some x, P(x)”  x P(x) is TRUE if there is an x for which P(x) is true.  x P(x) is FALSE if P(x) is false for every single x.  x C(x)?

Predicates - the existential quantifier B(x) = “x is wearing sneakers.” L(x) = “x is at least 16 years old.” Y(x)= “x is less than 24 years old.” Are either of these propositions true? a)  x B(x) b)  x (Y(x)  L(x)) A: only a is true B: only b is true C: both are true D: neither is true Universe of discourse is people in this room.

Predicates - more examples Universe of discourse is all creatures. L(x) = “x is a lion.” F(x) = “x is fierce.” C(x) = “x drinks coffee.” All lions are fierce. Some lions don’t drink coffee. Some fierce creatures don’t drink coffee.  x (L(x)  F(x))  x (L(x)   C(x))  x (F(x)   C(x))

Predicates - more examples Universe of discourse is all creatures. B(x) = “x is a hummingbird.” L(x) = “x is a large bird.” H(x) = “x lives on honey.” R(x) = “x is richly colored.” All hummingbirds are richly colored. No large birds live on honey. Birds that do not live on honey are dully colored.  x (B(x)  R(x))  x (L(x)  H(x))  x (  H(x)   R(x))

Fundamentals of Logic The Use of Quantifiers Ex x=4 x=1 x=5,6,... x=-1 universe: real numbers

Predicates - the universal quantifier B(x) = “x is wearing sneakers.” L(x) = “x is at least 18 years old.” Y(x)= “x is less than 24 years old.” Are either of these propositions true? a)  x (Y(x)  B(x)) b)  x (Y(x)  L(x)) A: only a is true B: only b is true C: both are true D: neither is true Universe of discourse is people in this Hall.

Predicates - quantifier negation Not all large birds live on honey.  x P(x) means “P(x) is true for every x.” What about  x P(x) ? Not [“P(x) is true for every x.”] “There is an x for which P(x) is not true.”  x  P(x) So,  x P(x) is the same as  x  P(x).  x (L(x)  H(x))  x  (L(x)  H(x))

Predicates - quantifier negation No large birds live on honey.  x P(x) means “P(x) is true for some x.” What about  x P(x) ? Not [“P(x) is true for some x.”] “P(x) is not true for all x.”  x  P(x) So,  x P(x) is the same as  x  P(x).  x (L(x)  H(x))  x  (L(x)  H(x))

Predicates - quantifier negation So,  x P(x) is the same as  x  P(x). So,  x P(x) is the same as  x  P(x). General rule: to negate a quantifier, move negation to the right, changing quantifiers as you go.

Fundamentals of Logic Ex. p(x): x is odd. q(x): x 2 -1 is even. Negate (If x is odd, then x 2 -1 is even.) There exists an integer x such that x is odd and x 2 -1 is odd. (a false statement, the original is true)

Predicates - quantifier negation No large birds live on honey.  x (L(x)  H(x))   x  (L(x)  H(x))Negation rule   x (  L(x)   H(x))DeMorgan’s   x (L(x)   H(x))Subst for  What’s wrong with this proof?

Fundamentals of Logic multiple variables

Fundamentals of Logic BUT Ex. p(x,y): x+y=17. : For every integer x, there exists an integer y such that x+y=17. (TRUE) : There exists an integer y so that for all integer x, x+y=17. (FALSE) Therefore,

20 Order matters Set the universe of discourse to be all natural numbers {0, 1, 2, 3, … }. Let R (x,y ) = “ x < y ”. Q1: What does  x  y R (x,y ) mean? Q2: What does  y  x R (x,y ) mean?

21 Order matters R (x,y ) = “ x < y ” A1:  x  y R (x,y ): “ All numbers x admit a bigger number y ” A2:  y  x R (x,y ): “ Some number y is bigger than all x ” Q: What ’ s the true value of each expression?

More Practice for Predicate Logic Nermin likes all movies that Rehab likes (and possibly more).  x [Movie(x)  Likes(Rehab, x)  Likes(Nermin, x)] There is exactly one AU professor who won a Nobel prize  x[AU_Prof(x)  Wins(x, NobelPrize)]   y,z[y  z  AU_Prof(y)  AU_Prof(z)  Wins(y, NobelPrize)  Wins(z, NobelPrize)]

23 Review of Boolean algebra Not is a horizontal bar above the number –0 = 1 –1 = 0 Or is a plus –0+0 = 0 –0+1 = 1 –1+0 = 1 –1+1 = 1 And is multiplication –0*0 = 0 –0*1 = 0 –1*0 = 0 –1*1 = 1

NOT A A’ or -A Logic Gate: (also called an inverter) Single-throw Double-pole Switch: A A-A Truth Table: A’ or -A Y = ~X Y = !X Y = not X Y = X’ not(Y,X)

AND A B A*B Logic Gate: Series Circuit: ABABA*B Truth Table: A*B

X & Y (Verilog and ABEL) X and Y (VHDL) X Y X * Y XY(textbook) and(Z,X,Y)(Verilog) AND U V

A B A+B Logic Gate: Parallel Circuit: A B ABA+B Truth Table: A+B OR

X | Y(Verilog) X # Y(ABEL) X or Y(VHDL) X + Y(textbook) X V Y X U Y or(Z,X,Y) (Verilog)

NAND Gate NAND X Y Z X Y Z Z = ~(X & Y) nand(Z,X,Y)

NOR Gate NOR X Y Z X Y Z Z = ~(X | Y) nor(Z,X,Y)

Exclusive-OR Gate X Y Z XOR X Y Z Z = X ^ Y xor(Z,X,Y)

XOR X ^ Y(Verilog) X $ Y(ABEL) Y xor(Z,X,Y) (Verilog)

Logic Circuits ≡ Boolean Expressions All logic circuits are equivalent to Boolean expressions and any boolean expression can be rendered as a logic circuit. AND-OR logic circuits are equivalent to sum-of-products form. Consider the following circuits: A C B abc aBc Ab y=abc+aBc+Ab y A B C Y y=aB+Bc

34 question Find the output of the following circuit Answer: (x+y)y –Or (x  y)  y x+yx+y y (x+y)y(x+y)y__

question Write the circuits for the following Boolean algebraic expressions (x+y)x _______ x+yx+y x+yx+y (x+y)x(x+y)x

36 Draw a circuit diagram for  = (xy' + x'y)z.

37

38

Let’s compare the resulting circuits Here are two different but equivalent circuits. In general the one with fewer gates is “better”: –It costs less to build –It requires less power –But we had to do some work to find the second form