Skip to content

Commit 07b520a

Browse files
committed
Update documentation
1 parent 1f3b9d4 commit 07b520a

17 files changed

+322
-201
lines changed

docs/docs/examples/recId.rzk.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,34 @@ We begin by introducing common HoTT definitions:
1313
#lang rzk-1
1414
1515
-- A is contractible there exists x : A such that for any y : A we have x = y.
16-
#def iscontr (A : U) : U
16+
#define iscontr (A : U) : U
1717
:= ∑ (a : A), (x : A) -> a =_{A} x
1818
1919
-- A is a proposition if for any x, y : A we have x = y
20-
#def isaprop (A : U) : U
20+
#define isaprop (A : U) : U
2121
:= (x : A) -> (y : A) -> x =_{A} y
2222
2323
-- A is a set if for any x, y : A the type x =_{A} y is a proposition
24-
#def isaset (A : U) : U
24+
#define isaset (A : U) : U
2525
:= (x : A) -> (y : A) -> isaprop (x =_{A} y)
2626
2727
-- Non-dependent product of A and B
28-
#def prod (A : U) (B : U) : U
28+
#define prod (A : U) (B : U) : U
2929
:= ∑ (x : A), B
3030
3131
-- A function f : A -> B is an equivalence
3232
-- if there exists g : B -> A
3333
-- such that for all x : A we have g (f x) = x
3434
-- and for all y : B we have f (g y) = y
35-
#def isweq (A : U) (B : U) (f : A -> B) : U
35+
#define isweq (A : U) (B : U) (f : A -> B) : U
3636
:= ∑ (g : B -> A), prod ((x : A) -> g (f x) =_{A} x) ((y : B) -> f (g y) =_{B} y)
3737
3838
-- Equivalence of types A and B
39-
#def weq (A : U) (B : U) : U
39+
#define weq (A : U) (B : U) : U
4040
:= ∑ (f : A -> B), isweq A B f
4141
4242
-- Transport along a path
43-
#def transport
43+
#define transport
4444
(A : U)
4545
(C : A -> U)
4646
(x y : A)
@@ -55,7 +55,7 @@ We can now define relative function extensionality. There are several formulatio
5555

5656
```rzk
5757
-- [RS17, Axiom 4.6] Relative function extensionality.
58-
#def relfunext : U
58+
#define relfunext : U
5959
:= (I : CUBE)
6060
-> (psi : I -> TOPE)
6161
-> (phi : psi -> TOPE)
@@ -65,7 +65,7 @@ We can now define relative function extensionality. There are several formulatio
6565
-> (t : psi) -> A t [ phi t |-> a t]
6666
6767
-- [RS17, Proposition 4.8] A (weaker) formulation of function extensionality.
68-
#def relfunext2 : U
68+
#define relfunext2 : U
6969
:= (I : CUBE)
7070
-> (psi : I -> TOPE)
7171
-> (phi : psi -> TOPE)
@@ -92,13 +92,13 @@ First, we define how to restrict an extension type to a subshape:
9292
#variable A : {t : I | psi t \/ phi t} -> U
9393
9494
-- Restrict extension type to a subshape.
95-
#def restrict_phi
95+
#define restrict_phi
9696
(a : {t : I | phi t} -> A t)
9797
: {t : I | psi t /\ phi t} -> A t
9898
:= \t -> a t
9999
100100
-- Restrict extension type to a subshape.
101-
#def restrict_psi
101+
#define restrict_psi
102102
(a : {t : I | psi t} -> A t)
103103
: {t : I | psi t /\ phi t} -> A t
104104
:= \t -> a t
@@ -108,13 +108,13 @@ Then, how to reformulate an `a` (or `b`) as an extension of its restriction:
108108

109109
```rzk
110110
-- Reformulate extension type as an extension of a restriction.
111-
#def ext-of-restrict_psi
111+
#define ext-of-restrict_psi
112112
(a : {t : I | psi t} -> A t)
113113
: (t : psi) -> A t [ psi t /\ phi t |-> restrict_psi a t ]
114114
:= a -- type is coerced automatically here
115115
116116
-- Reformulate extension type as an extension of a restriction.
117-
#def ext-of-restrict_phi
117+
#define ext-of-restrict_phi
118118
(a : {t : I | phi t} -> A t)
119119
: (t : phi) -> A t [ psi t /\ phi t |-> restrict_phi a t ]
120120
:= a -- type is coerced automatically here
@@ -124,7 +124,7 @@ Now, assuming relative function extensionality, we construct a path between rest
124124

