0% found this document useful (0 votes)
23 views

05 Predicatequantifier

This document discusses predicates, quantifiers, and their use in logic. 1. Predicates allow expressions to be evaluated as true or false based on variable values. Quantifiers are used to make statements about all or some of the values in a domain for a given predicate. 2. The universal quantifier asserts a property is true for all values, while the existential quantifier asserts a property is true for at least one value. 3. Examples demonstrate evaluating predicates with variables, finding counterexamples to disprove universal statements, and determining the truth of quantified statements in different domains.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

05 Predicatequantifier

This document discusses predicates, quantifiers, and their use in logic. 1. Predicates allow expressions to be evaluated as true or false based on variable values. Quantifiers are used to make statements about all or some of the values in a domain for a given predicate. 2. The universal quantifier asserts a property is true for all values, while the existential quantifier asserts a property is true for at least one value. 3. Examples demonstrate evaluating predicates with variables, finding counterexamples to disprove universal statements, and determining the truth of quantified statements in different domains.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 71

Predicates and Quantifiers

Review
□ Proposition:
1. It is a sentence that declares a fact.
2. It is either true or false, but not both.
Examples:
□ 2 + 1 = 3.
True Proposition
□ Toronto is the capital of Canada.
False Proposition
□ x + 1 = 2.
Neither true nor false

1
Review
□ Logical Operators
■ Negation
¬p “not p.”
■ Conjunction
p q “p and q.”
■ Disjunction
pq “p or q.”
■ Exclusive or
pq “p or q, but not both.”
■ Conditional
statement “If p, then q.”
p
q “p if and only if q.”
■ Biconditional
statement 2
pq
Predicate Logic
□ More powerful
□ Express a wide range of statements in
mathematics and computer science

3
Predicates

x>3
Variable:
subject of the
statement
P
r
e
d
i
c 4
a
t
Predicates

x>3

value of propositional function P at x


P(x)
d
e
n
o
t
e 5
s
Predicates (example)
P(x) : x>3.
What are the truth value of P(4) and P(2)?

Solution:
□ Set variable x
■ x=4
P(4): 4>3
True
■ x=2
P(2): 2>3
False
6
Predicates (example)
Q(x,y) : x = y+3.
What are the truth value of Q(1,2) and Q(3,0)?

Solution:
□ Set variables x and y
■ x=1, y=2
Q(1,2): 1=2+3
False
■ x=3, y=0
Q(3,0): 3=0+3
True
7
Predicates (example)
A(c,n) : Computer c is connected to network n.
Assume computer “CS1” is connected to network “AirYork”, but not to
network “Indigo”.
What are the truth value of A(CS1,AirYork) and A(CS1,Indigo)?

Solution:
□ Set variables c and n
■ A(CS1,AirYork):
Computer CS1 is connected to network AirYork.
True
■ A(CS1,Indigo):
Computer CS1 is connected to network Indigo.
False

8
Verification of computer programs
Interchange the values of two variables x and y.
1. Temp := x
2. x := y
3. y := temp

□ Precondition: conditions that input should satisfy


■ P(x,y): x=a, y=b

□ Postcondition: conditions that output should satisfy


■ Q(x,y): x=b, y=a

9
Verification of computer programs
Interchange the values of two variables x and y.
1. Temp := x
2. x := y
3. y := temp
□ How to verify the program?
■ Assume precondition P(x,y) holds
P(x,y): x=a, y=b True
■ Check the values of variables after each step of the program
1. Temp := x
x=a, y=b, temp=a
2. x := y
x=b, y=b, temp=a
3. y := temp
x=b, y=a, temp=a
■ At the end, check the postcondition Q(x,y)
Q(x,y): x=b, y=a True
10
Review
□ Propositional function
P(x1, x2, …, xn)

□ Assign a values to variables and form


proposition with certain truth value
Q(x,y) : x = y+3
Q(3,0) : 3 = 0+3

11
Quantifiers
□ Create a proposition from a propositional
function using Quantifiers

□ Quantifiers express the range of elements


the statement is about.
■ The universal quantifier
■ The existential quantifier

12
The universal quantifier

□ The universal quantifier is used to assert a


property of all values of a variable in a
particular domain.

13
The universal quantifier
□ The universal quantification of P(x) is
“P(x) for all values of x in the domain.”,
denoted by x P(x)
The universal quantifier
□ The universal quantifier
■ For all …
■ For every …
■ For each …
■ All of …
■ For arbitrary …

