You are on page 1of 61

Computers and Law Lecture 4

Logical Reasoning

Michael Genesereth Autumn 2003


Outline
Introduction
Logical Entailment
Proofs

Proofs Techniques
Natural Deduction
Resolution

Examples
Evaluation and Design
Inconsistency and Overlap
Simulation and Planning

Limitations of Deductive Reasoning


2
Logical Reasoning

In logical reasoning, the conclusion is true whenever the


premises are true.

Premise: p
Conclusion: (p ⁄ q)

Premise: p
Non-Conclusion: (p Ÿ q)

Premises: p, q
Conclusion: (p Ÿ q)

3
Logical Entailment

A set of premises D logically entails a conclusion j (written as


D |= j) if and only if every interpretation that satisfies the
premises also satisfies the conclusion.

{p} |= (p ⁄ q)

{p} |# (p Ÿ q)

{p,q} |= (p Ÿ q)

4
Problem
Even without variables, the number of models to be checked
can be exceedingly large. There are, in general, infinitely many
models to check.

As it turns out, Relational Logic has two nice properties that


help to deal with this problem.

(1) Whenever a set of premises logically entails a conclusions,


there is a finite proof of the conclusion from the premises.

(2) It is possible to enumerate all proofs in a systematic way.

5
Natural Deduction

6
Patterns
A pattern is a parameterized expression, i.e. an expression
satisfying the grammatical rules of our language except for
the occurrence of meta-variables (Greek letters) in place of
various subparts of the expression.

Sample Pattern:
j fi (y fi j)

Instance:
p fi (q fi p)

Instance:
(p fi r) fi ((pfiq) fi (p fi r))

7
Rule of Inference
A rule of inference is a rule of reasoning consisting of one
set of sentence patterns, called conditions, and a second
set of sentence patterns, called conclusions.

j fi y
j
y

8
Rule Instances
An instance of a rule of inference is a rule in which all meta-
variables have been consistently replaced by expressions in
such a way that all premises and conclusions are syntactically
legal sentences.

raining fi wet wet fi slippery


raining wet
wet slippery

p fi (q fi r) ( p fi q) fi r
p p fi q
q fi r r
9
Logical Rules of Inference
A logical rule of inference is one in which the conditions
in every instance of the rule logically entail the
conclusions.

10
Some Logical Rules of Inference
Modus Ponens (MP) Modus Tolens (MT)

j ÿy
j fi y j fi y
y ÿj

And Introduction (AI) And Elimination (AE)

j jŸy
y j
jŸy y

11
Logical Schemata
A logical schema is a sentence pattern all instances are true in
all models.

Sample Pattern:
j fi (y fi j)

Instance:
p fi (q fi p)

Instance:
(p fi r) fi ((pfiq) fi (p fi r))

12
Rules and Schemata
Axiom Schemata as Rules of Inference

j fi (y fi j) j fi (y fi j )

Rules of Inference as Axiom Schemata


j fi y
ÿy (j fi y) fi (ÿy fi ÿj)
ÿj

Note: Of course, we must keep a least one rule of inference to


use the schemata. By convention, we retain Modus Ponens.

13
Standard Axiom Schemata
II: j fi (y fi j)
ID: (j fi (y fi c)) fi ((j fi y) fi (j fi c))
NE: (ÿj fi y) fi ((ÿj fiÿy) fi j)
QE: (j ¤ y) fi (j fi y)
QE: (j ¤ y) fi (y fi j)
QI: (j fi y) fi ((y fi j) fi (j ¤ y))
RE: (j ‹ y) ¤ (y fi j)
OE: (j ⁄ y) ¤ (ÿj fi y)
AE: (j Ÿ y) ¤ ÿ(ÿj ⁄ ÿy)
UD: "n.(j fi y) fi ("n.j fi"n.y)
UG: j fi "n.j
UI: "n.j fi j[n¨t] where t is free for n in j
!
EE: $n.j(n) ¤ j(t) where t is a new constant
EI: j(t) fi $n.j(n)
14
Standard Proof
A standard proof of a conclusion from a set of premises is a
sequence of sentences containing the conclusion in
which each item is one of the following:

