SAT-solving An old AI technique becomes very popular in modern A.I.

Slides:



Advertisements
Similar presentations
1 Finite Constraint Domains. 2 u Constraint satisfaction problems (CSP) u A backtracking solver u Node and arc consistency u Bounds consistency u Generalized.
Advertisements

Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License:
UIUC CS 497: Section EA Lecture #2 Reasoning in Artificial Intelligence Professor: Eyal Amir Spring Semester 2004.
Propositional and First Order Reasoning. Terminology Propositional variable: boolean variable (p) Literal: propositional variable or its negation p 
1 Logic Logic in general is a subfield of philosophy and its development is credited to ancient Greeks. Symbolic or mathematical logic is used in AI. In.
Models and Propositional Logic In propositional logic, a model in general simply fixes the truth value – true or false – for every proposition symbol.
Methods of Proof Chapter 7, second half.. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound)
Effective Propositional Reasoning CSE 473 – Autumn 2003.
Methods of Proof Chapter 7, Part II. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound) generation.
CPSC 422, Lecture 21Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 21 Mar, 4, 2015 Slide credit: some slides adapted from Stuart.
ECE 667 Synthesis & Verification - SAT 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Boolean SAT CNF Representation Slides adopted (with.
Proof methods Proof methods divide into (roughly) two kinds: –Application of inference rules Legitimate (sound) generation of new sentences from old Proof.
Methods for SAT- a Survey Robert Glaubius CSCE 976 May 6, 2002.
1 Boolean Satisfiability in Electronic Design Automation (EDA ) By Kunal P. Ganeshpure.
Ryan Kinworthy 2/26/20031 Chapter 7- Local Search part 1 Ryan Kinworthy CSCE Advanced Constraint Processing.
1 Quantified Formulas Acknowledgement: QBF slides borrowed from S. Malik.
The Theory of NP-Completeness
Methods of Proof Chapter 7, second half.
Search in the semantic domain. Some definitions atomic formula: smallest formula possible (no sub- formulas) literal: atomic formula or negation of an.
1 Discrete Structures CS 280 Example application of probability: MAX 3-SAT.
Last time Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search strategy.
1 CS 4700: Foundations of Artificial Intelligence Carla P. Gomes Module: Satisfiability (Reading R&N: Chapter 7)
Knowledge Representation II (Inference in Propositional Logic) CSE 473 Continued…
Knowledge & Reasoning Logical Reasoning: to have a computer automatically perform deduction or prove theorems Knowledge Representations: modern ways of.
SAT Solver Math Foundations of Computer Science. 2 Boolean Expressions  A Boolean expression is a Boolean function  Any Boolean function can be written.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
Satisfiability Introduction to Artificial Intelligence COS302 Michael L. Littman Fall 2001.
Logics for Data and Knowledge Representation Propositional Logic: Reasoning Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto.
Boolean Satisfiability and SAT Solvers
SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.
CHAPTERS 7, 8 Oliver Schulte Logical Inference: Through Proof to Truth.
Propositional Equivalences
INTRODUCTION TO ARTIFICIAL INTELLIGENCE COS302 MICHAEL L. LITTMAN FALL 2001 Satisfiability.
Explorations in Artificial Intelligence Prof. Carla P. Gomes Module 3 Logic Representations (Part 2)
Solvers for the Problem of Boolean Satisfiability (SAT) Will Klieber Aug 31, 2011 TexPoint fonts used in EMF. Read the TexPoint manual before you.
An Introduction to Artificial Intelligence – CE Chapter 7- Logical Agents Ramin Halavati
CS Introduction to AI Tutorial 8 Resolution Tutorial 8 Resolution.
Explorations in Artificial Intelligence Prof. Carla P. Gomes Module Logic Representations.
Logical Agents Chapter 7. Knowledge bases Knowledge base (KB): set of sentences in a formal language Inference: deriving new sentences from the KB. E.g.:
LDK R Logics for Data and Knowledge Representation Propositional Logic: Reasoning First version by Alessandro Agostini and Fausto Giunchiglia Second version.
First-Order Logic and Inductive Logic Programming.
Automated reasoning with propositional and predicate logics Spring 2007, Juris Vīksna.
1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start  Breeze.
CPSC 422, Lecture 21Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 21 Oct, 30, 2015 Slide credit: some slides adapted from Stuart.
Review of Propositional Logic Syntax
© Copyright 2008 STI INNSBRUCK Intelligent Systems Propositional Logic.
Tommy Messelis * Stefaan Haspeslagh Patrick De Causmaecker *
Nikolaj Bjørner Microsoft Research DTU Winter course January 2 nd 2012 Organized by Flemming Nielson & Hanne Riis Nielson.
1 Example: The following knowledge is given :The following knowledge is given : 1. Marcus was a man. 2. Marcus was a Pompeian. 3. All Pompeians were Romans.
1 Propositional Logic Limits The expressive power of propositional logic is limited. The assumption is that everything can be expressed by simple facts.
CS182 Intelligent Machines: Reasoning, Actions and Plans Section 4.
Satisfiability and SAT Solvers CS 270 Math Foundations of CS Jeremy Johnson.
Logical Agents Chapter 7. Outline Knowledge-based agents Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem.
SAT Solving As implemented in - DPLL solvers: GRASP, Chaff and
Inference in Propositional Logic (and Intro to SAT) CSE 473.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View Basic Concepts and Background.
Proof Methods for Propositional Logic CIS 391 – Intro to Artificial Intelligence.
Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License:
1 Intro to AI Local Search. 2 Intro to AI Local search and optimization Local search: –use single current state & move to neighboring states Idea: –start.
CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 04 : Logic.
Inference in Propositional Logic (and Intro to SAT)
ARTIFICIAL INTELLIGENCE
First-Order Logic and Inductive Logic Programming
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 21
Logical Inference: Through Proof to Truth
Logics for Data and Knowledge Representation
Propositional Equivalences
Artificial Intelligence: Agents and Propositional Logic.
PROPOSITIONAL LOGIC - SYNTAX-
Methods of Proof Chapter 7, second half.
Presentation transcript:

SAT-solving An old AI technique becomes very popular in modern A.I.

Overview: Basics on SAT Unit propagation SAT-solving Local Search SAT-solving Local Search SAT-solving

3 What is SAT-solving?  Given KR: a set of propositional formula’s  Find a model for KR. More specifically:  Let X 1, X 2, …, X n be all the variables in KR,  Find an assignment I; X i -> {T,F}, for i=1,n, such that all formula’s in KR become true. such that all formula’s in KR become true. Useful ?

Example: 3-queens Representation: X 1,1 X 1,2 X 1,3 X 2,1 X 2,3 X 2,2 X 3,1 X 3,2 X 3,3 represents: there is a queen on i,j represents: there is a queen on i,j X i,j X i,1  X i,2  X i,3 (i=1,3) At least one queen on each row: X i,1  ~X i,2  ~X i,3, X i,2  ~X i,1  ~X i,3, X i,3  ~X i,1  ~X i,2 (i=1,3) At most one queen on each row: Plus: similar formulas for columns and diagonals. 33 formula’s ! Generalisation to q-queens ? Very many formula’s !

Example: personel rostering Representation: - For every employee, i, - For every employee, i, - For every shift in the day, j, - For every shift in the day, j, - For every day in the month, k : - For every day in the month, k : represents: i works on shift j of day k represents: i works on shift j of day k X i,j,k Often this is more elegantly done with assignments to {0,1} and sums instead of  Generalise to higher numbers than just 1 At least one person works on every shift of every day:  X i,j,k (j=1,5, k=1,30) i=1,35 An interpretation assigns to each Xi,j,k: true or false Is a personel assignment !

6 SAT-solving and NP-completeness  SAT-solving: one of the first identified as NP-complete  If you find a P-algorithm for SAT: you get a P- algorithm for all the others.  Also means: most problems can be encoded as SAT-problems and solved using SAT-techniques. Means: all other NP-problems are technically equivalent with this problem

7 But why practically useful?  Although NP(-complete)  Has led to: -Many areas in CS and AI convert problems to SAT -Then use SAT-solvers. Very efficient heuristic approaches exist that work well on certain classes of problems.

Example: Automated Reasoning  Compute a finite grounding of the predicate logic theory.  Marcus example: 2 constants: Marcus and Ceasar. 1. man(Marcus) is ground 2. Pompeian(Marcus) is ground 3.  x Pompeian(x)  Roman(x) Pompeian(Marcus)  Roman(Marcus) Pompeian(Ceasar)  Roman(Ceasar) 4. ruler(Caesar) is ground 5.  x Roman(x)  loyal_to(x,Caesar)  hates(x,Caesar) Roman(Marcus)  loyal_to(Marcus,Caesar)  hates(Marcus,Caesar) Roman(Ceasar)  loyal_to(Ceasar,Caesar)  hates(Ceasar,Caesar) Ect. ….

9 Example: continued  Ground predicate logic is equivalent to propositional ! Example: Pompeian(Marcus) converts to Pompeian_Marcus loyal_to(Marcus,Caesar) converts to loyal_to_Marcus_Caesar  The theorem follows if and only if this propositional KB in unsatisfiable ! KB in unsatisfiable !  Add the propositional version of the negation of the theorem ~loyal_to(Marcus,Caesar) converts to loyal_to_Marcus_Caesar SAT-solving

Conjunctive Normal Form  Every formula is equivalent to a formula of the form: (A1 ...  An)  (B1  …  Bm)  …  (C1  …  Ck)  where all Ai, Bi, …, Ci are either atomic or ~atomic.  Idea: p  q p  q push all ~ as deep as possible apply distributivity of  and  p  q  q  p q  ~p  SAT-solving will work on a collection of disjunctions: X1  …  Xn  ~Y1  … ~Ym

Naive SAT-solving Depth-first left-to-right enumeration of all interpretations

SAT - Standard backtracking ~Y X  ~Y  ~W,, ~X  Y  Z, ~XW ~X  W ~Y T  ~Y  ~W,, F  Y  Z, FW F  W X=TX=TX=TX=T Y=TY=TY=TY=T,TZ,WW,TZ,WWW Z=TZ=TZ=TZ=T, W T, W W=TW=TW=TW=T TF W=FW=FW=FW=F, W F, W Z=FZ=FZ=FZ=F, W T, W Z=TZ=TZ=TZ=T T W=TW=TW=TW=T F W=FW=FW=FW=F, W F, W Z=FZ=FZ=FZ=F ~Y F  ~Y  ~W,, T  Y  Z, TW T  W X=FX=FX=FX=F Y=TY=TY=TY=T F F  ~W, W=TW=TW=TW=T F W=FW=FW=FW=F T,FZ,WW,FZ,WWW Y=FY=FY=FY=F Y=FY=FY=FY=F T T  ~W Success Success Success Success Fail Fail Fail FailFail

13 Naïve SAT-solving algorithm NaiveSAT( i) For Truth = T, F do X i := Truth; X i := Truth; Remove all Dj containing T from S; Remove all Dj containing T from S; Remove all  F and F  from all Dj; Remove all  F and F  from all Dj; If no Dj in S is equal to F then If no Dj in S is equal to F then Else i := i + 1; NaiveSAT( i ); i := i - 1; If S= {} then return( X 1, X 2, …, X n ); return( X 1, X 2, …, X n ); Form is a CNF-formula with variables X 1, X 2,...X n S:= { Dj | Dj is a disjunction in Form} Call: NaiveSAT(1) End-For

Davis-Putman (1960): unit propagation The basis for VERY efficient SAT-solvers An early form of Dynamic Search Rearrangement

15 1. Dealing with pure symbols Example: S = { } S = { X  ~Y, ~Y  ~Z, Z  X } X is pure: only occurs positive Y is pure: only occurs negative Z is not pure.  A variable Xi is pure if it only appears with one sign in all disjunctions.  Assign a pure variable the value that makes it true everywhere (don’t consider the other assignment).

SAT + treating pure symbols ~Y X  ~Y  ~W,, ~X  Y  Z, ~XW ~X  W Success Z=TZ=TZ=TZ=T ~Y X  ~Y  ~W,, ~X  Y  T, ~XW ~X  W Y=FY=FY=FY=F T X  T  ~W, ~XW ~X  W X=FX=FX=FX=F T T  W Z is pure Y is pure X is pure

17 The order of choosing variables has become dynamic. Effect of dealing with pure symbols: Yet: we do not loose completeness: If another solution exist, then the current assignment is ok too. + If unsatisfiable: this will fail too. But not first-fail based. We get a _much_ smaller search space ! But we are no longer considering all assignments.

18 1. Unit propagation Example: S = { } S = { X  ~Y, ~Y, X } ~Y and X are units ~Y and X are units  A disjunction is unit if it only contains one variable Xi.  Assign a unit the value that makes it true (don’t consider the other assignment).

SAT – with unit propagation ~Y X  ~Y  ~W,, ~X  Y  Z, ~XW ~X  W ~Y T  ~Y  ~W,, F  Y  Z, FW F  W X=TX=TX=TX=T ~Y F  ~Y  ~W,, T  Y  Z, TW T  W X=FX=FX=FX=F Y=TY=TY=TY=T F F  ~W Y=FY=FY=FY=F T T  ~W Success Success Success Success,YZ,TT,YZ,TTT W=TW=TW=TW=T Y=TY=TY=TY=T,TZ,,TZ, FZFZ Y=FY=FY=FY=F Z=TZ=TZ=TZ=T T W=FW=FW=FW=F T unit !

20 Many more optimzations in real SAT-solvers! Effect of unit propagation Obviously: combine both optimizations! - Components analysis. - More Dynamic Search Rearrangement -Eg.: take most frequent variable first - Intelligent backtracking, Indexing, … Smaller search space again. But example is not well suited for unit propagation.

Marcus as SAT-solving: man_Marcus, ruler_Caesar, try_assassinate_Marcus_Ceasar, loyal_to_Marcus_Caesar, ~man_Marcus  ~ruler_Ceasar  ~try_assassinate_Marcus_Ceasar  ~local_to_Marcus_Ceasar,...  ~local_to_Marcus_Ceasar,...  Part of the grounding of Marcus-example  plus the negation of the theorem: 4 unit propagations: try_assassinate_Marcus_Ceasar = T man_Marcus = T ruler_Caesar = T loyal_to_Marcus_Caesar = T T, T, T, T, F  F  F  F,... Fails ! Theorem proved.

SAT-solving by Local Search WalkSAT algorithm

Local Search representation: X i, i=1,n propositional variables D j, j=1,m the disjunctions in the CNF States are n-tuples: (T,F,F,T, …,F) Objective function: the number of D j ‘s that evaluate to F = an interpretation for the X i ‘s Find the global minimum Neighbors: flip one truth value of an X i in failing D j To avoid local minima: probabilistically do Not take the best flip

24 The WalkSAT algorithm: For i= 1 to Max_flip do IF all Dj’s are true in State Then return State; IF all Dj’s are true in State Then return State; Else Else Disj:= random Dj that is false under State; Disj:= random Dj that is false under State; With probability P flip random Xi in Dj; With probability P flip random Xi in Dj; Else Else flip the Xi of Dj that minimizes false Dj’s; flip the Xi of Dj that minimizes false Dj’s; Max_flip:= some number; P:= some probability; S:= { Dj | Dj disjunction}; State:= some interpretation for X 1, X 2,...X n ; End-For Report Failure

Evaluation:  Unclear whether optimized SAT-solving or Local Search is better.  but today more people are using local search  Efficiency of methods depends on underconstraint versus overconstraintness of problems  see Norvig & Russel for a discussion

26 What about Disjunctive Normal From?  DNF: a dual representation for propositional formulas:  Satisfiability of DNF can be checked in linear time!  Find 1 conjunction that does not contain a variable and the negation of that variable. But: conversion to DNF requires exponential time and exponential space !  CNF and DNF are dual: so conversion to CNF is also exponential !!! (A1 ...  An)  (B1  …  Bm)  …  (C1  …  Ck) So why do we still prefer CNF ?? Think about it.