## The safe lambda calculus (2007)

Venue: | of Lecture Notes in Computer Science |

Citations: | 5 - 1 self |

### BibTeX

@INPROCEEDINGS{Blum07thesafe,

author = {William Blum and C. -h and Luke Ong},

title = {The safe lambda calculus},

booktitle = {of Lecture Notes in Computer Science},

year = {2007},

pages = {39--53},

publisher = {Springer}

}

### OpenURL

### Abstract

Abstract. Safety is a syntactic condition of higher-order grammars that constrains occurrences of variables in the production rules according to their type-theoretic order. In this paper, we introduce the safe lambda calculus, which is obtained by transposing (and generalizing) the safety condition to the setting of the simply-typed lambda calculus. In contrast to the original definition of safety, our calculus does not constrain types (to be homogeneous). We show that in the safe lambda calculus, there is no need to rename bound variables when performing substitution, as variable capture is guaranteed not to happen. We also propose an adequate notion of β-reduction that preserves safety. In the same vein as Schwichtenberg’s 1976 characterization of the simply-typed lambda calculus, we show that the numeric functions representable in the safe lambda calculus are exactly the multivariate polynomials; thus conditional is not definable. We also give a characterization of representable word functions. We then study the complexity of deciding beta-eta equality of two safe simply-typed terms and show that this problem is PSPACE-hard. Finally we give a game-semantic analysis of safety: We show that safe terms are denoted by P-incrementally justified strategies. Consequently pointers in the game semantics of safe λ-terms are only necessary from order 4 onwards.

### Citations

218 |
On Full Abstraction for PCF
- Hyland, Ong
- 2000
(Show Context)
Citation Context ...sals over a souped-up abstract syntax tree of the η-long form of M. In the language of game semantics, traversals are just (concrete representations of) the uncovering (in the sense of Hyland and Ong =-=[18]-=-) of plays in the strategy denotation. The useful transference technique between plays and traversals was originally introduced by the second author [30] for studying the decidability of monadic secon... |

205 | Full abstraction for PCF
- Abramsky, Jagadeesan, et al.
(Show Context)
Citation Context ... ψ(λϕ.ϕa) : o] where M2 denotes the unsafe Kierstead term.30 W. BLUM AND C.-H. L. ONG Towards a fully abstract game model. The standard game models which have been shown to be fully abstract for PCF =-=[2, 18]-=- are of course also fully abstract for the restricted language safe PCF. One may ask, however, whether there exists a fully abstract model with respect to safe context only. Such model may be obtained... |

167 |
The essence of Algol
- Reynolds
- 1981
(Show Context)
Citation Context ... have Theorem 4.14. Safe PCF terms have P-incrementally justified denotations. Similarly, we can define safe IA to be safe PCF augmented with the imperative features of Idealized Algol (IA for short) =-=[32]-=-. Adapting the game-semantic correspondence and safety characterization to IA seems feasible although the presence of the base type var, whose game arena com N ×exp has infinitely many initial moves, ... |

65 |
Intuitionistic propositional logic is polynomial-space complete
- Statman
- 1979
(Show Context)
Citation Context ...habited. For instance σ(1,3,4) is inhabited by the safe term λx 1a→3b y 3b→4c z 1c .y(x(λu a .u)) . The order-4 type σ(0,2,0), however, is only inhabited by the unsafe term λxyz.y(xz). Statman showed =-=[35]-=- that the problem of deciding whether a type defined over an infinite number of ground atoms is inhabited (or equivalently of deciding validity of an intuitionistic implicative formula) is PSPACE-comp... |

64 |
2002): On infinite terms having a decidable monadic theory
- Caucal
(Show Context)
Citation Context ...[11] to an equivalence result with respect to generating trees: A ranked tree is generated by an order-n safe grammar if and only if it is generated by an order-n pushdown automaton. • Graphs. Caucal =-=[9]-=- has shown that the MSO theories of graphs generated 3 by safe grammars of every finite order are decidable. Recently Hague et al. have shown that the MSO theories of graphs generated by order-n unsaf... |

63 |
Indexed grammars, an extension of contextfree grammars
- Aho
- 1968
(Show Context)
Citation Context ...hierarchy gives an attractive classification of the semi-decidable languages: Levels 0, 1 and 2 of the hierarchy are respectively the regular, context-free, and indexed languages (in the sense of Aho =-=[5]-=-), although little is known about higher orders. Remarkably, for generating word languages, order-n safe grammars are equivalent to order-n pushdown automata [11], which are in turn equivalent to orde... |

54 | Game semantics
- Abramsky, McCusker
- 1998
(Show Context)
Citation Context ... Our aim is to characterize safety by game semantics. We shall assume that the reader is familiar with the basics of game semantics; for an introduction, we recommend Abramsky and McCusker’s tutorial =-=[3]-=-. Recall that a justified sequence over an arena is an alternating sequence of O-moves and P-moves such that every move m, except the opening move, has a pointer to some earlier occurrence of the move... |

