+ All Categories
Home > Documents > _شبتر 2شرح ذكاء

_شبتر 2شرح ذكاء

Date post: 24-Oct-2014
Category:
Upload: ranarokaia
View: 37 times
Download: 6 times
Share this document with a friend
Popular Tags:
31
Artificial Intelligence, 2004 by Yeuan-Kuen Lee http://www.csie.mcu.edu.tw/~yklee/Courses/AI/ArtificialIntelligence2004.html Chapter 2 THE PREDICATE CALCULUS Ch 2 The Predicate Calculus 2 Outline 1. The Propositional Calculus 2. The Predicate Calculus 3. Using Inference Rules to Produce Predicate Calculus Expressions 4. Application: A Logic-Based Financial Advisor Chapter 2 The Predicate Calculus Propositional Calculus Ch 2 The Predicate Calculus 4 2.1 The Propositional Calculus 2.1.1 Symbols and Sentences 2.1.2 Semantics Symbol Sentence make up Syntax Semantic ( meaning )
Transcript
Page 1: _شبتر 2شرح ذكاء

Artificial Intelligence, 2004by Yeuan-Kuen Lee

http://www.csie.mcu.edu.tw/~yklee/Courses/AI/ArtificialIntelligence2004.html

Chapter 2THE PREDICATE CALCULUS

Ch 2 The Predicate Calculus 2

Outline

1. The Propositional Calculus

2. The Predicate Calculus

3. Using Inference Rules to Produce

Predicate Calculus Expressions

4. Application:

A Logic-Based Financial Advisor

Chapter 2 The Predicate Calculus

Propositional Calculus

Ch 2 The Predicate Calculus 4

2.1 The Propositional Calculus

2.1.1Symbols and Sentences

2.1.2 Semantics

Symbol Sentencemake up

Syntax Semantic( meaning )

Page 2: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 5

2.1 The propositional calculus

Propositional calculus and predicate calculus are first of all languages. Using their words, phrases, and sentences, we can represent and reason about properties and relationships in the world.

Language: Symbol Sentence

make up

SyntaxSemantic( meaning )

Ch 2 The Predicate Calculus 6

2.1.1 Symbols and sentences

Propositional symbols : P, Q, R, S…denote propositions, or statements about the world that may be either true or false.Example: “the car is red”, “water is wet”

Truth symbols : true, falseConnectives: ∧, ∨, ¬, →, ≡Sentences are formed from these atomic symbols by the following rules:

DEFINITION : DEFINITION : PROPOSITIONAL CALCULUS SYMBOLSPROPOSITIONAL CALCULUS SYMBOLS

Symbol Sentencemake up

Syntax Semantic( meaning )

Ch 2 The Predicate Calculus 7

2.1.1 Symbols and sentences

Every propositional symbol and truth symbol is a sentence.Example: true, P, Q, and R are sentencesThe negation of a sentence is a sentence.Example: ¬ P and ¬ false are sentencesThe conjunction, or and, of two sentences is a sentences.Example: P ∧ ¬ P is a sentenceterm: conjunct

DEFINITION: DEFINITION: PROPOSITIONAL CALCULUS SENTENCESPROPOSITIONAL CALCULUS SENTENCES

Ch 2 The Predicate Calculus 8

2.1.1 Symbols and sentences

The disjunction, or or, of two sentences is a sentences.Example: P ∨ ¬ P is a sentenceterm: disjunct

The implication of one sentence from another is a sentence.Example: P → Q is a sentenceterm: premise or antecedentterm: conclusion or consequent

DEFINITION: DEFINITION: PROPOSITIONAL CALCULUS SENTENCESPROPOSITIONAL CALCULUS SENTENCES

Page 3: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 9

2.1.1 Symbols and sentences

The equivalence of two sentence is a sentence.Example: P ≡ Q is a sentence

Legal sentences are also called well-formed formulas or WFFs.

Symbol Sentencemake up

Syntax Semantic( meaning )

DEFINITION: DEFINITION: PROPOSITIONAL CALCULUS SENTENCESPROPOSITIONAL CALCULUS SENTENCES

Ch 2 The Predicate Calculus 10

2.1.1 Symbols and sentencesSymbols ( ) and [ ]

Used to group symbols into subexpressionsTo control the order of evaluation and meaning

Example: (P ∨ Q) ≡ R is quite different from P ∨ (Q ≡ R)

Ch 2 The Predicate Calculus 11

2.1.1 Symbols and sentences

An expression is a sentenceor well-formed formula

it can be formed of legal symbols through some sequence of these rules.

iff

(( P ∧ Q) → R ) ≡ ¬ P ∨ ¬ Q ∨ Ris a well-formed sentence

Ch 2 The Predicate Calculus 12

2.1 The Propositional Calculus

2.1.1Symbols and Sentences

2.1.2 Semantics

Symbol Sentencemake up

Syntax Semantic( meaning )

Page 4: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 13

2.1.2 SemanticsA precise treatment of semantics is essential

Automatic Reasoning is needed in AI program.

It is important to demonstrate that the truth of their conclusions depends only on the truth of their initial knowledge.

Logical errors are not introduced in the inference procedures

[ Meaning of sentence ]

Ch 2 The Predicate Calculus 14

2.1.2 Semantics

It is rainingPQ I live in a brown house

May be either true or false

A proposition symbol corresponds to a statement about the world

The truth value assignment to propositional sentences is called interpretation.

Propositional symbols { T, F } interpretation

mapping

“T”, and “F” are truth values, “true” and “false” are part of set of well-formed formulas

Note

Ch 2 The Predicate Calculus 15

2.1.2 Semantics

An interpretation of a set of propositions isthe assignment of a truth value, either T or F, to each propositional symbol.

The symbol true is always assigned T, and the symbol false is assigned F.

DEFINITION : DEFINITION : PROPOSITIONAL CALCULUS SEMANTICSPROPOSITIONAL CALCULUS SEMANTICS

Ch 2 The Predicate Calculus 16

2.1.2 Semantics

The interpretation or truth value for sentencesis determined by:

The truth assignment of negation, ¬ P , is F if the assignment to P is T, and T if the assignment to P is F. (where P is any propositional symbol) The truth assignment of conjunction, ∧ , is T only when both conjuncts have truth value T; otherwise, it is F.

DEFINITION : DEFINITION : PROPOSITIONAL CALCULUS SEMANTICSPROPOSITIONAL CALCULUS SEMANTICS

Page 5: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 17

2.1.2 Semantics

The interpretation or truth value for sentences is determined by:

