# Polymorphic Higher-order Termination

We generalise the termination method of higher-order polynomial interpretations to a setting with impredicative polymorphism. Instead of using weakly monotonic functionals, we interpret terms in a suitable extension of System F-omega. This enables a direct interpretation of rewrite rules which make essential use of impredicative polymorphism. In addition, our generalisation eases the applicability of the method in the non-polymorphic setting by allowing for the encoding of inductive data types. As an illustration of the potential of our method, we prove termination of a substantial fragment of full intuitionistic second-order propositional logic with permutative conversions.

## Authors

• 4 publications
• 10 publications
• ### A Modular Termination Method for Second-Order Computation

We present a new modular proof method of termination for second-order co...
12/07/2019 ∙ by Makoto Hamana, et al. ∙ 0

• ### Modular Termination for Second-Order Computation Rules and Application to Algebraic Effect Handlers

We present a new modular proof method of termination for second-order co...
12/07/2019 ∙ by Makoto Hamana, et al. ∙ 0

• ### A static higher-order dependency pair framework

We revisit the static dependency pair method for proving termination of ...
02/15/2019 ∙ by Carsten Fuhs, et al. ∙ 0

• ### Theory of higher order interpretations and application to Basic Feasible Functions

Interpretation methods and their restrictions to polynomials have been d...
01/25/2018 ∙ by Emmanuel Hainry, et al. ∙ 0

• ### From Linear Term Rewriting to Graph Rewriting with Preservation of Termination

Encodings of term rewriting systems (TRSs) into graph rewriting systems ...
06/25/2021 ∙ by Roy Overbeek, et al. ∙ 0

• ### Modular Termination Checking Theorems for Second-Order Computation

We present new theorems of modular termination checking for second-order...
12/07/2019 ∙ by Makoto Hamana, et al. ∙ 0

• ### An interpretation of system F through bar recursion

There are two possible computational interpretations of second-order ari...
04/02/2018 ∙ by Valentin Blot, et al. ∙ 0

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

Termination of higher-order term rewriting systems [20, Chapter 11] has been an active area of research for several decades. One powerful method, introduced by v.d. Pol [22, 14], interprets terms into weakly monotonic algebras. In later work [5, 11], these algebra interpretations are specialised into higher-order polynomial interpretations, a generalisation of the popular – and highly automatable – technique of polynomial interpretations for first-order term rewriting.

The methods of weakly monotonic algebras and polynomial interpretation are both limited to monomorphic systems. In this paper, we will further generalise polynomial interpretations to a higher-order formalism with full impredicative polymorphism. This goes beyond shallow (rank-1, weak) polymorphism, where type quantifiers are effectively allowed only at the top of a type: it would be relatively easy to extend the methods to a system with shallow polymorphism since shallowly polymorphic rules can be seen as defining an infinite set of monomorphic rules. While shallow polymorphism often suffices in functional programming practice, there do exist interesting examples of rewrite systems which require higher-rank impredicative polymorphism.

For instance, in recent extensions of Haskell one may define a type of heterogeneous lists.

 List:∗foldlσ(f,a,nil)⟶anil:Listfoldlσ(f,a,consτ(x,l))⟶foldlσ(f,fτax,l)cons:∀α.α→List→List\omit\span\omitfoldl:∀β.(∀α.β→α→β)→β→List→β

The above states that is a type (), gives the types of its two constructors and , and defines the corresponding fold-left function . Each element of a heterogeneous list may have a different type. In practice, one would constrain the type variable  with a type class to guarantee the existence of some operations on list elements. The function argument of  receives the element together with its type. The -quantifier binds type variables: a term of type takes a type  as an argument and the result is a term of type .

Impredicativity of polymorphism means that the type itself may be substituted for its own type variable, e.g., if then . Negative occurrences of impredicative type quantifiers prevent a translation into an infinite set of simply typed rules by instantiating the type variables. The above example is not directly reducible to shallow polymorphism as used in the ML programming language.

