0% found this document useful (0 votes)
20 views63 pages

Chap 2

Uploaded by

Amjad Bashayreh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views63 pages

Chap 2

Uploaded by

Amjad Bashayreh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 63

The Predicate Calculus

2.0 Introduction 2.4 Application: A Logic-Based


Financial Advisor
2.1 The Propositional Calculus
2.5 Epilogue and References
2.2 The Predicate Calculus
2.6 Exercises
2.3 Using Inference Rules to Produce
Predicate Calculus Expressions

George F Luger

ARTIFICIAL INTELLIGENCE 5th edition


Structures and Strategies for Complex Problem Solving

1
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
Propositional & Predicate Calculus

• Languages to express (represent)


knowledge.
• They use words, phrases, and sentences to
represent knowledge and reason about
properties and relationships of the world.

2
Propositional Calculus

3
4
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
Examples of sentences
• P represents (denotes) “My car is green”

• Q represents “It is raining”

• R represents “I like my job”

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

• Ali likes sweet and Ahmad doesn’t eat


waffles

• If Omar is ill then he goes to the doctor

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.

• i.e. it rains everyday.

18
19
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
Predicate calculus symbols
• Symbols denote objects, properties, or
relations.

• Use meaningful names.


– w(tu,r) Vs. weather(tuesday, rain)

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

• father(ali) its value may be ahmad


• plus(4, 5) its value may be 9
• price(apple) its value may be 75

• Replacing the function with its value is


called evaluation.

23
24
Luger: Artificial Intelligence, 5th edition. © Pearson Education Limited, 2005
Predicates
• Begin with a lower case letter.

• A predicate is a relationship between zero


or more objects in the world.
– likes, equals, on, near, part_of
– red(book1) represents property
– on(labtop,table1) relationship between labtop
and table
25
Atomic sentences, atoms, or
propositions
• Atomic sentences: predicate of arity n
followed by n terms:
• Examples:
– likes(george, kate)
– friends(ali,hasan)
– friends(farah,areej,school)
– helps(ahmad,faris)
– friends(father_of(ali), brother_of(ahmad))
26
Variable quantifiers
• universal quantifier (for all) 
 X likes(X, ice_cream)

• existential quantifier (there exists) 


 Y friends(Y, ali)
27
Some Properties of quantifiers
Xp( X )  Xp ( X )
Xp( X )  Xp ( X )
Xp( X )  Yp (Y )
Xp( X )  Yp (Y )
X ( p ( X )  q ( X ))  Xp( X )  Yq (Y )
X ( p ( X )  q ( X ))  Xp( X )  YQ(Y )

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)

all basketball players are tall


X basketball _ player ( X )  tall ( X ) 

some people like ice_cream


Xperson(X)  likes(X, ice_cream)

if wishes are horses, beggars would ride


equal(wishes, horses)  ride(beggars)

no body like taxes


30
 X likes(X, taxes)
Quiz Translate from English into first
order logic

• Every hardworking student who attends his


exams will pass
• Every student who does his homework and
revises his lectures is a hardworking student
• ali revises his lectures and does his
homework
• ali attends all his exams

31
Quiz Translate from English into first
order logic
Every hardworking student who attends his exams will pass
X student(X)  hardworking(X)  Eexam(E)  attends(X, E)   pass( X ) 

Every student who does his homeworks and revises his lectures is a hardworking student
XHLstudent(X)  does(X, H)  revises(X, L)  hardworking(X)

ali revises his lectures and does his homework


homework(ali)  revises(ali)

ali attends all his exams


X exam(X)  attends(ali, 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

plus(two, three ) : is a function and not an atomic sentence

equal(plus(two, three ), five) : is an atomic sentence

equal( plus(three, four ), eight ) :


is an atomic sentence although it is false

 X foo( X , two, plus(two, three ))  equal( plus(two, three ), five) :


is a sentence because it is a conjunt of two sentences

 foo(two,two,plus(two,three))  equal( plus(three, two), five)  true :


is a sentence because it is an implication of one sentence on another 34
verify_sentence algorithm

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)

 X  Yfather ( X , Y )  mother ( X , Y )  parent ( X , Y )


 X  Y  Z parent ( X , Y )  parent ( X , Z )  sibling (Y , Z )

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 :

X (Y on(Y , X )  clear ( X ))

We can also define operations such as how to move


a block on top of another
XY (( hand _ empty  clear ( X )  clear (Y ) 
pick _ up( X )  put _ down( X , Y )  stack ( X , Y ))
41
Inference Rules
• Logical inference: The ability to infer
(produce) new correct expressions
(sentences) from a set of true assertions.

• An expression X logically follows from a


set of predicate calculus expressions S if
every interpretation that satisfies S also
satisfies X.
42
Inference Rules
• Inference rule: A mechanism of producing
new predicate calculus sentences from other
sentences.

• When every sentence X produced by an


inference rule operating on set of sentences
S logically follows from S, the inference
rule is said to be sound.
43
Inference Rules
• If the inference rule is able to produce every
expression that logically follows from S, it
is said to be complete.

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
Pq rp pq
p pq p  q
_________ ________ ________
q rq q

2.Modus Tollens 4.Contradiction


Pq p
q p
_________ _________
p 
Modus Ponens
pq p  q {p, q}
p p {p}
_____ _____ _____
q q {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.

XY friend ( X , Y ) using skolemization it may be replaced by


X friend(X,f(X))
53
Examples of substitutions
• The expression:
foo(X, a, goo(Y))
• Can yield many expressions using legal
substitutions (bindings):

– foo(fred, a, goo(Z)) using {fred/X, Z/Y}


– foo(W, a, goo(jack)) using {W/X, jack/Y}
– foo(Z, a, goo(moo(Z))) using {Z/X, moo(Z)/Y}
54
In unifying the expressions p(X) and p(Y) the substitution
{Z/X, Z/Y} is more general than the substitution {fred/X, fred/Y}

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

{bill/X, (mother bill)/Y}

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

• Adequate income means $15,000 plus $4,000


for each dependent.
– Define function called
minincome(X)=15000+(4000*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

You might also like