The truth assignment of disjunction, ∨ , is F only when both disjuncts have truth value F; otherwise, it is T.The truth assignment of implication, → , is F only when the premise or symbol before the implication is T and the truth value of the consequent or symbol after the implication is F; otherwise, it is T.

DEFINITION : DEFINITION : PROPOSITIONAL CALCULUS SEMANTICSPROPOSITIONAL CALCULUS SEMANTICS

Ch 2 The Predicate Calculus 18

2.1.2 Semantics

The interpretation or truth value for sentences is determined by:

The truth assignment of equivalence, ≡ , is T only when both expressions have the same truth assignment for all possible interpretations; otherwise, it is F.

DEFINITION : DEFINITION : PROPOSITIONAL CALCULUS SEMANTICSPROPOSITIONAL CALCULUS SEMANTICS

Ch 2 The Predicate Calculus 19

2.1.2 SemanticsTruth table

List all possible truth value assignments to the atomic propositions of an expressionGive the truth value of the expression for each assignment

A truth tableenumerate all possible worlds of interpretation that may be given to an expression

The truth table for P ∧ Q TTFF

TFTF

TFFF

P Q P∧Q

Ch 2 The Predicate Calculus 20

2.1.2 Semantics

TTFF

TFTF

FFTT

P Q ¬P∨Q

TFTT

TFTT

TTTT

¬P P→Q (¬P∨Q ) ≡ (P→Q)

Truth table demonstrating the equivalence ofP→Q and ¬P∨Q

Two expressions in the propositional calculus are equivalent if they have the same value under all truth value assignments.This equivalence may be demonstrated using truth tables.

Page 6: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 21

2.1.2 SemanticsThese following equivalences can be proven:

¬ ( ¬ P ) ≡ P( P ∨ Q ) ≡ ( ¬ P → Q )

Contrapositive law: ( P → Q ) ≡ ( ¬ Q → ¬ P )

Morgan’s law: ¬ ( P ∨ Q ) ≡ ( ¬ P ∧ ¬ Q ) ¬ ( P ∧ Q ) ≡ ( ¬ P ∨ ¬ Q )

Ch 2 The Predicate Calculus 22

2.1.2 SemanticsThese following equivalences can be proven: (Conti.)

Commutative laws ( P ∧ Q ) ≡ ( Q ∧ P )( P ∨ Q ) ≡ ( Q ∨ P )

Associate laws (( P ∧ Q ) ∧ R ) ≡ ( P ∧ ( Q ∧ R ))(( P ∨ Q ) ∨ R ) ≡ ( P ∨ ( Q ∨ R ))

Distribute lawsP ∨ ( Q ∧ R ) ≡ ( P ∨ Q ) ∧ ( P ∨ R )P ∧ ( Q ∨ R ) ≡ ( P ∧ Q ) ∨ ( P ∧ R )

These identities can be used to change propositionalcalculus expressions into a syntactically different but logically equivalent form.

Ch 2 The Predicate Calculus 23

2.1.2 SemanticsLogic Theorist(An early AI program, Newell and Simon, 1956)

Designed by Newell, Simon and ShawUse transformations between equivalent forms of expressionTo prove many of the theorem in Whitehead and Russell’s

Principia Mathematica (1950)

Allen Netwell Chapter 2 The Predicate Calculus

Predicate Calculus

Page 7: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 25

2.2 The predicate calculusPropositional calculus

Atomic symbol, P, denotes “it rained on Tuesday”.Drawback: There is no way to access the components of an individual assertion.

Predicate calculus provides this ability.weather( tuesday, rain )Predicate calculus also allows expressions to contain variable.weather( X, rain ), where X is a day of the weekThe statement weather( X, rain ) is true; i.e., it rains every day.

Ch 2 The Predicate Calculus 26

2.2 The predicate calculus

2.2.1Syntax

2.2.2Semantics

2.2.3 A “Block World” Example

of Semantic Meaning

Ch 2 The Predicate Calculus 27

2.2.1 The syntaxPredicate calculus symbol

Like a token in a programming languageirreducible syntactic element(can not be broken into their component parts by the operations of the language)Strings of letters and digits (beginning with a letter)Blanks and nonalphanumeric characters cannot appear within the stringThe underscore, _, may be used to improve readability.

Ch 2 The Predicate Calculus 28

2.2.1 The syntaxLegitimate characters in a symbol

a R 6 9 p _ z …

Examples of characters not in the alphabet include# % @ / & “ “ …

Legitimate symbolsGeorge fire tom_and jerry bill XXXX friends_of

Examples of strings that are not legal symbols3jack “no blanks allow” ab%cd ***71 duck!!!

Symbols are used to denote objects, properties, or relations

Page 8: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 29

2.2.1 The syntax

alphabet : make up the symbols, consists of:1. The set of letters, both upper- and lowercase, of

the English alphabet.2. The set of digits, 0, 1, 2, … 9.3. The underscore, _ .

Symbolsbegin with a letter and followed by any sequence of these legal characters

DEFINITION: DEFINITION: PREDICATE CALCULUS SYMBOLSPREDICATE CALCULUS SYMBOLS

Ch 2 The Predicate Calculus 30

2.2.1 The syntaxReadability of expressions (for human readers)

l(g,k) vs. likes(george, kate)Symbol’s intended meaning assists us in understanding the program codeThe only meaning that predicate calculus expressions may be said to have is through their formal semantics

Improper symbolsParentheses “ ( ) “, Commas “ , “ , Period “ . “Used only to construct well-formed expressions Do not denote objects or relations (improper)

Ch 2 The Predicate Calculus 31

Predicate calculus symbols

Predicatecalculus

symbolVariable

Constant

Function

Predicate

Ch 2 The Predicate Calculus 32

Predicate calculus symbols

1. Specific object or property in the world2. Must begin with a lowercase letter3. Constant true and false are reserved

for truth symbols

O: geroge, tree, tall, blue

Constant

Page 9: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 33

Predicate calculus symbols

1. Used to designate general classes of objects or properties

2. Must begin with a uppercase letter

O: George, BILL, KAte,X: geORGE, bill

Variable

Ch 2 The Predicate Calculus 34

Predicate calculus symbols

1. Must begin with a lowercase letter2. Denote a mapping of one or more elements (in the

domain) to a unique element (in the range)3. Arity: indicate the number of elements in the

domain mapped onto each element of the range.4. Function expression: a function symbol followed by

its arguments (enclosed in parentheses and separated by commas)

Function

objects

mappingdomaindomain rangerange

Ch 2 The Predicate Calculus 35

Predicate calculus symbols

O: f(X,Y), father(david), price(banana).

The act of replacing a function with its valueis called evaluation.

george = father ( david )

function symbol argumentvalue

Function