125125
```rzk
126126
-- Transform extension of an identity into an identity of restrictions.
127-
#def restricts-path
127+
#define restricts-path
128128
(a_psi : (t : psi) -> A t)
129129
(a_phi : (t : phi) -> A t)
130130
(e : {t : I | psi t /\ phi t} -> a_psi t = a_phi t)
@@ -144,7 +144,7 @@ Finally, we bring everything together into `recId`:
144144
-- A weaker version of recOR, demanding only a path between a and b:
145145
-- recOR(psi, phi, a, b) demands that for psi /\ phi we have a == b (definitionally)
146146
-- (recId psi phi a b e) demands that e is the proof that a = b (intensionally) for psi /\ phi
147-
#def recId uses (r) -- we declare that recId is using r on purpose
147+
#define recId uses (r) -- we declare that recId is using r on purpose
148148
(a_psi : (t : psi) -> A t)
149149
(a_phi : (t : phi) -> A t)
150150
(e : {t : I | psi t /\ phi t} -> a_psi t = a_phi t)
@@ -172,7 +172,7 @@ whenever we can show that they are equal on the intersection of shapes:
172172
```rzk
173173
-- If two extension types are equal along two subshapes,
174174
-- then they are also equal along their union.
175-
#def id-along-border
175+
#define id-along-border
176176
(r : relfunext2)
177177
(I : CUBE)
178178
(psi : I -> TOPE)

docs/docs/reference/builtins/directed-interval.rzk.md

Whitespace-only changes.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Unit type
2+
3+
Since [:octicons-tag-24: v0.5.1][Unit support]
4+
5+
```rzk
6+
#lang rzk-1
7+
```
8+
9+
In the syntax, only `Unit` (the type) and `unit` (the only inhabitant) are provided. Everything else should be available from computation rules.
10+
More specifically, `rzk` takes the uniqueness property of the `Unit` type (see Section 1.5 of the HoTT book[^1]) as the computation rule, meaning that any (well-typed) term of type Unit reduces to unit.
11+
This means in particular, that induction and uniqueness can be defined very easily:
12+
13+
```rzk
14+
#define ind-Unit
15+
(C : Unit -> U)
16+
(C-unit : C unit)
17+
(x : Unit)
18+
: C x
19+
:= C-unit
20+
21+
#define uniq-Unit
22+
(x : Unit)
23+
: x = unit
24+
:= refl
25+
26+
#define isProp-Unit
27+
(x y : Unit)
28+
: x = y
29+
:= refl
30+
```
31+
32+
As a non-trivial example, here is a proof that `Unit` is a Segal type:
33+
34+
```rzk
35+
#section isSegal-Unit
36+
37+
#variable extext : ExtExt
38+
39+
#define iscontr-Unit : isContr Unit
40+
:= (unit, \_ -> refl)
41+
42+
#define isContr-Δ²→Unit uses (extext)
43+
: isContr (Δ² -> Unit)
44+
:= (\_ -> unit, \k -> eq-ext-htpy extext
45+
(2 * 2) Δ² (\_ -> BOT)
46+
(\_ -> Unit) (\_ -> recBOT)
47+
(\_ -> unit) k
48+
(\_ -> refl)
49+
)
50+
51+
#define isSegal-Unit uses (extext)
52+
: isSegal Unit
53+
:= \x y z f g -> isRetract-ofContr-isContr
54+
(∑ (h : hom Unit x z), hom2 Unit x y z f g h)
55+
(Δ² -> Unit)
56+
(\(_, k) -> k, (\k -> (\t -> k (t, t), k), \_ -> refl))
57+
isContr-Δ²→Unit
58+
59+
#end isSegal-Unit
60+
```
61+
62+
[Unit support]: https://github.com/fizruk/rzk/releases/tag/v0.5.1
63+
64+
[^1]: The Univalent Foundations Program (2013). _Homotopy Type Theory: Univalent Foundations of Mathematics._ <https://homotopytypetheory.org/book>

docs/docs/reference/commands/check.rzk.md

Whitespace-only changes.

docs/docs/reference/commands/compute.rzk.md

Whitespace-only changes.

docs/docs/reference/commands/define-postulate.rzk.md

Whitespace-only changes.

docs/docs/reference/commands/options.rzk.md

Whitespace-only changes.

