This is not the first time that I have given a talk at Kent.
Years a go I spoke at a CryptoForma workshop hosted there.
The topic was on linking dependent types, session types, and protocol implementation validation.
A topic that I should revisit once my restraints are released, and I am unshackled!
I have been thinking, again, about way’s in which one can encode linear variable usage in EDSLs.
One cannot state usage on things that one cannot bind.
We can encode EDSLs using intrinsically well-typed EDLS that, at the type-level, gives all terms a type type and carries around the local typing context.
Bound variables are represented using De Bruijn indices encoded as existential quantification over a type-level context.
STLC is intrinsically well-typed in that, at the type-level, all terms are given a type type and has the local typing context.
Within STLC, bound variables are represented using De Bruijn indices encoded as existential quantification over a type-level context.
When reading foundational texts such as PLFA, TAPL, and Software Foundations the learner is often presented with Simply-Typed Lambda Calculi that supports both products and sums.
When translating these calculi to dependently typed languages in an intrinsically typed way as we do with Idris & Agda, how we might approach
supporting other data structures such as tuples, records and variants is not precisely clear.
In fact Software Foundations does give an idea on how to do so but let us explore how we may choose to represent such structures in Idris/Agda.
Traditionally, computer programs must be complete when presented to the compiler.
Typed Holes (also known as meta variables) are an important tool when programming that supports computing with incomplete programs in which holes (the things we do not know) are a core aspect of the language (and tooling) design.
Specifically, if you have used dependently typed languages such as Idris and Agda you will have encountered holes before.
Typed Holes in Idris allow us to inspect the local typing context from where the hole was placed.
This allows us to see what information is directly available when looking to fill the hole.
Further, computing the type of the typed hole also tells us the type of thing we need to insert.
With these books each presents a treatment of PLT either:
mechanised using Agda or Coq; presented purely theoretically in LaTeX; or
a mixture of theory and practice.
Of particular interest to myself is the presentation using Agda.
Dependent types allow us to present formal descriptions of our programs together with their practical constructions.
Sometimes dependent types push you towards mutually defined data structures:
I try to avoid them where I can.
For me, this occurrs when you need a helper data type where a container is not suitable expressive at the type level to capture the inductive case.
When this happens you can index your helper data structure with the signature of the top type.
This helps remove the need for a mutual
definition, that is turn the call graph edge from undirected to directed.
Dependently typed theorem proving is about using the power of dependent types to provide guarantees over various properties of software programs and mathematical constructs.
In dependently typed programming we use dependent types to construct and better reason about the properties of our software programs.
While the former requires that we construct proofs, the latter requires that we construct a usable system.
In this post I want to discuss how proving and construction can get in the way of each other and that when programming with dependent types we must recognise and tread carefully the fine line between theorem proving and programming.
Let us consider the /Well-Typed Interpreter/ (WTI), a well known application of dependent types to ensure that our program’s are not only well-typed but also well-scoped w.r.t. variables.
To be specific the WTI details not how program’s are correct but /expressions/.
When dealing with program’s we will have a top-level expression that may depend on globally declared expressions.
In this post I will describe a Razor, detailing how with a little thought we can use the concept of the WTI to described /Well-Typed Programs/.
This post was derived from a literate Idris file so there will be some cruft related to Idris that will remain until I get round to 1 improving Idris’ literate mode support.
module Main
We will need some data structures, and helper functions, not defined in Idris’ prelude.
import Data.List
The following two imports are from my container’s library, we will need these in the final sections to keep our musing’s DRY.