Formalizing the dependency pair criterion for innermost termination,☆☆

https://doi.org/10.1016/j.scico.2020.102474Get rights and content

Highlights

  • Dependency pairs criterion and verification of termination of rewriting systems.

  • Automating termination of rewriting and functional programs.

  • Formalization of termination of first-order term rewriting systems.

  • Innermost reduction and termination of rewriting.

  • Formally proving the soundness of rewriting with the PVS proof assistant.

Abstract

Rewriting is a framework for reasoning about functional programming. The dependency pair criterion is a well-known mechanism to analyze termination of term rewriting systems. Functional specifications with an operational semantics based on evaluation are related, in the rewriting framework, to the innermost reduction relation. This paper presents a PVS formalization of the dependency pair criterion for the innermost reduction relation: a term rewriting system is innermost terminating if and only if it is terminating by the dependency pair criterion. The paper also discusses the application of this criterion to check termination of functional specifications.

Introduction

Although closely related to the halting problem [1], and thus undecidable, termination is a relevant property for computational objects. This property is crucial to state correctness of programs, since it can guarantee that an output will eventually be produced for any input. Even in concurrent and reactive systems, important properties as progress and liveness are related to termination.

It is well-known that term rewriting systems (TRSs) are an adequate formal framework to reason about functional programs. In this context, the dependency pairs (DPs) criterion ([2], [3], [4], [5]), provides a good mechanism to analyze termination. Instead of checking decreasingness of rewrite rules, this criterion aims to check just decreasingness of the fragments of rewrite rules headed by defined symbols. Indeed, a dependency pair consists of the left-hand side (lhs) of a rewrite rule and a subterm of the right-hand side (rhs) of the rule headed by a defined symbol. Thus, a dependency pair expresses the dependency of a function on calls of any function. Checking decreasingness over chains of such pairs corresponds, in a functional specification, to the construction of a ranking function that provides a measure over data exchanging points of the program and that decreases with respect to some well-founded order [6]. For functional programs, such measures are given over the arguments of each possible (recursive) function call (data exchange point), and it is expected that they decrease after each function call. This is indeed the semantics of termination used in several proof assistants; in particular, in the Prototype Verification Systems (PVS) such ranking functions should be provided by the specifier, as part of each recursive definition, and the decreasingness requirements are implemented through the so-called termination Type Correctness Conditions (termination TCCs, for short). Termination TCCs are proof obligations built by static analysis over the recursive definitions, stating that the measure of the actual parameters of each recursive call strictly decreases regarding the measure of the formal parameters.