Ch 2 The Predicate Calculus 36

2.2.1 The syntax

Predicate calculus symbols include:1. Truth symbols true and false

(these are reserved symbols).2. Constant symbols are symbol expressions having the

first character lowercase.3. Variable symbols are symbol expressions beginning

with an uppercase character.4. Function symbols are symbol expressions having the

first character lowercase. Functions have an attached arity indicating the number of elements of the domain mapped onto each element of the range.

DEFINITION: DEFINITION: SYMBOLS and TERMSSYMBOLS and TERMS

Page 10: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 37

2.2.1 The syntax

A function expression consists of a function constant of arity n, followed by n terms, t1, t2,…, tn , enclosed in parentheses and separated by commas.

A predicate calculus term is either a constant, variable, or function expression.

objects and properties ( in the problem domain )cattimes(2, 3)X

bluemother(jane)kate

DEFINITION: DEFINITION: SYMBOLS and TERMS SYMBOLS and TERMS (Conti.)

Ch 2 The Predicate Calculus 38

Predicate calculus symbols

Symbols in predicate calculus may also represent predicates. A predicate names a relationship between zero or more objects.

1. Must begin with a lowercase letter2. Arity of the predicate: the number of related objects

Example: likes equals on near part_of

Predicate

Ch 2 The Predicate Calculus 39

Predicate symbol

Predicate calculus symbols

Atomic sentence: the most primitive unit of the predicatecalculus language, is a predicate of arity n followed by n term enclosed in parentheses and separated by commas.

Example: likes(george,kate) likes(X, george) likes(george,susie)likes(X,X) likes(george, sarah, tuesday) friends(bill, george) friends(bill,richard) friends(father_of(david), father_of(andrew)) helps(bill, george) helps(richard, bill)

constant symbol(present object)

Argument

Predicate

Ch 2 The Predicate Calculus 40

Predicate calculus symbolsA predicate relation is defined by its name and arity.

likes(george, sarah, tuesday) Arity: 3likes(george,susie) Arity: 2It is considered to represent two different relations. (avoid confusion)

friends(father_of(david), father_of(andrew))

Arguments [ may be constant symbols ]may also include variables or function expressions

likes(X, george)

friends( george, allen )evaluation

constant symbol

Predicate

Page 11: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 41

2.2.1 The syntax

Predicate symbols are symbols beginning with a lowercase letter.Predicates have an associated non-negative integer referred to as the arity or “argument number” for the predicate. Predicates with the same name but different arities are considered distinct.An atomic sentence is a predicate constant of arity n, followed by n terms, t1, t2, …tn, enclosed in parentheses and separated by commas.The truth values, true and false, are also atomicsentences.

DEFINITION: DEFINITION: PREDICATE and ATOMIC SENTENCESPREDICATE and ATOMIC SENTENCES

Ch 2 The Predicate Calculus 42

2.2.1 The syntax

Atomic sentences are also called atomic expressions, atoms, or propositions.

Atomic sentence Atomic sentenceLogical operator

∧, ∨, ¬, →, ≡

Same logical connectives used in propositional calculus

Sentence

Ch 2 The Predicate Calculus 43

mapping2.2.1 The syntax

Variable (in a sentence)refers to unspecified objects in the domain.Variable quantifier ∀ and ∃ constrain the meaningof a sentence containing a variable.A quantifier is followed by a variable and a sentence.

∃ Y friends(Y, peter)∀ X likes(X, ice_cream)

Sentencedomaindomain rangerange

Ch 2 The Predicate Calculus 44

2.2.1 The syntaxUniversal quantifier, ∀indicated that the sentence is truefor all values of the variable.

Existential quantifier, ∃indicated that the sentence is truefor at least one value in the domain.

∃ Y friends(Y, peter)is true

∀ X likes(X, ice_cream)

There is at least one object, indicated by Y that is a friend of peter

Sentence

Page 12: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 45

2.2.1 The syntax

Every atomic sentence is a sentence.1. If s is a sentence, then so is its negation, ¬ s.2. If s1 and s2 are sentences, then so is their conjunction, s1 ∧ s2.3. If s1 and s2 are sentences, then so is their disjunction, s1 ∨ s2. 4. If s1 and s2 are sentences, then so is their implication, s1 → s2.5. If s1 and s2 are sentences, then so is their equivalence, s1 ≡ s2.6. If X is a variable and s is a sentence, then ∀ X s is a sentence.7. If X is a variable and s is a sentence, then ∃ X s is a sentence.

DEFINITION: DEFINITION: PREDICATE CALCULUS SENTENCESPREDICATE CALCULUS SENTENCES

Ch 2 The Predicate Calculus 46

2.2.1 The syntax

Let times and plus be function symbols of arity 2 and let equal and foo be predicate symbols with arity 2 and 3, respectively.

plus(two, three) Not an atomic sentence

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

equal( plus(two, three), seven) an atomic sentence

∃ X foo (X, two, plus(two,three)) ∧ equal ( plus(two, three), five)

(foo(two,two,plus(two,three))) → (equal(plus(three,two),five) ≡ true )

a sentence

a sentence

example well-formed sentences:

Ch 2 The Predicate Calculus 47

2.2.1 The syntaxRecursive algorithm: verify_sentence(expression)for verifying that an expression is a sentence.function verify_sentence(expression);begin

case expression is an atomic sentence: return SUCCESS;expression is of the form Q X s , where Q is either ∀ or ∃,

X is a variable, and s is a sentence:if verify_sentence(s) returns SUCCESS

then return SUCCESSelse return FAIL;

expression is of the form ¬ s:if verify_sentence(s) returns SUCCESS

then return SUCCESSelse return FAIL;

Ch 2 The Predicate Calculus 48

2.2.1 The syntax

expression is of the form s1 op s2, where op is a binary logical operator:

if verify_sentence(s1) returns SUCCESS andverify_sentence(s2) returns SUCCESS

then return SUCCESSelse return FAIL;

otherwise: return FAILend

end.

Recursive algorithm: verify_sentence(expression) (Conti.)

Page 13: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 49

2.2.1 The syntax

A set of family relationships in a biblical genealogymother(eve, abel)mother(eve,cain)father(adam, abel)father(adam,cain)∀ X ∀ Y (father(X, Y) ∨ mother(X, Y) → parent(X, Y))∀ X ∀ Y ∀ Z (parent(X, Y) ∧ parent(X, Z) → sibling(Y, Z))

Parent-child relationship

sibling(cain, abel)

example use predicate calculus to describe a simple world.

Ch 2 The Predicate Calculus 50

2.2 The predicate calculus

2.2.1Syntax

2.2.2Semantics