Related work. The term rewriting literature has various examples of higher-order term rewriting systems with some forms of polymorphism. To start, there are several studies that consider shallow polymorphic rewriting (e.g., [8, 10, 24]), where (as in ML-like languages) systems like above cannot be handled. Other works consider extensions of the -calculus [2, 3] or the calculus of constructions [1, 25] with rewriting rules; only the latter includes full impredicative polymorphism. The termination techniques presented for these systems are mostly syntactic (e.g., a recursive path ordering [10, 25], or general schema [1]), as opposed to our more semantic method based on interpretations. An exception is [3], which defines interpretations into -algebras; this technique bears some similarity to ours, although the methodologies are quite different. A categorical definition for a general polymorphic rewriting framework is presented in [4], but no termination methods are considered for it.

Our approach. The technique we develop in this paper operates on Polymorphic Functional Systems (PFSs), a form of higher-order term rewriting systems with full impredicative polymorphism (Section 3), that various systems of interest can be encoded into (including the example of heterogeneous fold above). Then, our methodology follows a standard procedure:

• we define a well-ordered set (Section 4);

• we provide a general methodology to map each PFS term to a natural number , parameterised by a core interpretation for each function symbol (Section 5);

• we present a number of lemmas to make it easy to prove that or whenever reduces to (Section 6).

Due to the additional complications of full polymorphism, we have elected to only generalise higher-order polynomial interpretations, and not v.d. Pol’s weakly monotonic algebras. That is, terms of base type are always interpreted to natural numbers and all functions are interpreted to combinations of addition and multiplication.

We will use the system of heterogeneous fold above as a running example to demonstrate our method. However, termination of this system can be shown in other ways (e.g., an encoding in System ). Hence, we will also study a more complex example in Section 7: termination of a substantial fragment of IPC2, i.e., full intuitionistic second-order propositional logic with permutative conversions. Permutative conversions [21, Chapter 6] are used in proof theory to obtain “good” normal forms of natural deduction proofs, which satisfy e.g. the subformula property. Termination proofs for systems with permutative conversions are notoriously tedious and difficult, with some incorrect claims in the literature and no uniform methodology. It is our goal to make such termination proofs substantially easier in the future.

This is a pre-publication copy of a paper at FSCD 2019. In particular, it contains an appendix with complete proofs for the results in this paper.

## 2 Preliminaries

In this section we recall the definition of System  (see e.g. [16, Section 11.7]), which will form a basis both of our interpretations and of a general syntactic framework for the investigated systems. In comparison to System , System  includes type constructors which results in a more uniform treatment. We assume familiarity with core notions of lambda calculi such as substitution and -conversion.

###### Definition .

Kinds are defined inductively: is a kind, and if are kinds then so is . We assume an infinite set  of type constructor variables of each kind . Variables of kind  are type variables. We assume a fixed set  of type constructor symbols paired with a kind , denoted . We define the set  of type constructors of kind  by the following grammar. Type constructors of kind  are types.

 T∗::=V∗∣ΣT∗∣Tκ⇒∗Tκ∣∀VκT∗∣T∗→T∗Tκ1⇒κ2::=Vκ1⇒κ2∣ΣTκ1⇒κ2∣Tκ⇒(κ1⇒κ2)Tκ∣λVκ1Tκ2

We use the standard notations and . When is of kind then we use the notation . If not indicated otherwise, we assume  to be a type variable. We treat type constructors up to -conversion.

If and , types are for instance and . The expression is a type constructor, but not a type. If and , then both and are types.

The compatible closure of the rule defines -reduction on type constructors. As type constructors are (essentially) simply-typed lambda-terms, their -reduction terminates and is confluent; hence every type constructor  has a unique -normal form . A type atom is a type in -normal form which is neither an arrow nor a quantification .

We define – the set of free type constructor variables of the type constructor  – in an obvious way by induction on . A type constructor  is closed if .

We assume a fixed type symbol . For we define .

###### Definition .

We assume given an infinite set of variables, each paired with a type, denoted . We assume given a fixed set of function symbols, each paired with a closed type, denoted . Every variable  and every function symbol occurs only with one type declaration.

The set of preterms consists of all expressions  such that can be inferred for some type by the following clauses:

• for .

• for all .

• if and .

• if and does not occur free in the type of a free variable of .

• if and

• if and  is a type constructor of kind ,

• if and .

The set of free variables of a preterm , denoted , is defined in the expected way. Analogously, we define the set  of type constructor variables occurring free in . If is a type then we use the notation . We denote an occurrence of a variable  of type  by , e.g. . When clear or irrelevant, we omit the type annotations, denoting the above term by . Type substitution is defined in the expected way except that it needs to change the types of variables. Formally, a type substitution changes the types associated to variables in . We define the equivalence relation  by: iff and are identical modulo -conversion in types.

