Professional Documents
Culture Documents
Today
Propositional Logics
Predicate Logics
Automated reasoning
Deduction
Agent
Robotics
Reasoning
Search
Forward Chaining
Backward Chaining
Resolution-Refutation
Perception
Learning
Planning
Knowledge Constrai
nt
rep.
satisfac
tion
Natural
language
Expert
Systems
...
Logic
What do we need?
To represent knowledge
To reason with knowledge
Source: Luger p. 63
// Goat and cabbage cannot be on same side and farmer on opposite side
opposite(X, Y) (unsafe(state(Y,Y,G,C)))
(move(state(X,X,G,C), state(Y,Y,G,C))
opposite(X, Y) (unsafe(state(Y,W,Y,C)))
(move(state(X,W,X,C), state(Y,W,Y,C))
Source: Luger p. 64
Propositional logic
Predicate logic
Fuzzy logic for reasoning under uncertainty
Default logics
Non-monotonic logic
Description logics
Non-standard logics
10
Propositional logic
Well-defined formal semantics
Sound and complete inference rules
But expressive power is too restrictive
Predicate logic
Well-defined formal semantics
Sound and complete inference rules
But more expressive power
11
Today
Propositional Logics
Predicate Logics
Automated reasoning
Deduction
Forward Chaining
Backward Chaining
Resolution-Refutation
12
Truth symbols:
Propositional symbols:
True False
P, Q,
13
Example
Propositions are
P
Q
P
Q
P
Q
P
Q
True
True
False
True
True
True
True
True
False
False
False
True
False
False
False
True
True
False
True
True
False
False
False
True
False
False
True
True
15
Double-negation elimination:
(
P) P
(PQ) (P Q)
Contrapositive law:
(P Q) (
Q P)
de Morgans law:
(P
Q) P Q
(P
Q) P Q
16
Commutative law:
Associative law:
(P Q) (Q P)
(P Q) (Q P)
((P Q) R) (P (Q R))
((P Q) R) (P (Q R))
Distributive law:
P (Q R) (P Q) (P R)
P (Q R) (P Q) (P R)
17
Pic-nic cancelled C
Stay at home H
(R
H) W
R W
(R (
C H)) W or (R C) H) W
(C C) R H
18
It rained Wednesday
It rained Friday
It rained Saturday
Today
Propositional Logics
Predicate Logics
Automated reasoning
Deduction
Forward-chaining
Backward-chaining
Resolution-Refutation
20
Predicate Calculus
jogged(bill, sunday) or
activity(bill, jogging, sunday)
or...
weather(sunday, rain)
letters, digits, _
begin with a letter
used to denote objects, properties or relations in the world
+ numbers & arithmetic operations
Symbols:
1.
2.
3.
4.
5.
Truth symbols
Constants
Variables
Functions
Predicates
22
FOPL:
Terms:
Predicates
Sentence:
Atomic sentence
Non-atomic sentence
Variables (eg. X, Y)
24
plus(2,3) evaluates to 5
ex: father/1
note: father/1 is different from father/2
form function expressions together with their arguments
f(X,Y), father(david), price(bananas), plus(2,3)
25
Predicates
ex: father/1
note: father/1 is different from father/2
ex:
predicate
father(david,george) evaluates to T
likes(george,kate)
function
likes(X,X)
function
likes(joe,kate,susy)
friends(father_of(david),father_of(andrew))
26
Quantifiers
universal quantification:
existential quantification:
X weather(X,rain)
X likes(X,ice_cream)
X weather(X,rain)
Y friends(Y,peter)
Examples
X Y Z abbreviated as X,Y,Z
28
More Examples
1.
2.
3.
4.
5.
6.
7.
People only try to assassinate leaders to whom they are not loyal.
X Y person(X)
leader(Y)
tryToAssasinate(X,Y) loyalTo(X,Y)
8.
29
Trivia on Quantifiers
true or false?
30
because
Eg:
X loves(john,X) --> OK
X X(john,mary) --> not OK
31
Description of a snapshot
of blocks world
on(c,a)
on(b,d)
ontable(a)
ontable(d)
clear(b)
clear(c)
hand_empty
33
Inference Rules
Substitution/Unification
35
Examples of Substitution
A= X cat(X) annoying(X)
= {felix/X}
A = cat(felix) annoying(felix)
A= X Y near(X,Y) near(Y,X)
= {john/X, mary/Y}
A = near(john,mary) near(mary,john)
36
Unification
A= cat(X)
B= cat(Y)
= {Y/X} or = {felix/X, felix/Y}
A= friend(john,X)
B= friend(Y, Z)
= {john/Y, Z/X} or
= {john/Y, mary/X, mary/Z} or
= {john/Y, ali/X, ali/Z} or
37
With ={X/Y}
P1 P2
With {f(Y)/X}
P1 P2
MGU:
p(a,b) --> [p a b]
p(f(a), g(X,Y)) --> [p [f a] [g X Y]]
parents(X, father(X), mother(bill)) -->
[ parents X [father X] [mother bill]]
39
More Formally
function unify(E1, E2)
if E1, E2 both constants or both empty then
if E1 = E2 then return {} else return FAIL
if E1 or E2 variable then
if E1 variable
if E1 occurs in E2 then return FAIL
else return {E2/E1}
else if E2 variable
if E2 occurs in E1 then return FAIL
else return {E1/E2}
if E1 or E2 empty then return FAIL
S1
if
F1
F2
S2
if
:=
S1
:=
:=
:=
S2
An Example
unify( [parents X [father X] [mother bill]],
[parents bill [father bill] Y] )
unify(parents, parents) --> {}
apply {} to rest of expression
unify(X [father X] [mother bill], bill [father bill] Y )
unify(X, bill) --> {bill/X}
apply {bill/X} --> [father bill] [mother bill], [father bill] Y
unify([father bill] [mother bill], [father bill] Y)
unify(father, father) --> {}
unify(bill, bill) --> {}
unify([], []) --> {}
unify([mother bill], Y) --> {[mother bill]/Y}
apply {[mother bill]/Y} to rest of expression
unify([], []) --> {}
return {bill/X} {[mother bill]/Y} = { bill/X, [mother bill]/Y }
41
Today
Propositional Logics
Predicate Logics
Automated reasoning
Deduction
Forward Chaining
Backward Chaining
Resolution-Refutation
42
Automated Reasoning
43
The Task
We have:
We want:
We need:
Logical Inference
Inference: process of deriving
new facts from a set of premises
1.
2.
3.
Deduction
Induction
Abduction
45
Deduction
Sound inference
46
Induction
Not sound
But, can be seen as hypothesis construction or
generalisation
47
Abduction
Used in medicine
Today
Propositional Logics
Predicate Logics
Automated reasoning
Deduction
Forward Chaining
Backward Chaining
Resolution-Refutation
49
Modus Ponens
PQ P
Q
2.
And-Introduction
P Q
PQ
5.
P
P
7.
Or-Introduction
Unit Resolution
P Q Q
P
And-Elimination
PQ
P
4.
Modus Tollens
Q P Q
P
3.
6.
8.
Resolution
P Q Q R
PR
P Q Q R
P R
P
PQ
50
Deduction rules of
propositional logics
Universal Elimination:
Existential Elimination
(i.e. naming an existential
var.)
k=a new constant
X P ( X)
P( g )
X likes( X, iceCream )
likes(mary, iceCream )
Existential Introduction
X P( X)
P (k )
P( g )
X P ( X )
X kill( X, Y )
kill(murderer, Y )
51
Proof Procedure
Assume:
we have the facts F1, F2, ..., Fn
we want to show that G is a logical consequence.
Direct proof:
Refutation proof:
52
Today
Propositional Logics
Predicate Logics
Automated reasoning
Deduction
Forward Chaining
Backward Chaining
Resolution-Refutation
53
Forward chaining:
Backward chaining:
54
Example
1) The law says that it is a crime for an American to sell weapons to hostile nations.
2) The country Nono, an enemy of America, has some missiles,
3) and all of its missiles were sold to it by 4) Colonel West, who is American.
1) american(X) weapon(Y) sells(X,Y,Z) hostile(Z) criminal(X)
2) X owns(nono, X) missile(X)
owns(nono, m1) // by Existential Elimination
missile(m1) // by Existential Elimination
enemy(nono, america) // Nono, an enemy of America
3) missile(X) owns(nono, X) sells(west, X, nono)
4) american(west) // Colonel West, who is American
// from world knowledge
missile(X) weapon(X)
enemy(X, america) hostile(X)
Forward Chaining
Example
KB
1.
2.
owns(nono, m1)
3.
missile(m1)
4.
enemy(nono, america)
5.
6.
american(west)
7.
missile(X) weapon(X)
8.
Today
Propositional Logics
Predicate Logics
Automated reasoning
Deduction
Forward Chaining
Backward Chaining
Resolution-Refutation
61
Backward Chaining
Today
Propositional Logics
Predicate Logics
Automated reasoning
Deduction
Forward Chaining
Backward Chaining
Resolution Refutation
71
Modus Ponens
PQ P
Q
2.
And-Introduction
P Q
PQ
5.
P
P
7.
Unit Resolution
P Q Q
P
And-Elimination
PQ
P
4.
Modus Tollens
Q P Q
P
3.
6.
Or-Introduction
8.
Resolution
P Q Q R
PR
P Q Q R
P R
P
PQ
72
Proof by Resolution-Refutation
how the
73
KB:
A
B
(AB) C
KB:
KB:
A
B
(AB) C
C
KB:
A
B
ABC
C
Inconsistent !
Goal: C?
Step1: Add
negation of
goal to KB
Step2: Transform
KB in some
normal form
Step3: Apply
resolution to
show that the
KB is now
inconsistent
74
A
A
Empty clause
(or contradiction)
A B
A B C
A B D
B
B C D
75
More Formally
resolution:
Q R
PR
PQ
3.
76
Resolution Refutation in
Predicate Logics
77
Conversion to CNF
Ex: X (p(X) (
Y(p(Y) p(f(X,Y))) Y(q(X,Y)
p(Y))))
-->
p(X) p(Y) p(f(X,Y)
p(X) q(X,g(X))
p(X) p(g(X))
78
Running example:
X (
Y p(a,Y)
s(Y,X)) (
Y q(X,Y) s(Y,X)
r(X,Y))
X (
Y p(a,Y)
s(Y,X)) (
Y q(X,Y) s(Y,X)
r(X,Y))
X (
Y p(a,Y)
s(Y,X)) (
Y (q(X,Y)
s(Y,X)) r(X,Y))
79
replace
replace
replace
replace
replace
A by A
(A B) by A B
(A B) by A B
(X A) by (X A)
(X
( X A) by ((X
X A)
A)
X (
Y p(a,Y) s(Y,X)) (
Y (q(X,Y) s(Y,X)) r(X,Y))
X (
Y p(a,Y) s(Y,X)) (
Y q(X,Y) s(Y,X) r(X,Y))
80
X (
Y p(a,Y) s(Y,X)) (
Y q(X,Y) s(Y,X) r(X,Y))
X (
Y p(a,Y) s(Y,X)) (
Z q(X,Z) s(Z,X) r(X,Z))
81
X (
Y p(a,Y) s(Y,X)) (
Z q(X,Z) s(Z,X) r(X,Z))
82
83
A Note on Skolemization
84
X p(X) p(sk)
85
ex:
X Y Z p(X,Y,Z) X
Y p(X, Y, sk2(X,Y) )
X Y Z p(X,Y) q(X,Z)
X p(X, sk3(X) ) q(X, sk4(X) )
86
X Y Z (
p(a,Y) s(Y,X))
(q(X,Z) s(Z,X) r(X,Z))
87
X p(a,sk1(X)) s(sk1(X),X)
(q(X,sk2(X)) s(sk2(X),X) r(X,sk2(X)))
88
(
p(a, sk1(X)) s(sk1(X),X) q(X, sk2(X)))
(
p(a, sk1(X)) s(sk1(X),X) s(sk2(X),X))
(
p(a, sk1(X)) s(sk1(X),X) r(X,sk2(X)))
89
ex: (P Q) (R S) (R S T) is written as
P
R
R
Q
S
S T
Summary of Transformations
Example of Resolution-Refutation
Jack owns a dog.
Every dog owner is an animal lover.
No animal lover kills an animal.
Either Jack or Curiosity killed the cat, who, by the way, is named
Tuna.
Did Curiosity kill the cat?
1.
2.
3.
4.
5.
6.
X dog(X) owns(jack,X)
X (
Y dog(Y) owns(X,Y) animalLover(X))
X animalLover(X) (
Y animal(Y) kills(X,Y))
kills(jack,tuna) kills(curiosity,tuna)
cat(tuna)
X cat(X) animal(X) from world knowledge
Conversion to CNF
1a. dog(sk)
1b. owns(jack, sk)
2. dog(f(X)) owns(X, f(X)) animalLover(X)
3. animalLover(X) animal(Y) kills(X,Y)
4. kills(jack,tuna) kills(curiosity,tuna)
5. cat(tuna)
6. cat(X) animal(X)
7.
Add: kills(curiosity,tuna)
94
dog(sk)
{sk/f(X)}
owns(X,sk) animalLover(X)
owns(jack,sk)
{jack/X}
animalLover(jack)
cat(tuna)
cat(X) animal(X)
{tuna/X}
animal(tuna)
animalLover(X) kills(X,tuna)
{jack/X}
animalLover(jack)
kills(jack,tuna)
95
kills(jack,tuna) kills(curiosity,tuna)
kills(curiosity,tuna)
{}
kills(jack,tuna)
kills(jack,tuna)
{}
96
criminal(west) ?
97
C1:
C2:
bunny(bugs) bunny(roger)
bunny(X) likes(X,carrots)
98
99
Breadth-first search:
Subsumption:
uninformed search
Keep the initial KB as small as possible by removing clauses that are
more specific than others (subsumed by already existing clauses)
ex: if KB contains p(X), we can remove p(a)
idea: we want shorter clauses; the empty result is the shortest with
size 0
prefer resolutions that produce shorter sentences
an easy way to achieve this is to use unit clauses having only one literal
the result of a resolution with a unit is always shorter than the parent
100
101
are allowed
built-in resolution inferencing with backward chaining,
depth-first search and several heuristics
left-to-right search through conjuncts, first-to-last
search in knowledge base, no occur-check in unification
negation as failure: p is considered proved if no proof
for p is found
closed-world assumption
103
104
Fuzzy logic:
Higher-order logic
Modal logics
Temporal logics
Description logics
105
Today
Propositional Logics
Predicate Logics
Automated reasoning
Deduction
Forward Chaining
Backward Chaining
Resolution Refutation
106