## The Computational Power and Complexity of Constraint Handling Rules (2005)

### Cached

### Download Links

- [www.cs.kuleuven.ac.be]
- [people.cs.kuleuven.be]
- [people.cs.kuleuven.be]
- [www.cs.kuleuven.be]
- [www.cs.kuleuven.be]
- [people.cs.kuleuven.be]
- [people.cs.kuleuven.be]
- [www.cs.kuleuven.ac.be]
- [people.cs.kuleuven.be]
- [www.cs.kuleuven.be]
- [people.cs.kuleuven.be]
- [dtai.cs.kuleuven.be]
- DBLP

### Other Repositories/Bibliography

Venue: | In Second Workshop on Constraint Handling Rules, at ICLP05 |

Citations: | 50 - 21 self |

### BibTeX

@INPROCEEDINGS{Sneyers05thecomputational,

author = {Jon Sneyers and Tom Schrijvers and Bart Demoen},

title = {The Computational Power and Complexity of Constraint Handling Rules},

booktitle = {In Second Workshop on Constraint Handling Rules, at ICLP05},

year = {2005},

pages = {3--17}

}

### OpenURL

### Abstract

Constraint Handling Rules (CHR) is a high-level rule-based programming language which is increasingly used for general purposes. We introduce the CHR machine, a model of computation based on the operational semantics of CHR. Its computational power and time complexity properties are compared to those of the well-understood Turing machine and Random Access Memory machine. This allows us to prove the interesting result that every algorithm can be implemented in CHR with the best known time and space complexity. We also investigate the practical relevance of this result and the constant factors involved. Finally we expand the scope of the discussion to other (declarative) programming languages.

### Citations

3837 |
Introduction to Automata Theory, Languages and Computation
- Hopcroft
- 1979
(Show Context)
Citation Context ...gle-tape formulation of the Turing machine (TM). Multitape Turing machines can be simulated on single-tape Turing machines with a quadratic complexity penalty [8]. The definition below corresponds to =-=[11]-=-.sDefinition 1 (Turing Machine). A Turing machine is defined as a 6-tuple M = 〈Q, Σ, s0, b, F, δ〉 where – Q is a finite set of states – Σ is a finite set of symbols, the tape alphabet – s0 ∈ Q is the ... |

2438 |
The design and analysis of computer algorithms
- Aho, Hopcroft, et al.
- 1974
(Show Context)
Citation Context ...tic RAM machine (or standard RAM) consists of a program and a working memory as described above. The program instruction set is given in Table 1. This instruction set is similar to the one defined in =-=[3]-=-, and resembles more closely actual computers. The inc, dec, and clr instructions are redundant: they can be implemented using add, sub, and const. Time complexity. Every fetch-and-execute cycle in th... |

1436 | A note on two problems in connexion with graphs - Dijkstra - 1959 |

1157 | M.: On computable numbers, with an application to the Entscheidungsproblem - Turing - 1936 |

586 | L.: Rete: A fast algorithm for the many pattern/many object pattern match problem - Forgy - 1982 |

575 | Fibonacci heaps and their uses in improved network optimization algorithms - Fredman, Tarjan - 1984 |

396 | Theory and practice of constraint handling rules
- Frühwirth
- 1998
(Show Context)
Citation Context ...andom Access Memory machine. Our major result is the proof that every algorithm can be implemented in CHR with the best known time and space complexity. 1 Introduction Constraint Handling Rules (CHR) =-=[5]-=- is a high-level programming language extension based on multi-headed committed-choice rules. Originally designed for writing constraint solvers, it is increasingly used for general purposes. After a ... |

342 |
Programming with Constraints: An Introduction, The Massachusetts Institute of technology
- Marriott, Stuckey
- 1998
(Show Context)
Citation Context ... operational semantics may skip to subsection 2.3, in which some new terminology is introduced. 2.1 Syntax We assume the reader to be familiar with some basic notions of Constraint Logic Programming [=-=Marriott and Stuckey 1998-=-; Frühwirth and Abdennadher 2003]. CHR is embedded in a host language H that provides data types and a number of predefined constraints. These constraints are called host language constraints or built... |

