Pure Pattern Calculus \`a la de Bruijn

It is well-known in the field of programming languages that dealing with variable names and binders may lead to conflicts such as undesired captures when implementing interpreters or compilers. This situation has been overcome by resorting to de Bruijn indices for calculi where binders capture only one variable name, like the $\lambda$-calculus. The advantage of this approach relies on the fact that so-called $\alpha$-equivalence becomes syntactical equality when working with indices. In recent years pattern calculi have gained considerable attention given their expressiveness. They turn out to be notoriously convenient to study the foundations of modern functional programming languages modeling features like pattern matching, path polymorphism, pattern polymorphism, etc. However, the literature falls short when it comes to dealing with $\alpha$-conversion and binders capturing simultaneously several variable names. Such is the case of the Pure Pattern Calculus (PPC): a natural extension of $\lambda$-calculus that allows to abstract virtually any term. This paper extends de Bruijn's ideas to properly overcome the multi-binding problem by introducing a novel presentation of PPC with bidimensional indices, in an effort to implement a prototype for a typed functional programming language based on PPC that captures path polymorphism.


Introduction
The foundations of functional programming languages like LISP, Miranda, Haskell or the ones in the ML family (Caml, SML, OCaml, etc.) rely strongly on the study of the λ-calculus [Bar85] and its many variants introduced over the years. Among them there are the pattern calculi [vO90,CK98,Kah03,CK04,JK06,Jay04,KvOdV08], whose key feature can be identified as pattern-matching. Pattern-matching has been extensively used in programming languages as a means for writing succinct and elegant programs. It stands for the possibility of defining functions by cases, analysing the shape of their arguments, while providing a syntactic tool to decompose such arguments in their parts when applying the function.
In the standard λ-calculus, functions are represented by expressions of the form λx.t, where x is the formal parameter and t the body of the function. Such a function may be applied to any term, regardless of its form, as dictated by the β-reduction rule: (λx.t) u → β {x \ u}t, where {x \ u}t stands for the result of replacing all free occurrences of x in t by u. Note that no requirement on the shape of u is placed. Pattern calculi, on the contrary, provide generalisations of the β-reduction rule in which abstractions λx.t are replaced by more not delve deeper into these new forms of polymorphism. We refer the reader to [JK09,Jay09] for an in-depth study of them.
Given an infinitely countable set of symbols V (x, y, z, . . .), the sets of terms T PPC and contexts are given by the following grammar: where θ is a list of symbols that are bound by the abstraction. A symbol x appearing in a term is dubbed a variable symbol while x is called a matchable symbol. In particular, given λ θ p.t, θ binds variable symbols in the body t and matchable symbols in the pattern p. Thus, the set of free variables and free matchables of a term t, written fv(t) and fm(t) respectively, are inductively defined as: A term is said to be closed if it has no free variables. Note that free matchables are allowed, and should be understood as constants or constructors for data structures. The pattern p of an abstraction λ θ p.t is linear if every symbol x ∈ θ occurs at most once in p.
λ [x] x.(λ [y] x y .y) To illustrate how variables and matchables are bound, consider the function elim defined as λ [x] x.(λ [y] x y.y). The inner abstraction binds the only occurrence of the matchable y in the pattern x y and that of the variable y in the body y. However, the occurrence of x in x y is not bound by the inner abstraction, as it is excluded from [y], acting as a place-holder in that pattern. It is the outermost abstraction that binds both x in the inner pattern and x in the outermost pattern. This is graphically depicted above.
A substitution (σ, ρ, . . .) is a partial function from variables to terms. The substitution σ = {x i \ u i } i∈I , where I is a set of indices, maps the variable x i into the term u i (i.e. σ(x i ) u i ) for each i ∈ I. Thus, its domain and image are defined as dom(σ) {x i } i∈I and img(σ) {u i } i∈I respectively. For convenience, a substitution σ is usually turned into a total function by defining σ(x) x for every x / ∈ dom(σ). Then, the identity substitution is denoted {} or simply id .
A match (µ, ν, . . .) may be successful (yielding a substitution), it may fail (returning a special symbol fail) or be undetermined (denoted by a special symbol wait). The cases of success and failure are called decided matches. All concepts and notation relative to substitutions are extended to matches so that, for example, the domain of fail is empty while that of wait is undefined. The sets of free variable and free matchable symbols of σ are defined as the union of fv(σx) and fm(σx) for every x ∈ dom(σ) respectively, while fv(fail) = fm(fail) = ∅ and they are undefined for wait. The set of symbols of a substitution is defined as sym(σ) dom(σ) ∪ fv(σ) ∪ fm(σ). The predicate x avoids σ states that x / ∈ sym(σ). It is extended to sets and matches as expected. In particular, θ avoids µ implies that µ must be decided.
The result of applying a substitution σ to a term t, denoted σt, is inductively defined as: The restriction in the case of the abstraction is required to avoid undesired captures of variables/matchables. However, it can always be satisfied by resorting to α-conversion.
The result of applying a match µ to a term t, denoted µ t, is defined as: (i) if µ = σ a substitution, then µ t σt; (ii) if µ = fail, then µ t λ [x] x.x (i.e. the identity function); or (iii) if µ = wait, then µ t is undefined.
Before introducing the matching operation it is necessary to motivate the concept of matchable form. The pattern x y allows, at first, to decompose arbitrary applications, which may lead to the loss of confluence. For instance: ( This issue arises when allowing to match the pattern x y with an application that may still be reduced, like the argument (λ [w] w. z 0 z 1 ) z 0 of the outermost redex in the example above. To avoid this situation it is required for the match to be decided only if the argument is sufficiently evaluated. An analogous issue occurs if the pattern is reducible. Thus, both the pattern and the argument must be in matchable form for the match to be decided. The set of data structures D PPC and matchable forms M PPC are given by the following grammar: The matching operation { {p \ θ u} } of a pattern p against a term u relative to a list of symbols θ is defined as the application, in order, of the following equations: This last condition is necessary to prevent bound symbols from going out of scope when reducing. It can be easily guaranteed though by requesting, for each abstraction λ θ p.t, that θ ⊆ fm(p). For instance, consider the term (λ [x,y] x.y) u. Without this final check, matching the argument u against the pattern x would yield a substitution {x \ u} and no term would be assigned to the variable y in the body of the abstraction.
Finally, the reduction relation → PPC of PPC is given by the closure by contexts of the rewriting rule: To illustrate the operational semantics of PPC consider the term elim introduced above, applied to the function λ [z] z. c z n where the free matchables c and n can be seen as constructors for lists cons and nil respectively: In the first step, λ [z] z. c z n is substituted for x into the pattern x y. In the second step, the resulting application, which resides in the pattern, is reduced. The resulting term, when applied to an argument, will yield a successful matching only if this argument is a compound data of the form c t n. This relation is shown to be confluent (CR) based on the matching operation introduced above.

de Bruijn indices
We introduce next de Bruijn indices for the λ-calculus. Among the many presentations of de Bruijn indices in the literature, we will follow that of [KR95] as our development builds upon their ideas. In particular, we choose to work with the presentation where indices are partially updated as the term is being traversed by the substitution operation (details below). We refer the reader to [KR95] for the equivalent version where the update is performed once at the end of the substitution process. We introduce now the λ-calculus with de Bruijn indices (λ dB for short).
The sets of terms T λdB and contexts are given by the following grammar: is called an index. Indices are place-holders indicating the distance to the binding abstraction.
In the context of the λ dB -calculus, indices are also called variables. Thus, the free variables of a term are inductively defined as: fv(i) {i}; fv(t u) fv(t) ∪ fv(u); and fv(λt) fv(t) − 1, where X − k stands for subtracting k from each element of the set X, removing those that result in a non-positive index.
In order to define β-reductionà la de Bruijn, the substitution of an index i for a term u in a term t must be defined. Therefore, it is necessary to identify among the indices of the term t, those corresponding to i. Furthermore, the indices of u should be updated in order to preserve the correct bindings after the replacement of the variable by u. To that end, the increment at depth k for variables in a term t, written ↑ k (t), is inductively defined as follows: λ↑ k+1 (t) Then, the substitution at level i of a term u in a term t, denoted {i \ u}t, is defined as a partial function mapping free variables at level i to terms, performing the appropriate updates as it traverses the substituted term, to avoid undesired captures.
It is worth noticing that this substitution should be interpreted in the context of a redex, where a binder is removed and its bound index substituted. This forces to update the free indices, that might be captured by an outermost abstraction, as done by the first case of the substitution over a variable i ′ . Hence, preserving the correct bindings. Finally, the reduction relation → dB of the λ dB -calculus is given by the closure by contexts of the rewriting rule: (λs) u → dB {1 \ u}s Also, embeddings between the λ-calculus and λ dB are defined: : T λ → T λdB and : T λdB → T λ , in such a way that they are the inverse of each other and they allow to simulate one calculus into the other: Theorem 2.2 ( [KR95]) Let t ∈ T λ and s ∈ T λdB . Then, This shows that both formalisms (λ-calculus and λ dB ) have exactly the same operational semantics. As an example to illustrate both reduction in the λ dB -calculus and its equivalence with the λ-calculus, consider the following terms: (λz.λy.z) (λx.x) (λx.x x) and (λλ2) (λ1) (λ1 1). The reader can verify that both expressions encode the same function in its respective calculus. As expected, their operational semantics coincide

The Pure Pattern Calculus with de Bruijn indices
This section introduces the novel Pure Pattern Calculus with de Bruijn indices (PPC dB ). It represents a natural extension of de Bruijn ideas to a framework where a binder may capture more than one symbol. In the particular case of PPC there are two kinds of captured symbols, namely variables and matchables. This distinction is preserved in PPC dB while extending indices to pairs (a.k.a. bidimensional indices) to distinguish the binder that captures the symbol and the individual symbol among all those captured by the same binder. The sets of terms T PPC dB , contexts, data structures D PPC dB and matchable forms M PPC dB of PPC dB are given by the following grammar: where i j is dubbed a bidimensional index and denotes an ordered pair in N ≥1 × N ≥1 with primary index i and secondary index j. The sub-index n ∈ N in an abstraction represents the amount of indices (pairs) being captured by it. The primary index of a pair is used to determine if the pair is bound by an abstraction, while the secondary index identifies the pair among those (possibly many) bound ones. As for PPC, an index of the form i j is called a variable index while i j is dubbed a matchable index. The free variables and free matchables of a term are thus defined as follows: where X − k stands for subtracting k from the primary index of each element of the set X, removing those that result in a non-positive index.
Let us illustrate these concepts with a similar example as that given for PPC, namely the function elim = λ [x] x.(λ [y] x y.y). An equivalent term in the PPC dB framework would be λ 1 1 1 .(λ 1 1 1 1 1 .1 1 ). Note that variable indices in the context of a pattern are not bound by the respective abstraction, in the same way that matchable indices in the body of the abstraction are not captured either. Thus, the first occurrence of 1 1 is actually bound by the outermost abstraction, together with the first occurrence of the matchable index 1 1 . The rest of the indices in the term are bound by the inner abstraction as depicted in the figure to the right. As a further (more interesting) example, consider the term λ [x,y] x y.λ [] x.y from PPC, whose counter-part in PPC dB would look like λ 2 1 1 1 2 .λ 0 1 1 .2 2 . This example illustrates the use of secondary indices to identify symbols bound by the same abstraction. It also shows how the primary index of a variable is increased when occurring within the body of an internal abstraction, while this is not the case for occurrences in a pattern position. Thus, both 1 1 and 2 2 are bound by the outermost abstraction, as well as 1 1 and 1 2 . Note how the inner abstraction does not bind any index at all.
A term t is said to be well-formed if all the free bidimensional indices (variables and matchables) of t have their secondary index equal to 1, and for every sub-term of the form λ n p.s (written λ n p.s ⊆ t) all the pairs captured by the abstraction have their secondary index within the range [1, n]. Formally, Before introducing a proper notion of substitution for PPC dB it is necessary to have a mechanism to update indices at a certain depth within the term. The increment at depth k for variable and matchable indices in a term t, written ↑ k (t) and ⇑ k (t) respectively, are inductively defined as follows Similarly, the decrement at depth k for variables (↓ k ( )) and matchables (⇓ k ( )) are defined by subtracting one from the primary index above k in the term. Most of the times these functions are used with k = 0, thus the subindex will be omitted when it is clear from context. In particular, the decrement function for variables will allow us to generalise the idea of substitution at level i with respect to the original one presented in Sec. 2.2, which only holds in the context of a β-reduction, by making the necessary adjustments to the indices at the moment of the redution instead of hard-coding them into the substitution meta-operation.
Lemma 3.1 Let t ∈ T PPC dB . Then, Proof All items follow by straightforward induction on t. ✷ A substitution at level i is a partial function from variable indices to terms. It maps free variable indices at level i to terms, performing the appropriate updates as it traverses the substituted term, to avoid undesired captures.
It is worth noticing that the base case for variable indices is undefined if i ′ = i and k / ∈ J. Such case will render the result of the substitution undefined as well. In the operational semantics of PPC dB , the matching operation presented below will be responsible for avoiding this undesired situation, as we will see later. The domain of a substitution at level i is given by As in PPC, a match (µ, ν, . . .) may succeed, fail (fail) or be undetermined (wait). For PPC dB , a successful match will yield a substitution at level 1, as given by the following matching operation, where the rules are applied in order as in PPC: where disjoint union of matching is adapted to PPC dB from PPC in a straightforward way. The first two rules in the matching operation for PPC dB are worth a comment. As the matching operation should be understood in the context of a redex, the matchable symbols bound in the pattern are those with primary index equal to 1. Thus, PPC dB 's counter-part of the membership check x ∈ θ from PPC's matching operation is a simple syntactic check on the primary index. Similarly, x / ∈ θ corresponds to the primary index being greater than 1, as checked by the second rule of the definition. However, a primary index i + 1 within the pattern should match primary index i from the argument, since the former is affected by an extra binder in a redex. For instance, in the term (λ 1 2 1 1 1 .1 1 ) ( 1 1 t ′ ) the matchable 2 1 is free and corresponds to 1 1 in the argument, while 1 1 from the pattern is bound by the abstraction. Its counter-part in PPC would be α-equivalent to (λ [x] y x.x) ( y t). Hence, As for PPC, an additional post-condition is checked over { {p\ n u} } to prevent indices from going out of scope. It requires dom({ {p \ n u} }) = {1 1 , . . . , 1 n }, which essentially implies that all the bound indices are assigned a value by the resulting substitution. This condition can be guaranteed by requesting {1 1 , . . . , 1 n } ⊆ fm(p), for each abstraction λ n p.t within a well-formed term. To illustrate the need of such a check, consider the term (λ 2 1 1 .1 2 ) u ′ (i.e. the PPC dB counter-part of (λ [x,y] x.y) u, given in Sec. 2.1). If the matching { { 1 1 \ 2 u ′ } } = {1 1 \u ′ } is considered correct, then no replacement for the variable index 1 2 in the body of the abstraction is set, resulting in an ill-behaved operational semantics.
The reduction relation → dB of PPC dB is given by the closure by contexts of the rewriting rule: The decrement function for variable indices is applied to the reduct to compensate for the loss of a binder over s. However, the variable indices of u are not affected by such binder in the redex. Hence the need of incrementing them prior to the (eventual) substitution.
Following the reduction example given above for PPC, consider these codifications of elim = λ [x] x.(λ [y] x y.y) and λ [z] z. c z n respectively: λ 1 1 1 . (λ 1 1 1 1 1 .1 1 ) and λ 1 1 1 . 1 1 1 1 2 1 . Note how the first occurrence of 1 1 is actually bound by the outermost abstraction, since abstractions do not bind variable indices in their pattern. Similarly, the matchable index 1 1 in the body of λ 1 1 1 . 1 1 1 1 2 1 turns out to be free as well as 2 1 . Then, as expected, we have the following sequence: In the first step, λ 1 1 1 . 1 1 1 1 2 1 is substituted for 1 1 into the pattern 1 1 1 1 . The fact that the substitution takes place within the context of a pattern forces the application of ⇑( ), thus updating the matchable indices and obtaining λ 1 1 1 . 2 1 1 1 3 1 . Note that the increment and decrement added by the reduccion rule take no effect as there are no free variable indices in the term. In the second step, the resulting application is reduced, giving place to a term whose counter-part in PPC would be equivalent to λ [y] c y n.y (cf. the reduction example in Sec. 2.1).
In the following sections PPC dB is shown to be equivalent to PPC in terms of expressive power and operational semantics. The main advantage of this new presentation is that it gets rid of α-conversion, since there is no possible collision between free and bound variables/matchables. However, there is one minor drawback with respect to the use of de Bruijn indices for the standard λ-calculus. As mentioned above, when working with de Bruijn indices in the standard λ-calculus, α-equivalence becomes syntactical equality.
Unfortunately, this is not the case when working with bidimensional indices. For instance, consider the terms λ 2 1 1 1 2 .1 1 and λ 2 1 2 1 1 .1 2 . Both represent the function that decomposes an application and projects its first component. But they differ in the way the secondary indices are assigned. Moreover, one may be tempted to impose an order for the way the secondary indices are assigned within the pattern to avoid this situation (recall that the post-condition of the matching operation forces all bound symbols to appear in the pattern). Given the dynamic nature of patterns in the PPC framework, this enforcement would not solve the problem since patterns may reduce and such an order is not closed under reduction. For example, consider λ 2 (λ 2 1 1 1 2 .1 2 1 1 ) ( 1 1 1 2 ).1 1 → dB λ 2 1 2 1 1 .1 1 .
Fortunately enough, this does not represent a problem from the implementation point of view, since the ambiguity is local to a binder and does not imply the need for "renaming" variables/matchables while reducing a term, i.e. no possible undesired capture can happen because of it. It is important to note though, that in the sequel, when refering to equality over terms of PPC dB , it is not syntactical equality but equality modulo these assignments for secondary indices that we are using.

Translation
This section introduces translations between PPC and PPC dB (back and forth). The goal is to show that these interpretations are suitable to simulate one calculus into the other. Moreover, the proposed translations turn out to be the inverse of each other (modulo α-conversion) and, as we will see in Sec. 5, they allow to formalise a strong bisimulation between the two calculi.
We start with the translation from PPC to PPC dB . It takes the term to be translated together with two lists of lists of symbols that dictate how the variables and matchables of the terms should be interpreted respectively. We use lists of lists since the first dimension indicates the distance to the binder, while the second identifies the symbol among the multiple bound ones.
Given the lists of lists X and Y , we denote by XY their concatenation. To improve readability, when it is clear from context, we also write θX with θ a list of symbols to denote [θ]X where [ ] denotes the list constructor. We use set operations like union and intersection over lists to denote the union/intersection of its underlying sets.
Definition 4.1 Given a term t ∈ T PPC and lists of lists of symbols V and M such that fv(t) ⊆ V ′ ∈V V ′ and fm(t) ⊆ M ′ ∈M M ′ , the translation of t relative to V and M , written t M V , is inductively defined as follows: Let x 1 , x 2 , . . . be an enumeration of V. Then, the translation of t to PPC dB , written simply t , is defined as ). Note that the inicialisation of V and M with singleton elements implies that each free variable/matchable in the term will be assigned a distinct primary index (when interpreted at the same depth), following de Bruijn's original ideas: let λ 1 2 1 1 1 .1 1 ) ( 1 1 2 1 ). Our main goal is to prove that PPC dB simulates PPC via this embedding. For this purpose we need to state first some auxiliary lemmas that prove how the translation behaves with respect to the substitution and the matching operation. We start with a technical result concerning the increment functions for variable and matchable indices. Notation ↑ n k (t) stands for n consecutive applications of ↑ k ( ) over t (similarly for ⇑ n k (t)). Lemma 4.2 Let t ∈ T PPC , k ≥ 0, i ≥ 1 and n ≥ k+i such that X l ∩(fv(t)∪fm(t)) = ∅ for all l ∈ [k+1, k+i−1]. Then, .

Proof
(i) By induction on t.
. Then, there are two possible cases:  The translation of a substitution σ requires an enumeration θ such that dom(σ) ⊆ θ to be provided. It is then defined as σ, θ M V {1 j \ σx j M V } xj ∈dom(σ) . Note how substitutions from PPC are mapped into substitutions at level 1 in the PPC dB framework. This suffices since substitutions are only meant to be created in the context of a redex. When acting at arbitrary depth on a term, substitutions are shown to behave properly.
Lemma 4.3 Let s ∈ T PPC , σ be a substitution, θ be an enumeration such that dom(σ) ⊆ θ and Y be a Proof By induction on term s.
• s = y. There are three possible cases.
(i) y ∈ θ (i.e. y = θ k for some k). By hypothesis, Y X and we conclude. • s = t u. This case is immediate from the i.h. since every definition involved distributes over applications.
• s = λ θ ′ p.t. W.l.o.g. we assume θ ′ avoids σ and also θ ′ fresh for θ, M , X and Y . By ). Finally, we conclude by definition of ↓( ) and Def. 4.1: In the case of a match, its translation is given by Note how θ is pushed into the matchable symbol list of the pattern, in accordance with the translation of an abstraction. This is crucial for the following result of preservation of the matching output.
First, note that matchable forms are preserved by the translation as well.
Lemma 4.4 Let t ∈ T PPC . Then, Proof Both items follow by straightforward induction on t, using (i) to prove (ii). ✷ Then, the result of preservation of the matching output states: Proof By induction on p considering the result of { {p \ θ u} } before the final consistency check.
There are two possible cases: Then, x θM V = (i + 1) j for some i, j ∈ N ≥1 . There are two further cases to analyse:  These previous results will allow to prove the simulation of PPC into PPC dB via the translation . We postpone this result to Sec. 5 (cf. Thm. 5.3). Now we focus on the converse side of the embedding, i.e. the translation of PPC dB terms into PPC terms. As before, this mapping requires two lists of lists of symbols from which names of the free indices of the term will be selected: one for variable indices and the other for matchable indices.
Definition 4.6 Given a term t ∈ T PPC dB and lists of lists of distinct symbols V and M such that V ij is defined for every i j ∈ fv(t) and M ij is defined for every i j ∈ fm(t), the translation of t relative to V and M , written t M V , is inductively defined as follows: . , x n ] fresh symbols Let x 1 , x 2 , . . . be the same enumeration of V as in Def. 4.1. Then, the translation of t to PPC, written simply t , is defined as t X X where X = [[x 1 ], . . . , [x n ]] such that fv(t) ∪ fm(t) ⊆ {1 1 , . . . , n 1 }. Note that well-formedness of terms guarantees that X satisfies the conditions above.
Similarly to the substitution case, the translation of a match { {p \ n u} } requires to be supplied with a list of n fresh symbols θ. Then, it is defined as The newly provided list of symbols is used both as the parameter of the resulting match and to properly translate the pattern, obtaining the following expected results.
Lemma 4.9 Let t ∈ T PPC dB . Then, Proof Both items follow by straightforward induction on t, using (i) to prove (ii). ✷ Lemma 4.10 Let p, u ∈ T PPCdB .
Proof By straightforward induction on p using Lem. 4.9. Similar to the proof for Lem. 4.5. ✷ Now we are in conditions to prove the simulation of PPC dB into PPC via the translation provided in Def. 4.6.
Before proceeding to the next section, one final result concerns the translations. It turns out that each translation is the inverse of the other, as shown in Thm. 4.13. In case of PPC terms we should work modulo α-conversion, while for PPC dB terms we may use equality (modulo secondary indices permutations, cf. last paragraph in Sec. 3). This constitutes the main result of this section and is the key to extend our individual simulation results (cf. Thm. 5.3 and 5.5 resp.) into a strong bisimulation between the two calculi, as shown in Sec. 5.

Strong bisimulation
In this section we prove the simulation of one calculus by the other via the proper translation and, most importantly, the strong bisimulation that follows after the invertibility result (cf. Thm. 4.13). This strong bisimulation result will allow to port many important properties already known for PPC into PPC dB , as we will discuss later.
We start by extending the increment function to substitutions and matches. The increment at depth k for variable indices in a substitution at level 1 is defined as ↑ k (σ) {1 j \ ↑ k (σ1 j )} 1j∈dom(σ) . As for matches, we simply define ↑ k (fail) fail and ↑ k (wait) wait, and use the definition over substitution for successful matches. Recall that the matching operation yields only substitutions at level 1. Then, the following result holds.
Proof By straightforward induction on p. ✷ Let us focus first on simulating PPC by PPC dB . The key step here is the preservation of the matching operation shown for in Lem. 4.5. It guarantees that every redex in PPC turns into a redex in PPC dB too. Then, the appropiate definition of the operational semantics given for PPC dB in Sec. 3 allows us to conclude.
We proceed by induction on C.
Proof The property is an immediate consequence of Lem. 5.2, taking V = M = X as given in Def. 4.1. ✷ Regarding the converse simulation, i.e. PPC dB into PPC, we resort here to the fact that the embedding also preserves the matching operation (cf. Lem. 4.10). Then, every redex in PPC dB is translated into a redex in PPC as well.
We proceed by induction on C.
Proof The property is an immediate consequence of Lem. 5.4, taking V = M = X as given in Def. 4.6. ✷ As already commented, these previous results may be combined to obtain a strong bisimulation between the two calculi. The invertibility result allows to define a relation between terms in PPC and PPC dB . Given t ∈ T PPC dB and s ∈ T PPC , let us write t ⇒ s whenever t = α s and, therefore, s = t by Thm. 4.13. Then, the strong bisimulation result states that whenever t ⇒ s and t → dB t ′ , there exists a term s ′ such that t ′ ⇒ s ′ and s → PPC s ′ , and the other way around. Graphically: Theorem 5.6 (Strong bisimulation) The relation ⇒ is a strong bisimulation with respect to the reduction relations → PPC and → dB respectively.
Proof The proof follows immediately from Thm. 5.3 and 5.5 above, and the invertibility result (Thm. 4.13) given in Sec. 4. ✷ The importance of this result resides in the fact that it guarantees that PPC and PPC dB have exactly the same operational semantics. An immediate consequence of this is the confluence of → dB .
Theorem 5.7 (Confluence) The reduction relation → dB is confluent (CR). Another result of relevance to our line of research, is the existence of normalising reduction strategies for PPC, as it is shown in [BKLR17]. This result is particularly challenging since reduction in PPC is shown to be non-sequential due to the nature of its matching operation. This implies that the notion of needed redexes (a key concept for defining normalising strategies) must be generalised to necessary sets [vR97] of redexes. Moreover, the notion of gripping [Mel96] is also captured by PPC, representing a further obstacle in the definition of such a normalising strategy. All in all, in [BKLR17] the authors introduce a reduction strategy S that is shown to be normalising, overcoming all the aforementioned issues. Thanks to the strong bisimulation result presented above, this strategy S can also be guaranteed to normalise for PPC dB .

Conclusion
In this paper we introduced a novel presentation of the Pure Pattern Calculus (PPC) [JK09] in de Bruijn's style. This required extending de Bruijn ideas for a setting where each binder may capture more than one variable at once. To this purpose we defined bidimensional indices of the form i j where i is dubbed the primary index and j the secondary index, so that the primary index determines the binding abstraction and the secondary index identifies the variable among those (possibly many) bound ones. Moreover, given the nature of PPC semantics, our extension actually deals with two kinds of bidimensional indices, namely variable indices and matchable indices. This newly introduced calculus is simply called Pure Pattern Calculus with de Bruijn indices (PPC dB ).
Our main result consists of showing that the relation between PPC and PPC dB is a strong bisimulation with respect to their respective redution relations, i.e. they have exactly the same operational semantics. For that reason, proper translations between the two calculi were defined, : T PPC → T PPC dB and : T PPC dB → T PPC , in such a way that is the inverse of and vice-versa (modulo α-conversion). Most notably, these embeddings are shown to preserve the matching operation of their respective domain calculus.
The strong bisimulation result allows to port into PPC dB many already known results for PPC. Of particular interest for our line of research are the confluence and the existence of normalising reduction strategies for PPC [BKLR17], a rather complex result that requires dealing with notions of gripping [Mel96] and necessary sets [vR97] of redexes. The result introduced on this paper may allow for a direct implementation of such strategies without the inconveniences of working modulo α-conversion.
As commented before, the ultimate goal of our research is the implementation of a prototype for a typed functional programming language capturing path polymorphism. This development is based on the Calculus of Applicative Patterns (CAP) [ABEV19], for which a static type system has already been introduced, guaranteeing well-behaved operational semantics, together with its corresponding efficient type-checking algorithm. CAP is essentially the static fragment of PPC, where the abstraction is generalised into an alternative (i.e. abstracting multiple branches at once). These two calculi are shown to be equivalent. Thus, future lines of work following the results presented in this paper involve porting CAP to the bidimensional indices setting and formalising the ideas of [BKLR17] into such framework. This will lead to a first functional version of the sought-after prototype.