2.2.3 A “Block World” Example

of Semantic Meaning

Ch 2 The Predicate Calculus 51

2.2.2 The SemanticsPredicate calculus semantics provide a formal basis for determining the truth value of well-formed expressions.

Information about a person, George, and his friends Kate and Susie may be expressed byfriends(george, susie)friends(george, kate)

If it is true thatGeorge is a friend of SusieGeorge is a friend of Kate

then friends(george, susie) has a truth value Tfriends(george, kate) has a truth value T

George is NOT a friend of Kate

F

Ch 2 The Predicate Calculus 52

2.2.2 The Semantics

Predicate calculus expressionsDatabase:

Each having truth value T“state of the world”

describe

Using predicate calculus as a representation for problem solving:

objects and relations

A BLOCK WORLD

a b

c

clear(c)clear(a)ontable(a)ontable(b)

on(c,b)cube(a)cube(b)pyramid(c)

describe

Example

Page 14: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 53

mapping2.2.2 The Semantics

Let the domain D be a nonempty set.An interpretation over D is an assignment of the entities of D to each of the constant, variable, predicate, and function symbols of a predicate calculus expression, such that:1. Each constant is assigned an element of D.2. Each variable is assigned to a nonempty subset of D;

these are the allowable substitutions for the variable.3. Each function f of arity m is defined on m arguments

from D and defines a mapping from Dm into D. 4. Each predicate p of arity n is defined on n arguments

from D and defines a mapping from Dn into {T, F}.

DEFINITION: DEFINITION: INTERPRETATIONINTERPRETATIONdomaindomain rangerange

Ch 2 The Predicate Calculus 54

2.2.2 The Semantics

Assume an expression E and an interpretation I for E over a nonempty domain D. The truth value for E is determined by:1. The value of a constant is the element of D it is

assigned to by I.2. The value of a variable is the set of elements of D

it is assigned to by I. 3. The value of a function expression is that element

of D obtained by evaluating the function for the parameter values assigned by the interpretation.

DEFINITION: DEFINITION: TRUTH VALUE OF PREDICATE CALCULUS EXPRESSIONSTRUTH VALUE OF PREDICATE CALCULUS EXPRESSIONS

Ch 2 The Predicate Calculus 55

2.2.2 The Semantics

The truth value for E is determined by:4. The value of truth symbol “true” is T and “false” is F.5. The value of an atomic sentence is either T or F,

as determined by the interpretation I.6. The value of the negation of a sentence is

T if the value of the sentence is F and is F if the value of the sentence is T.

7. The value of the conjunction of two sentences is T if the values of both sentences is T and is F otherwise.

DEFINITION: DEFINITION: TRUTH VALUE OF PREDICATE CALCULUS EXPRESSIONSTRUTH VALUE OF PREDICATE CALCULUS EXPRESSIONS

Ch 2 The Predicate Calculus 56

2.2.2 The Semantics

The truth value for E is determined by:8. - 10. The truth value of expressions using ∨, →,

and ≡ is determined from the value of theiroperands as defined in Section 2.1.2.

Finally, for a variable X and a sentence S containing X :11. The value of ∀ X S is T if S is

T for all assignments to X under I, and it is F otherwise.

12. The value of ∃ X S is T if there is an assignment to X in the interpretation under which S is T; otherwise it is F.

DEFINITION: DEFINITION: TRUTH VALUE OF PREDICATE CALCULUS EXPRESSIONSTRUTH VALUE OF PREDICATE CALCULUS EXPRESSIONS

Page 15: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 57

2.2.2 The SemanticsQuantification of variables is an important part of predicate calculus semantics.

likes(george, X)

kate

likes(george, kate)

Under the interpretation

likes(george, X )likes(george, PEOPLE )

have the same meaning

The variable is said to be a dummy.

Ch 2 The Predicate Calculus 58

2.2.2 The Semantics

In the predicate calculus, variables must be quantifiedin either of two ways: universally or existentially.

A variable is considered free if it not within the scope of either the universal or existential quantifiers.

An expression is closed if all of its variables are quantified.

Quantification

Free variable

Closed expression

Ground expression

A ground expression has no variables at all.

Ch 2 The Predicate Calculus 59

2.2.2 The SemanticsUniversal quantification

Computing problem All the possible values of a variable symbolmust be tested to see whether the expression remains true.

∀ X likes( george, X )

All humansIf the domain of an interpretation is infinite, exhaustive testing of all substitutions to a universal quantified variable is computationally impossible: the algorithm may never halt.Because of the problem, the predicate calculus is said to be undecidable.

Universal quantifier ∀ ( for all )

∀ X ( p (X) ∨ q ( Y ) → r( X ) )

Using parentheses to indicate the scope of quantification.X is universally quantified in both p(X) and r(X).

Ch 2 The Predicate Calculus 60

2.2.2 The SemanticsExistential quantification

The expression containing the variable is said to be true for at least one substitution from the domain of definition.

Existential quantifier ∃ ( exist at least one )

Computing problem

If the domain of the variable is infinite, and the expression is false under all substitutions, the algorithm will never halt.

Page 16: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 61

2.2.2 The SemanticsRelationships between negation and the universaland existential quantifiers for predicates p and q and variables X and Y.

¬ ∃ X p(X) ≡ ∀ X ¬ p(X) ¬ ∀ X p(X) ≡ ∃ X ¬ p(X)∃ X p(X) ≡ ∃ Y p(Y)∀ X q(X) ≡ ∀ Y q(Y)∀ X ( p(X) ∧ q(X) ) ≡ ∀ X p(X) ∧ ∀ Y q(Y)∃ X ( p(X) ∨ q(X) ) ≡ ∃ X p(X) ∨ ∃ Y q(Y)

Ch 2 The Predicate Calculus 62

2.2.2 The Semantics

If it doesn’t rain on Monday, Tom will go to the mountains.¬ weather(rain, monday) → go(tom, mountains)Emma is a Doberman pinscher and a good dog.Gooddog(emma) ∧ isa(emma, doberman)All basketball players are tall.∀ X (basketball_player(X) → tall(X))

http://www.petsmart.com/aspca/images/dogs/doberman_pinscher.jpg

Ch 2 The Predicate Calculus 63

2.2.2 The Semantics

Some people like anchovies.∃ X (person(X) ∧ likes(X, anchovies))

http://www.charterboats-uk.co.uk/Z%20-%20Fish%20Identification.htm

Anchoa lucida (Jordan & Gilbert, 1882)

anchovy Ch 2 The Predicate Calculus 64

2.2.2 The Semantics

Green olives and anchovy creamhttp://usa.oliviersandco.com/browse.cfm/4,40.html

