Discrete Structures for Computer Science

Similar documents
Propositional Logic Not Enough

Discrete Structures for Computer Science

Introduction to Sets and Logic (MATH 1190)

Discrete Structures for Computer Science

Review: Potential stumbling blocks

Section Summary. Section 1.5 9/9/2014

Section Summary. Predicate logic Quantifiers. Negating Quantifiers. Translating English to Logic. Universal Quantifier Existential Quantifier

Mat 243 Exam 1 Review

Today s Lecture. ICS 6B Boolean Algebra & Logic. Predicates. Chapter 1: Section 1.3. Propositions. For Example. Socrates is Mortal

ICS141: Discrete Mathematics for Computer Science I

Section Summary. Predicate logic Quantifiers. Negating Quantifiers. Translating English to Logic. Universal Quantifier Existential Quantifier

DISCRETE MATHEMATICS BA202

Proposi'onal Logic Not Enough

Chapter 3. The Logic of Quantified Statements

Logic and Propositional Calculus

! Predicates! Variables! Quantifiers. ! Universal Quantifier! Existential Quantifier. ! Negating Quantifiers. ! De Morgan s Laws for Quantifiers

Math.3336: Discrete Mathematics. Nested Quantifiers/Rules of Inference

Discrete Mathematics and Its Applications

Discrete Mathematics & Mathematical Reasoning Predicates, Quantifiers and Proof Techniques

Lecture Predicates and Quantifiers 1.5 Nested Quantifiers

4 Quantifiers and Quantified Arguments 4.1 Quantifiers

Review. Propositional Logic. Propositions atomic and compound. Operators: negation, and, or, xor, implies, biconditional.

3/29/2017. Logic. Propositions and logical operations. Main concepts: propositions truth values propositional variables logical operations

Predicate Logic & Quantification

Predicate Calculus lecture 1

Math.3336: Discrete Mathematics. Nested Quantifiers

Logic and Propositional Calculus

CS 220: Discrete Structures and their Applications. Predicate Logic Section in zybooks

2/2/2018. CS 103 Discrete Structures. Chapter 1. Propositional Logic. Chapter 1.1. Propositional Logic

1.3 Predicates and Quantifiers

Chapter 2: The Logic of Quantified Statements. January 22, 2010

Predicate Logic Thursday, January 17, 2013 Chittu Tripathy Lecture 04

3. The Logic of Quantified Statements Summary. Aaron Tan August 2017

2. Use quantifiers to express the associative law for multiplication of real numbers.

Logical Operators. Conjunction Disjunction Negation Exclusive Or Implication Biconditional

THE LOGIC OF QUANTIFIED STATEMENTS. Predicates and Quantified Statements I. Predicates and Quantified Statements I CHAPTER 3 SECTION 3.

Predicates, Quantifiers and Nested Quantifiers

Lecture 4. Predicate logic

Logic. Definition [1] A logic is a formal language that comes with rules for deducing the truth of one proposition from the truth of another.

Announcements CompSci 102 Discrete Math for Computer Science

Quantifiers. P. Danziger

Announcement. Homework 1

Section Summary. Predicates Variables Quantifiers. Negating Quantifiers. Translating English to Logic Logic Programming (optional)

Predicate Logic. CSE 191, Class Note 02: Predicate Logic Computer Sci & Eng Dept SUNY Buffalo

Section 2.1: Introduction to the Logic of Quantified Statements

Topic #3 Predicate Logic. Predicate Logic

(Refer Slide Time: 02:20)

Predicates and Quantifiers. CS 231 Dianna Xu

COMP 2600: Formal Methods for Software Engineeing

COMP 182 Algorithmic Thinking. Proofs. Luay Nakhleh Computer Science Rice University

Predicate Calculus - Syntax

Predicate Logic. Example. Statements in Predicate Logic. Some statements cannot be expressed in propositional logic, such as: Predicate Logic

Basic Logic and Proof Techniques

Review. Propositions, propositional operators, truth tables. Logical Equivalences. Tautologies & contradictions

Logic. Propositional Logic: Syntax

Propositional and Predicate Logic

Today s Topic: Propositional Logic

Proseminar on Semantic Theory Fall 2013 Ling 720 Propositional Logic: Syntax and Natural Deduction 1

Lecture 3. Logic Predicates and Quantified Statements Statements with Multiple Quantifiers. Introduction to Proofs. Reading (Epp s textbook)

Formal (Natural) Deduction for Predicate Calculus

