Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or...
Transcript of Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or...
![Page 1: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/1.jpg)
1/25/2008
Where the hard
problems are
Toby Walsh
Cork Constraint Computation Centre
http://4c.ucc.ie/~tw
![Page 2: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/2.jpg)
1/25/2008
Where the hard problems are
� That’s easy� Passing your finals
� Finding a job
� …
![Page 3: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/3.jpg)
1/25/2008
Where the hard problems are
� That’s easy� Passing your finals
� Finding a job
� …
� Where are the hard computational problems?� Computational complexity
� Phase transition behaviour
� Exploiting structure
![Page 4: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/4.jpg)
1/25/2008
Computational complexity
� Study of “problem hardness”� Typically worst case
� Big O analysis� Sorting is easy, O(n logn)
� Chess and GO are hard, EXP-time
� “Can I be sure to win?”
� Need to generalize problem to n by n board
![Page 5: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/5.jpg)
1/25/2008
Computational complexity
� Study of “problem hardness”� Typically worst case
� Big O analysis� Sorting is easy, O(n logn)
� Chess and GO are hard, EXP-time
� “Can I be sure to win?”
� Need to generalize problem to n by n board
Where do things start getting hard?
![Page 6: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/6.jpg)
1/25/2008
Computational complexity
� Hierarchy of complexity classes
� Polynomial (P), NP, PSpace, ….
� NP-complete problems mark boundary of tractability� No known polynomial time algorithm
� Though open if P=/=NP
Aside: What happens at the top of this hierarchy?
Some algorithms may NEVER terminate, e.g.
halting problem is undecidable
![Page 7: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/7.jpg)
1/25/2008
NP-complete problems
� Non-deterministic Polynomial time� If I guess a solution, I can check it in polynomial time
� But no known easy way to guess solution correctly!
� Complete� Representative of all problems in this class
� If this problem can be solved in polynomial time, all
problems in the class can be solved
� Any NP-complete problem can be mapped into any other
![Page 8: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/8.jpg)
1/25/2008
NP-complete problems
� Many examples� Propositional satisfiability (SAT)
� Graph colouring
� Travelling salesperson problem
� Exam timetabling
� …
![Page 9: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/9.jpg)
1/25/2008
Satisfiability
� 1st problem shown to be NP-complete [Cook 71]
� Decision problem� Given a clausal formula, is it satisfiable?
E.g. (X or Y) & (-Y or Z) is satisfied by
X=true, Y=false …
� Clausal = ANDs of some ORs
![Page 10: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/10.jpg)
1/25/2008
Satisfiability
� In NP (easy to prove)� You give me an assignment, I can check it satisfies formula in polynomial time
� Complete for NP (hard to prove)� Any problem in NP can be reduced to SAT in polynomial time
![Page 11: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/11.jpg)
1/25/2008
Diplomatic problem
� Embassy ball. King wants to invite PERU or exclude QATAR
Queen wants to invite QATAR or ROMANIA
Kings wants to snub ROMANIA or PERU
Who can we invite?
![Page 12: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/12.jpg)
1/25/2008
Diplomatic problem
� Embassy ball. King wants to invite PERU or exclude QATAR
Queen wants to invite QATAR or ROMANIA
Kings wants to snub ROMANIA or PERU
(P or -Q) & (Q or R) & (-R or -P)
![Page 13: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/13.jpg)
1/25/2008
Diplomatic problem
� Embassy ball. King wants to invite PERU or exclude QATAR
Queen wants to invite QATAR or ROMANIA
Kings wants to snub ROMANIA or PERU
(P or -Q) & (Q or R) & (-R or -P) is satisfied by
P=true, Q=true, R=false
![Page 14: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/14.jpg)
1/25/2008
Diplomatic problem
� Embassy ball. King wants to invite PERU or exclude QATAR
Queen wants to invite QATAR or ROMANIA
Kings wants to snub ROMANIA or PERU
(P or -Q) & (Q or R) & (-R or -P) is satisfied by
P=true, Q=true, R=false and by
P=false, Q=false, R=true
![Page 15: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/15.jpg)
1/25/2008
Other applications of SAT
� Hardware verification
![Page 16: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/16.jpg)
1/25/2008
Other applications of SAT
� Hardware verification
S = Cin or (P or Q), …
![Page 17: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/17.jpg)
1/25/2008
Other applications of SAT
� Scheduling jobs in a factory� Set of jobs, resource constraints, start and due
dates, …
� Just need to sequence jobs
� Xij = true iff Job i occurs before Job j
…
![Page 18: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/18.jpg)
1/25/2008
Other applications of SAT
� Design theory� Experimental design, Latin squares with special
properties
� Open problems solved by encoding problems into
SAT
� [Fujita, Slaney, Bennet, 1993]
� Best paper at the International Joint Conference on
Artificial Intelligence, 1993
![Page 19: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/19.jpg)
1/25/2008
Quasigroup or Latin Square
(Order 4)
Latin square
� Also called “quasigroup”
� Each colour occurs once in each row and column
![Page 20: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/20.jpg)
1/25/200832% preassignment
Latin squares
� Can we complete a partially coloured Latin
square?� NP-complete problem
� Applications in telecommunications
![Page 21: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/21.jpg)
1/25/2008
SAT model for Latin square
� What are the variables?� Xijk is true if square (i,j) has the colour k
� What are the constraints� Row constraints
(-Xijk or -Xij+1k), ….
� Column constraints
(-Xijk or -Xi+1jk), …
![Page 22: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/22.jpg)
1/25/2008
Nodes
connect point to point
fiber optic links
Each fiber optic link supports a
large number of wavelengths
Nodes are capable of photonic switching --dynamic wavelength routing --
which involves the setting of the wavelengths.
Fibre-optic routing
![Page 23: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/23.jpg)
1/25/2008
Routing in Fiber Optic Networks
Routing NodeHow can we achieve conflict-free routing in each node of the network?
Dynamic wavelength routing is a NP-hard problem.
Input Ports Output Ports1
2
3
4
1
2
3
4
preassigned channels
![Page 24: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/24.jpg)
1/25/2008
Inp
ut
po
rts
Output ports
3
1
2
4
Input Port Output Port
1
2
43
Routing = Latin square problem
� Each channel cannot be repeated on input ports
� Each channell cannot be repeated on output ports
![Page 25: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/25.jpg)
1/25/2008
Orthogonal Latin squares
� Find a pair of Latin squares� Every cell has a different
pair of elements
� Generalized form:� Find a set of m Latin
squares
� Each possible pair is
orthogonal
![Page 26: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/26.jpg)
1/25/2008
Orthogonal Latin squares
1 2 3 4 1 2 3 4
2 1 4 3 3 4 1 2
3 4 1 2 4 3 2 1
4 3 2 1 2 1 4 3
11 22 33 44
23 14 41 32
34 43 12 21
42 31 24 13
� Two 4 by 4 Latin squares
� No pair is repeated
![Page 27: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/27.jpg)
1/25/2008
History
� Orthogial Latin squares were introduced by Euler
in 1783� Also called Graeco-Latin or Euler squares
� No orthogonal Latin square of order 2� There are only 2 (non)-isomorphic Latin squares of
order 2 and they are not orthogonal
![Page 28: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/28.jpg)
1/25/2008
History
� Euler conjectured in 1783 that there are no orthogonal
Latin squares of order 4n+2� Constructions exist for 4n and for 2n+1
� Took till 1900 to show conjecture for n=1
� Took till 1960 to show false for all n>1
![Page 29: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/29.jpg)
1/25/2008
History
� 6 by 6 problem known as
the 36 officer problem
“… Can a delegation of six regiments,
each of which sends a colonel, a
lieutenant-colonel, a major, a captain, a
lieutenant, and a sub-lieutenant be
arranged in a regular 6 by 6 array such
that no row or column duplicates a rank
or a regiment?”
![Page 30: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/30.jpg)
1/25/2008
More background
� Lam’s problem� Existence of finite projective plane of order 10
� Equivalent to set of 9 mutually orthogonal Latin squares of order 10
� In 1989, this was shown not to be possible after 2000 hours on a Cray (and some major maths)
� Applications in experimental design� To ensure no dependency between independent variables
![Page 31: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/31.jpg)
1/25/2008
A simple SAT model
� What are the variables?� Xijkl = true if pair (i,j) is in row k column l, false otherwise
� What are the constraints?� Lots of them!
� Latin square constraints
� Orthogonality constraints
![Page 32: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/32.jpg)
1/25/2008
A simple SAT model
� Orthogonal Latin square has lots of symmetry� Permute the rows
� Permute the cols
� Permute the numbers 1 to n in each square
� How can we eliminate such symmetry?
![Page 33: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/33.jpg)
1/25/2008
Symmetry removal
� Fix first row 11 22 33 …
� Fix first column11
23
32
..
� Eliminates all this symmetry?
See Ian Gent or Steve Linton if this interests you!
![Page 34: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/34.jpg)
1/25/2008
SAT algorithms
� How do we test if a problem is SAT or not?� Complete methods
� Return “Yes” if SATisfiable
� Return “No” if UNSATisfiable
� Incomplete methods
� If return “Yes”, problem is SATisfiable
� Otherwise timeout/run forever, problem can be SAT or
UNSAT
![Page 35: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/35.jpg)
1/25/2008
Complete SAT algorithms
� Truth tables
![Page 36: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/36.jpg)
1/25/2008
Complete SAT algorithms
� Truth tables� Exponential time to
construct
![Page 37: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/37.jpg)
1/25/2008
Complete SAT algorithms
� Truth tables� Exponential time to
construct
� Exponential space
![Page 38: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/38.jpg)
1/25/2008
Complete SAT algorithms
� Davis Putnam algorithm� Due to Davis, Logemann and Loveland from 1962
� Original algorithm by Davis & Putnam in 1960 could
use exponential space
� DLL traded time for space to give linear space
algorithm
![Page 39: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/39.jpg)
1/25/2008
Complete SAT algorithms
� Davis Putnam algorithm� Consider
(X or Y) & (-X or Z) & (-Y or Z) & …
� Basic idea
� Try X=true
![Page 40: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/40.jpg)
1/25/2008
Complete SAT algorithms
� Davis Putnam algorithm� Consider
(X or Y) & (-X or Z) & (-Y or Z) & …
� Basic idea
� Try X=true
� Remove clauses which must be satisfied
![Page 41: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/41.jpg)
1/25/2008
Complete SAT algorithms
� Davis Putnam algorithm� Consider
(-X or Z) & (-Y or Z) & …
� Basic idea
� Try X=true
� Remove clauses which must be satisfied
� Simplify clauses containing -X
![Page 42: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/42.jpg)
1/25/2008
Complete SAT algorithms
� Davis Putnam algorithm� Consider
( Z) & (-Y or Z) & …
� Basic idea
� Try X=true
� Remove clauses which must be satisfied
� Simplify clauses containing -X
� Can now deduce that Z must be true
![Page 43: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/43.jpg)
1/25/2008
Complete SAT algorithms
� Davis Putnam algorithm� Consider
( Z) & (-Y or Z) & …
� Basic idea
� Try X=true
� Remove clauses which must be satisfied
� Simplify clauses containing -X
� Can now deduce that Z must be true
� At any point, may have to backtrack and try X=false
instead
![Page 44: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/44.jpg)
1/25/2008
Complete SAT algorithms
� Davis Putnam algorithm� Branching heuristics
� Which variable to assign next?
� Which value (true/false) to try first?
� Other refinements
� Clause learning
� Intelligence backtracking
� Implementation tricks
� Worst-case complexity
� O(1.696^n)
![Page 45: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/45.jpg)
1/25/2008
Incomplete SAT algorithms
� Most fit a very simple schema� Randomly guess truth assignment
� Repeat
� Pick a variable
� Flip its truth value
![Page 46: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/46.jpg)
1/25/2008
Incomplete SAT algorithms
� Most fit a very simple schema� Randomly guess truth assignment
� Repeat
� Pick a variable
� Flip its truth value
� Heuristics to pick variable
� Any var in UNSAT clause
� Var that maximizes number of SAT clauses if flipped
� Var in UNSAT clause flipped longest time ago …
![Page 47: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/47.jpg)
1/25/2008
Other SAT algorithms
� All kinds of exotic approaches have also been
tried� Genetic algorithms
� Ant algorithms
� DNA algorithms
� Quantum algorithms
� …
![Page 48: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/48.jpg)
1/25/2008
k-SAT
� Subclass of SAT problem� Exactly k variables in each clause
(P or -Q) & (Q or R) & (-R or -P) is in 2-SAT
![Page 49: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/49.jpg)
1/25/2008
k-SAT
� Subclass of SAT problem� k variables in each clause
(P or -Q) & (Q or R) & (-R or -P) is in 2-SAT
� 3-SAT is NP-complete� SAT can be reduced to 3-SAT
![Page 50: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/50.jpg)
1/25/2008
k-SAT
� Subclass of SAT problem� k variables in each clause
(P or -Q) & (Q or R) & (-R or -P) is in 2-SAT
� 3-SAT is NP-complete� SAT can be reduced to 3-SAT
(P or Q or R or S) = (P or Q or T) & T iff (R or S)
= (P or Q or T) & (-T or R or S)
& (T or -R) & (T or -S)
![Page 51: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/51.jpg)
1/25/2008
k-SAT
� Subclass of SAT problem� k variables in each clause
(P or -Q) & (Q or R) & (-R or -P) is in 2-SAT
� 3-SAT is NP-complete� SAT can be reduced to 3-SAT
� 2-SAT is in P� Exists linear time algorithm!
Adding extra var to each clause makes problems hard … more on this later in the lectures!
![Page 52: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/52.jpg)
1/25/2008
3-SAT
� Where are the hard 3-SAT problems?
� Sample randomly generated 3-SAT
� Fix number of clauses, l
� Number of variables, n
� By definition, each clause has 3 variables
� Generate all possible clauses with uniform probability
![Page 53: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/53.jpg)
1/25/2008
Random 3-SAT
� Which are the hard
instances?� around l/n = 4.3
What happens with larger problems?
Why are some dots red and others blue?
This is a so-called “phase transition”
![Page 54: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/54.jpg)
1/25/2008
Random 3-SAT
� Varying problem size, n
� Complexity peak appears to be
largely invariant of algorithm� complete algorithms like
Davis-Putnam
� Incomplete methods like
local search
What’s so special about 4.3?
![Page 55: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/55.jpg)
1/25/2008
Random 3-SAT
� Complexity peak coincides with satisfiability transition
� l/n < 4.3 problems under-constrained and SAT
� l/n > 4.3 problems over-constrained and UNSAT
� l/n=4.3, problems on “knife-edge” between SAT and UNSAT
![Page 56: Toby Walsh Cork Constraint Computation Centre ... Lecture… · King wants to invite PERU or exclude QATAR Queen wants to invite QATAR or ROMANIA Kings wants to snub ROMANIA or PERU](https://reader036.fdocuments.in/reader036/viewer/2022081617/60221c6d4cc40f5144116a51/html5/thumbnails/56.jpg)
1/25/2008
Conclusions
� SAT is a useful problem class� Theoretical importance
� Practical value
� Hard problems often turn up at a phase transition� Next lecture: a closer look at this phenomenon!