1. A premise

2. A standard axiom, e.g. (p fi (q fi p))

3. The result of applying Modus Ponens to earlier items in


the sequence.

15
Example

When it is raining, the ground is wet. When the ground is wet,


it is slippery. It is raining. Prove that it is slippery.

1. raining fi wet Premise


2. wet fi slippery Premise
3. raining Premise
4. wet MP :1,3
5. slippery MP : 2,4

16
Example
Everybody loves somebody. Everybody loves a lover. Show
that Jack loves Jill.

1. "x.$y.loves(x,y) Premise
2. "u."v."w.(loves(v,w) fi loves(u,v)) Premise
3. $y.loves(jill,y) UI: 1
4. loves(jill,joe) EI: 3
5. "v."w.(loves(v,w) fi loves(jack,v)) UI: 2
6. "w.(loves(jill,w) fi loves(jack,jill)) UI: 5
7. loves(jill,joe) fi loves(jack,jill) UI: 6
8. loves(jack,jill) MP: 4, 7

17
Example
Whenever p is true, q is true. Whenever q is true, r is true.
Prove that, whenever p is true, r is true.

1. p fi q Premise
2. q fi r Premise
3. (q fi r) fi ( p fi (q fi r)) II
4. p fi (q fi r) MP : 3,2
5. ( p fi (q fi r)) fi (( p fi q) fi (p fi r)) ID
6. ( p fi q) fi ( p fi r) MP : 5, 4
7. p fi r MP : 6,1

18
Provability
A sentence j is provable from a set of sentences D (written as
D |- j) if and only if there is a standard proof of j from D.

19
Soundness and Completeness
Soundness: Our proof system is sound, i.e. if the conclusion is
provable from the premises, then the premises logically entail
the conclusion.

(D |- j) fi (D |= j)

Completeness: Our proof system is complete, i.e. if the premises


logically entail the conclusion, then the conclusion is provable
from the premises.

(D |= j) fi (D |- j)

20
Decidability
A class of questions is decidable if and only if there is a
procedure such that, when given as input any question in the
class, the procedure halts and says yes if the answer is positive
and no if the answer is negative.

A class of questions is semidecidable if and only if there is a


procedure that halts and says yes if the answer is positive.

Obvious Fact: If a class of questions is decidable, it is


semidecidable.

21
Semidecidability of Logical Entailment

goal
kb
rules

proof <- kb

goal in proof? Success

r <- choose(rules)
p <- choose(proof)
q <- choose(proof)
c <- apply(r,p,q)
proof <- proof|c

22
Non-decidability of Logical Entailment
Note that we have not shown that logical entailment is
decidable. In fact, it can be shown that it is not decidable.

The procedure may not halt.


p(x) fi p(f(x))
p(f(f(a)))
p(f(b))?

We cannot just run procedure on negated sentence because that


may not be logically entailed either!
p(x) fi p(f(x))
p(f(f(a)))
ÿp(f(b))?

23
Other Proof Systems
Deductive Calculi (forward reasoning):
Standard Proof System
Sequent Calculus (Gentzen)

Test Calculi (backward reasoning)


Tableau Method (Smullyan)
Resolution (Robinson)
Model Elimination (Loveland)

24
Resolution

25
Overview

Rule Resolution is a theorem proving method for Relational


Logic that is sound and complete and in almost all cases
more efficient than Natural Deduction.

(1) Requires that sentences be written in Rule Normal Form.


This is a simple algorithm for converting any Relational
Logic sentence to Rule Normal Form.

(2) Based on unification of expressions containing variables.


There is an algorithm for computing this in linear time.

(3) Utilizes three rules of inference (Resolution, Antecedent


Factoring, Consequent Factoring) and no axiom schemata.

26
Algebra
Xavier is three times as old as Yolanda. Xavier's age and
Yolanda's age add up to twelve. How old are Xavier and
Yolanda?