docs/docs/reference/cube-layer.rzk.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Cube layer
2+
3+
```rzk
4+
#lang rzk-1
5+
```
6+
7+
All cubes live in `#!rzk CUBE` universe.
8+
9+
There are two built-in cubes:
10+
11+
1. `#!rzk 1` cube is a unit cube with a single point `#!rzk *_1`
12+
2. `#!rzk 2` cube is a [directed interval](../builtins/directed-interval.rzk.md) cube with points `#!rzk 0_2` and `#!rzk 1_2`
13+
14+
It is also possible to have `#!rzk CUBE` variables and make products of cubes:
15+
16+
1. `#!rzk I * J` is a product of cubes `#!rzk I` and `#!rzk J`
17+
2. `#!rzk (t, s)` is a point in `#!rzk I * J` if `#!rzk t : I` and `#!rzk s : J`
18+
3. if `#!rzk ts : I * J`, then `#!rzk first ts : I` and `#!rzk second ts : J`
19+
20+
You can usually use `#!rzk (t, s)` both as a pattern, and a construction of a pair of points:
21+
22+
```rzk
23+
-- Swap point components of a point in a cube I × I
24+
#define swap
25+
(I : CUBE)
26+
: (I * I) -> I * I
27+
:= \(t, s) -> (s, t)
28+
```
29+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Extension types
2+
3+
4+
4. Extension types \(\left\langle \prod_{t : I \mid \psi} A \vert ^{\phi} _{a} \right\rangle\) are written as `#!rzk {t : I | psi t} -> A [ phi |-> a ]`
5+
- specifying `#!rzk [ phi |-> a ]` is optional, semantically defaults to `#!rzk [ BOT |-> recBOT ]` (like in RSTT);
6+
- specifying `#!rzk psi` in `#!rzk {t : I | psi}` is mandatory;
7+
- values of function types are \(\lambda\)-abstractions written in one of the following ways:
8+
- `#!rzk \t -> <body>` — this is usually fine;
9+
- `#!rzk \{t : I | psi} -> <body>` — this sometimes helps the typechecker;
10+
11+
5. Types of functions from a shape \(\prod_{t : I \mid \psi} A\) are a specialised variant of extension types and are written `#!rzk {t : I | psi} -> A`
12+
- specifying the name of the argument is mandatory; i.e. `#!rzk {I | psi} -> A` is invalid syntax!
13+
- values of function types are \(\lambda\)-abstractions written in one of the following ways:
14+
- `#!rzk \t -> <body>` — this is usually fine;
15+
- `#!rzk \{t : I | psi} -> <body>` — this sometimes helps the typechecker;
16+
17+
[^1]: Emily Riehl & Michael Shulman. _A type theory for synthetic ∞-categories._ Higher Structures 1(1), 147-224. 2017. <https://arxiv.org/abs/1705.07442>
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Introduction
2+
3+
`rzk` is an experimental proof assistant for synthetic ∞-categories.
4+
`rzk-1` is an early version of the language supported by `rzk`.
5+
The language is based on Riehl and Shulman's «Type Theory for Synthetic ∞-categories»[^1]. In this section, we introduce syntax, discuss features and some of the current limitations of the proof assistant.
6+
7+
Overall, a program in `rzk-1` consists of a language pragma (specifying that we use `rzk-1` and not one of the other languages[^2]) followed by a sequence of commands. For now, we will only use `#define` command.
8+
9+
Here is a small formalisation in an MLTT subset of `rzk-1`:
10+
11+
```rzk
12+
#lang rzk-1
13+
14+
-- Flipping the arguments of a function.
15+
#define flip
16+
(A B : U) -- For any types A and B
17+
(C : (x : A) -> (y : B) -> U) -- and a type family C
18+
(f : (x : A) -> (y : B) -> C x y) -- given a function f : A -> B -> C
19+
: (y : B) -> (x : A) -> C x y -- we construct a function of type B -> A -> C
20+
:= \y x -> f x y -- by swapping the arguments
21+
22+
-- Flipping a function twice is the same as not doing anything
23+
#define flip-flip-is-id
24+
(A B : U) -- For any types A and B
25+
(C : (x : A) -> (y : B) -> U) -- and a type family C
26+
(f : (x : A) -> (y : B) -> C x y) -- given a function f : A -> B -> C
27+
: f = flip B A (\y x -> C x y)
28+
(flip A B C f) -- flipping f twice is the same as f
29+
:= refl -- proof by reflexivity
30+
```
31+
32+
Let us explain parts of this code:
33+
34+
1. `#!rzk #lang rzk-1` specifies that we are in using `#!rzk rzk-1` language;
35+
2. `#!rzk --` starts a comment line (until the end of the line);
36+
3. `#!rzk #define «name» : «type» := «term»` defines a name `«name»` to be equal to `«term»`; the proof assistant will typecheck `«term»` against type `«type»`;
37+
4. We define two terms here — `flip` and `flip-flip-is-id`;
38+
5. `flip` is a function that takes 4 arguments and returns a function of two arguments.
39+
6. `flip-flip-is-id` is a function that takes two types, a type family, and a function `f` and returns a value of an identity type `flip ... (flip ... f) = f`, indicating that flipping a function `f` twice gets us back to `f`.
40+
41+
Similarly to the three layers in Riehl and Shulman's type theory, `rzk-1` has 3 universes:
42+
43+
- `CUBE` is the universe of cubes, corresponding to the cube layer;
44+
- `TOPE` is the universe of topes, corresponding to the tope layer;
45+
- `U` is the universe of types, corresponding to the types and terms layer.
46+
47+
These are explained in the following sections.
48+
49+
## Soundness
50+
51+
`rzk-1` assumes "type-in-type", that is `U` has type `U`.
52+
This is known to make the type system unsound (due to Russell and Curry-style paradoxes), however,
53+
it is sometimes considered acceptable in proof assistants.
54+
And, since it simplifies implementation, `rzk-1` embraces this assumption, at least for now.
55+
56+
Moreover, `rzk-1` does not prevent cubes or topes to depend on types and terms. For example, the following definition typechecks:
57+
58+
```rzk
59+
#define weird
60+
(A : U)
61+
(I : A -> CUBE)
62+
(x y : A)
63+
: CUBE
64+
:= I x * I y
65+
```
66+
67+
This likely leads to another inconsistency, but it will probably not lead to bugs in actual proofs of interest,
68+
so current version embraces this lax treatment of universes.
69+
70+
[^1]: Emily Riehl & Michael Shulman. _A type theory for synthetic ∞-categories._ Higher Structures 1(1), 147-224. 2017. <https://arxiv.org/abs/1705.07442>
71+
72+
[^2]: In version [:octicons-tag-24: v0.1.0](https://github.com/fizruk/rzk/releases/tag/v0.1.0), `rzk` has supported simply typed lambda calculus, PCF, and MLTT. However, those languages have been removed.

docs/docs/rzk-1/render.rzk.md renamed to docs/docs/reference/render.rzk.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ Topes are visualised with <span style="color: orange">**orange**</span> color:
6464

6565
```rzk
6666
-- 2-simplex
67-
#def Δ² : (2 * 2) -> TOPE
67+
#define Δ² : (2 * 2) -> TOPE
6868
:= \(t, s) -> s <= t
6969
```
7070
<br><br>
7171
Boundary of a tope:
7272

7373
```rzk
7474
-- boundary of a 2-simplex
75-
#def ∂Δ² : Δ² -> TOPE
75+
#define ∂Δ² : Δ² -> TOPE
7676
:= \(t, s) -> s === 0_2 \/ t === 1_2 \/ s === t
7777
```
7878

@@ -81,14 +81,14 @@ The busiest tope diagram involves the entire 3D cube:
8181

8282
```rzk
8383
-- 3-dim cube
84-
#def 2³ : (2 * 2 * 2) -> TOPE
84+
#define 2³ : (2 * 2 * 2) -> TOPE
8585
:= \_ -> TOP
8686
```
8787
<br><br><br>
8888

8989
```rzk
9090
-- 3-simplex
91-
#def Δ³ : (2 * 2 * 2) -> TOPE
91+
#define Δ³ : (2 * 2 * 2) -> TOPE
9292
:= \((t1, t2), t3) -> t3 <= t2 /\ t2 <= t1
9393
```
9494

@@ -100,7 +100,7 @@ Types are visualised with <span style="color: blue">**blue**</span> color. Recog
100100
```rzk
101101
-- [RS17, Definition 5.1]
102102
-- The type of arrows in A from x to y.
103-
#def hom
103+
#define hom
104104
(A : U) -- A type.
105105
(x y : A) -- Two points in A.
106106
: U -- (hom A x y) is a 1-simplex (an arrow)
@@ -113,7 +113,7 @@ Types are visualised with <span style="color: blue">**blue**</span> color. Recog
113113
```rzk
114114
-- [RS17, Definition 5.2]
115115
-- the type of commutative triangles in A
116-
#def hom2
116+
#define hom2
117117
(A : U) -- A type.
118118
(x y z : A) -- Three points in A.
119119
(f : hom A x y) -- An arrow in A from x to y.
@@ -134,7 +134,7 @@ Terms (with non-trivial labels) are visualised with <span style="color: red">**r
134134
We can visualise terms that fill a shape:
135135

136136
```rzk
137-
#def square
137+
#define square
138138
(A : U)
139139
(x y z : A)
140140
(f : hom A x y)
@@ -148,7 +148,7 @@ We can visualise terms that fill a shape:
148148
If a term is extracted as a part of a larger shape, generally, the whole shape will be shown (in gray):
149149

150150
```rzk
151-
#def face
151+
#define face
152152
(A : U)
153153
(x y z : A)
154154
(f : hom A x y)

0 commit comments

Comments
 (0)