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

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

2/18/14. What is logic? Proposi0onal Logic. Logic? Propositional Logic, Truth Tables, and Predicate Logic (Rosen, Sections 1.1, 1.2, 1.

Propositional Logic Not Enough

ICS141: Discrete Mathematics for Computer Science I

Section Summary. Section 1.5 9/9/2014

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

Logical Operators. Conjunction Disjunction Negation Exclusive Or Implication Biconditional

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

1.3 Predicates and Quantifiers

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

Proposi'onal Logic Not Enough

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

Predicates and Quantifiers. CS 231 Dianna Xu

Discrete Mathematics and Its Applications

Introduction to Sets and Logic (MATH 1190)

Math.3336: Discrete Mathematics. Nested Quantifiers

Announcement. Homework 1

Discrete Structures for Computer Science

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

Solutions to Exercises (Sections )

Predicates and Quantifiers. Nested Quantifiers Discrete Mathematic. Chapter 1: Logic and Proof

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

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

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

Lecture Predicates and Quantifiers 1.5 Nested Quantifiers

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

4 Quantifiers and Quantified Arguments 4.1 Quantifiers

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

Quantifiers Here is a (true) statement about real numbers: Every real number is either rational or irrational.

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

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

Predicate Calculus lecture 1

Thinking of Nested Quantification

Discrete Structures Lecture Predicates and Quantifiers

Discrete Structures Lecture 5

Mat 243 Exam 1 Review

Nested Quantifiers. Predicates and. Quantifiers. Agenda. Limitation of Propositional Logic. Try to represent them using propositional.

Predicates, Quantifiers and Nested Quantifiers

Section 2.1: Introduction to the Logic of Quantified Statements

Department of Mathematics and Statistics Math B: Discrete Mathematics and Its Applications Test 1: October 19, 2006

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

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

Chapter 1, Part II: Predicate Logic

Logic and Modelling. Introduction to Predicate Logic. Jörg Endrullis. VU University Amsterdam

Announcements CompSci 102 Discrete Math for Computer Science

Predicate Logic: Introduction and Translations

Propositional Functions. Quantifiers. Assignment of values. Existential Quantification of P(x) Universal Quantification of P(x)

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

Predicate Logic & Quantification

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


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

Chapter 3. The Logic of Quantified Statements

Formal Logic: Quantifiers, Predicates, and Validity. CS 130 Discrete Structures

2-4: The Use of Quantifiers

Rosen, Discrete Mathematics and Its Applications, 6th edition Extra Examples

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

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

1. Consider the conditional E = p q r. Use de Morgan s laws to write simplified versions of the following : The negation of E : 5 points

Logic and Proof. Aiichiro Nakano

Why Learning Logic? Logic. Propositional Logic. Compound Propositions

CSE 20 Discrete Math. Algebraic Rules for Propositional Formulas. Summer, July 11 (Day 2) Number Systems/Computer Arithmetic Predicate Logic

THE LOGIC OF QUANTIFIED STATEMENTS

Discrete Mathematics & Mathematical Reasoning Predicates, Quantifiers and Proof Techniques

Predicate Calculus. Lila Kari. University of Waterloo. Predicate Calculus CS245, Logic and Computation 1 / 59

MATH 215 DISCRETE MATHEMATICS INSTRUCTOR: P. WENG

Lecture 4. Predicate logic

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

Exercise Set 1 Solutions Math 2020 Due: January 30, Find the truth tables of each of the following compound statements.

MAT2345 Discrete Math

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

Chapter 2: The Logic of Quantified Statements

EECS 1028 M: Discrete Mathematics for Engineers

Section 2.3: Statements Containing Multiple Quantifiers

MATH 215 Discrete Mathematics Worksheets. Which of these are propositions? What are the truth values of those that are propositions?

Department of Computer Science & Software Engineering Comp232 Mathematics for Computer Science

First order Logic ( Predicate Logic) and Methods of Proof

Predicate Calculus - Syntax

Before you get started, make sure you ve read Chapter 1, which sets the tone for the work we will begin doing here.

1 Predicates and Quantifiers

Predicate in English. Predicates and Quantifiers. Predicate in Logic. Propositional Functions: Prelude. Propositional Function

CSE 311: Foundations of Computing. Lecture 6: More Predicate Logic

Introduction. Predicates and Quantifiers. Discrete Mathematics Andrei Bulatov

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

Section 1.3. Let I be a set. When I is used in the following context,

Logic and Propositional Calculus

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

Announcements. CS311H: Discrete Mathematics. Introduction to First-Order Logic. A Motivating Example. Why First-Order Logic?

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

LING 501, Fall 2004: Quantification

Basic Logic and Proof Techniques

Transparencies to accompany Rosen, Discrete Mathematics and Its Applications Section 1.3. Section 1.3 Predicates and Quantifiers

CSCE 222 Discrete Structures for Computing. Predicate Logic. Dr. Hyunyoung Lee. !!!!! Based on slides by Andreas Klappenecker

DISCRETE MATHEMATICS BA202

Quantifiers. Alice E. Fischer. CSCI 1166 Discrete Mathematics for Computing February, 2018

Today. Proof using contrapositive. Compound Propositions. Manipulating Propositions. Tautology

Intro to Logic and Proofs

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

ECOM Discrete Mathematics

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

Transcription:

CS 220: Discrete Structures and their Applications Predicate Logic Section 1.6-1.10 in zybooks

From propositional to predicate logic Let s consider the statement x is an odd number Its truth value depends on the the value of the variable x. Once we assign x a value, it becomes a proposition. Predicate logic will allow us to reason about statements with variables without having to assign values to them.

Predicates Predicate: A logical statement whose truth value is a function of one or more variables. Examples: x is an odd number Computer x is under attack The distance between cities x and y is less than z When the variables are assigned a value, the predicate becomes a proposition and can be assigned a truth value.

Predicates The truth value of a predicate can be expressed as a function of the variables, for example: x is an odd number can be expressed as P(x). So, the statement P(5) is the same as "5 is an odd number. The distance between cities x and y is less than z miles Represented by a predicate function D(x, y, z) D(fort-collins, denver, 100) is true.

The domain of a predicate The domain of a variable in a predicate is the set of all possible values for the variable. Examples: The domain of the predicate "x is an odd number" is the set of all integers. In general, the domain of a predicate should be defined with the predicate. Compare domain to type. Compare predicate to a java method declaration. What about the predicate: The distance between cities x and y is less than z miles?

Predicates Consider the predicate S(x, y, z) which is the statement that x + y = z What is the domain of the variables in the predicate? What is the truth value of: ² S(1, -1, 0) ² S(1, 2, 5)

Predicates Let R(x, y) denote: x beats y in rock-paper-scissors with the standard rules. What are the truth values of: R(Rock, Paper) R(Scissors, Paper) image from http://en.wikipedia.org/wiki/rock-paper-scissors

Uses of predicate logic Verifying program correctness Consider the following snippet of code: if (x < 0) x = -x; What is true before? (called precondition) x has some value What is true after? (called postcondition) greaterthan(x, 0)

Quantifiers Assigning values to variables is one way to provide them with a truth value. Alternative: Say that a predicate is satisfied for every value (universal quantification), or that it holds for some value (existential quantification) Example: Let P(x) be the statement x + 1 > x. This holds regardless of the value of x We express this as: "x P(x)

Universal quantification Universal quantification is the statement P(x) for all values of x in the domain of P Notation: "x P(x) " is called the universal quantifier If the domain of P contains a finite number of elements a 1, a 2,..., a k : x P(x) P(a 1 ) Ù P(a 2 ) Ù,..., Ù P(a k )

Universal quantification Universal quantification is the statement P(x) for all values of x in the domain of P Notation: "x P(x) " is called the universal quantifier An element x for which P(x) is false is called a counterexample. Example: Let P be the predicate x 2 > x with the domain of real numbers. Give a counterexample. What does the existence of a counterexample tell us about the truth value of "x P(x)?

Existential quantification Existential quantification of P(x) is the statement There exists an element x in the domain of P such that P(x) Notation: $x P(x) $ is called the existential quantifier Example: M(x) - x is a mammal and E(x) - x lays eggs (both with the domain of animals ). What is the truth value of $x (M(x) Ù E(x))? True (Platipus)

Existential quantification Existential quantification of P(x) is the statement There exists an element x in the domain of P such that P(x) Notation: $x P(x) $ is called the existential quantifier If the domain of P contains a finite number of elements a 1, a 2,..., a k : $x P(x) P(a 1 ) Ú P(a 2 ) Ú,..., Ú P(a k )

Quantified statements Consider the following predicates: P(x): x is prime O(x): x is odd The proposition x (P(x) Ù O(x)) states that there exists a positive number that is prime and not odd. Is this true? What about x (P(x) O(x))?

Precedence of quantifiers The quantifiers : $ and " have higher precedence than the logical operators from propositional logic. Therefore: "x P(x) Ù Q(x) means: ("x P(x)) Ù Q(x) rather than: "x (P(x) Ù Q(x)) Image from: http://mrthinkyt.tumblr.com/

Binding variables When a quantifier is used on a variable x, we say that this occurrence of x is bound All variables that occur in a predicate must be bound or assigned a value to turn it into a proposition Example: $x D(x, Denver, 60)

Examples In the statement $x (x + y = 1) x is bound In the statement $x P(x) Ú "x R(x) all variables are bound Can also be written as: $x P(x) Ú "y R(y) What about "x P(x) Ù Q(x)? Better to express this as What about "x P(x) Ù Q(y)

English to Logic Every student in CS220 has visited Mexico Every student in CS220 has visited Mexico or Canada

Negating quantified statements Suppose we want to negate the statement: Every student in CS220 has taken Math160 Translation into logic: "x P(x) where P is the predicate x has taken Math160, with the domain of CS220 students. The negation: not every student in CS220 has taken Math160, or there exists a student in CS220 who hasn t taken Math160 i.e.: $x P(x)

Note Alternative way of expressing the statement Every student in CS220 has taken Math160 "x (takes(x, CS220) hastaken(x, math160)) or "x (takescs220(x) hastakenmath160(x))

De Morgan s laws for quantifiers We have illustrated the logical equivalence: x P(x) x P(x) A similar equivalence holds for the existential quantifier: x P(x) x P(x). Example: There does not exist someone who likes to go to the dentist. Same as: everyone does not like to go to the dentist

De Morgan s laws for quantifiers Example: Each quantifier be expressed using the other "x Likes(x,IceCream) $x Likes(x,IceCream) $x Likes(x,Broccoli) "x Likes(x,Broccoli)

English to Logic No one in this class is wearing shorts and a ski parka. Some lions do not drink coffee

Nested quantifiers If a predicate has more than one variable, each variable must be bound by a separate quantifier. The logical expression is a proposition if all the variables are bound.

Nested quantifiers of the same type Example: M(x, y): x sent an email to y, with the domain of people. Consider the statement x y M(x, y) In English: Every person sent an email to everyone. This is a statement on all pairs x,y: For every pair of people, x,y it is true that x sent y a mail.

Nested quantifiers Example: M(x, y): x sent an email to y, with the domain of people. Consider the statement x y M(x, y) In English: Every person sent an email to everyone including themselves. But what if we would like to exclude the self emails? x y ((x y) M(x, y))

Nested quantifiers of the same type Example: M(x, y): x sent an email to y, with the domain of people. Express the following in English: x y M(x, y) Order does not matter: "x "y is the same as "y "x $x $y is the same as $y $x

Alternating nested quantifiers $x "y is not the same as "y $x: $x "y Likes(x, y) There is a person who likes everyone "y $x Likes(x, y) Everyone is liked by at least one person

Nested quantifiers as a two person game Two players: the Universal player, and the Existential player. Each selects values for their variables. Example: x y (x + y = 0) The Universal player selects a value. Given the value chosen, the Existential player chooses its value, making the statement true.

Nested quantifiers as a two person game Two players: the Universal player, and the Existential player. Each selects values for their variables. What happens in this situation: x y (x + y = 0)?

Expressing uniqueness L(x): x was late How do we express the statement that exactly one person was late? What s wrong with x L(x)?

Expressing uniqueness L(x): x was late How do we express the statement that exactly one person was late? What s wrong with x L(x)? Instead: x (L(x) Ù y((x y) L(y) )

Moving quantifiers L(x): x was late How do we express the statement that exactly one person was late? x (L(x) Ù y((x y) L(y)) Equivalent to: x y (L(x) Ù ((x y) L(y))

De Morgan s laws with nested quantifiers x y P(x, y) x y P(x, y) x y P(x, y) x y P(x, y) x y P(x, y) x y P(x, y) x y P(x, y) x y P(x, y) Example: x y Likes(x, y ) : There is a person who likes everyone Its negation: x y Likes(x, y ) : There is no person who likes everyone. x y Likes(x, y ) x y Likes(x, y ) : Every person has someone that they do not like.