x - 3y = 0
x + y = 12
-4y = -12

y=3
x=9

27
Rule of Inference
Rule of Inference
p1 Ÿ ... Ÿ pk fi q1 ⁄ ... ⁄ ql
r1 Ÿ ... Ÿ rm fi s1 ⁄ ... ⁄ sn
p1 Ÿ ... Ÿ pk Ÿ r1 Ÿ ... Ÿ rm fi q1 ⁄ ... ⁄ ql ⁄ s1 ⁄ ... ⁄ sn

NB: If pi on the left hand side of one sentence is identical to qj


on the right hand side of the other sentence, it is okay to drop
the two expressions, with the proviso that only one such pair
may be dropped.
NB: If a constant is repeated on the same side of a single
sentence, all but one of the occurrences can be deleted.

28
Examples
q(a) ‹ p(a) q(a) ‹ p(a) q(a) ‹ p(a)
p(a) ‹ ‹ q(a) r(a) ‹ q(a)
q(a) ‹ ‹ p(a) r(a) ‹ p(a)

q(y) ‹ p(a,y)
p(x,b) ‹ m(x)
???

29
Substititions
A substitution is a finite set of pairs of variables and
terms. The variables together constitute the domain of the
substitution, and the terms are called replacements.

{x¨a, y¨f(b), z¨v}

The result of applying a substitution s to an expression j


is the expression js obtained from the original expression
by replacing every occurrence of every variable in the
substitution by the term with which it is associated.

p(x,x,y,z){x¨a,y¨b,v¨b}=p(a,a,b,z)

30
Unification
A substitution s is a unifier for an expression j and an
expression y if and only if js=ys.

p(x,y){x¨a,y¨b,v¨b}=p(a,b)
p(a,v){x¨a,y¨b,v¨b}=p(a,b)

If two expressions have a unifier, they are said to be unifiable.


Otherwise, they are nonunifiable.

p(x,x)
p(a,b)

31
Resolution
y1⁄ …⁄ yj ‹ yj+1 Ÿ…Ÿy Ÿ… Ÿ ym
j1⁄ …⁄j ⁄ …⁄ jk ‹ jk+1Ÿ…Ÿ jn
(j1 ⁄…⁄y1⁄…⁄y j ⁄… jk ‹yj+1Ÿ…Ÿ jk+1Ÿ…Ÿjn …Ÿym)s
where s is a unifier of j and y

q(x) ⁄ r(x) ‹ p(x,b)


p(a,y) ‹ m(y) Ÿ n(y)
(q(x) ⁄ r(x) ‹ m(y) Ÿ n(y)){x¨a,y¨b}
q(a) ⁄ r(a) ‹ m(b) Ÿ n(b)

32
Factoring

j1⁄…⁄ j ⁄…⁄ y ⁄ …⁄ jn‹ jn+1Ÿ…Ÿ jn


(j1⁄…⁄ j ⁄…⁄ jn‹ jn+1Ÿ…Ÿ jn)s

where s is a unifier of j and y

j1⁄ …⁄jn‹ jn+1Ÿ … Ÿ j Ÿ … Ÿ y Ÿ…Ÿ jn


(j1⁄⁄…⁄ jn‹ jn+1Ÿ … Ÿ j j Ÿ …Ÿ jn)s

where s is a unifier of j and y

33
Example
1. m(a) ‹ Premise
2. p(x) ‹ m(x) Premise
3. q(x) ‹ m(x) Premise
4. r(x) ‹ p(x) Ÿ q(x) Premise
5. ‹ r(a) Goal
6. ‹ p(a) Ÿ q(a) 4, 5
7. ‹ m(a) Ÿ q(a) 2, 6
8. ‹ q(a) 1, 7
9. ‹ m(a) 3, 8
10. ‹ 1,9

34
Determining Logical Entailment
To determine whether a set D of sentences logically entails a
closed sentence j, start with D and try to find a proof of j.

35
Example
Show that q(x) ‹ p(x) and p(a) logically entail $z.q(z).