http://www.sealitsoc.org/images/scanned/bay_anchovy.jpg

http://www.ikoreaplaza.com/

Page 17: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 65

2.2.2 The SemanticsIf wishes were horses, beggars would ride.Equal(wishes, horse) → ride(beggars)Nobody likes taxes.¬ ∃ X likes(X, taxes)

Ch 2 The Predicate Calculus 66

2.2 The predicate calculus

2.2.1Syntax

2.2.2Semantics

2.2.3 A “Block World” Example

of Semantic Meaning

Ch 2 The Predicate Calculus 67

2.2.3 A blocks world example

on(c,a) on(b,d) ontable(a) ontable(d)clear(b) clear(c)hand_empty

Figure 2.3 A blocks world with its predicate calculus description

Suppose we want to model the blocks world to designa control algorithm for a robot arm.

This set of blocks offers an interpretation and a possible model for the set of predicate calculus.The predicate calculus is declarative, i.e., there is no assumed timing or order for considering each expression.

of semantic meaning

a d

c b

Ch 2 The Predicate Calculus 68

2.2.3 A blocks world example

a d

c b

To pick up a block and stack it on another block, both blocks must be clear. Suppose it removes block cfrom block a and updates the knowledge base to reflect this by deleting the assertion on(c,a).The program needs to be able to infer that blocka has become clear.

on(c,a)on(b,d) ontable(a)ontable(d)

clear(b)clear(c)hand_empty

The arm can move the blocks, it can change the state of the world and clear a block.

Page 18: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 69

2.2.3 A blocks world example

a d

c bon(c,a)on(b,d) ontable(a)ontable(d)

clear(b)clear(c)hand_empty

a dcb on(c,a)

on(b,d) ontable(a)ontable(d)

ontable(c)

clear(b)clear(c)hand_emptyclear(a)

Ch 2 The Predicate Calculus 70

2.2.3 A blocks world example∀ X ( ¬ ∃ Y on(Y, X) → clear(X) ) ∀ X ( ¬ ∃ Y on(Y, X) → clear(X) )

This rule describes when a block is clear.For all X, X is clear if there does not exist a Y such that Y is on X.

This rule not only defines what it means for a block to be clearbut also provides a basis for determining how to clear blocks that are not.

a d

c b

Example:Block d is not clear.

because: X –-> d , Y --> b ¬ on(b, d) is false

To make it trueon(b,d) should be deleteb must be removed from d

1

12

2

Ch 2 The Predicate Calculus 71

2.2.3 A blocks world example

This rule describes operations such as stacking one block on top to another.

To stack X on Y:first empty the hand, then clear X, then clear Y and then pick_up X and put_down X on Y

∀ X ∀ Y ( ( hand_empty ∧ clear (X) ∧ clear (Y) ∧ pick_up(X) ∧ put_down(X, Y) ) → stack(X, Y) )

∀ X ∀ Y ( ( hand_empty ∧ clear (X) ∧ clear (Y) ∧ pick_up(X) ∧ put_down(X, Y) ) → stack(X, Y) )

Chapter 2 The Predicate Calculus

Using inference rules to produce predicate

calculus expressions

Page 19: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 73

2.3 Using inference rules

2.3.1Inference rules

2.3.2Unification

2.3.3 A Unification Example

to produce predicatecalculus expressions

Ch 2 The Predicate Calculus 74

2.3 Using inference rules

The semantics of the predicate calculus provides a basis for a formal theory of logical inference.

to produce predicatecalculus expressions

∀ ¬ ∧ ∨ ∃ →

2.3.1 Inference rules

A set of true assertion new correct expression

infer

This ability is an important feature of the predicate calculus

Consistent

Ch 2 The Predicate Calculus 75

2.3.1 Inference rulesAn interpretation that makes a sentence true is saidto satisfy that sentence.An interpretation that satisfies every member of a setof expressions is said to satisfy the set. An expression X logically follows from a set of predicate calculus expressions S if every interpretation that satisfies S also satisfies X.

Ch 2 The Predicate Calculus 76

2.3.1 Inference rulesX logically follows SX logically follows S

This notion gives us a basis for verifying the correctness of rules of inference.

S Xinfer

logically follows

The function of logical inference is to producenew sentences that logically follow a given set of predicate calculus sentences.

Page 20: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 77

2.3.1 Inference rulesAn inference rule is essentially a mechanical means of producing new predicate calculus sentence from othersentences, i.e., inference rules produce new sentencesbased on the syntactic form of given logical assertions.

When every sentence X ( produced by an inference rule operating on a set S of logical expressions ) logically follows from S,the inference rule is said to be sound.

Sound inference ruleSound inference rule

Complete inference ruleComplete inference ruleIf the inference rule is able to produce every expression that logically follows from S, then it is said to be complete.

Ch 2 The Predicate Calculus 78

2.3.1 Inference rules

For a predicate calculus expression Xand an interpretation I

If X has a value of T under I and a particular variable assignment, then I is said to satisfy X.If I satisfies X for all variable assignments, then I is a model of X. X is satisfiable if and only if there exist an interpretation and variable assignment that satisfy it; otherwise, it is unsatisfiable.

DEFINITION: DEFINITION: SATISFY, MODELSATISFY, MODEL

Ch 2 The Predicate Calculus 79

2.3.1 Inference rules

For a predicate calculus expression Xand an interpretation I

A set of expression is satisfiable if and only ifthere exist an interpretation and variable assignment that satisfy every element.If a set of expression is not satisfiable, it is said to be inconsistent.If X has a value T for all possible interpretation, X is said to be valid.

DEFINITION: DEFINITION: SATISFY, VALID, INCONSISTENTSATISFY, VALID, INCONSISTENT

Ch 2 The Predicate Calculus 80

2.3.1 Inference rules

∃ X ( p(X) ∧ ¬ p(X))

inconsistent∃ X ( p(X) ∨ ¬ p(X))

valid

Page 21: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 81

2.3.1 Inference rules

A proof procedure is a combination of an inference rule and an algorithm for applying that rule to a set of logical expressions to generate new sentences.We present proof procedures for the resolution inference rule in Chapter 12.

DEFINITION: DEFINITION: PROOF PROCEDUREPROOF PROCEDURE

inferencerule

AlgorithmA set of logical expressions New sentence

Proof procedure

E1 ∨ E3E1 ∨ E2¬E2 ∨ E3 infer

Ch 2 The Predicate Calculus 82

2.3.1 Inference rules

