An Infinitary Lambda Calculus with Global Trace Condition
(Extended Abstract)


Abstract

We consider an extension of the infinitary lambda calculus by Kennaway et al., with zero, successor, and conditional, and a type system akin to Gödel’s system T. For terms that can be typed in this system, we define the Global Trace Condition (GTC), adapting the concept from Brotherston and Simpson’s Cyclic Proofs, and show that any infinite reduction of a well-typed term satisfying the GTC is strongly convergent. As a corollary, we obtain the proof that any closed term of type Nat reduces to some numeral through any reduction by levels.

We argue that the Church-Rosser in the limit holds for our calculus and, when restricted to regular terms, the calculus defines exactly the total functions defined in Das’s Cyclic System T (an infinitary version of System T without \(\lambda\)), and hence in Gödel’s System T.

1 Infinitary Lambda Terms↩︎

We extend the infinitary \(\lambda\)-calculus \(\Lambda^\infty\) [1], [2] of Kennaway et alii, by adding the constant \(0\) and the function symbols \({\tt succ}\) and \({\tt cond}\). Then we define the subset \({ {\sf GTC} -\Lambda^{\infty}_T }\) of terms satisfying the Global Trace Condition (GTC), and for them we prove that all reductions are strongly convergent and all terms are total. \({ {\sf GTC} -\Lambda^{\infty}_T }\) is an extension with variables and \(\lambda\) of CT, Cyclic System \(T\) of Das [3], [4].

Our definition of \({ {\sf GTC} -\Lambda^{\infty}_T }\) is by consecutive restrictions. We first define the set \({ {\sf Row} -\Lambda^{\infty}_T }\) of infinitary row-terms with \(\lambda\) and conditional, most of which are meaningless, for which neither \(\alpha\)-renaming nor substitution is sound. Then we define the subset \({ {\sf FinVar} -\Lambda^{\infty}_T }\) of row-terms with finitely many free variables, for which we can consistently define \(\alpha\)-renaming and substitution. Then we define the subset \({\sf WTyped}\) of infinitary terms with finitely many variables that are well-typed. Eventually, we restrict well-typed infinitary terms by adding GTC, a sufficient condition for totality.

Definition 1 (Types and the set \({ {\sf Row} -\Lambda^{\infty}_T }\) of Row-Terms). Let \({\sf Type}\) be the set inductively defined by \[{\sf Type}\ni A,B ::= N \mid (A\to B)\] Then the set \({ {\sf Row} -\Lambda^{\infty}_T }\) is coinductively defined by \[{ {\sf Row} -\Lambda^{\infty}_T }\ni t,s ::= x \mid (\lambda x{:}A. t) \mid (t\,s) \mid 0 \mid {\tt succ} (t) \mid {\tt cond} (t,s)\] where \(x\) ranges over a denumerable set \({\sf Var}\) of term variables.

As usual, we omit unnecessary braces, assuming that \(\to\) associates to the right and term application associates to the left. We abbreviate by \(A_1, \ldots , A_n \to B\), and by \(\vec{A} \to B\) when the \(A_i\) are understood, the type \((A_1 \to \cdots (A_n \to B)\cdots)\), and say that the \(A_i\) are in argument position.

\({\sf Type}\) is the set of simple types generated by the single atomic type \(N\), whose intended interpretation is the set of natural numbers. Row-terms are possibly infinite terms representing elements of the metric completion of finite ones, namely those with a finite syntactic tree. Unlike [1] and following [5], we consider the subset \({ {\sf FinVar} -\Lambda^{\infty}_T }\) of raw terms with finite \({{\rm FV}}(t)\), the set of free variables occurring in \(t\), which admits the obvious corecursive definition. We also adapt the slightly different metric from [5] to account for truncation.

Definition 2. Let \({ {\sf FinVar} -\Lambda^{\infty}_T }+ \bot\) be \({ {\sf FinVar} -\Lambda^{\infty}_T }\) extended with the constant \(\bot\). Then for all \(n \in \mathbb{N}\) we define the map \({(-)}^{[n]}: { {\sf FinVar} -\Lambda^{\infty}_T }\to { {\sf FinVar} -\Lambda^{\infty}_T }+ \bot\) by \({t}^{[0]} = \bot\) and \[\begin{array}{rcl@{}rcl} {x}^{[n+1]} & = & x & {(ts)}^{[n+1]} & = & {t}^{[n]} {s}^{[n]} \\ [1mm] {(\lambda x{:}A.t)}^{[n+1]} & = & \lambda x{:}A.{t}^{[n]} & { {\tt cond} (t,s)}^{[n+1]} & = & {\tt cond} ({t}^{[n]}, {s}^{[n]}) \\ [1mm] {{\tt 0}}^{[n+1]} & = & {\tt 0}& { {\tt succ} (t)}^{[n+1]} & = & {\tt succ} ({t}^{[n]}) \end{array}\]