Section 2.3: Statements Containing Multiple Quantifiers

Recall that the expression x > 3 is not a proposition. Why?

Logic and Proof. Aiichiro Nakano

Propositional and Predicate Logic

University of Ottawa CSI 2101 Midterm Test Instructor: Lucia Moura. February 9, :30 pm Duration: 1:50 hs. Closed book, no calculators

CS100: DISCRETE STRUCTURES. Lecture 5: Logic (Ch1)

Tools for reasoning: Logic. Ch. 1: Introduction to Propositional Logic Truth values, truth tables Boolean logic: Implications:

THE LOGIC OF COMPOUND STATEMENTS

CSCI-2200 FOUNDATIONS OF COMPUTER SCIENCE

PREDICATE LOGIC. Schaum's outline chapter 4 Rosen chapter 1. September 11, ioc.pdf

MACM 101 Discrete Mathematics I. Exercises on Predicates and Quantifiers. Due: Tuesday, October 13th (at the beginning of the class)

Mathacle. PSet ---- Algebra, Logic. Level Number Name: Date: I. BASICS OF PROPOSITIONAL LOGIC

Logic. Propositional Logic: Syntax. Wffs

First order Logic ( Predicate Logic) and Methods of Proof

Intro to Logic and Proofs

Packet #2: Set Theory & Predicate Calculus. Applied Discrete Mathematics

1.1 Language and Logic

Logic Overview, I. and T T T T F F F T F F F F

THE LOGIC OF COMPOUND STATEMENTS


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

Chapter 1 Elementary Logic

1.1 Language and Logic

Full file at

Propositional Logic: Syntax

CSI30. Chapter 1. The Foundations: Logic and Proofs Nested Quantifiers

Logic. Logic is a discipline that studies the principles and methods used in correct reasoning. It includes:

Test 1 Solutions(COT3100) (1) Prove that the following Absorption Law is correct. I.e, prove this is a tautology:

Discrete Mathematics and Probability Theory Spring 2014 Anant Sahai Note 1

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

III. Elementary Logic

Discrete Mathematical Structures. Chapter 1 The Foundation: Logic

Symbolising Quantified Arguments

MAT 243 Test 1 SOLUTIONS, FORM A

Unit I LOGIC AND PROOFS. B. Thilaka Applied Mathematics

Discrete Structures Lecture 5

University of Ottawa CSI 2101 Midterm Test Instructor: Lucia Moura. March 1, :00 pm Duration: 1:15 hs

Introduction to Predicate Logic Part 1. Professor Anita Wasilewska Lecture Notes (1)

Math 3336: Discrete Mathematics Practice Problems for Exam I

1 Predicates and Quantifiers

Transcription:

Discrete Structures for Computer Science William Garrison bill@cs.pitt.edu 6311 Sennott Square Lecture #4: Predicates and Quantifiers Based on materials developed by Dr. Adam Lee

Topics n Predicates n Quantifiers n Logical equivalences in predicate logic n Translations using quantifiers

Propositional logic is simple, therefore limited Propositional logic cannot represent some classes of natural language statements Given: Kody is one of my dogs Given: All of my dogs like peanut butter Propositional logic gives us no way to draw the (obvious) conclusion that Kody likes peanut butter!

Propositional logic also limits the mathematical truths that we can express and reason about Consider the following: l p 1 º 2 has no divisors other than 1 and itself l p 2 º 3 has no divisors other than 1 and itself l p 3 º 5 has no divisors other than 1 and itself l p 4 º 7 has no divisors other than 1 and itself l p 5 º 11 has no divisors other than 1 and itself l This is an inefficient way to reason about the properties of prime numbers! General problem: Propositional logic has no way of reasoning about instances of general statements.

Historical Context The previous examples are called syllogisms Aristotle used syllogisms in his Prior Analytics to deductively infer new facts from existing knowledge Major premise All men are mortal Socrates is a man Socrates is mortal Minor premise Conclusion

Predicate logic allows us to reason about the properties of individual objects and classes of objects Predicate logic allows us to use propositional functions during our logical reasoning P(x) º x 3 > 0 variable predicate Note: A propositional function P(x) has no truth value unless it is evaluated for a given x or set of xs.

Examples Assume P(x) º x 3 > 0. What are the truth values of the following expressions: l P(0) false l P(23) true l P(-42) false We can express the prime number property using predicate logic: l P(x) º x is prime l D(x) º x has no divisors other than 1 and itself l P(x) «D(x)

