Conference PaperPDF Available

Transactions in Constraint Handling Rules

Authors:

Abstract

CHR is a highly concurrent language, and yet it is by no means a trivial task to write correct concurrent CHR programs. We propose a new semantics for CHR, which allows specifying and reasoning about transactions. Transactions alleviate the complexity of writing concurrent programs by offering entire derivations to run atomically and in isolation. We derive several program transformations based on our semantics that transform particular classes of transitional CHR programs to non-transactional ones. These transformations are useful because they obviate a general purpose transaction manager, and may lift unnecessary sequentialization present in the transactional semantics.
A preview of the PDF is not available
... The paper [SS08] proposes CHRt as a conservative extension of CHR with atomic transactions. An atomic transaction is denoted as a meta-constraint atomic(C) where C is a conjunction of CHR constraints. ...
Article
Constraint Handling Rules is an effective concurrent declarative programming language and a versatile computational logic formalism. CHR programs consist of guarded reactive rules that transform multisets of constraints. One of the main features of CHR is its inherent concurrency. Intuitively, rules can be applied to parts of a multiset in parallel. In this comprehensive survey, we give an overview of concurrent and parallel as well as distributed CHR semantics, standard and more exotic, that have been proposed over the years at various levels of refinement. These semantics range from the abstract to the concrete. They are related by formal soundness results. Their correctness is established as correspondence between parallel and sequential computations. We present common concise sample CHR programs that have been widely used in experiments and benchmarks. We review parallel CHR implementations in software and hardware. The experimental results obtained show a consistent parallel speedup. Most implementations are available online. The CHR formalism can also be used to implement and reason with models for concurrency. To this end, the Software Transaction Model, the Actor Model, Colored Petri Nets and the Join-Calculus have been faithfully encoded in CHR.
... Alternative and more refined semantics for parallel CHR are e.g. [86,114,87,104,63]. ...
Article
Constraint Handling Rules (CHR) is both an effective concurrent declarative constraint-based programming language and a versatile computational formalism. While conceptually simple, CHR is distinguished by a remarkable combination of desirable features: - semantic foundation in classical and linear logic, - effective and efficient sequential and parallel execution model - guaranteed properties like the anytime online algorithm properties - powerful analysis methods for deciding essential program properties. This overview of CHR research and applications is by no complete. It concentrates on the years since 2000. Up-to-date information on CHR can be found at the CHR web-site www.constraint-handling-rules.org, including the slides of the keynote talk associated with this article, an extensive bibliography, online demo versions and free downloads of the language.
... The second commit fails and is rolled back, i.e. the rule application is hindered. A related approach is given in [9], in which an atomic operational semantics for CHR is given. ...
Article
Parallel multiset rewriting is usually restricted to be free of overlaps, such that multiple rule applications cannot remove the same object. In this work, we present a parallel execution strategy for Constraint Handling Rules that allows multiple removals of constraints, for which different multiplicities have no effect on results. We show that the resulting operational semantics is sound with respect to sequential execution and discuss exemplary applications. 1
... Consider the following program P , similar to that one given in (Schrijvers and Sulzmann 2008), which describes the rules for updating a bank account and for performing the money transfer. We write the program by using the standard syntax, namely without using the local token store and the identifiers in the body of rules, since there are no annotated propagation rules. ...
Article
Full-text available
Program transformation is an appealing technique which allows to improve run-time efficiency, space-consumption, and more generally to optimize a given program. Essentially, it consists of a sequence of syntactic program manipulations which preserves some kind of semantic equivalence. Unfolding is one of the basic operations which is used by most program transformation systems and which consists in the replacement of a procedure call by its definition. While there is a large body of literature on transformation and unfolding of sequential programs, very few papers have addressed this issue for concurrent languages. This paper defines an unfolding system for CHR programs. We define an unfolding rule, show its correctness and discuss some conditions which can be used to delete an unfolded rule while preserving the program meaning. We also prove that, under some suitable conditions, confluence and termination are preserved by the above transformation. To appear in Theory and Practice of Logic Programming (TPLP)
Conference Paper
We address the problem of making syntactic sense of text for which the grammar has only partial information. Our proposed methodology is to adapt a recent formalism, Womb Grammars, into parsing creative text that departs from the grammar at hand, or which cannot rely on a complete grammar being available. We argue that unspecified information can be detected with appropriate ontologies together with our adaptation of a recently introduced constraint-based methodology for acquiring linguistic information on a given language from that of another. Our implementation tool is CHRG (Constraint Handling Rule Grammars). We examine as well possible extensions to multilingual text parsing. Our proposed methodology exploits the descriptive power of constraints both for defining sentence acceptability and for inferring lexical knowledge from a word’s sentential context, even when foreign.
Conference Paper
Constraint Handling Rules (CHR) is both an effective concurrent declarative constraint-based programming language and a versatile computational formalism. While conceptually simple, CHR is distinguished by a remarkable combination of desirable features: a semantic foundation in classical and linear logic, an effective and efficient sequential and parallel execution model guaranteed properties like the anytime online algorithm properties powerful analysis methods for deciding essential program properties. This overview of some CHR-related research and applications is by no means meant to be complete. Essential introductory reading for CHR provide the survey article [122] and the books [55, 62]. Up-to-date information on CHR can be found online at the CHR web-page www. constraint-handling-rules. org, including the slides of the keynote talk associated with this article. In addition, the CHR website dtai. cs. kuleuven. be/ CHR/ offers everything you want to know about CHR, including online demo versions and free downloads of the language.
Article
Full-text available
(To appear in Theory and Practice of Logic Programming (TPLP)) We introduce a systematic, concurrent execution scheme for Constraint Handling Rules (CHR) based on a previously proposed sequential goal-based CHR semantics. We establish strong correspondence results to the abstract CHR semantics, thus guaranteeing that any answer in the concurrent, goal-based CHR semantics is reproducible in the abstract CHR semantics. Our work provides the foundation to obtain efficient, parallel CHR execution schemes.
Article
Full-text available
We investigate an approach to the design and implementa- tion of linear logic based agent systems via the linear logic semantics of Constraint Handling Rules (CHR). The intuition behind our approach is simple: Linear logic provides strong logical foundations to reason, verify and specify agent systems beyond the limitations of classical logics, while with CHR, one can implement and analyse agent systems in a concise and compact manner by executable inference rules. We discuss necessary refinements of the CHR semantics to allow for sequential computations of actions and the verification of action determinism. Our approach can possibly provide a seemless integration of the formal specification and implementation of agent programs via CHRs.
Conference Paper
Full-text available
Writing concurrent programs is notoriously difficult, and is of increasing practical importance. A particular source of concern is that even correctly-implemented concurrency abstractions cannot be composed together to form larger abstractions. In this paper we present a new concurrency model, based on transactional memory, that offers far richer composition. All the usual benefits of transactional memory are present (e.g. freedom from deadlock), but in addition we describe new modular forms of blocking and choice that have been inaccessible in earlier work.
Conference Paper
Full-text available
We describe a methodology for transforming a large class of highly-concurrent linearizable objects into highly-concurrent trans- actional objects. As long as the linearizable implementation satis- fies certain regularity properties (informally, that every method has an inverse), we define a simple wrapper for the linearizable im- plementation that guarantees that concurrent transactions without inherent conflicts can synchronize at the same granularity as the original linearizable implementation. Synchronizing via read/write conflicts has one substantial ad- vantage: it can be done automatically without programmer partici- pation. It also has a substantial disadvantage: it can severely and un- necessarily restrict concurrency for certain shared objects. If these objects are subject to high levels of contention (that is, they are "hot-spots"), then the performance of the system as a whole may suffer. Here is a simple example. Consider a mutable set of integers that provides add(x), remove(x) and contains(x) methods with the obvious meanings. Suppose we implement the set as a sorted linked list in the usual way. Each list node has two fields, an integer value and a node reference next. List nodes are sorted by value, and values are not duplicated. Integer x is in the set if and only if a list node has value field x. The add(x) method reads along the list until it encounters the largest value less than x. Assuming x is
Conference Paper
Full-text available
Transactional memory (TM) promises to simplify concurrent programming while providing scalability competitive to fine-grained locking. Language-based constructs allow programmers to denote atomic regions declaratively and to rely on the underlying system to provide transactional guarantees along with concurrency. In contrast with fine-grained locking, TM allows programmers to write simpler programs that are composable and deadlock-free. TM implementations operate by tracking loads and stores to memory and by detecting concurrent conflicting accesses by different transactions. By automating this process, they greatly reduce the programmer's burden, but they also are forced to be conservative. Incertain cases, conflicting memory accesses may not actually violate the higher-level semantics of a program, and a programmer may wish to allow seemingly conflicting transactions to execute concurrently. Open nested transactions enable expert programmers to differentiate between physical conflicts, at the level of memory, and logical conflicts that actually violate application semantics. A TMsystem with open nesting can permit physical conflicts that are not logical conflicts, and thus increase concurrency among application threads. Here we present an implementation of open nested transactions in a Java-based software transactional memory (STM)system. We describe new language constructs to support open nesting in Java, and we discuss new abstract locking mechanisms that a programmer can use to prevent logical conflicts. We demonstrate how these constructs can be mapped efficiently to existing STM data structures. Finally, we evaluate our system on a set of Java applications and data structures, demonstrating how open nesting can enhance application scalability.
Article
Constraint Handling Rules (CHR) is a committed-choice rule-based language that was originally intended for writing constraint solvers. In this paper we show that it is also possible to write the classic union-find algorithm and variants in CHR. The programs neither compromise in declarativeness nor efficiency. We study the time complexity of our programs: they match the almost-linear complexity of the best known imperative implementations. This fact is illustrated with experimental results.
Chapter
We show how the language Constraint Handling Rules (CHR), a high-level logic language for the implementation of constraint solvers, can be slightly extended to become a general-purpose logic programming language with an expressive power subsuming the expressive ower of Horn clause programs with SLD resolution. The extended language, called “CHR∀”, retains however the extra features of CHR, e.g., committed choice and matching, which axe important for other purposes, especially for efficiently solving constraints. CHR∀ turns out to be a very flexible query language in the sense that it supports several (constraint) logic programming paradigms and allows to mix them in a single program. In particular, it supports top-down query evaluation and also bottom-up evaluation as it is frequently used in (disjunctive) deductive databases.
Article
Constraint Handling Rules (CHR) are our proposal to allow more flexibility and application-oriented customization of constraint systems. CHR are a declarative language extension especially designed for writing user-defined constraints. CHR are essentially a committed-choice language consisting of multi-headed guarded rules that rewrite constraints into simpler ones until they are solved. In this broad survey we aim at covering all aspects of CHR as they currently present themselves. Going from theory to practice, we will define syntax and semantics for CHR, introduce an important decidable property, confluence, of CHR programs and define a tight integration of CHR with constraint logic programming languages. This survey then describes implementations of the language before we review several constraint solvers – both traditional and nonstandard ones – written in the CHR language. Finally we introduce two innovative applications that benefited from using CHR.