1 Introduction

Call-by-Name (CBN) and Call-by-Value (CBV) stand as two foundational evaluation strategies inspiring distinct techniques and models of computation in the theory of programming languages and proof assistants [46]. Notably, most theoretical studies in the \(\lambda \)-calculus still continues to focus on its CBN variant, while CBV, the cornerstone of operational semantics for most programming languages and proof assistants, has been less extensively explored. This is due in particular to the CBV stipulation that an argument can be passed to a function only when it is a value (i.e. variable or abstraction), making the reasoning notably challenging to grasp. Consequently, some fundamental concepts in the theory of the \(\lambda \)-calculus (e.g. denotational semantics, contextual equivalence, solvability, Böhm trees) make subtle –and not entirely understood– distinctions between CBN and CBV, sometimes resulting in completely ad-hoc scenarios for CBV, not being uniform with the corresponding notion in CBN. This is for example the case of CBV Böhm trees [33] or the notion of substitution in [23].

Unifying Frameworks. Reynolds [47] (quoted by Levy [37]) advocated for a unifying framework for CBN and CBV. This not only minimizes their arbitrariness, but also avoids developing and proving distinct and independent concepts and properties for them from scratch. Indeed, both paradigms can be encompassed into broader foundational frameworks [1, 16, 17, 21, 24, 37, 38, 40, 49] that explicitly differentiate values by marking them with a distinguished constructor. While multiple such frameworks exist, our focus lies on the Bang Calculus [18, 22, 30]. Inspired by Girard’s Linear Logic (LL) [28] and Ehrhard’s interpretation [21] of Levy’s Call-by-Push-Value [37] into LL, the Bang Calculus is obtained by enriching the \(\lambda \)-calculus with two distinguished modalities \(!\) and \(\textsf{der}\). The modality \(!\) plays a twofold role: it marks what can be duplicated or erased during evaluation (i.e. copied an arbitrary number of times, including zero), and it freezes the evaluation of subterms (called thunks). The modality \(\textsf{der}\) annihilates the effect of \(!\). Embedding CBN or CBV into the Bang Calculus just consists in decorating \(\lambda \)-terms with \(!\) and \(\textsf{der}\), thus forcing one model of computation or the other one. Thanks to these two modalities, the Bang Calculus eases the identification of shared behaviors and properties of CBN and CBV, encompassing both syntactic and semantic aspects of them, within a unifying and simple framework.

Adequate Models of Computation. Both CBN and CBV were originally defined on closed terms (without occurrences of free variables), that are enough to model execution of programs. However, evaluation in proof assistants must be performed on possibly open terms, that is, with free variables. While open terms are harmless to CBN, the theory of the CBV \(\lambda \)-calculus on open terms turns out to be much more subtle and trickier (see [6,7,8] for a detailed discussion). In particular, Plotkin’s original CBV [46] is not adequate for open terms, as there exist terms that may be both irreducible and meaningless/unsolvable. The non-adequacy problem in Plotkin’s CBV calculus can be repaired by introducing a form of sharing implemented by explicit substitutions (ES), together with a notion of reduction at a distance [9, 10], like in the Value Substitution Calculus [11] (here called dCBV), a CBV variant of Accattoli and Kesner’s linear substitution calculus [2, 3] (generalizing in turn Milner’s calculus [35, 41]). Adequacy also fails for the version of the Bang Calculus studied in [25, 30], for the same reasons as in CBV. It can be repaired again via ES and distance, resulting in the Distant Bang Calculus dBANG  [18, 19]. It is then natural to also integrate ES and distance in the CBN specification: this gives rise to CBN substitution calculi at a distance [9, 10], here we call dCBN the one in [2], which is adequate as the usual CBN. In summary, we focus in this paper on a CBN calculus dCBN, an adequate CBV calculus dCBV, and the adequate unifying Distant Bang Calculus dBANG.

Static and Dynamic. The literature has shown that some static properties of CBN and CBV, including normal forms [36], quantitative typing [18], tight typing [19, 36], inhabitation [12], and denotational semantics [30], can be inferred from their corresponding counterparts in the (Distant) Bang Calculus by exploiting suitable CBN and CBV encodings. However, retrieving dynamic properties from the Bang Calculus into CBN or CBV turns out to be a more intricate task, especially in their adequate (distant) variant [18, 19, 25, 30]. Indeed, it is easy to obtain simulation (a CBN or CBV reduction sequence is always embedded into a dBANG reduction sequence), but the converse, known as reverse simulation, fails: a dBANG reduction sequence from a term in the image of the CBN or CBV embedding may not correspond to a valid reduction sequence in CBN or CBV (counterexample in Fig. 1). Up to these days, there are no embeddings in the literature enjoying reverse simulation for an adequate CBV calculus, so that it is impossible to export dynamic properties from dBANG to both dCBN and dCBV.

Contributions. We first revisit and extend the existing static and dynamic preservation results relating dCBN and dBANG, including simulation and reverse simulation, exploiting the embedding used in [18, 19]. However, our primary and most significant contribution is a new methodology to deal with the (adequate) calculus dCBV. Indeed, we define a novel embedding from dCBV into dBANG, refining the one of [18, 19], that finely decorates terms with the modalities \(!\) and \(\textsf{der}\). To avoid redundant decorations, as \(!\) and \(\textsf{der}\) annihilate each other, a dedicated \(\texttt {d!} \)-reduction step is then applied on the fly by the embedding, as in [18, 19]. But our new dCBV embedding not only preserves static and dynamic properties, but also satisfies reverse simulation, an essential property that was previously lacking. This achievement is realized by the second ingredient of our new methodology, given by the notion of diligent sequence in dBANG, a concept standing independently of the embeddings. Indeed, a challenge at this point is to prove that the earlier mentioned \(\texttt {d!} \)-reductions have a purely administrative nature, and additionally, that they can be treated diligently, by executing all of them as soon as possible. We call this method diligent administration: we consistently address all administrative steps before proceeding with any other computational steps. A further challenge is then to establish that working with administrative diligence does not alter the CBN or CBV nature of evaluation.

As explained above, reverse simulation is crucial to derive properties for dCBN and dCBV from their respective properties in dBANG. We provide two main illustrative applications of this by studying the cases of confluence and factorization. Confluence is a well-known property, and factorization is crucial to prove important results in (or via) rewriting [2, 4, 5, 15, 26, 27, 29, 32, 42, 45, 51, 53]: we say that a reduction enjoys factorization when every reduction sequence can be rearranged so that some specific external steps (head in dCBN, weak in dCBV, surface in dBANG) are performed first. In the two last sections, we use confluence/factorization for dBANG as a basis to easily deduce confluence/factorization for dCBN and dCBV. This is done by exploiting the CBN and CBV embeddings back and forth, via reduction simulation and reverse simulation. Just one proof is enough for three confluence/factorization results: it’s a three-for-one deal! The fact that dCBN and dCBV confluence/factorizations can be easily derived from dBANG confluence/factorization in essentially the same way is another achievement, attained thanks to having introduced good tools, such as diligence and the new dCBV embedding.

We actually provide a first proof of factorization for dBANG, another major contribution of this paper. Factorizations in dCBN and dCBV were already proved in [2] and [11], respectively, but their proofs are not trivial, even when applying some abstract approach [2]. Deducing from dBANG the same dCBN/dCBV factorizations as in [2, 11] shows that our methodology is robust and not ad-hoc.

Road Map. Section 2 recalls dBANG and introduces diligence. The dCBN/dCBV calculi and their embeddings are presented in Sect. 3, together with their corresponding (static and dynamic) preservation results. Sect. 4 derives dCBN/dCBV confluence from that of dBANG. Section 5 proves a factorization result for dBANG, and deduces factorization for dCBN and dCBV by projection. Section 6 discusses future and related work and concludes. Proofs can be found in [13], the long version of this paper.

1.1 Basic Notions Used All Along the Paper

An abstract rewriting system (ARS) \(\mathcal {E}\) is a set E with a binary relation \(\rightarrow _\mathcal {E}\) on E, called reduction. We write u \(_{\mathcal {E}} \leftarrow \) t if \(t \rightarrow _\mathcal {E} u\), and we denote by \(\rightarrow _\mathcal {E}^+\) (resp. \(\rightarrow _\mathcal {E}^*\)) the transitive (resp. reflexive-transitive) closure of \(\rightarrow _\mathcal {E}\). Given \(t \in E\), t is an \(\mathcal {E}\) -normal form (\(\mathcal {E}\)-NF) if there is no \(u \in E\) such that \(t \rightarrow _\mathcal {E} u\); t is \(\mathcal {E}\) -terminating if there is no infinite \(\rightarrow _\mathcal {E}\) reduction sequence starting at t. Reduction \(\rightarrow _\mathcal {E}\) is terminating if every \(t \in E\) is \(\mathcal {E}\)-terminating; \(\rightarrow _\mathcal {E}\) is diamond if for any \(t, u_1, u_2 \in E\) such that \(u_{{1}~_{\mathcal {E}}} \leftarrow t \rightarrow _\mathcal {E} u_2\) and \(u_1 \ne u_2\), there is \(s\in E\) such that \(u_1 \rightarrow _\mathcal {E} s _{\mathcal {E}} \leftarrow u_2\); \(\rightarrow _\mathcal {E}\) is confluent if \(\rightarrow _\mathcal {E}^*\) is diamond.

