Factorize Factorization

05/04/2020 ∙ by Beniamino Accattoli, et al. ∙ 0

We present a new technique for proving factorization theorems for compound rewriting systems in a modular way, which is inspired by Hindley-Rosen result for confluence. Factorization – a simple form of standardization – is concerned with reduction strategies, i.e. how a result is computed. The technique is first developed abstractly. In particular, we isolate a simple sufficient condition (called linear swap) for lifting factorization from components to the compound system. We then closely analyze some common factorization schemas for the lambda-calculus, and show that the technique simplifies even more, reducing to the test of elementary local commutations. Concretely, we apply our technique to diverse extensions of the λ-calculus, among which de' Liguoro and Piperno's non-deterministic lambda-calculus and – for call-by-value – Carraro and Guerrieri's shuffling calculus. For both calculi the literature contains factorization theorems. For each, we obtain a novel proof which is neat and strikingly short.



There are no comments yet.


page 1

page 2

page 3

page 4

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

The -calculus is the model underling functional programming languages and, more generally, is the paradigm of higher-order computation. Through the years, more and more advanced features have enriched this paradigm, including control, non-determinism, states, probabilistic or quantum features. The well established way to proceed is to extend the -calculus with new operators. Every time, good operational properties, such as confluence, normalization, or termination, need to be proved. It is evident that the more complex and advanced is the calculus under study, the more the ability to modularize the analysis of its properties is crucial.

Techniques for modular proofs are available for termination and confluence, with a rich literature which examines under which conditions these properties lift from modules to the compound system—some representative papers are [50, 49, 51, 45, 34, 35, 36, 28, 7, 18, 16, 15, 5, 9], see Gramlich [20] for a survey. Termination and confluence concern the existence and the uniqueness of normal forms, which are the results of a computation. When the focus is on how to compute the result, that is, on identifying reduction strategies with good properties, then only few abstract techniques are currently available (we mention [19, 32, 33], [48](Ch.8), and [2])—this paper proposes a new one.


The most basic abstract property about how to compute is factorization, whose paradigmatic example is the head factorization theorem of the -calculus ([8], 11.4.6): every -reduction sequence can be re-organized/factorized so as to first reducing head redexes and then everything else—in symbols .

The study of factorization in -calculus goes back to Rosser [44]. Here, we adopt Melliès terminology [33]: factorization is sometimes referred to as semi-standardization (Mitschke in [37]), or postponement ([48]), and often simply called standardization—standardization is however a more sophisticated property (sketched below) of which factorization is a basic instance.

The content of factorization is captured well by Melliès [33]: it means that the essential part of a computation can always be separated from its junk. Let’s abstract the role of head reduction, by assuming that computations consists of steps which are in some sense essential to reach the result, and steps which are not. Factorization says that every rewrite sequence can be factorized in a sequence of essential steps, followed by inessential ones: implies .

Well known examples of essential reductions are head and leftmost-outermost reduction (see Barendregt [8]) for the -calculus, or left and weak reduction for the call-by-value -calculus (see Plotkin [40] and Paolini and Ronchi Della Rocca [43]).

Very much as confluence, factorization is a non-trivial property of -calculus; proofs require techniques such as finite developments [12, 48], labeling [31, 27], parallel reduction [47].

Uses of Factorization.

Factorization is commonly used as the building block in proving more sophisticated properties of the how-to-compute kind. It is often the main ingredient in proofs of normalization theorems [8, 47, 25, 52, 3], stating that a reduction strategy reaches a normal form whenever one exists. Leftmost normalization is a well known example.

Another property, standardization

, generalizes factorization: reduction sequences can be organized with respect to an order on redexes, not just with respect to the distinction essential/inessential. It is an early result that factorization can be used to prove standardization: iterated head factorizations provides what is probably the simplest way to prove Curry and Feis’ left-to-right standardization theorem, via Mitschke’s argument


Additionally, the independence of some computational tasks, such as garbage collection, can also be modeled as a factorization theorem. In calculi where -reduction is decomposed in smaller, micro steps, there is often a rule for garbage collection. The fact that garbage collection is an orthogonal task, managed by the system, can sometimes be expressed as factorization property: implies , where is made of all the evaluation rules but the garbage collecting one.