191 | The execution algorithm of Mercury: An efficient purely declarative logic programming language
- Somogyi, Henderson, et al.
- 1996
(Show Context)
Citation Context ... O(log n) worst-case time. Figure 13 lists a Prolog program which uses association lists to implement a RAM simulator. We used the same version of hProlog as the one we used for testing CHR. Mercury [=-=Somogyi et al. 1996-=-] is a strongly-typed high-performance logic programming language. The Mercury system includes the array module, but the procedures in this module are written in the target languages (C, C#, and Java)... |

190 |
On the computational complexity of algorithms
- Hartmanis, Stearns
- 1965
(Show Context)
Citation Context .... 2.1 Turing machines We will use the single-tape formulation of the Turing machine (TM). Multitape Turing machines can be simulated on single-tape Turing machines with a quadratic complexity penalty =-=[8]-=-. The definition below corresponds to [11].sDefinition 1 (Turing Machine). A Turing machine is defined as a 6-tuple M = 〈Q, Σ, s0, b, F, δ〉 where – Q is a finite set of states – Σ is a finite set of s... |

189 | Constraint Handling Rules
- Frühwirth
- 2009
(Show Context)
Citation Context ...n this section we introduce the syntax (subsection 2.1) and semantics (subsection 2.2) of Constraint Handling Rules. Gentler introductions to CHR can be found in [Frühwirth 1998], [Schrijvers 2005], [=-=Frühwirth 2008-=-], and [Sneyers et al. 2008]. Readers that are already familiar with CHR and its theoretical operational semantics may skip to subsection 2.3, in which some new terminology is introduced. 2.1 Syntax W... |

176 |
Patricia - practical algorithm to retrieve information coded in alphanumeric
- Morrison
- 1968
(Show Context)
Citation Context ... implemented in Haskell itself. The fastest pure Haskell implementation of arrays we could find is available in the standard Data.IntMap module, which is based on an implementation of Patricia trees [=-=Morrison 1968-=-] by Okasaki and Gill [1998]. This data structure allows memory cell look-ups, updates, and insertion (initialization) in O(min(n, W )) time, where W is the number of bits in an Int. On our test platf... |

171 | Maude: specification and programming in rewriting logic
- Clavel, Duran, et al.
(Show Context)
Citation Context ...y, each function application fe is transformed into let x = e in x ‘seq‘ f x, which forces the subexpression e to WHNF before evaluating the main expression f e. 7.2.3 Term-rewrite systems. Maude 11 [=-=Clavel et al. 2002-=-] is a system for declarative programming in rewriting logic. It features efficient rewriting of terms with associative-commutative (AC) operators using the stripper-collector matching algorithm of Ek... |

142 | Shortest path algorithms: Theory and experimental evaluation - Cherkassky, Goldberg, et al. - 1996 |

109 | Leeuwen. Worst-case analysis of set union algorithms - Tarjan, van |

91 | Operational Semantics and Confluence of Constraint Propagation Rules
- Abdennadher
- 1997
(Show Context)
Citation Context ... standard operational semantics of CHR, sometimes also called abstract or high-level operational semantics. Several versions of the operational semantics have already appeared in the literature, e.g. =-=[1, 5]-=-. We adopt the version of [4], which is equivalent to the previous ones, but closer in formulation to the refined semantics, used in most implementations. The operational semantics is formulated as a ... |

80 |
Models of Computation
- Savage
- 1998
(Show Context)
Citation Context ...RAM machine consists of a program and a working memory as described above. The program instructions are inc, dec, clr, jump, cjump, and halt (see Table 1).sThis corresponds to the definition given in =-=[12]-=-. All copying, addition and subtraction has to be done by repeated use of the inc and dec instructions. This makes the Peano-arithmetic RAM less realistic, as actual computers do provide instructions ... |

76 | PATRICIA-Practical algorithm to retrieve information coded in alphanumeric - Morrison - 1968 |

69 | Expert Systems - GIARRATANO, G - 1989 |

64 |
in Action: Java Rule-based Systems
- Jess
- 2003
(Show Context)
Citation Context ...t matching algorithm. By making the data structure operations more explicit (using the Map{Int,Int} module) we obtain a more efficient program. It is listed in Figure 16. 7.2.4 Rule engines. Jess 12 [=-=Friedman-Hill 2003-=-] is considered to be one of the fastest rule engines. Like its ancestor CLIPS [Giarratano and Riley 1994], it uses the RETE algorithm of Forgy [1982]. Figure 17 lists the Jess program we have tested ... |

56 | The K.U.Leuven CHR system: Implementation and application
- Schrijvers, Demoen
- 2004
(Show Context)
Citation Context ...T ), not counting memory initialization. 5 Simulating CHR on RAM machines For the simulation of CHR on RAM machines we can refer to the available CHR implementations in various host languages: Prolog =-=[13, 9]-=-, HAL [10], Haskell [16]sand Java [2, 17]. As all these host languages can be simulated on RAM machines, the simulation of CHR on RAM machines follows. Theorem 4. Both CHR machines are Turing-complete... |

