Predicate logic
….Motivation
• Proposition logic can not adequately express the meaning of
statements in mathematics and natural languages.
For example:
• x is greater than 3.
• The above statement can be true as well as false depending upon the
value of x.
Some more examples…
• Every computer connected to the University Network is functioning
properly.
• M1 is functioning properly.
• M2 is under attack by the Intruder.
• There is a computer in University Network that is under attack by the
intruder.
• No rules of proposition logic allow us to conclude the truth of the
above statements.
Predicate logic…
• Predicate logic is more powerful types of logic .
• Predicate logic can be used to express the meaning of a wide range of
statements in mathematics and computer science in a ways that
permit us to reason and explore relationship between objects.
• The statement “x is greater than 3” has two parts:
• the variable x , is the subject of the statement.
• the predicate, is greater than 3 ,refers to a property that the subject
of the statement can have.
• We can denote the statement “ x is greater than 3” by
P(x), where P denote the predicate ”is greater than 3” and x is a
variable.
• P(x) is value of predicate function P at x.
• P(x) becomes the proposition ,when x takes a concrete value.
Q1. If P(x) denote the statement “x>3”. What is the truth values of P(4)
and P(2)?
Multivalued predicate
• Q(x ,y) denote the statement “x=y+3”. What is the truth values of
Q(1,2) and Q(3,0)?
Converting Predicates to propositions
• Method 1: Explicitly assign the value to underlying variables.
• less interesting.
• Method 2: Quantification- express the extent to which a predicate is true over a range
of element
• Universal Quantification
• Existential Quantification
Universal Quantifier
• Asserts that a property is true for all the elements of the
domain(universe of discourse)
∀x P(x)
• ∀x P(x) is true if the property P holds for every x in the domain.
• Let domain={x1,x2,…..xm}
∀x P(x) ≡ P(x1) ∧ P(x2) …. ∧ P(xm)
∀x P(x) will be false if there is some value a in the domain such
that P(a) is false---called a counter example of ∀x P(x) .
Existential Quantifier
• Asserts that a property is true for atl east one element of the
domain(universe of discourse)
∃ x P(x)
• ∃ x P(x) is true if the property P holds for some x in the domain.
• Let domain={x1,x2,…..xm}
∃ x P(x) ≡ P(x1) ∨ P(x2) …. ∨ P(xm)
∃ x P(x) will be false if there is no value xi in the domain such
that P(xi ) is true.
Question: suppose the domain for Q(x,y,z) consists of x,y,z where
x=0,1,2
y=0,1
z=0 ,1
Write out the following proposition using conjunction and disjunction
• ∀y Q(0,y.0)
• ∃ x Q(x,1,1)
Quantifiers:
Statement When true When false
∀x :P(x) P(x) is true for every x There is an x for which P(x)
is false.
∃ x: P(x) There is an x for which P(x) P(x) is false for every x.
is true.
Significance of Domain
• Any quantifier statement is incomplete without the domain
specification.
P(x):x2>0
• Is ∀x P(x) true?
• Yes, provided the domain does not include 0.
The logical meaning of a quantified statement completely changes if
the domain changes.
Translating English statement Using
Predicates
• Every student in CS has studied calculus.
(Domain- is all student of the college).
The logical interpretation of the statement is—
For every student x in the college, If student x has enrolled for CS,
then student x has studied calculus.
S(x): true, if student x is enrolled in CS.
C(x): true, if student x is studied calculus.
∀x:[S(x) → C(x)]
• Some student in CS has studied calculus.
• Domain: all student of the college.
• S(x): true, if student x is enrolled in CS.
• C(x): true, if student x has studied calculus.
• ∃ x:[S(x) ∧ C(x)]
Bounded and Free Variables
• Bounded Variables: If there is a quantifier applied on it.
• ∃ x: x+y=1
• Here x is bounded while y is free.
• ∃ x: P(x) ∨ ∀x :Q(x) or ∃ x: [P(x) ] ∨ ∀x :[Q(x) ] or ∃ x: P(x)
∨ ∀y :Q(y)
• Here two different variables bounded by different quantifiers.
• Scope of quantifier: part of the expression over which the
quantifier is applied.
Uniqueness Quantification
∃! x: P(x) or ∃1 x: P(x)
there exists a unique x such that P(x) is true.
Question 1.
Let P(x) denote the statement “x>3”. What is the truth value of
∃ x: P(x) where the domain consists of all real numbers.
Ans:
∃ x P(x) is true as 4>3
Note: ∃ x P(x) is false if and only if there is no element x in the
domain for which P(x) is true.
Question 2:
Q(x) : x=x+1 What is the truth value of ∃ x: Q(x) , where the domain
consists of all real numbers ?
Ans: ∃ x: Q(x) is false.
Question 3:
P(x): x2>10, Domain consists of positive integers not exceeding 4.
What is the truth value of ∃ x: P(x) ? Ans : ∃ x: P(x) is true.
Question 4:
Let P(x) denote the statement “x+1>x”. What is the truth value of
∀ x: P(x) where the domain consists of all real numbers.
Ans: Because P(x) is true for all real numbers, so ∀ x: P(x) is
true.
Negating Quantified Expression
~ ∀ x P(x) ≡ ∃ x ~P(x)
~∃ x Q(x) ≡ ∀ x ~Q(x) ( for every x ,Q(x) is false)
Example:
P(x) is “x is taken a course in calculus.”
∀ x P(x) is “Every student in your class has taken a course in
calculus”.
~ ∀ x P(x) is ”It is not the case that every student in your class has
taken a course in calculus”.
That means “There is a student in your class who has not taken a
course in calculus” i.e. ∃ x ~P(x)
Negation Equivalent Statement When is negative true When false
~∃ x P(x) ∀ x ~P(x) For every x, P(x) is false There is an x for which
P(x) is true.
~ ∀ x P(x) ∃ x ~P(x) There is an x for which P(x) is true for every x
P(x) is false.
Q. What are the negations of the following statements.
1. There is an honest politician.
2. All Americans eat cheeseburgers.
3. ∀ x : (x2>x)
4. ∃ x: (x2=2)
1. Domain: set of politicians
P(x): x is honest.
There is an honest politician . ∃ x P(x)
Negation of it. ~ ∃ x P(x) ≡ ∀ x ~P(x)
All politicians are dishonest.
2. Domain: Americans.
P(x): x eat cheeseburgers.
All Americans eat cheeseburgers. ∀ x P(x)
Negation of it. ~∀ x P(x) ≡ ∃ x ~P(x)
Some Americans do not eat cheeseburgers.
3. ∀ x : (x2>x)
Negation of it:
~ ∀ x : (x2>x) ≡ ∃ x : ~ (x2>x) ≡ ∃ x: (x2<=x)
4. ∃ x: (x2=2)
• Negation of it:
~∃ x: (x2=2) ≡ ∀ x: ~ (x2=2) ≡ ∀ x: (x2 ≠ 2)
Nested Quantifiers
• Two quantifiers are nested if one is within the scope of other, such
as
∀ x ∃y (x + y = 0) - for all x there exists a y such that x + y = 0
is true.
∃x ∀y (x + y = 0) - there exist a x for which x + y = 0 is true for
every y.
• Order of quantifiers is important , unless all the quantifiers
are universal quantifiers or all are existential quantifiers.
Nested Quantifiers…
Example:
M(x, y): true, if person y is mother of person x.
Every person in this world has a mother.
∀x ∃y: M(x ,y)- For all person x, there is some y such that person y is the mother of
person x.
∃y ∀x : M(x ,y)-some person is the mother of all the persons in the world.
∀x ∃y: M(x ,y) ≠ ∃y ∀x : M(x ,y)
• Order of nested quantifiers matters a lot.
• Swapping of nested quantifiers are not always possible.
• Example1:
• P(x, y) be the statement “x+y = y+x”. What is the truth values of ∀x
∀y P(x, y) and ∀y ∀x P(x, y) where the domain for all
variables consists of all real numbers.
• ∀x ∀y P(x, y) denote the proposition “For all real numbers x,
for all real number y, “x+y = y+x”.
• ∀y ∀x P(x, y) denote the proposition “For all real numbers y,
for all real number x, “x+y = y+x”.
• So both the above proposition has same meaning.
• Example 2: Let Q(x, y) denote “x + y=0”.
What is the truth values of ∃ y ∀x Q(x, y) and ∀x ∃ y Q(x, y)
where the domain for all variables consists of all real numbers.
• ∃ y ∀x Q(x, y) denotes “There is a number y such that for
every real number x, Q(x, y) “.
∃ y ∀x Q(x, y) is false)
• ∀x ∃ y Q(x, y) denotes “For every real no x there is a real no y
such that Q(x, y) “.
∀x ∃ y Q(x, y) ) is true.(y=-x)
• So both the above propositions have different meaning.
Quantifications of two Variables.
Statement When True When False
∀x∀y P(x,y) is true for every There is a pair x, y for
P(x,y) pair (x,y). which P(x,y) is false.
∀y∀x
P(x,y)
∀x∃y For every X there is a There is an x such that
P(x,y) y for which P(x,y) is P(x,y) is false for every
true y.
∃x∀y There is an x for which For Every x there is a
P(x,y) P(x,y) is true for every y for which P(x,y) is
y. false.
∃x∃y There is a pair x,y pair P(x,y) is false for every
More examples…
• All humming bird are richly in colour.
• No large bird live on honey.
• Birds that do not live on honey are dull in colour.
• All humming birds are small.
• Domain-all the birds.
• B(x): true, if x is humming bird.
• C(x):true, if x is richly in colour.
• L(x): true, if x is large bird.
• H(x): true, if x live in honey.
• All humming bird are richly in colour.
∀x:[B(x) → C(x)]
• No large bird live on honey.
~[∃ x:[L(x) ∧ H(x)]] ≡ ∀x:[L(x) →~ H(x)]
• Birds that do not live on honey are dull in colour
∀x:[~H(x) →~ C(x)]
• All humming birds are small.
∀x:[B(x) →~ L(x)]
Q. Translate the following mathematical statement in logical
statements.
A) The sum of two positive integers is always positive.
• If Domain=set of all integers
∀x ∀y : ((x>0) ∧(y>0 ) → (x+y>0))
• If Domain=set of all positive integers
∀x ∀y: (x+y>0)
B) Every real number except zero has a multiplicative
inverse.
Domain=set of real numbers.
∀x: ((x ≠ 0) → ∃ y:(xy=1))
Q. Translate the statement ∀x: (C(x) ∨ ∃ y:(C(y) ∧ F(x, y)))
into English, where C(x) is “x has a computer”, F(x, y) is “X
and Y are friends.” and domain for both x and y consists of
all students in your school.
• For every student x in the school , x has a computer or there is
a student y such that y has a computer and x and y are friends.
• Every student in your school has a computer or has a
friend who has computer.
Ex 1: If a person is female and is a parent then this person is
someone’s mother.
F(x): true, if x is female.
P(x): true, if x is a parent.
M(x, y): true if person x is mother of some person y.
Domain – set of all people.
∀x [F(x) ∧ P(x) → ∃ y: M(x, y)]
• Ex2. Every person has exactly one best friend. Domain is set of all
people.
1. Each person x has at least one best friend y.
2. Some person x has no other best friend z such that z ≠ y.
B(x, y): x has at least one best friend y.
∀x ∃y:[B(x, y) ∧ ~∃ z : ((z ≠ y) ∧ B(x, z) )]
1. All lions are fierce.
2. Some lions do not drink coffee.
3. Some fierce creatures do not drink coffee.
L(x) : “ x is lion.”
F(x): x is fierce.
C(x): x drink coffee.
Domain: set of all creatures
1. ∀x :( L(x) → F(x))
2. Ǝ x: (L(x) /\ ~ C(x))
3. Ǝ x: (F(x) /\ ~ C(x))
Logical Equivalences involving predicate
• Show that ∀ x [P(x) ∧ Q(x)] ≡ ∀ x P(x) ∧ ∀ x Q(x) , we can
distribute a universal quantifier over a conjunction.
Consider a arbitrary domain={x1,x2,…..xn}
∀ x (P(x) ∧ Q(x)) ≡ [P(x1) ∧ Q(x1)] ∧ [P(x2) ∧ Q(x2)] …. ∧
[P(xn) ∧ Q(xn)]
≡ [P(x1) ∧ P(x2) ……∧ P(xn)] ∧ [Q(x1) ∧ Q(x2) ……∧ Q(xn)]
≡ ∀ x P(x) ∧ ∀ x Q(x)
Note: We can also distribute an existential qualifier over a
disjunction.
∃ x [P(x) ∨ Q(x)] ≡ ∃ x P(x) ∨ ∃ x Q(x)—proof your self
• But we cannot distribute a universal quantifier over disjunction and
existential quantifier over a conjunction.
Rules of Inference for Quantifiers
• Universal Instantiation
∀x [P(x)]
∴ P(c)
c is some specific element of the domain.
Ex: All women are wise that mona is wise where mona is a member of
the domain of all women.
Rules of Inference for Quantifiers
• Universal Generalization
P(c)
∴ ∀x [P(x)]
c should be a completely arbitrary elements.
For instance, every arbitrary university student has a high school
diploma. we can therefore conclude that all university students
have a high school diploma.
Rules of Inference for Quantifiers
• Existential Instantiation
∃ x [P(x)]
∴ P(c)
c is some non-arbitrary element of the domain.
Ex: For instance, there is someone who got an A+ in the course,
let’s call her a and say that a got an A+.
Rules of Inference for Quantifiers
• Existential Generalization
P(c)
∴ ∃ x [P(x)]
c is a specific known element of the domain.
Mona got an A+ in the course, therefore someone got an A+ in
the course.
Rules of Inferences in Predicate Logic
Arguments involving Quantifiers
Is the following argument valid?
❖ Every student in CS course has studied calculus.
❖ Srinivas is a student in CS201 course.
❖ So Srinivas has studied calculus.
S(x): x is a student in CS course.
C(x): x has studied calculus.
Domain: set of all students 1. ∀x: [S(x) → C(x)] Given Premise
Argument form: 2. S(Srinivas) → C(Srinivas) Universal Instantiation on
(1)
∀x: [S(x) → C(x)] 3. S(Srinivas) Given Premise
S(Srinivas) 4. C(Srinivas) Modus ponens in 2 &3
∴ C(Srinivas) Hence the given arguments are valid.
Q: Show that the premises “ Everyone in this discrete mathematics
class has taken a course in computer science” and “Maria is a student
in this class” imply the conclusion “Maria has taken a course in
computer science”.
• Sol:
D(x): x is in this discrete mathematics class.
C(x): x has taken course in computer science.
Domain : all student
Argument form: 1. ∀x:[D(x) → C(x)] given premise
2. D(Maria) → C(Maria) Universal Instantiation
∀x:[D(x) → C(x)] from 1
3. D(Maria) given premise
D(Maria) 4. C(Maria) Modus ponens in 2 and 3
∴ C(Maria)
Hence Given arguments are Valid.
• Show that the premise “A student in this class has not read the
book.” and “Everyone in this class passed the first exam.” imply the
conclusion “Someone who passed the first exam has not read the
book“.
• Sol: C(x): x is in the class.
• B(x): x has not read the book.
• P(x): x has passed the first exam.
• Domain: all student in college.
1. ∃ x:[C(x) /\ B(x)] Given Premise
• Argument form: 2. C(a) /\ B(a) Existential instantiation from
1
∃ x:[C(x) /\ B(x)] 3. C(a) simplification from 2
∀x:[C(x) → P(x)] 4. ∀x:[C(x) → P(x)] Given Premise
5. C(a) → P(a) Universal instantiation from 4
∴ ∃ x:[P(x) /\ B(x)] 6. P(a) Modus ponens in 5 and 3
7. B(a) simplification from 2
8. P(a) /\ B(a) Conjunction in 6 and 7
9. ∃ x:[P(x) /\ B(x)] Existential generalization
from 8
Exercise Questions: (do your self-H.W)
Express the following using predicates and quantifiers.
• Some student in this class has visited Mexico.
• Every student in the class has visited either Canada or Mexico.
• Every mail message larger than one megabyte will be compressed.
• If a user is active, at least one network link will be available.
1. Some student in this class has visited Mexico.
Domain: set of students.
M(x): x has visited Mexico.
∃x: M(x)
2. Every student in the class has visited either Canada or Mexico.
C(x): X has visited Canada.
S(x):x is a student in this class.
∀x: [S(x) → (M(x) ∨ C(x))]
3. Every mail message larger than one megabyte will be compressed.
Domain: set of all mail messages.
S(m, y): mail message m is larger than m megabytes.
C(m): m is compressed.
∀m: [S(m,1) → C(m)]
4. If a user is active, at least one network link will be available.
n has domain of all network link.
x has domain of all possible states for a network link.
u has domain of all users.
A(u): user u is active.
S(n, x): network link n is in state x.
∃u A(u) → ∃n S(n, available)
Translate each of these statements into logical expressions using
predicates, quantifiers, and logical connectives.
a) No one is perfect.
b) Not everyone is perfect.
c) All your friends are perfect.
d) At least one of your friends is perfect.
e) Everyone is your friend and is perfect.
f ) Not everybody is your friend or someone is not perfect.
• P(x) be “x is perfect”;
• F(x) be “x is your friend”;
• domain : all people.
a) No one is perfect. ∀x ¬P(x)
b) Not everyone is perfect. ¬∀x P(x)
c) All your friends are perfect. ∀x(F(x) → P(x))
d) At least one of your friends is perfect. ∃x(F(x) ∧ P(x))
e) Everyone is your friend and is perfect. ∀x(F(x) ∧ P(x))
f) Not everybody is your friend or someone is not perfect
(¬∀x F(x)) ∨ (∃x ¬P(x))
• Express each of these statements using logical operators, predicates,
and quantifiers.
a) Some propositions are tautologies.
b) The negation of a contradiction is a tautology.
c) The disjunction of two contingencies can be a tautology.
d) The conjunction of two tautologies is a tautology.
Ans: Let T (x) mean that x is a tautology and C(x) mean that x is a contradiction.
a) ∃x T (x)
b) ∀x(¬ C(x)→T (x))
c) ∃x∃y(((T (x) ∨ C(x) )∨ (T (y) ∨ C(y))∧(T (x ∨ y))
d) ∃x∃y((T (x) ∧T (y)) ∧ T (x∧y))