265 research outputs found
Abstraction and Invariance for Algebraically Indexed Types
Reynoldsâ relational parametricity provides a powerful way to reason about programs in terms of invariance under changes of data representation. A dazzling array of applications of Reynoldsâ theory exists, exploiting invariance to yield âfree theoremsâ, non-inhabitation results, and encodings of algebraic datatypes. Outside computer science, invariance is a common theme running through many areas of mathematics and physics. For example, the area of a triangle is unaltered by rotation or flipping. If we scale a triangle, then we scale its area, maintaining an invariant relationship be-tween the two. The transformations under which properties are in-variant are often organised into groups, with the algebraic structure reflecting the composability and invertibility of transformations. In this paper, we investigate programming languages whose types are indexed by algebraic structures such as groups of geometric transformations. Other examples include types indexed by principalsâfor information flow securityâand types indexed by distancesâfor analysis of analytic uniform continuity properties. Following Reynolds, we prove a general Abstraction Theorem that covers all these instances. Consequences of our Abstraction Theorem include free theorems expressing invariance properties of programs, type isomorphisms based on invariance properties, and non-definability results indicating when certain algebraically indexed types are uninhabited or only inhabited by trivial programs. We have fully formalized our framework and most examples in Coq
Indexed Induction and Coinduction, Fibrationally
This paper extends the fibrational approach to induction and coinduction
pioneered by Hermida and Jacobs, and developed by the current authors, in two
key directions. First, we present a dual to the sound induction rule for
inductive types that we developed previously. That is, we present a sound
coinduction rule for any data type arising as the carrier of the final
coalgebra of a functor, thus relaxing Hermida and Jacobs' restriction to
polynomial functors. To achieve this we introduce the notion of a quotient
category with equality (QCE) that i) abstracts the standard notion of a
fibration of relations constructed from a given fibration; and ii) plays a role
in the theory of coinduction dual to that played by a comprehension category
with unit (CCU) in the theory of induction. Secondly, we show that inductive
and coinductive indexed types also admit sound induction and coinduction rules.
Indexed data types often arise as carriers of initial algebras and final
coalgebras of functors on slice categories, so we give sufficient conditions
under which we can construct, from a CCU (QCE) U:E \rightarrow B, a fibration
with base B/I that models indexing by I and is also a CCU (resp., QCE). We
finish the paper by considering the more general case of sound induction and
coinduction rules for indexed data types when the indexing is itself given by a
fibration
Indexed induction and coinduction, fibrationally.
This paper extends the fibrational approach to induction and coinduction pioneered by Hermida and Jacobs, and developed by the current authors, in two key directions. First, we present a sound coinduction rule for any data type arising as the final coalgebra of a functor, thus relaxing Hermida and Jacobsâ restriction to polynomial data types. For this we introduce the notion of a quotient category with equality (QCE), which both abstracts the standard notion of a fibration of relations constructed from a given fibration, and plays a role in the theory of coinduction dual to that of a comprehension category with unit (CCU) in the theory of induction. Second, we show that indexed inductive and coinductive types also admit sound induction and coinduction rules. Indexed data types often arise as initial algebras and final coalgebras of functors on slice categories, so our key technical results give sufficent conditions under which we can construct, from a CCU (QCE) U : E -> B, a fibration with base B/I that models indexing by I and is also a CCU (QCE)
Generating Bijections between HOAS and the Natural Numbers
A provably correct bijection between higher-order abstract syntax (HOAS) and
the natural numbers enables one to define a "not equals" relationship between
terms and also to have an adequate encoding of sets of terms, and maps from one
term family to another. Sets and maps are useful in many situations and are
preferably provided in a library of some sort. I have released a map and set
library for use with Twelf which can be used with any type for which a
bijection to the natural numbers exists.
Since creating such bijections is tedious and error-prone, I have created a
"bijection generator" that generates such bijections automatically together
with proofs of correctness, all in the context of Twelf.Comment: In Proceedings LFMTP 2010, arXiv:1009.218
Relational parametricity for higher kinds
Reynoldsâ notion of relational parametricity has been extremely influential and well studied for polymorphic programming languages and type theories based on System F. The extension of relational parametricity to higher kinded polymorphism, which allows quantification over type operators as well as types, has not received as much attention. We present a model of relational parametricity for System FÏ, within the impredicative Calculus of Inductive Constructions, and show how it forms an instance of a general class of models defined by Hasegawa. We investigate some of the consequences of our model and show that it supports the definition of inductive types, indexed by an arbitrary kind, and with reasoning principles provided by initiality
- âŠ