Controlling Reasoning

1 / 27

# Controlling Reasoning - PowerPoint PPT Presentation

Controlling Reasoning. Logical view on rules: CNF Inference: TD, BU, Resolution Control in PLANNER, MBASE, PRESS Conclusions Notations in slides for logical connectors: &amp;, |, ¬, , A, E. Rules as logical implications. A person admires a philosopher if he beats him in a race

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about ' Controlling Reasoning' - kato

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### Controlling Reasoning

Logical view on rules: CNF

Inference: TD, BU, Resolution

Control in PLANNER, MBASE, PRESS

Conclusions

Notations in slides for logical connectors: &, |, ¬, , A, E.

Rules as logical implications
• A person admires a philosopher if he beats him in a race
• Rule: IF x is Philosopher AND x beats y in race THEN y admires x
• Logic: A x,y: Ph(x) & Be(x,y)  Ad(y,x)
• PROLOG: Ad(y,x) :- Ph(x), Be(x,y).
• CLIPS: (defrule (Ph x) (Be x y) => (assert (Ad y x)))

CLIPS and PROLOG: Program is list of implications.

Each is valid individually: conjunction of implications.

Implication is disjunction: p  q is the same as ¬p | q

Expert Systemen 5

Conjunctive Normal Form
• Atom: Relation symbol Be(x,y)
• Literal: Atom or negated atom Be(x,y) ¬Be(x,y)
• Clause: Disjunction of Literals ¬Be(x,y) | ¬Ph(x) | Ad(y,x)
• Conjunctive Normal Form: Conjunction of clauses.CNF is Universal: Every statement is equivalent to a CNF.
• Special case: Horn clause has ONE positive literal.Our programs have Horn clauses but…
• Horn clauses are NOT universal!Influences expressibility and efficiency of programs.

Expert Systemen 5

CNF is Universal

Statement: Every student uses some computer and some computer is used by every student.

Formalize in logic:(A x: St(x)  (E y: Co(y) & Use(x,y)) ) &(E z: Co(z) & (A t: St(t)  Use(t,z)) )

Eliminate implications:(A x: ¬St(x) | (E y: Co(y) & Use(x,y)) ) &(E z: Co(z) & (A t: ¬St(t) | Use(t,z)) )

Replace existentials by Skolem functions:(A x: ¬St(x) | (Co(Y(x)) & Use(x,Y(x))) ) &(Co(Z) & (A t: ¬St(t) | Use(t,Z)) )

Expert Systemen 5

Transformation to CNF, continued

Replace existentials by Skolem functions:(A x: ¬St(x) | (Co(Y(x)) & Use(x,Y(x))) ) &(Co(Z) & (A t: ¬St(t) | Use(t,Z)) )

Move universal quantifiers up front:A x, A t:¬St(x) | (Co(Y(x)) & Use(x,Y(x))) & (Co(Z) & (¬St(t) | Use(t,Z)) )

