Global Constraints Toby Walsh NICTA and University of New South Wales www.cse.unsw.edu.au/~tw.

Slides:



Advertisements
Similar presentations
Today’s Objective To be able to find the x and y intercepts of an equation and use them to draw a quick graph.
Advertisements

Thursday, March 7 Duality 2 – The dual problem, in general – illustrating duality with 2-person 0-sum game theory Handouts: Lecture Notes.
Graph of a Curve Continuity This curve is _____________These curves are _____________ Smoothness This curve is _____________These curves are _____________.
Graph of a Curve Continuity This curve is continuous
The Derivative in Graphing and Application
1D Bin Packing (or “CP? Who cares?”)
Non-Binary Constraint Satisfaction Toby Walsh Cork Constraint Computation Center.
Non-binary Constraints Toby Walsh
Constraint Programming Peter van Beek University of Waterloo.
Maximal Independent Subsets of Linear Spaces. Whats a linear space? Given a set of points V a set of lines where a line is a k-set of points each pair.
Markov models and HMMs. Probabilistic Inference P(X,H,E) P(X|E=e) = P(X,E=e) / P(E=e) with P(X,E=e) = sum h P(X, H=h, E=e) P(X,E=e) = sum h,x P(X=x, H=h,
WOOD 492 MODELLING FOR DECISION SUPPORT Lecture 17 Integer Programming.
Weighted Matching-Algorithms, Hamiltonian Cycles and TSP
PROLOG MORE PROBLEMS.
Another example Max z=5x1+12x2+4x3-MR S.t. x1+2x2+x3+x4=10
Max output (Q) subject to a cost constraint
Inverting a Singly Linked List Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals.
TS: Explicitly assessing information and drawing conclusions Increasing & Decreasing Functions.
Constraint Satisfaction Problems Russell and Norvig: Chapter
Global Constraints Toby Walsh National ICT Australia and University of New South Wales
Global Constraints Toby Walsh National ICT Australia and University of New South Wales
10/7/2014 Constrainedness of Search Toby Walsh NICTA and UNSW
Intelligence Artificial Intelligence Ian Gent Constraint Programming 1.
Global Constraints Toby Walsh National ICT Australia and University of New South Wales
Global Constraints Toby Walsh National ICT Australia and University of New South Wales
Global Constraints Toby Walsh National ICT Australia and University of New South Wales
Global Constraints Toby Walsh NICTA and University of New South Wales
0 “Applications” of knapsack problems 10 September 2002.
Global Constraints Toby Walsh National ICT Australia and University of New South Wales
Constraint Programming Toby Walsh UNSW and NICTA.
2 x0 0 12/13/2014 Know Your Facts!. 2 x1 2 12/13/2014 Know Your Facts!
2 x /10/2015 Know Your Facts!. 8 x /10/2015 Know Your Facts!
IEOR 4004 Midterm Review (part I)
SAT Encoding For Sudoku Puzzles
Distributed Constraint Satisfaction Problems M OHSEN A FSHARCHI.
C&O 355 Lecture 5 N. Harvey TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A.
The Max-Cut problem: Election recounts? Majority vs. Electoral College? 7812.
1 Lecture 5 PRAM Algorithm: Parallel Prefix Parallel Computing Fall 2008.
16.410: Eric Feron / MIT, Spring 2001 Introduction to the Simplex Method to solve Linear Programs Eric Feron Spring 2001.
5 x4. 10 x2 9 x3 10 x9 10 x4 10 x8 9 x2 9 x4.
EMIS 8374 LP Review: The Ratio Test. 1 Main Steps of the Simplex Method 1.Put the problem in row-0 form. 2.Construct the simplex tableau. 3.Obtain an.
DIRECTIONAL ARC-CONSISTENCY ANIMATION Fernando Miranda 5986/M
Linear Programming – Simplex Method: Computational Problems Breaking Ties in Selection of Non-Basic Variable – if tie for non-basic variable with largest.
A Case Study  Some Advice on How to Go about Solving Problems in Prolog  A Program to Play Connect-4 Game.
Constraint Optimization We are interested in the general non-linear programming problem like the following Find x which optimizes f(x) subject to gi(x)
Variational Inference Amr Ahmed Nov. 6 th Outline Approximate Inference Variational inference formulation – Mean Field Examples – Structured VI.
Chapter 8: The Solver and Mathematical Programming Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University.
Computational Facility Layout
Section 3.4 The Traveling Salesperson Problem Tucker Applied Combinatorics By Aaron Desrochers and Ben Epstein.
Constraint Satisfaction taking advantage of internal structure of states when paths don’t matter.
(1) MAX X1+3X2+2X3+4X4 X1=AM PHONE, X2=AM RIDE, X3=AFT PHONE, X4=AFT RIDE CONSTRAINTS AM: X1+20X2 < 12(60)=720 AFT: 2X3+30X4 < 14(60) = 840 GAS: X2+X4.
Simplex (quick recap). Replace all the inequality constraints by equalities, using slack variables.
Constraint Networks (cont.) Emma Rollón Postdoctoral researcher at UCI April 1st, 2009.
BINARY/MIXED-INTEGER PROGRAMMING ( A SPECIAL TYPE OF INTEGER PROGRAMMING)
Global Constraints Toby Walsh National ICT Australia and University of New South Wales
Global Constraints Toby Walsh National ICT Australia and University of New South Wales
Global Constraints Toby Walsh National ICT Australia and University of New South Wales
1 Finite Constraint Domains. 2 u Constraint satisfaction problems (CSP) u A backtracking solver u Node and arc consistency u Bounds consistency u Generalized.
Global Constraints Toby Walsh NICTA and University of New South Wales
Linear Programming Unit 2, Lesson 4 10/13.
HELP ME WITH THE WEATHER REPORT. PRESS THE GREEN BUTTON TO START.
Global Grammar Constraints Toby Walsh National ICT Australia and University of New South Wales Joint work with Claude-Guy Quimper.
Non-binary constraints Toby Walsh Cork Constraint Computation Center
Math Meeting What is today’s date? __________________________________________ What is another way to write this date? ______________________ Who would.
CP Summer School Modelling for Constraint Programming Barbara Smith 1.Definitions, Viewpoints, Constraints 2.Implied Constraints, Optimization,
Canberra is the capital of Australia. The capital of China is Beijing.
Artificial Intelligence CS482, CS682, MW 1 – 2:15, SEM 201, MS 227 Prerequisites: 302, 365 Instructor: Sushil Louis,
We’ve got a surprise!!! Any ideas what it is???? excited-and-i-just-cant-hide-it/
Constraint satisfaction problems
Constraint satisfaction problems
Presentation transcript:

Global Constraints Toby Walsh NICTA and University of New South Wales

Quick advert ZUNSW is in Sydney ZRegularly voted in top 10 cities in World ZUNSW is one of top universities in Australia ZIn top 100 universities in world ZTalk to me about our PhD programme! ZAlso happy to have PhDs/PostDocs visit for weeks/months/years … ZAttend CP/KR/ICAPS in Sept

Value precedence ZGlobal constraint used to deal with value symmetry ZGood example of “global” constraint where we can use an efficient encoding ZEncoding gives us GAC ZAsymptotically optimal, achieve GAC in O(nd) time ZGood incremental/decremental complexity

Value symmetry ZDecision variables: ZCol[Italy], Col[France], Col[Austria]... ZDomain of values: Zred, yellow, green,... ZConstraints Col[Italy]=/=Col[France] Col[Italy]=/=Col[Austria] …

Value symmetry ZSolution: ZCol[Italy]=green Col[France]=red Col[Spain]=green … ZValues (colours) are interchangeable: ZSwap red with green everywhere will still give us a solution

Value precedence ZOld idea ZUsed in bin-packing and graph colouring algorithms ZOnly open the next new bin ZOnly use one new colour ZApplied now to constraint satisfaction

Value precedence ZSuppose all values from 1 to m are interchangeable ZMight as well let X1=1

Value precedence ZSuppose all values from 1 to m are interchangeable ZMight as well let X1=1 ZFor X2, we need only consider two choices ZX2=1 or X2=2

Value precedence ZSuppose all values from 1 to m are interchangeable ZMight as well let X1=1 ZFor X2, we need only consider two choices ZSuppose we try X2=2

Value precedence ZSuppose all values from 1 to m are interchangeable ZMight as well let X1=1 ZFor X2, we need only consider two choices ZSuppose we try X2=2 ZFor X3, we need only consider three choices ZX3=1, X3=2, X3=3

Value precedence ZSuppose all values from 1 to m are interchangeable ZMight as well let X1=1 ZFor X2, we need only consider two choices ZSuppose we try X2=2 ZFor X3, we need only consider three choices ZSuppose we try X3=2

Value precedence ZSuppose all values from 1 to m are interchangeable ZMight as well let X1=1 ZFor X2, we need only consider two choices ZSuppose we try X2=2 ZFor X3, we need only consider three choices ZSuppose we try X3=2 ZFor X4, we need only consider three choices ZX4=1, X4=2, X4=3

Value precedence ZGlobal constraint ZPrecedence([X1,..Xn]) iff min({i | Xi=j or i=n+1}) < min({i | Xi=k or i=n+2}) for all j<k ZIn other words ZThe first time we use j is before the first time we use k

Value precedence ZGlobal constraint ZPrecedence([X1,..Xn]) iff min({i | Xi=j or i=n+1}) < min({i | Xi=k or i=n+2}) ZE.g ZPrecedence([1,1,2,1,3,2,4,2,3]) ZBut not Precedence([1,1,2,1,4])

Value precedence ZGlobal constraint ZPrecedence([X1,..Xn]) iff min({i | Xi=j or i=n+1}) < min({i | Xi=k or i=n+2}) ZPropagator proposed by [Law and Lee 2004] ZPointer based propagator (alpha, beta, gamma) but only for two interchangeable values at a time

Value precedence ZPrecedence([j,k],[X1,..Xn]) iff min({i | Xi=j or i=n+1}) < min({i | Xi=k or i=n+2}) ZOf course ZPrecedence([X1,..Xn]) iff Precedence([i,j],[X1,..Xn]) for all i<j ZPrecedence([X1,..Xn]) iff Precedence([i,i+1],[X1,..Xn]) for all i

Value precedence ZPrecedence([j,k],[X1,..Xn]) iff min({i | Xi=j or i=n+1}) < min({i | Xi=k or i=n+2}) ZOf course ZPrecedence([X1,..Xn]) iff Precedence([i,j],[X1,..Xn]) for all i<j ZBut this hinders propagation ZGAC(Precedence([X1,..Xn])) does strictly more pruning than GAC(Precedence([i,j],[X1,..Xn])) for all i<j ZConsider X1=1, X2 in {1,2}, X3 in {1,3} and X4 in {3,4}

Puget’s method ZIntroduce Zj to record first time we use j ZAdd constraints ZXi=j implies Zj <= i ZZj=i implies Xi=j ZZi < Zi+1

Puget’s method ZIntroduce Zj to record first time we use j ZAdd constraints ZXi=j implies Zj < i ZZj=i implies Xi=j ZZi < Zi+1 ZBinary constraints Zeasy to implement

Puget’s method ZIntroduce Zj to record first time we use j ZAdd constraints ZXi=j implies Zj < I ZZj=i implies Xi=j ZZi < Zi+1 ZUnfortunately hinders propagation ZAC on encoding may not give GAC on Precedence([X1,..Xn]) ZConsider X1=1, X2 in {1,2}, X3 in {1,3}, X4 in {3,4}, X5=2, X6=3, X7=4

Propagating Precedence ZSimple ternary encoding ZIntroduce sequence of variables, Yi ZRecord largest value used so far ZY1=0

Propagating Precedence ZSimple ternary encoding ZPost sequence of constraints C(Xi,Yi,Yi+1) for each 1<=i<=n These hold iff Xi<=1+Yi and Yi+1=max(Yi,Xi)

Propagating Precedence ZSimple ternary encoding ZPost sequence of constraints ZEasily implemented within most solvers ZImplication and other logical primitives ZGAC-Schema (alias “table” constraint) Z…

Propagating Precedence ZSimple ternary encoding ZPost sequence of constraints ZC(Xi,Yi,Yi+1) for each 1<=i<=n ZThis decomposition is Berge-acyclic ZConstraints overlap on one variable and form a tree

Propagating Precedence ZSimple ternary encoding ZPost sequence of constraints ZC(Xi,Yi,Yi+1) for each 1<=i<=n ZThis decomposition is Berge-acyclic ZConstraints overlap on one variable and form a tree ZHence enforcing GAC on the decomposition achieves GAC on Precedence([X1,..Xn]) ZTakes O(n) time ZAlso gives excellent incremental behaviour

Propagating Precedence ZSimple ternary encoding ZPost sequence of constraints ZC(Xi,Yi,Yi+1) for each 1<=i<=n ZThese hold iff Xi<=1+Yi and Yi+1=max(Yi,Xi) ZConsider Y1=0, X1 in {1,2,3}, X2 in {1,2,3} and X3=3

Precedence and matrix symmetry ZAlternatively, could map into 2d matrix ZXij=1 iff Xi=j ZValue precedence now becomes column symmetry ZCan lex order columns to break all such symmetry ZAlternatively view value precedence as ordering the columns of a matrix model

Precedence and matrix symmetry ZAlternatively, could map into 2d matrix ZXij=1 iff Xi=j ZValue precedence now becomes column symmetry ZHowever, we get less pruning this way ZAdditional constraint that rows have sum of 1 ZConsider, X1=1, X2 in {1,2,3} and X3=1

Partial value precedence ZValues may partition into equivalence classes ZValues within each equivalence class are interchangeable ZE.g. Shift1=nursePaul, Shift2=nursePeter, Shift3=nurseJane, Shift4=nursePaul..

Partial value precedence ZShift1=nursePaul, Shift2=nursePeter, Shift3=nurseJane, Shift4=nursePaul.. ZIf Paul and Jane have the same skills, we can swap them (but not with Peter who is less qualified) ZShift1=nurseJane, Shift2=nursePeter, Shift3=nursePaul, Shift4=nurseJane …

Partial value precedence ZValues may partition into equivalence classes ZValue precedence easily generalized to cover this case ZWithin each equivalence class, vi occurs before vj for all i<j (ignore values from other equivalence classes)

Partial value precedence ZValues may partition into equivalence classes ZValue precedence easily generalized to cover this case ZWithin each equivalence class, vi occurs before vj for all i<j (ignore values from other equivalence classes) ZFor example ZSuppose vi are one equivalence class, and ui another

Partial value precedence ZValues may partition into equivalence classes ZValue precedence easily generalized to cover this case ZWithin each equivalence class, vi occurs before vj for all i<j (ignore values from other equivalence classes) ZFor example ZSuppose vi are one equivalence class, and ui another ZX1=v1, X2=u1, X3=v2, X4=v1, X5=u2

Partial value precedence ZValues may partition into equivalence classes ZValue precedence easily generalized to cover this case ZWithin each equivalence class, vi occurs before vj for all i<j (ignore values from other equivalence classes) ZFor example ZSuppose vi are one equivalence class, and ui another ZX1=v1, X2=u1, X3=v2, X4=v1, X5=u2 ZSince v1, v2, v1 … and u1, u2, …

Variable and value precedence ZValue precedence compatible with other symmetry breaking methods ZInterchangeable values and lex ordering of rows and columns in a matrix model

Conclusions ZSymmetry of interchangeable values can be broken with value precedence constraints ZValue precedence can be decomposed into ternary constraints ZEfficient and effective method to propagate ZCan be generalized in many directions ZPartial interchangeability, …

Global constraints ZHardcore algorithms ZData structures ZGraph theory ZFlow theory ZCombinatorics Z… ZComputational complexity ZGlobal constraints are often balanced on the limits of tractability!

Computational complexity 101 ZSome problems are essentially easy ZMultiplication, O(n 1.58 ) ZSorting, O(n logn) ZRegular language membership, O(n) ZContext free language membership, O(n 3 ).. ZP (for “polynomial”) ZClass of decision problems recognized by deterministic Turing Machine in polynomial number of steps ZDecision problem ZQuestion with yes/no answer? E.g. is this string in the regular language? Is this list sorted? …

NP ZNP ZClass of decision problems recognized by non-deterministic Turing Machine in polynomial number of steps ZGuess solution, check in polynomial time ZE.g. is propositional formula  satisfiable? (SAT) ZGuess model (truth assignment) ZCheck if it satisfies formulae in polynomial time

NP ZProblems in NP ZMultiplication ZSorting Z.. ZSAT Z3-SAT ZNumber partitioning ZK-Colouring ZConstraint satisfaction Z…

NP-completeness ZSome problems are computationally as hard as any problem in NP ZIf we had a fast (polynomial) method to solve one of these, we could solve any problem in NP in polynomial time ZThese are the NP-complete problems ZSAT (Cook’s theorem: non-deterministic TM => SAT) Z3-SAT Z….

NP-completeness ZTo demonstrate a problem is NP- complete, there are two proof obligations: Zin NP ZNP-hard (it’s as hard as anything else in NP)

NP-completeness ZTo demonstrate a problem is NP- complete, there are two proof obligations: Zin NP ZPolynomial witness for a solution ZE.g. SAT, 3-SAT, number partitioning, k- Colouring, … ZNP-hard (it’s as hard as anything else in NP)

NP-completeness ZTo demonstrate a problem is NP- complete, there are two proof obligations: ZNP-hard (it’s as hard as anything else in NP) ZReduce some other NP-complete to it ZThat is, show how we can use our problem to solve some other NP-complete problem ZAt most, a polynomial change in size of problem

Global constraints are NP- hard ZCan solve 3SAT using a single global constraint! ZGiven 3SAT problem in N vars and M clauses Z3SAT([X1,…Xn]) where n=N+3M+2 ZConstraint holds iff X1=N, X2=M, ZX_2+i is 0/1 representing value assigned to xi ZX_2+N+3j, X_2+N+3j+1 and X_2+N+3j+2 represents jth clause

Our hammer ZUse tools of computational complexity to study global constraints

Questions to ask? ZGACSupport? is NP-complete ZDoes this value have support? ZBasic question asked within many propagators ZMaxGAC? is DP-complete ZAre these domains the maximal generalized arc-consistent domains? ZTermination test for a propagator ZDP = NP u coNP ZPropagation “harder” than solving the problem!

Questions to ask? ZIsItGAC? is NP-complete ZAre the domains GAC? ZWakeup test for a propagator ZNoGACWipeOut? is NP-complete ZIf we enforce GAC, do we not get a wipeout? ZUsed in many reductions ZGACDomain? is NP-hard ZReturn the maximal GAC domains ZWhat a propagator actually does!

Relationships between questions ZNoGACWipeOut = GACSupport = GACDomain ZNoGACWipeOut in P GACDomain in P ZNoGACWipeOut in NP GACDomain in NP ZGACDomain in P => MaxGAC in P => IsItGAC in P ZIsItGAC in NP => MaxGAC in NP => GACDomain in NP ZOpen if arrows cannot be reversed!

Constraints in practice ZSome constraints proposed in the past are intractable ZNValues(N,X1,..Xn) ZCardPath(N,[X1,..,Xn],C) Z…

NValues ZNValues(N,X1,..,Xm) ZN values used in X1,…,Xm ZUseful for resource allocation

NValues ZNValues(Y,X1,..,Xn) ZReduction of 3SAT to NValues Z3SAT problem in N vars, M clauses  Xi in {i,-i} for 1 ≤ i ≤ N  XN+s in {i,-j,k} if s-th clause is: (i or -j or k) Z Y= N ZHence 3SAT has a solution => NoGACWipeOut answers “yes”

NValues ZNValues(N,X1,..,Xm) ZReduction of 3SAT to NValues Z3SAT problem in n vars, l clauses  Xi in {i,-i} for 1 ≤ i ≤ n  Xn+s in {i,-j,k} if s-th clause is: (i or -j or k) ZN = n ZHence 3SAT has a solution NoGACWipeOut answers “yes” ZEnforce lesser level of local consistency (e.g. BC)

Generalizing constraints ZTake a tractable constraint ZGCC([X1,..,Xn],[l1,..,lm],[u1,..,um]) ZValue j occurs between lj and uj times in X1,..,Xn ZGeneralize some constants to variables ZE.g. GCC([X1,..,Xn],[O1,..,Om]) ZNP-hard to enforce GAC!

Generalizing constraints ZGCC([X1,..,Xn],[O1,..,Om]) ZReduction from 1in3SAT on positive clauses ZIf jth clause is (x or y or z) then Xj in {x,y,z} ZIf x occurs k times in all clauses then Ox in {0,k} ZHence 1in3SAT has a solution iff NoGACWipeOut answers “yes” ZThus enforcing GAC is NP-hard

Meta-constraints ZGlobal constraint used in sequencing problems ZCardPath(C,[X1,..Xn],N) iff C(Xi,..Xi+k) holds N times ZE.g. number of changes is CardPath(=/=,[X1,..Xn],N) ZFixed parameter tractable Zk fixed, GAC takes O(nd^k) time Zk = O(n), GAC is NP-hard even when C is polynomial to test

Meta-constraints ZCardPath(C,[X1,..Xn],N) iff C(Xi,..Xi+k) holds N times ZReduce 3SAT in N variables and M clauses to CardPath where k=N+2 ZNM vars Xi to represent repeated truth assignment ZM vars Yj to represent jth clause ZC(X1,..,XN,Yj,X1’) iff Yj=k and Xk=1 and X1=X1’ or Yj=-k and Xk=0 and X1=X1’ ZC(X2,..,XM.Yj,X1’,X2’) iff X2=X2’ Z..

Conclusions ZComputational complexity is a useful hammer to study global constraints ZUncovers fundamental limits of reasoning with global constraints ZLesser consistency needs to be enforced ZGeneralization intractable Z..

Global grammar constraints ZOften easy to specify a global constraint ZALLDIFFERENT([X1,..Xn]) iff Xi=/=Xj for i<j ZDifficult to build an efficient and effective propagator ZEspecially if we want global reasoning

Global grammar constraints ZPromising direction initiated is to specify constraints via automata/grammar ZSequence of variables = string in some formal language ZSatisfying assignment = string accepted by the grammar/automata Global constraints meets formal language theory

REGULAR constraint ZREGULAR(A,[X1,..Xn]) holds iff ZX1.. Xn is a string accepted by the deterministic finite automaton A ZProposed by Pesant at CP 2004 ZGAC algorithm using dynamic programming ZHowever, DP is not needed since simple ternary encoding is just as efficient and effective

REGULAR constraint ZDeterministic finite automaton (DFA) Z ZQ is finite set of states ZSigma is alphabet (from which strings formed) ZT is transition function: Q x Sigma -> Q Zq0 is starting state ZF subseteq Q are accepting states ZDFAs accept precisely regular languages ZRegular language can be specified by rules of the form: NonTerminal -> Terminal | Terminal NonTerminal

REGULAR constraint ZDFAs accept precisely regular languages ZRegular language can be specified by rules of the form: NonTerminal -> Terminal NonTerminal -> Terminal NonTerminal | NonTerminal Terminal -Alternatively given by regular expressions -More limited than BNF which can express context- free grammars

REGULAR constraint ZRegular language ZS -> 0 | 0A| AB | AC | 1B | 1 ZA -> 0 | 0A ZB -> 1 | 1B ZC -> 1 | 1C | 0 | 0A ZDFA ZQ={q0,q1,q2} ZSigma={0.1} ZT(q0,0)=q0. T(q0,1)=q1 ZT(q1,0)=q2, T(q1,1)=q1 ZT(q2,0)=q2 ZF={q0,q1,q2}

REGULAR constraint ZRegular language ZS -> 0 | 0A| AB | AC | 1B | 1 ZA -> 0 | 0A ZB -> 1 | 1B ZC -> 1 | 1C | 0 | 0A ZDFA ZQ={q0,q1,q2} ZSigma={0.1} ZT(q0,0)=q0. T(q0,1)=q1 ZT(q1,0)=q2, T(q1,1)=q1 ZT(q2,0)=q2 ZF={q0,q1,q2} CONTIGUITY constraint

REGULAR constraint ZMany global constraints are instances of REGULAR ZAMONG, CONTIGUITY, LEX, PRECEDENCE, STRETCH,.. ZDomain consistency can be enforced in O(ndQ) time using dynamic programming ZContiguity example: {0,1}, {0}, {1}, {0,1}, {1}

REGULAR constraint ZREGULAR constraint can be encoded into ternary constraints ZIntroduce Qi+1 Zstate of the DFA after the ith transition ZThen post sequence of constraints ZC(Xi,Qi,Qi+1) iff DFA goes from state Qi to Qi+1 on symbol Xi

REGULAR constraint ZREGULAR constraint can be encoded into ternary constraints ZConstraint graph is Berge-acyclic ZConstraints only overlap on one variable ZEnforcing GAC on ternary constraints achieves GAC on REGULAR in O(ndQ) time

REGULAR constraint ZPRECEDENCE([X1,..Xn]) iff Zmin({i | Xi=j or i=n+1}) < min({i | Xi=k or i=n+2}) for all j<k ZStates of DFA represents largest value so far used ZT(Si,vj)=Si if j<=i ZT(Si,vj)=Sj if j=i+1 ZT(Si,vj)=fail if j>i+1 ZT(fail,v)=fail

REGULAR constraint ZPRECEDENCE([X1,..Xn]) iff Zmin({i | Xi=j or i=n+1}) < min({i | Xi=k or i=n+2}) for all j<k ZStates of DFA represents largest value so far used ZT(Si,vj)=Si if j<=i ZT(Si,vj)=Sj if j=i+1 ZT(Si,vj)=fail if j>i+1 ZT(fail,v)=fail ZREGULAR encoding of this is just these transition constraints (can ignore fail)

REGULAR constraint ZSTRETCH([X1,..Xn]) holds iff ZAny stretch of consecutive values is between shortest(v) and longest(v) length ZAny change (v1,v2) is in some permitted set, P ZFor example, you can only have 3 consecutive night shifts and a night shift must be followed by a day off

REGULAR constraint ZSTRETCH([X1,..Xn]) holds iff ZAny stretch of consecutive values is between shortest(v) and longest(v) length ZAny change (v1,v2) is in some permitted set, P ZDFA ZQi is ZQ0= ZT(,a)= if q+1<=longest(a) ZT(,b)= if (a,b) in P and q>=shortest(a) ZAll states are accepting

Other generalizations of REGULAR ZREGULAR FIX(A,[X1,..Xn],[B1,..Bm]) iff ZREGULAR(A,[X1,..Xn]) and Bi=1 iff exists j. Xj=I ZCertain values must occur within the sequence ZFor example, there must be a maintenance shift ZUnfortunately NP-hard to enforce GAC on this

Other generalizations of REGULAR ZREGULAR FIX(A,[X1,..Xn],[B1,..Bm]) ZSimple reduction from Hamiltonian path ZAutomaton A accepts any walk on a graph Zn=m and Bi=1 for all i

Chomsky hierarchy ZRegular languages ZContext-free languages ZContext-sensitive languages Z..

Chomsky hierarchy ZRegular languages ZGAC propagator in O(ndQ) time ZConext-free languages ZGAC propagator in O(n^3) time and O(n^2) space ZAsymptotically the same as parsing! ZConext-sensitive languages ZChecking if a string is in the language PSPACE-complete ZUndecidable to know if empty string in grammar and thus to detect domain wipeout and enforce GAC!

Context-free grammars ZApplications ZHierarchy configuration ZBioinformatics ZNatual language parsing ZRostering Z… ZCFG(G,[X1,…Xn]) holds iff ZX1.. Xn is a string accepted by the context free grammar G

CFG propagator ZAdapt CYK parser ZWorks on Chomsky normal form ZNon-terminal -> Terminal ZNon-terminal -> Non-terminal Non- terminal ZUsing dynamic programming ZComputes V[i,j], set of possible parsings for the ith to the jth symbols

Conclusions ZGlobal grammar constraints ZSpecify wide range of global constraints ZProvide efficient and effective propagators automatically ZNice marriage of formal language theory and constraint programming!