1. q(x) ‹ p(x) Premise


2. p(a) ‹ Premise
3. ‹ q(z) Goal
4. ‹ p(z) 1, 3
5. ‹ 2, 4

36
Alternate Method
Basic Method: To determine whether a set D of sentences
logically entails a closed sentence j, start with D and try to
find a standard proof of j.

Alternate Method: To determine whether a set D of sentences


logically entails a closed sentence j, start with D»{j fi goal}
and try to find a formal proof of goal.

37
Example
Show that q(x) ‹ p(x) and p(a) logically entail $z.q(z).

1. q(x) ‹ p(x) Premise


2. p(a) ‹ Premise
3. goal ‹ q(z) Goal
4. goal ‹ p(z) 1, 3
5. goal ‹ 2, 4

38
Answer Extraction Method
Alternate Method: To determine whether a set D of sentences
logically entails a closed sentence j, start with D»{j fi goal}
and try to find a formal proof of goal.

Method for Answer Extraction: To get values for free


variables n1,…,nn in j for which D logically entails j, start
with D»{j fi goal(n1,…,nn)} and try to find a formal proof of
goal(t1,…, tn). Each t1,…, tn constitutes an answer.

Intuition: The sentence (q(z) fi goal(z)) says that, whenever, z


satisfies q, it satisfies the “goal”.

39
Example
Given q(x) ‹ p(x) and p(a), find a term t such that q(t) is
true.

1. q(x) ‹ p(x) Premise


2. p(a) ‹ Premise
3. goal(z) ‹ q(z) Goal
4. goal(z) ‹ p(z) 1, 3
5. goal(a) ‹ 2, 4

40
Example
Given q(x) ‹ p(x) and p(a) and p(b), find a term t such that
q(t) is true.

1. q(x) ‹ p(x) Premise


2. p(a) ‹ Premise
3. p(b) ‹ Premise
4. goal(z) ‹ q(z) Goal
5. goal(z) ‹ p(z) 1, 4
6. goal(a) ‹ 2, 5
7. goal(b) ‹ 3, 5

41
Example
Given q(x) ‹ p(x) and p(a) ⁄ p(b), find a term t such that
q(t) is true.

1. q(x) ‹ p(x) Premise


2. p(a) ⁄ p(b) ‹ Premise
3. goal(z) ‹ q(z) Goal
4. goal(z) ‹ p(z) 1, 3
5. goal(a) ⁄ p(b) ‹ 2, 4
6. goal(a) ⁄ goal(b) ‹ 4, 5

42
Examples

43
Subsumption
Existing Law:
legal(e,“Owner”) ‹ owner(e,x) Ÿ affiliation(x,cs)

Prospective Law:
legal(e,“Owner”) ‹ owner(e,x) Ÿ office(x,y) Ÿ in(y,gates)

Background Knowledge:
affiliation(x,cs) ‹ office(x,y) Ÿ in(y,gates)

Technique:
Assume conditions hold for arbitrary values of variables.
Prove that conclusion holds.

44
Proof

1. legal(e,“Owner”) ‹ owner(e,x) Ÿ affiliation(x,cs)


2. affiliation(x,cs) ‹ office(x,y) Ÿ in(y,gates)
3. ‹ owner(e1,p1)
4. ‹ office(p1,o1)
5. ‹ in(p1,gates)
6. goal ‹ legal(e1,“Owner”)
7. goal ‹ owner(e1,x) Ÿ affiliation(x,cs) 1, 6
8. goal ‹ affiliation(p1,cs) 3, 7
9. goal ‹ office(p1,y) Ÿ in(y,gates) 2, 8
10. goal ‹ in(y,gates) 4, 9
11. goal ‹ 5, 10

45
Inconsistency
Existing Law:
legal(e) ‹
owner(e,x) Ÿ location(e,gates104) Ÿ faculty(x)

Prospective Law:
ÿlegal(e) ‹
owner(e,x) Ÿ location(e,gates104) Ÿ ÿaffiliation(x,cs)