A predicate calculus expression X logically followsfrom a set S of predicate calculus expression if every interpretation and variable assignment that satisfies S also satisfies X.An inference rule is sound if every predicate calculus expression produced by the rule from a set S of predicate calculus expression also logically follows from S.An inference rule is complete if, given a set S of predicate calculus expressions, the rule can infer every expression that logically follows from S.

DEFINITION: DEFINITION: LOGICALLY FOLLOWS, SOUND, and COMPLETELOGICALLY FOLLOWS, SOUND, and COMPLETE

S Xinfer

logically follows

Ch 2 The Predicate Calculus 83

2.3.1 Inference rules

If the sentences P and P → Q are known to be true, then modus ponens let us infer Q.Under the inference rule modus tollens, if P → Q isknown to be true and Q is known to be false, we can infer ¬ P.And elimination allows us to infer the truth of either of the conjuncts from the truth of a conjunctive sentence. For instance, P ∧ Q let us conclude P and Q are true.

DEFINITION: DEFINITION: MODUS PONENS, MODUS TOLLENS, and MODUS PONENS, MODUS TOLLENS, and ANDAND ELIMINATION.ELIMINATION.

Ch 2 The Predicate Calculus 84

2.3.1 Inference rules

And introduction lets us infer the truth of conjunction from the truth of its conjuncts.For instance, if P and Q are true, then P ∧ Q is true.

Universal instantiation states that if any universally quantified variable in a true sentence is replaced be any appropriate term from the domain, the result is a true sentence. Thus, if a is from the domain of X, ∀ X p(X) let us infer p(a).

DEFINITION: DEFINITION: AND INTRODUCTION and UNIVERSAL INSTANTIATIONAND INTRODUCTION and UNIVERSAL INSTANTIATION

Page 22: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 85

2.3.1 Inference rules

TTFF

TFTF

FFTT

P Q

TFTT

¬P -Q→-PP ∧ Q

TFTT

TFFF

P→Q

FTFT

-Q

Ch 2 The Predicate Calculus 86

2.3.1 Inference rulesExample: the use of modus ponens

in the propositional calculus:Our observations: P → Q : “If it is raining then the ground will be wet”P : “It is raining.”

P→QP Qmodus ponens

P→QPQ

set of true expression

set of true expression

Ch 2 The Predicate Calculus 87

2.3.1 Inference rulesExample: the use of modus ponens in expressions containing variablesSyllogism: “all men are mortal and Socrates is a man;

therefore Socrates is mortal”“All men are mortal” ∀ X (man(X) → mortal (X))“Socrates is man man(socrates)

∀ X (man(X) → mortal (X))man(socrates)

set of true expression

Ch 2 The Predicate Calculus 88

2.3.1 Inference rules

∀ X (man(X) → mortal (X))man(socrates)

universal instantiation

set of true expression

(man(Socrates) → mortal (Socrates))

∀ X (man(X) → mortal (X))man(Socrates) → mortal (Socrates)

man(socrates)

Page 23: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 89

2.3.1 Inference rules

mortal(socrates)

set of true expression

∀ X (man(X) → mortal (X))man(Socrates) → mortal (Socrates)

man(socrates)

modus ponens

∀ X (man(X) → mortal (X))man(Socrates) → mortal (Socrates)

man(socrates)mortal(socrates)

set of true expression

Ch 2 The Predicate Calculus 90

2.3 Using inference rules

2.3.1Inference rules

2.3.2Unification

2.3.3 A Unification Example

to produce predicatecalculus expressions

Ch 2 The Predicate Calculus 91

2.3.2 Unification

Why ?

For resolution inference rule

QP → QP

E1 ∨ E3E1 ∨ E2¬E2 ∨ E3

For modus ponens inference rule

P → QPQ

E1 ∨ E2¬E2 ∨ E3E1 ∨ E3

infer

infer

Are two expressions the same or match ?

Ch 2 The Predicate Calculus 92

2.3.2 UnificationAre two expressions the same or match ?

In propositional calculus:Two expressions match if and only ifthey are syntactically identical.In predicate calculus: ( the existence of variables in expression )

The process of match two sentences is complicated.

Unification(Algorithm)Unification(Algorithm)

Expression 1Expression 2

Match or Not ?

for determining the needed substitutions

Page 24: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 93

2.3.2 Unification

Unification(Algorithm)Unification(Algorithm)

man(socrates)man(X) Match, {socrates/X}

Socrates in man(socrates) was substituted for X in ∀ X(man(X) → mortal(X)Modus ponens : mortal(socrates)

Example 1:Example 1:

Ch 2 The Predicate Calculus 94

2.3.2 Unification

Unification(Algorithm)Unification(Algorithm)

p(X)p(Y) Match, {Y/X}

Example 2:Example 2:

p(X) and p(Y) are equivalent, Y may be substituted for Xto make the sentences match.

Ch 2 The Predicate Calculus 95

2.3.2 Unification

∃ X parent(X, tom)

Existence qualified variable X

This assertion is true.

parent(bob, tom)parent(mary, tom)

Logical database must be expressed in an appropriate form:1. All variables be universally quantified.2. Existentially quantified variables may be eliminated

from sentences in the database by replacing them with the constants that make the sentence true.

May be complicated.

Ch 2 The Predicate Calculus 96

2.3.2 UnificationUnification is complicated: Some instances of the expression

{ fred/X, Z/Y }

3) foo(Z, a, goo(moo(Z)))

foo(X, a, goo(Y)

1) foo(fred, a, goo(Z)

2) foo(W, a, goo(jack)) { W/X, jack/Y }

{ Z/X, moo(Z)/Y }

Unification

Unification are also referred to as bindings.A variable is said to be bound to the valuesubstituted for it.

Page 25: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 97

2.3.2 Unification

