Predicate Logic

Download as pdf or txt
Download as pdf or txt
You are on page 1of 40
At a glance
Powered by AI
Predicate logic expands on propositional logic by allowing statements to be made about variables and their relationships using predicates and quantifiers.

Predicate logic, also known as predicate calculus or predicate logic, introduces predicates and quantifiers to logic. A predicate refers to a property that the subject of a statement can have. Predicate logic deals with predicates and quantifiers like 'for all' and 'there exists'.

The two main quantifiers in predicate logic are the universal quantifier, which is written as ∀x and means 'for all x in the domain', and the existential quantifier, which is written as ∃x and means 'there exists x in the domain'.

Limitations of Propositional Logic

 Which can NOT be expressed using


propositional logic?
Ex1: How do you make a statement about all
even integers from integers? (any x, x mod 2 = 0)
Ex2: Every computer connected to the
university network is functioning properly,
which can imply () CS1 is functioning
properly.
 A more general language: Predicate logic

2017/11/13 CSE, NCHU 1


Predicate Logic (1/3)
Predicate Calculus or Predicate Logic
• Predicate – refers to a property that the subject
of a statement can have.
• The area of logic that deals with predicates and
quantifiers (e.g. for any  and there exists )
E.G. “x is greater than 3”
x is the subject and “is greater than 3” is a
predicate.
• A predicate which binds with variable(s) is called
propositional function.

2017/11/13 CSE, NCHU 2


Predicate Logic (2/3)
 Propositional function P at x, P(x), once a value has
been assigned to x, P(x) becomes a proposition and
has a truth value. Domain of x is critical.
E.g.: P(x): x is an even number. Then P(1) is false
and P(2) is true,….where Domain(x) = all integers.
 Examples of predicates:
 Domain is ASCII characters - IsAlpha(x) : TRUE iff
x is an alphabetical character.
 Domain is floating point numbers - IsInt(x): TRUE
iff x is an integer.
 Domain is integers: Prime(x) - TRUE if x is prime,
FALSE otherwise.
2017/11/13 CSE, NCHU 3
Predicate Logic (3/3)
 A propositional function may associate with
two or more variables.
Eg 1: P(x,y): “x = y+3”, and P(1,2) is false.
Eg 2: Q(x,y,z): “x+y=z”, then Q(1,2,3) is true.

 P(x1, x2, …, xn ) is the value of the


propositional function P at the n-tuple (x1,
x2, …, xn ) and P is also called a n-tuple
predicate or a n-ary predicate.

2017/11/13 CSE, NCHU 4


Quantifications
 When the variables in a propositional function
are assigned values, the resulting statement
becomes a proposition, which could be either
true of false.
 Another way to create a proposition – using
Quantifications
 Universal quantification 
 Existential quantification 

 Uniqueness quantification !
2017/11/13 CSE, NCHU 5
Two Popular Quantifiers
 Universal: x P(x) – “P(x) for all x in the domain”
 Existential: x P(x) – “P(x) for some x in the domain”
or “there exists x such that P(x) is TRUE”.
 Either is meaningless if the domain is not
known/specified. Think about x (x2 ≧ x) ?
 Examples
 x (x2 ≧ 0) is true, if domain of x is R.
 x (x >1) is true, if domain of x is R.
 (x>1) (x2 > x) is true, if domain of x is R.
Note: in the last case - quantifier with restricted domain
2017/11/13 CSE, NCHU 6
Using Quantifiers
Let domain of x be integers,
 Using implications: The cube of any
negative integer is negative.
x (x < 0) (x3 < 0)
 Expressing sums (domain of n be N):

n
n ( i = n(n+1)/2)
i=1

2017/11/13 CSE, NCHU 7


Scope of Quantifiers
 , have higher precedence than operators
from Propositional Logic (¬    )
x P(x)  Q(x) is not logically equivalent to
x (P(x)  Q(x))
  x (P(x)  Q(x))  x R(x)
Say, P(x): x is odd, Q(x): x is divisible by 3, R(x): (x=0)  (2x >x)
 Logical Equivalence: P(x)  Q(x) iff they have same
truth value no matter which domain value is used and
no matter which predicates are substituted into these
statements.
 For example, ¬x P(x)   x ¬P(x)