This Paper.

Here we present a method for proving factorization theorems for compound systems in a modular way. The approach can be seen as an analogous for factorization of the classical technique based on Hindley-Rosen lemma, which we discuss in the next paragraph. To use a similar technique also for factorization is natural, yet to our knowledge this has never been proposed before.

Crucially to make the method usable and useful, we craft a simple condition that—quite surprisingly—suffices to handle with ease a variety of interesting cases. In particular, we apply our method to two diverse extensions of the -calculus in the literature, which do not fit into easily manageable categories of rewriting systems. In both cases, we obtain a novel proof which is neat, simpler than the original, as well as strikingly short.

Confluence via Hindley-Rosen.

Let us consider confluence. The simplest possible modular technique to establish it is based on Hindley-Rosen lemma, which states that the union of two confluent reductions and is itself confluent if and satisfy a commutation property. See for example the classical proof of confluence of in [8] (Thm. 3.3.9 therein); Barendregt explicitly points out how the resulting proof is simpler than the original one by Curry and Feys.

While the result is basic—even elementary—Hindley-Rosen lemma provides a powerful tool to prove confluence of complex systems, as those obtained when extending the -calculus with advanced features. We mention for instance its use in the linear-algebraic -calculus [6], the probabilistic -calculus [17], the -calculus [46], the shuffling calculus [11], the -calculus extended with lists [42]

or pattern-matching

[10]. It is worth to spell-out the gain. Confluence is often a non-trivial property to establish—when higher-order is involved, the proof of confluence requires sophisticated techniques. The difficulty compounds when extending the -calculus with new constructs. Still, the problem is often originated by the -reduction itself, which encapsulates the higher-order features of the computation. By using Hindley-Rosen lemma, we rely on the fact that the -calculus is confluent, and do not need to prove that again. We use confluence of as a black box.

Modular Factorization, Abstractly.

In this paper, we present a similar approach to factorization. First, we study the question abstractly, with no assumptions on the structure of the object involved in the reduction. The starting point is an analog of Hindley-Rosen lemma for factorization: if and factorize separately and satisfy a property of commutation then the union also factorizes. Such a statement alone is of little use, because the commutation condition is in general non-trivial verifying – it may be as difficult as the general problem. However, we identify a simple and sufficient linear swap condition which, remarkably, is satisfied by several interesting examples, making it a rather powerful tool.

A key point here is that we assume the modules to be factorizing, therefore we can use their factorization—that may require a non-trivial proof via parallel reductions or finite developments—as a black box. Instead, to test the linear swap condition is combinatorial in nature, and local, in the sense that only single steps (rather than sequences of steps) need to be manipulated. This holds true even when the modules are not confluent, or non-terminating.

Modular Factorization, Concretely.

Next, we focus on oru target, which are extensions of the -calculus and discover a further striking gain: for common factorization schemas such as head or weak factorization, to verify the linear swap condition reduces to checking a single case, together with the fact that the new rule behaves well with respect to substitution.

We illustrate our method by providing several examples, chosen to stress the independence of the technique from other rewriting properties. In particular, we revisit two results from the literature. The first is head factorization for the non-deterministic -calculus by de’ Liguoro and Piperno [14], that extends the -calculus with a choice operator. It is a non confluent calculus, and it is representative of the class of -calculi extended with a commutative effect, such as probabilistic choice; indeed, most features and all issues are already present there, see [13] for a thorough discussion.

The second result is factorization for the shuffling calculus—a refinement of the call-by-value -calculus due to Carraro and Guerrieri [11], whose left factorization is proved by Guerrieri, Paolini, and Ronchi della Rocca in [21]. In this case the -calculus is extended with extra rules, but they are not associated to a new operator, very much like -reduction.

In both cases, we obtain a neat, and conceptually clear proof, which is remarkably short (versus several pages for the originals).

Summing up, we provide a simple method, based on testing a sufficient condition—the (root) linear swap—for testing common factorization schemes of enriched -calculi. Our technique is combinatorial and local. This fact makes it easy to use, and a convenient tool for the analysis of complex calculi. Additionally, it makes the technique suitable for automated proofs or to certify proofs of factorization, in the same spirit propounded by Hirokawa, Middeldorp, and Moser in [25].

