0% found this document useful (0 votes)
154 views43 pages

Predicate Calculus AI

The document discusses the Predicate Calculus, which extends propositional logic to represent statements about objects, properties of objects, and relationships between objects. It introduces predicates, terms, atomic sentences, and well-formed formulas in predicate calculus. It also explains how to determine the truth value of predicate calculus expressions using an interpretation and domain. The key aspects covered are predicates, terms, quantifiers, and evaluating expressions based on an interpretation.

Uploaded by

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

Predicate Calculus AI

The document discusses the Predicate Calculus, which extends propositional logic to represent statements about objects, properties of objects, and relationships between objects. It introduces predicates, terms, atomic sentences, and well-formed formulas in predicate calculus. It also explains how to determine the truth value of predicate calculus expressions using an interpretation and domain. The key aspects covered are predicates, terms, quantifiers, and evaluating expressions based on an interpretation.

Uploaded by

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

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

1
Chapter Objectives

• Learn the basics of knowledge representation


• Learn the basics of inference using
propositional logic and predicate logic
• The agent model: Has a knowledge base of
logical statements and can draw inferences.

2
Example

If thunk is an English verb, then thunk is an


English word. If thunk is an English word, then
thunk is in Noah’s Lexicon. Thunk is not in
Noah’s Lexicon.
Is thunk an English verb?

3
Propositional logic

The symbols of propositional calculus are


the propositional symbols:
P, Q, R, S, …
the truth symbols:
true, false
and connectives:
, , , →, 

4
Propositional Calculus Sentences

Every propositional symbol and truth symbol is


a sentence.
Examples: true, P, Q, R.
The negation of a sentence is a sentence.
Examples: P,  false.
The conjunction, or and, of two sentences is a
sentence.
Example: P  P

5
Propositional Calculus Sentences
(cont’d)
The disjunction, or or, of two sentences is a
sentence.
Example: P  P
The implication of one sentence from another is
a sentence.
Example: P → Q
The equivalence of two sentences is a
sentence.
Example: P  Q  R
Legal sentences are also called well-formed
formulas or WFFs.
6
Propositional calculus semantics

An interpretation of a set of propositions is the


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.
The truth assignment of negation, P, where P
is any propositional symbol, is F if the
assignment to P is T, and is T is the assignment
to P is F.
The truth assignment of conjunction, , is T
only when both conjuncts have truth value T;
otherwise it is F.
7
Propositional calculus semantics (cont’d)

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 F;
otherwise it is T.
The truth assignment of equivalence, , is T
only when both expressions have the same
truth assignment for all possible
interpretations; otherwise it is F.

8
For propositional expressions P, Q, R

9
Fig. 2.1: Truth table for the operator 

10
Fig. 2.2 Truth table demonstrating the
equivalence of PQ and P→Q

11
Proofs in propositional calculus

If thunk is an English verb, then thunk is an


English word. If thunk is an English word, then
thunk is in Noah’s Lexicon. Thunk is not in
Noah’s Lexicon.
Is thunk an English verb?
P: Thunk is an English verb.
Q: Thunk is an English word.
R: Thunk is in Noah’s Lexicon.
Premises: P→Q, Q→R, R
Question: P

12
Prove using a truth table
Variables Premises Trial
Conclusions
P Q R P→Q Q→R R P P
T T T T T F T F
T T F T F T T F
T F T F T F T F
T F F F T T T F
F T T T T F F T
F T F T F T F T
F F T T T F F T
F F F T T T F T
13
Propositional calculus is cumbersome

If thunk is an English verb, then thunk is an


English word. If thunk is an English word, then
thunk is in Noah’s Lexicon. Thunk is not in
Noah’s Lexicon.
Is thunk an English verb?
If a word is an English verb, then it is an
English word. If a word is an English word, then
it is in Noah’s Lexicon.
Thunk is not in Noah’s Lexicon.
Is thunk an English verb?

14
Represent in predicate calculus

If a word is an English verb, then it is an


English word. If a word is an English word, then
it is in Noah’s Lexicon.
Thunk is not in Noah’s Lexicon.
Is thunk an English verb?
Premises:
W English-verb (W)→ English-word (W)
W English-word (W)→ In-Noah-L (W)
 In-Noah-L (thunk)
Question: English-verb(thunk)

15
Can also use functions

A person’s mother is that person’s parent.


X person (X)→ parent(mother-of(X),X)
There are people who think this class is cool.
X person (X)  T (X)
A person’s mother’s mother is that person’s
grandmother
X person (X)→
grandmother (mother-of(mother-of(X)), X)

16
The role of the knowledge engineer

fisher-hall-is-a-building
ee-is-a-building
building (fisher)
building (ee)
white-house-on-the-corner-is-a-building
green (fisher)
color (fisher, green)
holds (color, fisher, green)
holds (color, fisher, green, jan-2003)
holds (color, fisher, blue, jul-2003) 17
18
Symbols and terms
1. Truth symbols true and false (these are
reserved symbols)
2. Constant symbols are symbol expressions
having the first character lowercase.
E.g., thunk, fisher
3. Variable symbols are symbol expressions
beginning with an uppercase character.
E.g., X, Y, Z, Building
4. Function symbols are symbol expressions
having the first character lowercase.
Arity: number of elements in the domain
E.g., mother-of (bill); maximum-of (7,8) 19
Symbols and terms (cont’d)
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.
E.g., mother-of(mother-of(joe))
maximum(maximum(7, 18), add-one(18))
A term is either a constant, variable, or function
expression.
E.g. color-of(house-of(neighbor(joe)))
house-of(X)

