Programming and Reasoning with Guarded Recursion for Coinductive Types [chapter]

Ranald Clouston, Aleš Bizjak, Hans Bugge Grathwohl, Lars Birkedal
2015 Lecture Notes in Computer Science  
We present the guarded lambda-calculus, an extension of the simply typed lambda-calculus with guarded recursive and coinductive types. The use of guarded recursive types ensures the productivity of well-typed programs. Guarded recursive types may be transformed into coinductive types by a type-former inspired by modal logic and Atkey-McBride clock quantification, allowing the typing of acausal functions. We give a call-by-name operational semantics for the calculus, and define adequate
more » ... nal semantics in the topos of trees. The adequacy proof entails that the evaluation of a program always terminates. We demonstrate the expressiveness of the calculus by showing the definability of solutions to Rutten's behavioural differential equations. We introduce a program logic with Löb induction for reasoning about the contextual equivalence of programs. 3 unfolding indefinitely. We define adequate denotational semantics in the topos of trees [6] and as a consequence prove normalisation. We introduce a program logic Lgλ for reasoning about the denotations of gλ-programs; given adequacy this permits proofs about the operational behaviour of terms. The logic is based on the internal logic of the topos of trees, with modalities , on predicates, and Löb induction for reasoning about functions on both guarded recursive and coinductive types. We demonstrate the expressiveness of the calculus by showing the definability of solutions to Rutten's behavioural differential equations [20] , and show that Lgλ can be used to reason about them, as an alternative to standard bisimulation-based arguments. We have implemented the gλ-calculus in Agda, a process we found helpful when fine-tuning the design of our calculus. The implementation, with many examples, is available at http://cs.au.dk/~hbugge/gl-agda.zip. Guarded λ-calculus This section presents the guarded λ-calculus, written gλ, its call-by-name operational semantics, and its types, then gives some examples. Definition 2.1. gλ-terms are given by the grammar x is a variable and σ = [x 1 ← t 1 , . . . , x n ← t n ], usually abbreviated [ x ← t], is a list of variables paired with terms. prev[ x ← t].t and box[ x ← t].t bind all variables of x in t, but not in t. We write prev ι.t for prev[ x ← x].t where x is a list of all free variables of t. If furthermore t is closed we simply write prev t. We will similarly write box ι.t and box t. We adopt the convention that prev and box have highest precedence. We may extend gλ with sums; for space reasons we leave these to App. C. Definition 2.2. The reduction rules on closed gλ-terms are The rules above look like standard β-reduction, removing 'roundabouts' of introduction then elimination, with the exception of those regarding prev and next. An apparently more conventional β-rule for these term-formers would be prev[ x ← t].(next t) → t [ t/ x]
doi:10.1007/978-3-662-46678-0_26 fatcat:cvxdii63ivgc3pdrlv3ckawrj4