Related work

To our knowledge, the only result in the literature about modular techniques for factorization is Accattoli’s technique for calculi with explicit substitutions [2], which relies on termination hypotheses. Our linear swap condition (page Linear Swap) is technically the same as his diagonal-swap condition. One of the observations at the inception of this work is exactly that termination in [2] is used only to establish factorization of each single module, but not when combining them. Here we assume modules to be factorizing, therefore avoiding termination requirements, and obtaining a more widely applicable technique.

A divide-and-conquer approach is well-studied for termination. The key point is finding conditions which guarantee that the union of terminating relations is terminating. Several have been studied [7, 18]; the weakest such condition, namely , is introduced by Doornbos and von Karger [16], and then studied by Dershowitz [15], under the name of lazy commutation, and by van Oostrom and Zantema [53]. Interestingly, lazy commutation has a similar flavor as the linear swap condition.

Finally, we mention a somehow orthogonal approach to study extensions of a rewriting system, which is to identify syntactical classes of term rewriting systems, which satisfy a property. While confluence is again the most studied property (e.g., [48], Ch 10.4), factorization and standardization are also investigated. Notably, if all rules which compose a system are left-normal, the system admits left-to-right standardization ([48], Ch. 8.5.7).

2 Preliminaries

In this section we start by recalling some standard definitions and notations in rewriting theory (see e.g. [48]); we provide an overview of confluence, commutation, and factorization.


An abstract rewriting system (ARS) (see [48], Ch.2) is a pair consisting of a set and a binary relation on whose pairs are written and called steps. We denote (resp. ) the transitive-reflexive (resp. reflexive) closure of . We write to denote the ARS where . We use freely the fact that the transitive-reflexive closure of a relation is a closure operator, i.e. satisfies


The following property is an immediate consequence:


We shall also use the following easy property.

Property .

implies .


Two relations and on commute if and imply that there exists such that and . Confluence and factorization, discussed in the next subsections, are both forms of commutations.

Local vs Global Properties.

In rewriting theory it is common to distinguish between local and global properties. A property of term is local if it is quantified over only one-step reductions from ; it is global if it is quantified over all rewrite sequences from . Local properties are usually easy to test. Global properties instead are more delicate. Note however that the difference between global and local is also a matter of perspective (and relation choice). A paradigmatic example is confluence (global) vs. diamond (local), as we recall below.

2.1 Confluence

The heart of Confluence is a Diamond.

A relation on is

  • Confluent if and implies that there exists such that and ;

  • Diamond: if , implies that there exists such that and ;

Observe that confluence can be formulated as a diamond property:

is confluent if and only if is diamond

It is well known that the diamond property implies confluence. The diamond property, however, can rarely be used directly, because most relations of interest–e.g. -reduction of -calculus–do not satisfy it. Nonetheless, the diamond is at the heart of to two fundamental techniques for proving confluence: Hindley-Rosen Lemma and the Parallel Reduction method of Tait and Martin-Löf. Both techniques rely the following easy property, which introduces a mediating relation . Observe that the diamond does not hold for , but for the mediating relation.

[Characterization] is confluent if and only if there exists a relation such that

  1. Same closure: ,

  2. Diamond: is diamond.


A classic result to modularize the proof of confluence is Hindley-Rosen lemma. Confluence of two relations and does not in general imply confluence of , however it does if and commute.

Lemma (Hindley-Rosen).

Let and be relations on the set . If and are confluent and commute with each other, then is confluent.

The proof of Hindley-Rosen looks at confluence and commutation as expressing the diamond property of . The diamond property lends itself, indeed, to easy modularization. We shall follow a similar path to modularize factorization.

2.2 Factorization

We now recall basic facts on the rewriting property at the center of this paper, factorization. Like for confluence, we shall focus on the local vs global perspective.

Definition (Factorization).

Let be an ARS. The relation satisfies -factorization, written , if the following holds