The metric \(\textit{d}: ({ {\sf FinVar} -\Lambda^{\infty}_T }+ \bot)^2 \to [0, 1]\) is \(\textit{d}(t,s) = 2^{-m}\) where \(m\) is the last \(n \in \mathbb{N}\) such that \({t}^{[n]} = {s}^{[n]}\) if it exists, \(\textit{d}(t,s) = 0\) otherwise.

The choice of \({ {\sf FinVar} -\Lambda^{\infty}_T }\) makes it easier and unproblematic to define \(\alpha\)-equivalence and substitution, which are as follows.

Definition 3 (\(\alpha\)-Equivalence on \({ {\sf FinVar} -\Lambda^{\infty}_T }\)). Let \(=_\alpha\) be the ordinary \(\alpha\)-equivalence over finite terms of system T + \(\bot\). For any \(t, u \in { {\sf FinVar} -\Lambda^{\infty}_T }\) define \[t =^\infty_\alpha u \qquad iff \qquad \forall n \in \mathbb{N}.\; {t}^{[n]} =_\alpha {u}^{[n]}\]

Proposition 4. The relation \(=^\infty_\alpha\) is a congruence over \({ {\sf FinVar} -\Lambda^{\infty}_T }\).

In view of the above, we consider the terms in \({ {\sf FinVar} -\Lambda^{\infty}_T }\) up to \(\alpha\)-equivalence, and define substitution corecursively as follows.

Definition 5 (Substitution on \({ {\sf FinVar} -\Lambda^{\infty}_T }\)). For \(t,s \in { {\sf FinVar} -\Lambda^{\infty}_T }\) and \(x \in {\sf Var}\) the substitution of \(s\) for \(x\) in \(t\), written \(t[x := s]\), is corecursively defined by:

  1. \(x[x := s] = s\), and \(y[x := s] = y\) for \({\sf Var}\ni y \neq x\)

  2. \((t\, t')[x := s] = (t[x := s])(t'[x := s])\)

  3. \((\lambda y{:}A.t)[x := s] = \lambda z{:}A.(t[y := z])[x := s]\) for the first \(z \not\in \{ y \} \cup {{\rm FV}}(t) \cup {{\rm FV}}(s)\)

  4. \(0[x := s] =0\) and \({\tt succ} (t)[x := s] = {\tt succ} (t[x := s])\)

  5. \({\tt cond} (t,t')[x := s] = {\tt cond} (t[x := s],t'[x := s])\)

In the clause [case:abs] above, the required \(z\) always exists because \({{\rm FV}}(t) \cup {{\rm FV}}(s)\) is finite, and its choice is immaterial by \(\alpha\)-equivalence.

Finally, a row term is regular if its syntactic tree is regular. We call \({ {\sf Reg} -\Lambda^{\infty}_T }\) the set of regular terms, which is clearly a (proper) subset of \({ {\sf FinVar} -\Lambda^{\infty}_T }\).

Reduction rules for \({ {\sf FinVar} -\Lambda^{\infty}_T }\), also called notions of reduction in the literature, include the usual \(\beta\)-reduction and an additional rule for the conditional.

Definition 6 (Reduction rules). Let \(f\), \(t\) and \(u\) be terms in \({ {\sf FinVar} -\Lambda^{\infty}_T }\). We define the \(\beta\)-reduction relation \(\mathbin{\mapsto} _\beta\) and the \({\tt cond}\)-reduction relation \(\mathbin{\mapsto} _ {\tt cond}\) as follows:

\(\beta\)-reduction:

\((\lambda x{:}A.t)(u) \mathbin{\mapsto} _\beta t[x := u]\),

\({\tt cond}\)-reduction:

\({\tt cond} (u,f)(0) \mathbin{\mapsto} _ {\tt cond} u\) and \({\tt cond} (u,f)( {\tt succ} (t)) \mathbin{\mapsto} _ {\tt cond} f(t)\).

