The Predicate Calculus
The Predicate Calculus
Introduction The Propositional Calculus The Predicate Calculus Using Inference Rules to Produce Predicate Calculus Expressions
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.
Example
Given:
The red block is above the blue block The green block is above the red block
Infer:
The green block is above the blue block The blocks form a tower
Example
Given: If it is sunny today, then the sun shines on the screen. If the sun shines on the screen, the blinds are brought down. The blinds are not down. Find out: Is it sunny today?
A KR language needs to be
expressive unambiguous flexible
Logic consists of
A language which tells us how to build up sentences in the language (i.e., syntax), and and what the sentences mean (i.e., semantics) An inference procedure which tells us which sentences are valid inferences from other sentences
Propositional logic
The symbols of propositional calculus are the propositional symbols: P, Q, R, S, the truth symbols: true, false and connectives: , , , ,
10
Examples: true, P, Q, R.
The negation of a sentence is a sentence. Examples: P, false.
11
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.
12
15
P T T T T
Q T F T F
PQ T F F F
16
17
Is it sunny today?
P: It is sunny today.
18
R PQ QR T T T F T F T F T F T F F T T T T F T T T F T T
If it is sunny on a particular day, then the sun shines on the screen. If the sun shines on the screen on a particular day, the blinds are brought down. The blinds are not down today. Is it sunny today?
20
Premises: D sunny (D) screen-shines (D) D screen-shines(D) blinds-down(D) blinds-down (today) Question: sunny(today)
21
22
23
house_of(X)
25
26
Examples
greater_than(2, 3)
Predicate symbol term (constant)
mother_of(joe, susan)
mother_of(sister_of(joe), susan)
27
28
Remember that logic sentences evaluate to true or false, therefore only such objects are atomic sentences. Functions are not atomic sentences.
29
verify_sentence algorithm
30
Contains: Facts
(quantified or not)
Result
+ Function
implementations
31
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}).
32
35
Revisit and
A persons mother is that persons parent. X person (X) parent(mother-of(X),X) vs. X person (X) parent(mother-of(X),X) I: joe, jane are people fido is a dog person (joe) is T, person (jane) is T
person (fido) is F,
mother-of (joe) is jane
dog (fido) is T
36
person (fido) is F,
mother-of (joe) is jane
dog (fido) is T
37
P P(Jane) P(john)
39
40
Examples
Johns 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.
41
Examples
Johns meals are spicy. X meal-of(John,X) spicy(X) Every city has a dogcatcher who has been bitten by every dog in town. T C D city(C) ( dogcatcher(C,T)
42
Examples (contd)
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))
43
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)
44
Blocks world
on (c,a) on(b,d) ontable(a) ontable(d) clear(b) clear(c) c a hand_empty b d
45
moved(X)
46
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.
47
48
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.
49
51
And introduction allows us to infer the truth of a conjunction from the truth of its conjuncts. For instance, if P and Q are true, then P Q is true.
52
Universal instantiation
Universal instantion states that if any universally quantified variable in a true sentence is replaced by any appropriate term from the domain, the result is a true sentence. Thus, if a is from the domain of X, X P(X) lets us infer P(a).
53
blinds-down (today)
54
Unification
Make sentences look alike. Unify p(a,X) and p(a,b) Unify p(a,X) and p(Y,b) Unify p(a,X) and p(Y, f(Y)) Unify p(a,X) and p(X,b) Unify p(a,X) and p(Y,b) Unify p(a,b) and p(X, X)
55
Unification examples
Unify p(a,X) and p(a,b) answer: b/X Unify p(a,X) and p(Y,b) answer: a/Y, b/X Unify p(a,X) and p(Y, f(Y)) answer: a/Y, f(a)/X p(a,f(a)) p(a,b) p(a,b)
56
answer: b/Y
this is an mgu
this in not an mgu
57
b/X, b/Y
Basic idea: Commit to a substitution only if you have to; keep it as general as possible.
58
Unification algorithm
Basic idea: can replace variables by: other variables constants function expressions High level algorithm: Represent the expression as a list Process the list one by one
Determine a substitution (if necessary)
Apply to the rest of the list before proceeding
59
60
62
Processed example
(parents X (father X) (mother bill)), (parents bill (father bill) Y) parents =? parents yes
return nil
(X (father X) (mother bill)), (bill (father bill) Y) X =? bill no, substitute
return {bill/X} (bill (father bill) (mother bill)), (bill (father bill) Y) bill =? bill return nil yes
63
64
65
Example rule:
If the amount in the savings account is inadequate, increasing this amount should be the first priority.
66
Sentences
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) Y is the number of dependents, minsavings is the number of dependents multiplied by 5000.
67
Sentences (contd)
5. X amount_saved(X) Y (dependents (Y) greater (X, minsavings(Y))) savings_account(inadequate)
68
Sentences (contd)
9. amount_saved(22000) 10. earnings(25000, steady)
13. savings_account(adequate)
Using 12, 13, and 3, we can infer 14. investment(combination)
69
Summary
Propositional calculus: no variables or functions
70
Key concepts
Sentence Interpretation Proposition, term, function, atom Unification and mgu Proofs in logic
71