• Stars
    star
    245
  • Rank 160,249 (Top 4 %)
  • Language
    OCaml
  • License
    MIT License
  • Created over 6 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Spartan type theory

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 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 dune, menhir, mehirLib and sedlex:

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

Compilation

You can type:

  • dune build to compile the spartan.exe executable.
  • dune clean to clean up.

Usage

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.

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.

More Repositories

1

plzoo

Programming Languages Zoo
OCaml
1,420
star
2

homotopy-type-theory-course

A course on homotopy theory and type theory, taught jointly with Jaka Smrekar
TeX
271
star
3

marshall

Real number computation software
OCaml
114
star
4

Homotopy

Homotopy theory in Coq.
Verilog
90
star
5

coop

A prototype programming language for programming with runners
OCaml
87
star
6

alg

Alg is a program that generates all finite models of a first-order theory. It is optimized for equational theories.
OCaml
83
star
7

notes-on-realizability

Lecture notes on realizability
TeX
62
star
8

what-is-algebraic-about-algebraic-effects

TeX
46
star
9

mathematics-and-computation

Andrej Bauer's blog "Mathematics and Computation"
Mathematica
44
star
10

dedekind-reals

A formalization of the Dedekind reals in Coq
Coq
41
star
11

social-distancing-simulator

An artificial simulation of social distancing in the time of an epidemic.
HTML
29
star
12

clerical

Command-like expressions for real infinite-precision calculations
OCaml
20
star
13

miniLCF

A bare-bones LCF-style proof assistant
OCaml
20
star
14

higher-rank-syntax

Agda
16
star
15

simple-random-art

A simple implementation of Random art in Python. Suitable for teaching and experiments.
Python
15
star
16

repl-in-browser

Implementation of a language interpreter in the browser, using js_of_ocaml.
OCaml
15
star
17

mathematical-stories

Mathematical stories
13
star
18

kmeans

A demonstration of Ocaml modules & functors for machine learning.
OCaml
11
star
19

rz

A tool for automatic generation of specifications based on realizability theory
TeX
9
star
20

hydra

The combinatorial Hydra game
Java
9
star
21

zeroes

Programs for computing beautiful pictures and animations of zeroes of polynomials.
Python
8
star
22

dependent-type-theory-syntax

An Agda formalization of raw syntax for dependent type theory
Agda
7
star
23

ppj-skripta

Zapiski pri predmetu Principi programskih jezikov
OCaml
7
star
24

ucbenik-logika-in-mnozice

Učbenik za predmet Logika in množice na Fakulteti za matematiko in fiziko, Univerza v Ljubljani
TeX
6
star
25

slack-to-discord

Transfer Slack archives to a Discord server on a per-channel basis
Python
5
star
26

costa-surface

Triangulation of Costa's minimal surface with normals, suitable for PovRay rendering
Python
5
star
27

lvr-sat

SAT solver (for teaching purposes in the course Logic in computer science)
OCaml
5
star
28

lvr-coq

Coq related material for the Logic in computer science course
Coq
4
star
29

lean2sexp

Convert Lean .olean files to s-expressions
Lean
3
star
30

the-daily-algebra

The daily algebra fact.
3
star
31

formal-type-theory

Formalising Type Theory in a modular way for translations between type theories
Coq
3
star
32

jurij

A simple Python application for drawing graphs, useful for teaching and experiments.
Python
2
star
33

backup

Remote backups using ssh and rsync.
Perl
2
star
34

formalabstracts

Lean
1
star