47 | On model-checking trees generated by higher-order recursion schemes
- Ong
- 2006
(Show Context)
Citation Context ...ed with the conditional function. In the same vein, we show that the numeric functions representable in the safe lambda calculus are exactly the multivariate polynomials. 2 It has recently been shown =-=[30]-=- that trees generated by unsafe deterministic grammars (of every finite order) also have decidable MSO theories. More precisely, the MSO theory of trees generated by order-n recursion schemes is n-EXP... |

46 | Higher-order pushdown trees are easy
- Knapik, Niwinski, et al.
- 2002
(Show Context)
Citation Context ...y pointers in the game semantics of safe λ-terms are only necessary from order 4 onwards. Introduction Background. The safety condition was introduced by Knapik, Niwiński and Urzyczyn at FoSSaCS 2002 =-=[19]-=- in a seminal study of the algorithmics of infinite trees generated by higher-order grammars. The idea, however, goes back some twenty years to Damm [10] who introduced an essentially equivalent 1 syn... |

44 |
The IO- and OI-hierarchies
- Damm
- 1982
(Show Context)
Citation Context ... Knapik, Niwiński and Urzyczyn at FoSSaCS 2002 [19] in a seminal study of the algorithmics of infinite trees generated by higher-order grammars. The idea, however, goes back some twenty years to Damm =-=[10]-=- who introduced an essentially equivalent 1 syntactic restriction (for generators of word languages) in the form of derived types. A higher-order grammar (that is assumed to be homogeneously typed) is... |

44 |
J.-Y.Marion, Lambda calculus characterizations of poly-time
- Leivant
- 1993
(Show Context)
Citation Context ... Curry-Howard Isomorphism? Does the safe lambda calculus characterize a complexity class, in the same way that the simply-typed lambda calculus characterizes the polytime-computable numeric functions =-=[21]-=-? Is the addition of unsafe contexts to safe ones conservative with respect to observational (or contextual) equivalence? With a view to algorithmic game semantics and its applications, it would be in... |

36 |
The expressiveness of simple and second-order type structures
- Fortune, Leivant, et al.
- 1983
(Show Context)
Citation Context ... the safety constraint is to introduce countably many domains of representation for natural numbers. Such a technique is used to represent the predecessor function in the simply-typed lambda calculus =-=[14]-=-. (ii) The boolean conditional can be represented in the safe lambda calculus as follows: We encode booleans by terms of type B = (o,o,o). The two truth values are then represented by λx o y o .x and ... |

35 | Collapsible pushdown automata and recursion schemes
- Hague, Murawski, et al.
- 2008
(Show Context)
Citation Context ...e decidable. Recently Hague et al. have shown that the MSO theories of graphs generated by order-n unsafe grammars are undecidable, but deciding their modal mu-calculus theories is n-EXPTIME complete =-=[17]-=-. Overview. In this paper, we examine the safety condition in the setting of the lambda calculus. Our first task is to transpose it to the lambda calculus and express it as an appropriate sub-system o... |

33 | Reasoning about Idealized Algol using regular languages
- Ghica, McCusker
(Show Context)
Citation Context ...yclic graph”. The possibility of representing plays without some or all of their pointers under the safety assumption suggests potential applications in algorithmic game semantics. Ghica and McCusker =-=[15]-=- were the first to observe that pointers are unnecessary for representing plays in the game semantics of the second-order finitary fragment of Idealized Algol (IA2 for short). Consequently observation... |

23 |
The typed lambda calculus is not elementary recursive
- Statman
- 1979
(Show Context)
Citation Context ...ing the validity of such formulae requires nonelementary time [26]. A famous result by Statman states that deciding the βη-equality of two first-order typable lambda-terms is not elementary recursive =-=[36]-=-. The proof proceeds by encoding the Henkin quantifier elimination of type theory in the simply-typed lambda calculus and by appealing to Meyer’s result [26]. Simpler proofs have subsequently been giv... |

22 |
Safety is not a restriction at level 2 for string languages
- Aehlig, Miranda, et al.
- 2005
(Show Context)
Citation Context ...transpose it to the lambda calculus and express it as an appropriate sub-system of the simply-typed theory. A first version of the safe lambda calculus has appeared in an unpublished technical report =-=[4]-=-. Here we propose a more general and cleaner version where terms are no longer required to be homogeneously typed (see Section 1 for a definition). The formation rules of the calculus are designed to ... |

