Discrete Structures: Predicate Logic 2
Discrete Structures: Predicate Logic 2
Predicate Logic 2
Prof. Mohsin Riaz
1
Negation of Quantifiers
• ¬∀𝑥 𝑃 𝑥 ≡ ∃¬𝑃 𝑥
• ¬∃𝑥 𝑃 𝑥 ≡ ∀¬𝑃 𝑥
• ¬∀𝑥 (𝑃 𝑥 ∧ 𝑄 𝑥 ) ≡ ???
2
Negation of Quantifiers
• ¬∀𝑥 𝑃 𝑥 ≡ ∃¬𝑃 𝑥
• ¬∃𝑥 𝑃 𝑥 ≡ ∀¬𝑃 𝑥
• ¬∀𝑥 (𝑃 𝑥 ∧ 𝑄 𝑥 ) ≡ ???
3
Negation of Quantifiers
• ¬∀𝑥 𝑃 𝑥 ≡ ∃¬𝑃 𝑥
• ¬∃𝑥 𝑃 𝑥 ≡ ∀¬𝑃 𝑥
• ¬∀𝑥 (𝑃 𝑥 ∧ 𝑄 𝑥 ) ≡ ???
4
Exercise
B(x): “x is a baby”
ignorant(x): “x is ignorant”
vain(x): “x is vain”
Universe: The set of all people.
5
Exercise
B(x): “x is a baby”
ignorant(x): “x is ignorant”
vain(x): “x is vain”
Universe: The set of all people.
6
Exercise
B(x): “x is a baby”
ignorant(x): “x is ignorant”
vain(x): “x is vain”
Universe: The set of all people.
7
Exercise
professor(x): “x is a professor”
ignorant(x): “x is ignorant”
vain(x): “x is vain”
Universe: The set of all people.
21
Quantifiers with Restricted Domain
• ∀𝑥 𝑥 2 > 0
– ∀ 𝑥 < 0 𝑥2 > 0
– ≡ ∀𝑥 (𝑥 < 0) → (𝑥 2 > 0)
• ∀𝑦 𝑦 3 ≠ 0
– ∀ 𝑦 ≠ 0 𝑦3 ≠ 0
– ≡ ∀ 𝑦 ≠ 0 → 𝑦3 ≠ 0
• ∃𝑧 (𝑧 2 = 2)
– ∃𝑧 > 0 (𝑧 2 = 2)
– ≡ ∃𝑧(𝑧 > 0 → 𝑧 2 = 2)
22
Quantifiers with Restricted Domain
• ∀𝑥 𝑥 2 > 0
– ∀ 𝑥 < 0 𝑥2 > 0
– ≡ ∀𝑥 (𝑥 < 0) → (𝑥 2 > 0)
• ∀𝑦 𝑦 3 ≠ 0
– ∀ 𝑦 ≠ 0 𝑦3 ≠ 0
– ≡ ∀ 𝑦 ≠ 0 → 𝑦3 ≠ 0
• ∃𝑧 (𝑧 2 = 2)
– ∃𝑧 > 0 (𝑧 2 = 2)
– ≡ ∃𝑧(𝑧 > 0 → 𝑧 2 = 2)
23
Quantifiers with Restricted Domain
• ∀𝑥 𝑥 2 > 0
– ∀ 𝑥 < 0 𝑥2 > 0
– ≡ ∀𝑥 (𝑥 < 0) → (𝑥 2 > 0)
• ∀𝑦 𝑦 3 ≠ 0
– ∀ 𝑦 ≠ 0 𝑦3 ≠ 0
– ≡ ∀ 𝑦 ≠ 0 → 𝑦3 ≠ 0
• ∃𝑧 (𝑧 2 = 2)
– ∃𝑧 > 0 (𝑧 2 = 2)
– ≡ ∃𝑧(𝑧 > 0 → 𝑧 2 = 2)
24
Quantifiers with Restricted Domain
• ∀𝑥 𝑥 2 > 0
– ∀ 𝑥 < 0 𝑥2 > 0
– ≡ ∀𝑥 (𝑥 < 0) → (𝑥 2 > 0)
• ∀𝑦 𝑦 3 ≠ 0
– ∀ 𝑦 ≠ 0 𝑦3 ≠ 0
– ≡ ∀ 𝑦 ≠ 0 → 𝑦3 ≠ 0
• ∃𝑧 (𝑧 2 = 2)
– ∃𝑧 > 0 (𝑧 2 = 2)
– ≡ ∃𝑧(𝑧 > 0 → 𝑧 2 = 2)
25
Nested Quantifiers
∀𝑥∃𝑦 𝑃(𝑥, 𝑦)
“For all 𝑥, there exists a 𝑦 such that 𝑃(𝑥, 𝑦)”.
Example:
∀𝑥∃𝑦 (𝑥 + 𝑦 = 0) where 𝑥 and 𝑦 are integers
26
Nested Quantifiers
∀𝑥∃𝑦 𝑃(𝑥, 𝑦)
“For all 𝑥, there exists a 𝑦 such that 𝑃(𝑥, 𝑦)”.
Example:
∀𝑥∃𝑦 (𝑥 + 𝑦 = 0) where 𝑥 and 𝑦 are integers
𝑥𝑦 𝑃(𝑥, 𝑦)
There exists an x such that for all 𝑦, 𝑃(𝑥, 𝑦) is true”
Example: 𝑥𝑦 (𝑥 × 𝑦 = 0)
• ∀𝑥∀𝑦∀𝑧 𝑥 + 𝑦 + 𝑧 = 𝑥 + 𝑦 + 𝑧
• THINK QUANTIFICATION AS LOOPS
27
Meanings of multiple quantifiers
Suppose 𝑷(𝒙, 𝒚) = “x likes y.”
Domain of x: {St1, St2}; Domain of y: {DS, Calculus}
• 𝒙𝒚 𝑷(𝒙, 𝒚)
– 𝑃(𝑥, 𝑦) true for all x, y pairs.
• 𝒙𝒚 𝑷(𝒙, 𝒚)
– 𝑃(𝑥, 𝑦) true for at least one x, y pair.
• 𝒙𝒚 𝑷(𝒙, 𝒚)
– For every value of x we can find a (possibly different) y
so that P(x,y) is true.
• 𝒙𝒚 𝑷(𝒙, 𝒚)
– There is at least one x for which P(x,y) is always true.
28
Meanings of multiple quantifiers
Suppose 𝑷(𝒙, 𝒚) = “x likes y.”
Domain of x: {St1, St2}; Domain of y: {DS, Calculus}
• 𝒙𝒚 𝑷(𝒙, 𝒚)
– 𝑃(𝑥, 𝑦) true for all x, y pairs.
• 𝒙𝒚 𝑷(𝒙, 𝒚)
– 𝑃(𝑥, 𝑦) true for at least one x, y pair.
• 𝒙𝒚 𝑷(𝒙, 𝒚)
– For every value of x we can find a (possibly different) y
so that P(x,y) is true.
• 𝒙𝒚 𝑷(𝒙, 𝒚)
– There is at least one x for which P(x,y) is always true.
29
Meanings of multiple quantifiers
Suppose 𝑷(𝒙, 𝒚) = “x likes y.”
Domain of x: {St1, St2}; Domain of y: {DS, Calculus}
• 𝒙𝒚 𝑷(𝒙, 𝒚)
– 𝑃(𝑥, 𝑦) true for all x, y pairs.
• 𝒙𝒚 𝑷(𝒙, 𝒚)
– 𝑃(𝑥, 𝑦) true for at least one x, y pair.
• 𝒙𝒚 𝑷(𝒙, 𝒚)
– For every value of x we can find a (possibly different) y
so that P(x,y) is true.
• 𝒙𝒚 𝑷(𝒙, 𝒚)
– There is at least one x for which P(x,y) is always true.
30
Meanings of multiple quantifiers
Suppose 𝑷(𝒙, 𝒚) = “x likes y.”
Domain of x: {St1, St2}; Domain of y: {DS, Calculus}
• 𝒙𝒚 𝑷(𝒙, 𝒚)
– 𝑃(𝑥, 𝑦) true for all x, y pairs.
• 𝒙𝒚 𝑷(𝒙, 𝒚)
– 𝑃(𝑥, 𝑦) true for at least one x, y pair.
• 𝒙𝒚 𝑷(𝒙, 𝒚)
– For every value of x we can find a (possibly different) y
so that P(x,y) is true.
• 𝒙𝒚 𝑷(𝒙, 𝒚)
– There is at least one x for which P(x,y) is always true.
31
• Quantification order is not commutative
𝒙𝒚 𝑷 𝒙, 𝒚 ≠ 𝒙𝒚 𝑷(𝒙, 𝒚)
32
Example
𝑄 (𝑥 , 𝑦, 𝑧): x + y = z
Domain: Real numbers
• ∀𝑥∀𝑦∃𝑧 𝑄(𝑥, 𝑦, 𝑧) True/False???
• For all real numbers x and for all real numbers y there
is a real number z such that 𝑥 + 𝑦 = 𝑧.
• True
• ∃𝑧∀𝑥∀𝑦 𝑄(𝑥, 𝑦, 𝑧) True/False???
• There is a real number z such that for all real
numbers x and for all real numbers y it is true that
𝑥 + 𝑦 = 𝑧.
• False
33
Example
𝑄 (𝑥 , 𝑦, 𝑧): x + y = z
Domain: Real numbers
• ∀𝑥∀𝑦∃𝑧 𝑄(𝑥, 𝑦, 𝑧) True/False???
• For all real numbers x and for all real numbers y there
is a real number z such that 𝑥 + 𝑦 = 𝑧.
• True
• ∃𝑧∀𝑥∀𝑦 𝑄(𝑥, 𝑦, 𝑧) True/False???
• There is a real number z such that for all real
numbers x and for all real numbers y it is true that
𝑥 + 𝑦 = 𝑧.
• False
34
Example
𝑄 (𝑥 , 𝑦, 𝑧): x + y = z
Domain: Real numbers
• ∀𝑥∀𝑦∃𝑧 𝑄(𝑥, 𝑦, 𝑧) True/False???
• For all real numbers x and for all real numbers y there
is a real number z such that 𝑥 + 𝑦 = 𝑧.
• True
• ∃𝑧∀𝑥∀𝑦 𝑄(𝑥, 𝑦, 𝑧) True/False???
• There is a real number z such that for all real
numbers x and for all real numbers y it is true that
𝑥 + 𝑦 = 𝑧.
• False
35
Example
𝑄 (𝑥 , 𝑦, 𝑧): x + y = z
Domain: Real numbers
• ∀𝑥∀𝑦∃𝑧 𝑄(𝑥, 𝑦, 𝑧) True/False???
• For all real numbers x and for all real numbers y there
is a real number z such that 𝑥 + 𝑦 = 𝑧.
• True
• ∃𝑧∀𝑥∀𝑦 𝑄(𝑥, 𝑦, 𝑧) True/False???
• There is a real number z such that for all real
numbers x and for all real numbers y it is true that
𝑥 + 𝑦 = 𝑧.
• False
36
From Nested Quantifiers to English
∃𝑥∀𝑦∀𝑧 𝐹 𝑥, 𝑦 ∧ 𝐹 𝑥, 𝑧 ∧ 𝑦 ≠ 𝑧 → ¬𝐹 𝑦, 𝑧
∃𝑥∀𝑦∀𝑧 𝐹 𝑥, 𝑦 ∧ 𝐹 𝑥, 𝑧 ∧ 𝑦 ≠ 𝑧 → ¬𝐹 𝑦, 𝑧
41
• The sum of two positive integers is always
positive.
• ∀𝑥 ∀𝑦 [ 𝑥 > 0 ∧ 𝑦 > 0 → 𝑥 + 𝑦 > 0 ]
• ∀𝑥 ∀𝑦 [𝑝𝑜𝑠 𝑥 ∧ 𝑝𝑜𝑠 𝑦 → 𝑝𝑜𝑠 𝑥 + 𝑦 ]
• What is domain above?
• Integers
• If domain is “+ve integers”
• ∀𝑥 ∀𝑦 𝑥 + 𝑦 > 0
42
• The sum of two positive integers is always
positive.
• ∀𝑥 ∀𝑦 [ 𝑥 > 0 ∧ 𝑦 > 0 → 𝑥 + 𝑦 > 0 ]
• ∀𝑥 ∀𝑦 [𝑝𝑜𝑠 𝑥 ∧ 𝑝𝑜𝑠 𝑦 → 𝑝𝑜𝑠 𝑥 + 𝑦 ]
• What is domain above?
• Integers
• If domain is “+ve integers”
• ∀𝑥 ∀𝑦 𝑥 + 𝑦 > 0
43
• Everyone has exactly one best friend
• For every person x , person x has exactly one best
friend.
• ∀𝑥 [person x has exactly one best friend]
• B(x,y): “x has best friend y”
• ∀𝑥∃𝑦[ 𝐵 𝑥, 𝑦 ]
• Exactly one best friend ????
• ∀𝒙∃𝒚[𝑩 𝒙, 𝒚 ∧ ∀𝒛 𝒚 ≠ 𝒛 → ¬𝑩(𝒙, 𝒛 ]
• ∀𝑥∃𝑦∀𝑧[𝐵 𝑥, 𝑦 ∧ 𝑦 ≠ 𝑧 → ¬𝐵(𝑥, 𝑧 ]
44
• Everyone has exactly one best friend
• For every person x , person x has exactly one best
friend.
• ∀𝑥 [person x has exactly one best friend]
• B(x,y): “x has best friend y”
• ∀𝑥∃𝑦[ 𝐵 𝑥, 𝑦 ]
• Exactly one best friend ????
• ∀𝒙∃𝒚[𝑩 𝒙, 𝒚 ∧ ∀𝒛 𝒚 ≠ 𝒛 → ¬𝑩(𝒙, 𝒛 ]
• ∀𝑥∃𝑦∀𝑧[𝐵 𝑥, 𝑦 ∧ 𝑦 ≠ 𝑧 → ¬𝐵(𝑥, 𝑧 ]
45
• Everyone has exactly one best friend
• For every person x , person x has exactly one best
friend.
• ∀𝑥 [person x has exactly one best friend]
• B(x,y): “x has best friend y”
• ∀𝑥∃𝑦[ 𝐵 𝑥, 𝑦 ]
• Exactly one best friend ????
• ∀𝒙∃𝒚[𝑩 𝒙, 𝒚 ∧ ∀𝒛 𝒚 ≠ 𝒛 → ¬𝑩(𝒙, 𝒛 ]
• ∀𝑥∃𝑦∀𝑧[𝐵 𝑥, 𝑦 ∧ 𝑦 ≠ 𝑧 → ¬𝐵(𝑥, 𝑧 ]
46
• Everyone has exactly one best friend
• For every person x , person x has exactly one best
friend.
• ∀𝑥 [person x has exactly one best friend]
• B(x,y): “x has best friend y”
• ∀𝑥∃𝑦[ 𝐵 𝑥, 𝑦 ]
• Exactly one best friend ????
• ∀𝒙∃𝒚[𝑩 𝒙, 𝒚 ∧ ∀𝒛 𝒚 ≠ 𝒛 → ¬𝑩(𝒙, 𝒛 ]
• ∀𝑥∃𝑦∀𝑧[𝐵 𝑥, 𝑦 ∧ 𝑦 ≠ 𝑧 → ¬𝐵(𝑥, 𝑧 ]
47
• Everyone has exactly one best friend
• For every person x , person x has exactly one best
friend.
• ∀𝑥 [person x has exactly one best friend]
• B(x,y): “x has best friend y”
• ∀𝑥∃𝑦[ 𝐵 𝑥, 𝑦 ]
• Exactly one best friend ????
• ∀𝒙∃𝒚[𝑩 𝒙, 𝒚 ∧ ∀𝒛 𝒚 ≠ 𝒛 → ¬𝑩(𝒙, 𝒛 ]
• ∀𝑥∃𝑦∀𝑧[𝐵 𝑥, 𝑦 ∧ 𝑦 ≠ 𝑧 → ¬𝐵(𝑥, 𝑧 ]
48
• Everyone has exactly one best friend
• For every person x , person x has exactly one best
friend.
• ∀𝑥 [person x has exactly one best friend]
• B(x,y): “x has best friend y”
• ∀𝑥∃𝑦[ 𝐵 𝑥, 𝑦 ]
• Exactly one best friend ????
• ∀𝒙∃𝒚[𝑩 𝒙, 𝒚 ∧ ∀𝒛 𝒚 ≠ 𝒛 → ¬𝑩(𝒙, 𝒛 ]
• ∀𝑥∃𝑦∀𝑧[𝐵 𝑥, 𝑦 ∧ 𝑦 ≠ 𝑧 → ¬𝐵(𝑥, 𝑧 ]
49
• There is a woman who has taken a flight on
every airline in the world.
• Domains: people airlines flights
• W(x): x is a woman
• F(x, f): x has taken flight f
• A(f, a): flight f belongs to airline a
• ∃𝒙[𝑾 𝒙 → ∀𝒂∃𝒇 𝑨 𝒇, 𝒂 ∧ 𝑭 𝒙, 𝒇 ]
• ∃𝑥∀𝑎∃𝑓[𝑊 𝑥 → 𝐴 𝑓, 𝑎 ∧ 𝐹 𝑥, 𝑓 ]
50
• There is a woman who has taken a flight on
every airline in the world.
• Domains: woman airlines flights
• P(w, f): Woman w has taken flight f
• Q(f, a): flight f belongs to airline a
• ∃𝒙[𝑾 𝒙 → ∀𝒂∃𝒇 𝑨 𝒇, 𝒂 ∧ 𝑭 𝒙, 𝒇 ]
• ∃𝑥∀𝑎∃𝑓[𝑊 𝑥 → 𝐴 𝑓, 𝑎 ∧ 𝐹 𝑥, 𝑓 ]
51
• There is a woman who has taken a flight on
every airline in the world.
• Domains: woman airlines flights
• P(w, f): Woman w has taken flight f
• Q(f, a): flight f belongs to airline a
• ∃𝒘∀𝒂∃𝒇[ 𝑷 𝒘, 𝒇 ∧ 𝑸 𝒇, 𝒂 ]
52
• There is a woman who has taken a flight on
every airline in the world.
• Domains: woman airlines flights
• R(w, f, a): Woman w has taken flight f on airline a
• ∃𝒘∀𝒂∃𝒇[𝑸(𝒘, 𝒇, 𝒂]
53
Bound and free variables
A variable is bound if it is known or quantified.
Otherwise, it is free.
Examples:
P(x) x is free
P(5) x is bound to 5
x P(x) x is bound by quantifier
• ∀𝒘∃𝒂∀𝒇 ¬ 𝑷 𝒘, 𝒇 ∨ ¬𝑸 𝒇, 𝒂
55
Do Exercises
56