Predicates can also be defined on more than one variable Let P(x, y) º x + y = 42. What are the truth values of the following expressions: l P(45, -3) true l P(23, 23) false l P(1, 119) false Let S(x, y, z) º x + y = z. What are the truth values of the following expressions: l S(1, 1, 2) true l S(23, 24, 42) false l S(-9, 18, 9) true

Predicates play a central role in program control flow and debugging If/then statements: l if x > 17 then y = 13 Loops: l while y <= 14 do end while This is a predicate! Debugging in C/C++: l assert(strlen(passwd) > 0);

Quantifiers allow us to make general statements that turn propositional functions into propositions In English, we use quantifiers on a regular basis: l All students can ride the bus for free l Many people like chocolate l I enjoy some types of tea l At least one person will sleep through their final exam Quantifiers require us to define a universe of discourse (also called a domain) in order for the quantification to make sense l Many like chocolate doesn t make sense! What are the universes of discourse for the above statements?

Universal quantification allows us to make statements about the entire universe of discourse Examples: l All of my dogs like peanut butter l Every even integer is a multiple of two l For each positive integer x, 2x > x Given a propositional function P(x), we express the universal quantification of P(x) as "x P(x) What is the truth value of "x P(x)? l true if P(x) is true for every x in the universe of discourse l false if P(x) is false for even one x in the universe of discourse

Examples All rational numbers are greater than 42 l Domain: rational numbers l Propositional function: Let G(x) º x is greater than 42 l Statement: "x G(x) l Truth value: false (counterexample: ½) If a natural number is prime, it has no divisors other than 1 and itself l Domain: natural numbers l Propositional functions: Let P(x) º x is prime Let D(x) º x has no divisors other than 1 and itself l Statement: "x [P(x) D(x)] l Truth value: true (by definition)

Existential quantifiers allow us to make statements about some objects Examples: l Some elephants are scared of mice l There exist integers a, b, and c such that the equality a 2 + b 2 = c 2 is true l There is at least one person who did better than John on the midterm Given a propositional function P(x), we express the existential quantification of P(x) as $x P(x) What is the truth value of $x P(x)? l true if P(x) is true for at least one x in the universe of discourse l false if P(x) is false for each x in the universe of discourse

Examples The inequality x + 1 < x holds for at least one integer l Domain: Integers l Propositional function: P(x) º x + 1 < x l Statement: $x P(x) l Truth value: false For some integers, the equality a 2 + b 2 = c 2 is true l Domain: Integers l Propositional function: P(a, b, c) º a 2 + b 2 = c 2 l Statement: $a,b,c P(a,b,c) l Truth value: true

We can restrict the domain of quantification The square of every natural number less than 4 is no more than 9 l Domain: natural numbers This is equivalent to writing "x [(x < 4) (x 2 9)] l Statement: "x<4 (x 2 9) l Truth value: true Some integers between 0 and 6 are prime l Domain: Integers l Propositional function: P(x) º x is prime l Statement: $0 x 6 P(x) l Truth value: true This is equivalent to writing $x [(0 x 6) Ù P(x)]

Precedence of quantifiers The universal and existential quantifiers have the highest precedence of all logical operators For example: l "x P(x) Ù Q(x) actually means ("x P(x)) Ù Q(x) l $x P(x) Q(x) actually means ($x P(x)) Q(x) For the most part, we will use parentheses to disambiguate these types of statements But you are still responsible for understanding precedence!

In-class exercises Problem 1: Assume M(x) º x is a Monday and D(x,y) º 2x = y. What are the truth values of the following statements? l M( September 5, 2017 ) l D(2, 5) Problem 2: Let P(x) º x is prime where the domain of x is the integers. Let T(x,y) º x = 3y where the domain of x and y is all natural numbers. What are the truth values of the following statements? l "x P(x) l $x,y T(x,y)

We can extend the notion of logical equivalence to expressions containing predicates or quantifiers Definition: Two statements involving predicates and quantifiers are logically equivalent iff they take on the same truth value regardless of which predicates are substituted into these statements and which domains of discourse are used.

Prove: $x [P(x) Ú Q(x)] º $x P(x) Ú $x Q(x) We must prove each direction of the equivalence. Assume that P and Q have the same domain. First, prove $x [P(x) Ú Q(x)] $x P(x) Ú $x Q(x): l If $x [P(x) Ú Q(x)] is true, this means that there is some value v in the domain such that either P(v) is true or Q(v) is true l If P(v) is true, then $x P(x) is true and [$x P(x) Ú $x Q(x)] is true l If Q(v) is true, then $x Q(x) is true and [$x P(x) Ú $x Q(x)] is true l Thus $x [P(x) Ú Q(x)] $x P(x) Ú $x Q(x)