Note that we present terms in orthodox Church-style, i.e., instead of using contexts each variable has a globally fixed type associated to it.

If and then .

Induction on . ∎

###### Definition .

The set of terms is the set of the equivalence classes of .

Because -reduction on types is confluent and terminating, every term has a canonical preterm representative – the one with all types occurring in it -normalised. We define as the value of  on the canonical representative of . We say that is closed if both and . Because typing and term formation operations (abstraction, application, …) are invariant under , we may denote terms by their (canonical) representatives and informally treat them interchangeably.

We will often abuse notation to omit and . Thus, can refer to both and . This is not ambiguous due to typing. When writing we implicitly assume that and have the same kind. Analogously with .

[Substitution lemma]

1. If and and then .

2. If then .

###### Proof.

Induction on the typing derivation. ∎

[Generation lemma] If then there is a type  such that and and one of the following holds.

• is a variable with .

• is a function symbol with in .

• and and .

• and and and does not occur free in the type of a free variable of .

• and and and .

• and and and  is a type constructor of kind .

###### Proof.

By analysing the derivation . To ensure , note that if is of kind  and , then by the substitution lemma (thus we can eliminate ). ∎

## 3 Polymorphic Functional Systems

In this section, we present a form of higher-order term rewriting systems based on : Polymorphic Functional Systems (PFSs). Systems of interest, such as logic systems like ICP2 and higher-order TRSs with shallow or full polymorphism can be encoded into PFSs, and then proved terminating with the technique we will develop in Sections 46.

###### Definition .

Kinds, type constructors and types are defined like in Definition 2, parameterised by a fixed set  of type constructor symbols.

Let  be a set of function symbols such that for :

 σ=∀(α1:κ1)…∀(αn:κn).σ1→…→σk→τ(with τ a type atom)

We define PFS terms as in Definition 2 (based on Definition 2), parameterised by , with the restriction that for any subterm of a term , we have where:

 f:∀(α1:κ1)…∀(αn:κn).σ1→…→σk→τ(with τ a type atom and k>m)

This definition does not allow for a variable or abstraction to occur at the head of an application, nor can we have terms of the form (although terms of the form , or with a variable, are allowed to occur). To stress this restriction, we will use the notation as an alternative way to denote when is a function symbol in  with  a type atom and . This allows us to represent terms in a “functional” way, where application does not explicitly occur (only implicitly in the construction of ).

The following result follows easily by induction on term structure:

If are PFS terms then so is .

PFS terms will be rewritten through a reduction relation based on a (usually infinite) set of rewrite rules. To define this relation, we need two additional notions.

###### Definition .

A replacement is a function satisfying:

1. is a type constructor substitution,

2. is a term substitution such that for every .

For  a type constructor, we use to denote . We use the notation . Note that if then .

###### Definition .

A -context  is a PFS term with a fresh function symbol of type  occurring exactly once. By  we denote a PFS term obtained from  by substituting  for . We drop the subscripts when clear or irrelevant.

Now, the rewrite rules are simply a set of term pairs, whose monotonic closure generates the rewrite relation.

###### Definition .

A set of term pairs is a set of rewrite rules if: (a) ; (b) and have the same type; and (c) if then for any replacement . The reduction relation on PFS terms is defined by:

iff and for some and context .

###### Definition .

A Polymorphic Functional System (PFS) is a triple where  is a set of type constructor symbols, a set of function symbols (restricted as in Def. 3), and is a set of rules as in Definition 3. A term of a PFS  is referred to as an -term.

While PFS-terms are a restriction from the general terms of system , the reduction relation allows us to actually encode, e.g., system  as a PFS: we can do so by including the symbol in and adding all rules of the form . Similarly, -reduction of type abstraction can be modelled by including a symbol and rules .111The use of a type constructor variable of kind makes it possible to do type substitution as part of a rule. An application with is encoded as , so is substituted with . This is well-typed because and . We can also use rules without the extra symbol, but to apply our method it may be convenient to use the extra symbol, as it creates more liberty in choosing an interpretation.

[Fold on heterogenous lists] The example from the introduction may be represented as a PFS with one type symbol , the following function symbols:

and the following rules (which formally represents an infinite set of rules: one rule for each choice of types and PFS terms , , etc.):