14
The universal quantifier (example)
P(x): x+1 > x
The universal quantifier of P(x) is in the domain
of real numbers:

x P(x) (x is a real number)


x ( x+1 > x ) (x is a real number)

15
The universal quantifier
□  x P(x)

■ When true?
□ P(x) is true for every x in the domain

■ When false?
□ P(x) is not always true when x is in the
domain
(find a value of x that P(x) is false)

16
The universal quantifier

□ An element for which P(x) is false is called


a counterexample of x P(x).

P(x): x>3
P(2): 2>3 is a counterexample of x P(x)

17
The universal quantifier (example)
P(x): x+1 > x.
What is the truth value of x P(x) in the
domain of real numbers?

Solution:
□ Check if P(x) is true for all real numbers
■ “x+1 > x” is true for all real number
So, the truth value of x P(x) is true.

18
The universal quantifier (example)
Q(x): x < 2.
What is the truth value of x Q(x) in the
domain of real numbers?

Solution:
□ Find a counterexample for x Q(x)
■ Q(3): 3<2 is false
x=3 is a counterexample for x Q(x), so x Q(x) is
false.
19
The universal quantifier (example)
P(x): x2 > 0.
What is the truth value of x P(x) in the
domain of integers?

Solution:
□ Find a counterexample for x P(x)
■ P(0): 0>0 is false
x=0 is a counterexample for x P(x), so x P(x) is
false.
20
The universal quantifier (example)
A(x): Computer x is connected to the network.
What is x A(x) in the domain of all computers
on campus?

Solution:
□ x A(x) :
“For every computer x on campus, computer x is
connected to the network.”
“Every computer on campus is connected to the
network.”

21
The universal quantifier (example)
P(x): x2 � x.
What is the truth value of x P(x) in the domain of
all real numbers?

Solution:
□ Find a counterexample for x P(x)
■ P(1/2): 1/4 � 1/2 is false
x=1/2 is a counterexample for x P(x), so x P(x)
is false.

22
The universal quantifier (example)
P(x): x2 � x.
What is the truth value of x P(x) in the domain of
all real numbers?
Solution: How to find a counterexample?
x2 � x.
(x2 - x) = x(x - 1) � 0.
x and (x-1) must both be x and (x-1) must both be
zero or positive. OR zero or negative.
x � 0 and (x - 1) � 0 x  0 and (x - 1)  0
x � 0 and x � 1 x  0 and x  1
x�1 x0
0 < x < 1 such as x=1/2 is a counterexample
23
The universal quantifier (example)
P(x): x2 � x.
What is the truth value of x P(x) in the
domain of all integers?

Solution:
□ Check if P(x) is true for all integers
■ P(x) is true when x � 1 or x  0.
■ There is no integer between 0 < x < 1.
■ So, x P(x) is true for the domain of all integers.
24
The universal quantifier
□ x P(x) in the domain D
□ If D can be listed as x1, x2, …, xn.

x P(x) in the domain D is the same as


P(x1)  P(x2)  …  P(xn)

25
The universal quantifier (example)
P(x): x2 < 10.
What is the truth value of x P(x) in the domain
of positive integers not exceeding 4?

Solution:
□ List the domain
■ Domain is 1, 2, 3, 4.
□ Find the equivalent conjunction and its truth
value
■ P(1)  P(2)  P(3)  P(4)
■ T  T  T  F which is false
□ So, P(4) is a counterexample and x P(x) is 26

false.
The existential quantifier

□ The existential quantifier is used to assert a


property of at least one value of a
variable in a domain.

27
The existential quantifier
□ The existential quantification of P(x) is
“There exists an element x in the domain such
that P(x).”,
denoted by x P(x)
The existential quantifier

□ The existential quantifier


■ There exists …
■ There is …
■ For some …
■ For at least one …
28
The existential quantifier (example)
P(x): x > 3
The existential quantifier of P(x) is in the
domain of integers:

x P(x) (x is an integer)
x ( x > 3 ) (x is an
integer)

29
The existential quantifier
□ x P(x)

■ When true?
□ There is an x for which P(x) is true.
(find a value of x that
P(x) is true.)

■ When false?
□ P(x) is false for every x.
30
The existential quantifier (example)
P(x): x > 3.
What is the truth value of x P(x) in
the domain of real numbers?

Solution:
□ Check if P(x) is true for some real
numbers
■ “x > 3” is true when x = 4.
So, the truth value of x P(x) is true.
31
The existential quantifier (example)
Q(x): x = x+1.
What is the truth value of x Q(x) in
the domain of real numbers?

