Research
λ calculus Agda Bidirectional Updating Burrows-Wheeler Transform Concurrency Converse-of-a-Function Theorem Curry-Howard Data Structure Dependent Type Fibonacci GADT Greedy Theorem Haskell HaXML List Homomorphism Logic Logic Programming Program Derivation Program Inversion Quantum Programming Quine Regular Expression Segment Problems Termination Thinning Theorem Types XML Streaming-
Recent Comments
- 先寬度標記 on Theory and applications of inverting functions as folds.
- Liang-Ting Chen on Proof Irrelevance, Extensional Equality, and the Excluded Middle
- Shin on Proof Irrelevance, Extensional Equality, and the Excluded Middle
- speleologic on Proof Irrelevance, Extensional Equality, and the Excluded Middle
- Dan Doel on No Inverses for Injective but Non-Surjective Functions?
AoPA — Algebra of Programming in Agda
[Last update: Sep. 28, 2008]
An Agda library accompanying the paper Algebra of Programming in Agda: Dependent Types for Relational Program Derivation, developed in co-operation with Hsiang-Shang Ko and Patrik Jansson.
Dependent type theory is rich enough to express that a program satisfies an input/output relational specification, but it could be hard to construct the proof term. On the other hand, squiggolists know very well how to show that one relation is included in another by algebraic reasoning. The AoPA library allows one to encode Algebra of Programming style program derivation, both functional and relational, in Agda.
Example
The following is a derivation of insertion sort in progress:
The type of
isort-deris a proposition that there exists a functionfthat is contained inordered ? ◦ permute, a relation mapping a list to one of its ordered permutations. The proof proceeds by derivation from the specification towards the algorithm. The first step exploits monotonicity of◦and thatpermutecan be expressed as a fold. The second step makes use of relational fold fusion. The shaded areas denote interaction points — fragments of (proof ) code to be completed. The programmer can query Agda for the expected type and the context of the shaded expression. When the proof is completed, an algorithmisortis obtained by extracting the witness of the proposition. It is an executable program that is backed by the type system to meet the specification.The complete program is in the Example directory of the code.
The Code
The code consists of the following files and folders:
PreorderReasoningmodule in earlier versions of the Standard Library was not expressive enough for our need. We may adapt to the new Standard Library later.Download
To grab the latest code, install darcs and check our the code from the repository:
A gzipped tarball is also available.
AoPA makes use of the Standard Library, to install which you will need darcs.