## 4 A well-ordered set of interpretation terms

In polynomial interpretations of first-order term rewriting [20, Chapter 6.2], each term is mapped to a natural number , such that whenever . In higher-order rewriting, this is not practical; instead, following [14], terms are mapped to weakly monotonic functionals according to their type (i.e., terms with a -order type are mapped to natural numbers, terms with a -order type to weakly monotonic functions over natural numbers, terms with a -order type to weakly monotonic functionals taking weakly monotonic functions as arguments, and so on). In this paper, to account for full polymorphism, we will interpret PFS terms to a set of interpretation terms in a specific extension of System . This set is defined in Section 4.1; we provide a well-founded partial ordering on in Section 4.2.

Although our world of interpretation terms is quite different from the weakly monotonic functionals of [14], there are many similarities. Most pertinently, every interpretation term essentially defines a weakly monotonic function from to . This, and the use of both addition and multiplication in the definition of , makes it possible to lift higher-order polynomial interpretations [5] to our setting. We prove weak monotonicity in Section 4.3.

### 4.1 Interpretation terms

###### Definition .

The set  of interpretation types is the set of types as in Definition 2 with , i.e., there is a single type constant . Then .

The set  of interpretation terms is the set of terms from Definition 2 (see also Definition 2) where as types we take the interpretation types and for the set  of function symbols we take , where .

For easier presentation, we write , , etc., instead of , , etc. We will also use and in infix, left-associative notation, and omit the type denotation where it is clear from context. Thus, should be read as if has type . Thus, our interpretation terms include natural numbers with the operations of addition and multiplication. It would not cause any fundamental problems to add more monotonic operations, e.g., exponentiation, but we refrain from doing so for the sake of simplicity.

#### Normalising interpretation terms

The set of interpretation terms can be reduced through a relation , that we will define below. This relation will be a powerful aid in defining the partial ordering in Section 4.2.

###### Definition .

We define the relation on interpretation terms as the smallest relation on  for which the following properties are satisfied:

1. if then both and

2. if then

3. if then both and

4. and (-reduction)

5. and

6. for

7. for

Recall Definition 2 and Definition 4.1 of the set of interpretation terms  as the set of the equivalence classes of . So, for instance, above denotes the equivalence class of all preterms with . Hence, the above rules are invariant under  (by confluence of -reduction on types), and they correctly define a relation on interpretation terms. We say that is a redex if reduces by one of the rules 4–13. A final interpretation term is an interpretation term such that (a) is closed, and (b) is in normal form with respect to . We let be the set of all final interpretation terms. By  () we denote the set of all (final) interpretation terms of interpretation type .

An important difference with System  and related ones is that the rules for , , and depend on the type . In particular, type substitution in terms may create redexes. For instance, if is a type variable then is not a redex, but is. This makes the question of termination subtle. Indeed, System  is extremely sensitive to modifications which are not of a logical nature. For instance, adding a constant with a reduction rule makes the system non-terminating [7]. This rule breaks parametricity by making it possible to compare two arbitrary types. Our rules do not allow such a definition. Moreover, the natural number constants cannot be distinguished “inside” the system. In other words, we could replace all natural number constants with 0 and this would not change the reduction behaviour of terms. So for the purposes of termination, the type is essentially a singleton. This implies that, while we have polymorphic functions between an arbitrary type and which are not constant when seen “from outside” the system, they are constant for the purposes of reduction “inside” the system (as they would have to be in a parametric -like system). Intuitively, these properties of our system ensure that it stays “close enough” to so that the standard termination proof still generalises.

Now we state some properties of , including strong normalisation. Because of space limitations, most (complete) proofs are delegated to Appendix A.1.

[Subject reduction] If and then .

###### Proof.

By induction on the definition of , using Lemmas 2 and 2. ∎

If then is terminating with respect to .

###### Proof.

By an adaptation of the Tait-Girard computability method. The proof is an adaptation of chapters 6 and 14 from the book [6], and chapters 10 and 11 from the book [16]. Details are available in Appendix A.1. ∎

Every term has a unique normal form . If  is closed then so is .

###### Proof.

One easily checks that  is locally confluent. Since the relation is terminating by Theorem 4.1, it is confluent by Newman’s lemma. ∎

The only final interpretation terms of type are the natural numbers.

