Title: University of Aberdeen, Computing Science CS3511 Discrete Methods Kees van Deemter
1University of Aberdeen, Computing
ScienceCS3511Discrete MethodsKees van Deemter
- Slides adapted from Michael P. Franks Course
Based on the TextDiscrete Mathematics Its
Applications (5th Edition)by Kenneth H. Rosen
2Module 1Part 2 Predicate Logic
- Rosen 5th ed., 1.3-1.4 (but much extended)
- 135 slides, 5 lectures
3Predicate Logic (1.3)
Topic 3 Predicate Logic
- We can use propositional logic to prove that
certain real-life inferences are valid. - If its cold then it snows.
- If it snows there are accidents
- There are no accidents. Therefore
- Its not cold
- In propositional logic
- ((c?s ?s?a ??a) ??c) is a tautology
4Predicate Logic (1.3)
Topic 3 Predicate Logic
- In propositional logic
- (((c?s) ?(s?a) ??a) ??c) is a tautology
- Saying this differently,It follows by
propositional logic from(c?s) ?(s?a) ??a
(premisse) that ?a (conclusion)
5Predicate Logic (1.3)
Topic 3 Predicate Logic
- But other valid inferences cannot be proven valid
by propositional logic - Some girl is adored by everyone. Therefore
- Everyone adores someone
- For inferences like this, we need a more
expressive logic - Needed treatment of some and every(a bit
analogous to or and and)
6Predicate Logic (1.3)
Topic 3 Predicate Logic
- Predicate logic is an extension of propositional
logic that permits quantification over classes of
entities. - Propositional logic (recall) treats simple
propositions (sentences) as atomic entities. - In contrast, predicate logic distinguishes the
subject of a sentence from its predicate.
7Applications of Predicate Logic
Topic 3 Predicate Logic
- It is one of the most-used formal notations for
writing mathematical definitions, axioms, and
theorems. - For example, in linear algebra, a partial order
is introduced saying that a relation R is
reflexive and transitive and these notions are
defined using predicate logic.
8Practical Applications of Predicate Logic
Topic 3 Predicate Logic
- Basis for many Artificial Intelligence systems.
- E.g. automatic program verification systems.
- Predicate-logic like statements are supported by
some of the more sophisticated database query
engines - There are also problems/limitations associated
with using predicate logic. More about that
later
9First A bit of grammar
Topic 3 Predicate Logic
- In the sentence The dog is sleeping
- The phrase the dog denotes the subject - which
the sentence is about. - The phrase is sleeping denotes the predicate- a
property that is true of the subject. - Predicate logic will follow the same pattern.
10Formulas of predicate logic (informal)
Topic 3 Predicate Logic
- We will use various kinds of individual constants
that denote individuals/objects a,b,c, - Constants are a bit like names
- Individual variables over objects x, y, z ,
- The result of applying a predicate P to
aconstant a is the proposition P(a)Meaning the
object denoted by a has the property denoted by P.
11Formulas of predicate logic (informal)
Topic 3 Predicate Logic
- The result of applying a predicate P to
avariable x is the propositional form P(x). - E.g. if P is a prime number, then P(x) is
the propositional form x is a prime number.
12Predicates/relations with n places
Topic 3 Predicate Logic
- Predicate logic generalises the notion of a
predicate to include propositional functions of
any number of arguments. E.g. - R(x,y) x adores y
- P(x,y,z) x gave y the grade z
- Q(x,y,z,u) x(yz)u
13Universes of Discourse (U.D.s)
Topic 3 Predicate Logic
- Predicate Logic lets you state things about many
objects at once. - E.g., let P(x) (x2) ? x . We can then
say,For any number x, P(x) is true instead
of(02 ? 0) ? (12 ? 1) ? (22 ? 2) ? ... - The collection of values that a variable x can
take is called xs universe of discourse.(u.d.
is something outside the formula that helps
giving it its intended interpretation.)
14Universes of Discourse (U.D.s)
Topic 3 Predicate Logic
- E.g., let P(x)x2 ? x. We can then say,For
any number x, P(x) is true instead of(02 ? 0)
? (12 ? 1) ? (22 ? 2) ? ... - Applying the notion of an u.d.
- For any number x, P(x) is true is true when
u.d. N - For any number x, P(x) is true is false when
u.d. Z
15Back to propositional logic
- In propositional logic, we could not simply say
whether a formula is TRUE what we could say is
whether it is TRUE with respect to a given
assignment of TRUE/FALSE to the Atoms in the
formula - E.g., p?q is TRUE with respect to the assignment
pTRUE, qTRUE
16Predicate logic
- In predicate logic, we say that a formula is TRUE
(FALSE) with respect to a model - Model u.d. plus specification of the meanings
of the predicates. This can be done e.g. - by giving an English equivalent of a predicate
- by listing explicitly which objects the
predicate is true of - ... as long the extension of the predicate is
clear.(By definition, this is the set of objects
in the u.d. for which the predicate holds.)
17Quantifier Expressions
Topic 3 Predicate Logic
- Quantifiers provide a notation that allows us to
quantify (count) how many objects in the u.d.
satisfy a given predicate. - ? is the FOR?LL or universal quantifier. ?
is the ?XISTS or existential quantifier. - For example, ?x P(x) and ?x P(x) are propositions
18Meaning of Quantified Expressions
Topic 3 Predicate Logic
- First, informally
- ?x P(x) means for all x in the u.d., P holds.
- ?x P(x) means there exist x in the u.d. (that is,
1 or more) such that P(x) is true.
19Example ?
Topic 3 Predicate Logic
- Let the u.d. be the parking spaces at UF.Let
P(x) mean x is full.Then the existential
quantification of P(x), ?x P(x), is the
proposition saying that - Some parking spaces at UF are full.
- There is a parking space at UF that is full.
- At least one parking space at UF is full.
20Example ?
Topic 3 Predicate Logic
- Let the u.d. be parking spaces at UF.Let P(x)
be the prop. form x is occupiedThen the
universal quantification of P(x), ?x P(x), is the
proposition - All parking spaces at UF are occupied.
- For each parking space at UF, that space is
full.
21Syntax of predicate logic (for 1- and 2-place
predicates)
- Variable x,y,z, Constants a,b,c,
- 1-place predicates P,Q,
- 2-place predicates R,S,
- Atomic formulas If ? is a 1-pace predicate and
? a variable or constant then ?(?) is an atomic
formula. - If ? is a 2-pace predicate and ? and ? are
variables or constants then ?(?,?) is an atomic
formula.
22Syntax of predicate logic (for 1- and 2-place
predicates)
- (Wellformed) Formulas
- All atomic formulas are formulas
- If ? and ? are formulas then ??, (? ??), (???),
(? ??) are formulas. - If ? is a formula then ?x ? and ?x ? are
formulas. (Likewise, ?y ? and ?y ?,and so on.) - This could be seen as overgenerating
- wellformed formulas somewhat
23Syntax of predicate logic (for 1- and 2-place
predicates)
- Show that these are wellformed formulas
- ?xP(x) ?yQ(x) ?x?y R(x,y) ?xP(b)
24Syntax of predicate logic (for 1- and 2-place
predicates)
- ?xP(x) ?yQ(x) ?x?y R(x,y) ?xP(b)
- P(x) is a (atomic) formula, hence ?xP(x) is a
formula - Q(x) is a (atomic) formula, hence ?yQ(x) is a
formula - R(x,y) is a (atomic) formula, hence ?y R(x,y) is
a formula, hence ?x?y R(x,y) is a formula - P(b) is a (atomic) formula, hence ?xP(b) is a
formula
25Syntax of predicate logic (for 1- and 2-place
predicates)
- Examples ?xP(x) and ?yQ(x), ?x(?y R(x,y)),
?x(?x R(x,y)), ?xP(b) etc. - Lots of pathological cases. For example,
- It will follow from the meaning of these formulas
that ?xP(b) is true iff P(b) is true - Rule of thumb a quantifier that does not bind
any variables can be ignored
26Free and Bound Variables
Topic 3 Predicate Logic
- An expression like P(x) is said to have a free
variable x (i.e., x is not defined). - A quantifier (either ? or ?) operates on an
expression having one or more free variables, and
binds one or more of those variables, to produce
an expression having one or more bound variables.
27Example of Binding
Topic 3 Predicate Logic
- P(x,y) has 2 free variables, x and y.
- ?x P(x,y) has 1 free variable, and one bound
variable. Which is which? - An expression with zero free variables is a
bona-fide (actual) proposition. - An expression with one or more free variables is
similar to a predicate e.g. let Q(y) ?x
Adore(x,y)
y
x
28Free variables, defined formally
Topic 3 Predicate Logic
- The free-variable occurrences in an Atom are all
the variable occurrences in that Atom - The free-variable occurrences in ?? are the
free-variable occurrences in ? - The free-variable occurrences in (? connective
?) are the free-variable occurrences in ? plus
the free-variable occurrences in ? - The free-variable occurrences in ?x? and ?x?
are the free-variable occurrences in ? except
for all/any occurrences of x.
29- Occurrences of variables that are not free are
bound. - Test your understanding Which (if any) variables
are free in - ?x ?P(x)
- ??x ?P(x)
- ?yQ(x)
- ?xP(b) (NB, b is a constant)
- ?x(?y R(x,y))
30- Occurrences of variables that are not free are
bound. - Check your understanding Which (if any)
variables are free in - ?x ?P(x) no free variables
- ??x ?P(x) no free variables
- ?yQ(x) x is free
- ?xP(b) (NB, b is a constant) no free var.
- ?x(?y R(x,y)) no free variables
31A more precise definition of the truth/falsity of
quantified formulas
Topic 3 Predicate Logic
- (Formulation is simplified somewhat because we
assume that every object in the u.d. D has a
name (i.e., a constant referring to it)). - First some notation ?(xa) is the result of
substituting all free occurrences of the variable
x in ? by the constant a
32Exercise
Topic 3 Predicate Logic
- Say what ?(xa) is, if ?
- P(x)
- R(x,y)
- P(b)
- ?x ?P(x)
- ?yQ(x)
33Exercise
Topic 3 Predicate Logic
- Say what ?(xa) is, if ?
- P(x) ..... P(a)
- R(x,y) .... R(a,y)
- P(b) ..... P(b)
- ?x ?P(x) ...... ?x ?P(x)
- ?yQ(x) ...... ?yQ(a)
34A more precise definition of the truth/falsity of
quantified formulas
Topic 3 Predicate Logic
- (Formulation is simplified somewhat because we
assume that every object in the u.d. has a
name (i.e., a constant referring to it)). - Let ? be a formula. Then ?x? is true in D if at
least one expression of the form ?(xa) is true
in D, and false otherwise. (a can be any
constant)
35A more precise definition
Topic 3 Predicate Logic
- Let ? be a formula. Then ?x? is true in D if at
least one expression ?(xa) is true in D, and
false otherwise. - A simple example ? P(x)
- P(x) is a formula, hence ?x P(x) is true in D if
at least one expression of the form P(a) is true
in D, and false otherwise.
36Similarly for ?
Topic 3 Predicate Logic
- Let ? be a formula. Then the proposition ?x? is
true in D if every expression of the form ?(xa)
is true in D, and false otherwise. - A simple example ? P(x)
- P(x) is a formula, hence ?x P(x) is true in D
if every expression P(a) is true in D, and false
otherwise.
37Complex formulas
Topic 3 Predicate Logic
- Example Let the u.d. of x and y be people.
- Let L(x,y)x likes y (a predicate w. 2 f.v.s)
- Then ?y L(x,y) There is someone whom x likes.
(A predicate w. 1 free variable, x) - Then ?x (?y L(x,y)) Everyone has someone whom
they like. - (a real proposition no free variables left)
38Consequences of Binding (work out for yourself by
checking when each formula is true)
Topic 3 Predicate Logic
- ?x ?x P(x) - x is not a free variable in ?x
P(x), therefore the ?x binding isnt used,as it
were. - (?x P(x)) ? Q(x) - The variable x is outside of
the scope of the ?x quantifier, and is therefore
free. Not a complete proposition! - (?x P(x)) ? (?x Q(x)) A complete proposition,
and no superfluous quantifiers
39Nested quantifiers
- Assume S(x,y) means x sees y
- u.d.all people
- What does the following formula mean?
- ?xS(x,a)
40Nested quantifiers
- Assume S(x,y) means x sees y.
- u.d.all people
- ?xS(x,a) means For every x, x sees a
- In other words,Everyone sees a
41Nested quantifiers
- What does the following formula mean?
- ?x(?y S(x,y))
42Nested quantifiers
- ?x(?y S(x,y)) means For every x, there exists a
y such that x sees y - In other words Everyone sees someone
43Quantifier Exercise
Topic 3 Predicate Logic
- If R(x,y)x relies upon y, express the
following in unambiguous English - ?x(?y R(x,y))
- ?y(?x R(x,y))
- ?x(?y R(x,y))
- ?y(?x R(x,y))
- ?x(?y R(x,y))
Everyone has someone to rely on.
Theres a poor overburdened soul whom everyone
relies upon (including himself)!
Theres some needy person who relies upon
everybody (including himself).
Everyone has someone who relies upon them.
Everyone relies upon everybody, (including
themselves)!
44Quantifier Exercise
Topic 3 Predicate Logic
- R(x,y)x relies upon y. Suppose the u.d. is
- not empty. Now consider these formulas
- ?x(?y R(x,y))
- ?y(?x R(x,y))
- ?x(?y R(x,y))
- Which of them is most informative?
- Which of them is least informative?
45Quantifier Exercise
Topic 3 Predicate Logic
- (Recall the u.d. is not empty. Empty u.d.s are
discussed later.) - ?x(?y R(x,y)) Least informative
- ?y(?x R(x,y))
- ?x(?y R(x,y)) Most informative
- If 3 is true then 2 must also be true.
- If 2 is true then 1 must also be true.
- We say 3 is logically stronger than 2 than 1
46logically stronger than
- General ? is logically stronger than ? iff
- it is not possible for ? to be true and ? false
- it is possible for ? to be true and ? false
- E.g. ? John is older than 30, ? John
is older than 20. - We write iff for if and only if
47Natural language is ambiguous!
Topic 3 Predicate Logic
- Everybody likes somebody.
- For everybody, there is somebody they like,
- ?x ?y Likes(x,y)
- or, there is somebody (a popular person) whom
everyone likes? - ?y ?x Likes(x,y)
Probably more likely.
48Interactions between quantifiers and connectives
- Let the u.d. be parking spaces at UF.
- Let P(x) be x is occupied.
- Let Q(x) be x is free of charge.
- ?x (Q(x) ? P(x))
- ?x (Q(x) ? P(x))
- ?x (Q(x) ?P(x))
- ?x (Q(x) ? P(x))
49I. Construct English paraphrases
- Let the u.d. be parking spaces at UF.
- Let P(x) be x is occupied.
- Let Q(x) be x is free of charge.
- ?x (Q(x) ? P(x))
- ?x (Q(x) ? P(x))
- ?x (Q(x) ?P(x))
- ?x (Q(x) ? P(x))
50I. Construct English paraphrases
- ?x (Q(x) ? P(x)) Some places are free of charge
and occupied - ?x (Q(x) ? P(x)) All places are free of charge
and occupied - ?x (Q(x) ?P(x)) All places that are free of
charge are occupied - ?x (Q(x) ? P(x)) For some places x, if x is free
of charge then x is occupied
51About the last of these
- 4. ?x (Q(x) ? P(x)) For some x, if x is free
of charge then x is occupied ?x (Q(x) ? P(x))
is true iff, for some place a, Q(a) ? P(a) is
true. Q(a) ? P(a) is true iff Q(a) is false
and/or P(a) is true (conditional is only
false in one row of table!) Some places are
either (not free of charge) and/or occupied
52About the last of these
- ?x (Q(x) ? P(x)) When confused by a conditional
re-write it using negation and disjunction ?x
(?Q(x) ? P(x)) ?? (p. 67) ?x ?Q(x) ? ?x P(x)
Some places are not free of charge or some
places are occupied
53- Combinations to remember
- ?x (Q(x) ? P(x))
- ?x (Q(x) ?P(x))
54II. Construct a model where 1 and 4 are true,
while 2 and 3 are false
- Let the u.d. be parking spaces at UF.
- Let P(x) be x is occupied.
- Let Q(x) be x is free of charge.
- ?x (Q(x) ? P(x))
- ?x (Q(x) ? P(x))
- ?x (Q(x) ?P(x))
- ?x (Q(x) ? P(x))
55II. Construct a model where 1 and 4 are true,
while 2 and 3 are false
- ?x (Q(x) ? P(x)) (true for place a below)
- ?x (Q(x) ? P(x)) (false for places b below)
- ?x (Q(x) ?P(x)) (false for place b below)
- ?x (Q(x) ? P(x)) (true for place a below)
- One solution a model with exactly two objects in
it. One object has the property Q and the
property P the other object has the property Q
but not the property P. In a diagram -
- a Q P b Q not-P
56III. Construct a model where 1 and 3 and 4 are
true, but 2 is false
- ?x (Q(x) ? P(x))
- ?x (Q(x) ? P(x))
- ?x (Q(x) ?P(x))
- ?x (Q(x) ? P(x))
- Here is such a model (using a diagram). It has
just two objects in its u.d., called a and b -
- a Q P b not-Q P
-
57Quantifier Equivalence Laws
Topic 3 Predicate Logic
- Expanding quantifiers If u.d.a,b,c, ?x P(x) ?
P(a) ? P(b) ? P(c) ? ?x P(x) ? P(a) ? P(b) ?
P(c) ? - From those, we can prove the laws?x P(x) ?
??x ?P(x)?x P(x) ? ??x ?P(x) - Which propositional equivalence laws can be used
to prove this?
DeMorgan's
58Remember
- In propositional logic, we can strictly speaking
only build formulas of finite size. - E.g., we can write P(a) ? P(b) P(a) ? P(b) ?
P(c) P(a) ? P(b) ? P(c) ? P(d) , etc. - But this way, we could never say that all natural
numbers have P
59Formulas of infinite length?
- In predicate logic, you can say this easily
?xP(x) - Its sometimes useful to pretend that
propositional logic allows infinitely long
formulas, but in the official version this is
not possible.
60More Equivalence Laws
Topic 3 Predicate Logic
- ?x ?y P(x,y) ? ?y ?x P(x,y)?x ?y P(x,y) ? ?y ?x
P(x,y) - ?x (P(x) ? Q(x)) ? (?x P(x)) ? (?x Q(x))?x (P(x)
? Q(x)) ? (?x P(x)) ? (?x Q(x))
61More Equivalence Laws
Topic 3 Predicate Logic
- ?x ?y P(x,y) ? ?y ?x P(x,y)?x ?y P(x,y) ? ?y ?x
P(x,y) - ?x (P(x) ? Q(x)) ? (?x P(x)) ? (?x Q(x))?x (P(x)
? Q(x)) ? (?x P(x)) ? (?x Q(x)) - Lets prove the last of these equivalences using
the definition of the truth of a formula of the
form ?x f
62A Pred. Log. equivalence proven
Topic 3 Predicate Logic
- ?x (P(x) ? Q(x)) ? (?x P(x)) ? (?x Q(x))Proof
? Suppose ?x (P(x) ? Q(x)) is true. So, there
is a constant a such that (P(x) ? Q(x)) (xa) is
true. So, for that a, the formula P(a) ? Q(a) is
true. One possibility is that P(a) is true. In
this case, P(x)(xa) is true. So, ?x P(x) is
true, so (?x P(x)) ? (?x Q(x)) is true. The other
possibility is that Q(a) is true. In this case,
Q(x)(xa) is true. So, ?x Q(x) is true, so (?x
P(x)) ? (?x Q(x))is true.
63A Pred. Log. equivalence proven
Topic 3 Predicate Logic
- ?x (P(x) ? Q(x)) ? (?x P(x)) ? (?x Q(x))Proof
? Suppose (?x P(x)) ? (?x Q(x)) is true. One
possibility is that ?x P(x) is true. This would
mean that there is an a such that P(x) (xa) is
true. So, for that constant a, P(a) is
true.Therefore, P(a) ? Q(a) would also be true.
Hence, (P(x) ? Q(x))(xa) would be true. Hence,
?x (P(x) ? Q(x)) would be true. The other
possibility is that ?x Q(x). From this, ?x (P(x)
? Q(x)) is proven in the same way QED
64More Equivalence Laws
Topic 3 Predicate Logic
- ?x ?y P(x,y) ? ?y ?x P(x,y)?x ?y P(x,y) ? ?y ?x
P(x,y) - ?x (P(x) ? Q(x)) ? (?x P(x)) ? (?x Q(x))?x (P(x)
? Q(x)) ? (?x P(x)) ? (?x Q(x)) - How about this one?
- ?x (P(x) ? Q(x)) ? (?x P(x)) ? (?x Q(x))?
65More Equivalence Laws
Topic 3 Predicate Logic
- How about this one?
- ?x (P(x) ? Q(x)) ? (?x P(x)) ? (?x Q(x)) ?
- This equivalence statement is false.
Counterexample (i.e. model making this false) - P(x) xs birthday is on 30 AprilQ(x) xs
birthday is on 20 December
66Cases to think carefully about
- Lets discuss some specific cases
- These might seem unusual, but its
important not to loose your way when they occur - Quantifiers that dont bind any variables
- Quantification in an empty u.d.
- ?x (Q(x) ?P(x)) when ??yQ(y)
671. Quantifiers that do not bind ?xP(b)
- Recall definition Let ? be a formula. Then ?x?
is true in D if every expression ?(xa) is true
in D, and false otherwise. - ?xP(b) is true in D if every expression of the
form P(b)(xa) is true in D, and false
otherwise. - What is the set of all the expression of the form
P(b)(xa)?
68Consider ?xP(b)
- What is the set of all the expression of the form
P(b)(xa)? - Thats the singleton set P(b) ! So,
- ?xP(b) is true in D if P(b) is true, and false
otherwise. - So, ?xP(b) means just P(b)
692. Empty u.d. We defined
- Let ? be a formula. Then the proposition ?x? is
true in D if every expression ?(xa) is true in
D, and false otherwise. - This is read as follows
- Let ? be a formula. Then the proposition ?x? is
false in D if at least one expression ?(xa) is
false in D, and true otherwise.
70? could have been defined differently. For
example,
- Let ? be a formula. Then the proposition ?x? is
true in D if D is nonempty and every expression
?(xa) is true in D, and false otherwise. - Under this definition, ?x P(x) would have been
false whenever D is empty (e.g., when there are
no parking spaces at U.F., and P occupied) - But thats not how its done!
71Suppose D is empty
- Suppose the u.d. is empty. Consider
- ?x P(x) (e.g., P(x) means x is occupied.)
- This counts as true. (Sometimes called vacuously
true) - For the same reason,
- ?x ?P(x) is also true
72Consequences of the standard position
- Two logical equivalences in Predicate Logic
- ?x P(x) ? ??x ?P(x) (no counterexample against
P) - ?x P(x) ? ??x ?P(x)
- So, one of the two quantifiers suffices (cf.,
functional completeness of a set of connectives
in propositional logic) - Well return to these equivalences later.
733. ?x (Q(x) ?P(x)) when ??yQ(y)
74When many implications are combined
- Consider the formula r ?x (Q(x) ?P(x)) with
respect to a nonempty u.d. - Suppose ??yQ(y)
- (For example, Q might mean being more than 4
meters tall) - Can you work out whether r is true?
75When many implications are combined
- Consider ?x (Q(x) ?P(x)) in a nonempty u.d.
- Suppose, however, ??yQ(y)
- Then Q(a) ?P(a) is true for every a (since Q(a)
is false for every a) - Consequently ?x (Q(x) ?P(x)) is true
- Once again, we sometimes say it is vacuously
true (because the antecedent is always false, so
you can never use the formula to conclude that P
holds of something).
76Vacuous truth
- Example 1 Think of a tax form Have you sent us
details about all your children? No children ?
Youve complied (without doing anything) - Example 2 Think of our definition of ?(xa) as
the result of substituting all free occurrences
of x in ? by aNo occurrences ? dont do
anything (after which its true that all
occurrences have been substituted)
77Some consequences of these definitions
- Sometimes, predicate logic is taught very
informally - This makes it easy to understand simple formulas
- But each more complex case has to be explained
separately, as if it was an exception - By defining things properly once, complex
formulas fall out as special cases - One example quantifier nesting
78Back to Quantifier Exercise
Topic 3 Predicate Logic
- R(x,y)x relies upon y. Suppose the u.d. is
- empty. Now consider these formulas
- ?x(?y R(x,y))
- ?y(?x R(x,y))
- ?x(?y R(x,y))
- Which of them is most informative?
- Which of them is least informative?
79Back to our Quantifier Exercise
Topic 3 Predicate Logic
- Now that the u.d. is empty,
- ?x(?y R(x,y)) is uninformative
- ?y(?x R(x,y)) is false!
- ?x(?y R(x,y)) is uninformative
- ?x(P(x)) is true if P(a) is true for all a.
- If no x exist then this makes ?x(P(x))
(vacuously) true - ?x(P(x)) is true if P(a) is true for some a.
- If no x exist then this makes ?x(P(x)) false.
80Back to models Look at the old formula 3 again
- 3. ?x (Q(x) ?P(x)) Consider this model
-
- a ?Q P b ?Q?P
- c?Q P d ?Q?P
- Is the proposition true or false in the model?
81Look at formula number 3 again
- 3. ?x (Q(x) ?P(x)) is true in this model
-
- a ?Q P b ?Q?P
- c?Q P d ?Q?P
- (3) Is true iff each of these is true ?x (Q(a)
?P(a)) ?x (Q(b) ?P(b)) ?x (Q(c) ?P(c)) ?x
(Q(d) ?P(d))
82Look at formula number 3 again
- 3. ?x (Q(x) ?P(x)) is true in this model
-
- a ?Q P b ?Q?P
- c?Q P d ?Q?P
- (3) Is true because each of these is true Q(a)
?P(a) F T, hence T Q(b) ?P(b) F F, hence T
Q(c) ?P(c) F T, hence T Q(d) ?P(d) F F,
hence T
83Predicate Logic essentials
- Predicates of different arity (one-place,
two-place, etc.) - Quantifiers ?x P(x) For all x, P(x). ?x
P(x) There is/are x such that P(x). - Universes of discourse, bound free vars.
- The rest follows empty domains, quantified
implications, quantifier nesting
84Some common shorthands
Topic 3 Predicate Logic
- Sometimes the universe of discourse is restricted
within the quantification, e.g., - ?xgt0 P(x) is shorthand forFor all x that are
greater than zero, P(x). - How would you write this in formal notation?
85Some common shorthands
Topic 3 Predicate Logic
- Sometimes the universe of discourse is restricted
within the quantification, e.g., - ?xgt0 P(x) is shorthand forFor all x that are
greater than zero, P(x).?x (xgt0 ? P(x))
86Some common shorthands
Topic 3 Predicate Logic
- Sometimes the universe of discourse is restricted
within the quantification, e.g., - ?xgt0 P(x) is shorthand forFor all x that are
greater than zero, P(x).?x (xgt0 ? P(x)) - ?xgt0 P(x) is shorthand forThere is an x greater
than zero such that P(x).?x (xgt0 ? P(x))
87Some common shorthands
Topic 3 Predicate Logic
- Consecutive quantifiers of the same type can be
combined ?xyz P(x,y,z) ?def ?x ?y ?z P(x,y,z)
?xyz P(x,y,z) ?def ? x ? y ? z P(x,y,z)
88Theorems about logic
- We are studying logical languages/calculi to
allow you to use them (better) - Logicians study logical languages/calculi to
understand their limitations - Meta-theorems can, e.g., say things like
cannot be expressed in predicate logic
89Theorems about logic
- About propositional logic, we asked What types
of things can we express? How many connectives
do we need? - About predicate logic, logicians ask similar
questions. For example, are these two quantifiers
enough to be able to say everything? - This is a question about the expressive power of
predicate logic
90Example one
- As per their name, quantifiers can be used to
express that a predicate is true of a given
quantity (number) of objects. - Example Can predicate logic say there exists at
most one object with property P?
91Example at most one
- Example Can predicate logic say there exists at
most one object with property P? - Yes (provided we have equality)
- ?x?y ((P(x) ? P(y)) ? x y)
92Example one
- Can predicate logic say there exists exactly one
object with property P?
93Example one
- Can predicate logic say there exists exactly one
object with property P? ?xP(x) ? ?x?y((P(x)
?P(y))?x y) - There exist x such that P(x) andThere exists
at most one x such that P(x) - Abbreviation ?!x P(x)(there exists exactly one
x such that P(x))
94Example one
- Another way to write this
- ?x (P(x) ? ??y (P(y) ? y? x))There is an x such
that P(x), such that there is no y such that P(y)
and y? x. - ?x binds x throughout the conjunction?x (P(x) ?
??y (P(y) ? y? x))
95At least two
- Can predicate logic say there exist at least two
objects with property P?
96At least two
- Can predicate logic say there exist at least two
objects with property P? - Yes?x ?y ((P(x) ? P(y)) ? x? y)
- Incorrect would be ?xP(x) ? ?y(P(y) ? x?
y),(where x occurs free, and whichtherefore
does not express a proposition)
97Exactly two
- Can predicate logic say there exist exactly two
objects with property P?
98Exactly wo
- Can predicate logic say there exist exactly two
objects with property P? - Yes
- ?x ?y (P(x) ? P(y) ? x? y ? ?z
(P(z) ? (z x ? z y) ))
99Whats wrong with
- ?x ?y (P(x) ? P(y) ? x? y) ? ?z (P(z) ? (z x ?
z y ))as a formalisation of exactly two?
100Whats wrong with
- ?x ?y (P(x) ? P(y) ? x? y) ? ?z (P(z) ? (z x ?
z y ))as a formalisation of exactly two? - This is a conjunction of two separate
propositions. As a result, x and y are not bound,
so this is not even a proposition
101infinitely many
- Can predicate logic say there exist infinitely
many objects with property P? - No! This follows from the so-called Compactness
Theorem An infinite set S of formulas has a
model iff every finite subset of S has a model - How about finitely many?
102finitely many
- How about finitely many?
- Suppose there existed a formula ? there exist
only finitely many x such that so and so - Then ?? there exist infinitely many x such
that so and so - We know that such a formula does not exist
- So, also ? does not exist
103- (Of course if we allow infinite conjunctions
then all this can be expressed?!x P(x) ? ?2!x
P(x) ? ?3!x P(x) ? )
104- Can predicate logic say most objects have
property P? - No! This follows from the Compactness Theorem as
well. Again, this is unless we allow infinitely
long disjunctions. - Can predicate logic say many objects have
property P? - No, only precisely defined quantities
105Decidability
- Weve shown you two ways of checking
propositional-logic equivalencies - Checking truth tables
- Using equivalence laws
- Youve seen how (1) can be done algorithmically.
- This shows that checking propositional logic
equivalence is decidable
106Decidability
- Checking proplog equivalence is decidable
- Checking predlog equivalence is not
decidableTherefore, theorem proving will always
remain an art (for both computers and humans) - Some fragments of predlog are decidable. One
application PROLOG
107Bonus Topic Logic Programming
- Some programming languages are based entirely on
(a part of) predicate logic - The most famous one is called Prolog.
- A Prolog program is a set of propositions
(facts) and (rules) in predicate logic. - The input to the program is a query
proposition. - Want to know if it is true or false.
- The Prolog interpreter does some automated
deduction to determine whether the query follows
from the facts.
108Facts in Prolog
- A fact in Prolog represents a simple,
non-compound proposition in predicate logic. - E.g., likes(john,mary)
- Lowercase symbols are used for constants and
predicates, uppercase is used for variables.
109Rules in Prolog
- A rule in Prolog represents a universally
quantified proposition of the general form ?x?y
(P(x,y)?Q(x)),where x and y are variables, P a
possibly compound predicate, and Q an atomic
proposition. - In Prolog q(X) - p(X,Y).
- i.e., the ?,? quantifiers are implicit.
- Example likable(X) - likes(Y,X).
110Rules in Prolog
- Note that ?x?y (P(x,y)?Q(x))is equivalent to
?x((?y P(x,y)?Q(x)) - In other words, Q(x) holds if you can find a y
such that P(x,y)
111Conjunction and Disjunction
- Logical conjunction is encoded using multiple
comma-separated terms in a rule. - Logical disjunction is encoded using multiple
rules. - E.g., ?x ((P(x)?Q(x))?R(x))?S(x) can be rendered
in Prolog as - s(X) - p(X),q(X)
- s(X) - r(X)
112Deduction in Prolog
- When a query is input to the Prolog interpreter,
- it searches its database to determine if the
query can be proven true from the available
facts. - if so, it returns yes, if not, no (!)
- If the query contains any variables, all values
that make the query true are printed.
113Simple Prolog Example
- An example input program
- likes(john,mary).
- likes(mary,fred).
- likes(fred,mary).
- likable(X) - likes(Y,X).
- An example query ? likable(Z)returns ...
114Simple Prolog Example
- An example input program
- likes(john,mary).
- likes(mary,fred).
- likes(fred,mary).
- likable(X) - likes(Y,X).
- An example query ? likable(Z)returns
mary fred
115Relation between PROLOG and Predicate Logic
- PROLOG cannot use all predicate logic formulas.
(It covers a decidable fragment of predicate
logic.) - It uses negation as failure
- Based on these limitations, PROLOG-based
deduction is decidable. - PROLOG is more than just logic (I/O, cut!), but
logic is its hard core.
116Deduction Example (as appetiser for the next
lecture)
Topic 3 Predicate Logic
- Premises
- ?x H(x) ? M(x) (e.g. Humans are mortal)
- ?x G(x) ? ?M(x) (Gods are immortal).
- Suppose you need to prove the Conclusion ??x
(H(x) ? G(x)) (No human is a god.)
117A semantic proof in informal style
Topic 3 Predicate Logic
- ?x (H(x) ? M(x)) (Humans are mortal) and
- ?x (G(x) ? ?M(x)) (Gods are immortal).
- Suppose ?x (H(x) ? G(x)). For example,
- H(a) ? G(a). Then
- By the first premisse, we have M(a).
- By the second premisse, we have ?M(a).
- Contradiction! Therefore, it follows that
- ??x (H(x) ? G(x)) (No human is a god.)
118Alternative proof, using equivalences
Topic 3 Predicate Logic
- ?x (H(x)?M(x)) and ?x (G(x)??M(x)).
- ?x (?M(x)??H(x)) Contrapositive.
- ?x (G(x)??M(x) ? ?M(x)??H(x))
- ?x (G(x)??H(x)) Transitivity of ?.
- ?x (?G(x) ? ?H(x)) Definition of ?.
- ?x ?(G(x) ? H(x)) DeMorgans law.
- ??x (G(x) ? H(x)) An equivalence law.
119Bonus Number Theory Examples
Topic 3 Predicate Logic
- Let u.d. the natural numbers 0, 1, 2,
- What do the following mean?
- ?x (E(x) ? (?y x2y))
- ?x (P(x) ? (xgt1 ? ??yz xyz ? y?1 ? z?1))
120Bonus more Number Theory Examples
Topic 3 Predicate Logic
- Let u.d. the natural numbers 0, 1, 2,
- A number x has the property E if and only if it
is equal to 2 times some other number.
(even!)?x (E(x) ? (?y x2y)) - A number has P, iff its greater than 1 and it
isnt the product of any non-unity numbers.
(prime!) - ?x (P(x) ? (xgt1 ? ??yz xyz ? y?1 ? z?1))
121Goldbachs Conjecture (unproven)
Topic 3 Predicate Logic
- Using E(x) and P(x) from previous slide,
- ?x( xgt2 ? E(x) ?
- ?p ?q P(p) ? P(q) ? pq x).
122Goldbachs Conjecture (unproven)
Topic 3 Predicate Logic
- Using E(x) and P(x) from previous slide,
- ?x( xgt2 ? E(x) ?
- ?p ?q P(p) ? P(q) ? pq x).
- Every even number greater than 2 is the sum of
two primes.
123Game Theoretic Semantics
Topic 3 Predicate Logic
- Thinking in terms of a competitive game can help
you tell whether a proposition with nested
quantifiers is true. - The game has two players, both with the same
knowledge - Verifier Wants to demonstrate that the
proposition is true. - Falsifier Wants to demonstrate that the
proposition is false. - The Rules of the Game Verify or Falsify
- Read the quantifiers from left to right, picking
values of variables. - When you see ?, the falsifier gets to select
the value. - When you see ?, the verifier gets to select the
value. - If the verifier can always win, then the
proposition is true. - Otherwise it is false.
124Lets Play, Verify or Falsify!
Topic 3 Predicate Logic
Let B(x,y) xs birthday is followed within
14 days
by ys birthday.
Suppose I claim that among you ?x ?y B(x,y)
Your turn, as falsifier You pick any x ?
(so-and-so)
?y B(so-and-so,y)
My turn, as verifier I pick any y ?
(such-and-such)
B(so-and-so,such-and-such)
125Summing up strict Predicate Logic without
extensions and simplified notations
Topic 3 Predicate Logic
- Syntax definition
- Variable x,y,z, Constants a,b,c,
- 1-place predicates P,Q,
- 2-place predicates R,S,
- Atomic formulas If ? is a 1-pace predicate and
? a variable or constant then ?(?) is an atomic
formula. - If ? is a 2-pace predicate and ? and ? are
variables or constants then ?(?,?) is an atomic
formula. and so on for 3-place, etc.
126Syntax of predicate logic (for 1- and 2-place
predicates)
- (Wellformed) Formulas
- All atomic formulas are formulas
- If ? and ? are formulas then ??, (? ??), (???),
(? ??) are formulas. - If ? is a formula then ?x ? and ?y ? are
formulas.
127Semantics of predicate logic(this time using
models)
- The truth conditions for propositional logic
connectives are as specified in their truth-table
definitions - ?x? is true with respect to a model if at least
one expression ?(xa) is true with respect to
the model, and false otherwise. - ?x? is true with respect to a model if every
expression ?(xa) is true with respect to the
model, and false otherwise
128Semantics of predicate logic(using models in a
more precise way)
- Observe Effectively, the meaning of formulas is
defined via rules of the form ... is true iff
.... This is called a truth definition. - For those of you who like a formal treatment of
truth definitions, in which the role of models is
made mathematically more explicit, here goes ...
129Formally what is a model?
- A model M is a pair ltD,Igt where D is a set (an
u.d.), and I is a suitable interpretation
function. Informally speaking, a given M defines
one way of giving a concrete meaning to the
symbols (other than ??????) in your formulas. - If a is an individual constant then I(a)?D
- If P is a 1-place predicate then I(P)?D
- If R is a 2-place predicate then I(P) is a set of
pairs (?,?) such that ? ?D, and ? ?D
130- (This way to specify the meaning of a
2-place predicate will become clearer after
the lectures about relations. An example
might help )
131An example of a model
- Suppose M (D,I) where DJohn,Mary,Bill and
I(j)John, I(m)Mary, I(b)Bill,
I(B)John,BillI(G)MaryI(A)(John,Mary),(Bi
ll,Mary) - Note John is a person (i.e., a part of the
world)j is an individual constant (i.e., a part
of the language of predicate logic). j names
John.
132Formally (where M ltD,Igt) atomic formulas
- Here is the start of the new truth definition
- A formula of the form P(a) is true with respect
to M iff I(a) ? I(P). - A formula of the form R(a,b) is true with
respect to M iff (I(a),I(b)) ? I(R).
133Formally (where M ltD,Igt) formulas with
propositional connectives
- A formula of the form ?? is true wrt M iff ? is
false wrt M - A formula of the form ??? is true wrt M iff ? is
true wrt M or ? is true wrt M or both - A formula of the form ??? is true wrt M iff ? is
true wrt M and ? is true wrt M - A formula of the form ? ? ? is true wrt M iff ?
is false wrt M or ? is true wrt M or both
134Formally (where M ltD,Igt) quantified formulas
- A formula of the form ?x? is true wrt M iff at
least one expression ?(xa) is true wrt M.
(More precisely there is an a such that ...) - A formula of the form ?x? is true wrt M iff all
expressions ?(xa) are true wrt M. (More
precisely for all a, ...) - (End of truth definition.)
135models some illustrations
- Suppose M (D,I) , where DJohn,Mary,Bill, and
I(j)John, I(m)Mary, I(b)Bill,
andI(B)John,BillI(G)MaryI(A)(John,Mary)
,(Bill,Mary) - Is B(j) true wrt M?
136models some illustrations
- Suppose M( D,I) , where DJohn,Mary,Bill, and
I(j)John, I(m)Mary, I(b)Bill,
andI(B)John,BillI(G)MaryI(A)(John,Mary)
,(Bill,Mary) - Is B(j) true wrt M? Yes
137models some illustrations
- Suppose M(D,I), where DJohn,Mary,Bill, and
I(j)John, I(m)Mary, I(b)Bill,
andI(B)John,BillI(G)MaryI(A)(John,Mary)
,(Bill,Mary) - Is B(j) true wrt M? Yes
- Is B(j)?B(b)?A(m,m) true wrt M?
138models some illustrations
- Suppose M(D,I), where DJohn,Mary,Bill, and
I(j)John, I(m)Mary, I(b)Bill,
andI(B)John,BillI(G)MaryI(A)(John,Mary)
,(Bill,Mary) - Is B(j) true wrt M? Yes
- Is B(j)?B(b)?A(m,m) true wrt M? No
139models some illustrations
- Suppose M(D,I), where DJohn,Mary,Bill, and
I(j)John, I(m)Mary, I(b)Bill,
andI(B)John,BillI(G)MaryI(A)(John,Mary)
,(Bill,Mary) - Is B(j) true wrt M? Yes
- Is B(j)?B(b)?A(m,m) true wrt M? No
- Is ?x(B(x)?A(x,m)) true wrt M?
140models some illustrations
- Suppose M(D,I), where DJohn,Mary,Bill, and
I(j)John, I(m)Mary, I(b)Bill,
andI(B)John,BillI(G)MaryI(A)(John,Mary)
,(Bill,Mary) - Is B(j) true wrt M? Yes
- Is B(j)?B(b)?A(m,m) true wrt M? No
- Is ?x(B(x)?A(x,m)) true wrt M? Yes
141models some illustrations
- ?x(B(x)?A(x,m)) true wrt M iff
- all expressions B(a) ?A(a,m) are true wrt M.
- These are the following
- B(j) ?A(j,m)
- B(b) ?A(b,m)
- B(m) ?A(m,m)
142why is the latter formula true?
- ?x(B(x)?A(x,m)) true wrt M iff
- all expressions B(a) ?A(a,m) are true wrt M.
- These are the following
- B(j) ?A(j,m) true wrt M
- B(b) ?A(b,m) true wrt M
- B(m) ?A(m,m)
143why is the latter formula true?
- ?x(B(x)?A(x,m)) true wrt M iff
- all expressions B(a) ?A(a,m) are true wrt M.
- These are the following
- B(j) ?A(j,m) true wrt M
- B(b) ?A(b,m) true wrt M
- B(m) ?A(m,m) true wrt M (antecedent false!)
- Consequently ?x(B(x)?A(x,m)) is true wrt M
144Predicate logic optional extensions
- This completes the strict version of predicate
logic - In addition, we have introduced a number of
simplifications and extensions - Brackets
- all outermost brackets can be omitted
- brackets that are superfluous because of
associativity can be omitted, e.g., p?q?r instead
of (p?q)?r - we sometimes add extra brackets for clarity, or
.. rather than (..), to show which brackets
match
145Predicate logic optional extensions
- Quantifiers
- we sometimes write ?xyz instead of ?x?y?z, or
?xyz instead of ?x?y?z - ?!x P(x), ?2!x P(x), etc. for exact numbers
- restricted quantification e.g., ?xgt0? instead
of ?x(xgt0??) or ?xgt0? instead of ?x(xgt0??) - Other
- we sometimes write ??? instead of ???
- we sometimes allow ourselves to suggest
infinitely long formulas using dots, e.g. p1 ?
p2 ? ...