Solution:
□ Check if Q(x) is false for all real
numbers
■ “x = x+1” is false for all real numbers.
So, the truth value of x Q(x) is false.
32
The existential quantifier
□ x P(x) in the domain D
□ If D can be listed as x1, x2, …, xn.

x P(x) in the domain D is the same as


P(x1)  P(x2)  …  P(xn)

33
The existential quantifier (example)
P(x): x2 > 10.
What is the truth value of x P(x) in the domain of
positive integers not exceeding 4?

Solution:
□ List the domain
■ Domain is 1, 2, 3, 4.
□ Find the equivalent disjunction and its truth
value
■ P(1)  P(2)  P(3)  P(4)
■ F  F  F  T which is true.
□ So, x P(x) is true. 34
Quantifiers (review)

Statement When True? When False?


x P(x) P(x) is true for There is an x for
every x. which P(x) is false.
x P(x) There is an x for P(x) is false for
which P(x) is true. every x.

35
Translating from English into logical
expression (example)
Express the following statement using predicates
and quantifiers?
“Every student in this class has studied
calculus.”
Solution:
□ Determine individual propositional
function
■ P(x): x has studied calculus.
□ Translate the sentence into logical
expression
■ x P(x) domain: students 36

in class
Translating from English into logical
expression (example)
Express the following statement using predicates
and quantifiers?
“Some student in this class has visited Mexico.”
Solution:
□ Determine individual propositional function
■ P(x): x has visited Mexico.
□ Translate the sentence into logical
expression
■ x P(x) domain: students in class

37
Translating from English into logical
expression (example)
Express the following statement using predicates and
quantifiers?
“Every student in this class has visited either the US or
Mexico.”
Solution:
□ Determine individual propositional functions
■ P(x): x has visited the US.
■ Q(x): x has visited Mexico.
□ Translate the sentence into logical expression
■ x ( P(x)  Q(x)) domain: students in
class
38
Quantifiers with restricted domain

□ Sometimes a variable in the domain must


satisfy a condition.

39
Quantifiers with restricted domain
(example)
 x < 0 (x2 > 0).
What does this statement mean in the domain of real numbers?
(express it in English and logic using conditional statement)

Solution:
□ Express the statement in English
■ For every real number x with x < 0, x2 > 0.
■ The square of a negative real number is positive.
□ Find the equivalent if statement (find condition and
property)
■ Condition: x < 0 property: x2 > 0
■ x ( x< 0  x2 > 0 )
40
Quantifiers with restricted domain
(example)
y f: 0 (y3 f: 0).
What does this statement mean in the domain of real numbers?
(express it in English and logic using conditional statement)

Solution:
□ Express the statement in English
■ For every real number y with y f: 0, y3 f: 0.
■ The cube of every nonzero real number is nonzero.
□ Find the equivalent if statement (find condition and
property)
■ Condition: y f: 0 property: y3 f: 0
■ y ( y f: 0  y3 f: 0 )
41
Quantifiers with restricted domain
(example)
z > 0 (z2 = 2).
What does this statement mean in the domain of real numbers?
(express it in English and logic using conjunction)

Solution:
□ Express the statement in English
■ There exists a real number z with z > 0, z2 = 2.
■ There is a positive square root of 2.
□ Find the equivalent conjunction (find conditions)
■ Conditions: z>0 z2 = 0
■ z ( z > 0  z2 = 0 )

42
Example of system specifications
Express the following system specifications.
“Every mail message larger than one megabyte will be
compressed.”
“If a user is active, at least one network link will be available.”
Solution:
□ Determine individual predicates
■ Mail message is larger than one megabyte.
■ Mail message will be compressed.
■ User is active.
■ Network link will be available.

43
Example of system specifications
“Every mail message larger than one megabyte will be compressed.”
“If a user is active, at least one network link will be available.”
Solution:
□ Introduce variables for each sentence
■ Mail message is larger than one megabyte.
□ P(m,x): Mail message m is larger than x
megabytes.
domain of m: all mail messages
domain of x: positive real numbers
■ Mail message will be compressed.
□ Q(m): Mail message m will be compressed.
domain of m: all mail messages
44
Example of system specifications
“Every mail message larger than one megabyte will be compressed.”
“If a user is active, at least one network link will be available.”
Solution:
□ Introduce variables for each sentence
■ User is active.
□ R(u): User u is active.
domain of u: all users
■ Network link will be available.
□ S(n): Network link n is available.
domain of n: all network links