Let and . Then we can reduce . If and are variables, this term is in normal form.

### 4.2 The ordering pair (⪰,≻)

With these ingredients, we are ready to define the well-founded partial ordering on . In fact, we will do more: rather than a single partial ordering, we will define an ordering pair: a pair of a quasi-ordering and a compatible well-founded ordering . The quasi-ordering often makes it easier to prove , since it suffices to show that for some interpretation terms . Having will also allow us to use rule removal (Theorem 6).

###### Definition .

Let . For closed  and closed  in -normal form, the relation is defined coinductively by the following rules.

 \infer=s Rnat ts↓ R t↓ in N\infer=s Rσ→τ ts⋅q Rτ t⋅q for all q∈Ifσ\infer=s R∀(α:κ).σ ts∗τ Rnfβ(σ[α:=τ]) t∗τ for all closed τ∈Tκ

We define if both and . We drop the type subscripts when clear or irrelevant.

Note that in the case for  the terms , are natural numbers by Lemma 4.1 ( are closed and in normal form, so they are final interpretation terms).

Intuitively, the above definition means that e.g. iff there exists a possibly infinite derivation tree using the above rules. In such a derivation tree all leaves must witness in natural numbers. However, this also allows for infinite branches, which solves the problem of repeating types due to impredicative polymorphism. If e.g.  then , which forces an infinite branch in the derivation tree. According to our definition, any infinite branch may essentially be ignored.

Formally, the above coinductive definition of e.g.  may be interpreted as defining the largest relation such that if then:

• and in , or

• and for all , or

• and for all closed .

For more background on coinduction see e.g. [13, 15, 9]. In this paper we use a few simple coinductive proofs to establish the basic properties of  and . Later, we just use these properties and the details of the definition do not matter.

###### Definition .

A closure  is a replacement such that is closed for each type constructor variable , and is closed for each term variable . For arbitrary types  and arbitrary terms we define if for every closure  we can obtain coinductively with the above rules. The relations and are defined analogously.

Note that for closed and closed  in -normal form, iff (and analogously for ). In this case we shall often omit the superscript .

The definition of  and  may be reformulated as follows.

if and only if for every closure  and every sequence of closed terms and closed type constructors such that we have in natural numbers. An analogous result holds with or instead of .

###### Proof.

The direction from left to right follows by induction on ; the other by coinduction. ∎

In what follows, all proofs by coinduction could be reformulated to instead use the lemma above. However, this would arguably make the proofs less perspicuous. Moreover, a coinductive definition is better suited for a formalisation – the coinductive proofs here could be written in Coq almost verbatim.

Our next task is to show that and have the desired properties of an ordering pair; e.g., transitivity and compatibility. We first state a simple lemma that will be used implicitly.

If is closed and -normal, then or or .

is well-founded.

###### Proof.

It suffices to show this for closed terms and closed types in -normal form, because any infinite sequence induces an infinite sequence for any closure . By induction on the size of a -normal type  (with size measured as the number of occurrences of  and ) one proves that there does not exist an infinite sequence For instance, if has kind  and then , where . Because is in -normal form, all redexes in are created by the substitution and must have the form . Hence, by the definition of  (see Definition 2) the type  is smaller than . This contradicts the inductive hypothesis. ∎

Both and are transitive.

###### Proof.

We show this for , the proof for  being analogous. Again, it suffices to prove this for closed terms and closed types in -normal form. We proceed by coinduction.

If then , so . Thus .

If then for . Hence for by the coinductive hypothesis. Thus .

If then for any closed  of kind , where . By the coinductive hypothesis ; thus . ∎

is reflexive.

###### Proof.

By coinduction one shows that is reflexive on closed terms for closed -normal . The case of  is then immediate from definitions. ∎

The relations  and  are compatible, i.e., and .

###### Proof.

By coinduction, analogous to the transitivity proof. ∎

If then .

###### Proof.

By coinduction. ∎

If then .

###### Proof.

Follows from Lemma 4.2, noting that implies for all closures . ∎

Assume (resp. ). If or then (resp. ). If or then (resp. ).

###### Proof.

Follows from Lemma 4.2, transitivity and compatibility. ∎

For : if and only if .

We can prove that : by definition, this holds if for all closed , so if for all closed . Following Example 4.1 and Lemma 4.2, this holds if . By definition, this is the case if in the natural numbers, which clearly holds for any .