All reductions in this paper will be defined by a set of rewrite rules \(\mathbb {R}\), closed by a set of contexts \(\mathbb {E}\). A term being an instance of the left-hand side of a rewrite rule \(\mathcal {R}\in \mathbb {R}\) is called a \(\mathcal {R}\) -redex. Given a rule \(\mathcal {R}\in \mathbb {R}\), and a context \(\texttt{E}\in \mathbb {E}\), we use \(\rightarrow _{\texttt{E}\langle \mathcal {R}\rangle }\) to denote the reduction of the \(\mathcal {R}\)-redex under the context \(\texttt{E}\). The reduction \(\rightarrow _{\mathbb {E}\langle \mathcal {R}\rangle }\) is the union of reductions \(\rightarrow _{\texttt{E}\langle \mathcal {R}\rangle }\) over all contexts \(\texttt{E}\in \mathbb {E}\). In other words, \(\rightarrow _{\mathbb {E}\langle \mathcal {R}\rangle }\) is the closure of the rule \(\mathcal {R}\) under all the contexts in \(\mathbb {E}\).

2 The Distant Bang Calculus dBANG

We introduce the term syntax of dBANG  [18]. Given a countably infinite set \(\mathcal {X}\) of variables \(x, y, z, \dots \), the set \(\varLambda _{!}\) of terms is defined inductively as follows:

$$\begin{aligned} {\textbf {(Terms)}} \qquad t, u, s \;::=\; x \in \mathcal {X}\;|\;tu \;|\;\lambda x.t \;|\;!t \;|\;\textsf{der}(t) \;|\;t[x \backslash u] \end{aligned}$$

The set \(\varLambda _{!}\) includes variables x, abstractions \(\lambda x.t\), applications \(tu\), closures \(t[x \backslash u]\) representing a pending explicit substitution (ES) \([x \backslash u]\) on t, bangs \(!t\) and derelictions \(\textsf{der}(t)\) (their operational meaning is explained below).

Abstractions \(\lambda x.t\) and closures \(t[x \backslash u]\) bind the variable x in their body t. The set of free variables \(\texttt {fv}(t)\) of a term t is defined as expected, in particular \(\texttt {fv}(\lambda x.t) := \texttt {fv}(t) \setminus \{x\}\) and \(\texttt {fv}( t[x \backslash u]) := \texttt {fv}(u) \cup (\texttt {fv}(t) \setminus \{x\})\). The usual notion of \(\alpha \)-conversion [15] is extended to the whole set \(\varLambda _{!}\), and terms are identified up to \(\alpha \)-conversion, e.g. \(y[y \backslash \lambda x.x] = z[z \backslash \lambda y.y]\). We denote by \(t\{x \backslash u\}\) the usual (capture avoiding) meta-level substitution of u for all free occurrences of x in t.

Full contexts \((\texttt{F}\in \mathbb {F})\), surface contexts \((\texttt{S}\in \mathbb {S})\) and list contexts \((\texttt{L}\in \mathbb {L})\), which can be seen as terms with exactly one hole \(\diamond \), are inductively defined by:

$$\begin{aligned} {{\textbf {(Full Contexts)}}} & \texttt{F}:= \diamond \;|\;\texttt{F}\,t \;|\;t\,\texttt{F} \;|\;\lambda x.\texttt{F} \;|\;!\texttt{F}\;|\;\textsf{der}(\texttt{F}) \;|\;\texttt{F}[x \backslash t] \;|\;t[x \backslash \texttt{F}] \\ {{\textbf {(Surface Contexts)}}}& \texttt{S}:= \diamond \;|\;\texttt{S}\,t \;|\;t\,\texttt{S} \;|\;\lambda x.\texttt{S} \;|\;\textsf{der}(\texttt{S}) \;|\;\texttt{S}[x \backslash t] \;|\;t[x \backslash \texttt{S}] \\ {{\textbf {(List Contexts)}}}& \texttt{L}:= \diamond \;|\;\texttt{L}[x \backslash t] \end{aligned}$$

\(\texttt{L}\) and \(\texttt{S}\) are special cases of \(\texttt{F}\): the hole may occur everywhere in \(\texttt{F}\), while in \(\texttt{S}\) it cannot appear under a \(!\). List contexts \(\texttt{L}\) are arbitrary lists of ES, used to implement reduction at a distance [9, 10]. We write \(\texttt{F}\langle t\rangle \) for the term obtained by replacing the hole in \(\texttt{F}\) with the term t (possibly capturing the free variables of t).

The following rewrite rules are the base components of our reductions.

$$\begin{aligned} \texttt{L}\langle \lambda x.t\rangle u &\mapsto _{\texttt {dB}}\texttt{L}\langle t[x \backslash u]\rangle & t[x \backslash \texttt{L}\langle !u\rangle ] &\mapsto _{\texttt {s!}}\texttt{L}\langle t\{x \backslash u\}\rangle & \textsf{der}(\texttt{L}\langle !t\rangle ) &\mapsto _{\texttt {d!}}\texttt{L}\langle t\rangle \end{aligned}$$

Rule \(\texttt {dB} \) (resp. \(\texttt {s!} \)) is assumed to be capture-free, so no free variable of u (resp. t) is captured by the context \(\texttt{L}\). The rule \(\texttt {dB} \) fires a \(\beta \)-redex, generating an ES. The rule \(\texttt {s!} \) fires an ES provided that its argument is duplicable, i.e. is a bang. The rule \(\texttt {d!} \) uses \(\textsf{der}\) to erase a \(!\). In all of these rewrite rules, the reduction acts at a distance [9, 10]: the main constructors involved in the rule can be separated by a finite—possibly empty—list \(\texttt{L}\) of ES. This mechanism unblocks desired computations that otherwise would be stuck, e.g. \((\lambda x.x)[y \backslash w]!z \mapsto _{\texttt {dB}}x[x \backslash !z] [y \backslash w]\).

Reductions are defined, as specified in Sect. 1.1, by taking the set of rewrite rules \(\{\texttt {dB}, \texttt {s!}, \texttt {d!} \}\) and the sets of contexts \(\mathbb {S}\) and \(\mathbb {F}\). Surface reduction is the relation \(\rightarrow _{\mathbb {S}} \,:=\, \rightarrow _{\mathbb {S}\langle \texttt{dB}\rangle } \cup \rightarrow _{\mathbb {S}\langle \mathtt {s!}\rangle } \cup \rightarrow _{\mathbb {S}\langle \mathtt {d!}\rangle }\), while full reduction is the relation \(\rightarrow _{\mathbb {F}} \,:=\, \rightarrow _{\mathbb {F}\langle \texttt{dB}\rangle } \cup \rightarrow _{\mathbb {F}\langle \mathtt {s!}\rangle } \cup \rightarrow _{\mathbb {F}\langle \mathtt {d!}\rangle }\). For example, for \(\texttt{S}_1 = \diamond \in \mathbb {S}\) and \(\texttt{F}_1= !\diamond \in \mathbb {F}\setminus \mathbb {S}\): \((\lambda x.!\textsf{der}(!x))!y \;\rightarrow _{{\texttt{S}_1}\langle \texttt {dB} \rangle }\; (!\textsf{der}(!x))[x \backslash !y] \;\rightarrow _{{\texttt{S}_1}\langle \texttt {s!} \rangle }\; !\textsf{der}(!y) \;\rightarrow _{{\texttt{F}_1}\langle \texttt {d!} \rangle }\; !y\). The first two steps are \(\rightarrow _{\mathbb {S}}\)- and also \(\rightarrow _{\mathbb {F}}\)-steps, while the last one is a \(\rightarrow _{\mathbb {F}}\)-step but not a \(\rightarrow _{\mathbb {S}}\)-step. More generally, \(\rightarrow _{\mathbb {S}} \,\subsetneq \, \rightarrow _{\mathbb {F}}\). For instance, \(!(\textsf{der}(!y))\) is a \(\mathbb {S}\text {-}\texttt{NF}\) but not a \(\mathbb {F}\text {-}\texttt{NF}\) since \(!(\textsf{der}(!y)) \rightarrow _{\mathbb {F}} !y\), while \(!y\) is a \(\mathbb {F}\text {-}\texttt{NF}\) (and hence a \(\mathbb {S}\text {-}\texttt{NF}\) too).

The \(!\) modality plays a twofold role. First, it marks the only subterms that can be substituted (i.e. erased or arbitrarily copied): the \(\texttt {s!} \)-rule fires an ES only if there is a \(!\) in its argument (up to a list context). Second, it freezes (surface) evaluation of the term under the scope of \(!\): surface reduction \(\rightarrow _{\mathbb {S}}\) does not reduce under \(!\). In full reduction \(\rightarrow _{\mathbb {F}}\), the \(!\) modality looses its freezing behavior.

Diligent Administration. While reductions \(\rightarrow _{\mathbb {F}\langle \texttt{dB}\rangle }\) and \(\rightarrow _{\mathbb {F}\langle \mathtt {s!}\rangle }\) are actual computational steps, reduction \(\rightarrow _{\mathbb {F}\langle \mathtt {d!}\rangle }\) is rather administrative in nature. As we use dBANG to simulate other calculi, we need to align with the implicit nature of these administrative steps: this can be achieved by executing them as soon as possible. We thus introduce a diligent process that reorders some reduction steps to ensure that administrative steps are always performed as soon as there is a \(\texttt {d!} \)-redex.

To begin, we formally introduce the concept of diligent administrative reduction sequence, characterizing sequences where each computational step (\(\texttt {dB} \) or \(\texttt {s!} \)) can be performed only after all administrative steps (\(\texttt {d!} \)) have been executed.

Definition 1

(Diligent Administrative Reduction). The diligent administrative surface (resp. full) reduction \(\rightarrow _{\mathbb {S}\texttt{ad}}\) (resp. \(\rightarrow _{\mathbb {F}\texttt{ad}}\)) is a subset of the surface (resp. full) reduction obtained by restricting \(\texttt {dB} \)- and \(\texttt {s!} \)-steps to \(\mathbb {S}\langle \texttt {d!} \rangle \)-normal forms (resp. \(\mathbb {F}\langle \texttt {d!} \rangle \)-normal forms). More precisely, it is defined as follows:

