Higher-Order and Symbolic Computation,, 12, 171–201 (1999) c 1999 Kluwer Academic Publishers. Manufactured in The Netherlands. Computing with Contexts IAN A. MASON iam@turing.une.edu.au School of Mathematical and Computer Sciences, University of New England, NSW, Australia, 2351 Abstract. We investigate a representation of contexts, expressions with holes in them, that enables them to be meaningfully transformed, in particular α-converted and β-reduced. In particular we generalize the set of λ-expressions to include holes, and on these generalized entities define β-reduction (i.e., substitution) and filling so that these operations preserve α-congruence and commute. The theory is then applied to allow the encoding of reduction systems and operational semantics of call-by-value calculi enriched with control, imperative and concurrent features. Keywords: λ-calculus, contexts, operational semantics, theorem proving 1. Introduction Contexts, expressions with holes in them, play an increasingly important role in the lambda calculus and its applications to Computer Science. We list some recent examples of their use: They provide an elegant description of reduction strategies (e.g., lazy, left-first depth first) via evaluation and reduction contexts [8]. They feature in the operational semantics of control, imperative and concurrent features [3, 7, 18]. They are center stage in the definition of operational equivalence [20]. They are similarly prominent in the characterization of operational equivalence via context lemmas [19]. They have recently been used to great effect as modalities akin to Hoare triples in logics for functional programming languages with effects [12]. Even more recently they have been used as a powerful technique for establishing reasoning principles for a very general class of programming languages [27]. 1.1. Related approaches There has also been a lot of recent interest in developing theories and calculi for mani- pulating and computing with contexts, and closely related concepts. We provide a few notable examples. Talcott [25, 26] presents a theory of (de Bruijn) binding structures akin to abstract algebras. Her notion of binding structures extends abstract data types by incor- porating binding mechanisms and structures with holes. She provides three applications of her theory: term rewriting; a unification theory for binding structures; and a basis for an inference system for quantified first order logic. Her work is motivated by building tools such as theorem provers, rewriters, static analyzers, evaluators and transformers. Sands [23] outlines the use of higher-order syntax to represent and compute with contexts in a very general manner. In this approach holes are represented by function variables applied to the sequence of variables that the hole is supposed to trap. Filling is then represented