### 4.3 Weak monotonicity

We will now show that implies (weak monotonicity). For this purpose, we prove a few lemmas, many of which also apply to , stating the preservation of  under term formation operations. We will need these results in the next section.

For : if then with a term or type constructor.

###### Proof.

Follows from definitions. ∎

For : if then for all types .

###### Proof.

Without loss of generality we may assume closed and in -normal form. By coinduction we show for closed . First note that (with a different type subscript in  on the right side, omitted for conciseness). If then . If then by the coinductive hypothesis for any , so by definition. If then by the coinductive hypothesis for any closed , where . Hence by definition. ∎

For : if then for all types .

###### Proof.

Without loss of generality we may assume  is closed and in -normal form. Using Lemma 4.2, the lemma follows by induction on . ∎

For : if then and .

###### Proof.

Assume and . Let  be a closure. We need to show . Let . Then is a closure and . Hence . By Lemma 4.2 this implies . Therefore . The proof for is analogous. ∎

Let be terms of type .

1. If then , , , and .

2. If then and . Moreover, if additionally then also and .

###### Proof.

It suffices to prove this for closed and closed in -normal form. The proof is similar to the proof of Lemma 4.3. For instance, we show by coinduction that for closed (denoted ): if and then . ∎

The following lemma depends on the lemmas above. The full proof may be found in Appendix A.2. The proof is actually quite complex, and uses a method similar to Girard’s method of candidates for the termination proof.

[Weak monotonicity] If then .

If then .

## 5 A reduction pair for PFS terms

Recall that our goal is to prove termination of reduction in a PFS. To do so, in this section we will define a systematic way to generate reduction pairs. We fix a PFS , and define:

###### Definition .

A binary relation  on -terms is monotonic if implies for every context  (we assume have the same type ).

A reduction pair is a pair  of a quasi-order  on -terms and a well-founded ordering  on -terms such that: (a) and  are compatible, i.e., and , and (b) and  are both monotonic.

If we can generate such a pair with for each rule , then we easily see that the PFS is terminating. (If we merely have for some rules and for the rest, we can still progress with the termination proof, as we will discuss in Section 6.) To generate this pair, we will define the notion of an interpretation from the set of -terms to the set of interpretation terms, and thus lift the ordering pair to . In the next section, we will show how this reduction pair can be used in practice to prove termination of PFSs.

One of the core ingredients of our interpretation function is a mapping to translate types:

###### Definition .

A type constructor mapping is a function which maps each type constructor symbol to a closed interpretation type constructor of the same kind. A fixed type constructor mapping is extended inductively to a function from type constructors to closed interpretation type constructors in the expected way. We denote the extended interpretation (type) mapping by . Thus, e.g.  and .

###### Proof.

Induction on . ∎

Similarly, we employ a symbol mapping as the key ingredient to interpret PFS terms.

###### Definition .

Given a fixed type constructor mapping , a symbol mapping is a function which assigns to each function symbol a closed interpretation term of type . For a fixed symbol mapping , we define the interpretation mapping inductively:

 ⟦x⟧=x⟦Λα.s⟧=Λα.⟦s⟧⟦t1⋅t2⟧=⟦t1⟧⋅⟦t2⟧⟦f⟧=J(f)⟦λx:σ.s⟧=λx:⟦σ⟧.⟦s⟧⟦t∗τ⟧=⟦t⟧∗⟦τ⟧

Note that above depend on . Essentially, substitutes for type constructor symbols , and for function symbols , thus mapping -terms to interpretation terms. This translation preserves typing:

If then .

###### Proof.

By induction on the form of , using Lemma 5. ∎

For all : and .

Induction on . ∎

###### Definition .

For a fixed type constructor mapping and symbol mapping , the interpretation pair is defined as follows: if , and if .

The polymorphic lambda-calculus has a much greater expressive power than the simply-typed lambda-calculus. Inductive data types may be encoded, along with their constructors and recursors with appropriate derived reduction rules. This makes our interpretation method easier to apply, even in the non-polymorphic setting, thanks to more sophisticated “programming” in the interpretations. The reader is advised to consult e.g. [6, Chapter 11] for more background and explanations. We demonstrate the idea by presenting an encoding for the recursive type and its fold-left function (see also Ex. 5).

Towards a termination proof of Example 3, we set