$$\begin{aligned} \begin{array}{rcl} \rightarrow _{\mathbb {S}\texttt{ad}} &{}:=&{} (\rightarrow _{\mathbb {S}\langle \texttt{dB}\rangle } \cap \; {\mathbb {S}\langle \mathtt {d!}\rangle }\text {-}\texttt{NF} \times \varLambda _{!}) \;\;\cup \;\; (\rightarrow _{\mathbb {S}\langle \mathtt {s!}\rangle } \cap \; {\mathbb {S}\langle \mathtt {d!}\text {-}\texttt{NF}\rangle } \times \varLambda _{!}) \;\;\cup \; \rightarrow _{\mathbb {S}\langle \mathtt {d!}\rangle } \\[0.2cm] \rightarrow _{\mathbb {F}\texttt{ad}} &{}:=&{} (\rightarrow _{\mathbb {F}\langle \texttt{dB}\rangle } \cap \; {\mathbb {F}\langle \mathtt {d!}\rangle }\text {-}\texttt{NF} \times \varLambda _{!}) \;\;\cup \;\; (\rightarrow _{\mathbb {F}\langle \mathtt {s!}\rangle } \cap \; {\mathbb {F}\langle \mathtt {d!}\text {-}\texttt{NF}\rangle } \times \varLambda _{!}) \;\;\cup \; \rightarrow _{\mathbb {F}\langle \mathtt {d!}\rangle } \end{array} \end{aligned}$$

Example 2

Consider the two surface reduction sequences \(\textsf{der}(!x)[x \backslash !y] \rightarrow _{\mathbb {S}\langle \mathtt {s!}\rangle } \textsf{der}(!y) \rightarrow _{\mathbb {S}\langle \mathtt {d!}\rangle } y\) and \(\textsf{der}(!x)[x \backslash !y] \rightarrow _{\mathbb {S}\langle \mathtt {d!}\rangle } x[x \backslash !y] \rightarrow _{\mathbb {S}\langle \mathtt {s!}\rangle } y\). The first one is not diligent administrative, as the step \(\rightarrow _{\mathbb {S}\langle \mathtt {s!}\rangle }\) is performed in a term that is not \(\mathbb {S}\langle \mathtt {d!}\rangle \text {-}\texttt{NF}\). But the second one is diligent administrative: \(\textsf{der}(!x)[x \backslash !y] \rightarrow _{\mathbb {S}\texttt{ad}} x[x \backslash !y] \rightarrow _{\mathbb {S}\texttt{ad}} y\).

To show that every reduction sequence can be transformed into a diligent one (Lemma 3), we first observe that it is possible to perform all administrative steps from any term: indeed, reductions \(\rightarrow _{\mathbb {F}\langle \mathtt {d!}\rangle }\) and \(\rightarrow _{\mathbb {S}\langle \mathtt {d!}\rangle }\) are terminating, because each administrative step erase two constructors, \(\textsf{der}\) and \(!\), so the term size decreases.

Some reduction sequences can be made diligent, as in Example 2, but this is not the case for all reduction sequences. For instance \(\textsf{der}(!x)[x \backslash !y] \rightarrow _{\mathbb {S}} \textsf{der}(!y)\) but \(\textsf{der}(!x)[x \backslash !y] \not \rightarrow _{\mathbb {S}\texttt{ad}} \textsf{der}(!y)\). Therefore, we focus solely on reduction sequences reaching terms that are normal for \(\texttt {d!} \). Under these conditions and by commuting computational steps with administrative ones, we obtain the following results:

Lemma 3

(Diligence Process). Let \(t, u \in \varLambda _{!}\) be terms.

  • (Surface)   If \(t \rightarrow ^{*}_\mathbb {S} u\) and u is a \(\mathbb {S}\langle \mathtt {d!}\rangle \text {-}\texttt{NF}\), then \(t \rightarrow ^*_{\mathbb {S}\texttt{ad}} u\).

  •      (Full)           If \(t \rightarrow ^{*}_\mathbb {F} u\) and u is a \(\mathbb {F}\langle \mathtt {d!}\rangle \text {-}\texttt{NF}\), then \(t \rightarrow ^{*}_{\mathbb {F}\texttt{ad}} u\).

3 Call-by-Name and Call-by-Value Embeddings

In this section we present the call-by-name dCBN (Sect. 3.1) and call-by-value dCBV (Sect. 3.2) calculi, as well as their embeddings into dBANG, which preserve static properties (Corollaries 7.2 and 9.2 for dCBN, 13.2 and 14.2 for dCBV) and dynamic ones (Corollaries 7.3 and 9.3 for dCBN, 13.3 and 14.3 for dCBV).

Both dCBN  [2, 9, 10] and dCBV  [11] are specified using ES and action at a distance, as explained in Sect. 1, and they share the same term syntax. The sets \(\varLambda \) of terms and \(\varUpsilon \) of values are inductively defined below.

$$\begin{aligned} {\textbf {(Terms)}} \ \ t, u \;::=\; v \;|\;t\,u \;|\;t[x \backslash u] {\textbf {(Values)}} \ \ v \;::=\; x \;|\;\lambda x.t \end{aligned}$$

Note that the syntax contains neither \(\textsf{der}\) nor \(!\). The distinction between terms and values is irrelevant in dCBN but crucial in dCBV. The two calculi also share the same full contexts \(\texttt{F}\) and list contexts \(\texttt{L}\), which can be seen as terms with exactly one hole \(\diamond \) and are inductively defined below. The differences between dCBN and dCBV are in the definitions of surface contexts and rewrite rules.

$$\begin{aligned} {\textbf {(List Contexts)}} \qquad \quad \texttt{L}&\;::= \diamond \;|\;\texttt{L}[x \backslash t] \\ {\textbf {(Full Contexts)}}\qquad \quad \texttt{F}&\;::= \diamond \;|\;\texttt{F}\,t \;|\;t\,\texttt{F} \;|\;\lambda x.\texttt{F} \;|\;\texttt{F}[x \backslash t] \;|\;t[x \backslash \texttt{F}] \end{aligned}$$

3.1 The Call-by-Name Calculus dCBN and Its Embedding to dBANG

In dCBN, surface contexts \(\texttt{S}_\texttt{N}\in \mathbb {S}_\texttt{N}\) are defined below: the hole cannot be in the argument of an application or ES. To align the notations, in dCBN full contexts are denoted by \(\texttt{F}_\texttt{N}\in \mathbb {F}_\texttt{N}\) and list contexts by \(\texttt{L}_\texttt{N}\in \mathbb {L}_\texttt{N}\).

$$\begin{aligned} {\textbf {(}}\texttt {dCBN} ~{\textbf {Surface Contexts)}} \qquad \, \texttt{S}_\texttt{N}&\;::= \diamond \;|\;\texttt{S}_\texttt{N}\,t \;|\;\lambda x.\texttt{S}_\texttt{N} \;|\;\texttt{S}_\texttt{N}[x \backslash t] \end{aligned}$$

As explained in Sect. 1.1, reductions in \(\texttt {dCBN} \) are defined by taking the set of rewrite rules \(\{\texttt {dB}, \texttt {s} \}\) defined below and the sets of contexts \(\mathbb {S}_\texttt{N}\) and \(\mathbb {F}_\texttt{N}\).

$$\begin{aligned} \texttt{L}_\texttt{N}\langle \lambda {x}.{t}\rangle {u} \;\mapsto _{\texttt{dB}}\; \texttt{L}_\texttt{N}\langle t[x\backslash u]\rangle \qquad \qquad \quad t[x\backslash u] \mapsto _{\texttt{s}} t\{x\backslash u\} \end{aligned}$$

Rule dB is capture-free: no free variable of u is captured by the context \(\texttt{L}_\texttt{N}\). The dCBN surface reduction is the relation \(\rightarrow _{{\mathbb {S}}_\texttt{N}} \,:=\, \rightarrow _{{\mathbb {S}}_\texttt{N}\langle \texttt{dB}\rangle } \cup \rightarrow _{{\mathbb {S}}_\texttt{N}\langle \texttt{s}\rangle }\), while the dCBN full reduction is the relation \(\rightarrow _{{\mathbb {F}}_\texttt{N}} \,:=\, \rightarrow _{{\mathbb {F}}_\texttt{N}\langle \texttt{dB}\rangle } \cup \rightarrow _{{\mathbb {F}}_\texttt{N}\langle \texttt{s}\rangle }\). E.g., for \(\texttt{F}_\texttt{N}= \lambda z.\diamond \), \(t_0 = \lambda z.((\lambda x.yxx)(zz)) \rightarrow _{{\texttt{F}}_\texttt{N}\langle \texttt{dB}\rangle } t_1 = \lambda z.((yxx)[x \backslash zz]) \rightarrow _{{\texttt{F}}_\texttt{N}\langle \texttt{s}\rangle } t_2 = \lambda z.(y(zz)(zz))\).

The dCBN surface reduction is nothing but (a non-deterministic but diamond variant of) the well-known head reduction.

Embedding dCBN into dBANG . The dCBN embedding \(\cdot ^\texttt {n} :\varLambda \rightarrow \varLambda _{!}\) from dCBN to dBANG, introduced in [18, 19] and presented below, extends Girard’s one [22] to ES.

$$\begin{aligned} x^\texttt {n} &:= x & (\lambda x.t)^\texttt {n} &:= \lambda x.t^\texttt {n} & (tu)^\texttt {n} &:= t^\texttt {n}\,!u^\texttt {n} & (t[x \backslash u])^\texttt {n} &:= t^\texttt {n}[x \backslash !u^\texttt {n}]. \end{aligned}$$