45
Example of system specifications
“Every mail message larger than one megabyte will be compressed.”
“If a user is active, at least one network link will be available.”
Solution:
□ Translate each specification into logical expression
■ “Every mail message larger than one megabyte will be
compressed.”
□ P(m,x): Mail message m is larger than x
megabytes.
□ Q(m): Mail message m will be compressed.

 m (P(m,1)  Q(m))

46
Example of system specifications
“Every mail message larger than one megabyte will be compressed.”
“If a user is active, at least one network link will be available.”
Solution:
□ Translate each specification into logical expression
■ “If a user is active, at least one network link will be
available.”
□ R(u): User u is active.
□ S(n): Network link n is available.

u R(u)  n S(n)

47
Example
Express the following sentences using predicates and quantifiers.
“All lions are fierce.”
“Some lions do not drink coffee.”
Assume
P(x): x is a lion. Q(x): x
is fierce. R(x): x
drinks coffee.
Solution:
□ Translate each sentence
into logical expression
■ “All lions are fierce.”
□  x (P(x) 
Q(x))
48
Example
Express the following sentences using predicates and quantifiers.
“All lions are fierce.”
“Some lions do not drink coffee.”
Assume
P(x): x is a lion. Q(x): x
is fierce. R(x): x
drinks coffee.
Solution:
□ Translate each sentence
into logical expression
■ “Some lions do not
drink coffee.”
□ x (P(x) 
R(x)) 49
Precedence of quantifiers
The quantifiers  and  has higher precedence than
all logical operators.
Example: x p(x)  Q(x)
(x p(x)) 
Q(x)Operators Precedence
  0
 1
 2
 3
 4
 5
50
Binding variables
□ Variable
■ Bound
□ Qua
ntifi
ers
■ Free
□ Not
bou
nd

□ Turn a propositional function into a


proposition 51

■ All variables must be bound.


Binding variables (example)
x (x+y=1).
Is it a proposition?

Solution:
□ Check if any variable is free
■ Variable x
□ bound
■ Variable y
□ Free
■ Since
variable y
is free, it
is not a 52

propositio
n.
Logical equivalences
□ Assume S and T are two statements
involving predicates and quantifiers.

□ S and T are logically equivalent if and


only if they have the same truth value no
matter which predicates are substituted
and which domain is used for the variables,
denoted by S  T.

53
Logical equivalences (example)
Show that x (P(x)  Q(x)) and x P(x)  x Q(x) are
logically equivalent.
Solution:
Part1: Show if x (P(x)  Q(x)) is true then x
P(x) 
x Q(x) is true. (using direct technique)
■ Assume x (P(x)  Q(x)) is true.
■ If a is in the domain, then P(a)  Q(a) is true.
■ So, P(a) is true and Q(a) is true.
■ Since P(a) and Q(a) are both true for every element in
the domain, x P(x) and x Q(x) are both true.
■ So, x P(x)  x Q(x) is true.
54
Logical equivalences (example)
Show that x (P(x)  Q(x)) and x P(x)  x Q(x)
are logically equivalent.
Solution:
Part2: Show if x P(x)  x Q(x) is true then x
(P(x)
 Q(x)) is true. (using direct technique)
■ Assume x P(x)  x Q(x) is true.
■ So, x P(x) is true and x Q(x) is true.
■ If a is in the domain, then P(a) is true and Q(a) is
true.
■ If P(a) is true and Q(a) is true, then P(a)  Q(a) is
true.
■ Since P(a)  Q(a) is true for every element in the 55

domain,
x (P(x)  Q(x)) is true.
Logical equivalences (example)
Show that x (P(x)  Q(x)) and x P(x)  x Q(x) are
not logically equivalent.
Solution:
□ Give an example that x (P(x)  Q(x)) and x P(x)  x
Q(x) have different truth values.
■ P(x): x is odd. Q(x): x is even. (in the domain of
integers.)
■ For all element (P(x)  Q(x)) is true. (all x is odd or even.)
■ So, x (P(x)  Q(x)) is true.
■ For all element P(x) is false. (all x is not odd.)
■ For all element Q(x) is false. (all x is not even.)
■ So, x P(x)  x Q(x) is false.
□ Thus, x (P(x)  Q(x)) and x P(x)  x Q(x) are
not logically equivalent. 56
Negation (review)