Prove: $x [P(x) Ú Q(x)] º $x P(x) Ú $x Q(x) Then, prove $x P(x) Ú $x Q(x) $x [P(x) Ú Q(x)]: l If $x P(x) Ú $x Q(x) is true, this means that there is some value v in the domain such that either P(v) is true or Q(v) is true l If P(v) is true, then $x [P(x) Ú Q(x)] is true l If Q(v) is true, then $x [P(x) Ú Q(x)] is true l Thus $x P(x) Ú $x Q(x) $x [P(x) Ú Q(x)] Since $x [P(x) Ú Q(x)] $x P(x) Ú $x Q(x) and $x P(x) Ú $x Q(x) $x [P(x) Ú Q(x)] then $x [P(x) Ú Q(x)] º $x P(x) Ú $x Q(x).

We also have DeMorgan s laws for quantifiers Negation over universal quantifier: "x P(x) º $x P(x) Intuition: If P(x) is not true for all x, then there is at least one x for which P(x) is false Negation over existential quantifier: $x P(x) º "x P(x) Intuition: If P(x) is not true for at least one value x, then P(x) is false for all x These are very useful logical equivalences, so let s prove one of them

Prove: "x P(x) º $x P(x) n "x P(x) $x P(x) l "x P(x) is true if and only if "x P(x) is false l "x P(x) is false if and only if there is some v such that P(v) is true l If P(v) is true, then $x P(x) n $x P(x) "x P(x) l $x P(x) is true if and only if there is some v such that P(v) is true l If P(v) is true, then clearly P(x) does not hold for all possible values in the domain and thus we have "x P(x) Therefore "x P(x) º $x P(x).

Translations from English To translate English sentences into logical expressions: 1. Rewrite the sentence to make it easier to translate 2. Determine the appropriate quantifiers to use 3. Look for words that indicate logical operators 4. Formalize sentence fragments 5. Put it all together

Example: At least one person in this classroom is named Bill and has lived in Pittsburgh for 8 years Rewrite: There exists at least one person who is in this classroom, is named Bill, and has lived in Pittsburgh for 8 years Formalize: l C(x) º x is in this classroom l N(x) º x is named Bill l P(x) º x has lived in Pittsburgh for 8 years Final expression: $x [C(x) Ù N(x) Ù P(x)] Existential quantifier Conjunction

Example: If a student is taking CS441, then they have taken high school algebra Universal quantifier Rewrite: For all students, if a student is in CS 441, then they have taken high school algebra Formalize: Implication l C(x) º x is taking CS441 l H(x) º x has taken high school algebra Final expression: "x [C(x) H(x)]

Negate the previous example "x [C(x) H(x)] º $x [C(x) H(x)] º $x [ C(x) Ú H(x)] a b º a Ú b Double negation law º $x [ C(x) Ù H(x)] º $x [C(x) Ù H(x)] DeMorgan s law for negation over the universal quantifier DeMorgan s law for negation over disjunction Translate back into English: l There is a student taking CS441 that has not taken high school algebra!

Example: Jane enjoys drinking some types of tea Rewrite: There exist some types of tea that Jane enjoys drinking Formalize: l T(x) º x is a type of tea l D(x) º Jane enjoys drinking x Final expression: $x [T(x) Ù D(x)] Negate the previous example: $x [T(x) Ù D(x)] º "x [T(x) Ù D(x)] º "x [ T(x) Ú D(x)] º "x [T(x) D(x)] For all types of drink, if x is a tea, Jane does not enjoy drinking it.

In-class exercises Problem 3: Translate the following sentences into logical expressions. a) Some cows have black spots b) At least one student likes to watch football or ice hockey c) Any adult citizen of the US can register to vote if he or she is not a convicted felon Problem 4: Negate the translated expressions from problem 3. Translate these back into English.

Final Thoughts n The simplicity of propositional logic makes it unsuitable for solving certain types of problems n Predicate logic makes use of l Propositional functions to describe properties of objects l The universal quantifier to assert properties of all objects within a given domain l The existential quantifier to assert properties of some objects within a given domain n Predicate logic can be used to reason about relationships between objects and classes of objects n Next lecture: l Applications of predicate logic and nested quantifiers l Please read section 1.5