A faithful encoding of programmable strategies into term rewriting systems

Leibniz International Proceedings in Informatics, Jun 2015

Rewriting is a formalism widely used in computer science and mathematical logic. When using rewriting as a programming or modeling paradigm, the rewrite rules describe the transformations one wants to operate and declarative rewriting strategies are used to control their application. The operational semantics of these strategies are generally accepted and approaches for analyzing the termination of specific strategies have been studied. We propose in this paper a generic encoding of classic control and traversal strategies used in rewrite based languages such as Maude, Stratego and Tom into a plain term rewriting system. The encoding is proven sound and complete and, as a direct consequence, established termination methods used for term rewriting systems can be applied to analyze the termination of strategy controlled term rewriting systems. The corresponding implementation in Tom generates term rewriting systems compatible with the syntax of termination tools such as AAProVE and TTT2, tools which turned out to be very effective in (dis)proving the termination of the generated term rewriting systems. The approach can also be seen as a generic strategy compiler which can be integrated into languages providing pattern matching primitives; this has been experimented for Tom and performances comparable to the native Tom strategies have been observed.

A PDF file should load here. If you do not see its contents the file may be temporarily unavailable at the journal website or you do not have a PDF plug-in installed and enabled in your browser.

Alternatively, you can download the file locally and open with any standalone PDF reader:

http://drops.dagstuhl.de/opus/volltexte/2015/5190/pdf/10.pdf

A faithful encoding of programmable strategies into term rewriting systems

R TA A faithful encoding of programmable strategies into term rewriting systems Horatiu Cirstea Sergueï Lenglet Pierre-Etienne Moreau Vandoeuvre-lès-Nancy France } Rewriting is a formalism widely used in computer science and mathematical logic. When using rewriting as a programming or modeling paradigm, the rewrite rules describe the transformations one wants to operate and declarative rewriting strategies are used to control their application. The operational semantics of these strategies are generally accepted and approaches for analyzing the termination of specific strategies have been studied. We propose in this paper a generic encoding of classic control and traversal strategies used in rewrite based languages such as Maude, Stratego and Tom into a plain term rewriting system. The encoding is proven sound and complete and, as a direct consequence, established termination methods used for term rewriting systems can be applied to analyze the termination of strategy controlled term rewriting systems. The corresponding implementation in Tom generates term rewriting systems compatible with the syntax of termination tools such as AProVE and TTT2, tools which turned out to be very effective in (dis)proving the termination of the generated term rewriting systems. The approach can also be seen as a generic strategy compiler which can be integrated into languages providing pattern matching primitives; this has been experimented for Tom and performances comparable to the native Tom strategies have been observed. 1998 ACM Subject Classification F.4 Mathematical Logic and Formal Languages and phrases Programmable strategies; termination; term rewriting systems - Introduction Rewriting is a very powerful tool used in theoretical studies as well as for practical implementations. It is used, for example, in semantics in order to describe the meaning of programming languages [24], but also in automated reasoning when describing by inference rules a logic, a theorem prover or a constraint solver [20]. It is also used to compute in systems making the notion of rule an explicit and first class object, like Mathematica, Maude [8], or Tom [25, 4]. Rewrite rules, the core concept in rewriting, consist of a pattern that describes a schematic situation and the transformation that should be applied in that particular case. The pattern expresses a potentially infinite number of instances and the application of the rewrite rule is decided locally using a (matching) algorithm which only depends on the pattern and its subject. Rewrite rules are thus very convenient for describing schematically and locally the transformations one wants to operate. In many situations, the application of a set of rewrite rules to a subject eventually leads to the same final result independently on the way the rules are applied, and in such cases we say that the rewrite rules are confluent and terminating. When using rewriting as a programming or modeling paradigm it is nevertheless common to consider term rewriting systems (TRS) that are non-confluent or non-terminating. In order to make the concept operational when such rules are employed we need an additional ingredient allowing one to specify which rules should be applied and where (in the subject). This fundamental mechanism allowing the control of rule application is a rewriting strategy. Rule-based languages like ELAN [6], Maude, Stratego [30] or Tom have introduced the notion of programmable strategies to express rule application control in a declarative way. All these languages provide means to define term representations for the objects we want to transform as well as rewrite rules and strategies expressing the way the terms are transformed and offer thus, a clear separation between data structures, function logic and control. Similarly to plain TRS (i.e. TRS without strategy), it is interesting to guarantee that the strategy controlled TRS enjoy properties such as confluence and termination. Confluence holds as long as the rewrite rules are deterministic (i.e. the corresponding matching is unitary) and all strategy operators are deterministic (or a deterministic implementation is provided). Termination is more delicate and the normalization under some specific strategy is usually guaranteed by imposing (sufficient) conditions on the corresponding set of rewrite rules. Such conditions have been proposed for the innermost [2, 13, 29, 17], outermost [9, 28, 17, 26], context-sensitive [14, 1, 17], or lazy [15] reduction strategies. Termination under programmable strategies has been studied for ELAN [11] and Stratego [21, 23]. In [11], the authors prove that a programmable strategy is terminating if the system formed with all the rewrite rules the strategy contains is terminating. This criterion is too coarse as it does not take into account how the strategy makes its arguments interact and consequently, the approach cannot be used to prove termination for many terminating strategies. In (...truncated)


This is a preview of a remote PDF: http://drops.dagstuhl.de/opus/volltexte/2015/5190/pdf/10.pdf

Horatiu Cirstea, Serguei Lenglet, Pierre-Etienne Moreau. A faithful encoding of programmable strategies into term rewriting systems, Leibniz International Proceedings in Informatics, 2015, pp. 74-88, 36, DOI: 10.4230/LIPIcs.RTA.2015.74