NOTE: This repository has been superseded by Faux type theory.
This repository shows how to implement a minimalist type theory of the kind that is sometimes called “spartan”. The version shown here is an updated version of the one presented at the School and Workshop on Univalent Mathematics which took place at the University of Birmingham in December 2017.
The dependent type theory spartan has the following ingridients:
Type with Type : Type.forall (x : T₁), T₂ or ∀ (x : T₁), T₂ or ∏ (x : T₁), T₂.fun (x : T) => e or λ (x : T) ⇒ e. The typing annotation may
be omitted, i.e., fun x => e, and multiple abstractions may be shortened as
λ x y (z u : T) (w : U) ⇒ e.e₁ e₂.e : T.Top-level commands:
Definition x := e. -- define a valueAxiom x : T. -- assume a constant x of type TCheck e. -- print the type of eEval e. -- evaluate e a la call-by-valueLoad "⟨file⟩". -- load a fileThe OPAM packages dune, menhir, mehirLib, sedlex and bindlib:
opam install dune menhir menihirLib sedlex bindlib
It is recommended that you also install the rlwrap or ledit command line wrapper.
You can type:
dune build to compile the spartan.exe executable.dune clean to clean up.Once you compile the program, you can run it in interactive mode as ./spartan.exe
Run ./spartan.exe --help to see the command-line options and general usage.
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.
It is best to first familiarize yourself with the core:
lib/core/TT.ml – the core type theorylib/core/context.ml – typing contextlib/core/typecheck.ml – type checking and elaborationlib/core/norm.ml – normalizationlib/core/equal.ml – equality and normalizationlib/core/toplevel.ml – top-level commandsContinue with the infrastructure:
lib/parsing/syntax.ml – abstract syntax of the input codelib/parsing/lexer.ml – the lexerlib/parsing/parser.mly – the parserlib/util – various utilitiesbin/spartan.ml – the main executableOCaml
96.6%
Raku
2.0%
Dune
1.4%
NOTE: This repository has been superseded by Faux type theory.
This repository shows how to implement a minimalist type theory of the kind that is sometimes called “spartan”. The version shown here is an updated version of the one presented at the School and Workshop on Univalent Mathematics which took place at the University of Birmingham in December 2017.
The dependent type theory spartan has the following ingridients:
Type with Type : Type.forall (x : T₁), T₂ or ∀ (x : T₁), T₂ or ∏ (x : T₁), T₂.fun (x : T) => e or λ (x : T) ⇒ e. The typing annotation may
be omitted, i.e., fun x => e, and multiple abstractions may be shortened as
λ x y (z u : T) (w : U) ⇒ e.e₁ e₂.e : T.Top-level commands:
Definition x := e. -- define a valueAxiom x : T. -- assume a constant x of type TCheck e. -- print the type of eEval e. -- evaluate e a la call-by-valueLoad "⟨file⟩". -- load a fileThe OPAM packages dune, menhir, mehirLib, sedlex and bindlib:
opam install dune menhir menihirLib sedlex bindlib
It is recommended that you also install the rlwrap or ledit command line wrapper.
You can type:
dune build to compile the spartan.exe executable.dune clean to clean up.Once you compile the program, you can run it in interactive mode as ./spartan.exe
Run ./spartan.exe --help to see the command-line options and general usage.
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.
It is best to first familiarize yourself with the core:
lib/core/TT.ml – the core type theorylib/core/context.ml – typing contextlib/core/typecheck.ml – type checking and elaborationlib/core/norm.ml – normalizationlib/core/equal.ml – equality and normalizationlib/core/toplevel.ml – top-level commandsContinue with the infrastructure:
lib/parsing/syntax.ml – abstract syntax of the input codelib/parsing/lexer.ml – the lexerlib/parsing/parser.mly – the parserlib/util – various utilitiesbin/spartan.ml – the main executableOCaml
96.6%
Raku
2.0%
Dune
1.4%