As usual, the relation \(\mathbin{\mapsto}\) is the compatible closure of \(\mathbin{\mapsto} _\beta \, \cup \, \mathbin{\mapsto} _ {\tt cond}\), and \(\mathbin{\mapsto} ^*\) is its reflexive and transitive closure.

2 Well-typed terms and Global Trace Condition↩︎

Figure 1: Typing rules and the trace relation

To rule out meaningless row-terms like \(0\,0\) or \({\tt succ} (\lambda x{:}N.x)\), we introduce the typing system in Figure 1 for terms in \({ {\sf FinVar} -\Lambda^{\infty}_T }\). There are differences between our system and the inference rules of the simply typed \(\lambda\)-calculus and Gödel System \(T\). In our system, contexts are sequences of variable typings rather than sets. By \(x:A \in \Gamma\), we mean that \(x:A\) occurs in \(\Gamma\), and \(\Gamma \subseteq \Gamma'\) means that there is an injection from the first sequence into the second, possibly including permutations. We explicitly list the rule \({\tt wk}\) for weakening+exchange, which is not merely admissible. Further, the application rule is split into the rules \({{\tt ap}_{\tiny v}}\) and \({\tt ap} _{\neg v}\), depending on whether the term \(s\) in the subject \(t\,s\) of the conclusion is a variable: \({{\tt ap}_{\tiny v}}\) corresponds to a contraction between two occurrences of \(A\) in Logic. Finally, we add a pair of relations, represented by and arrows, linking variables in type contexts and types in the argument position of the derived type in the conclusion to variables and types in the premises of each rule. These relations are essential to the definition of traces below.

Definition 7 (Derivation tree).

  1. A judgment* is a triple \(\Gamma \vdash t:A\), where \(\Gamma = x_1:A, \ldots, x_n : A_n\) is a context, namely a finite sequence of pairs \(x_i:A_i\) with \(x_i \in {\sf Var}\) and \(A_i \in {\sf Type}\) and with pairwise distinct term variables, \(t \in { {\sf FinVar} -\Lambda^{\infty}_T }\) called the subject, and \(A \in {\sf Type}\) called the derived type.*

  2. A derivation* is any finite or infinite tree \(\Pi\) whose nodes are labeled with judgments and whose edges are instances of the rules in Figure 1, without infinite nesting of the \({\tt wk}\)-rule.*

  3. \(\Gamma \vdash t :A\) is derivable* if there exists a derivation \(\Pi\) with root \(\Gamma \vdash t :A\); then we say that \(t\) is well-typed, and denote by \({\sf WTyped}\) the set of such terms.*

We observe that both terms and derivations may be infinite trees, and only finite terms in \({\sf WTyped}\) are typable by finite derivations. A well-typed term does not necessarily have a unique derivation and type, even when the type context is fixed. Consider the family of closed terms \(t_n = t_{n+1} \,0\); then for each \(n \in \mathbb{N}\) we can find a derivation of \(\vdash t_n :N^n \rightarrow A\), where \(N^n\) is a list of \(n\) occurrences of \(N\) and \(A\) is arbitrary. Moreover, derivations are too weak to filter out infinite terms of the form \(t = (\lambda x{:}N.t)\,0: A\) or \(t = {\tt cond} (t, \lambda x{:}N.t)\, {\tt succ} (0): A\) that reduce infinitely often to a redex, never returning a meaningful output. These terms are called active in Kennaway et alii [1], [2]. We introduce the Global Trace Condition (GTC) for our system by adapting concepts from [4], [6] that rule out active well-typed terms. Moreover, the condition GTC rules out closed terms of type \(N\) that do not denote numbers, such as \(t = {\tt succ} (t) : N\), or do not denote total functionals, and enforces the uniqueness of typing.

Definition 8 (Traces and GTC).

  1. For each rule \(r\) in Figure 1, variables in the contexts and types in argument position of the derived types, which are connected by either a arrow, called stationary, or a arrow, called progressing, in Figure 1, are in trace relation. With \(\Gamma \,{\color{blue}{\to}}\, \Gamma'\) we abbreviate the trace relation \(x:A \, {\color{blue}{\to}} \, x:A\) for all \(x:A\) both in \(\Gamma\) and \(\Gamma'\).

  2. For any derivation \(\Pi\) of \(\Gamma \vdash t:A\), and branch \(\pi\) of \(\Pi\), a trace following \(\pi\) is any chain of trace relations among nodes of \(\pi\).

  3. A progress point* of a trace is a trace relation colored with , between the first argument \(N\) of \({\tt cond} (t,s): N,\vec{B} \rightarrow N\) and the first argument \(N\) of \(s: N,\vec{B} \rightarrow N\) in the right premise of the rule. A trace is progressing if it includes a progress point.*

  4. A derivation \(\Pi\) satisfies the GTC if for all infinite branches \(\pi\) of \(\Pi\), there is some trace from a node of \(\pi\) progressing infinitely many times. Such a derivation is called a proof.

  5. We denote by \({ {\sf GTC} -\Lambda^{\infty}_T }\) the set of terms in \({\sf WTyped}\) that have a proof.

In Figure 2, we illustrate the proof of the typing of the term \({\tt sum} = \lambda x{:}{N}. {\tt cond} (x,\lambda y{:}{N}. {\tt succ} ( {\tt sum} \,x\,y))\) for summation. We depict only the relevant arrows of the trace relations. Since \({\tt sum} \in { {\sf Reg} -\Lambda^{\infty}_T }\) (namely, it is regular), the proof itself is regular, and we represent it by a finite cyclic graph, where the only cycle is represented by the pair of the two \((\dagger)\) connected by a black arrow.

None

Figure 2: Typing of \({\tt sum} = \lambda x{:}{N}. {\tt cond} (x,\lambda y{:}{N}. {\tt succ} ( {\tt sum} \,x\,y))\).

Theorem 1 (Uniqueness of Types and Subject Reduction).

Let \(t \in { {\sf GTC} -\Lambda^{\infty}_T }\), then:

  1. For all \(\Gamma\), there exists a unique type \(A\) such that some \(\Gamma \vdash t:A\) is provable.

  2. If there is a proof of \(\Gamma \vdash t:A\) and \(t \mathbin{\mapsto} t'\) then \(\Gamma \vdash t':A\) is provable.

The proof of \(\Gamma \vdash t:A\) claimed in Theorem [theorem-uniqueness-typing] is not unique in general. However, it can be transformed into a (unique) canonical form by: (i) restricting the conclusion \(\Gamma' \vdash u:B\) of each instance of rule \(\not = {\tt wk}\) so that \({{\rm dom}}(\Gamma') = {{\rm FV}}(u)\); (ii) collapsing any two consecutive \({\tt wk}\) into one; (iii) removing identical \({\tt wk}\) and possibly adding at most one \({\tt wk}\) to the end.