As an example, \((yx)[y \backslash z]^\texttt {n} = (y!x)[y \backslash !z]\). Note that \(\cdot ^\texttt {n}\) never introduces \(\textsf{der}\), hence \(t^\texttt {n}\), and every term it reduces to, are always a \(\mathbb {F}\langle \mathtt {d!}\rangle \text {-}\texttt{NF}\) (this does not hold for the dCBV embedding, Sect. 3.2). In every application and ES, \(\cdot ^\texttt {n}\) puts a \(!\) in front of their argument, which shows the two roles—called duplicability and accessibility—played by \(!\) in this embedding: dCBN duplicability means that any argument can be duplicated (or erased), dCBN accessibility means that surface reduction cannot take place inside arguments. Indeed, the \(!\) seals all subterms in argument position.

The embedding is trivially extended to dCBN contexts by setting \(\diamond ^\texttt {n} = \diamond \).

The static properties of this embedding have already been partially discussed in [18, 19]. We will revisit and refine them (Corollaries 7, 9 and 23), but our main focus lies in the preservation of the dynamics of dCBN within dBANG. For that, we first extend the embedding to rule names, by defining \(\texttt {dB} ^\texttt {n} \;:=\; \texttt {dB} \) and \(\texttt {s} ^\texttt {n} \;:=\; \texttt {s!} \).

The reduction of a dCBN redex can be effectively simulated in dBANG by reducing the corresponding redex occurring at the translated location/context.

Lemma 4

(dCBN  One-Step Simulation). Let \(t, u \in \varLambda \) and \(\texttt{F}_\texttt{N}\in \mathbb {F}_\texttt{N}\) and \(\mathcal {R}\in \{\texttt {dB}, \texttt {s} \}\). If \(t \rightarrow _{{\texttt{F}}_\texttt{N}\langle \mathcal {R}\rangle } u\) then \(t^\texttt {n} \rightarrow _{\texttt{F}_\texttt{N}^\texttt {n}\langle {\mathcal {R}^n}\rangle } u^\texttt {n}\).

Example 5

Consider the dCBN reductions \(t_0 \rightarrow _{{\texttt{F}}_\texttt{N}\langle \texttt{dB}\rangle } t_1\) and \(t_1 \rightarrow _{{\texttt{F}}_\texttt{N}\langle \texttt{s}\rangle } t_2\) seen above with \(\texttt{F}_\texttt{N}= \lambda z.\diamond \). Since \( \texttt{F}_\texttt{N}^\texttt {n} = \lambda z.\diamond \), we have \(t_0^\texttt {n} = \lambda z.((\lambda x.y!x!x)!(z!z) ) \rightarrow _{\texttt{F}_\texttt{N}^\texttt {n}\langle {\mathcal {R}^n}\rangle } \lambda z.((y\,!x!x)[x \backslash !(z!z)] ) = t_1^\texttt {n}\) and \(t_1^\texttt {n} \rightarrow _{\texttt{F}_\texttt{N}^\texttt {n}\langle {\mathtt {s!}}\rangle } \lambda z.(y !(z!z)!(z!z) ) = t_2^\texttt {n}\).

So, every dCBN reduction step is simulated by the corresponding dBANG reduction step, without the need for any administrative step. Simulation of \(\texttt {dCBV} \) (Lemma 11) is instead more involved, requiring some further administrative steps.

The following property, which effectively reverses the simulation process, extends the one holding for the original Bang Calculus (without distance) [30].

Lemma 6

(dCBN  One-Step Reverse Simulation). Let \(t \in \varLambda \), \(u' \in \varLambda _{!}\), \(\texttt{F}\in \mathbb {F}\) and \(\mathcal {R}' \in \{\texttt {dB}, \texttt {s!}, \texttt {d!} \}\).

