Focusing on Binding and Computation
Logic in Computer Science
Variable binding is a prevalent feature of the syntax and proof theory of many logical systems. In this paper, we define a programming language that provides intrinsic support for both representing and computing with binding. This language is extracted as the Curry-Howard interpretation of a focused sequent calculus with two kinds of implication, of opposite polarity. The representational arrow extends systems of definitional reflection with the notion of a scoped inference rule, which permits
... he adequate representation of binding via higher-order abstract syntax. On the other hand, the usual computational arrow classifies recursive functions over such higher-order data. Unlike many previous approaches, both binding and computation can mix freely. Following Zeilberger [POPL 2008], the computational function space admits a form of openendedness, in that it is represented by an abstract map from patterns to expressions. As we demonstrate with Coq and Agda implementations, this has the important practical benefit that we can reuse the pattern coverage checking of these tools. 1 1 I.e., the rule "reflects" upon the possible proofs of P according to its definition. 1 Our work began by observing a seeming paradox about the polarity of variable binding: In some respects, binding behaves like implication, ordinarily negative, with application defined by substitution. However, it is also possible to pattern-match against data with variable binding, suggesting it may correspond to a positive connective. In this paper, we propose an extension of definitional reflection called definitional variation, which, via Curry-Howard, yields a functional programming language with intrinsic support for representing and computing with binding. We present this logic as a focused sequent calculus in which the definitions of atoms are open-ended, and can be varied by means of logical connectives. One such connective is indeed a positive form of implication R ⇒ A, called the representational arrow. A proof of R ⇒ A is a proof of A which may use the additional inference rule R: this connective introduces a new, scoped inference rule, which corresponds to a new, scoped datatype constructor. The representational arrow thus provides an abstraction for encoding binding through higher-order abstract syntax. On the other hand, the familiar computational arrow →, of negative polarity, classifies clausal, pattern-matching functions over such higher-order data. This yields a programming language which has the expressiveness of ML (via the computational arrow) while permitting direct representations of variable binding (via the representational arrow). Moreover, both function spaces can be used in datatype definitions, providing datatypes that freely mix binding and computation. We leave the study of a dependent version of this language, which would enrich a type theory such as Coq with intrinsic support for binding and scope, to future work. Following Zeilberger , our computational arrow admits a form of open-endedness, in that such functions are represented abstractly by meta-level functions from patterns to expressions. These meta-level functions can be taken to be constructive, in which case all implications are effectively computable, or nonconstructive, in which case the operational behavior is necessarily oracular (as in Howe ). The openendedness of the computational arrow has important practical benefits. First, these meta-level functions can be presented as programs in existing proof assistants, which permits us to reuse existing pattern coverage checkers. Second, open-endedness means that functions written in several proof assistants, using different implementations of binding, can be combined in a single program. The technical contributions of this paper are as follows: • In Section 2, we present a focused sequent calculus for definitional variation, and give the expansions and reductions witnessing admissibility of identity and cut. • In Section 3, we discuss some interesting distributivity properties of ⇒, and prove that the type theory includes (simply-typed) LF as a subsystem-proving that the representational arrow adequately represents binding. • In Section 4, we give a proof term assignment to our sequent calculus, yielding a functional programming language with an operational semantics given by cut elimination. We prove type safety, and illustrate programming in this language via several examples that mix binding and computation. Additionally, we discuss implementations of the type theory in Agda [Norell, 2007] and Coq [Bertot and Castéran, 2004] . We now describe the high-level differences between our approach to representing binding and other techniques which have been discussed in the literature. We defer a detailed, technical comparison with related work to Section 5.