Intuitively, a progress point represents the application of the conditional \({\tt cond} (t, s)\) to decreasing values of its argument. All other references to argument terms or potential values of free variables are considered stationary, meaning their values in an actual computation need not decrease. The GTC prevents infinite computations involving infinitely decreasing values of type \(N\). This is stated in the next section, where we relate infinitely progressing traces to strongly convergent reductions of transfinite length.

3 Infinite reduction and strong convergence↩︎

Given an ordinal \(\alpha\), either finite or infinite, a sequence of terms \((t_\beta)_{\beta < \alpha}\) is a reduction of length \(\alpha\) if for all \(\beta < \alpha\) we have \(t_\beta \mathbin{\mapsto} t_{\beta + 1}\). In the theory of the infinitary \(\lambda\)-calculus, normal forms (terms not including any redex) might be reached only in the limit, after infinitely many reduction steps; consistently, the concept of normalizing reduction is replaced by that of strongly convergent reduction, which does not necessarily yield a normal form but rather generates a sequence of terms that is Cauchy-convergent with respect to the term distance and such that the depth of contracted redexes tends to infinity (see [2]).

To reconcile strong convergence with the idea of strong normalization in type theory, we consider a stronger notion of possibly infinite reduction, which we call \({\tt cond}\)-convergence. In the following, a position is a finite string \(p \in \{ 1,2 \}^*\) representing a node in the syntactic tree of a term \(t \in { {\sf FinVar} -\Lambda^{\infty}_T }\), where the empty sequence is the root of \(t\); if \(t = \lambda x{:}A.t'\) or \(t = {\tt succ} (t')\) and \(p = 1\,q\), then \(p\) is the position \(q\) in \(t'\); if \(t = t't''\) or \(t = {\tt cond} (t',t'')\), then \(p = 1\,q\) is the position \(q\) in \(t'\), and \(p = 2\,q\) is the position \(q\) in \(t''\). If \(p\) is a position in \(t\), then \(t \upharpoonright p\) denotes the subterm of \(t\) rooted at \(p\).

Definition 9 (\({\tt cond}\)-Convergence). A position \(p\) in the syntactic tree of a term \(t \in { {\sf FinVar} -\Lambda^{\infty}_T }\) has \({\tt cond}\)-depth \(n\) if the number of \(2\)’s in \(p\) such that, for some \(q\), \(q\,2\) is a prefix of \(p\) and \(t \upharpoonright q\) is a \({\tt cond}\) term, is \(n\).

A reduction \((t_\beta)_{\beta < \alpha}\) is \({\tt cond}\)-convergent if for all limit ordinals \(\lambda \leq \alpha\), the limit of the \({\tt cond}\)-depth of the redex reduced in \(t_\beta\) for \(\beta < \lambda\) is infinite.

In words, a position \(p\) of a term \(t\) encodes a finite path from the root of the syntactic tree of \(t\); it has \({\tt cond}\)-depth \(n\) if it passes through the tree of the subterm \(t_2\) of some occurrence of \({\tt cond} (t_1, t_2)\) in \(t\) exactly \(n\) times. Remember that \({\tt cond} (t_1,t_2)( {\tt succ} (u)) \mathbin{\mapsto} t_2 (u)\), thereby mimicking the recursion mechanism via the nesting of \({\tt cond}\) in \(t_2\). Hence, an infinite \({\tt cond}\)-convergent reduction is one in which no redex on the right branch of a \({\tt cond}\) can be contracted infinitely often.

Any \({\tt cond}\)-convergent reduction is strongly convergent, but not vice versa. We can establish the following results.

Theorem 2 (Strong convergence of terms in \({ {\sf GTC} -\Lambda^{\infty}_T }\)). Let \(t \in { {\sf GTC} -\Lambda^{\infty}_T }\), then:

  1. All reductions out of \(t\) are \({\tt cond}\)-convergent and, consequently, strongly convergent.

  2. All reductions from \(t\) always reducing some redex of minimum \({\tt cond}\)-depth end in at most \(\omega\) steps to some normal form. If, furthermore, \(t\) is a closed term of type \(N\), then such reductions terminate in finitely many steps in some \({\tt succ} ^n(0)\).

We briefly mention additional properties of terms in \({ {\sf GTC} -\Lambda^{\infty}_T }\) that are not covered in the paper. Typability is preserved not only under finite reductions, as stated in Theorem 1.[thr:SR], but also in the limit. As for \(\Lambda^\infty\), confluence does not hold in general because of infinite reductions, but it holds in the limit. This allows us to show that the numeral in [thr:main-3] above is unique. Finally, we conjecture that the expressive power of our system is the same as that of Das’s system \(CT\) and, hence, Goedel’s system \(T\).

References↩︎

[1]
J. R. Kennaway, J. W. Klop, M. R. Sleep, and F. J. de Vries, “Infinitary lambda calculus,” Theoretical Computer Science, vol. 175, no. 1, pp. 93–125, 1997, doi: https://doi.org/10.1016/S0304-3975(96)00171-5.
[2]
J. R. Kennaway and F.-J. de Vries, “Infinitary rewriting,” in Term rewriting systems, vol. 55, Terese, Ed. Cambridge University Press, 2003, pp. 668–711.
[3]
A. Das, A circular version of Gödel’s T and its abstraction complexity,” CoRR, vol. abs/2012.14421, 2020, [Online]. Available: https://arxiv.org/abs/2012.14421.
[4]
A. Das, On the Logical Strength of Confluence and Normalisation for Cyclic Proofs,” in 6th international conference on formal structures for computation and deduction, FSCD 2021, july 17-24, 2021, buenos aires, argentina (virtual conference), 2021, vol. 195, pp. 29:1–29:23, doi: 10.4230/LIPICS.FSCD.2021.29.
[5]
A. Kurz, D. Petrisan, P. Severi, and F.-J. de Vries, “An alpha-corecursion principle for the infinitary lambda calculus,” in Coalgebraic methods in computer science - 11th international workshop, CMCS 2012, colocated with ETAPS 2012, tallinn, estonia, march 31 - april 1, 2012, revised selected papers, 2012, vol. 7399, pp. 130–149, doi: 10.1007/978-3-642-32784-1\_8.
[6]
J. Brotherston and A. Simpson, “Sequent calculi for induction and infinite descent,” J. Log. Comput., vol. 21, no. 6, pp. 1177–1216, 2011, doi: 10.1093/LOGCOM/EXQ052.

  1. Computer Science Department, Turin University, Torino, Italy↩︎

  2. Department of Information Science, Toho University, Japan↩︎