53 | A theory of overloading
- Stuckey, Sulzmann
(Show Context)
Citation Context ...itialization. 5 Simulating CHR on RAM machines For the simulation of CHR on RAM machines we can refer to the available CHR implementations in various host languages: Prolog [13, 9], HAL [10], Haskell =-=[16]-=-sand Java [2, 17]. As all these host languages can be simulated on RAM machines, the simulation of CHR on RAM machines follows. Theorem 4. Both CHR machines are Turing-complete. Proof. Because of Lemm... |

48 | The refined operational semantics of Constraint Handling Rules - Duck, Stuckey, et al. - 2004 |

47 | A history of haskell: being lazy with class
- Hudak, Hughes, et al.
- 2007
(Show Context)
Citation Context ...+ g + s) log n) time and O(n) space. We have not tested this experimentally since CTGC is not yet available in the main release of the Mercury system. 7.2.2 Functional programming languages. Haskell [=-=Hudak et al. 2007-=-] is a modern typed, lazy, purely functional language. Most Haskell systems include the Data.Array module in their standard libraries. This module efficiently implements arrays, but it is not implemen... |

46 | Analyses, optimizations and extensions of Constraint Handling Rules - Schrijvers - 2005 |

41 | Optimizing compilation of Constraint Handling Rules
- Holzbaur, Banda, et al.
- 2005
(Show Context)
Citation Context ... the K.U.Leuven CHR system 4 . It was developed by Schrijvers and Demoen [2004], building on the system developed by Holzbaur and Frühwirth [1999]. For more detail on optimizing CHR compilation, see [=-=Holzbaur et al. 2005-=-; Schrijvers 2005; Duck 2005; Sneyers et al. 2008]. First we give an overview of some notions of optimizing compilation that are crucial for time and space efficiency. Given the refined operational se... |

37 |
María García de la
- Duck, Stuckey
- 2004
(Show Context)
Citation Context ...of CHR, sometimes also called abstract or high-level operational semantics. Several versions of the operational semantics have already appeared in the literature, e.g. [1, 5]. We adopt the version of =-=[4]-=-, which is equivalent to the previous ones, but closer in formulation to the refined semantics, used in most implementations. The operational semantics is formulated as a state transition system. Exec... |