The following equivalent formulations of -factorization are all well known111Factorization can also be formulated in terms of commutation, and viceversa, as postpones after if and only if and commute.. The following are equivalent (for any two relations )

  1. Semi-local postponement 1: .

  2. Semi-local postponement 2: .

  3. Postponement: .

  4. Factorization: .

The heart of Factorization is Local Postponement.

Hindley first noted that a local property implies factorization [24].

Definition (Local Postponement).

We say that locally postpones after if

[Hindley [24]] Given , implies .

We observe that a property similar to Lemma 2.1 holds for factorization.

[Characterization] Let be an ARS. Factorization holds if and only if there exists such that:

  1. Same closure: .

  2. Local Postponement: holds.


If. By Lemma 2.2, implies . By and property (TR) (page TR), holds. Only if. Observe that instantiating , condition (a) is trivially satisfied and (b) holds because implies case (2) of Lemma 1. ∎

The content of Lemma 2.2 may be familiar. In the -calculus, the role of a mediating relation is typically played by parallel reduction, both for confluence and for factorization. The core of Takahashi’s method for factorization [47] is to introduce a mediating relation , called internal parallel reduction, which verifies the hypotheses of Lemma 2.2.

Similarly to the diamond property for confluence, local postponement can rarely be used directly, because interesting reductions do not often satisfy it. However, we claim that it is the core of factorization; indeed, local postponement is at the heart of Takahashi’s Parallel Reduction method to prove Factorization [47] , and it will be the cornerstone of our approach to modularity.

In the next section, we first deal modularly with local postponement, and then lift the result to factorization by using a mediating relation.

Factorization vs. Confluence.

Note that factorization and confluence are independent properties. In Sect. 5 we shall apply our modular factorization technique to a non-confluent calculus. Conversely, is a confluent reduction, which does not admit neither head nor leftmost factorization—interestingly and do verify head and leftmost factorization separately.

3 Modularizing Factorization

A natural way of modularizing factorization is to find conditions to make local postponement modular. We capture them in the following definition.

[LOcal Postponement Pair (LOPP)] A pair and of ARS form a LOPP if the following conditions hold, where

Local Postponement of : implies
Local Postponement of : implies ,
Swap of after : implies ,
Swap of after : implies .

Note in the right-hand side of the swap conditions. The four conditions essentially say that postpones after both and , and similarly for .

The four conditions above can be unified in following compact condition:

implies for all .

The condition, and the result below, easily extends to the union of any number of relations

[] If and form a LOPP, then their union satisfies local postponement , where and .


It is immediate that implies , because the 4 combinations of () exactly correspond to the 4 conditions. ∎

We now lift the result from local postponement to the global property, factorization.

[Modular factorization, mediated] Let and be two ARS. Their union satisfies factorization , where and , if there exist such that

  1. Same closures: and .

  2. LOPP: and form a LOPP.


We use Lemma 2.2, where we instantiate . Note that

  1. , by assumption (A.) and property TR (page TR).

  2. holds, by assumption (B.) and Lemma 3.

3.1 Union of Factorizing Relations

We formulated Theorem 3 in full generality; this allows for to be any mediating relation we need, for example a parallel reduction. We now focus on a specific choice and provide a simple local diagram implying the swap conditions.

Since we want to study under which conditions the union of factorizing relations satisfies factorization, the most natural choice is to take directly and . Assuming that and factorize separately, by Theorem 3, we have that the following are sufficient conditions to guarantee that factorizes (note that local postponement of and is given by Lemma 2.2):

Swap of after :      and    Swap of after :    .

These conditions are rather strong, because global, hence difficult to verify. Perhaps surprisingly, the following easy-to-check condition, which is local and linear in , suffices, and holds in a large variety of cases. Note in the right-hand side. We say that linearly swaps with if

(Linear Swap)

[Linear Swap] and (Swap of after ).


implies , by Property 2. By factorization of , we obtain . ∎

By Theorem 3 and Lemma 3.1, we obtain that the union of two factorizing relations , is factorizing if two elementary conditions are verified.

Corollary (Modular Factorization, linearly).

Let and be -factorizing relations, such that

 and   .

Then their union satisfies where , and .

Linear Postponement.

The idea behind the linear swap condition also applies to local postponement. The following will simplify the proof of factorization in several of our case studies.

