Chap 2
Chap 2
George F Luger
1
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
Propositional & Predicate Calculus
2
Propositional Calculus
3
4
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
Examples of sentences
• P represents (denotes) “My car is green”
5
P ^ Q is a sentence
P Q is a sentence
P: Premise or antecedent
Q: Conclusion or consequent
6
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
Example of a WFF
(( P Q) R ) P Q R
7
8
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
For propositional expressions P, Q and R:
9
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
Figure 2.1: Truth table for the operator .
10
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
Figure 2.2: Truth table demonstrating the equivalence of: (P Q) and ( P Q)
P Q P P Q P Q ( P Q ) ( P Q )
T T F T T T
T F F F F T
F T T T T T
F F T T T T
11
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
Prove the following
( P Q) (P Q)
P (Q R ) ( P Q) ( P R )
(( P Q) R ) ( P (Q R ))
12
Give the representation for the
following sentences
• I will go to Aqaba or I will visit the zoo
13
Propositional Calculus
• Also called propositional logic
• Zero-order logic
– Does not contain variables
– Always uses constants
– Uses verb
• Action: eat, like
• Static: is, was
14
Propositional Calculus – Lack of
enough power of representation
• Example 1:
– All students are smart
– Ali is a student
– With propositional calculus we cannot conclude
that Ali is smart
• Example 2:
– Ali likes sweet
– Ali eats everything he likes
– We cannot conclude that Ali eats sweet 15
Examples of differences
• Propositional calculus: “It rained on Tuesday”
– Single statement
• Predicate calculus expression: weather(tuesday, rain)
– We can access single components
– Relationship between components
– Through inference rules, we can manipulate
predicate access components and infer new rules.
16
Predicate Calculus (First-order logic)
Advantages:
• More representation power.
• Expressions may contain variables (General
assertions).
• Well-defined formal semantics.
• Sound and Complete inference rules.
17
Predicate Calculus Example
• For all values of X, where X is a day of the
week, weather (X, rain) is true.
18
19
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
Predicate calculus symbols
• Symbols denote objects, properties, or
relations.
20
21
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
Examples of predicate calculus terms
• Terms are symbols which are either variables,
constants, or function expressions.
• Examples
– cat
– times(2,3)
– X
– blue
– mother(jane)
– kate
22
Examples of predicate calculus functions
23
24
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
Predicates
• Begin with a lower case letter.
28
Examples of mapping between English
language and predicate calculus
X bird ( X ) flies( X )
There exists some birds that don' t fly
X person( X ) Y loves( X , Y )
Every person has something/someone that they love
29
Examples of mapping between English
language and predicate calculus
If it doesn' t rain tomorrow, tom will go to the mountain
weather(rain, tomorrow) go(tom, mountains)
31
Quiz Translate from English into first
order logic
Every hardworking student who attends his exams will pass
X student(X) hardworking(X) Eexam(E) attends(X, E) pass( X )
Every student who does his homeworks and revises his lectures is a hardworking student
XHLstudent(X) does(X, H) revises(X, L) hardworking(X)
32
33
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
Test for well-formedness
plus and times are funcion symbols
equal and foo are predicate symbols
35
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
World description using
predicate calculus
mother (eve, abel )
mother (eve, cain)
father (adam, abel )
father (adam, cain)
36
37
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
38
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
(likes)likes( george, kate) is not a well - formed expression
39
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
Figure 2.3: A blocks world with its predicate calculate description.
Note:
Predicate calculus is
declarative. i.e. No timing or
ordering is assumed.
PROLOG is an example of
procedural semantics where
expressions are evaluated over
time.
40
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
Blocks World - Continued
We can conclude that a block X is clear
(Nothing on its top) according to the following rule :
44
45
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
46
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
47
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
Sound
48
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
Inference Rules
1.Modus Ponens 3.Chaining Rule 5.Margin Rule
Pq rp pq
p pq p q
_________ ________ ________
q rq q
Contradiction
{p}
{p}
______
{}
Resolution Inference Rule
w int er summer
T cold
w int er cold winter or
________________ F summer
summer cold
Unification
• We need to check whether two expressions are
the same or match?
• Unification: An algorithm for determining the
substitutions needed to make two predicate
calculus expressions match.
Example1 :
X (man( X ) mortal ( X ))
Using universal instantiation by substituting socrates for X, we infer
man( socrates) mortal ( socrates)
Example 2 : P(X) can be substituted by P(Y)
52
Elimination of there exists quantifier
• Unification requires the elimination of
existential quantifiers as it requires all
variables be universally quantified to give
freedom in substitutions.
X likes ( X , ice _ cream) may be replaced by
likes(tom,ice_cream) if tom satisfies the predicate.
55
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
56
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
Figure 2.5: Further steps in the unification of
(parents X (father X) (mother bill)) and
(parents bill (father bill) Y).
57
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
Figure 2.6: Final trace of the unification of (parents X (father X)
(mother bill)) and (parents bill (father bill) Y).
58
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
Unification Answer
59
Sec 2.6: A Logic-Based Financial
Advisor
1. If you have inadequate saving account,
increase your savings regardless of your
income.
2. If you have adequate saving account and
adequate income, invest in stock market.
3. If you have adequate saving account but
inadequate income, split your savings
between your bank and an investment in stock
market.
60
Sec 2.6: A Logic-Based Financial
Advisor
• Adequate saving corresponds to $5,000 for
each dependent.
– Define function called minsavings(X)=5000*X
61
62
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
Added Predicates
• 12. saving(adequate)
• 13. income(inadequate)
The conclusion is
investment (combination)
63