34 | Optimal union-find in Constraint Handling Rules. Theory and Practice of Logic Programming
- Schrijvers, Frühwirth
- 2006
(Show Context)
Citation Context ...ngly used for general purposes. After a new programming language is introduced, sooner or later the question arises whether classical algorithms can be implemented in an efficient and elegant way. In =-=[15]-=- this question is partially answered for CHR by describing a CHR implementation of the union-find algorithm. Thanks to some compiler optimizations, most notably hash-table constraint stores, the best ... |

31 |
On the performance of lazy matching in production systems
- Miranker, Brant, et al.
- 1990
(Show Context)
Citation Context ...CHR programmers do not have to worry about the order of the heads in multi-headed rules. In general, the eager matching RETE algorithm is asymptotically slower than the lazy matching LEAPS algorithm [=-=Miranker et al. 1990-=-] on which the CHR execution mechanism is based. In the specific case of the RAM machine simulator program of Figure 17, this disadvantage of RETE does not emerge. 7.3 Experimental results Table V lis... |

30 | A new metacomplexity theorem for bottom-up logic programs
- Ganzinger, McAllester
- 2001
(Show Context)
Citation Context ...ably hash-table constraint stores, the best known time complexity was obtained. In contrast, it is not clear whether the union-find algorithm can be implemented with optimal complexity in pure Prolog =-=[7]-=-. The major result of this paper is an affirmative answer to the first part of the above question: is it possible, in general, to implement algorithms in CHR in an efficient way? i.e. with the best kn... |

29 |
An algorithm for the organization of information. Doklady Akademii Nauk SSSR, 146:263–266, (Russian). English translation by Myron
- Adelson-Velskii, Landis
- 1962
(Show Context)
Citation Context ..., can be used instead. The implementation of assoc that is used in hProlog is based on an implementation by Mats Carlsson (which was based on an implementation by Richard O’Keefe) based on AVL-trees [=-=Adelson-Velsky and Landis 1962-=-]. Lookup, insertion and update take O(log n) worst-case time. Figure 13 lists a Prolog program which uses association lists to implement a RAM simulator. We used the same version of hProlog as the on... |

28 | Machine models and simulations - Boas, P - 1990 |

27 | Logical algorithms - Ganzinger, McAllester - 2002 |

26 |
Adaptive constraint handling with CHR in Java,” in Princ. and Pract. of Constraint Programming (CP 2001), ser
- Wolf
- 2001
(Show Context)
Citation Context ...5 Simulating CHR on RAM machines For the simulation of CHR on RAM machines we can refer to the available CHR implementations in various host languages: Prolog [13, 9], HAL [10], Haskell [16]sand Java =-=[2, 17]-=-. As all these host languages can be simulated on RAM machines, the simulation of CHR on RAM machines follows. Theorem 4. Both CHR machines are Turing-complete. Proof. Because of Lemma 2, every Turing... |

25 | T.: Compiling constraint handling rules into Prolog with attributed variables
- Holzbaur, Frühwirth
- 1999
(Show Context)
Citation Context ...T ), not counting memory initialization. 5 Simulating CHR on RAM machines For the simulation of CHR on RAM machines we can refer to the available CHR implementations in various host languages: Prolog =-=[13, 9]-=-, HAL [10], Haskell [16]sand Java [2, 17]. As all these host languages can be simulated on RAM machines, the simulation of CHR on RAM machines follows. Theorem 4. Both CHR machines are Turing-complete... |

23 |
Compilation of Constraint Handling Rules
- Duck
- 2005
(Show Context)
Citation Context ...eveloped by Schrijvers and Demoen [2004], building on the system developed by Holzbaur and Frühwirth [1999]. For more detail on optimizing CHR compilation, see [Holzbaur et al. 2005; Schrijvers 2005; =-=Duck 2005-=-; Sneyers et al. 2008]. First we give an overview of some notions of optimizing compilation that are crucial for time and space efficiency. Given the refined operational semantics, the join ordering s... |

23 | Fast mergeable integer maps - Okasaki, Gill - 1998 |

