A type checker for FreshMLTT, a dependent type theory with abstractable names together with an equational characterisation of freshness inspired by the corresponding notion in Nominal Sets.
freshtt FILE
A file consists of a semicolon-separated list of definitions
DEF_1;
... ;
DEF_n
where each definition DEFi consists of a name (that later definitions can
refer to) a type and a body (of that type):
ID : TERM = TERM
There's no syntactic distinction between types and terms. Terms are formed as follows
-
local definitions
let ID : TERM = TERM in TERM -
cumulative hierarchy of universes
U nwhere
nis an integer -
universe of name sorts
N -
simple and dependent function types
TERM -> TERM (ID1, ..., IDn : TERM) -> TERMThe arrow
->can be replaced by the unicode right arrow character,→. -
simple and dependent name abstraction types
[ID1, ..., IDn : TERM] -> TERM [TERM] TERM -
function abstraction (domain-free)
\ID1 ... IDn. TERM λID1 ... IDn. TERM -
name abstraction (domain-free)
!ID1 ... IDn. TERM αID1 ... IDn. TERM -
local name abstraction (domain-full)
?ID : TERM. TERM νID : TERM. TERM -
function application
TERM TERM -
concretion
TERM @ ID -
name swapping
swap ID ID in TERM -
type annotation
TERM :: TERM
Some syntactic sugar:
-
Telescopic type syntax: consecutive dependent function and name abstractions can be written without a separating arrow (
->), i.e. instead of(ID : TERM) -> [ID : TERM] -> ...we can write
(ID : TERM) [ID : TERM] -> ...
parser.mly: parser for freshtt programsraw.ml: abstract syntax close to concrete syntax and a pretty-printerterm.ml: internal syntax (note thatFunandNabare non-binding!)eval.mlandreadback.ml: NbE-style normalisation procedure. In particular,evalperforms weak-head normalisation andrb_nfeta expands and reduction under alpha- and lambda-abstractions.model.ml: values in the NbE model. Alpha- and lambda-abstractions are represented byTerm.tclosures.normal.ml: normal formscheck.ml: bidirectional type checker
- A. Abel, Normalization by Evaluation: Dependent Types and Impredicativity.
- T. Coquand, An algorithm for type-checking dependent types.
- M. J. Gabbay, A. M. Pitts, A New Approach to Abstract Syntax with Variable Binding.
- A. M. Pitts, J. Matthiesen and J. Derikx, A Dependent Type Theory with Abstractable Names.