4 th nov, 2002. oct 23 rd happy deepavali!. 10/23 sat & csp

11
4 th Nov, 2002 Oct 23 rd Happy Deepavali!

Post on 18-Dec-2015

218 views

Category:

Documents


3 download

TRANSCRIPT

Page 2: 4 th Nov, 2002. Oct 23 rd Happy Deepavali!. 10/23 SAT & CSP

10/23

SAT & CSP

Page 3: 4 th Nov, 2002. Oct 23 rd Happy Deepavali!. 10/23 SAT & CSP

2 2

3

7 7

1

5

8

4 4

1

0

1

2

3

4

5

6

7

8

9

Average: 33St Dev: 13.2Max: 55.5Min: 7

5 15 554025

Midterm Histogram

Marks

Page 4: 4 th Nov, 2002. Oct 23 rd Happy Deepavali!. 10/23 SAT & CSP

Entailment by model checking

• We said entailment can be checked by truth table enumeration. Can we do the check without full enumeration?– SAT problem

• Given a set of propositions• And a set of (CNF) clauses• Find a model (an assignment of t/f values to propositions) that satisfies all clauses

– k-SAT is a SAT problem where all clauses are length less than or equal to k» SAT is NP-complete;» 1-SAT and 2-SAT are polynomial» k-SAT for k> 2 is NP-complete

– If we have a procedure for solving SAT problems, we can use it to compute entailment

• The senstence S is entailed, if negation of S, when added to the KB, gives a SAT theory that is unsatisfiable (NO MODEL)

– CO-NP-Complete

– SAT is useful for modeling many other “assignment” problems• We will see use of SAT for planning; it can also be used for Graph coloring, n-

queens, Scheduling and Circuit verification etc (the last thing makes SAT VERY interesting for Electrical Engineering folks)

Review

Page 5: 4 th Nov, 2002. Oct 23 rd Happy Deepavali!. 10/23 SAT & CSP

Compiling Planning into SAT

Init: At-R-E-0 & At-A-E-0 & At-B-E-0Goal: In-A-1 & In-B-1

Graph: “cond at k => one of the supporting actions at k” In-A-1 => Load-A-1 In-B-1 => Load-B-1 At-R-M-1 => Fly-R-1 At-R-E-1 => P-At-R-E-1

Load-A-1 => At-R-E-0 & At-A-E-0 “Actions at k => preconds at k-1” Load-B-1 => At-R-E-0 & At-B-E-0 P-At-R-E-1 => At-R-E-0h

~In-A-1 V ~ At-R-M-1 ~In-B-1 V ~At-R-M-1 “Mutexes”

At(R,E)

At(A,E)

At(B,E)

1: Load(A)

2 : Load(B)

3 : Fly(R)

P-At(R,E)

P-At(A,E)

P-At(B,E)

In(A)

In(B)

At(R,M)

At(R,E)

At(A,E)

At(B,E)

Goals: In(A),In(B)

One way of finding a k-length plan is to grow a k-length planning graph (with mutexes) and looking for a valid subgraph of this graph. If it is not found, extend the graph and try again

Review

Page 6: 4 th Nov, 2002. Oct 23 rd Happy Deepavali!. 10/23 SAT & CSP

Planning as SAT (another example)

Init: J-0Goal: P-2 & Q-2

Do the following for every cond; action and mutex at every level

Graph: “cond at k => one of the supporting actions at k”

P-2=> O1-2 V p-P-2Q-2 => O2-2 V p-Q-2….

“Actions at k => preconds at k-1” O2-2 => J-1 p-P-2 => P-1

Mutexes ~P-2 V ~J-2 ~P-1 V ~Q-1 ….

A solution assignment will be J-0; O2-1; Q-1; p-Q-2; O1-2; P-2; Q-2;

Page 7: 4 th Nov, 2002. Oct 23 rd Happy Deepavali!. 10/23 SAT & CSP

SAT as Search

• Search in the space of “partial assignments” (P=T,Q=F..)– Extend a partial assignment by picking a variable and

generating the t/f children of the assignment• Nodes: partial assignments• Operators: assigning values to variables

– We can assign variables in any order (commutative). So no need to consider more than one order

– If a partial assignment is already inconsistent, you can kill the search

– Depth first search is good enough • depth of the search tree is finite (= number of propositions)• all satisfying models are equally good. • All assignments are at depth d (d = # propositions)

Page 8: 4 th Nov, 2002. Oct 23 rd Happy Deepavali!. 10/23 SAT & CSP

Improvements?

• Need hints on– Which prop to pick for assignment next?– Which value to try for it next?– Can we detect inevitable failures early on?

• Involves inference– Notice the “circularity”

» Inference can be done by SAT which involves inference (which can be done by SAT which involves inference…

– Can we avoid previously encountered failures?

– Can we improve the mobility of the search?

Inferencesatisfaction

Page 9: 4 th Nov, 2002. Oct 23 rd Happy Deepavali!. 10/23 SAT & CSP

DPLL—does lookahead by unit propagation

• DPLL is a procedure that basically implements this with 2 enhancements:– Unit propagation [Trying to detect inevitable failure early]

• Before expanding a partial assignment, run unit resolution to completion

– Apply inference of type [P ; ~P V Q VJ ] => Q V J repeatedly– Whenever a unit clause is found, set the corresponding variable to True,

and remove all clauses that have that variable– If an empty clause is detected, the node is “dead”--Backtrack

– Pure-literal elimination• If a proposition appears with the same polarity in all clauses it

appears, set its value to that polarity, and remove all the clauses that it is part of.

– Makes sense only if all satisfying assignments are equally desirable– E.g. be-god V study; be-god V practice

Page 10: 4 th Nov, 2002. Oct 23 rd Happy Deepavali!. 10/23 SAT & CSP

Davis-Putnam-Logeman-Loveland Procedure

detect failure

Page 11: 4 th Nov, 2002. Oct 23 rd Happy Deepavali!. 10/23 SAT & CSP

Improvements to DPLL

• Order in which propositions are selected– Select the most constraining prop first (the one that takes part in most

clauses)– Select the prop which, when set, leads to most unit-propagation cascade

[Costly, but works wonders—e.g SATZ)• Learning from mistakes (“Nogood” learning)

– If we are forced to backtrack over particular partial assignment, remember the reason so if that reason holds in another branch, we can cut search.

– Problem: Need to carefully control the amount of nogoods you remember (storage and matching costs). Works great in RelSAT.

• Using random-restart policies to increase the “mobility” of the search• Many many many more.. (still continuing)• Read the overview paper on the quest for efficient boolean solvers