21 |
The Inherent Computational Complexity of Theories of Ordered Sets
- Meyer
- 1974
(Show Context)
Citation Context ...k+1 . Formulae are built up from prime formulae using the logical connectives ∧,∨,→,¬ and the quantifiers ∀ and ∃. Meyer showed that deciding the validity of such formulae requires nonelementary time =-=[26]-=-. A famous result by Statman states that deciding the βη-equality of two first-order typable lambda-terms is not elementary recursive [36]. The proof proceeds by encoding the Henkin quantifier elimina... |

20 | A simple proof of a theorem of Statman
- Mairson
- 1992
(Show Context)
Citation Context ...s by encoding the Henkin quantifier elimination of type theory in the simply-typed lambda calculus and by appealing to Meyer’s result [26]. Simpler proofs have subsequently been given: one by Mairson =-=[23]-=- and another by Loader [22]. Both proceed by encoding the Henkin quantifier elimination procedure in the lambda calculus, as in the original proof, but their use of list iteration to implement quantif... |

20 | Third-order Idealized Algol with iteration is decidable
- Murawski, Walukiewicz
- 2005
(Show Context)
Citation Context ...lence for this fragment can be reduced to the problem of equivalence of regular expressions. At order 3, although pointers are necessary, deciding observational equivalence of IA3 is EXPTIME-complete =-=[29, 28]-=-. Restricting the problem to the safe fragment of IA3 may lead to a lower complexity.THE SAFE LAMBDA CALCULUS 31 5. Further work and open problems The safe lambda calculus is still not well understoo... |

18 |
An automata-theoretical characterization of the OI-hierarchy
- Damm, Goerdt
- 1986
(Show Context)
Citation Context ...manifestly important. As we survey in the following, higher-order safe grammars capture fundamental structures in computation and offer clear algorithmic advantages: • Word languages. Damm and Goerdt =-=[11]-=- have shown that the word languages generated by order-n safe grammars form an infinite hierarchy as n varies over the natural numbers. The hierarchy gives an attractive classification of the semi-dec... |

18 | Notes on simply typed lambda calculus
- Loader
- 1998
(Show Context)
Citation Context ...antifier elimination of type theory in the simply-typed lambda calculus and by appealing to Meyer’s result [26]. Simpler proofs have subsequently been given: one by Mairson [23] and another by Loader =-=[22]-=-. Both proceed by encoding the Henkin quantifier elimination procedure in the lambda calculus, as in the original proof, but their use of list iteration to implement quantifier elimination makes them ... |

17 |
On program equivalence in languages with ground-type references
- Murawski
- 2003
(Show Context)
Citation Context ...], a version of IA where multiple uses of arguments are allowed only if they do not “overlap in time”. We believe that a PUR language can be obtained by imposing the safety condition on IA3. Murawski =-=[27]-=- has shown that observational equivalence for IA4 is undecidable; is observational equivalence for safe IA4 decidable? Acknowledgment. We thank Ugo dal Lago for the insightful discussions we had durin... |

16 |
Multilevel stack automata
- Maslov
- 1976
(Show Context)
Citation Context ... known about higher orders. Remarkably, for generating word languages, order-n safe grammars are equivalent to order-n pushdown automata [11], which are in turn equivalent to order-n indexed grammars =-=[24, 25]-=-. • Trees. Knapik et al. have shown that the Monadic Second Order (MSO) theories of trees generated by safe (deterministic) grammars of every finite order are decidable 2 . They have also generalized ... |

13 | Data-Abstraction Refinement: A Game Semantic Approach - Dimovski, Ghica, et al. - 2005 |

9 |
The hierarchy of indexed languages of an arbitrary level
- Maslov
- 1974
(Show Context)
Citation Context ... known about higher orders. Remarkably, for generating word languages, order-n safe grammars are equivalent to order-n pushdown automata [11], which are in turn equivalent to order-n indexed grammars =-=[24, 25]-=-. • Trees. Knapik et al. have shown that the Monadic Second Order (MSO) theories of trees generated by safe (deterministic) grammars of every finite order are decidable 2 . They have also generalized ... |

8 |
Structures Generated by Higher-Order Grammars and the Safety Constraint, D.Phil thesis submitted
- Miranda
- 2006
(Show Context)
Citation Context ...phrases: lambda calculus, higher-order recursion scheme, safety restriction, game semantics. Some of the results presented here were first published in TLCA proceedings [8]. 1 See de Miranda’s thesis =-=[12]-=- for a proof. LOGICAL METHODS IN COMPUTER SCIENCE DOI:10.2168/LMCS-5 (1:3) 2009 c○ W. Blum and C.-H. L. Ong ○CC Creative Commons2 W. BLUM AND C.-H. L. ONG itself is manifestly important. As we survey... |