Technique:
Assume conditions hold for arbitrary values of variables.
Prove the negation of the conclusion.

46
Proof

1. legal(e,“Owner”) ‹ owner(e,x) Ÿ affiliation(x,cs)


2. affiliation(x,cs) ‹ office(x,y) Ÿ in(y,gates)
3. ‹ owner(e1,p1)
4. ‹ office(p1,o1)
5. ‹ in(p1,gates)
6. goal ‹ legal(e1,“Owner”)
7. goal ‹ owner(e1,x) Ÿ affiliation(x,cs) 1, 6
8. goal ‹ affiliation(p1,cs) 3, 7
9. goal ‹ office(p1,y) Ÿ in(y,gates) 2, 8
10. goal ‹ in(y,gates) 4, 9
11. goal ‹ 5, 10

47
Blocks World
clear(x) - true of x iff it has no blocks above it.
table(x) - true of x iff it is resting on the table.
on(x,y) - true of x and y iff x is immediately on y.

clear(a)
table(c)
on(a,b)
on(b,c)

s(x,y) - action of moving x from table to y


u(x,y) - action of moving x from y to table
m(x,y,z) - action of moving x from y to z

48
Laws of Change
true(on(x,y), do(s(x,y),s))‹
true(clear(x),s) Ÿ true(clear(y),s) Ÿ true(table(x),s)

true(table(y), do(u(x,y),s)) ‹ true(clear(x),s) Ÿ true(on(x,y),s)

true(clear(y), do(u(x,y),s)) ‹ true(clear(x),s) Ÿ true(on(x,y),s)

true(on(x,z), do(m(x,y,z),s)) ‹
true(clear(x),s) Ÿ true(on(x,y),s) Ÿ true(clear(z),s)

true(clear(y), do(m(x,y,z),s)) ‹
true(clear(x),s) Ÿ true(on(x,y),s) Ÿ true(clear(z),s)
49
Laws of Inertia
true(clear(u),do(s(x,y),s))‹ true(clear(u),s) Ÿ u≠y
true(table(v),do(s(x,y),s))‹ true(table(v),s) Ÿ v≠x
true(on(u,v),do(s(x,y),s)) ‹ true(on(u,v),s)

true(clear(u),do(u(x,y),s))‹ true(clear(u),s)
true(table(v),do(u(x,y),s))‹ true(table(v),s)
true(on(u,v),do(u(x,y),s)) ‹ true(on(u,v),s) Ÿ u≠x

true(clear(u),do(m(x,y,z), s))‹ true(clear(u),s) Ÿ u≠z


true(table(v),do(m(x,y,z), s))‹ true(table(v),s)
true(on(u,v),do(m(x,y,z), s)) ‹ true(on(u,v),s) Ÿ u≠x

50
Simulation
Show that the plan u(c,a), s(a,b) results in a state in which a is
on b when executed in a state in which c is on a, b and c are
clear, and a and b are on the table.

1. true(table(a),s1) ‹
2. true(clear(b),s1) ‹
3. true(table(b),s1) ‹
4. true(clear(c),s1) ‹
5. true(on(c,a),s1) ‹
6. goal ‹ true(on(a,b), do(s(a,b),do(u(c,a),s1)))

51
Proof
1. true(table(a),s1) ‹
2. true(clear(b),s1) ‹
3. true(table(b),s1) ‹
4. true(clear(c),s1) ‹
5. true(on(c,a),s1) ‹
6. goal ‹ true(on(a,b), do(s(a,b),do(u(c,a),s1)))
7. goal ‹ true(clear(a), do(u(c,a),s1)) Ÿ
true(clear(b), do(u(c,a),s1)) Ÿ
true(table(a), do(u(c,a),s1))
8. goal ‹ true(clear(c), s1) Ÿ
true(on(c,a), s1) Ÿ
true(clear(b), do(u(c,a),s1)) Ÿ
true(table(a), do(u(c,a),s1))