A variable cannot be unified with a term containing that variable. X cannot be replaced by p(X) as this creates an infinite expression: P(p(p(p(…X)…).The test for this situation is called the occurs check.

occurs checkoccurs check

Ch 2 The Predicate Calculus 98

2.3.2 Unification

It is important that any unifying substitution be

made consistently across all occurrences of the

variable in both expression be matched.

If a variable is bound to a constant, that variable

may not be given a new binding in a future

unification.

Ch 2 The Predicate Calculus 99

2.3.2 UnificationComposition of unification substitutions Composition of unification substitutions

If S and S’ are two substitution sets, then thecomposition of S and S’ (written SS’) is obtained by Applying S’ to the element of S and adding the result to S.

Example:{ X/Y, W/Z }, { V/X }, { a/V, f(b)/W }{ V/Y, W/Z} {a/V. f(b)/W }So, these are equivalent to the single substitution.{ a/Y, f(b)/Z }

Ch 2 The Predicate Calculus 100

2.3.2 Unification

A final requirement of the unification algorithm is that the unifier be as general as possible: that the most general unifier be found for the two expressions. This is important, because, if generality is lost in the solution process, it will lesson the scope of the eventual solution or even eliminate the possibility of a solution entirely.

Most General UnifierMost General Unifier

input

Page 26: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 101

2.3.2 Unification

< Example >In unifying p(X) and p(Y), and constant expression such as { fred/X, fred/Y } will do the trick. However, fred is not the most general unifier; any variable will work and produce a more general expression: {Z/X. Z/Y}. fred would be a unifier, but it would lessen the generality of the result.

Most General UnifierMost General Unifier

Ch 2 The Predicate Calculus 102

2.3.2 Unification

If s is any unifier of expressions Eand g is the most general unifier of that set of expressions, then for s applied to E there exists another unifier s’ such that Es = Egs’,where Es and Egs’ are the composition of unifiers applied to the expression E.

DEFINITION: DEFINITION: MOST GENERAL UNIFIER (MOST GENERAL UNIFIER (mgumgu))

Ch 2 The Predicate Calculus 103

2.3.2 Unificationfunction unify (E1, E2) function unify (E1, E2)

Unify takes as arguments two expressions in the predicate calculus and return either the most general unifying substitutionsor the constant FAIL if no unification is possible.Unify is defined as a recursive function.The recursion stop when either argument is a symbol or the elements of the expression have all been match.

Ch 2 The Predicate Calculus 104

2.3.2 Unification

PC SYNTAXPC SYNTAX LIST SYNTAXLIST SYNTAX

p ( a, b ) ( p a b )p ( f ( a ), g ( X, Y ) ) ( p ( f a ) ( g X Y ) )equal ( eve, mother(cain) ) ( equal eve ( mother cain ) )

By representing an expression as a list (an order sequence of elements) with the predicate or function name as the first element followed by its arguments, we simplify the manipulation of expressions.

Page 27: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 105

2.3.2 Unificationfunction unify (E1, E2) function unify (E1, E2)

begincase

both E1 and E2 are constants or the empty list: %recursion stopif E1 = E2 then return {}

else return FAIL; E1 is a variable:

if E1 occurs in E2 then return FAIL % occurs checkelse return {E2/E1}

E2 is a variable:if E2 occurs in E1 then return FAIL % occurs check

else return {E1/E2} either E1 or E2 are empty: then return FAIL %the lists are of different sizesotherwise: [ ---- ] % both E1 and E2 are list

end % end case end

Ch 2 The Predicate Calculus 106

2.3.2 Unification

otherwise:begin

HE1 := first element of E1;HE2 := first element of E2;SUBS1 := unify(HE1, HE2);if SUBS1 := FAIL then return FAIL;TE1 := apply(SUBS1, rest of E1) TE2 := apply(SUBS1, rest of E2)SUBS2 := unify(TE1, TE2);if SUBS2 := FAIL then return FAIL;

else return composition(SUBS1, SUBS2)end

(Conti.)function unify (E1, E2) function unify (E1, E2)

Ch 2 The Predicate Calculus 107

2.3 Using inference rules

2.3.1Inference rules

2.3.2Unification

2.3.3 A Unification Example

to produce predicatecalculus expressions

Ch 2 The Predicate Calculus 108

2.3.3 A Unification Exampleunify(( parents X (father X) (mother bill)), (parents bill (father bill) Y )).unify(( parents X (father X) (mother bill)), (parents bill (father bill) Y )).

E1 : ( parents X (father X) (mother bill))E2 : ( parents bill (father bill) Y )

<< neither argument is an atomic symbol >>unify ( parents, parents) return empty substitution, {}

<< applying empty substitution {} to the remainder : no change >>unify ( (X (father X) (mother bill)), (bill (father bill) Y ) )unify ( X , bill ) return substitution, {bill/X}

<< applying substitution {bill/X} to the remainder >>((father X) (mother bill)) ----- > ((father bill) (mother bill))((father bill) Y ) ----- > ((father bill) Y)

Page 28: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 109

2.3.3 A Unification Example

1. unify(( parents X (father X) (mother bill)), (parents bill (father bill) Y ))

Unify first elements and apply substitution to rest

2. unify( parents, parents )

return {}

3. unify ( (X (father X) (mother bill)), (bill (father bill) Y ) )

Fig 2.4 Initial steps

Ch 2 The Predicate Calculus 110

2.3.3 A Unification Example1. unify(( parents X (father X) (mother bill)), (parents bill (father bill) Y ))

2. unify( parents, parents )

3. unify ( (X (father X) (mother bill)), (bill (father bill) Y ) )

Fig 2.5 Further steps

4. unify ( X , bill )

Unify first elements and apply substitution to rest

return {}

5. unify ( ((father bill) (mother bill)), ((father bill) Y ) )

return {bill/X}

Ch 2 The Predicate Calculus 111

2.3.3 A Unification Example

unify ( ((father bill) (mother bill)), ((father bill) Y ) )

unify(( parents X (father X) (mother bill)), (parents bill (father bill) Y )).unify(( parents X (father X) (mother bill)), (parents bill (father bill) Y )).

unify ( (father bill), (father bill) )

unify ( father, father ) return empty substitution, {}

unify ( bill, bill ) return empty substitution, {}

unify ( (), () ) return empty substitution, {}

unify ( (bill), (bill) ) return empty substitution, {}

unify ( ( (mother bill)), ( Y ) )unify ( ( (mother bill)), ( Y ) )unify ( (father bill), (father bill) )unify ( (father bill), (father bill) )

Ch 2 The Predicate Calculus 112

2.3.3 A Unification Exampleunify(( parents X (father X) (mother bill)), (parents bill (father bill) Y )).unify(( parents X (father X) (mother bill)), (parents bill (father bill) Y )).

unify ( ( (mother bill)), ( Y ) )unify ( ( mother bill), Y ) return substitution,

{ (mother bill)/Y }unify ( (), () ) return empty substitution, {}

Finally, composition of {bill/X} and { (mother bill)/Y }

unify ( ( (mother bill)), ( Y ) )unify ( ( (mother bill)), ( Y ) )

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

Page 29: _شبتر 2شرح ذكاء

Chapter 2 The Predicate Calculus

Application:A Logic-based Financial

Advisor

Ch 2 The Predicate Calculus 114

2.4 Application:

1. Individuals with an inadequate savings account should always make increasing the amount saved their first priority, regardless of their income.

2. Individuals with an adequate savings account and an adequate income should consider a riskier but potentially more profitable investment in the stock market.

3. Individuals with a lower income who already have an adequate savings account may want to consider splitting their surplus income between savings and stocks, to increase the cushion in savings while attempting to increase their income through stocks.

A Logic-based Financial Advisor

The use of predicate calculusto represent and reason about problem domains.

Ch 2 The Predicate Calculus 115

2.4 A Logic-based Financial AdvisorThe adequacy of both savings and incomeis determined by the the number of dependentsan individual must support.1. Have at least $5,000 in the bank for each

dependents2. A steady income and supply at least $15,000 per

year plus an additional $4,000 for each dependents.Constant: adequate, inadequate

Major Featuresunary predicates: savings_account and income

saving_account(adequate), saving_account(inadequate)income(adequate), income(inadequate)

Ch 2 The Predicate Calculus 116

2.4 A Logic-based Financial AdvisorConclusions

unary predicate: investmentinvestment(stocks), investment(savings), investment(combination).

Investment strategies1. savings_account(inadequate)→investment(savings)2. savings_account(adequate) ∧ income (adequate)

→investment(stocks)3. savings_account(adequate) ∧ income

(inadequate) →investment(combination)

Page 30: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 117

2.4 A Logic-based Financial AdvisorIs savings adequate or inadequate ?4. ∀ X amount_saved(X) ∧

∃ Y (dependents(Y) ∧ greater(X, minsavings(Y))) → savings_account(adequate)

5. ∀ X amount_saved(X) ∧∃ Y (dependents(Y) ∧ ¬ greater(X, minsavings(Y))) → savings_account(inadequate)

where minsavings(Y) = 5000*Yamount_saved(X) : the current amount in savingsdependents(Y) : the number of dependents of an investorgreater(X, Y) : standard arithmetic test

Ch 2 The Predicate Calculus 118

2.4 A Logic-based Financial AdvisorIs income adequate or inadequate ?6. ∀ X earnings(X, steady) ∧

∃ Y (dependents(Y) ∧ greater(X, minincome(Y))) → income(adequate)

7. ∀ X earnings(X , steady) ∧∃ Y (dependents(Y) ∧ ¬ greater(X, minincome(Y))) → income(inadequate)

8. ∀ X earnings (X , unsteady) →income(inadequate).

where minincome(Y) = 15000 + 4000* YBinary predicate earnings1. Amount earned2. Constant: steady, or unsteady

Ch 2 The Predicate Calculus 119

2.4 A Logic-based Financial AdvisorExample: an individual with 3 dependents, $22,000 in savings, and a steady income of $25,0009. amount_saved(22000)10. earnings(25000, steady)11. dependents(3)

What is the logical system ?

?

Ch 2 The Predicate Calculus 120

2.4 A Logic-based Financial Advisor

1. savings_account(inadequate)→investment(savings)2. savings_account(adequate) ∧ income (adequate) →investment(stocks)

3. savings_account(adequate) ∧ income (inadequate) →investment(combination)4. ∀ X amount_saved(X) ∧ ∃ Y (dependents(Y) ∧ greater(X, minsavings(Y)))

→ savings_account(adequate)5. ∀ X amount_saved(X) ∧ ∃ Y (dependents(Y) ∧ ¬ greater(X, minsavings(Y)))

→ savings_account(inadequate)6. ∀ X earnings(X, steady) ∧ ∃ Y (dependents(Y) ∧ greater(X, minincome(Y)))

→ income(adequate)7. ∀ X earnings(X , steady) ∧ ∃ Y (dependents(Y) ∧ ¬ greater(X, minincome(Y)))

→ income(inadequate)8. ∀ X earnings (X , unsteady) → income(adequate)

9. amount_saved(22000)10. earnings(25000, steady)

11. dependents(3)

1. savings_account(inadequate)→investment(savings)2. savings_account(adequate) ∧ income (adequate) →investment(stocks)

3. savings_account(adequate) ∧ income (inadequate) →investment(combination)4. ∀ X amount_saved(X) ∧ ∃ Y (dependents(Y) ∧ greater(X, minsavings(Y)))

→ savings_account(adequate)5. ∀ X amount_saved(X) ∧ ∃ Y (dependents(Y) ∧ ¬ greater(X, minsavings(Y)))

→ savings_account(inadequate)6. ∀ X earnings(X, steady) ∧ ∃ Y (dependents(Y) ∧ greater(X, minincome(Y)))

→ income(adequate)7. ∀ X earnings(X , steady) ∧ ∃ Y (dependents(Y) ∧ ¬ greater(X, minincome(Y)))

→ income(inadequate)8. ∀ X earnings (X , unsteady) → income(adequate)

9. amount_saved(22000)10. earnings(25000, steady)

11. dependents(3)

The set of logical sentences describes the problem domainThe set of logical sentences describes the problem domain

Page 31: _شبتر 2شرح ذكاء

Ch 2 The Predicate Calculus 121

2.4 A Logic-based Financial Advisor

Step 1Step 1

Using unification and modus ponens, a correct investment strategy for this individual may be inferred:

Unify the conjunction of 10 and 11with the first two components of the premise of 7

earnings(25000, steady) ∧ dependents(3)earnings(X, steady) ∧ dependents(Y)

{ 25000/X, 3/Y }

earnings(25000 , steady) ∧dependents(3) ∧ ¬ greater(25000, minincome(3) )→ income(inadequate)

earnings(25000 , steady) ∧dependents(3) ∧ ¬ greater(25000, minincome(3) )→ income(inadequate)

27000

new assertion 12. income(inadequate)

7.

Ch 2 The Predicate Calculus 122

2.4 A Logic-based Financial AdvisorStep 2Step 2

Unify the conjunction of 9 and 11with the first two components of the premise of 4

amount_saved(22000) ∧ dependents(3)amount_saved(X) ∧ dependents(Y)

{ 22000/X, 3/Y }

amount_saved(22000) ∧dependents(3) ∧ greater(22000, minsavings(3) )→ savings_account(adequate)

amount_saved(22000) ∧dependents(3) ∧ greater(22000, minsavings(3) )→ savings_account(adequate)

15000

new assertion 13. savings_account(adequate)

4.

Ch 2 The Predicate Calculus 123

2.4 A Logic-based Financial AdvisorStep 3Step 3

income(inadequate) ∧ savings_account(adequate)→ investment(combination)

income(inadequate) ∧ savings_account(adequate)→ investment(combination)

3, 12, 13 Conclusion: investment(combination)modus ponens

This example illustrates how predicate calculus may be used to reason about a realistic problem, drawing correct conclusionsby applying inference rule to the initial problem description.

We have NOT discussed exactly how the algorithm can determine the correct inferences to make to solve a given problemor the way in which this can be implemented on a computer?


Recommended