Skip to content
Spartan type theory
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Cosmetics Dec 15, 2017
src
.dir-locals.el Make it compile without MPFR. Still scavanging Clerical. Dec 12, 2017
.gitignore Documentation. Dec 14, 2017
.merlin
LICENSE.md Add a licence and a merlin file Dec 12, 2017
Makefile Turn on more errors, and warning should be errors. Aug 31, 2018
README.md Link to video lecture Dec 2, 2018
_tags
spartan.odocl Documentation. Dec 14, 2017

README.md

An implementation of spartan type theory

This repository shows how to implement a minimalist type theory of the kind that is called "spartan" by some people. The implementation was presented at the School and Workshop on Univalent Mathematics which took place at the University of Birmingham in December 2017. The video recording of the lecture How to implement type theory in an hour is now available.

The type theory

The dependent type theory spartan has the following ingridients:

  • A universe Type with Type : Type.
  • Dependent products written as forall (x : T₁), T₂ or ∀ (x : T₁), T₂ or ∏ (x : T₁), T₂.
  • Functions written as fun (x : T) => e or λ (x : T) ⇒ e. The typing annotation may be omitted.
  • Application written as e₁ e₂.
  • Type ascription written as e : T.

Top-level commands:

  • Definition x := e. -- define a value
  • Axiom x : T. -- assume a constant x of type T
  • Check e. -- print the type of e
  • Eval e. -- evaluate e a la call-by-value
  • Load "⟨file⟩". -- load a file

Prerequisites

  • OCaml and OPAM

  • The OPAM packages menhir and sedlex:

      opam install menhir
      opam install sedlex
    
  • It is recommended that you also install the rlwrap or ledit command line wrapper.

Compilation

You can type:

  • make to make the spartan.native executable.
  • make byte to make the bytecode spartan.byte executable.
  • make clean to clean up.
  • make doc to generate HTML documentation (see the generated spartan.docdir/index.html).

Source code

The purpose of the implementation is to keep the source uncomplicated and short. The essential bits of source code can be found in the following files. It should be possible for you to just read the entire source code. You should start with the core:

and continue with the infrastructure

What experiments should I perform to learn more?

There are many things you can try, for example try adding dependent sums, or basic types unit, bool and nat.

You can’t perform that action at this time.