EPIGRAM by example
- dr. James McKinna, HG 02.540
james@cs.ru.nl
Grondslagen, November 29, 2007 Ism: Conor McBride, Edwin Brady Dank aan: ‘proefkonijn’ Dan Synek
E PIGRAM by example dr. James McKinna, HG 02.540 james@cs.ru.nl - - PowerPoint PPT Presentation
E PIGRAM by example dr. James McKinna, HG 02.540 james@cs.ru.nl Grondslagen, November 29, 2007 Ism: Conor McBride, Edwin Brady Dank aan: proefkonijn Dan Synek Themes (Certified) Programming. . . is algorithmic problem-solving. . . is
Grondslagen, November 29, 2007 Ism: Conor McBride, Edwin Brady Dank aan: ‘proefkonijn’ Dan Synek
(interactive; human-guided, machine-supported) proof search;
JHM: FUN@RUN 2007-11-27 Slide 1
No matter how weak the type system, we can intuitively interpret it like this:
and
[So typechecking is automated theorem proving, and programmers can shed the burden of justifying (‘proving’) the behaviour of their programs.] Type soundness theorems strengthen this intuition
JHM: FUN@RUN 2007-11-27 Slide 2
The underlying (meta-)logic of these theorems and proofs had better be
For (statement and proof of) type soundness theorems, this is OK. For the types of programs themselves, (relative) inexpressivity and non-termination make each of these more problematic.
JHM: FUN@RUN 2007-11-27 Slide 3
Why can’t we say
Why can’t we expect more
Holy Grail: correctness by design
JHM: FUN@RUN 2007-11-27 Slide 4
implemented in Agda2!
JHM: FUN@RUN 2007-11-27 Slide 5
JHM: FUN@RUN 2007-11-27 Slide 6
Peano-Dedekind naturals data
where
Also: . . . booleans, polymorphic lists. . . Polymorphic recursion [Bird & Paterson, Altenkirch & Reus] data
Inference-rule notation suppresses:
JHM: FUN@RUN 2007-11-27 Slide 7
Bounded numbers data
where
Vectors (lists with length) data
where
(NB. lengths are correlated with corresponding constructors) Hence also m × n Matrices We get bounds-safe lookup and matrix transpose etc. without tears
JHM: FUN@RUN 2007-11-27 Slide 8
Balanced trees as an intermediate data structure for sorting: data
where
Note: the invariant here is tightly specified; no wiggle room! Slogan:
Also: AVL trees [A-V,L 1962], etc. . . .
JHM: FUN@RUN 2007-11-27 Slide 9
a more informative type of binary numbers, indexed with respect to their decoding cf. singleton types [Harper, Xi, Sheard] data n : Nat
can easily be generalised to consider
JHM: FUN@RUN 2007-11-27 Slide 10
Obvious function |−| : Fin n → Nat Gives rise to a family over b, n : Nat expressing “small integer” property data
where
Obvious function bounded b n : Bounded b n Now, case analysis on values of bounded b n gives an informative view [Wadler 1987; McBride-McKinna 2004] of numbers. Slogan:
JHM: FUN@RUN 2007-11-27 Slide 11
A universe is given by a type TyExp of (type-)names, and a decoding function (a recursive family) Val : TyExp → ⋆, e.g.
Well-typed evaluator example. . . with a twist
JHM: FUN@RUN 2007-11-27 Slide 12
Can straighforwardly extend the simple evaluator example to include
Stack-safety for free by decorating the program you (McCarthy) first thought of.
JHM: FUN@RUN 2007-11-27 Slide 13
about termination?);
programming pattern needs some help: zippers (RBTs again)
traces are first-class data (there’s much more to say about this topic)
JHM: FUN@RUN 2007-11-27 Slide 14
supported by evidence
JHM: FUN@RUN 2007-11-27 Slide 15
Now what? EPIGRAM(2): a new type theory and implementation What about computational effects? What about applications?
JHM: FUN@RUN 2007-11-27 Slide 16
coinduction/corecursion properly, with nice syntax?
, http, ITasks?
JHM: FUN@RUN 2007-11-27 Slide 17