20
Predicates and atomic sentences

Predicate symbols are symbols beginning with


a lowercase letter. Predicates are special
functions with true/false as the range.
Arity: number of arguments
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 atomic
sentences.
E.g., mother-of(joe, susan)
greater-than (2, 3)

21
Predicate calculus sentences

Every atomic sentence is a sentence.


1. If s is a sentence, then so is its negation, s.
If s1 and s2 are sentences, then so is their
2. Conjunction, s1  s2 .
3. Disjunction, s1  s2 .
4. Implication, s1 → s2 .
5. Equivalence, s1  s2 .

22
Predicate calculus sentences (cont’d)

If X is a variable and s is a sentence, then so are


6. X s.
7. X s.

Remember that logic sentences evaluate to true


or false, therefore only such objects are atomic
sentences. Functions are not atomic sentences.

23
verify_sentence algorithm

24
How to compute the truth value of
predicate calculus expressions
Assume an expression E and an interpretation I
over 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.

25
How to compute the truth value of
predicate calculus expressions (cont’d)
4. The value of the 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 F if the value
of the sentence is T.
7. The value of the conjunction of two
sentences is T, if the value of both sentences is
T and F otherwise.
8-10. The truth value of expressions using ,→,
and  is determined as defined in Section 2.1.2.
26
How to compute the truth value of
predicate calculus expressions (cont’d)
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 under I such that S is T, and it
is F otherwise

27
Revisit  and 

A person’s mother is that person’s parent.


X person (X)→ parent(mother-of(X),X)
vs.
X person (X)  parent(mother-of(X),X)
I: joe, jane people
fido is a dog
person (joe) is T, person (jane) is T
person (fido) is F, dog (fido) is T
mother-of (joe) is jane
28
Revisit  and  (cont’d)

There are people who think this class is cool.


X person (X)  T (X)
vs.
X person (X) → T (X)
I: joe, jane people
fido is a dog
person (joe) is T, person (jane) is T
person (fido) is F, dog (fido) is T
mother-of (joe) is jane
29
First-order predicate calculus

First-order predicate calculus allows quantified


variables to refer to objects in the domain of
discourse and not to predicates or functions.
John likes to eat everything.
X food(X) → likes (john,X)
John likes at least one dish Jane likes.
Y food(X)  likes (jane, X) → likes (john, X)
John “does” everything Jane does.
P P(Jane) → P(john) This is not first-order.

30
Order of quantifiers matters

Everybody likes some food.

There is a food that everyone likes.

Whenever someone likes at least one spicy


dish, they’re happy.

31
Order of quantifiers matters

Everybody likes some food.


X Y food(X)  likes (X,Y)
There is a food that everyone likes.
Y X food(X)  likes (X,Y)
Whenever someone likes at least one spicy
dish, they’re happy.
X Y food(Y)  spicy(Y)  likes (X,Y) →
happy(X)

32
Examples

John’s meals are spicy.

Every city has a dogcatcher who has been


bitten by every dog in town.

For every set x, there is a set y, such that the


cardinality of y is greater than the cardinality of
x.

33
Examples

John’s meals are spicy.


X meal-of(John,X) → spicy(X)
Every city has a dogcatcher who has been
bitten by every dog in town.
C D Z city(C) → ( dogcatcher(D,C) 
(dog(Z)  lives-in (Z, C) → bit (Z, D)) )

34
Examples (cont’d)

For every set x, there is a set y, such that the


cardinality of y is greater than the cardinality of
x.
X Y U V set(X) → (set(Y)  cardinality(X,U)
 cardinality(Y, V)  greater-than(V,U))

35
Blocks world

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

a d

36
Blocks world example

All blocks on top of blocks that have been


moved or that are attached to blocks that have
been moved have also been moved.
X Y (block(X)  block(Y) 
(on(X,Y)  attached (X,Y))  moved (Y)) →
moved(X)

37
Interpretation

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:
1. Each constant is assigned an element of D.
2. Each variable is assigned to a nonempty
subset of D (allowable substitutions).
3. Each function f of arity m is defined (Dm to D).
4. Each predicate of arity n is defined
(Dn to {T,F}).
38
Satisfy, model, valid, inconsistent

For a predicate calculus expression X and 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 iff there is an interpretation and
variable assignment that satisfy it; otherwise it
is unsatisfiable.

39
Satisfy, model, valid, inconsistent (cont’d)

A set of expressions is satisfiable iff there is an


interpretation and variable assignment that
satisfy every element.
If a set of expressions is not satisfiable, it is
said to be inconsistent.
If X has a value T for all possible
interpretations, X is said to be valid.

40
Proof procedure

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.

(Proof by resolution inference rule is described


in Chapter 11.)

41
Logically follows, sound, and complete

A predicate calculus expression X logically


follows from a set S of predicate calculus
expressions 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 expressions 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.

42
43

You might also like