$$\begin{aligned} t^\texttt {n} \rightarrow _{\texttt{F}\langle \mathcal {R}'\rangle } u' \quad \implies \quad \left\{ \begin{array}{l@{}l} \exists \; u \in \varLambda , &{} u^\texttt {n} = u' \\ \exists \; \mathcal {R}\in \{\texttt {dB}, \texttt {s} \}, &{} \mathcal {R}^\texttt {n} = \mathcal {R}' \\ \exists \; \texttt{F}_\texttt{N}\in \mathbb {F}_\texttt{N}, &{}\texttt{F}_\texttt{N}^\texttt {n} = \texttt{F}\end{array}\right\} \text { such that } t \rightarrow _{{\texttt{F}}_\texttt{N}\langle \mathcal {R}\rangle } u. \end{aligned}$$

Lemma 6 states that any dBANG step from the image \(t^\texttt {n}\) of a dCBN term t (which is necessarily diligent, because \(t^\texttt {n}\) is a \(\texttt{F}\langle \mathtt {d!}\rangle \text {-}{} \texttt {NF}\)) actually simulates a dCBN step from t. In Example 5, \(t_0^\texttt {n}\) \(\texttt {dB} \)-reduces in the context \(\texttt{F}= \lambda z.\diamond \) to \(\lambda z.((y\,!x!x)[x \backslash !(z!z)])\), which is indeed equal to \(t_1^\texttt {n}\), and \(t_0 \rightarrow _{{\texttt{F}}_\texttt{N}\langle \texttt{dB}\rangle } t_1\) in the context \(\texttt{F}_\texttt{N}= \lambda z.\diamond \) as well, with \(\texttt{F}_\texttt{N}^\texttt {n} = \texttt{F}\). Note that Lemma 6 is vacuously true for \(\mathcal {R}= \texttt {d!} \), since there is no term t such that \(\textsf{der}\) occurs in \(t^\texttt {n}\). Lemmas 4 and 6 have some significant consequences:

Corollary 7

Let \(t, u \in \varLambda \) and \(s' \in \varLambda _{!}\).

  1. 1.

    (Stability): if \(t^\texttt {n} \rightarrow ^{*}_\mathbb {F} s'\) then there is \(s \in \varLambda \) such that \(s^\texttt {n} = s'\).

  2. 2.

    (Normal Forms): t is a \(\mathbb {F}_\texttt{N}\text {-}\texttt{NF}\) if and only if \(t^\texttt {n}\) is a \(\mathbb {F}\text {-}\texttt{NF}\).

  3. 3.

    (Simulations): \(t \rightarrow ^{*}_{{\mathbb {F}}_\texttt{N}} u\) if and only if \(t^\texttt {n} \rightarrow ^{*}_\mathbb {F} u^\texttt {n}\). Moreover, the number of \(\texttt {dB}/\texttt {s} \)-steps on the left matches the number \(\texttt {dB}/\texttt {s!} \)-steps on the right.

These results deserve some comments. Point 1 states that the image of the dCBN embedding is stable under reduction. However, it is not stable under expansion. For instance, \(\textsf{der}(!x) \rightarrow _S x = x^\texttt {n}\), although \(\textsf{der}(!x)\) does not belong to the embedding’s image, which only contains terms without \(\textsf{der}\). Point 2 guarantees the preservation of normal forms in both directions. Finally, Point 3 concerns the preservation of reduction sequences. It is worth highlighting that this is an equivalence, enabling to inject reduction sequences from dCBN into dBANG and project them back from dBANG into dCBN. This is a key property allowing in particular to infer confluence and factorization for \(\texttt {dCBN} \) from that for \(\texttt {dBANG} \).

The reader may wonder whether similar preservation results hold for surface reduction. Since it is a subreduction of full reduction, Corollary 7.1 already implies stability for surface reduction. However, it does not imply preservation of surface normal forms, and only yields back and forth simulation of surface reduction via full reduction, which is not exactly what we want: \(t^\texttt {n} \rightarrow ^{*}_\mathbb {F} u^\texttt {n}\) if \(t \rightarrow ^*_{{\mathbb {S}}_\texttt{N}} u\), and \(t \rightarrow ^{*}_{{\mathbb {F}}_\texttt{N}} u\) if \(t^\texttt {n} \rightarrow ^{*}_\mathbb {S} u^\texttt {n}\). So let us come back to analyze the situation for the one-step simulation and reverse simulation. Since surface contexts are special cases of full contexts, then \(t \rightarrow _{{\texttt{S}}_\texttt{N}\langle \mathcal {R}\rangle } u\) implies \({t}^\texttt{n} \rightarrow _{{\texttt{S}}^\texttt{n}_\texttt{N}\langle \mathcal {R}^n\rangle }\,u^n\) by Lemma 4. To prove that this simulating step is actually a surface step, we need an additional property: that dCBN surface contexts are translated into dBANG surface contexts (Lemma 8.1). A more subtle analysis will be required for surface reverse simulation: positions of dBANG surface redexes are always in the image of dCBN surface contexts:

Lemma 8

 

  1. 1.

    (dCBN \(\rightarrow \) dBANG) If \(\texttt{S}_\texttt{N}\in \mathbb {S}_\texttt{N}\), then \(\texttt{S}_\texttt{N}^\texttt {n} \in \mathbb {S}\).

  2. 2.

    (dBANG \(\rightarrow \) dCBN) If \(\texttt{S}\in \mathbb {S}\) and \(\texttt{F}_\texttt{N}\in \mathbb {F}_\texttt{N}\) such that \(\texttt{F}_\texttt{N}^\texttt {n} = \texttt{S}\), then \(\texttt{F}_\texttt{N}\in \mathbb {S}_\texttt{N}\).

Thanks to Lemma 8, one-step simulation and reverse simulation (Lemmas 4 and 6) can be iterated to obtain the following results about surface reduction.

Corollary 9

Let \(t, u \in \varLambda \) and \(s' \in \varLambda _{!}\).

  1. 1.

    (Stability): if \(t^\texttt {n} \rightarrow ^{*}_\mathbb {S} s'\) then there is \(s \in \varLambda \) such that \(s^\texttt {n} = s'\).

  2. 2.

    (Normal Forms): \(t \text { is a } \mathbb {S}_\texttt{N}\text {-}\texttt{NF}\) if and only if \(t^\texttt {n}\) is a \(\mathbb {S}\text {-}\texttt{NF}\).

  3. 3.

    (Simulations): \(t \rightarrow ^*_{{\mathbb {S}}_\texttt{N}} u\) if and only if \(t^\texttt {n} \rightarrow ^{*}_\mathbb {S} u^\texttt {n}\). Moreover, the number of \(\texttt {dB}/\texttt {s} \)-steps on the left matches the number of \(\texttt {dB}/\texttt {s!} \)-steps on the right.

Our results for dCBN notably extend the ones in [18, 19], where it was only shown that \(\texttt{N}\text {-}\texttt{NF}\) translates to \(\mathbb {S}\text {-}\texttt{NF}\), and that dCBN surface reduction is simulated by dBANG surface reduction: we went further by encompassing their converses.

3.2 The Call-by-Value Calculus dCBV and Its Embedding into dBANG

In dCBV, surface contexts \(\texttt{S}_\texttt{V}\in \mathbb {S}_\texttt{V}\) are defined below: the hole cannot be under an abstraction. To align the notations, in dCBV full contexts are denoted by \(\texttt{F}_\texttt{V}\in \mathbb {F}_\texttt{V}\) and list contexts by \(\texttt{L}_\texttt{V}\in \mathbb {L}_\texttt{V}\).

figure a

As explained in Corollary1.1, reductions in \(\texttt {dCBV} \) are defined by taking the set of rewrite rules \(\{\texttt {dB}, \texttt {sV} \}\) defined below and the sets of contexts \(\mathbb {S}_\texttt{V}\) and \(\mathbb {F}_\texttt{V}\).

$$\begin{aligned} \texttt{L}_\texttt{V}\langle \lambda {x}.{t}\rangle ~{u} \;\mapsto _{\texttt{dB}}\; \texttt{L}_\texttt{V}\langle t[x\backslash u]\rangle \qquad \qquad \quad t[x\backslash \texttt{L}_\texttt{V} \langle v\rangle ] \mapsto _{\texttt{sV}} \texttt{L}_\texttt{V} \langle t\{x\backslash v\}\rangle \end{aligned}$$

Rule dB (resp. sV) is capture-free: no free variable of u (resp. t) is captured by context \(\texttt{L}_\texttt{V}\). The dCBV surface reduction is the relation \(\rightarrow _{{\mathbb {S}}_\texttt{V}} \,:=\, \rightarrow _{{\mathbb {S}}_\texttt{V}\langle \texttt{dB}\rangle } \cup \rightarrow _{{\mathbb {S}}_\texttt{V}\langle \texttt{sV}\rangle }\), while the dCBV full reduction is the relation \(\rightarrow _{{\mathbb {F}}_\texttt{V}} \,:=\, \rightarrow _{{\mathbb {F}}_\texttt{V}\langle \texttt{dB}\rangle } \cup \rightarrow _{{\mathbb {F}}_\texttt{V}\langle \texttt{sV}\rangle }\).

The calculi dCBN and dCBV differ in that dCBN can always fire an ES (rule \(\texttt {s} \)), while dCBV only does when the ES argument is a value, possibly wrapped by a finite list of ES (rule \(\texttt {sV} \)). So e.g., for \(\texttt{S}_\texttt{V}= (yxx)[x \backslash \diamond ]\), we have:

$$\begin{aligned} \begin{aligned} u_0 &= (\lambda x.yxx)((\lambda z.z)y) \rightarrow _{\diamond \,\langle {dB}\rangle } u_1 = (yxx)[x \backslash (\lambda z.z)y] \\ &\rightarrow _{{\texttt{S}}_{\texttt{V}}\langle \texttt{dB}\rangle } u'_1 = (yxx)[x \backslash z[z \backslash y]] \rightarrow _{\texttt{S}_\texttt{V}{\langle \texttt{sV}\rangle }} u_2 = (yxx)[x \backslash y] \rightarrow _{\diamond \,\langle {\texttt{sV}}\rangle } u_3 = yyy \end{aligned} \end{aligned}$$
(1)

Reduction at a distance in dCBV fires redexes that are blocked in Plotkin’s CBV [46]. For instance, given \(\delta := \lambda z. zz\), the term \(t := (\lambda y. \delta ) (xx) \delta \) is a normal form in Plotkin’s CBV, but is non-terminating in dCBV: \(t \rightarrow _{{\mathbb {S}}_\texttt{V}} \delta [y \backslash xx] \delta \rightarrow _{{\mathbb {S}}_\texttt{V}} (zz)[z \backslash \delta ] [y \backslash xx] \rightarrow _{{\mathbb {S}}_\texttt{V}}(\delta \delta )[y \backslash xx] \rightarrow ^{*}_{{\mathbb {S}}_\texttt{V}} (\delta \delta )[y \backslash xx]\), as one would expect, since t is observationally equivalent to the diverging term \(\delta \delta \) in CBV [6, 8, 20, 44, 48].

The dCBV surface reduction is nothing but the well-known weak reduction that does not evaluate under abstractions.

Embedding dCBV into dBANG . Values (i.e., variables and abstractions) are the erasable and duplicable terms of dCBV. Girard’s CBV encoding (used in [22, 30], noted here) is built upon this insight, placing a bang in front of each variable and abstraction . The encoding of an application is , where the \(\textsf{der}\) is used to enable a \(\texttt {d!} \)-step if t (the left-hand side of the application) is a value, so as to restore its functional role. However, as highlighted in [18, 19], such a definition fails normal forms preservation: a dCBV normal form is not necessarily encoded by a dBANG normal form, for example given the normal term \(t_0 = xy\) we have which is not normal. Consequently, [18, 19] proposed an alternative encoding (noted here, whose details are omitted for lack of space), based on the same principle, but with an additional super-development: all \(\texttt {d!} \)-redexes appearing during the encoding on the left of an application are eliminated on the fly, so that the embedding preserves normal forms (e.g., , which is normal in dBANG). But, as shown in Fig. 1, breaks reverse simulation with respect to surface reduction.

Fig. 1.
figure 1

Counterexample to dCBV reverse simulation using the embedding

We introduce a new dCBV embedding that preserves normal forms and fulfills simulation and reverse simulation (this is one of our main contributions).

Definition 10

The dCBV embedding \(\cdot ^\texttt {v} :\varLambda \rightarrow \varLambda _{!}\) is defined as follows:

figure l

Note that, thanks to super-development, \(t^\texttt {v}\) is always a \(\mathbb {F}\langle \mathtt {d!}\rangle \text {-}\texttt{NF}\). For instance, \((\lambda z.z)^\texttt {v} =\,!\lambda z.!!z\) and \((yxx)^\texttt {v} = \textsf{der}\big (\textsf{der}(\textsf{der}(y !x))!x\big )\), whereas \(((\lambda x.yxx)(II))^\texttt {v} = \textsf{der}\big (\big (\lambda x.!\textsf{der}(\textsf{der}(\textsf{der}(y !x))!x)\big )\, \textsf{der}((\lambda z.!!z)!\lambda z.!!z)\big )\) where \(I = \lambda z.z\).

As in the dCBN embedding, the modality \(!\) plays a twofold role in our new dCBV embedding. First, \(\cdot ^\texttt {v}\) marks with \(!\) subterms to be considered as values, i.e. potentially erasable or duplicable. This induces the use of super-developments in the case of applications to avoid some administrative steps that would otherwise affect preservation of normal forms. Second, \(\cdot ^\texttt {v}\) marks the positions where surface reduction must not occur: inside values; thus it introduces a second (internal) \(!\) in the encoding of abstractions to encapsulate its body and shield it from surface computation. Additionally, to restore access to the abstraction’s body when it is applied, a second (external) \(\textsf{der}\) is added to the encoding of applications. These two principles highlights the dual role of \(!\) in dBANG: enabling duplication (and erasure) as well as isolating subterms from surface computation processes.

The dCBV embedding is extended to rule names, by defining \(\texttt {dB} ^\texttt {v} := \texttt {dB} \) and \(\texttt {sV} ^\texttt {v} := \texttt {s!} \). Similarly to dCBN, we have the fundamental simulation result below.

Lemma 11

(dCBV  One-Step Simulation). Let \(t, u \in \varLambda _{!}\), and \(\mathcal {R}\in \{\texttt {dB}, \texttt {sV} \}\). If \(t \rightarrow _{{\texttt{F}_\texttt{V}}\langle \mathcal {R}\rangle } u\) then there is \( \texttt{F}\in \mathbb {F}\) such that \(t^\texttt{V} \rightarrow _{\texttt{F}\langle \mathcal {R}^\texttt{V}\rangle } \rightarrow ^{*}_{\mathbb {F}\langle \mathtt {d!}\rangle } u^\texttt {v}\), where \(\texttt{F}\) and all contexts used for the steps in \(\rightarrow ^{*}_{\mathbb {F}\langle \mathtt {d!}\rangle }\) can be specified using \(\texttt{F}_\texttt{V}^\texttt {v}, \mathcal {R}\) and t.

Let us see how \(\texttt{F}\) and the contexts used in the steps \(\rightarrow ^{*}_{\mathbb {F}\langle \mathtt {d!}\rangle }\) are constructed: it highlights the difference between Lemma 11 for dCBV and Lemma 4 for dCBN.

  • Additional administrative steps (\(\rightarrow ^{*}_{\mathbb {F}\langle \mathtt {d!}\rangle }\)) may be needed at the end. For example, for the dCBV steps \(u_0 \rightarrow _{{\mathbb {F}}_\texttt{V}\langle \texttt{dB}\rangle } u_1\) and \(u_2 \rightarrow _{{\mathbb {F}}_\texttt{V}\langle \texttt{sV}\rangle } u_3\) seen in (1), we have:

    $$\begin{aligned} u_0^\texttt {v} &= \textsf{der}\big (\big (\lambda x.!\textsf{der}(\textsf{der}(\textsf{der}(y !x))\, !x)\big )\, \textsf{der}((\lambda z.!!z)!y)\big ) \nonumber \\ &\rightarrow _{\mathbb {F}\langle \texttt{dB}\rangle } \textsf{der}\big (\, !\textsf{der}(\textsf{der}(\textsf{der}(y !x))\, !x){\, [x \backslash \textsf{der}((\lambda z.!!z)!y)]}\,\big ) = s' \\ &\rightarrow _{\mathbb {F}\langle \mathtt {d!}\rangle } \textsf{der}(\textsf{der}(\textsf{der}(y !x))\, !x){ \, [x \backslash \textsf{der}((\lambda z.!!z)!y)]} = u_1^\texttt {v} \nonumber \\ u_2^\texttt {v} &= \textsf{der}\big ( \textsf{der}(\textsf{der}(y !x))\, !x \big ){[x \backslash !y]} \rightarrow _{\mathbb {F}\langle \mathtt {s!}\rangle } \textsf{der}\big (\textsf{der}(\textsf{der}(y\,!y))\,!y\big ) = u_3^\texttt {v} \nonumber \end{aligned}$$
    (2)
  • In dCBN one-step simulation the rule name and context are independently translated. It is slightly more subtle in dCBV: the rule name translates to the corresponding one in dBANG without any ambiguity, yet the translation of the context \(\texttt{F}_\texttt{V}\) depends not only on the initial context \(\texttt{F}_\texttt{V}\) but also on the rule name \(\mathcal {R}\) and the initial term t. Two distinct situations can emerge:

    • \(\texttt {dB} \)-steps require to add a dereliction to the translated context: for example, the \(\texttt {dB} \)-redex position \(\diamond \) in \(t = (\lambda x.x)y\) needs to be translated to the redex position \(\textsf{der}(\diamond )\) in \(t^\texttt {v} = \textsf{der}((\lambda x.!x)!y)\).

    • \(\texttt {sV} \)-steps may need to remove a dereliction from the translated context: for instance, the \(\texttt {sV} \)-redex position \(\diamond \,y\) in \(t = (\lambda z.x)[x \backslash y]\,y\) is translated to the redex position \(\textsf{der}(\diamond \,!y)\) in \(t^\texttt {v} = \textsf{der}((\lambda z.!x)[x \backslash !y]\,(!y))\). The context translation anticipates the super-development used in \(t^\texttt {v}\).

    Note that both situations can be detected by case-analysis on \(\mathcal {R}\) and t, where the target context translation is a slight variation over the original one.

While the dCBV embedding used in [18, 19] successfully enables the simulation of dCBV into dBANG, it falls short when it comes to reverse simulation, as shown in Fig. 1. Therefore, cannot be used to transfer dynamic properties from dBANG back to dCBV, thus failing in particular to derive dCBV factorization from dBANG (Sect. 5). Our new embedding instead satisfies reverse simulation.

Lemma 12

(dCBV  One-Step Reverse Simulation). Let \(t \in \varLambda \), \(u' \in \varLambda _{!}\), \(\texttt{F}\in \mathbb {F}\) and \(\mathcal {R}' \in \{\texttt {dB}, \texttt {s!}, \texttt {d!} \}\). If \(u'\) is a \(\mathbb {F}\langle \mathtt {d!}\rangle \text {-}\texttt{NF}\), then

$$\begin{aligned} t^\texttt {v} \rightarrow _{F\langle \mathcal {R}'\rangle }\rightarrow ^{*}_{\mathbb {F}\langle \mathtt {d!}\rangle } u' \ \implies \ \left\{ \begin{array}{lr} \exists \; u \in \varLambda , &{}u^\texttt {v} = u' \\ \exists \; \mathcal {R}\in \{\texttt {dB}, \texttt {sV} \}, &{}\mathcal {R}^\texttt {v} = \mathcal {R}' \\ \exists \; \texttt{F}_\texttt{V}\in \mathbb {F}_\texttt{V}, \end{array}\right\} \text { such that } t \rightarrow _{\texttt{F}_\texttt{V}\langle \mathcal {R}\rangle } u. \end{aligned}$$

Lemma 12 states that any dBANG diligent step from the image \(t^\texttt {v}\) of a dCBV term t actually simulates a dCBV step from t. As expected, the same subtleties encountered in the dCBV one-step simulation (Lemma 11) apply in this last result, in particular regarding the construction of \(\texttt{F}_\texttt{V}\). In the dCBN case, the absence of administrative steps renders all sequences from images of dCBN terms diligent, making stability, normal form preservation and simulations direct consequences of one-step simulation (Lemma 4) and reverse simulation (Lemma 6). This is not the case for dCBV, due to the presence of administrative steps in the simulation process. Indeed, when simulating dCBV reduction within dBANG (Lemma 11), administrative steps are performed as soon as they become available, thus constructing a diligent sequence. Conversely, projecting a reduction step from dBANG to dCBV (Lemma 12) requires a diligent step. However, in the case of sequences, in contrast to one-steps, there is no requirement for administrative steps to be correctly synchronized, and this may lead to deviations from the embedding’s image, significantly complicating reverse simulation. Fortunately, the diligence presented in dBANG (Lemma 3) resynchronizes administrative steps yielding sequences that are easy to project.

Corollary 13

Let \(t, u \in \varLambda \) and \(s' \in \varLambda _{!}\).

  1. 1.

    (Stability): if \(t^\texttt {v} \rightarrow ^{*}_\mathbb {F} s'\) and \(s'\) is a \(\mathbb {F}\langle \mathtt {d!}\rangle \text {-}\texttt{NF}\), then \(s' = s^\texttt {v}\) for some \(s \in \varLambda \).

  2. 2.

    (Normal Forms): \(t \text { is a }\mathbb {F}_\texttt{V}\text {-}\texttt{NF}\) if and only if \(t^\texttt {v}\) is a \(\mathbb {F}\text {-}\texttt{NF}\).

  3. 3.

    (Simulations): \(t \rightarrow ^{*}_{{\mathbb {F}}_\texttt{V}} u\) if and only if \(t^\texttt {v} \rightarrow ^{*}_\mathbb {F} u^\texttt {v}\). Moreover, the number of \(\texttt {dB}/\texttt {sV} \)-steps on the left matches the number \(\texttt {dB}/\texttt {s!} \)-steps on the right.

As in dCBN, we may wonder whether similar preservation results hold for surface reductions. Such results cannot be entirely derived out from Corollary 13 alone. Still, as with dCBN, the dCBV one-step simulation and reverse simulation properties (Lemmas 11 and 12) already encompass the surface case. However, even though surface redexes positions are mutually mapped by the embedding, it does not yet imply surface stability, preservation of normal forms, and simulations. As previously explained, diligence is required to deal with administrative steps. Fortunately, the surface fragment admits a diligence process, as illustrated in Lemma 3, which can then be leveraged to obtain the following results.

Corollary 14

Let \(t, u \in \varLambda \) and \(s' \in \varLambda _{!}\).

  1. 1.

    (Stability): if \(t^\texttt {v} \rightarrow ^{*}_\mathbb {S} s'\) and \(s'\) is a \(\mathbb {S}\langle \mathtt {d!}\rangle \text {-}\texttt{NF}\), then \(s' = s^\texttt {v}\) for some \(s \in \varLambda \).

  2. 2.

    (Normal Forms): \(t \text { is a }\mathbb {S}_\texttt{V}\text {-}\texttt{NF}\) if and only if \(t^\texttt {v}\) is a \(\mathbb {S}\text {-}\texttt{NF}\).

  3. 3.

    (Simulations): \(t \rightarrow ^{*}_{{\mathbb {S}}_\texttt{V}} u\) if and only if \(t^\texttt {v} \rightarrow ^{*}_\mathbb {S} u^\texttt {v}\). Moreover, the number of \(\texttt {dB}/\texttt {sV} \)-steps on the left matches the number of \(\texttt {dB}/\texttt {s!} \)-steps on the right.

Stability statements in dCBV (Corollary 13.1 and 14.1) require the reached term \(s'\) to be normal for \(\texttt {d!} \), otherwise stability does not hold (e.g., \(s'\) in (2) before is not in the image of \(\cdot ^\texttt {v}\)), This is not required in the dCBN stability statements (Corollary 7.1 and 9.1) since every term to which \(t^\texttt {n}\) reduces is \(\textsf{der}\)-free and so normal for \(\texttt {d!} \).

Proving simulation and reverse simulation requires a considerable effort. But this initial investment, made once and for all, lays the groundwork for numerous benefits without extra costs. For example, in Sects. 4 and 5, we demonstrate that typically challenging tasks like proving confluence and factorization in dCBN and dCBV can be easily achieved by deriving them from dBANG through simulation and reverse simulation, essentially for free. This approach not only unifies the proofs but also minimizes the workload for future proofs.

4 Confluence

Confluence is a crucial property in \(\lambda \)-calculi, ensuring that every term can reduce to at most one normal form, regardless of the chosen reduction path. In this section, we examine confluence of different reductions (surface and full) in the three calculi we considered: dCBN, dCBV, and dBANG. We specifically leverage simulation and reverse simulation properties to project these results from dBANG to dCBN and dCBV, providing a comprehensive solution across three frameworks.

Surface confluence is usually proved by showing that surface reduction is diamond, as for example in [18, 19]. Full confluence is more complex, since full reduction is not diamond, as one can easily see in dBANG with the term \((xx) [x \backslash !(II)]\) where \(I := \lambda z.z\). Alternative techniques [43, 52] can establish full reduction’s confluence, albeit often requiring numerous commutation diagrams and possibly non-trivial decreasing measures.

Theorem 15

(dBANG  Confluence).

  1. 1.

    (Surface) The reduction \(\rightarrow _{\mathbb {S}}\) is diamond and confluent. Moreover, any two surface reduction paths from a given term to a \(\mathbb {S}\)-normal form have the same length and number of \(\texttt {dB} \), \(\texttt {s!} \) and \(\texttt {d!} \)-steps.

  2. 2.

      (Full)   The reduction \(\rightarrow _{\mathbb {F}}\) is confluent.

Proof

(Surface) See [18, 19]. (Full) See [34].

These proofs are typically highly technical, requiring a significant amount of time to write and of cases to verify, and are prone to errors. Therefore, it is extremely beneficial to have a method to streamline them, especially when mechanizing proofs. With the robust preservation of dCBN reductions in the dBANG, we can actually project dCBN confluences directly from those of dBANG.

Corollary 16

(dCBN  Confluence).

  1. 1.

    (Surface) The reduction \(\rightarrow _{{\mathbb {S}}_\texttt{N}}\) is diamond and confluent. Moreover, any two surface reduction paths from a given term to a \(\mathbb {S}_\texttt{N}\)-normal form have the same length and same number of \(\texttt {dB} \) and \(\texttt {s} \)-steps.

  2. 2.

      (Full)   The reduction \(\rightarrow _{{\mathbb {F}}_\texttt{N}}\) is confluent.

Proof

(Surface) See Fig. 2. (Full) Following the same reasoning as Fig. 3.

Fig. 2.
figure 2

Schematic proof of Corollary 16.1

Fig. 3.
figure 3

Schematic proof of Corollary 17.2

The same technique can be used for dCBV, with the additional help of diligence (Corollary 13.1 and 14.1). Thus, we get the following results for free.

Corollary 17

(dCBV  Confluence).

  1. 1.

    (Surface) The reduction \(\rightarrow _{{\mathbb {S}}_\texttt{V}}\) is diamond and confluent. Moreover, any two surface reduction paths from a given term to a \(\mathbb {S}_\texttt{V}\)-normal form have the same length and same number of \(\texttt {dB} \) and \(\texttt {sV} \)-steps.

  2. 2.

      (Full)   The reduction \(\rightarrow _{{\mathbb {F}}_\texttt{V}}\) is confluent.

Proof

(Surface) Following the same reasoning as Fig. 2. (Full) See Fig. 3.

5 Factorization

In \(\lambda \)-calculi, reduction is a relation, so different reduction steps are possible starting from the same term. Some steps (e.g. head steps) are more significant than others, and they may occur in the middle of a reduction sequence. Factorization is the process of disentangling the significant steps from the “superfluous” ones, bringing the former forward and leaving the start and end terms unchanged.

This section is devoted to the factorization property for dBANG, dCBN and dCBV. We start by revisiting an abstract factorization theorem [2]. We first apply this abstract method to dBANG, thus obtaining a new result of factorization not previously appearing in the literature. Then, we use the properties of simulation and reverse simulation proved in Sect. 3 to project the factorization result for dBANG into dCBN and dCBV. Although these two results can be directly derived from the abstract factorization theorem [2], our approach circumvents the numerous commutation properties required by the abstract approach. Also, it provides a tangible illustration of how the simulation and reverse simulation properties discussed in Sects. 3.1 and 3.2 can be applied in concrete cases.

Abstract Factorization. We recall an abstract factorization method from [2] that relies on local rewrite conditions given by the notion of square factorization system (SFS). While its original presentation concerns only two subreductions, we (straightforwardly) extend the notion of SFS to a family of subreductions, as in dBANG the reduction consists of more than two subreductions.

Definition 18

Let \(\mathcal {R} = (R,\, \rightarrow _\mathcal {R})\) be an abstract rewriting system The family \(\left( \rightarrow _{{\mathcal {R}}^\circ _{k}}, \rightarrow _{{\mathcal {R}}^\bullet _k}\right) _{k \in K}\) of paired reduction relations is a square factorization system (SFS) for \(\mathcal {R}\) if it covers the reduction relation (i.e. \(\rightarrow _\mathcal {R}\;= \bigcup _{k \in K} \rightarrow \mathcal {R}_k\) where \(\rightarrow \mathcal {R}_k \,:=\, \rightarrow _{{\mathcal {R}}^\circ _k} \cup \rightarrow _{{\mathcal {R}}^\bullet _k}\)) and satisfies the following conditions:

  1. 1.

    Termination: \(\forall \, k \in K\), \(\rightarrow _{{\mathcal {R}}^\circ _k}\) is terminating.

  2. 2.

    Row-swaps: \(\forall \, k \in K\)\(\rightarrow _{{\mathcal {R}}^\bullet _k}\rightarrow _{{\mathcal {R}}^\circ _k} \;\subseteq \; \rightarrow ^+_{{\mathcal {R}}^\circ _k}\rightarrow ^*_{{\mathcal {R}}^\bullet _k}\).

  3. 3.

    Diagonal-swaps: \(\forall \, k_1, k_2 \in K\), \(k_1 \ne k_2\)\(\rightarrow _{{\mathcal {R}}^{\bullet }_{k_1}} \rightarrow _{{\mathcal {R}}^{\circ }_{k_2}} \;\subseteq \; \rightarrow _{{\mathcal {R}}^{\circ }_{k_2}} \rightarrow ^*_{{\mathcal {R}}_{k_1}}\).

The symbol \(\circ \) tags significant (also called external) steps, while \(\bullet \) is used for irrelevant (also called internal) ones. The commutations required in an SFS are sufficient to achieve factorization, which consists in rearranging a reduction sequence to prioritize significant steps \(\rightarrow _{{\mathcal {R}}^\circ }\) over irrelevant steps \(\rightarrow _\mathcal {R}^{\bullet }\).

Proposition 19

([2]). Let \(\mathcal {R} = (R, \rightarrow _\mathcal {R})\) be an abstract rewriting system and \((\rightarrow _{{\mathcal {R}}^\circ _k}, \rightarrow _{{\mathcal {R}}^\bullet _k})_{k \in K}\) be an SFS for \(\mathcal {R}\). Then the reduction relation factorizes, that is, \(\rightarrow ^*_\mathcal {R}\ \subseteq \ \rightarrow ^*_\circ \rightarrow ^*_\bullet \) where \(\rightarrow _\circ := \bigcup _{k \in K} \rightarrow _{{\mathcal {R}}^\circ _k}\) and \(\rightarrow _\bullet := \bigcup _{k \in K} \rightarrow _{{\mathcal {R}}^\bullet _k}\).

Factorization in dBANG . In dBANG we claim that surface reduction is the significant part of full reduction, and our goal is to factor it out. To exploit the abstract method, we first formally identify the irrelevant subreduction of full reduction, called here internal, as reduction under the scope of a \(!\). Internal contexts \(\texttt{I}\in \mathbb {I}\) are full contexts \(\mathbb {F}\) for which the hole is placed under a bang. Formally,

$$\begin{aligned} {\textbf {(}}\texttt {dBANG} ~{\textbf {Internal Contexts)}} \qquad \,\, \texttt{I}&\;:=\; !\texttt{F}\;|\;\texttt{S}^*\langle {\texttt{I}}\rangle \qquad \,\, \text {with } \texttt{S}^* \in \mathbb {S}\setminus \{\diamond \} \end{aligned}$$

Clearly, \(\mathbb {I}= \mathbb {F}\setminus \mathbb {S}\). As usual, \(\rightarrow _{\mathbb {I}\langle \mathcal {R}\rangle }\) is the closure of the rewrite rules \(\mathcal {R}\in \{\texttt {dB}, \texttt {s!}, \texttt {d!} \}\) over all contexts \(\texttt{I}\in \mathbb {I}\). The dBANG internal reduction is the relation \(\rightarrow _{\mathbb {I}} \, := \, \rightarrow _{\mathbb {I}\langle \texttt{dB}\rangle } \cup \rightarrow _{\mathbb {I}\langle \mathtt {s!}\rangle } \cup \rightarrow _{\mathbb {I}\langle \mathtt {d!}\rangle }\). For example, \((\lambda x.!\diamond )\,y \) is an internal context while \(\diamond \) is not. Thus, \((\lambda x.!(z[z \backslash x]))\,y \rightarrow _{\mathbb {I}\langle \mathtt {s!}\rangle } (\lambda x.!x)\,y \not \rightarrow _{\mathbb {I}} (!x)[x \backslash y]\). We can now show that surface and internal reductions enjoy the abstract properties of an SFS.

Lemma 20

The family \((\rightarrow _{\mathbb {S}\langle \mathcal {R}\rangle }, \rightarrow _{\mathbb {I}\langle \mathcal {R}\rangle })_{\mathcal {R}\in \{\texttt {dB}, \texttt {s!}, \texttt {d!} \}}\) is an SFS for \((\varLambda _{!}, \rightarrow _F)\).

This immediately gives the following novel factorization result for the Distant Bang Calculus, by applying Proposition 19 and Lemma 20.

Corollary 21

(dBANG  Factorization). We have that \(\rightarrow ^{*}_\mathbb {F} \;=\; \rightarrow ^{*}_\mathbb {S}\rightarrow ^*_\mathbb {I}\).

Example 22

Take \(t=(xy)[y \backslash !(I !!(I w))]\) where \(I = \lambda z.z\). Then, the factorization of the first sequence starting at t below, is given by the second one:

$$\begin{aligned}\begin{gathered} t \rightarrow _{\mathbb {F}} (xy)[y \backslash !(z[z \backslash !!(Iw)])] \rightarrow _{\mathbb {S}} x(z[z \backslash !!(Iw)]) \rightarrow _{\mathbb {F}} x(z[z \backslash !!(z[z \backslash w])]) \rightarrow _{\mathbb {S}} x!(z[z \backslash w]) \\ t \;\;\rightarrow _{\mathbb {S}}\;\; x(I!!(Iw)) \;\;\rightarrow _{\mathbb {S}}\;\; x(z[z \backslash !!(Iw)]) \;\;\rightarrow _{\mathbb {S}}\;\; x!(Iw) \;\;{\rightarrow _{\mathbb {I}}}\;\; x!(z[z \backslash w]) \end{gathered}\end{aligned}$$
Fig. 4.
figure 4

Schematic proof of Corollary 16.1

Fig. 5.
figure 5

Schematic proof of Corollary 17.2

Factorizations in dCBN and dCBV . To achieve factorization in dCBN and dCBV via the abstract method, we need to establish the existence of an SFS in each case. This requires validating multiple commutations. We bypass these lengthy proofs by adopting a simpler projection approach from dBANG.

As in dBANG, we claim that surface reduction is the significant part of full reduction in dCBN/dCBV, and we consequently identify the irrelevant subreduction, called here internal. The dCBN (resp. dCBV) internal contexts \(\texttt{I}_\texttt{N}\in \mathbb {I}_\texttt{N}\) (resp. \(\texttt{I}_\texttt{V}\in \mathbb {I}_\texttt{V}\)) are full contexts whose hole is in an argument (resp. under a \(\lambda \)). Formally,

$$\begin{aligned} {\textbf {(}}\texttt {dCBN} ~{\textbf {Internal Contexts)}} \qquad \texttt{I}_\texttt{N}&\;::=\; t\,\texttt{F}_\texttt{N} \;|\;t[x \backslash \texttt{F}_\texttt{N}] \;|\;\texttt{N}^*\texttt{N}{\texttt{I}_\texttt{N}} \qquad \text {with } \texttt{S}_\texttt{N}^* \in \mathbb {S}_\texttt{N}\setminus \{\diamond \} \\ {\textbf {(}}\texttt {dCBV} ~{\textbf {Internal Contexts)}} \qquad \texttt{I}_\texttt{V}&\;::=\; \lambda x.\texttt{F}_\texttt{V} \;|\;\texttt{S}^*_\texttt{V}\langle {\texttt{I}_\texttt{V}}\rangle \qquad \qquad \,\,\, \text {with } \texttt{S}_\texttt{V}^* \in \mathbb {S}_\texttt{V}\setminus \{\diamond \} \end{aligned}$$

The dCBN (resp. dCBV) internal reduction \(\rightarrow _{{\mathbb {I}}_\texttt{N}}\) (resp. \(\rightarrow _{{\mathbb {I}}_\texttt{V}}\)) is the closure over all internal contexts \(\texttt{I}_\texttt{N}\in \mathbb {I}_\texttt{N}\) (resp. \(\texttt{I}_\texttt{V}\in \mathbb {I}_\texttt{V}\)) of the rewrite rules dB and s (resp. dB and sV). For example, \((\lambda x.x)\diamond \) is a dCBN internal context, while \(\diamond \) is not, thus \((\lambda x.x)((\lambda y.z)t) \rightarrow _{{\mathbb {I}}_\texttt{N}} (\lambda x.x)z \not \rightarrow _{{\mathbb {I}}_\texttt{N}} z\). And \((\lambda x.\diamond )z\) is a dCBV internal context while \(\diamond \) is not, thus \((\lambda x.(\lambda y.y)z)z \rightarrow _{{\mathbb {I}}_\texttt{V}} (\lambda x.y[y \backslash z])z \rightarrow _{{\mathbb {I}}_\texttt{V}} (\lambda x.z)z \not \rightarrow _{{\mathbb {I}}_\texttt{V}} z[x \backslash z]\).

As in the surface case, the one-step simulation and reverse simulation (Lemmas 4 and 6 for dCBN, Lemmas 11 and 12 for dCBV) can be specialized to the internal case. This allows us to show in particular the following property.

Corollary 23

Let \(t, u \in \varLambda \) and \(s' \in \varLambda _{!}\).

  • (Stability): if \(t^\texttt {n} \rightarrow ^*_\mathbb {I} s'\) (resp. \(t^\texttt {v} \rightarrow ^*_\mathbb {I} s'\) and \(s'\) is a \(\mathbb {I}\langle \mathtt {d!}\rangle \text {-}\texttt{NF}\)) then there is \(s \in \varLambda \) such that \(s^\texttt {n} = s'\) (resp. \(s^\texttt {v} = s'\)).

  • (Normal Forms): \(t \text { is a } \mathbb {I}_{{\texttt{N}}}\text {-}\texttt{NF}\) (resp. \(\mathbb {I}_{{\texttt{V}}\text {-}\texttt{NF}}\)) iff \(t^\texttt {n}\) (resp. \(t^\texttt {v}\)) is a \(\mathbb {I}\text {-}\texttt{NF}\).

  • (Simulations): \(t \rightarrow ^{*}_{{\mathbb {I}}_\texttt{N}} u\) (resp. \(t \rightarrow ^{*}_{{\mathbb {I}}_\texttt{V}} u\)) iff \(t^\texttt {n} \rightarrow ^*_\mathbb {I} u^\texttt {n}\) (resp. \(t^\texttt {v} \rightarrow ^*_\mathbb {I} u^\texttt {v}\)). Moreover, the number of \(\texttt {dB}/\texttt {s} \)-steps (resp. \(\texttt {dB}/\texttt {sV} \)-steps) on the left matches the number of \(\texttt {dB}/\texttt {s!} \)-steps on the right.

Via Corollaries 9, 14 and 23, we can project factorization from dBANG back to dCBN/dCBV.

Theorem 24

(dCBN/dCBV  Factorizations). \(\rightarrow ^{*}_{{\mathbb {F}}_\texttt{N}} \,=\, \rightarrow ^*_{{\mathbb {S}}_\texttt{N}} \rightarrow _{{\texttt{I}}_\texttt{N}}\) and \(\rightarrow ^{*}_{{\mathbb {F}}_\texttt{V}} \,= \, \rightarrow ^{*}_{{\mathbb {S}}_\texttt{V}}\rightarrow ^{*}_{{\mathbb {I}}_\texttt{V}}\).

Proof

The proof for dCBN is depicted in Fig. 4. In particular, since \(t^\texttt {n} \rightarrow ^{*}_\mathbb {S} s'\), one deduces using Corollary 9 that there exists \(s \in \varLambda \) such that \(s^\texttt {n} = s'\).

The proof for dCBV is depicted in Fig. 5. In particular, by construction \(u^\texttt {v}\) is a \(\mathbb {F}\langle \mathtt {d!}\rangle \text {-}\texttt{NF}\) and by induction on the length of \(s' \rightarrow ^*_\texttt {I} u^{\texttt{V}}\), one has that \(s'\) is a \(\mathbb {S}\langle \mathtt {d!}\rangle \text {-}\texttt{NF}\). Using Corollary 14, one deduces that there exists \(s \in \varLambda \) such that \(s^\texttt {v} = s'\).    \(\square \)

6 Conclusion and Related Work

Our first contribution is to revisit and extend several properties concerning the encoding of dCBN into dBANG. The second contribution, more significant, consists in introducing a new embedding from dCBV to dBANG, which is conservative with respect to previous results in the literature [18, 19], but also (and this is a novelty) allows us to establish the essential reverse simulation property, achieved through the non-trivial concept of diligent sequence. We illustrate the strength of our methodology by means of an example, namely factorization. For that, we first prove a factorization theorem for dBANG, another major contribution of the paper, and we then deduce factorization for dCBN and dCBV by projecting that for dBANG.

In [25], factorization for the (non-distant) Bang Calculus has been proved and from that, factorizations results for standard (non distant) CBN \(\lambda \)-calculus and Plotkin’s original CBV \(\lambda \)-calculus has been deduced. But the (non-distant) Bang Calculus and Plotkin’s CBV are not adequate, in the sense explained in Sect. 1, thus decreasing the significance of those preliminary results.

When taking adequate versions of the Bang Calculus, by adding ES and distance, or \(\sigma \)-reduction [22, 31], the CBV encodings in the literature [18, 19, 22, 25, 30] fail to enjoy reverse simulation, thus preventing one deducing dynamic properties from the Bang Calculus into CBV. Other CBN and CBV encodings into a unifying framework appear in [14], but there is no reverse simulation property, so that no concrete application of the proposed encoding to export properties into CBN and CBV. The same occurs in [24]. The only exceptions are [12, 36] —where only static properties are obtained—, and [25, 30] —where the Bang and CBV calculi are not adequate in the sense explained in Sect. 1.

Sabry and Wadler [50] showed that simulation and reverse simulation between two calculi are for free when their back and forth translations give rise to an adjoint. One of the difficulties to achieve our results is that our CBN and CBV embeddings, as well as the ones used in [18, 19, 22, 25, 30], do not form an adjoint. This is basically due to the fact that a CBN/CBV term can be decorated by \(!\) and \(\textsf{der}\) so as that administrative steps performed in the (Distant) Bang Calculus do not correspond to anything in CBN or CBV. Our contribution is precisely to achieve simulation and reverse simulation without the need for any adjoint.

As discussed at the end of Sect. 3, proving simulation and reverse simulation requires a considerable effort. But this initial investment lays the groundwork for numerous benefits without extra costs, as we showed in Sects. 4 and 5.

In addition to the tangible contributions presented in this paper, we believe our methodology enhances the understanding of the semantic aspects of CBV, especially concerning untyped and typed approximants. This remains a topic that, while gradually gaining attention in the literature [12, 33, 39], is yet to be thoroughly explored. Our novel CBV embedding would also suggest a logical counterpart (a new encoding of intuitionistic logic into linear logic), which remains to be investigated. Moreover, we aim to further leverage our technique to explore other crucial dynamic properties of dCBN and dCBV, such as standardization, normalization, genericity as well as some specific deterministic strategies.