[Linear postponement] Let

  1. (.

  2. (.

4 Enriched -Calculi and Head Factorization

We now consider factorization theorems for extensions of the -calculus. We start with head factorization, which is by far the most important and common factorization scheme in -calculus.

We show that our method lends a simple, neat test to prove head factorization of compound systems which enrich the -calculus with extra rules. In particular, the linear swap conditions reduce to an even simpler version, where the extra relation is tested only at its root rule. This property of head factorization holds for all rules, independently from their specific form.

4.1 The (applied) -Calculus

Since in the next sections we shall extend the -calculus with new operators, such as a non-deterministic choice or a fix-point , we include in the syntax of the -calculus a set of constants, meant to represent such operators. So, for instance, in Sect. 5 we shall see as a constant. This way one can see factorization results with respect to -reduction as holding also in the -calculus with extended syntax; this is absolutely harmless.

Note that despite the fact that the classic Barendregt’s book [8] defines the -calculus without constants, other classic references such as Hindley and Seldin’s book [23] or Plotkin [40] do endow it with constants—therefore, there is nothing exotic in the approach adopted here.

The syntax.

-terms and contexts are generated by

where ranges over a countable set of variables, over a disjoint (finite, infinite or empty) set of constants. Variables and constants are atoms, a term of shape is an application, and an abstraction. If the constants are , the set of terms is sometimes indicated as . Following [23] (page 3), when the set of constants is empty, the calculus is called pure, otherwise applied.

The plugging of a term into a context is the operation replacing the only occurrence of in with , potentially capturing free variables of .

A reduction step is defined as the contextual closure of a root relation on ,which is called a rule. Explicitly, given a rule , then holds if and , for some context . The term is called a -redex. Given two (or more) rules on , the relation is , which can equivalently be defined as the contextual closure of .

The -calculus is , the set of terms together with -reduction , defined as the contextual closure of the -rule: where denotes capture-avoiding substitution. We silently work modulo -equivalence.

Properties of Contextual Closure.

Here we collect a few basic properties about contextual closures and substitution, preparing the ground for the root swap condition studied next.

A relation on terms is substitutive if implies . An obvious induction on the shape of shows the following ([8] pag. 54).

Property (Substitutive).

Let be the contextual closure of .

  1. If is substitutive then is substitutive:   implies .

  2. If then .

We also point out a basic but key property which holds for all internal reductions we study.

Property (Shape Preservation).

Assume with . is an application (resp. an abstraction) if and only if is.

The consequences of Property 4.1 are spelled-out in Property A.1 and A.2 in the Appendix.

Head Reduction.

Head contexts are defined as follows:

where and . Note that if and only if . A non-head context is a context which is not head.

A head step (resp. non-head step ) is defined as the closure under head contexts (resp. non-head contexts) of rule . Obviously, .

Since the empty context is a head context, observe two basic but useful facts:
(i.) , and (ii.) Property 4.1 always applies to non-head steps.

4.2 Head Factorization, Modularly.

Head factorization is of great importance for the -calculus. In this case, our method simplifies even more, in two ways. First, each linear swap condition can be tested by considering for the head step only the root relation i.e., only the closure of under empty context, which is a head step by definition. This is expressed in the following lemma, where we include also a variation on the same property, that shall be useful later on. [Root Linear Swaps]Let be root relations on . If then . Moreover, the same is true if one replaces with . Note that Lemma 4.2 gives either a proof that the swap conditions hold, or a counter-example—at the end of the section we give an example of this use.

Second, in practice, we study systems of the form , i.e. the -calculus is enriched with a new relation. In such a case, linearly swaps after as soon as is substitutive. [Swap with ] If is substitutive, holds. The easy proof of these two lemmas is in Appendix A.1.1.

Summing up, since head factorization for is known, we obtain the following compact test for head factorization for enriched -calculi.

Proposition (A Test for Head Factorization).

Let be -reduction and be the contextual closure of . Their union satisfies head factorization if:

  1. Head factorization of : .

  2. Substitutivity: is substitutive.

  3. Root linear swap: .

Note that none of the properties concerns alone, whose head factorization is used as a black box, as we already know that head factorization of holds.

In Sect. 5 we shall use our test (Proposition 4.2) to prove head factorization for the non-deterministic -calculus. The full proof is only a few lines long.

An Example of Counter-Example, .

Let us show how the test of Proposition 4.2 can provide a counter-example to head factorization when it fails. Let’s instatiate with , that is, the contextual closure of rule if . Now, consider the root linear swap:

,     where .

Note that has no step, and so the two steps cannot be swapped. In fact, the reduction sequence above is easily seen to be a counter-example to both head and leftmost factorization for : if we start with the head redex (which is also the leftmost-outermost redex) . From , there is no way to reach . We recall that somewhat surprisingly, still satisfies leftmost normalization. The proof is non-trivial, see [27, 47, 52, 26].

5 The Non-Deterministic -Calculus

De’ Liguoro and Piperno’s non-deterministic -calculus is defined in [14] by extending the -calculus with a new operator whose rule models non-deterministic choice. Intuitively, non-deterministically rewrites to either or . Notably, is not confluent, hence it is a good example of the fact that confluence and factorization are independent properties. The work by de’ Liguoro and Piperno has been ground-breaking; indeed many key features and all issues appearing in the more complex setting of the -calculus with probabilistic choice are already present—see Dal Lago and Zorzi [13] for a thorough discussion.

We briefly present the syntax of and its features, and then use our technique to give a novel and neat proof of de’ Liguoro and Piperno’s head factorization result (Cor. 2.10 in [14]).


We slightly depart from the presentation in [14], as we consider as a constant, and write rather than , working as usual for -calculus with constants (see e.g., Hindley and Seldin [23], or Barendregt [8], Sec. 15.3). Terms and contexts are generated by:

As before, denotes -reduction, while the rewrite step is the contextual closure of the following non-deterministic rule:


Note that there is no loss with respect to the syntax in [14], where always comes with two arguments, because such a constraint defines a sub-system which is closed under reduction.


The calculus is highly non trivial. Of course, is not confluent. Moreover, the following examples from [14] show that to permute -steps and -steps is delicate.

  • creates -redexes: for instance, , hence the -step cannot be postponed after .

  • Choice Duplication. Postponing after is also problematic, because -steps may multiply choices, introducing new results: flipping a coin and duplicating the result is not equivalent to duplicating the coin and then flipping twice. For instance, let and consider  vs   (we cannot reach !).

These examples are significant as the same issues impact any calculus with choice effects.

Head Factorization.

The head (resp. non-head) rewrite steps and (resp. and ) are defined as the closure by head (resp. non-head) contexts of rules and , respectively222Non-head steps are called internal () in [14].. We also set and .

De’ Liguoro and Piperno prove that despite the failure of confluence, satisfies head factorization. They prove this result via standardization, following Klop’s technique [27].

Theorem (Head Factorization, Cor. 2.10 in [14]).

holds in the non-deterministic -calculus .

A New Proof, Modularly.

We give a novel, strikingly simple proof of , simply by proving that and satisfy the hypotheses of the test for head factorization (Proposition 4.2). All the ingredients we need are given by the following easy lemma. [Roots]

  1. implies .

  2. implies .

  1. Let , and assume (the case is similar). Assume . By Property 4.1 (as spelled-out in Property A.1), has shape , with . Therefore, either or , from which .

  2. The proof is the same as above, just put in place of .∎

Theorem (Testing Head Factorization).

We have because we have:

  1. Head factorization of .

  2. Substitutivity:   is substitutive.

  3. Root linear swap:   .


We prove the hypotheses of Proposition 4.2:

  1. Because linearly postpones after . Indeed from Lemma 5.2, we use Lemma 4.2 with , and obtain that . We conclude by Lemma 3.1.2.

  2. By definition of substitution .

  3. This is exactly Lemma 5.1.∎

Standardization and Leftmost Normalization.

From head factorization, standardization and leftmost normalization easily follow, via Mitschke argument [37, 8], see Appendix A.1.2.

6 Call-by-Value -calculus

Plotkin’s call-by-value (CbV) -calculus [40] is the restriction of the -calculus where