5 | An approach to deciding observational equivalence of algol-like languages
- Ong
- 2004
(Show Context)
Citation Context ...lence for this fragment can be reduced to the problem of equivalence of regular expressions. At order 3, although pointers are necessary, deciding observational equivalence of IA3 is EXPTIME-complete =-=[29, 28]-=-. Restricting the problem to the safe fragment of IA3 may lead to a lower complexity.THE SAFE LAMBDA CALCULUS 31 5. Further work and open problems The safe lambda calculus is still not well understoo... |

5 |
Definierbare funktionen im lambda-kalkul mit typen
- Schwichtenberg
- 1976
(Show Context)
Citation Context ...lower the expressivity of the simply-typed lambda calculus. Our next contribution is to give a precise measure of the expressivity deficit of the safe lambda calculus. An old result of Schwichtenberg =-=[34]-=- says that the numeric functions representable in the simply-typed lambda calculus are exactly the multivariate polynomials extended with the conditional function. In the same vein, we show that the n... |

4 | Game semantics for region analysis - Greenland - 2004 |

4 |
λ-Definability on free algebras
- Zaionc
- 1992
(Show Context)
Citation Context ...able in the lambda calculus was extended to richer structures: Zaionc studied the problem for word functions, then functions over trees and eventually the general case of functions over free algebras =-=[20, 39, 38, 37, 40]-=-. In this section we consider the case of word functions expressible in the safe lambda calculus. Word functions. We consider a binary alphabet Σ = {a,b}. The result of this section naturally extends ... |

3 | Functions over free algebras definable in the simply typed lambda calculus
- Leivant
- 1993
(Show Context)
Citation Context ...able in the lambda calculus was extended to richer structures: Zaionc studied the problem for word functions, then functions over trees and eventually the general case of functions over free algebras =-=[20, 39, 38, 37, 40]-=-. In this section we consider the case of word functions expressible in the safe lambda calculus. Word functions. We consider a binary alphabet Σ = {a,b}. The result of this section naturally extends ... |

2 |
Semantics via game theory
- Abramsky
(Show Context)
Citation Context ... play are uniquely recoverable from the underlying sequence of moves. We name this class PUR. IA2 is the paradigmatic example of a PUR-language. Another example is Serially Re-entrant Idealized Algol =-=[1]-=-, a version of IA where multiple uses of arguments are allowed only if they do not “overlap in time”. We believe that a PUR language can be obtained by imposing the safety condition on IA3. Murawski [... |

2 |
On the lambda-definable tree operations
- Zaionc
- 1988
(Show Context)
Citation Context ... → o. Thus a closed term of type τ → τ → ... → τ represents an n-ary function over trees. Zaionc gave a characterization of the set of tree functions representable in the simply-typed lambda calculus =-=[38]-=-: It is precisely the minimal set containing constant functions, projections and closed under composition and limited primitive recursion. Zaionc20 W. BLUM AND C.-H. L. ONG showed that the same chara... |

2 |
Lambda representation of operations between different term algebras
- Zaionc
(Show Context)
Citation Context ...able in the lambda calculus was extended to richer structures: Zaionc studied the problem for word functions, then functions over trees and eventually the general case of functions over free algebras =-=[20, 39, 38, 37, 40]-=-. In this section we consider the case of word functions expressible in the safe lambda calculus. Word functions. We consider a binary alphabet Σ = {a,b}. The result of this section naturally extends ... |

1 | P = NP, up to sharing
- Asperti
(Show Context)
Citation Context ...d to use only existential quantifiers, thus the safe lambda calculus is also NP-hard. Asperti gave an interpretation of SAT in the simply-typed lambda calculus but his encoding relies on unsafe terms =-=[6]-=-. Remark 3.5. (i) Because the safety condition restricts expressivity in a non-trivial way, one can reasonably expect the beta-eta equivalence problem to have a lower complexity in the safe case than ... |

1 |
The complexity of beta-reduction in low orders
- Schubert
- 2001
(Show Context)
Citation Context ...ambda calculus. (iv) A related problem is that of beta-reduction: “Given a β-normal term M1 and a term M2, does M2 β-reduce to M1?”. It is known to be PSPACE-complete when restricted to order-3 terms =-=[33]-=-, but no complexity result is known for higher orders. The safe case can potentially give rise to interesting complexity characterizations at higher-orders.26 W. BLUM AND C.-H. L. ONG 4. A game-seman... |

1 |
Word operation definable in the typed lambda-calculus
- Zaionc
- 1987
(Show Context)
Citation Context ... contains only safe terms but the sets Aτ Σ in general may contain unsafe terms. Let Σ denote the alphabet {x,y : I,z : o,α : o → o}. By an easy reasoning (See the term grammar construction of Zaionc =-=[37]-=-), we can derive the following equations inducing a grammar over the set of terminals Σ ∪ {λxyαz.,λz.} that generates precisely the terms of N (I,I,I) ∅ : N (I,I,I) ∅ → λxyαz.A o Σ A o Σ → z | A (o,o)... |