Call-by-Value and Call-by-Name Dual Calculi with Inductive and Coinductive Types

This paper extends the dual calculus with inductive types and coinductive types. The paper first introduces a non-deterministic dual calculus with inductive and coinductive types. Besides the same duality of the original dual calculus, it has the duality of inductive and coinductive types, that is, the duality of terms and coterms for inductive and coinductive types, and the duality of their reduction rules. Its strong normalization is also proved, which is shown by translating it into a second-order dual calculus. The strong normalization of the second-order dual calculus is proved by translating it into the second-order symmetric lambda calculus. This paper then introduces a call-by-value system and a call-by-name system of the dual calculus with inductive and coinductive types, and shows the duality of call-by-value and call-by-name, their Church-Rosser properties, and their strong normalization. Their strong normalization is proved by translating them into the non-deterministic dual calculus with inductive and coinductive types.


Introduction
Dual Calculus DC given by Wadler [27,28] is a type system which corresponds to the classical sequent calculus LK (see, for example, [7]). It represents computation induced by cut elimination in LK by using its expressions and their reduction. The dual calculus has two nice properties: computation in classical logic, and duality.
The computation of classical logic has been intensively studied, for example, [2,4,8,9,20,21,23,27,28]. They all studied the Curry-Howard correspondence between classical logic and functional programming languages with sophisticated control structures like catch/throw and firstclass continuations. This correspondence is an extension of the Curry-Howard correspondence between intuitionistic logic and the typed λ-calculus, which is well established.
The classical sequent calculus LK has nice duality. We have an involution that maps conjunction and disjunction to each other, and maps the left and right rules of conjunction to the right and left rules of disjunction and vice versa. This involution can be extended to the cut elimination procedure for LK.
The system DC inherits the duality of the classical sequent calculus LK. Moreover, its proof terms called terms, coterms, and statements also have duality, since they correspond to proofs in The rules (ηR) and (ηL) are necessary to get the results of computation of terms and coterms from computation of statements inside them. We do not include the η-rules for logical connectives that are given in [28], since these break the confluence property for call-by-value and call-by-name systems, which we will study in Section 7. In order to study a base framework, we first consider a non-deterministic rewriting system that does not commit to either the call-by-name or call-by-value theory.
The system DC we consider first is obtained from the original dual calculus given in [27] by omitting evaluation strategies, dropping (ς)-rules that provide strong evaluation under call-by-value and call-by-name strategies, and replacing (ηL) and (ηR)-expansion rules by (ηL) and (ηR)-reduction rules.
The role of (ηL) and (ηR)-reduction rules are to simplify logical proofs without changing any proof structure. In the last section, we also give the call-by-value and call-by-name variants of DCµν. The role of these rules become clearer in that section since they are necessary to obtain a value as the result of a computation under some strategy. This proposition is shown by induction on reduction using the following substitution lemma. The following duality transformation extends the duality in the sequent calculus LK to terms, coterms, and statements. Definition 2.5 (Duality Transformation). The duality transformation (−) • from DC into itself is defined for types and expressions as follows: Note that a type and a statement are mapped to themselves. A term and a coterm are mapped to each other.
We also define transformation for judgments. If Γ is We also define transformation for inference rule names as follows: This duality transformation preserves substitution of terms and coterms. Lemma 2.6. The following claims hold.
Proof. The claims (1) and (2) are shown by induction on D. We treat the first case of (1): the case The other cases are straightforwardly proved by the induction hypothesis.
This duality transformation is shown to preserve typing and reduction, and to be an involution. This transformation is a homomorphism for this system in the sense that it preserves typing and reduction. An important feature of DC is its duality by this transformation. A term is dual to a coterm by this homomorphism. (1) If J is derived from J 1 , . . . , J n (n = 1 or 2) by an inference rule R, then (J) • is derived from Proof. The claim (1) is proved by case analysis of the inference rules. The claim (2) is proved by induction on the generation of −→ DC using Lemma 2.6. The claim (3) is proved by induction on types and expressions.
The constructor @ simulates the application in λ-calculus together with •. The following holds from the definition. Proposition 2.10. The following typing inference rules and reduction rule are derivable.