19 | K.U.Leuven JCHR: a user-friendly, flexible and efficient CHR system for Java - Weert, Schrijvers, et al. - 2005 |

18 | Dijkstra’s algorithm with Fibonacci heaps:An executable description - Sneyers, Schrijvers, et al. |

17 | Introducing simplification rules
- Frühwirth
- 1991
(Show Context)
Citation Context ...gation rule. At least one of Hr and Hk must be non-empty. Example. Figure 2 lists a simple CHR(Prolog) program called PRIMES, a CHR variant of the Sieve of Eratosthenes. Dating back to at least 1992 [=-=Frühwirth 1992-=-], this is one of the very first examples where CHR is used as a generalpurpose programming language. Given a query of the form “upto(n)”, where n is a positive integer, it computes all prime numbers ... |

15 | Observable confluence for constraint handling rules
- Duck, Stuckey, et al.
- 2007
(Show Context)
Citation Context ...tarting from a given input have the same result and all successful ones have the same length. Note that if a program P is ∆H ωt (P)-deterministic for all input GH P , it is also observable confluent [=-=Duck et al. 2006-=-]. The notion of observable confluence does not require derivations to have the same length. Example. Consider the CHR program of the previous example. This program (PRIMES, listed in Figure 2) is ∆Pr... |

14 |
A Java Constraint Kit
- JACK
- 2001
(Show Context)
Citation Context ...5 Simulating CHR on RAM machines For the simulation of CHR on RAM machines we can refer to the available CHR implementations in various host languages: Prolog [13, 9], HAL [10], Haskell [16]sand Java =-=[2, 17]-=-. As all these host languages can be simulated on RAM machines, the simulation of CHR on RAM machines follows. Theorem 4. Both CHR machines are Turing-complete. Proof. Because of Lemma 2, every Turing... |

14 | Automatic implication checking for CHR constraints
- Schrijvers, Demoen, et al.
- 2006
(Show Context)
Citation Context ...T 8 ). 2.3 CHR machines We assume the reader to be familiar with CHR. See [5] for an overview of the Constraint Handling Rules (CHR) language. We say a CHR program is CHRonly (this term was coined in =-=[14]-=-) if its rules do not contain any host-language 1 Actually, a tighter bounds of O ` (T log T log log T ) 2 ´ may be shown, as mentioned in a footnote on page 26 of [3].sbuilt-ins in the body, and cont... |

14 | As time goes by ii: More automatic complexity analysis of concurrent rule programs - Frühwirth |

12 |
García de la
- Holzbaur, Stuckey, et al.
- 2001
(Show Context)
Citation Context ...ting memory initialization. 5 Simulating CHR on RAM machines For the simulation of CHR on RAM machines we can refer to the available CHR implementations in various host languages: Prolog [13, 9], HAL =-=[10]-=-, Haskell [16]sand Java [2, 17]. As all these host languages can be simulated on RAM machines, the simulation of CHR on RAM machines follows. Theorem 4. Both CHR machines are Turing-complete. Proof. B... |

12 | As time goes by: Constraint handling rules – a survey of - Sneyers, Weert, et al. |

12 | Extending CHR with negation as absence - Weert, Sneyers, et al. |

9 | Associative-Commutative Rewriting on Large Terms - Eker - 2003 |

8 | Accurate functional dependency analysis for Constraint Handling Rules
- Duck, Schrijvers
(Show Context)
Citation Context ...constraint has a set semantics functional dependency on certain key arguments if there are no two instances of the constraint with the same key arguments. We omit the formal definition, referring to [=-=Duck and Schrijvers 2005-=-]. Functional dependencies can be enforced using simpagation rules. For example, to make sure 4 The K.U.Leuven CHR website: http://www.cs.kuleuven.be/∼toms/CHR/ ACM Transactions on Programming Languag... |

8 | Compile-time garbage collection for the declarative language Mercury - Mazur |