Explorations in Artificial Intelligence Prof Carla P Gomes

  • Slides: 26
Download presentation
Explorations in Artificial Intelligence Prof. Carla P. Gomes gomes@cs. cornell. edu Module 3 -1

Explorations in Artificial Intelligence Prof. Carla P. Gomes gomes@cs. cornell. edu Module 3 -1 -3 Logic Representations

Satisfiability

Satisfiability

Propositional Satisfiability problem Satifiability (SAT): Given a formula in propositional calculus, is there a

Propositional Satisfiability problem Satifiability (SAT): Given a formula in propositional calculus, is there a model (i. e. , a satisfying interpretation, an assignment to its variables) making it true? We consider clausal form, e. g. : ( a b c ) AND ( b c) AND ( a c) possible assignments SAT: prototypical hard combinatorial search and reasoning problem. Problem is NP-Complete. (Cook 1971) Surprising “power” of SAT for encoding computational problems.

Satisfiability as an Encoding Language

Satisfiability as an Encoding Language

Encoding Latin Square Problems in Propositional Logic Variables: Each variables represents a color assigned

Encoding Latin Square Problems in Propositional Logic Variables: Each variables represents a color assigned to a cell. Clauses: • Some color must be assigned to each cell (clause of length n); • No color is repeated in the same row (sets of negative binary clauses); • No color is repeated in the same column (sets of negative binary clauses);

3 D Encoding or Full Encoding This encoding is based on the cubic representation

3 D Encoding or Full Encoding This encoding is based on the cubic representation of the quasigroup: each line of the cube contains exactly one true variable; Variables: Same as 2 D encoding. Clauses: • Same as the 2 D encoding plus: – Each color must appear at least once in each row; – Each color must appear at least once in each column; – No two colors are assigned to the same cell;

Dimacs format At the top of the file is a simple header. p cnf

Dimacs format At the top of the file is a simple header. p cnf <variables> <clauses> Each variable should be assigned an integer index. Start at 1, as 0 is used to indicate the end of a clause. The positive integer a positive literal, whereas a negative interger represents a negative literal. Example -1 7 0 ( x 1 x 7)

Extended Latin Square 2 x 2 p cnf 8 24 -1 -2 -3 -4

Extended Latin Square 2 x 2 p cnf 8 24 -1 -2 -3 -4 -5 -6 -7 -8 -1 -5 -2 -6 -3 -7 -4 -8 -1 -3 -2 -4 -5 -7 -6 -8 1 2 3 4 5 6 7 8 1 5 2 6 3 7 4 8 1 3 2 4 5 7 6 8 0 0 0 0 0 0 A cell gets at most a color No repetition of color in a column No repetition of color in a row A cell gets a color A given color goes in each column A given color goes in each row order 2 -1 -1 1/2 3/4 5/6 7/8 1 – cell 11 is red 2 – cell 11 is green 3 – cell 12 is red 4 – cell 12 is green 5 – cell 21 is red 6 – cell 21 is green 7 – cell 22 is red 8 – cell 22 is green

Significant progress in Satisfiability Methods Software and hardware verification – complete methods are critical

Significant progress in Satisfiability Methods Software and hardware verification – complete methods are critical - e. g. for verifying the correctness of chip design, using SAT encodings Going from 50 variable, 200 constraints to 1, 000 variables and 5, 000 constraints in the last 10 years Current methods can verify automatically the correctness of > 1/7 of a Pentium IV. Applications: Hardware and Software Verification Planning, Protocol Design, etc.

Model Checking

Model Checking

A “real world” example

A “real world” example

Bounded Model Checking instance: i. e. ((not x 1) or x 7) and ((not

Bounded Model Checking instance: i. e. ((not x 1) or x 7) and ((not x 1) or x 6) and … etc.

10 pages later: … (x 177 or x 169 or x 161 or x

10 pages later: … (x 177 or x 169 or x 161 or x 153 … or x 17 or x 9 or x 1 or (not x 185)) clauses / constraints are getting more interesting…

4000 pages later: !!! a 59 -cnf clause… …

4000 pages later: !!! a 59 -cnf clause… …

Finally, 15, 000 pages later: Note that: … !!! The Chaff SAT solver solves

Finally, 15, 000 pages later: Note that: … !!! The Chaff SAT solver solves this instance in less than one minute.

Effective propositional inference

Effective propositional inference

Effective propositional inference Two families of algorithms for propositional inference (checking satisfiability) based on

Effective propositional inference Two families of algorithms for propositional inference (checking satisfiability) based on model checking (which are quite effective in practice): Complete backtracking search algorithms DPLL algorithm (Davis, Putnam, Logemann, Loveland) Incomplete local search algorithms – Walk. SAT algorithm

The DPLL algorithm Determine if an input propositional logic sentence (in CNF) is satisfiable.

The DPLL algorithm Determine if an input propositional logic sentence (in CNF) is satisfiable. Improvements over truth table enumeration: 1. Early termination A clause is true if any literal is true. A sentence is false if any clause is false. 2. Pure symbol heuristic Pure symbol: always appears with the same "sign" in all clauses. e. g. , In the three clauses (A B), ( B C), (C A), A and B are pure, C is impure. Make a pure symbol literal true. 3. Unit clause heuristic

The DPLL algorithm

The DPLL algorithm

DPLL Basic algorithm for state-of-the-art SAT solvers; ; Several enhancements: - data structures; -

DPLL Basic algorithm for state-of-the-art SAT solvers; ; Several enhancements: - data structures; - clause learning; - randomization

The Walk. SAT algorithm Incomplete, local search algorithm Evaluation function: The min-conflict heuristic of

The Walk. SAT algorithm Incomplete, local search algorithm Evaluation function: The min-conflict heuristic of minimizing the number of unsatisfied clauses Balance between greediness and randomness

The Walk. SAT algorithm

The Walk. SAT algorithm

Hard satisfiability problems Consider random 3 -CNF sentences. e. g. , ( D B

Hard satisfiability problems Consider random 3 -CNF sentences. e. g. , ( D B C) (B A C) ( C B E) (E D B) (B E C) m = number of clauses n = number of symbols – Hard problems seem to cluster near m/n = 4. 3 (critical point)

Intuition At low ratios: – few clauses (constraints) – many assignments – easily found

Intuition At low ratios: – few clauses (constraints) – many assignments – easily found At high ratios: – many clauses – inconsistencies easily detected