Distribute | over & and drop quantifiers:(¬St(x) | Co(Y(x)) & // St(x)  Co(Y(x))(¬St(x) | Use(x,Y(x))) & // St(x)  Use(x,Y(x))Co(Z) & // Co(Z)(¬St(t) | Use(t,Z)) // St(t)  Use(t,Z)

Expert Systemen 5

Clause notation and meaning
• { } means False
• {p} means p
• {¬p} means ¬p
• {¬p, q} means p  q
• {¬p, ¬q, r} means p & q  r
• {p} {q} means p & q
• {¬p, q, r} means p  (q | r)

or (p & ¬q)  rThis is a non-Horn clause!

Expert Systemen 5

Experts tell me that

IF powerfailureTHEN blackscreen

IF unitfailureTHEN blackscreen

Declarative (causal) domain knowledge

I want to express this knowledge as

IF blackscreenTHEN powerfailure OR unitfailure

Procedural domain knowledge

Why do I want that?

Is the conclusion justified?

How can I do it?(assert (fact1 | fact2)) ??

IF blackscreen & ¬unitfailureTHEN powerfailure

Symmetry between failures lost

Mixes symptom with cause

Negated conditions are costly

I have a problem with my TV . . .

Expert Systemen 5

p | q rConditions p and q each imply r by themselves:(p  r) & (q  r)Horn clause: {¬p,r} {¬q,r}

p & q  rHorn clause: {¬p,¬q,r}

p  q & rCondition p implies both q and r separately:(p  q) & (p  r)Horn clause: {¬p,q} {¬p,r}

Disjunction in the conclusion is the only problematic case

Conjunctions and Disjunctions in Implications

Expert Systemen 5

Facts in the database express positive literals

MP and MMP express how to extend the fact set.

Modus Ponens:p p  s s

Multi Modus Ponens:p q r p&q&r  s s

Goal

Initial Facts

Inference: Bottom-Up

Bottom-Up inference produces many irrelevant facts.

Expert Systemen 5

Focus on goal avoids irrelevant facts

Goal expansion:Goal s p  s Goal p

Goal expansion:Goal s p & q & r s Goals p, q, r

Achieve empty goal list

Inference: Top-Down

Top-Down inference persues many unreachable goals.

Goal

Initial Facts

Expert Systemen 5

Proving G is deriving a contradiction from ¬G.

Goal list: negated statements

Goal expansion:Goal s p  s Goal p

becomes¬s p  s¬p

or: Modus Tollens

prove False.

False

Initial Facts

¬G

Resolution generalizes BU and TD inference

Resolution may still derive too many facts.

Expert Systemen 5

Horn clauses generalizefacts and rules

Resolution generalizes Modus Ponens and Modus Tollens:

From { p, s1, s2, …}

and {¬p, t1, t2, …},

conclude {s1, s2, …, t1, t2, …}

Clauses clash on literal p

Justification:

In both clauses a literal is TRUE.

The p literal is TRUE in one.

In at least one clause, another literal is TRUE

Examples of Resolution:

Modus Ponens:{¬p, q} {p} give {q}

Modus Tollens:{¬p, q} {¬q} give {¬p}

Multi Modus Ponens:{¬p, ¬q, ¬r, s} {p} {q} {r}give in three steps

{¬q, ¬r, s}

{¬r, s}

{s}

Contradiction:{¬p} {p} give {}

The Resolution Principle

Expert Systemen 5

Chaining:

p  q and q  rimply p  r

If p is known, r is derived with 2x Modus Ponens

Natural deduction:assume and then eliminate p

Resolution:{¬p, q} and {¬q, r}clash on q and give{¬p, r}

Case distinction:

p  q and ¬p  q imply q

Resolution:{¬p, q} and {p, q}clash on p and give{q}

More proof rules subsumed by Resolution

Expert Systemen 5

Backward (Set-of-support):Use ¬G (or clause derived from it) in every step.

Forward reasoning:Ignore ¬G until you can resolve it with G.

Input Resolution:In each step use an IF or ¬G

Unit preference:Prefer clauses with one literal

Recency, Specificity, …

False

Initial Facts

¬G

Resolution Conflict strategy

Can we model and use Human Problem Solving Knowledge here?

BU-side

TD-side

Expert Systemen 5

Pros:

Employs some HE insights

Some efficiency gain

Cons:

Sacrifice completeness:All true statements can be derived.Counterexample:(ante p (assert q)) (ante t (assert G)) (conse t (goal q)) p¬G // Goal: G

Efficiency gain is small

PLANNER (Hewitt, 1971)

Distinguish antecedent and

consequent theorems

• A block is on the table(ante (block x) (assert (on x table)))is triggered by antecedent(Bottom-Up theorem)
• Men are mortal(conse (mortal x) (goal (man x)))is triggered by consequent(Top-Down theorem)

Expert Systemen 5

MECHO System Architecture

MECHO: Solver for highschool mechanics problems

Implemented in PROLOG, but with extended inference control: MBASE

language

interpreter

MECHO:

physics

PRESS:

mathematics

MBASE

PROLOG

Expert Systemen 5

MBASE: A Prolog extension

rule ordering, clause ordering, !

First order conflict resolution:

try rules in order in program.

Put

grandpa (abraham, jacob).

before

grandpa (x, y) :-

fath(x, z),

fath(z, y).

Second order conflict resolution:

try clauses in listed order:

Better write

grandpa (x, y) :-

fath(z, y),

fath(x, z).

In both cases the two programs are logically equivalent.

Expert Systemen 5

If x is found to be a woman, he cannot be anybodies grandpa:

grandpa(x, y) :-

female(x), fail.

Not enough; PROLOG will still try alternative clauses:

grandpa(x, y) :-

female(x), !, fail.

To prevent the penguin from flying:

flies(X) :-

penguin(X), !, fail.

flies(X) :-

bird(X).

Makes the program logically inconsistent.

The Use of ! (cut)

This clause is not successful

Don’t try anything else

Expert Systemen 5

grandpa(x, y) :-

brother (y, z),

grandpa (x, z).

Want to use known facts only:

grandpa(x, y) :-

brother (y, z),

DBC (grandpa (x, z) ).

DBC: Use fact if in database, but do not derive.

Knowledge that anybody has just one grandpa may stop superfluous search for another:grandpa(x, y) :-

DBC (grandpa (z, y) ),

different(z, x),

!, fail.

MBASE additional control: DBC

Expert Systemen 5

MECHO additional control: Frames
• Hierarchical grouping of concepts:
• a1 isa centrifugal
• centrifugal isa acceleration
• acceleration isa quantity
• Knowledge is associated to concepts.

Frame concept is NOT supported by MECHO/PROLOG,

but implemented within MECHO

Expert Systemen 5

How PRESS solves an equation

Human problem solving strategy

• Equation deduced from text (by MECHO):log(x+1) = c – log(x - 1)
• Rewrite to bring x on one side:log(x+1) + log(x-1) = c
• Rewrite to collect (reduce no. of occurrences of x):log(x2 – 1) = c
• Rewrite to isolate the value x:x = √(ec +1)

Insufficient: algebraic rewriting rules, domain knowledge.(x+1)(x-1) = x2 - 1

We must supply them together with an application context.

Expert Systemen 5

PRESS solution strategies:

/* Isolate a single occurrence of x */

solution( Lhs=Rhs, SolvedEquation ) :-

occur( x, Lhs, 1 ), occur( x, Rhs, 0 ),

isolate( Lhs=Rhs, SolvedEquation ), !.

/* Try to combine two occurrences */

solution( Equation, SolvedEquation ) :-

occur( x, Equation, N ), N > 1,

collect( Equation, Equation1 ),

solution( Equation1, SolvedEquation ), !.

/* Try two move two occurrences closer together */

solution( Equation, SolvedEquation ) :-

occur( x, Equation, N ), N > 1,

attract( Equation, Equation1 ),

solution( Equation1, SolvedEquation ), !.

Expert Systemen 5

Guide attraction by occurrences of x

/* Attraction can be done in subexpressions */

attract( Equation, Equation1 ) :-

subexpr( E, Equation ),

attract_rewrite( E, E1 ),

replace_sub( E, Equation, E1, Equation1 ).

/* Combine sum of logs, both containing x */

attract_rewrite( log(U)+log(V), log(U*V) ) :-

occur( x, U, NU ), NU > 0,

occur( x, V, NV ), NV > 0.

Expert Systemen 5

Collection is the ultimate attraction:

/* Allow collection on subexpressions */

collect( Equation, Equation1 ) :-

sub_expr( E, Equation ),

collect_rewrite( E, E1 ),

replace_sub( E, Equation, E1, Equation1 ).

/* Formula’s that vanish one x */

collect_rewrite( (x+N)*(x-N), (x^2-Nsq) ) :-

Nsq is N^2.

collect_rewrite( A*x + B*x , C * x ) :-

C is A + B.

Familiar product rule, but now has a direction and a goal context

Expert Systemen 5

Isolation: Peel the Onion to the kernel

/* isolate brings an equation of the form LHS=RHS,

with a single x in LHS, in the form x=Rhs */

/* What does that kernel look like */

isolate( x=Rhs, x=Rhs ) :- !.

/* Otherwise, apply recursion */

isolate( Equation, SolvedEquation ) :-

isolate_rewrite( Equation, Equation1 ),

isolate( Equation1, SolvedEquation ).

/* A is the subexpr of LHS that contains x */

isolate_rewrite( sin(A)=B, A=arcsin(B) ).

isolate_rewrite( log(A)=B, A=exp(B) ).

isolate_rewrite( A^N=B, A=B^(1/N) ).

Expert Systemen 5

• MECHO was successful because it workedwhich is what we want
• Rules are not just laws of algebra,but solution strategies of Human Expertwhich is what we want
• Solution strategies are coded together with algebra,which is not what we want
• Many are represented implicitly (eg., by clause order)which is not what we want

MECHO was influential as

• a demonstration of what was possible in AI / PROLOG
• a guide for later research in strategic knowledge representation

Expert Systemen 5

Experts tell me that

IF powerfailureTHEN blackscreen

IF unitfailureTHEN blackscreen

I want to express this knowledge as

IF blackscreenTHEN powerfailure OR unitfailure

Why do I want that?

Is the conclusion justified?

Both TD and BU inference only draw logically valid conclusions

Closed World Assumption:

If a statement is true, it can be proved

CWA in PROLOG: as long as blackscreen cannot be derived, your TV is fine.

CWA: The expert knowledge is complete wrt. possible causes

I still have a problem with my TV . . .

Expert Systemen 5