2017/11/13 CSE, NCHU 8
Translation Examples (1/5)
Example 23: “Every student in this class has studied calculus.”
Sol_1:
Domain of x is “the students in this class”
C(x) represents “x has studied calculus”
x C(x)

Sol_2:
Domain of x is “all people”
S(x) stands for “the person x is in this class”
x (S(x)  C(x)) (Caution: Not x (S(x)  C(x)) )

Sol_3:
Domain of x is “the students in this class” or “all people”
Q(x,y) represents “x has studied subject y”
x Q(x, calculus) or x (S(x)  Q(x, calculus))
2017/11/13 CSE, NCHU 9
Translation Examples (2/5)
Example 24: “some student in this class has visited Mexico” and
“every student in this class has visited either Canada or Mexico”
Sol:
Let M(x) = “x has visited Mexico”
S(x) = “x is a student in this class”
C(x) = “x has visited Canada”
V(x,y) denotes “x has visited y”
 x M(x) if x’s domain is “the students in this class”
 X (S(x)  M(x)) if x’s domain is defined as “all people”
(Caution: not  X (S(x)  M(x)) Why? )
x (S(x)  (C(x)  M(x)) or x (S(x)  (V(x,Mexico)  V(x,Canada)))
if x’s domain is defined as “all people”, how about in the restricted domain?

2017/11/13 CSE, NCHU 10


Translation Examples (3/5)
Translation from English into logical expression
• Every student in this class has studied calculus
C(x): x has studied calculus
S(x): the person x is in this class
Q(x,y): student x has studied subject y
 x (S(x)  C(x)), Domain(x)=“students in the class”
or
 x (S(x)  Q(x, calculus)), Domain(x)=“all people”
 x Q(x, calculus)

2017/11/13 CSE, NCHU 11


Translation Examples (4/5)
Examples from Lewis Carroll
1. all lions are fierce
2. some lions do not drink coffee
3. some fierce creatures do not drink coffee

P(x): x is a lion
Q(x): x is fierce
R(x): x drinks coffee

1. x (P(x)  Q(x))
2.  x (P(x)  ¬ R(x)) (note: not  x (P(x)  ¬ R(x))
3.  x (Q(x)  ¬ R(x)) (note: not  x (Q(x)  ¬ R(x))

2017/11/13 CSE, NCHU 12


Translation Examples (5/5)
Use predicates and quantifiers to express the system
specifications. “Every mail messages larger than one
megabytes will be compressed” and “If a user is active,
at least one network link will be available.”

Let S(m,y) be “mail message m is larger than y megabytes”,


where domain of m is all messages and y is a positive
integer. C(m) denotes “mail message m will be compressed”,
domain of m is all messages.
Let A(u) be “user u is active”, where domain of u is all users. Let
S(n,x) be “network link n is in state x”, domain of n is all
network links and domain of x is all possible states for a
network link.

1. m (S(m,1)  C(m))
2.  u A(u)   n S(n, available)
2017/11/13 CSE, NCHU 13
Translation Examples Again (1/2)
Let S(x) be “x is a student”, F(x) be “x is a faculty member”, and A(x,y)
be “x has asked y a question” where the domain consists of all people.
(expressions in red are for domain of students and faculty members)
✓ Some student has not asked any faculty member a question.

x y (S(x)  F(y)  ¬A(x,y)) (wrong), x y ¬(A(x,y))


x y (S(x)  (F(y)  ¬A(x,y))
✓ Some student has asked any faculty member a question.
x y (S(x)  F(y)  A(x,y)) (wrong), x y (A(x,y))
x y (S(x)  (F(y)  A(x,y)))
✓ There is a faculty member who has never been asked a question by
a student.
y x (F(y)  S(x)  ¬A(x,y))(wrong)) , y x ¬(A(x,y))
y (F(y)  x ( S(x)  ¬A(x,y)))
✓ No student has asked all faculty members.
¬(x y (S(x)  (F(y)  A(x,y))), ¬(x y (A(x,y)))
2017/11/13 14
Translation Examples Again (2/2)
Let S(x) be “x is a student”, F(x) be “x is a faculty member”, and A(x,y)
be “x has asked y a question” where the domain consists of all people.
(expressions in red are for domain of students and faculty members)
✓ Every student has asked a faculty member a question.

x (S(x)  y (F(y)  (A(x,y))), x y A(x,y)

✓ Every student has asked Professor Gross a question.


x (S(x)  A(x, Prof. Gross)), x A(x, Prof. Gross)

✓ No student has asked Professor Gross a question.


¬(x (S(x)  (A(x, Prof. Gross)))), x(¬A(x, Prof. Gross))

✓ No student has asked any faculty member a question.


¬(x y (S(x)  (F(y)  A(x,y))), x y(¬A(x, y))
x y ((¬S(x)  F(y))  (S(x)  ¬A(x,y))),
2017/11/13 CSE, NCHU 15
Negation of Quantifiers
 “There is no student who can …”
 “Not all professors are bad….”
 “There is no Toronto Raptor that can dunk like
Vince …”
 ¬x P(x)   x ¬P(x) why?
E.g. Every student in this class is working hard.
 ¬ x P(x)   x ¬P(x)
 Careful: The negation of “Every Canadian loves
Hockey” is NOT “No Canadian loves Hockey”! Many,
many students make this mistake!
2017/11/13 CSE, NCHU 16
Nested Quantifiers (1/3)
 Allows simultaneous quantification of
many variables.
 E.g. Let domains be positive integers,
 x  y  z x2 + y2 = z2 (畢氏定理)
n  x  y  z xn + yn = zn ? false
(對任一n,存在x,y,z 使得xn + yn = zn成立?)
 Domain of real numbers:
x  y  z (x < z < y)  (y < z < x) T or F ?
2017/11/13 CSE, NCHU 17
Nested Quantifiers (2/3)
x y (x + y = 0) is true over the integers
 Assume x is an arbitrary integer.
 To show that there exists a y that satisfies the
requirement of the predicate, choose y = -x. Clearly
y is an integer, and thus is in the domain.
 So x + y = x + (-x) = x – x = 0.
 Since we assumed nothing about x (other than it is
an integer), the argument holds for any integer x.
Therefore, the predicate is TRUE.
 BUT, x y (x + y = 0) is false over the reals
(How about if the domain is “integers”? false)
2017/11/13 CSE, NCHU 18
Nested Quantifiers (3/3)
 Caveat: In general, order matters!
Consider the following propositions over
the integer domain:
x y (x < y) and y x (x < y)
 x y (x < y) : “there is no maximum integer”
 y x (x < y) : “there is a maximum integer”
 Not the same meaning at all!!!

2017/11/13 CSE, NCHU 19


Negation of Nested Quantifiers
 Use the same rule as before carefully.
 Ex 1: ¬x y (x + y = 0)
 This is equivalent to x ¬y (x + y = 0)

 This is equivalent to x  y ¬(x + y = 0)

 This is equivalent to x  y (x + y  0)

 Ex 2: ¬x y (x < y)
 This is equivalent to x ¬y (x < y)

 This is equivalent to x y ¬(x < y)

 This is equivalent to x y (x  y)

2017/11/13 CSE, NCHU 20


Translation Examples (1/4)
Example 7: “Every real number except 0 has a
multiplicative inverse.”
Sol:
Assume that the domains of x and y are all “real numbers”
Let’s rewrite the sentence as “For every real number x
except 0, x has a multiplicative inverse.”

x ((x ≠ 0)   y (xy = 1))

2017/11/13 CSE, NCHU 21


Translation Examples (2/4)
Example 8: use quantifiers to express the definition of limit
of a real-valued function f(x) of a real variable at a point
a in its domain.
Sol:
The definition of the statement lim f(x) = L is:
For every real number ε >0 there exists a real number
σ>0 such that \f(x)-L\ < ε whenever 0 < \x-a\ < σ.
Hence,
ε σ x ((0 < \x-a\ < σ)  \f(x)-L\ < ε ) if the
domain of ε and σ is all positive reals and domain of x is
reals. Or,
ε>0 σ>0 x ((0 < \x-a\ < σ)  \f(x)-L\ < ε ), if the
domain for ε ,σ, and x is reals.
2017/11/13 CSE, NCHU 22
Translation Examples (3/4)
Example 13: There is a woman who has taken a flight on every
airline in the world.
Sol Let P(w,f) be “w has taken f” and
Q(f,a) be “f is a flight on a”
The statement can be expressed as
 w  a  f (P(w,f)  Q(f,a)),
where the domains for w,f, and a consists of all the
women in the world, all airplane flights, and all
airlines, respectively.

Example 15: There does not exist a woman who has taken a
flight on every airline in the world.
 w ¬ a  f (P(w,f)  Q(f,a))

2017/11/13 CSE, NCHU 23


Translation Examples (4/4)
Example 12: Everyone has exactly one best friend.
Sol: Let B(x,y) be “y is the best friend of x” and
the domain is all people.
The statement can be expressed as

x  y (B(x,y)  z (B(x,z)  (z = y))), or


x  y (B(x,y)  z ((z ≠ y)  ¬B(x,z))), or
x !y (B(x,y)

Q: How about “Someone has no any (best) friend”?


 x y ¬B(x,y)

2017/11/13 CSE, NCHU 24


Translating into English (1/2)
Example 9: 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”. The domain of both x and y consists of all
students in your school.

A: The statements says that every student in your school


has a computer or has a friend has a computer.

2017/11/13 CSE, NCHU 25


Translating into English (2/2)
Example 5: x y z Q(x,y,z) and z x y Q(x,y,z)
where Q(x,y,z) is “x+y=z” and the domain of all
variables consists of all real numbers.

A: (1) for all real numbers x and for all real numbers y,
there is a real number z such that x+y=z. (T)

(2) There is a real number z such that for all real


numbers x and for all real numbers y, it is true that
x+y=z. (F)

2017/11/13 CSE, NCHU 26


Domain is the Matter
Example 6: Translate the statement “the sum of two
positive integer is always positive.”

A: (1) Assume the domain of variables is Z.


x y ((x>0)  (y>0)  (x+y > 0))

(2) Assume that the domain of variable is Z+.


x y (x+y > 0)

2017/11/13 CSE, NCHU 27


Argument and Argument form
 An argument in propositional logic is a sequence of
propositions, or a sequence of statements that end with
a conclusion.
 For example, “ If you have a current password, then you
can log on to the network”., “You have a current
password.”, and “You can log onto the network.”
 All but the final proposition in the argument are called
premises, the final proposition is called the conclusion.
 An argument form in propositional logic is a sequence of
compound propositions involving propositional variables.
 Valid argument means the conclusion must follow from the
truth of the premises (no matter which variables are binding
to the propositional functions).
2017/11/13 CSE, NCHU 28
Valid Argument
 If you have a current password, then
you can log onto the network
 p “you have a current password”

q “you can log onto the network”


pq
p
 q (means “therefore”)

2017/11/13 CSE, NCHU 29


Inference rules (1/3)
 Recall that the reason for studying logic was to
formalize derivations and proofs.
 How can we infer facts using logic?
 Simplest possible inference: From p  q and p is
TRUE, we can infer that q is TRUE. (Modus Ponens)
 Similarly, From p  q, q  r and p is TRUE, we
can infer that r is TRUE. (by Hypothetical syllogism
& Modus Ponens)
 Read rules on page 72 and page 76.
2017/11/13 CSE, NCHU 30
Inference rules (2/3)
 Modus ponens (p  (p  q))  q
 Modus tollens (¬ q  (p  q))  ¬p
 Hypothetical syllogism
((p  q)  (q  r))  (p  r)
 Disjunctive syllogism ((p  q)  ¬p)  q
 Addition p  (p  q)
 Simplification (p  q)  p
 Conjunction ((p)  (q))  (p  q)
 Resolution (p  q)  (¬p  r)  (q  r)
2017/11/13 CSE, NCHU 31
Inference rules (3/3)
 Universal instantiation
x P(x)  P(c) for any element c
 Universal generalization
P(c) for an arbitrary c  x P(x)
 Existential instantiation
x P(x)  P(c) for some element c
 Existential generalization
P(c) for some element c  x P(x)

2017/11/13 CSE, NCHU 32


Using Rules of Inference to
build Arguments
• Using rules of inference to build arguments:
It is not sunny this afternoon and it is colder than yesterday.
We will go swimming only if it is sunny.
If we do not go swimming, then we will take a canoe trip.
If we take a canoe trip, then we will be home by sunset.
• The conclusion is “we will be home by sunset”
p: It is sunny this afternoon
q: it is colder than yesterday
r: we will go swimming
s: we will take a canoe trip
t: we will be home by sunset
(1) ¬ p  q  ¬ p simplification
(2) r  p  ¬ r modus tollens
(3) ¬ r  s  s modus ponens
(4) s  t  t modus ponens
2017/11/13 CSE, NCHU 33
Literal, Clause, and Resolution
 A variable or negation of a variable is called a literal.
 A disjunction of literals is called a sum and a
conjunction of literals is called a product.
 A Clause is a disjunction of literals, i.e. it is a sum.
 In the resolution rule: ((p  q)  (¬p  r))  (q  r),
(q  r) is called the resolvent.
 For any two clauses C1 and C2, if there is a literal L1
in C1 which is complementary to a literal L2 in C2 then
delete L1 and L2 from C1 and C2 respectively, we have
a resolvent.
2017/11/13 CSE, NCHU 34
Resolution Principle
 Definition: Given two clauses C1 and C2, a
resolvent C is a logical consequence of C1 and C2.
 The resolution principle Given a set S of clauses, a
resolution deduction of C from S is a finite sequence
C1, C2 ,.., Ck of clauses such that Ci is either a clause
in S or a resolvent of clauses preceding C and C K= C.
A deduction of empty clause is called a refutation or
a (an inconsistent) proof of S.
 Consequently, for premises P1,…, Pn, and conclusion
C, if put P1,…, Pn in clauses form and add it to ¬C,
then we should get an empty clause.
2017/11/13 CSE, NCHU 35
Examples of Resolutions
 Show the following argument is correct.
If today is Tuesday, I have a test in Math. or Economics.
If my Economics Professor is sick, I will not have a test in
Economics. Today is Tuesday and Economics Professor is
sick. Therefore, I have a test in Math.
 Proof Let T denote ‘today is Tuesday’
M denote ‘I have a test in Math.’
E denote ‘I have a test in Economics’
S denote ‘My Economics Prof. is sick’
we have T  (M  E), S  ¬E, T  S implies M.

2017/11/13 CSE, NCHU 36


Universal Modus Tollens
 Which rules are used in the following argument?
No man is an island. Manhattan is an island. Therefore,
Manhattan is not a man.

 Let M (x) be “x is a man”, I(x) be “x is an island”.


Domain of x is “all things”. The premises are:
x (M(x)  ¬I(x))
I(Manhattan) (Note that Manhattan is an instance)
Therefore, by universal modus tollens, we can conclude
that ¬M(Manhattan).

2017/11/13 CSE, NCHU 37


Remarks on  and 
 Verify whether the followings are true or not :
(i) x (P(x)  Q(x)) ≡ x P(x)  x Q(x) D={2,3}
(ii) x (P(x)  Q(x)) ≡ x P(x)  x Q(x) (T)
(iii) x (P(x)  Q(x)) ≡ x P(x)  x Q(x) (T)
(iv) x (P(x)  Q(x)) ≡ x P(x)  x Q(x) D={1,2,3,5}

Think about the domain is {all prime numbers} or integers.


P(x) denotes “x is a multiple of 2” or Even numbers
Q(x) denotes “x is a multiple of 3” or Odd numbers
2017/11/13 CSE, NCHU 38
First-Order Logic
For a fixed vocabulary Γ, each formula of first-
order logic (FO) is a string of symbols taken from
the alphabet consisting of:
1. v1, v2, … variables
2. ¬ and  for not and or
3.  existential quantifier
4. =, (,), equality and parentheses
And, all symbols are in Γ.

2017/11/13 CSE, NCHU 39


MEMO
 Read section 1.4, 1.5, and 1.6
 Why from propositions, predicates, to rules of
inference? For what?
 Get familiar with Modus ponens, Modus tollens,
and Resolution.
 Practice translating English sentences to
predicate logic statements by applying rules of
inference
 HW #6,7,9,15,17,18,21-27,31 of §1.4, #9-11,15-
17,21,23,24 of §1.5, #9,13-16 of §1.6 40
2017/11/13 CSE, NCHU

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy