
Correctness Considerations in CLP(FD) Systems Dissertation submitted in partial fulfillment of the requirements for the degree of Doktor der technischen Wissenschaften by Markus Triska Registration number 0225855 to the Faculty of Informatics at the Vienna University of Technology Advisor: Priv.-Doz. Dr. Nysret Musliu This dissertation has been reviewed by: Dr. Nysret Musliu Jan Wielemaker, Ph.D. Vienna, December 3rd 2013 To Ludwig Moser, whose commitment to elegance guided me. ii How infinitely good that Providence is, which has provided, in its govern- ment of mankind, such narrow bounds to his sight and knowledge of things; and though he walks in the midst of so many thousand dangers, the sight of which, if discovered to him, would distract his mind and sink his spirits, he is kept serene and calm, by having the events of things hid from his eyes, and knowing nothing of the dangers which surround him. Daniel Defoe, The Life and Adventures of Robinson Crusoe iii Abstract Constraint logic programming (CLP) is a declarative formalism for describ- ing conditions a solution must satisfy. Constraint logic programming over finite domains, denoted as CLP(FD), considers problems involving integers, including combinatorial problems such as planning, scheduling and alloca- tion tasks. Given a problem description, a constraint solver tries to find valid solutions via constraint propagation and search. Constraint solvers are complex programs, and many existing and widely used CLP(FD) systems suffer from limitations and mistakes that can cause them to miss valid solutions or give wrong answers. In this thesis, we show examples of common limitations and mistakes of several widely used CLP(FD) systems. We then present a new CLP(FD) system that overcomes some of these issues. Our system has several unique features such as monotonicity, reasoning over arbitrarily large integers and always terminating propagation. This yields new application opportunities for constraint solvers which we also present. We develop new domain-specific languages that let us concisely and declaratively express parts of our system whose encoding would otherwise be difficult and error prone, such as parsing, propagator selection and constraint reification. We present two methods for testing our solver: systematic test cases, and automated analysis of individual propagators. Our contributions are applicable to other constraint systems as well and may improve their correctness. iv Zusammenfassung Constraint Logic Programming (CLP) ist ein deklarativer Formulismus zur Beschreibung von Bedingungen, die von gesuchten L¨osungen erf¨ullt werden m¨ussen. Constraint Logic Programming ¨uber endlichen Wertebereichen, abgek¨urzt als CLP(FD), befasst sich mit Problemstellungen mit ganzen Zahlen und umfasst kombinatorische Probleme wie Planung, Scheduling und Allokationsaufgaben. Ein Constraint Solver sucht unter Anwendung von Constraint Propagierung nach L¨osungen, welche die angegebenen Be- dingungen erf¨ullen. Constraint Solver sind komplexe Programme, und viele existierende und in vielen Bereichen eingesetzte CLP(FD) Systeme weisen Einschr¨ankungen und Fehler auf, durch die sie g¨ultige L¨osungen nicht finden oder falsche Antworten geben. In dieser Dissertation zeigen wir Beispiele f¨ur typische Einschr¨ankungen und Fehler von weit verbreiteten CLP(FD) Systemen. Anschließend pr¨asen- tieren wir ein neues CLP(FD) System, das einige dieser Einschr¨ankungen aufhebt. Mehrere Eigenschaften wie Monotonie, Schließenuber ¨ beliebig großen ganzen Zahlen und immer terminierende Propagierung werden von unserem System erstmals garantiert. Dadurch entstehen neue Anwendungs- m¨oglichkeiten f¨ur Constraint Solver, die wir ebenfalls beschreiben. Wir entwickeln neue dom¨anenspezifische Sprachen, mit denen wir kompakt und deklarativ Teile unseres Systems ausdr¨ucken k¨onnen, die sonst schwierig und fehleranf¨allig w¨aren, wie Parsen, Propagator-Auswahl und Reifikation von Constraints. Wir pr¨asentieren zwei Methoden, mit denen wir unseren Con- straint Solver testen: systematische Testf¨alle, und automatisierte Analyse einzelner Propagatoren. Unsere Beitr¨age sind auch auf andere Constraint Systeme anwendbar und k¨onnen ihre Korrektheit verbessern. v Acknowledgements First and foremost, I thank my advisor Nysret Musliu for supervising this thesis. His interest in combinatorial problems motivated me to finally im- plement the CLP(FD) system that is the main subject of this thesis. Further, I thank Ulrich Neumerkel for introducing me to constraint logic programming, and drawing my attention to PostScript. My gratitude also goes to Mats Carlsson, whose exceptionally elegant CLP(FD) formulation of the so-called “social golfer problem” was my main motivation for imple- menting several important global constraints. Jan Wielemaker provides a robust, feature-rich and free Prolog system, which I used extensively. Tom Schrijvers generously contributed several libraries to SWI-Prolog, from which I learned a lot. Thank you! I thank all my colleagues in the Austrian Federal Ministry of Finance for making each working day so enjoyable. I thank all users of my constraint solver for their feedback and encouragement. I thank my friends for their support. Last, not least, I thank my parents and family for making it all possible in the first place. vi CONTENTS Contents Dedication ii Epigraph iii Abstract iv Zusammenfassung v Acknowledgements vi 1 Introduction 4 1.1 Goalsofthisthesis ........................ 6 1.2 Mainresultsofthisthesis . 6 1.3 Publications............................ 7 2 Constraint Programming and CLP(FD) 8 2.1 Introduction............................ 8 2.2 CLP(FD) ............................. 8 2.3 Example:Sudoku......................... 9 2.4 Consistency ............................ 10 2.5 Constraint propagation and search . 11 2.6 Selection strategies for variables and values . 13 2.7 Visualising the constraint solving process . 15 3 Current CLP(FD) systems and their properties 19 3.1 Terminology............................ 19 3.2 Kindsofmistakes......................... 19 3.3 GNUProlog............................ 20 3.3.1 Toplevel interaction . 21 3.3.2 Indexicals ......................... 22 3.3.3 Application: Constructing 2-(16,4,2) designs . 24 3.4 SICStusProlog .......................... 28 3.4.1 Symbolic infinities as domain boundaries . 28 3.4.2 Termination properties . 29 3.4.3 Semantic inconsistencies . 29 3.5 ECLiPSe ............................. 31 3.6 Gecode .............................. 31 3.6.1 Guarantee of mistakes . 32 3.6.2 History of corrections . 32 3.7 Summaryofproperties. 33 1 CONTENTS 4 A new CLP(FD) system 34 4.1 Introduction............................ 34 4.2 Defaulty representations and monotonicity . 34 4.3 AmonotonicCLP(FD)system . 37 4.4 Systemarchitecture . 39 4.5 Reasoning over arbitrarily large integers . 42 4.5.1 Large integers in conventional CLP(FD) tasks . 42 4.5.2 Uniform integer arithmetic . 43 4.6 Ensuring terminating propagation . 45 4.7 Sourcecodeorganisation. 46 4.8 Domain-specific languages . 46 4.9 Compactified arithmetic . 47 4.10Domains.............................. 52 4.10.1 Domain representation . 52 4.10.2 Domain properties . 54 4.10.3 Relations between domains . 54 4.11 Arithmetic constraints . 57 4.11.1 Parsing arithmetic expressions . 58 4.11.2 Selecting propagators for constraints . 60 4.11.3 Limitations of indexicals . 63 4.11.4 Important internal predicates . 64 4.11.5 Addition.......................... 65 4.11.6 Multiplication . 67 4.12Reification............................. 71 4.13 Global constraints . 76 4.13.1 cumulative/2 ...................... 77 4.13.2 all distinct/1 ..................... 79 4.13.3 Tarjan’s strongly connected components algorithm . 81 4.14 Properties of labeling/2 .................... 83 4.14.1 labeling/2 always terminates . 83 4.14.2 labeling/2 is always complete . 84 4.15 Performance............................ 85 5 Testing a CLP(FD) system 86 5.1 Introduction............................ 86 5.2 Properties of logical variables . 86 5.3 Systematic test cases for a CLP(FD) system . 87 5.4 Advantages of black-box testing . 89 5.5 Limitations of black-box testing . 89 5.6 Automated analysis of individual propagators . 91 2 CONTENTS 6 Application: Rotating workforce scheduling 97 6.1 Introduction............................ 98 6.2 Relatedwork ........................... 98 6.3 The rotating workforce scheduling problem . 99 6.4 A new system for rotating workforce scheduling . 101 6.5 A CLP(FD) model for rotating workforce scheduling . 102 6.6 The automaton/3 constraint . .. .. .. .. .. 103 6.7 Visualisingthesearch . 103 6.8 Labeling and allocation strategies . 104 6.9 Comparison with the commercial system FCS . 105 7 Conclusion and future work 107 8 Bibliography 110 9 About the author 114 Index 115 3 1 Introduction Constraint logic programming (CLP) is a declarative formalism for describ- ing conditions a solution must satisfy. Constraint logic programming over finite domains, denoted as CLP(FD), considers problems involving integers, including combinatorial problems such as planning, scheduling and alloca- tion tasks. Given a problem description, a constraint solver tries to find valid solutions via constraint propagation and search. Constraint solvers are complex programs, and many existing and widely used CLP(FD) systems suffer from limitations and mistakes that can cause them to miss valid solutions or give wrong answers. One frequent source of erroneous answers in common constraint systems are their – either implicit or explicit
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages122 Page
-
File Size-