PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS
4-1
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
THE PREDICATE CALCULUS
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ The truth tables
Def: Two expressions are equivalent if they have the same truth value.
syntactically different
but logically equivalent.
It is important when using inference rules that require
expressions to be in a specific form.
The Predicate Calculus
Propositional calculus Predicate calculus
"it rained on Tuesday" weather(tuesday, rain)
What's the difference?
Def: Predicate calculus symbols
1. A, B, C, ... , Z, a, b, c, ..., z.
2. 0, 1, ..., 9.
3. _.
Symbols: 1. Begin with a letter 2. Followed by any sequence of these legal
characters. Example:
legitimate characters: a R 6 9 p _ z
illegitimate characters: # % @ / & ""
4
PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS
4-2
legitimate symbols: George fire3 bill XXXX
friends_of tom_and_jerry
illegitimate symbols: 3jack ab%cd
duck!!! ***71
"no blanks allowed"
Predicate calculus symbols may represent either variables, constants functions, or predicates.
1. Constants:
1) Specific objects or properties. 2) Begin with a lowercase letter.
Ex: george, tree, tall, blue Note: The constants true and false are reserved as
truth symbols. 2. Variables:
1. General classes of objects or properties.
2. Begin with an uppercase letter.
Ex: legal variables: George, BILL, KAte illegal variables: geORGE, bill 3. Functions:
1) Begin with a lowercase letter.
2) Mappings between nonnumeric domain as well as common arithmetic functions.
Def:
arity: The number of elements in the domain mapped onto each element of the range.
Ex: father: arity 1 plus: arity n
PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS
4-3
Def: function expression: a function symbol followed by its arguments. Example:
f(X,Y) father(david)
price(bananas) Notation:
mapping domain ⎯⎯⎯⎯⎯⎯⎯→ range arguments evaluation value
Def:
term : a constant, a variable, or function expression.
→ It denotes objects and properties in the problem domain.
Example: cat times(2,3) blue X mother(jane) kate
• symbols:
1. Truth symbols: true, false (reserved symbols)
2. Constant symbols:
3. Variable symbols:
4. Function symbols: • function expression:
Consists of a function of arity n. • term:
Either a constant, a variable, or function expression.
PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS
4-4
Atomic sentence (atomic expression, atom, proposition)
Remark:
1. arity: number of argument
2. Both name and arity equals ⇒ the same relation.
PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS
4-5
From atomic sentence to sentence
The variable quantifiers
variable
X,Y,Zvariable quantifier
universal ∀∃existential
generalize constrain
atomic sentence
sentence
∃Y Yfriends( ,peter) ( )∃YS
∀X Xlikes( ,ice_ cream) ( )∀XS
atomic sentences
¬ ∧ ∨ ⇒ ∀ ∃= X
predicate calculus sentences
Example of predicate calculus sentences:
plus(two,three) equal(plus(two,three),five)
∃∧
X Xfoo( , two,plus(two, three))equal(plus(two, three), five)
(
(foo(two, two,plus(two, three)))
equal(plus(two, three),five) = true)⇒
equal(plus(2,3),seven)
PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS
4-6
A simple applied example
mother(eve,abel) mother(eve,cain) father(adam,abel) father(adam,cain)
∀ ∀ ∨⇒
X Y X Y X YX Y
father( , ) mother( , )parent( , )
∀ ∀ ∀ ∧⇒
X Y Z X Y XY Zparent( , ) parent( ,Z)
sibling( ),
How to apply these sentences to infer new fact such as
sibling(cain,abel)
The semantics of predicate calculus
. A semantics for the predicate calculus
atomic sentences
¬ ∧ ∨ ⇒ ∀ ∃= X
predicate calculus sentences
interpretation
truth value assignment
PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS
4-7
Relationships between ¬ ∀ ∃
¬∃ = ∀ ¬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( ( ) ( )) ( ) ( )
Examples: English → Predicate calculus sentences
If it doesn't rain tomorrow, Tom will go to the mountains.
↓ ¬weather(rain,tomorrow)⇒go(tom,mountains).
All basketball players are tall.
↓ ∀X(basketball-player(X)⇒tall(X)).
Some people like anchovies.
↓ ∃X(person(X)∧likes(X,anchovies)).
If wishes were horses, beggars would ride.
↓ equal(wishes,horses)⇒ride(beggars).
Nobody likes taxes.
↓ ¬∃Xlikes(X,taxes)
PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS
4-8
A real-world example: ◎ To stack a block: 1. Both blocks must be clear. 2. Hand is empty. 3. To perform pick-up and put-down. 1. Both blocks must be clear. → ∀ ¬∃ ⇒X Y Y X X( ( , ) ( ))on clear The action:
∀ ∀ − ∧ ∧∧ − ∧ −⇒
X Y X YX X Y
X Y
(( ( ( )( ) ( , ))
( , ))
hand empty clear ) clearpick up put down
stack
Note:
1. The actions must be performed in the order in which they appear in a rule premise.
2. The block-world figure is an interpretation.
3. A different set of blocks in another location → Another interpretation (I).
PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS
4-9
AI in Practice:
Using Inference Rules to Product Predicate Calculus Expressions
Satisfy: I satisfies
sentences ⎯⎯⎯⎯⎯→ true
logically following: SFX (X logically follows from S)
I I In1 2, ,..., satisfy Set of expressions (S) ⎯⎯⎯⎯⎯⎯⎯→ true
⇓ I I In1 2, ,..., satisfy
X ⎯⎯⎯⎯⎯⎯⎯→ true
PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS
4-10
logic inference:
To product new sentences that logically follow a given set of predicate calculus sentences.
The inference rules:
modus ponens: P and P Q⇒ true → Q modus tolens: P Q⇒ true, Q false → ¬P elimination: QP∧ true → P, Q introduction: P and Q true → QP∧ universal instantiation: ∀XP X( ) true → XaaP ∈ )(
Example: modus ponens
All men are mortal Socrates is a man ))()(( xmortalxmanx ⇒∀ man(Socrates)
(unify)
man(Socrates) mortal(Socrates)
Unification
What: To determine the substitutions needed to make two expressions match.
Why: To apply inference rule. How: To replace the quantified variable by terms
from the domain. Example:
1. ∀ ⇒X X X( ( ) ))man mortal( man(socrates) mortal(socrates) 2. P(X) P(Y) equivalent
PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS
4-11
3. ∃X Xparent( , tom) ⇒ parent(bob,tom) or parent(mary,tom)
Assume bob and mary are tom‘s parents 4. ∀ ∃X Ymother(X,Y) ⇒ mother(X,f(X)) Y depends on X
The substitution issues 1. Any constant is not replaceable. 2.
constant 1constant 2
variable X
3. occurs check:
X P(X)
otherwise P(P(P(...(X)...)
4. consistency:
( ( ) ))man mortal(X X⇒ all occurrence of the variable 5. Time-invariant
IF X t X t1 2( ) ( ) THEN constant constant1X t X t( ) ( )+ → +α α2 Ex: Let p(a,X) unifies the primise of p(Y,Z) ⇒ q(Y,Z) i.e. (a/Y,X/Z) THEN q(a,X) Now, let q(W,b) ⇒ r(W,b) It is claimed that (a/W,b/X) So we may infer r(a,b)
PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS
4-12
6. Composition:
Ex:
Let {X/Y,W/Z}, {V/X}, {a/V,f(b)/W} ⇓ {V/Y,W/Z}, {a/V,f(b)/W} ⇓ {a/Y,f(b)/Z} 7. Generality
Ex:
Unify P(X) and P(Y):
What's the difference between
{fred/X,fred/Y} and {Z/X,Z/Y} a constant a variable
. An unification example LIST syntax unify ((parents X (father X) (mother bill)), (parents bill (father bill) y)) PC syntax unify parent(X,father(X),mother(bill)) parent(bill,father(bill),Y)
PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS
4-13
AI in Practice:
PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS
4-14
Application: A Logic-Based Financial Advisor
The advices:
Saving account income saving stocks ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ inadequate investment adequate adequate investment adequate inadequate combination ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
In terms of PC: savings_account(inadequate) ⇒ investment(savings) savings_account(adequate)∧income(adequate) ⇒ investment(stocks) savings_account(adequate)∧income(inadequate) ⇒ investment(combination)
PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS
4-15
To determine whether savings and income are adequate or inadequate ⇓
The minimum adequate savings and the minimum income must be defined
The advices: 1. To have at least $5000 in the bank for each dependent. 2. An adequate income must be a steady income and supply at least $15,000 per
year plus an additional $4000 for each dependent.
In terms of PC: minsavings(X) = 5000*X minincome(X) = 15000+(4000*X)
PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS
4-16
The adequacy of savings is determined by the rule:
∀Xamount_saved(X)∧∃Y(dependents(Y)∧greater(X,minsavings(Y))) ⇒ savings_account(adequate)
∀Xamount_saved(X)∧∃Y(dependents(Y)∧¬greater(X,minsavings(Y))) ⇒ savings_account(inadequate)
The adequacy of income is determined by the rule: ∀Xearnings(X,steady)∧∃Y(dependents(Y)∧greater(X,minincome(Y))) ⇒ income(adequate)
∀Xearnings(X,steady)∧∃Y(dependents(Y)∧¬greater(X,minincome(Y))) ⇒ income(inadequate) ∀Xearnings(X,unsteady) ⇒ income(inadequate)
PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS
4-17
To perform a consultation for an individual with three independents, $22,000 in savings, and a steady income of $25,000. Three PC sentences are stated:
amount_saved(22000)
earnings(25000,steady)
dependents(3)
PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS
4-18
The final logic system: 1 savings_account(inadequate) ⇒ investment(savings) 2 savings_account(adequate)∧income(adequate) ⇒ investment(stocks) 3 savings_account(adequate)∧income(inadequate) ⇒ investment(combination) 4 ∀Xamount_saved(X)∧∃Y(dependents(Y)∧greater(X,minsavings(Y))) ⇒ savings_account(adequate) 5 ∀Xamount_saved(X)∧∃Y(dependents(Y)∧¬greater(X,minsavings(Y))) ⇒ savings_account(inadequate) 6 ∀Xearnings(X,steady)∧∃Y(dependents(Y)∧greater(X,minincome(Y))) ⇒ income(adequate) 7 ∀Xearnings(X,steady)∧∃Y(dependents(Y)∧¬greater(X,minincome(Y))) ⇒ income(inadequate) 8 ∀Xearnings(X,unsteady) ⇒ income(inadequate) 9 amount_saved(22000) 10 earnings(25000,steady) 11 dependents(3) where minsavings(X) = 5000*X; minincome(X) = 15000+(4000*X)
PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS
4-19
PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS
4-20
Now using unification and modus ponens, (10 & 11 → 7) Application
earnings(25000,steady)∧(dependents(3) unifies with
earnings(X,steady)∧(dependents(Y) under the substitution
{25000/X, 3/Y} It yields earnings(25000,steady)∧dependents(3)∧¬greater(25000,minincome(3)) ⇒ income(inadequate)
Evaluating the function minincome yield: earnings(25000,steady)∧dependents(3)∧¬greater(25000,27000)) ⇒ income(inadequate) It results a true conclusion:
12 income(inadequate)
PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS
4-21
Similarly, amount_saved(22000)∧dependents(3) unifies with 4 under the substitution
{22000/X, 3/Y}
It yields amount_saved(22000)∧dependents(3)∧greater(22000,minsavings(3)) ⇒ savings_account(adequate)
Evaluating the function minincome yield: amount_saved(22000)∧dependents(3)∧greater(22000,15000) ⇒ savings_account(adequate) It also results a true conclusion:
13 savings_account(adequate)
PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS PPPRRREEEDDDIIICCCAAATTTEEE CCCAAALLLCCCUUULLLUUUSSS
4-22
Examine the three expressions 3, 12, and 13, and apply modus ponens again we get the final conclusion
investment(combination)
How to arrange the combination?
Fuzzy Expert Systems