Introductionhunt/class/2015-fall/cs395t/slides/introduction.… · crown prince instructs you...
Transcript of Introductionhunt/class/2015-fall/cs395t/slides/introduction.… · crown prince instructs you...
Introduction
Marijn J.H. HeuleWarren A. Hunt Jr.
The University of Texas at Austin
Heule & Hunt (UT Austin) Introduction 1 / 28
Motivation satisfiability solving
From 100 variables, 200 clauses (early 90’s)
to 1,000,000 vars. and 5,000,000 clauses in 15 years.
Heule & Hunt (UT Austin) Introduction 2 / 28
Motivation satisfiability solving
From 100 variables, 200 clauses (early 90’s)
to 1,000,000 vars. and 5,000,000 clauses in 15 years.
Applications:
Hardware and Software Verification, Planning, Scheduling,Optimal Control, Protocol Design, Routing, Combinatorial
problems, Equivalence Checking, etc.
Heule & Hunt (UT Austin) Introduction 2 / 28
Motivation satisfiability solving
From 100 variables, 200 clauses (early 90’s)
to 1,000,000 vars. and 5,000,000 clauses in 15 years.
Applications:
Hardware and Software Verification, Planning, Scheduling,Optimal Control, Protocol Design, Routing, Combinatorial
problems, Equivalence Checking, etc.
SAT used to solve many other problems!
Heule & Hunt (UT Austin) Introduction 2 / 28
Overview
Introduction
The Satisfiability problem
Terminology
SAT solving
SAT benchmarks
Heule & Hunt (UT Austin) Introduction 3 / 28
Introduction
”You are chief of protocol for the embassy ball. Thecrown prince instructs you either to invite Peru or to
exclude Qatar. The queen asks you to invite either Qataror Romania or both. The king, in a spiteful mood, wants
to snub either Romania or Peru or both. Is there a guestlist that will satisfy the whims of the entire royal family?”
Heule & Hunt (UT Austin) Introduction 4 / 28
Introduction
”You are chief of protocol for the embassy ball. Thecrown prince instructs you either to invite Peru or to
exclude Qatar. The queen asks you to invite either Qataror Romania or both. The king, in a spiteful mood, wants
to snub either Romania or Peru or both. Is there a guestlist that will satisfy the whims of the entire royal family?”
(P ∨ ¬Q) ∧ (Q ∨ R) ∧ (¬R ∨ ¬P)
Heule & Hunt (UT Austin) Introduction 4 / 28
Truth Table
F := (P ∨ ¬Q) ∧ (Q ∨ R) ∧ (¬R ∨ ¬P)
P Q R falsifies ϕ ◦ F
0 0 0 (Q ∨ R) 00 0 1 — 10 1 0 (P ∨ ¬Q) 0
0 1 1 (P ∨ ¬Q) 01 0 0 (Q ∨ R) 0
1 0 1 (¬R ∨ ¬P) 01 1 0 — 1
1 1 1 (¬R ∨ ¬P) 0
Heule & Hunt (UT Austin) Introduction 5 / 28
Slightly Harder Example
What are the solutions for the following formula?
(A ∨ B ∨ ¬C )(¬A ∨ ¬B ∨ C )(B ∨ C ∨ ¬D)
(¬B ∨ ¬C ∨ D)(A ∨ C ∨ D)
(¬A ∨ ¬C ∨ ¬D)
(¬A ∨ B ∨ D)
Heule & Hunt (UT Austin) Introduction 6 / 28
Slightly Harder Example
What are the solutions for the following formula?
(A ∨ B ∨ ¬C )(¬A ∨ ¬B ∨ C )(B ∨ C ∨ ¬D)
(¬B ∨ ¬C ∨ D)(A ∨ C ∨ D)
(¬A ∨ ¬C ∨ ¬D)
(¬A ∨ B ∨ D)
A B C D
0 0 0 00 0 0 1
0 0 1 00 0 1 1
0 1 0 00 1 0 1
0 1 1 00 1 1 1
A B C D
1 0 0 01 0 0 1
1 0 1 01 0 1 1
1 1 0 01 1 0 1
1 1 1 01 1 1 1
Heule & Hunt (UT Austin) Introduction 6 / 28
Introduction: Sat question
Given a CNF formula,
does there exist an assignment
to the Boolean variablesthat satisfies all clauses?
Heule & Hunt (UT Austin) Introduction 7 / 28
Terminology: Variables and literals
Boolean variablecan be assigned the Boolean values 0 or 1
Literalrefers either to xi or its complement ¬xiliterals xi are satisfied if variable xi is assigned to 1 (true)
literals ¬xi are satisfied if variable xi is assigned to 0 (false)
Heule & Hunt (UT Austin) Introduction 8 / 28
Terminology: Clauses
ClauseDisjunction of literals: E.g. Cj = (l1 ∨ l2 ∨ l3)
Can be falsified with only one assignment to its literals: Allliterals assigned to false
Can be satisfied with 2k − 1 assignment to its k literals
One special clause - the empty clause (denoted by ∅) - which isalways falsified
Heule & Hunt (UT Austin) Introduction 9 / 28
Terminology: Formulae
FormulaConjunction of clauses: E.g. F = C1 ∧ C2 ∧ C3
Is satisfiable if there exists an assignment satisfying all clauses,otherwise unsatisfiable
Formulae are defined in Conjunction Normal Form (CNF) andgenerally also stored as such - also learned information
Heule & Hunt (UT Austin) Introduction 10 / 28
Terminology: Assignments
AssignmentMapping of the values 0 and 1 to the variables
ϕ ◦ F results in a reduced formula Freduced:
all satisfied clauses are removedall falsified literals are removed
satisfying assignment ↔ Freduced is empty
falsifying assignment ↔ Freduced contains ∅
partial assignment versus full assignment
Heule & Hunt (UT Austin) Introduction 11 / 28
Resolution
Given two clauses C1 = (x ∨ a1 ∨ · · · ∨ an) andC2 = (¬x ∨ b1 ∨ · · · ∨ bm), the resolvent of C1 and C2
(denoted by C1 ⊲⊳ C2) is R = (a1∨ · · · ∨ an ∨ b1∨ · · · ∨ bm)
Heule & Hunt (UT Austin) Introduction 12 / 28
Resolution
Given two clauses C1 = (x ∨ a1 ∨ · · · ∨ an) andC2 = (¬x ∨ b1 ∨ · · · ∨ bm), the resolvent of C1 and C2
(denoted by C1 ⊲⊳ C2) is R = (a1∨ · · · ∨ an ∨ b1∨ · · · ∨ bm)
Examples for F := (P ∨ ¬Q) ∧ (Q ∨ R) ∧ (¬R ∨ ¬P)(P ∨ ¬Q) ⊲⊳ (Q ∨ R) = (P ∨ R)
(P ∨ ¬Q) ⊲⊳ (¬R ∨ ¬P) = (¬Q ∨ ¬R)
(Q ∨ R) ⊲⊳ (¬R ∨ ¬P) = (Q ∨ ¬P)
Heule & Hunt (UT Austin) Introduction 12 / 28
Resolution
Given two clauses C1 = (x ∨ a1 ∨ · · · ∨ an) andC2 = (¬x ∨ b1 ∨ · · · ∨ bm), the resolvent of C1 and C2
(denoted by C1 ⊲⊳ C2) is R = (a1∨ · · · ∨ an ∨ b1∨ · · · ∨ bm)
Examples for F := (P ∨ ¬Q) ∧ (Q ∨ R) ∧ (¬R ∨ ¬P)(P ∨ ¬Q) ⊲⊳ (Q ∨ R) = (P ∨ R)
(P ∨ ¬Q) ⊲⊳ (¬R ∨ ¬P) = (¬Q ∨ ¬R)
(Q ∨ R) ⊲⊳ (¬R ∨ ¬P) = (Q ∨ ¬P)
Resolution, i.e., adding resolvents until fixpoint, is a
complete proof procedure. It produces the empty clause ifand only if the formula is unsatisfiable
Heule & Hunt (UT Austin) Introduction 12 / 28
Tautology
A clause C is a tautology if it containsfor some variable x , both the literals x and ¬x .
Slightly Harder Example 2
Compute all non-tautological resolvents for:
(A ∨ B ∨ ¬C ) ∧ (¬A ∨ ¬B ∨ C ) ∧(B ∨ C ∨ ¬D) ∧ (¬B ∨ ¬C ∨ D) ∧(A ∨ C ∨ D) ∧ (¬A ∨ ¬C ∨ ¬D) ∧(¬A ∨ B ∨ D)
Which resolvents remain after removing the supersets?
Heule & Hunt (UT Austin) Introduction 13 / 28
Sat solving: Unit propagation
A unit clause is a clause of size 1
UnitPropagation (ϕ,F):
1: while ∅ /∈ F and unit clause y exists do2: expand ϕ and simplify F3: end while
4: return ϕ,F
Heule & Hunt (UT Austin) Introduction 14 / 28
Unit propagation: Example
Funit := (¬x1 ∨ ¬x3 ∨ x4) ∧ (¬x1 ∨ ¬x2 ∨ x3) ∧(¬x1 ∨ x2) ∧ (x1 ∨ x3 ∨ x6) ∧ (¬x1 ∨ x4 ∨ ¬x5) ∧
(x1 ∨ ¬x6) ∧ (x4 ∨ x5 ∨ x6) ∧ (x5 ∨ ¬x6)
Heule & Hunt (UT Austin) Introduction 15 / 28
Unit propagation: Example
Funit := (¬x1 ∨ ¬x3 ∨ x4) ∧ (¬x1 ∨ ¬x2 ∨ x3) ∧(¬x1 ∨ x2) ∧ (x1 ∨ x3 ∨ x6) ∧ (¬x1 ∨ x4 ∨ ¬x5) ∧
(x1 ∨ ¬x6) ∧ (x4 ∨ x5 ∨ x6) ∧ (x5 ∨ ¬x6)
ϕ = {x1=1}
Heule & Hunt (UT Austin) Introduction 15 / 28
Unit propagation: Example
Funit := (¬x1 ∨ ¬x3 ∨ x4) ∧ (¬x1 ∨ ¬x2 ∨ x3) ∧(¬x1 ∨ x2) ∧ (x1 ∨ x3 ∨ x6) ∧ (¬x1 ∨ x4 ∨ ¬x5) ∧
(x1 ∨ ¬x6) ∧ (x4 ∨ x5 ∨ x6) ∧ (x5 ∨ ¬x6)
ϕ = {x1=1, x2=1}
Heule & Hunt (UT Austin) Introduction 15 / 28
Unit propagation: Example
Funit := (¬x1 ∨ ¬x3 ∨ x4) ∧ (¬x1 ∨ ¬x2 ∨ x3) ∧(¬x1 ∨ x2) ∧ (x1 ∨ x3 ∨ x6) ∧ (¬x1 ∨ x4 ∨ ¬x5) ∧
(x1 ∨ ¬x6) ∧ (x4 ∨ x5 ∨ x6) ∧ (x5 ∨ ¬x6)
ϕ = {x1=1, x2=1, x3=1}
Heule & Hunt (UT Austin) Introduction 15 / 28
Unit propagation: Example
Funit := (¬x1 ∨ ¬x3 ∨ x4) ∧ (¬x1 ∨ ¬x2 ∨ x3) ∧(¬x1 ∨ x2) ∧ (x1 ∨ x3 ∨ x6) ∧ (¬x1 ∨ x4 ∨ ¬x5) ∧
(x1 ∨ ¬x6) ∧ (x4 ∨ x5 ∨ x6) ∧ (x5 ∨ ¬x6)
ϕ = {x1=1, x2=1, x3=1, x4=1}
Heule & Hunt (UT Austin) Introduction 15 / 28
Sat solving: DPLL
Davis Putnam Logemann Loveland [DP60,DLL62]
Simplify (Unit Propagation)
Split the formula
Variable Selection HeuristicsDirection heuristics
Heule & Hunt (UT Austin) Introduction 16 / 28
DPLL: Example
FDPLL := (x1 ∨ x2 ∨ ¬x3) ∧ (¬x1 ∨ x2 ∨ x3) ∧(¬x1 ∨ ¬x2 ∨ x3) ∧ (x1 ∨ x3) ∧ (¬x1 ∨ ¬x3)
Heule & Hunt (UT Austin) Introduction 17 / 28
DPLL: Example
FDPLL := (x1 ∨ x2 ∨ ¬x3) ∧ (¬x1 ∨ x2 ∨ x3) ∧(¬x1 ∨ ¬x2 ∨ x3) ∧ (x1 ∨ x3) ∧ (¬x1 ∨ ¬x3)
x3
1 0
Heule & Hunt (UT Austin) Introduction 17 / 28
DPLL: Example
FDPLL := (x1 ∨ x2 ∨ ¬x3) ∧ (¬x1 ∨ x2 ∨ x3) ∧(¬x1 ∨ ¬x2 ∨ x3) ∧ (x1 ∨ x3) ∧ (¬x1 ∨ ¬x3)
x3
1 0
x2
x1 x3
0 1
0 1 1 0
Heule & Hunt (UT Austin) Introduction 17 / 28
DPLL: Slightly Harder Example
Slightly Harder Example 3
Construct a DPLL tree for:
(A ∨ B ∨ ¬C ) ∧ (¬A ∨ ¬B ∨ C ) ∧(B ∨ C ∨ ¬D) ∧ (¬B ∨ ¬C ∨ D) ∧(A ∨ C ∨ D) ∧ (¬A ∨ ¬C ∨ ¬D) ∧(¬A ∨ B ∨ D)
Heule & Hunt (UT Austin) Introduction 18 / 28
Sat solving: Decisions, implications
Decision variablesSelected by the heuristics
Play a crucial role in performance
Implied variablesAssigned by reasoning (e.g. unit propagation)
Maximizing the number of implied variables is an importantaspect of look-ahead Sat solvers
Heule & Hunt (UT Austin) Introduction 19 / 28
SAT Solving: Clauses ↔ assignments
A clause C represents a set of falsified assignments, i.e. thoseassignments that falsify all literals in C
A falsifying assignment ϕ for a given formula represents a set ofclauses that follow from the formula
For instance with all decision variablesImportant feature of conflict-driven Sat solvers
Heule & Hunt (UT Austin) Introduction 20 / 28
SAT solvers
Conflict-driven”brute-force”, complete
examples: zchaff, minisat, rsat
Look-aheadlots of reasoning, complete
examples: march, OKsolver, kcnfs
Local searchlocal optimazations, incomplete
examples: WalkSAT, UnitWalk
Heule & Hunt (UT Austin) Introduction 21 / 28
Applications: Industrial
Model CheckingTuring award ’07 Clarke, Emerson, and Sifakis
Software Verification
Hardware Verification
Equivalence Checking Problems
Heule & Hunt (UT Austin) Introduction 22 / 28
Applications: Crafted
Combinatorial problems
Sudoku
Factorization problems
Heule & Hunt (UT Austin) Introduction 23 / 28
Random k-Sat: Introduction
All clauses have length k
Variables have the same probability to occur
Each literal is negated with probability of 50%
Density is ratio Clauses to Variables
Heule & Hunt (UT Austin) Introduction 24 / 28
Random 3-Sat: % satisfiable, the phase transition
1 2 3 4 5 6 7 8
0
25
50
75
100
5040302010
variables
clause-variable density
Heule & Hunt (UT Austin) Introduction 25 / 28
Random 3-Sat: exponential runtime, the threshold
1 2 3 4 5 6 7 80
1,000
2,000
3,000
4,000
5,000
5040302010
variables
clause-variable density
Heule & Hunt (UT Austin) Introduction 26 / 28
SAT game
SAT gameby Olivier Roussel
http://www.cs.utexas.edu/~marijn/game/
Heule & Hunt (UT Austin) Introduction 27 / 28
Introduction
Marijn J.H. HeuleWarren A. Hunt Jr.
The University of Texas at Austin
Heule & Hunt (UT Austin) Introduction 28 / 28