Eager evaluation determines the operational semantics of several functional languages, and in particular of the functional language PVS0 specified in PVS for the verification of equivalence between different criteria to automate termination (available as part of the NASA LaRC PVS library at https://github.com/nasa/pvslib). The eager evaluation strategy of functional programs corresponds to innermost normalization. Thus to provide formal support to adaptations of the DP criterion over functional programming it is essential to verify the DP criterion for innermost reductions [5].

Main contribution. This work presents a complete formalization of the DP criterion for innermost reduction. The formalization extends the PVS library for TRSs (named also TRS) that encompasses the basic notions of rewriting as well as some elaborate results (e.g., [7], [8]). This library includes specifications of terms, positions, substitutions, abstract reduction relations, and term rewriting systems which are adequate for the development of formalizations that remain close to article and textbook proofs, as the one presented in this paper. Although having notions such as Noetherianity, TRS did not provide some elements required to fulfill the objective of formalizing the innermost DP criterion. In this sense, this work brings as a minor contribution specifications and formalizations related to the innermost reduction, non-root reduction and reduction over descendant relations, and as a major one, the formalization of the equivalence between the innermost DP criterion and the Noetherianity of the innermost reduction relation.

It is interesting to stress here that the full formalization of the DP criterion for the ordinary rewriting relation is also included in the theory, but since the interesting application is on termination of functional specifications, the focus of this paper is restricted to the innermost reduction case. The paper also discusses how the DP innermost reduction termination criterion over TRSs is related to the termination of PVS0 functional specifications.

Outline. Section 2 gives a brief overview of the basic notions of rewriting and the Dependency Pairs criterion, along with definitions of specific rewriting strategies required in the formalization ahead. Section 3 presents the basic elements of the theory TRS used in this work along with some additional ones, included by the development of this work, that were required for this formalization. Section 4 describes the proof that innermost Noetherianity implies termination in the dependency pair criterion, and Section 5 the converse. Section 6 discusses related work, Section 7 how this termination criterion may be applied to termination of functional programs, and Section 8 concludes and discusses future work. The formalization is available as part of the TRS library at http://trs.cic.unb.br and also at the NASA PVS library https://shemesh.larc.nasa.gov/fm/ftp/larc/PVS-library/. A preliminary version of this work was presented as [9].

Section snippets

Basic notions

Standard rewriting notation for terms, subterms, positions and substitutions (e.g., [10]), will be used. Given any relation R, R+ and R denote, respectively, its transitive and reflexive-transitive closure. The relation R between two terms will be referred as derivation. For a relation R and element s, if there exists t such that sRt holds, then s is said to be R-reducible, otherwise, it is said to be in R-normal form, denoted by nf(R)(s).

A TRS E is a set of rewrite rules that are ordered

Specification

This paper presents an extension of the PVS term rewriting library TRS. This library is a development that already contains the basic elements of abstract reduction systems and TRS, such as reducibility, confluence and Noetherianity regarding a given relation, notions of subterms and replacement, etc. Furthermore, this theory embraces several elaborate formalizations regarding such systems, such as confluence of abstract reduction systems (see [12]), the Critical Pair Theorem (see [7]) and

Necessity for the innermost dependency pairs criterion

Lemma inn_Noetherian_implies_inn_dp_termination formalizes this result, which is specified in Specification 10 along with the specification of the Noetherian? predicate over a given relation, which specified as holding whenever the converse of this relation is well-founded (both well_founded? predicate and function converse follow the standard definition and are specified in the prelude file of PVS).

The formalization follows by contraposition, by building an infinite sequence of terms

Sufficiency for the innermost dependency pairs criterion

The formalization is by contraposition. The core of the proof follows the idea in [5] to construct infinite chains from infinite innermost derivations. In an implementational level, to go from infinite derivations to infinite sequences of DPs that would create an infinite chain is challenging. Indeed, constructing the DPs requires, initially, choosing mint subterms from those terms leading to infinite innermost derivations; afterwards, choosing non-root innermost normalized terms; and, finally,

Related work

There are several methods of semi-decision to address the analysis of termination, among them, the well-known Ranking functions implemented in PVS as termination TCCs, as mentioned in the introduction. A more recent criterion to verify termination of functional programs is the so-called size-change principle (SCP, for short) [14]. This principle does not require decreasingness after each recursive call, but strict decreasingness (using a measure regarding some well-founded order) for each

Relating TRS termination to functional program termination

The CCGs technology has the advantage of allowing combinations of a finite family of measures at each node of a possible circuit, simplifying in this manner the formulation of a single and complex measure that works (decreases) for all possible circuits. These combinations are also implemented in the so-called Matrix Weighted Graphs (MWG) developed by Avelar in [24]. All these technologies (TCC, SCP, CCG, MWG) to verify termination are implemented and formalized to be equivalent in the PVS

Discussion and future work

A formalization in PVS of the soundness and completeness of the Dependency Pairs criterion for innermost termination of TRSs was presented. The formalization follows the lines of reasoning of proofs given in papers such as [5].

The kernel of the formalization consists of 56 lemmas, 34 of these being TCCs. These results are available in the specification and formalization files inn_dp_termination.pvs and .prf that have size 18 KB and 747 KB, respectively. The basic notions regarding Dependency

Declaration of Competing Interest

The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.

Acknowledgements

We would like to thank César Muñoz, Mariano Moscato and Thiago Ramos for the kind and precise support they provided on several PVS issues as well as for their fine work and continuous feedback on the development of the PVS0 theory.

References (25)

  • T. Arts et al.

    Termination of term rewriting using Dependency Pairs

    Theor. Comput. Sci.

    (2000)
  • B. Alarcón et al.

    Using context-sensitive rewriting for proving innermost termination of rewriting

    Electron. Notes Theor. Comput. Sci.

    (2009)
  • B. Alarcón et al.

    Context-sensitive dependency pairs

    Inf. Comput.

    (2010)
  • A.M. Turing

    On computable numbers with an application to the Entscheidungsproblem

    Proc. Lond. Math. Soc.

    (1937)
  • T. Arts

    Termination by absence of infinite chains of dependency pairs

  • T. Arts et al.

    Automatically proving termination where simplification orderings fail

  • T. Arts et al.

    Modularity of termination using dependency pairs

  • A.M. Turing

    Checking a large routine

  • A.L. Galdino et al.

    A formalization of the Knuth–Bendix(–Huet) critical pair theorem

    J. Autom. Reason.

    (2010)
  • A.C. Rocha-Oliveira et al.

    Confluence of orthogonal term rewriting systems in the prototype verification system

    J. Autom. Reason.

    (2017)
  • A.A. Almeida et al.

    Formalizing the dependency pair criterion for innermost termination

  • F. Baader et al.

    Term Rewriting and All That

    (1998)
  • Cited by (0)

    Work supported by FAPDF grant 193001369/2016.

    ☆☆

    This work is licensed under a Creative Commons “Attribution-ShareAlike 4.0 International” license

    Image 1
    .

    1

    Funded by CAPES with a PhD scholarship.

    2

    Partially funded by CNPq research grant number 307672/2017-4.

    View full text