aboutsummaryrefslogtreecommitdiff
path: root/makkai.md
blob: e24730beb1437e699edcfe41f5b6cb2b0875565f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Makkai

## Judgements
- `C ctx` means `C` is a context.
- `C ⊢ X set` means `X` is a set in context `C`.
- `C ⊢ m : X` means `m` is a match of set `X`.
- `C ⊢ S signature` means `S` is a signature in context `C`.
- `C ⊢ I :: S` means `I` is an instance of signature `S`.

Contexts are built by extension with either kind of binding:
- `· ctx`.
- `C, x : X` ctx, when `C ⊢ X set`.
- `C, i :: S` ctx, when `C ⊢ S signature`.

Everywhere below, `...` ranges over a finite (possibly zero) index, and the labels `xi`, `si`, `vi` are assumed distinct within any single list.

## The set layer

### Built-Ins
For each `B ∈ { Nat, Int, Float, Str }`:
- **Formation.** `C ⊢ B set`.
- **Intro.** Literals of the appropriate form match the corresponding built-in (e.g. `C ⊢ 7 : Nat`).

### Variables
- `C ⊢ x : X` when `x : X` is in `C`.

### Records
- **Formation.** `C ⊢ record { .x0 : X0, ..., .xn : Xn } set` when `C ⊢ X0 set`, `C, x0 : X0 ⊢ X1 set`, ..., `C, x0 : X0, ..., xn-1 : Xn-1 ⊢ Xn set`.
- **Intro.** `C ⊢ { .x0 = m0, ..., .xn = mn } : record { .x0 : X0, ..., .xn : Xn }` when `C ⊢ m0 : X0`, `C ⊢ m1 : X1[m0/x0]`, ..., `C ⊢ mn : Xn[m0/x0, ..., mn-1/xn-1]`.
- **Elim.** `C ⊢ m.xi : Xi[m.x0/x0, ..., m.xi-1/xi-1]` when `C ⊢ m : record { .x0 : X0, ..., .xn : Xn }`.
- **β.** `{ ..., .xi = mi, ... }.xi=mi`.
- **η.** `m=record { .x0=m.x0, ..., .xn=m.xn }` when `m : record { ... }`.

### Variants
- **Formation.** `C ⊢ variant { v0. : X0 | ... | vn. : Xn } set` when each `C ⊢ Xi set`.
- **Intro.** `C ⊢ vi.(m) : variant { v0. : X0 | ... | vn. : Xn }` when `C ⊢ m : Xi`.
- **Elim.** `C ⊢ case m of { v0.x0 => n0 | ... | vn.xn => nn } : X` when `C ⊢ m : variant { v0. : X0 | ... | vn. : Xn }` and, for each `i`, `C, xi : Xi ⊢ ni : X`.
- **β.** `case vi.(m) of { ... | vi.xi => ni | ... }=ni[m/xi]`.
- **η.** `m=case m of { v0.x0 => v0.(x0) | ... | vn.xn => vn.(xn) }` when `m : variant { ... }`.

## The signature layer

### Theory
- **Formation.** `C ⊢ theory { .s0 :: S0, ..., .sn :: Sn } signature` when `C ⊢ S0 signature`, `C, s0 :: S0 ⊢ S1 signature`, ..., `C, s0 :: S0, ..., sn-1 :: Sn-1 ⊢ Sn signature`.
- **Intro.** `C ⊢ { .s0 = I0, ..., .sn = In } :: theory { .s0 :: S0, ..., .sn :: Sn }` when `C ⊢ I0 :: S0`, `C ⊢ I1 :: S1[I0/s0]`, ..., `C ⊢ In :: Sn[I0/s0, ..., In-1/sn-1]`.
- **Elim.** `C ⊢ I.si :: Si[I.s0/s0, ..., I.si-1/si-1]` when `C ⊢ I :: theory { .s0 :: S0, ..., .sn :: Sn }`.
- **β.** `{ ..., .si=Ii, ... }.si=Ii`.
- **η.** `I={ .s0=I.s0, ..., .sn=I.sn }` when `I :: theory { ... }`.

### Variables
- `C ⊢ i :: S` when `i :: S` is in `C`.

## The interface

### The signature `Set`
- **Formation.** `C ⊢ Set signature`.
- **Intro.** `C ⊢ X :: Set` when `C ⊢ X set`.
- **Elim.** `C ⊢ set-of(I) set` when `C ⊢ I :: Set`.
- **β.** `set-of(X)=X` when `X :: Set` arises from `C ⊢ X set`.
- **η.** `I=set-of(I)` viewed as an instance, when `I :: Set`.

### Extension signatures
- **Formation.** `C ⊢ (x: X) -> S signature` when `C ⊢ X set` and `C, x : X ⊢ S signature`.
- **Intro.** `C ⊢ for (y: X). I :: (x: X) -> S` when `C, y : X ⊢ I :: S[y/x]`.
- **β.** `(for (x: X). I)(y)=I[y/x]`.
- **η.** `I=for (x: X). I(x)` when x is not free in I.