52
Proof
9. goal ‹ true(clear(b), do(u(c,a),s1)) Ÿ
true(table(a), do(u(c,a),s1))
10. goal ‹ true(clear(b), s1) Ÿ
true(table(a), do(u(c,a),s1))
11. goal ‹ true(table(a), do(u(c,a),s1))
12. goal ‹ true(table(a), s1)
13. goal ‹

53
Planning
Find a plan that results in a state in which a is on b when
executed in a state in which c is on a, b and c are clear, and
a and b are on the table.

1. true(table(a),s1) ‹
2. true(clear(b),s1) ‹
3. true(table(b),s1) ‹
4. true(clear(c),s1) ‹
5. true(on(c,a),s1) ‹
6. goal(s) ‹ true(on(a,b),s)

54
Proof
1. true(table(a),s1) ‹
2. true(clear(b),s1) ‹
3. true(table(b),s1) ‹
4. true(clear(c),s1) ‹
5. true(on(c,a),s1) ‹
6. goal(w) ‹ true(on(a,b),w)
7. goal(do(s(a,b),v) ‹ true(clear(a),v) Ÿ
true(clear(b),v) Ÿ
true(table(a),v)
8. goal(do(s(a,b),do(u(z,a),u)) ‹ true(on(z,a),u) Ÿ
true(on(z,a),u) Ÿ
true(clear(b),do(u(z,a),u))) Ÿ
true(table(a),do(u(z,a),u)))

55
Proof
8. goal(do(s(a,b),do(u(z,a),u)) ‹ true(on(z,a),u) Ÿ
true(clear(z),u) Ÿ
true(clear(b),do(u(z,a),u))) Ÿ
true(table(a),do(u(z,a),u)))
9. goal(do(s(a,b),do(u(c,a),s1)) ‹ true(clear(c),s1) Ÿ
true(clear(b),do(u(c,a),s1))) Ÿ
true(table(a),do(u(c,a),s1)))
11. goal(do(s(a,b),do(u(c,a),s1)) ‹
true(clear(b),do(u(c,a),s1))) Ÿ
true(table(a),do(u(c,a),s1)))
… as before …
n. goal(do(s(a,b),do(u(c,a),s1)) ‹

56
Path Constraints
A path constraint is a constraint on the way in which a goal is
achieved, i.e. the actions or states leading from the initial state
to a goal state.

Example: It is unacceptable to produce a state in which all


blocks are on the table.

legal(s1)
legal(do(x,s)) ‹ true(on(x,y),s) Ÿ legal(s)

Planning with path constraints accomplished by adding


another condition to the goal being achieved.

plan(s) ‹ goal(s) Ÿ legal(s)


57
Planning With Path Constraints
Find a plan that results in a state in which a is on b when
executed in a state in which c is on a, b and c are clear, and
a and b are on the table under the constraint that all blocks
may not be on table at the same time.

1. true(table(a),s1) ‹
2. true(clear(b),s1) ‹
3. true(table(b),s1) ‹
4. true(clear(c),s1) ‹
5. true(on(c,a),s1) ‹
6. goal(s) ‹ true(on(a,b),s)
7. legal(s1) ‹
8. legal(do(x,s)) ‹ true(on(x,y),s) Ÿ legal(s)
9. plan(s) ‹ goal(s) Ÿ legal(s)
58
Limitations of Deduction

59
Negation as Failure
Law:

ÿlegal(e,“Ownership”) ‹
owner(e,x) Ÿ location(e,gates104) Ÿ ÿaffiliation(x,cs)

In the absence of additional laws, can we assume it is legal for


a person who does have an affiliation with the Computer
Science Department?

Deductive Reasoning offers no way to do this.

60
Analogical Reasoning
Much legal reasoning is analogy on a current case to a
previous case.

Analogical Reasoning is not sound.

A wire is like a pipe.


Resistance in a pipe decreases quadratically with diameter.
So, resistance in wire decreases quadratically with diameter.

Now try price.

How do we justify analogical conclusions?

61

You might also like