The Dual Calculus DCµν with Inductive and Coinductive Types
In this section, we present DCµν, which is an extension of DC with inductive types and coinductive types. We first extend the definition of types of DC to inductive types µX.A and coinductive types νX.A, and then extend expressions and reduction.
In Section 5, we will introduce the second-order system DC2. The system DCµν is worth to be studied as well as DC2, since DCµν is within a first-order logic.
We first define types, their positive type variables, and their negative type variables. A positive type variable in a type does not occur negatively in the type in the usual sense. A negative type variable in a type does not occur positively in the type. Definition 3.1. The set of type variables is written by TyVars. We define the types of DCµν (denoted by A, B, . . .) and the set Pos(A) of positive type variables in the type A and the set Neg(A) of negative type variables in the type A as follows: where µX.A and νX.A are defined when the type variable X is in Pos(A).
Pos(X) = TyVars, The types µX.A and νX.A bind X in A.
When we think standard semantics of the propositional logic with inductive and coinductive definitions, µX.A and νX.A are interpreted by the least fixed point and the greatest fixed point of the monotone function P respectively, where P is the function which maps a set U to the set A[U/X]. Let µ be µX.A and ν be νX.A. They will have the following properties: Based on this meaning, we will introduce terms, coterms, and their reduction for inductive and coinductive types in the same way as [15].   K : We sometimes use the symbol ⊢ DCµν instead of the symbol ⊢ in a judgment in order to explicitly show it is a judgment of DCµν. That is, we write Γ ⊢ DCµν ∆ M : A for the judgment Γ ⊢ ∆ M : A. Similarly, we write K : A Γ ⊢ DCµν ∆ and Γ S ⊢ DCµν ∆.
The system DCµν satisfies the following basic lemmas.
Proof. They are shown simultaneously by induction on M, K, and S . ( Proof. They are shown simultaneously by induction on M, K, and S . The duality transformation can be extended from DC to DCµν. Definition 3.7 (Duality Transformation). The duality transformation for types, terms, coterms, statements, and inference rule names of DCµν is defined by those of DC and the following equations: The above duality transformation is well-defined. This duality transformation alternates free variables and free covariables that occur in terms and coterms. Let V be a set of variables, and C be a set of covariables. Then a set of covariables This duality transformation preserves substitution of types, terms, and coterms.

Lemma 3.10. Let A and B be types, D be an expression, M be a term, and K be a coterm of DCµν.
Then the following hold. The extended duality transformation preserves typing, and is an involution in DCµν.
Proposition 3.11. The following claims hold.

hold for any type A, expression D, and judgment J of
DCµν.
Proof. The claim (1) is shown by case analysis of the inference rules of DCµν using Lemma 3.10 (1). The claim (2) is shown by induction on types and expressions.
Our reduction rules for inductive and coinductive types will be defined so that they correspond to cut elimination procedures in the classical sequent calculus LK extended with inductive definitions and coinductive definitions. In the following proof figures, we will write µ, ν, and A[B] for µX.A, νX.A, and A[B/X] respectively. In the logical system, when the cut formula is an inductive type, the cut elimination procedure reduces the proof . . . .
We can intuitively understand the rule (mono) as follows: . This rule will be formally shown in Lemma 3.14 (2a). This reduction changes the cut formula from µ to A[µ]. We do not have to count the cut formula B, since that cut is auxiliary. When the cut formula is a coinductive type, the cut elimination procedure reduces a proof in a dual way to the above reduction. When we have a function λx.M from A to B and the variable X is in Pos(C), we can define the function from C[A/X] to C[B/X] by extending λx.M. We will use mono X.C A,B,x.M {N} so that this function maps z to mono X.C A,B,x.M {z}. We will define mono X.C A,B,x.M {N} by induction on the measure ||C|| X for a type C and a type variable X, which is defined by induction on C as follows: If X is not free in A, then ||A|| X = 0. In the other cases, we assume that some X occurs in A and we define The number ||A|| X will also be used for evaluating the size of mono X.C A,B,x.M {N} by using M, N, and C (see Lemma 6.2). If we replaced ||A|| X + ||A|| Y + 1 by ||A|| X + 1 in the definition of ||µY.A|| X and ||νY.A|| X , it would not work for this purpose.
For a covariable α and coterms K and L, we also define Note The paper [17] studied an intuitionistic logical system with strictly-positive inductive definitions, and on the other hand we study a classical logical system with positive inductive definitions. Our cut elimination for inductive types is the same as theirs, and on the other hand our cut elimination for coinductive types is different from theirs. They can avoid the use of mono. However, we cannot straightforwardly compare our method and their method, since our system is strictly larger than their system.
Our method works only for classical logic and does not work for an intuitionistic logic. This is because our cut elimination procedure keeps the duality and we have the corresponding proof rule that manipulates a succedent if we have some proof rule that manipulates an antecedent. In particular, we define the operator mono for coterms as the dual of the operator mono for terms. Roughly speaking, in the proof of the next lemma, when we show the properties of mono for negation by using the derivation we need the following derivation in order to show the properties of its dual: which uses a non-intuitionistic sequent.
Lemma 3.13. The following claims hold.
The claims (1a) and (1b) are shown by induction on C X . The claims (2a) and (2b) are shown by using (1a), (2b), and Lemma 3.9. Lemma 3.14. Assume X is in Pos(C) and Neg(D). Then the following hold:
The following proposition is obtained as a special case of the above lemma.
Proposition 3.15. Assume X is in Pos(C). The following are derivable: 16. We define the one-step reduction relation −→ DCµν of DCµν as the compatible closure of the reduction rules of DC and the following reduction rules: . This system has subject reduction. Proof. They are shown simultaneously by induction on the generation of −→ DCµν using Lemma 3.4, 3.5, 3.6, and 3.14. We consider the cases of (βµ) and (βν).
Case of (βµ). The case of (βν) is shown similarly to the case of (βµ). The other cases are straightforwardly proved by the induction hypothesis.
The duality transformation (−) • preserves reduction. Proof. This is proved by induction on the generation of −→ DCµν .
We have shown the duality of inductive types and coinductive types. Proposition 3.11 and Theorem 3.18 show that the duality transformation is a homomorphic involution. The description of a type can be defined as the set of the type itself, its terms, its coterms, and their reduction. The duality transformation maps the description of an inductive type and that of a coinductive type to each other. That is, we have the following. (1) Definition 3.7 shows that the inductive type µX.A is mapped to the coinductive type νX.(A) • , the term constructed by in for the inductive type is mapped to the coterm constructed by out for the coinductive type, and the coterm constructed by itr for the inductive type is mapped to the term constructed by coitr for the coinductive type. (2) Proposition 3.19 shows that the cut elimination procedure of the inductive type is mapped to the cut elimination procedure of the coinductive type. (3) the coinductive type is mapped to the inductive type in a similar way to (1) and (2). Remark 3.20. We cannot define our typing system by using instead of the typing rule (µL). If we used (µL ′ ), the set of terms would not be closed under substitution, because itr A α [K, L] would not have typing rules for it and hence it would not be a term, though it is obtained from itr A α [K, β] by substituting L for β.

Examples
In this section we show some examples of inductive and coinductive types in DCµν. Let X 0 be a distinguished type variable. We use the following abbreviations: The type Nat of natural numbers can be represented by: where 0 is the zero and succ is the successor. We can prove Γ ⊢ ∆ 0 : Nat. We can also prove Γ ⊢ We note that this stream example can be considered under the call-by-name setting (section 7) if we restrict coterms in the above example to covalues. If Stream(⊥) is considered under the call-by-name setting and Nat is considered under the callby-value setting, then the duality of the above proposition can be understood as follows. The type ⊤ means the singleton set { * }. The type ⊥ means the type of a program that returns some answer after computation with the input * since ⊥ is equivalent to ¬⊤. The type Nat means the infinite disjoint sum ⊤ + ⊤ + ⊤ + . . .. The type Stream(⊥) means the infinite cartesian product ⊥ × ⊥ × ⊥ × . . .. Since a term in Stream(⊥) is equivalent to a coterm in Nat, when the term gets some natural number and is computed, it returns some answer. When the term gets the natural numberñ, sinceñ is * in the n-th ⊤ in ⊤ + ⊤ + . . ., the term in the n-th ⊥ in ⊥ × ⊥ × . . . is given the input * and it is computed to give some answer.
Here we can also consider examples that include non-deterministic choices. Let M and N be terms of same type, x be a fresh variable, α and β be fresh covariables. We define the nondeterministic choice M | N by where α and β are fresh covariables. This term has both (β L ) and (β R )-redexes. It is reduced to M if the (β R )-redex is chosen, and is reduced to N if the (β L )-redex is chosen. Thus, M | N can be considered as a non-deterministic choice of either M or N. This non-deterministic choice M | N is forced to choose M under the call-by-value strategy, and is forced to choose N under the call-by-name strategy.
An example of non-deterministic computation is the list insertion function. This function gets a list as its input data, and non-deterministically chooses one arbitrary place in the list. Then it returns a new list that is obtained by inserting a given element at the place.

The Second-Order Dual Calculus DC2
We consider the second-order extension DC2 of DC given by Tzevelekos [26]. He showed the basic properties of DC2, such as the substitution lemma and subject reduction. Without formal discussion, he also mentioned that his translation from DC into the symmetric λ-calculus can be extended to the second-order case. In this section, we give a formal definition of the second-order translation from DC2 into the second-order symmetric λ-calculus, and show the strong normalization of DC2 by using this translation. For this purpose we will use the strong normalization result of the secondorder symmetric λ-calculus given in [21].
Definition 5.1. An expression is defined to be strongly normalizing if there does not exist any infinite reduction sequence starting from the expression.
First, we define a second-order extension DC2 of DC.
Definition 5.2 (DC2). The types, terms, coterms, and statements of DC2 are defined by: The typing rules and reduction rules (denoted by −→ DC2 ) of DC2 are defined by extending the rules of DC with the following rules: where Z is not free in Γ and ∆ in (∀R) and (∃L). We write −→ + DC2 to denote the transitive closure of −→ DC2 .
We have the new constructors a and e, which are trivial witnesses for the quantifiers at the level of expressions, so that the system has subject reduction. We choose our DC2 so that it does not contain type information in expressions, since our purpose is to show strong normalization of the second-order dual calculus, and in general the strong normalization of the system with type information is implied by the strong normalization of the system without type information.
We sometimes use the symbol ⊢ DC2 instead of the symbol ⊢ that appears in a judgment in order to explicitly show it is a judgment of DC2. That is, we write Γ ⊢ DC2 ∆ M : A for the judgment Γ ⊢ ∆ M : A. Similarly, we write K : A Γ ⊢ DC2 ∆ and Γ S ⊢ DC2 ∆. We Proof. They are shown simultaneously by induction on expressions.
The basic lemmas for DC and DCµν are also shown in DC2. We use Lemma 5.3 to show weakening lemma.
Proof. They are shown simultaneously by induction on M, K, and S . Lemma 5.6 (Substitution lemma). The following claims hold. The case of (β∃) is shown similar to the case of (β∀). The other cases are straightforwardly proved by the induction hypothesis.
Remark 5.8. The trivial witnesses a and e are necessary for the subject reduction. If we did not have these constructors, the subject reduction would fail. If we chose the following (∀R ′ ) and (∀L ′ ) instead of (∀R) and (∀L), then the following would be a counter-example: we would have In λ-calculus the constructor a is not necessary for subject reduction while the constructor e is necessary for it [25]. In our system, since ∀ and ∃ are dual, the constructor a is also needed.
The duality transformation can be extended from DC to DC2. This duality transformation preserves substitution of types, terms, and coterms. The extended duality transformation preserves typing and reduction. It is an involution in DC2.
(1) If J is derived from J 1 , . . . , J n (n = 1 or 2) by an inference rule R, then (J) • is derived from Proof. The claim (1) is proved by case analysis of the inference rules of DC2. The claim (2) is proved by induction of the generation of −→ DC2 using Lemma 5.10. The claim (3) is proved by induction on types and expressions.
Next we give a definition of the second-order symmetric λ-calculus Sλ2. The symmetric λcalculus is introduced by Barbanera and Berardi [2] as a classical extension of the λ-calculus. The strong normalization of its second-order extension Sλ2 is proved by Parigot [21] using the reducibility method. The particular system we consider here is an extension of Parigot's system with two additional rules (η r and η l ). As discussed in ibid., Parigot's proof works with this variant without problem.
Definition 5.12 (Sλ2). We define the second-order symmetric λ-calculus Sλ2. The types of Sλ2 are either the special type ⊥ or m-types (denoted by τ, σ, . . .) given by: where X, Y, . . . range over type variables. The types ∀X.τ and ∃X.τ bind X in τ. The negation (τ) ⊥ of τ is defined by: The symbols x, y, . . ., α, β, . . . range over variables. The terms of Sλ2, denoted by t, u, . . ., are defined by The one-step reduction relation −→ Sλ2 of Sλ2 is defined as the compatible closure of the following rules: where y is not free in t in (η l ) and (η r ). A typing context (denoted by Γ, ∆) is a finite set and of the form x 1 : τ 1 , . . . , x n : τ n . A judgment of Sλ2 takes either the form Γ ⊢ t : τ or Γ ⊢ t : ⊥. The typing rules of Sλ2 are defined as follows: Theorem 5.13 (Strong normalization of Sλ2 [21]). Every typable term is strongly normalizing in Sλ2.
We will give a reduction-preserving and type-preserving translation from DC2 into Sλ2. Our translation is a second-order extension of the translation from DC into the symmetric λ-calculus given by Tzevelekos [26].
Definition 5.14. Let A be a type of DC2. The type (A) † of Sλ2 is defined as follows: Let D be an expression of DC2. The term (D) † of Sλ2 is defined by: This translation preserves provability and one-step reductions.
Proposition 5.15. The following claims hold.
Proof. The claim (1) is shown by induction on the proof of J. The claim (2) is shown by induction on the definition of −→ DC2 .
We can obtain strong normalization of DC2 from the above proposition. is an infinite reduction sequence. This contradicts Theorem 5.13.
Remark 5.17. Tzevelekos [26] also gave a back translation (−) p from the symmetric λ-calculus into DC. As noted in his paper (Section 3, Note 3.5), this translation cannot extend to the secondorder case since it does not preserve typing judgments for existential quantification. This is because the translation (−) p does not preserve type substitution: The same argument applies to ours.

Strong Normalization of DCµν
In this section, we prove strong normalization in DCµν. We will give a translation from DCµν into DC2 that is based on the second-order encoding of inductive and coinductive types. Our proof of strong normalization will be done by showing the fact that one-step reduction in DCµν is translated to one or more steps reduction in DC2.
We use the following degree of expressions in DCµν for defining the second-order coding of inductive and coinductive types.
When we try to prove some properties of expressions by induction on expressions, that induction sometimes does not work, since the expression contains mono X,C A,B,x.M {N} that is defined by using induction on ||C|| X . In order for solving this, we will introduce the pair of the summation of ||C|| X and the size of an expression as a measure.  The number |D| is defined by: The degree deg(D) of the expression D is defined as the pair (||D||, |D|). We also define the order of the degrees by the lexicographic order.
The number |D| is the number of constructors in the expression D. The number ||D|| is the maximum summation of (||A|| X + 1) for in µX.A M and out νX.
. We have ||E|| ≤ ||D|| and |E| < |D| when the expression E is a proper subexpression of D. The degree satisfies the following properties.
The claims of (1) are shown by induction on D. The claim (2) is shown by induction on ||A|| X . The claim (3) is proved by using (2).
We present the second-order encoding for DCµν. We will write λ(x, α).S for λx.((S ).α). Then We also define the translation of judgments. The context Γ is defined as The next lemma shows that this translation commutes with (−) • . The claim for J is proved by using the claims for A and D.
The translation (−) preserves substitution. The case of (ii). We first claim that, for any S and V, if (S ).α ⇒ V, then there is some M such that S = M • α, M ⇒ V, and α is not free in M. This claim is easily obtained from the definition of the parallel reduction. In this case, we have V ⇐ M = (S 0 ).β ⇒ (S 0 ′ ).β. By the induction hypothesis and Lemma 7.14 (1), there is a value W such that V ⇒ W ⇐ (S 0 ′ ).β. Then, there exists a N such that S 0 ′ = N • β, N ⇒ W, and β is not free in N from the above claim. Hence we have