Let p be a proposition.
The negation of p, denoted by ¬p, is the
proposition “It is not the case that p.”

57
Negating quantified expression

Statement When False?


x P(x) There is an x for
which P(x) is false.
x P(x) P(x) is false for
every x.

¬ x P(x) x P(x)


¬ x P(x) x P(x)

58
Negating quantified expression
□ Assume x P(x) is:
“Every student has taken a course in calculus.”
□ ¬ (x P(x)) is:
“It is not the case that every student has taken
a course in calculus.”
“There is a student who has not taken a course
in calculus.”
x P(x)
¬ (x P(x))  x P(x)

59
Negating quantified expression
Show that ¬ (x P(x)) and x P(x) are logically equivalent.
Solution:
Show ¬ x P(x) is true if and only if x P(x) is true.
(using direct technique)
■ ¬ x P(x) is true if and only if x P(x) is false.
■ x P(x) is false if and only if there is an element in the
domain for which P(x) is false.
■ There is an element for which P(x) is false if and only if
there is an element for which ¬P(x) is true.
■ There is an element for which ¬P(x) is true if and only
if x
P(x) is true.
□ Thus, ¬ (x P(x)) and x P(x) are logically
60
equivalent.
Negating quantified expression
□ Assume x P(x) is:
“There is a student who has taken a course
in calculus.”
□ ¬ (x P(x)) is:
“It is not the case that there is a student who has
taken a course in calculus.”
“Every student has not taken a course in
calculus.”
 x P(x)
¬ (x P(x))   x P(x)

61
Negating quantified expression
Show that ¬ (x P(x)) and x P(x) are logically equivalent.
Solution:
Show ¬ x P(x) is true if and only if x P(x) is true.
(using direct technique)
■ ¬ x P(x) is true if and only if x P(x) is false.
■ x P(x) is false if and only if there is no element in the
domain for which P(x) is true.
■ There is no element for which P(x) is true if and only if for
all elements ¬P(x) is true.
■ For all elements ¬P(x) is true if and only if x
P(x) is true.
□ Thus, ¬ (x P(x)) and x P(x) are logically
equivalent. 62
De Morgan’s laws for quantifiers

Negation Equivalent st. When true? When false?


¬ x P(x) x P(x) There is an x that For all x P(x) is
P(x) is false. true.
¬ x P(x) x P(x) For all x P(x) is There is an x that
false. P(x) is true.

63
De Morgan’s laws for quantifiers
□ x P(x) in the domain D
□ If D can be listed as x1, x2, …, xn.

□ x P(x) 
P(x1)  P(x2)  …  P(xn)

□ ¬ x P(x) 
¬(P(x1)  P(x2)  …  P(xn)) 
¬P(x1)  ¬P(x2)  …  ¬P(xn))

64
De Morgan’s laws for quantifiers
□ x P(x) in the domain D
□ If D can be listed as x1, x2, …, xn.

□ x P(x) 
P(x1)  P(x2)  …  P(xn)

□ ¬ x P(x) 
¬(P(x1)  P(x2)  …  P(xn)) 
¬P(x1)  ¬P(x2)  …  ¬P(xn))

65
Negating quantified expression
(example)
What is the negation of the statement “All Canadians eat
sushi”?
Solution:
□ Determine individual propositional function
■ P(x): x eats sushi.
□ Then translate the sentence into logical expression
■ x P(x)domain: Canadians
□ Find the negation of x P(x)
■ x ¬P(x) domain: Canadians
□ Translate x ¬P(x) into English sentence
■ Some Canadian does not eat sushi.

66
Negating quantified expression
(example)
What is the negation of the statement “There is an honest
politician”?
Solution:
□ Determine individual propositional function
■ P(x): x is an honest politician.
□ Then translate the sentence into logical expression
■ x P(x) domain: politicians
□ Find the negation of x P(x)
■ x ¬P(x) domain: politicians
□ Translate x ¬P(x) into English sentence
■ Every politician is dishonest.

67
Negating quantified expression
(example)
What is the negation of x (x2 > x)?

Solution:
¬( x (x2 > x) ) 
x ¬(x2 > x) 
x (x2  x)

68
Negating quantified expression
(example)
What is the negation of x (x2 = 2)?

Solution:
¬(x (x2 = 2) ) 
x ¬(x2 = 2) 
x (x2 -/ 2)

69
Recommended exercises
5,10,13,19,21,23,25,33,35,39,61

70

You might also like