• Stars
    star
    249
  • Rank 162,987 (Top 4 %)
  • Language
    OCaml
  • License
    MIT License
  • Created almost 7 years ago
  • Updated 6 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,451
star
2

homotopy-type-theory-course

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

marshall

Real number computation software
OCaml
118
star
4

Homotopy

Homotopy theory in Coq.
Verilog
90
star
5

coop

A prototype programming language for programming with runners
OCaml
88
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
65
star
8

mathematics-and-computation

Andrej Bauer's blog "Mathematics and Computation"
Mathematica
47
star
9

what-is-algebraic-about-algebraic-effects

TeX
46
star
10

social-distancing-simulator

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

clerical

Command-like expressions for real infinite-precision calculations
OCaml
22
star
12

miniLCF

A bare-bones LCF-style proof assistant
OCaml
21
star
13

higher-rank-syntax

Agda
16
star
14

simple-random-art

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

repl-in-browser

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

mathematical-stories

Mathematical stories
13
star
17

hydra

The combinatorial Hydra game
Java
12
star
18

kmeans

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

zeroes

Programs for computing beautiful pictures and animations of zeroes of polynomials.
Python
11
star
20

rz

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

dependent-type-theory-syntax

An Agda formalization of raw syntax for dependent type theory
Agda
8
star
22

ppj-skripta

Zapiski pri predmetu Principi programskih jezikov
OCaml
7
star
23

formalized-mathematics-in-lean

A graduate course on formalized mathematics at the Faculty of Mathematics and Physics, University of Ljubljana, Fall semester 2024/25
Shell
7
star
24

costa-surface

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

slack-to-discord

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

ucbenik-logika-in-mnozice

Učbenik za predmet Logika in množice na Fakulteti za matematiko in fiziko, Univerza v Ljubljani
TeX
6
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

jurij

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

backup

Remote backups using ssh and rsync.
Perl
2
star
33

TopologyPrimerTest

A test before showing a Lean project to students
TeX
1
star