4 |
5 | Redirecting
6 |
9 |
12 |
13 |
14 | Redirecting to Blog/...
15 |
16 |
17 |
--------------------------------------------------------------------------------
/docs/docs/en/community.md:
--------------------------------------------------------------------------------
1 | # Rzk Community
2 |
3 | There is a small community of mathematicians and computer scientists around Rzk.
4 |
5 | ## Chat
6 |
7 | A Zulip chat is available for all to join and chat about Rzk, including formalization projects, development of Rzk, and related projects:
8 |
9 | [Join Rzk Zulip](https://rzk-lang.zulipchat.com/register/){ .md-button .md-button--primary }
10 |
--------------------------------------------------------------------------------
/docs/docs/en/examples/recId.rzk.md:
--------------------------------------------------------------------------------
1 | # Tope disjuction elimination along identity paths
2 |
3 | \(\mathsf{rec}_{\lor}^{\ψ,\φ}(a_\ψ, a*\φ)\) (written `recOR(ψ, φ, a_psi, a_phi)` in the code)
4 | is well-typed when \(a*\ψ\) and \(a*\φ\) are \_definitionally equal* on \(\ψ \land \φ\).
5 | Sometimes this is too strong since many terms are not _definitionally_ equal, but only equal up to a path.
6 | Luckily, assuming relative function extensionality, we can define a weaker version of \(rec*{\lor}\) (`recOR`), which we call `recId`, that can work in presence of a witness of type \(\prod*{t : I \mid \ψ \land \φ} a*\ψ = a*\φ\).
7 |
8 | ## Prerequisites
9 |
10 | This file relies on some definitions, defined in
11 |
12 | - [Getting Started > Dependent Types](../getting-started/dependent-types.rzk.md)
13 |
14 | We begin by introducing common HoTT definitions:
15 |
16 | ```rzk
17 | #lang rzk-1
18 |
19 | -- A is contractible there exists x : A such that for any y : A we have x = y.
20 | #define iscontr (A : U)
21 | : U
22 | := Σ (a : A) , (x : A) → a =_{A} x
23 |
24 | -- A is a proposition if for any x, y : A we have x = y
25 | #define isaprop (A : U)
26 | : U
27 | := (x : A) → (y : A) → x =_{A} y
28 |
29 | -- A is a set if for any x, y : A the type x =_{A} y is a proposition
30 | #define isaset (A : U)
31 | : U
32 | := (x : A) → (y : A) → isaprop (x =_{A} y)
33 |
34 | -- A function f : A → B is an equivalence
35 | -- if there exists g : B → A
36 | -- such that for all x : A we have g (f x) = x
37 | -- and for all y : B we have f (g y) = y
38 | #define isweq (A : U) (B : U) (f : A → B)
39 | : U
40 | := Σ (g : B → A)
41 | , prod
42 | ( ( x : A) → g (f x) =_{A} x)
43 | ( ( y : B) → f (g y) =_{B} y)
44 |
45 | -- Equivalence of types A and B
46 | #define weq (A : U) (B : U)
47 | : U
48 | := Σ (f : A → B)
49 | , isweq A B f
50 |
51 | -- Transport along a path
52 | #define transport
53 | ( A : U)
54 | ( C : A → U)
55 | ( x y : A)
56 | ( p : x =_{A} y)
57 | : C x → C y
58 | := \ cx → idJ(A , x , (\ z q → C z) , cx , y , p)
59 | ```
60 |
61 | ## Relative function extensionality
62 |
63 | We can now define relative function extensionality. There are several formulations, we provide two, following Riehl and Shulman:
64 |
65 | ```rzk
66 | -- [RS17, Axiom 4.6] Relative function extensionality.
67 | #define relfunext
68 | : U
69 | := (I : CUBE)
70 | → ( ψ : I → TOPE)
71 | → ( φ : ψ → TOPE)
72 | → ( A : ψ → U)
73 | → ( ( t : ψ) → iscontr (A t))
74 | → ( a : (t : φ) → A t)
75 | → ( t : ψ) → A t [ φ t ↦ a t]
76 |
77 | -- [RS17, Proposition 4.8] A (weaker) formulation of function extensionality.
78 | #define relfunext2
79 | : U
80 | :=
81 | ( I : CUBE)
82 | → ( ψ : I → TOPE)
83 | → ( φ : ψ → TOPE)
84 | → ( A : ψ → U)
85 | → ( a : (t : φ) → A t)
86 | → ( f : (t : ψ) → A t [ φ t ↦ a t ])
87 | → ( g : (t : ψ) → A t [ φ t ↦ a t ])
88 | → weq
89 | ( f = g)
90 | ( ( t : ψ) → (f t =_{A t} g t) [ φ t ↦ refl ])
91 | ```
92 |
93 | ## Construction of `recId`
94 |
95 | The idea is straightforward. We ask for a proof that `a = b` for all points in `ψ ∧ φ`. Then, by relative function extensionality (`relfunext2`), we can show that restrictions of `a` and `b` to `ψ ∧ φ` are equal. If we reformulate `a` as extension of its restriction, then we can `transport` such reformulation along the path connecting two restrictions and apply `recOR`.
96 |
97 | First, we define how to restrict an extension type to a subshape:
98 |
99 | ```rzk
100 | #section construction-of-recId
101 |
102 | #variable r : relfunext2
103 | #variable I : CUBE
104 | #variables ψ φ : I → TOPE
105 | #variable A : (t : I | ψ t ∨ φ t) → U
106 |
107 | -- Restrict extension type to a subshape.
108 | #define restrict_phi
109 | ( a : (t : φ) → A t)
110 | : ( t : I | ψ t ∧ φ t) → A t
111 | := \ t → a t
112 |
113 | -- Restrict extension type to a subshape.
114 | #define restrict_psi
115 | ( a : (t : ψ) → A t)
116 | : ( t : I | ψ t ∧ φ t) → A t
117 | := \ t → a t
118 | ```
119 |
120 | Then, how to reformulate an `a` (or `b`) as an extension of its restriction:
121 |
122 | ```rzk
123 | -- Reformulate extension type as an extension of a restriction.
124 | #define ext-of-restrict_psi
125 | ( a : (t : ψ) → A t)
126 | : ( t : ψ)
127 | → A t [ ψ t ∧ φ t ↦ restrict_psi a t ]
128 | := a -- type is coerced automatically here
129 |
130 | -- Reformulate extension type as an extension of a restriction.
131 | #define ext-of-restrict_phi
132 | ( a : (t : φ) → A t)
133 | : ( t : φ)
134 | → A t [ ψ t ∧ φ t ↦ restrict_phi a t ]
135 | := a -- type is coerced automatically here
136 | ```
137 |
138 | Now, assuming relative function extensionality, we construct a path between restrictions:
139 |
140 | ```rzk
141 | -- Transform extension of an identity into an identity of restrictions.
142 | #define restricts-path
143 | ( a_psi : (t : ψ) → A t)
144 | ( a_phi : (t : φ) → A t)
145 | : ( e : (t : I | ψ t ∧ φ t) → a_psi t = a_phi t)
146 | → restrict_psi a_psi = restrict_phi a_phi
147 | :=
148 | first
149 | ( second
150 | ( r I
151 | ( \ t → ψ t ∧ φ t)
152 | ( \ t → BOT)
153 | ( \ t → A t)
154 | ( \ t → recBOT)
155 | ( \ t → a_psi t)
156 | ( \ t → a_phi t)))
157 | ```
158 |
159 | Finally, we bring everything together into `recId`:
160 |
161 | ```rzk
162 | -- A weaker version of recOR, demanding only a path between a and b:
163 | -- recOR(ψ, φ, a, b) demands that for ψ ∧ φ we have a == b (definitionally)
164 | -- (recId ψ φ a b e) demands that e is the proof that a = b (intensionally) for ψ ∧ φ
165 | #define recId uses (r) -- we declare that recId is using r on purpose
166 | ( a_psi : (t : ψ) → A t)
167 | ( a_phi : (t : φ) → A t)
168 | ( e : (t : I | ψ t ∧ φ t) → a_psi t = a_phi t)
169 | : ( t : I | ψ t ∨ φ t) → A t
170 | := \ t → recOR(
171 | ψ t ↦
172 | transport
173 | ( ( s : I | ψ s ∧ φ s) → A s)
174 | ( \ ra → (s : ψ) → A s [ ψ s ∧ φ s ↦ ra s ])
175 | ( restrict_psi a_psi)
176 | ( restrict_phi a_phi)
177 | ( restricts-path a_psi a_phi e)
178 | ( ext-of-restrict_psi a_psi)
179 | ( t)
180 | , φ t ↦
181 | ext-of-restrict_phi a_phi t
182 | )
183 |
184 | #end construction-of-recId
185 | ```
186 |
187 | ## Gluing extension types
188 |
189 | An application of of `recId` is gluing together extension types,
190 | whenever we can show that they are equal on the intersection of shapes:
191 |
192 | ```rzk
193 | -- If two extension types are equal along two subshapes,
194 | -- then they are also equal along their union.
195 | #define id-along-border
196 | ( r : relfunext2)
197 | ( I : CUBE)
198 | ( ψ : I → TOPE)
199 | ( φ : I → TOPE)
200 | ( A : (t : I | ψ t ∨ φ t) → U)
201 | ( a b : (t : I | ψ t ∨ φ t) → A t)
202 | ( e_psi : (t : ψ) → a t = b t)
203 | ( e_phi : (t : φ) → a t = b t)
204 | ( border-is-a-set : (t : I | ψ t ∧ φ t) → isaset (A t))
205 | : ( t : I | ψ t ∨ φ t) → a t = b t
206 | :=
207 | recId r I ψ φ
208 | ( \ t → a t = b t)
209 | ( e_psi)
210 | ( e_phi)
211 | ( \ t → border-is-a-set t (a t) (b t) (e_psi t) (e_phi t))
212 | ```
213 |
--------------------------------------------------------------------------------
/docs/docs/en/getting-started/index.md:
--------------------------------------------------------------------------------
1 | # Getting Started with Rzk
2 |
3 | 1. [Install Rzk](install.md).
4 | 2. Get a [quick overview](quickstart.rzk.md) of Rzk language.
5 | 3. Get through the [introduction to dependent types](dependent-types.rzk.md) in Rzk.
6 | 4. Learn how to configure formalization [projects in Rzk](project.md).
7 | 5. Learn more about Rzk features in the [Rzk Reference](../reference/index.md).
8 |
--------------------------------------------------------------------------------
/docs/docs/en/getting-started/install.md:
--------------------------------------------------------------------------------
1 | # How to install Rzk
2 |
3 | ## VS Code extension with binaries (recommended)
4 |
5 | These instructions will walk you through setting up Rzk using the "basic" setup and VS Code as the editor.
6 |
7 | 1. Install [VS Code](https://code.visualstudio.com/).
8 | 2. Launch VS Code and install the [`rzk` extension](https://marketplace.visualstudio.com/items?itemName=NikolaiKudasovfizruk.rzk-1-experimental-highlighting).
9 | 3. Create a new file using "File > New Text File" (Ctrl+N). Click the `Select a language` prompt, type in `rzk`, and select "Literate Rzk Markdown".
10 | 
11 | 4. You should see the following popup:
12 | 
13 | 5. Click "Yes" button.
14 | 6. While it is installing, you can paste the following literate Rzk program into the new file:
15 |
16 | ````markdown
17 | # Sample literate Rzk markdown
18 |
19 | ```rzk
20 | #lang rzk-1
21 |
22 | #define id (A : U)
23 | : A -> A
24 | := \ x -> x
25 | ```
26 | ````
27 |
28 | 7. When the installation is done you should see the following popup:
29 | 
30 | 8. Click "Reload button".
31 | 9. Save your file as `example.rzk.md`.
32 | 10. Open local Terminal (Ctrl+`).
33 |
34 |
35 |
36 | 11. In the terminal, run
37 |
38 | ```sh
39 | rzk typecheck example.rzk.md
40 | ```
41 |
42 | 12. You should see the output of the proof assistant:
43 |
44 | ```text
45 | Loading file example.rzk.md
46 | Checking module from example.rzk.md
47 | [ 1 out of 1 ] Checking #define id
48 | Everything is ok!
49 | ```
50 |
51 | 13. Congratulations! Now you have a working rzk setup :) Note that the rzk extension will notify you about updates of `rzk` and prompt updating to new versions.
52 |
53 | 14. See [Quickstart](quickstart.rzk.md) to get familiar with the Rzk language!
54 |
55 | ## Install binaries
56 |
57 | ### Download from GitHub
58 |
59 | You can download and use binaries (at least for some platforms) directly for one of the latest releases on GitHub at . If your platform is not represented, please consider leaving an issue at .
60 |
61 | ## Install from sources
62 |
63 | You can install `rzk` from sources. You can get the latest "stable" release from Hackage or build from the `develop` branch on GitHub.
64 |
65 | ### Stack
66 |
67 | To build and install with Stack from Hackage:
68 |
69 | ```sh
70 | stack install rzk
71 | ```
72 |
73 | To build and install with Stack from sources on GitHub:
74 |
75 | ```sh
76 | git clone https://github.com/rzk-lang/rzk.git
77 | cd rzk
78 | git checkout develop
79 | stack build && stack install
80 | ```
81 |
82 | ### cabal-install
83 |
84 | To build and install with `cabal-install` from Hackage:
85 |
86 | ```sh
87 | cabal v2-update
88 | cabal v2-install rzk
89 | ```
90 |
91 | To build and install with `cabal-install` from sources on GitHub:
92 |
93 | ```sh
94 | git clone https://github.com/rzk-lang/rzk.git
95 | cd rzk
96 | git checkout develop
97 | cabal v2-build && cabal v2-install
98 | ```
99 |
100 | ### Nix
101 |
102 | !!! warning "Work-in-progress"
103 |
104 | To be done.
105 |
--------------------------------------------------------------------------------
/docs/docs/en/getting-started/project.md:
--------------------------------------------------------------------------------
1 | # Setting up an Rzk project
2 |
3 | !!! warning "Work-in-progress"
4 | Guide will be here soon.
5 | For now, please use the template project: .
6 | Also check out for an example of a project with generated documentation.
7 |
--------------------------------------------------------------------------------
/docs/docs/en/getting-started/quickstart.rzk.md:
--------------------------------------------------------------------------------
1 | # Quick introduction into Rzk
2 |
3 | !!! warning "Work-in-progress"
4 | Documentation is a work in progress.
5 |
6 | First, [install Rzk](install.md).
7 |
8 | This is a literate `rzk` file:
9 |
10 | ```rzk
11 | #lang rzk-1
12 | ```
13 |
--------------------------------------------------------------------------------
/docs/docs/en/index.md:
--------------------------------------------------------------------------------
1 | # Rzk proof assistant
2 |
3 | Rzk is an experimental proof assistant,
4 | based on [«Type Theory for Synthetic ∞-categories»](https://arxiv.org/abs/1705.07442)[^1].
5 |
6 | [Get started with Rzk](getting-started/install.md){ .md-button .md-button--primary }
7 | [Try Rzk Playground](playground/index.html){ .md-button }
8 |
9 | ## About this project
10 |
11 | This project has started with the idea of bringing Riehl and Shulman's 2017 paper[^1]
12 | to "life" by implementing a proof assistant based on their type theory with shapes.
13 | At the moment, Rzk provides a language that is close to the original paper,
14 | as well as some tooling around it (such as a VS Code extension and a language server with syntax highlighting and formatting support).
15 |
16 | ### Formalizing ∞-category theory
17 |
18 | A big portion of the original paper (up to the ∞-categorical Yoneda lemma) has been formalized in Rzk (see [Yoneda for ∞-categories](https://emilyriehl.github.io/yoneda/)[^2]).
19 | More formalization results are under way (see [sHoTT](https://rzk-lang.github.io/sHoTT/)).
20 | There are also some efforts to formalize the HoTT Book in Rzk (see [hottbook](https://rzk-lang.github.io/hottbook/)).
21 |
22 | ### Using Rzk
23 |
24 | The recommended way of interacting with Rzk is via VS Code (see [Getting Started](getting-started/install.md)),
25 | but you can also download binaries from [GitHub Releases](https://github.com/rzk-lang/rzk/releases), build [from sources](getting-started/install.md#install-from-sources),
26 | or try setting up the Rzk Language Server with your editor of choice.
27 | Additionally, for "throwaway" single-file formalizations, you can use [Rzk Online Playground](playground/index.html).
28 |
29 | ### Implementation
30 |
31 | Rzk serves also as a playground for some techniques of developing proof assistants in Haskell.
32 | In particular, it features a version of second-order abstract syntax for handling binders and,
33 | in the future, dependent type inference through higher-order unification[^3] [^4].
34 | The idea is ultimately, to provide higher-order unification and/or dependent type inference "as a library",
35 | keeping the implementation of Rzk (at least its core language) small, maintainable, and safe.
36 |
37 | Another important part of Rzk is the tope layer solver[^5],
38 | which is a built-in intuitionistic theorem prover required for a part of the type theory.
39 | Although its implementation is fairly simple,
40 | it is sufficient to check existing proofs in synthetic ∞-categories
41 | without requiring any explicit proofs for the tope layer.
42 |
43 | Rzk and the tooling around it is developed by just a couple of people.
44 | See the list of contributors at [CONTRIBUTORS.md](CONTRIBUTORS.md).
45 |
46 | ### Discussing Rzk and getting help
47 |
48 | A Zulip chat is available for all to join and chat about Rzk, including formalization projects, development of Rzk, and related projects:
49 |
50 | [Join Rzk Zulip](https://rzk-lang.zulipchat.com/register/){ .md-button .md-button--primary }
51 |
52 | [^1]:
53 | Emily Riehl & Michael Shulman. _A type theory for synthetic ∞-categories_.
54 | Higher Structures 1(1), 147-224. 2017.
55 |
56 | [^2]:
57 | Nikolai Kudasov, Emily Riehl, Jonathan Weinberger.
58 | _Formalizing the ∞-categorical Yoneda lemma_. 2023.
59 |
60 | [^3]:
61 | Nikolai Kudasov. _Functional Pearl: Dependent type inference via free higher-order unification_. 2022.
62 |
63 |
64 | [^4]:
65 | Nikolai Kudasov. _E-Unification for Second-Order Abstract Syntax_. In 8th International Conference on Formal Structures for Computation and Deduction (FSCD 2023). Leibniz International Proceedings in Informatics (LIPIcs), Volume 260, pp. 10:1-10:22, Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2023)
66 |
67 |
68 | [^5]:
69 | Nikolai Kudasov. Experimental prover for Tope logic. SCAN 2023, pages 37–39. 2023.
70 |
71 |
72 | ## Other proof assistants for HoTT
73 |
74 | Rzk is not the first or the only proof assistant where it's possible to do (a variant of) homotopy type theory.
75 | See a [brief comparison of Rzk with other proof assistants](related.md).
76 |
--------------------------------------------------------------------------------
/docs/docs/en/playground/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Redirecting
6 |
12 |
13 |
14 | Redirecting...
15 |
16 |
17 |
--------------------------------------------------------------------------------
/docs/docs/en/reference/builtins/directed-interval.rzk.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rzk-lang/rzk/3ea72b85e099e785e116a0877d37bca56cc77b7c/docs/docs/en/reference/builtins/directed-interval.rzk.md
--------------------------------------------------------------------------------
/docs/docs/en/reference/builtins/unit.rzk.md:
--------------------------------------------------------------------------------
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/rzk-lang/rzk/releases/tag/v0.5.1
63 |
64 | [^1]: The Univalent Foundations Program (2013). _Homotopy Type Theory: Univalent Foundations of Mathematics._
65 |
--------------------------------------------------------------------------------
/docs/docs/en/reference/commands/check.rzk.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rzk-lang/rzk/3ea72b85e099e785e116a0877d37bca56cc77b7c/docs/docs/en/reference/commands/check.rzk.md
--------------------------------------------------------------------------------
/docs/docs/en/reference/commands/compute.rzk.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rzk-lang/rzk/3ea72b85e099e785e116a0877d37bca56cc77b7c/docs/docs/en/reference/commands/compute.rzk.md
--------------------------------------------------------------------------------
/docs/docs/en/reference/commands/define-postulate.rzk.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rzk-lang/rzk/3ea72b85e099e785e116a0877d37bca56cc77b7c/docs/docs/en/reference/commands/define-postulate.rzk.md
--------------------------------------------------------------------------------
/docs/docs/en/reference/commands/options.rzk.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rzk-lang/rzk/3ea72b85e099e785e116a0877d37bca56cc77b7c/docs/docs/en/reference/commands/options.rzk.md
--------------------------------------------------------------------------------
/docs/docs/en/reference/cube-layer.rzk.md:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/docs/docs/en/reference/extension-types.rzk.md:
--------------------------------------------------------------------------------
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 -> ` — this is usually fine;
9 | - `#!rzk \{t : I | psi} -> ` — 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 -> ` — this is usually fine;
15 | - `#!rzk \{t : I | psi} -> ` — 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.
18 |
--------------------------------------------------------------------------------
/docs/docs/en/reference/introduction.rzk.md:
--------------------------------------------------------------------------------
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.
71 |
72 | [^2]: In version [:octicons-tag-24: v0.1.0](https://github.com/rzk-lang/rzk/releases/tag/v0.1.0), `rzk` has supported simply typed lambda calculus, PCF, and MLTT. However, those languages have been removed.
73 |
--------------------------------------------------------------------------------
/docs/docs/en/reference/render.rzk.md:
--------------------------------------------------------------------------------
1 | # Rendering Diagrams
2 |
3 | Starting from version `0.3.0`, `rzk` supports rendering of topes, types, and terms as diagrams.
4 |
5 | This is a literate `rzk` file:
6 |
7 | ```rzk
8 | #lang rzk-1
9 | ```
10 |
11 | To enable rendering, enable option `"render" = "svg"` (to disable, `"render" = "none"`):
12 |
13 | ```rzk
14 | #set-option "render" = "svg" -- enable rendering in SVG
15 | ```
16 |
17 | Rendering is completely automatic, and works in the following situations:
18 |
19 | 1. Mapping from a shape (including curried mappings), up to 3 dimensions, only in products of `2` cubes;
20 | 2. Type of mapping from a shape (including curried mappings), up to 3 dimensions, only in products of `2` cubes.
21 | 3. Mappings from a shape that is a section of an existing shape.
22 |
23 | The rendering assigns the following colors:
24 |
25 | - purple is assigned for parameters (context) variables;
26 | - blue is used for fillings for types (e.g. for `hom` and `hom2`);
27 | - red is used for terms (e.g. `Segal-comp-witness`);
28 | - orange is used for shapes in the tope layer;
29 | - grey is used for discarded parts of a (larger) mapping (e.g. when extracting a diagonal/face from a larger shape).
30 |
31 | The SVG pictures can be inserted directly into `.md` files before a corresponding `rzk` code block. At the bottom of a markdown file, you might want to add stylization, e.g.:
32 |
33 | ```html
34 |
38 |
39 |
40 |
57 | ```
58 |
59 | ## Examples
60 |
61 | ### Visualising Simplicial Topes
62 |
63 | Topes are visualised with **orange** color:
64 |
65 | ```rzk
66 | -- 2-simplex
67 | #define Δ² : (2 * 2) -> TOPE
68 | := \(t, s) -> s <= t
69 | ```
70 |
71 | Boundary of a tope:
72 |
73 | ```rzk
74 | -- boundary of a 2-simplex
75 | #define ∂Δ² : Δ² -> TOPE
76 | := \(t, s) -> s === 0_2 \/ t === 1_2 \/ s === t
77 | ```
78 |
79 | The busiest tope diagram involves the entire 3D cube:
80 |
96 | ### Visualising Simplicial Types
97 |
98 | Types are visualised with **blue** color. Recognised parameter part (e.g. fixed endpoints, edges, faces with clear labels) are visualised with **purple** color. When a type is constructed by taking a part of another shape, the rest of the larger shape is colored using **gray** color.
99 |
100 | ```rzk
101 | -- [RS17, Definition 5.1]
102 | -- The type of arrows in A from x to y.
103 | #define hom
104 | (A : U) -- A type.
105 | (x y : A) -- Two points in A.
106 | : U -- (hom A x y) is a 1-simplex (an arrow)
107 | := (t : 2) -> A [ -- in A where
108 | t === 0_2 |-> x, -- * the left endpoint is exactly x
109 | t === 1_2 |-> y -- * the right endpoint is exactly y
110 | ]
111 | ```
112 |
113 | ```rzk
114 | -- [RS17, Definition 5.2]
115 | -- the type of commutative triangles in A
116 | #define hom2
117 | (A : U) -- A type.
118 | (x y z : A) -- Three points in A.
119 | (f : hom A x y) -- An arrow in A from x to y.
120 | (g : hom A y z) -- An arrow in A from y to z.
121 | (h : hom A x z) -- An arrow in A from x to z.
122 | : U -- (hom2 A x y z f g h) is a 2-simplex (triangle)
123 | := { (t1, t2) : Δ² } -> A [ -- in A where
124 | t2 === 0_2 |-> f t1, -- * the top edge is exactly f,
125 | t1 === 1_2 |-> g t2, -- * the right edge is exactly g, and
126 | t2 === t1 |-> h t2 -- * the diagonal is exactly h
127 | ]
128 | ```
129 |
130 | ### Visualising Terms of Simplicial Types
131 |
132 | Terms (with non-trivial labels) are visualised with **red** color (you can see a detailed label on hover). Recognised parameter part (e.g. fixed endpoints, edges, faces with clear labels) are visualised with **purple** color. When a term is constructed by taking a part of another shape, the rest of the larger shape is colored using **gray** color.
133 |
134 | We can visualise terms that fill a shape:
135 |
136 | ```rzk
137 | #define square
138 | (A : U)
139 | (x y z : A)
140 | (f : hom A x y)
141 | (g : hom A y z)
142 | (h : hom A x z)
143 | (a : Sigma (h' : hom A x z), hom2 A x y z f g h')
144 | : (2 * 2) -> A
145 | := \(t, s) -> recOR( s <= t |-> second a (t, s) , t <= s |-> second a (s, t))
146 | ```
147 |
148 | If a term is extracted as a part of a larger shape, generally, the whole shape will be shown (in gray):
149 |
150 | ```rzk
151 | #define face
152 | (A : U)
153 | (x y z : A)
154 | (f : hom A x y)
155 | (a : Sigma (g : hom A y z), {((t1, t2), t3) : 2 * 2 * 2 | t3 <= t1 \/ t2 <= t1} -> A [ t1 === 0_2 |-> f t2, t1 === 1_2 |-> g t3 ])
156 | : Δ² -> A
157 | := \(t, s) -> second a ((t, t), s)
158 | ```
159 |
160 |
161 |
165 |
166 |
167 |
184 |
--------------------------------------------------------------------------------
/docs/docs/en/reference/sections.rzk.md:
--------------------------------------------------------------------------------
1 | # Sections and Variables
2 |
3 | Sections and variables allow to simplify definitions by factoring out common assumptions.
4 |
5 | !!! info "Coq-style variables"
6 | `rzk` implements variables similarly to
7 | `Variable` command in Coq.
8 | An important difference is that `rzk` does not allow definitions to use variables implicitly and adds `uses (...)` annotations to ensure such dependencies are not accidental.
9 | This is, perhaps, somewhat related to this error message in Coq.
10 |
11 | This is a literate `rzk` file:
12 |
13 | ```rzk
14 | #lang rzk-1
15 | ```
16 |
17 | ## Variables
18 |
19 | Consider the following definitions:
20 |
21 | ```rzk
22 | #define compose₁
23 | (A B C : U)
24 | (g : B -> C)
25 | (f : A -> B)
26 | : A -> C
27 | := \x -> g (f x)
28 |
29 | #define twice₁
30 | (A : U)
31 | (h : A -> A)
32 | : A -> A
33 | := \x -> h (h x)
34 | ```
35 |
36 | Since it might be common to introduce types `A`, `B`, and `C`, we can declare these are variables:
37 |
38 | ```rzk
39 | #variables A B C : U
40 |
41 | #define compose₂
42 | (g : B -> C)
43 | (f : A -> B)
44 | : A -> C
45 | := \x -> g (f x)
46 |
47 | #define twice₂
48 | (h : A -> A)
49 | : A -> A
50 | := \x -> h (h x)
51 | ```
52 |
53 | The `#variables` command here introduces assumptions, which can be used in the following definitions. Importantly, after checking a file (module), all definitions will have the assumptions used (explicitly or implicitly) attached as bound variables.
54 |
55 | ### Implicitly used variables (and `uses`)
56 |
57 | We can try going even further and declare variables `f`, `g`, `h`, and `x`:
58 |
59 | ```rzk
60 | #variable g : B -> C
61 | #variable f : A -> B
62 | #variable h : A -> A
63 | #variable x : A
64 |
65 | -- #define bad-compose₃ : C := g (f x) -- ERROR: implicit assumptions A and B
66 | #define twice₃ : A := h (h x)
67 | ```
68 |
69 | Note how this definition of `bad-compose₃` is implicitly dependent on the types `A` and `B`, which is promptly noted by `rzk`, which issues an error (if we uncomment the corresponding line):
70 |
71 | ```text
72 | implicit assumption
73 | B : U
74 | used in definition of
75 | bad-compose₃
76 | ```
77 |
78 | To let `rzk` know that this is not accidental, we can add `uses (...)` annotation to specify a list of variables implicitly used in the definition:
79 |
80 | ```rzk
81 | #define compose₃ uses (A B) : C := g (f x)
82 | ```
83 |
84 | ## Sections
85 |
86 | To introduce assumption variables temporarily inside of one file, you can use sections:
87 |
88 | ```rzk
89 | #section example-1
90 |
91 | #variables X Y Z : U
92 | #variable k : X -> X
93 | #variable x' : X
94 |
95 | #define compose₄
96 | (g : Y -> Z)
97 | (f : X -> Y)
98 | : X -> Z
99 | := \x -> g (f x)
100 |
101 | #define twice₄ : X := k (k x')
102 |
103 | #end example-1
104 | ```
105 |
106 | Now, once outside of the section, `compose₄` and `twice₄` obtain corresponding parameters
107 | (only those used, explicitly or implicitly):
108 |
109 | ```rzk
110 | -- compose₄ : (X : U) -> (Y : U) -> (Z : U) -> (g : Y -> Z) -> (f : X -> Y) -> (X -> Z)
111 | -- twice₄ : (X : U) -> (k : X -> X) -> (x' : X) -> X
112 |
113 | #define twice₅
114 | (T : U)
115 | (e : T -> T)
116 | : T -> T
117 | := compose₄ T T T e e
118 |
119 | #define identity
120 | (T : U)
121 | : T -> T
122 | := twice₄ T (\t -> t)
123 | ```
124 |
125 | !!! warning "Lack of indentation"
126 | `rzk` currently does not support indentation, so all definitions and commands inside a section (including nested sections) have to start at the beginning of a line.
127 |
--------------------------------------------------------------------------------
/docs/docs/en/reference/tope-disjunction-elimination.rzk.md:
--------------------------------------------------------------------------------
1 | # Tope disjuction elimination
2 |
3 | Following Riehl and Shulman's type theory[^1], `#!rzk rzk-1` introduces two primitive terms for disjunction elimination:
4 |
5 | 1. `#!rzk recBOT` corresponds to \(\mathsf{rec}_\bot\), has any type, and is valid whenever tope context is included in `#!rzk BOT`;
6 |
7 | 2. `#!rzk recOR(«tope_1» |-> «term_1», ..., «tope_n» |-> «term_n»)` defines a term for a disjunction of topes `#!rzk «tope_1» \/ ... \/ «tope_n»`. This is well-typed when for an intersection of any two topes `#!rzk «tope_i» /\ «tope_j»` the corresponding terms `#!rzk «term_i»` and `#!rzk «term_j»` are judgementally equal. In particular, `#!rzk recOR(psi |-> a_psi, phi |-> a_phi)` corresponds to \(\mathsf{rec}_\lor^{\psi, \phi}(a_\psi, a_\phi)\).
8 |
9 | !!! warning "Deprecated syntax"
10 | `#!rzk recOR(psi, phi, a_psi, a_phi)` corresponds to \(\mathsf{rec}_\lor^{\psi, \phi}(a_\psi, a_\phi)\), is well-typed when `#!rzk a_psi` is definitionally equal to `#!rzk a_phi` under `#!rzk psi /\ phi`. However, this syntax is deprecated since it is easy to confuse which tope relates to which term.
11 |
12 | [^1]: Emily Riehl & Michael Shulman. _A type theory for synthetic ∞-categories._ Higher Structures 1(1), 147-224. 2017.
13 |
14 |
--------------------------------------------------------------------------------
/docs/docs/en/reference/tope-layer.rzk.md:
--------------------------------------------------------------------------------
1 | # Tope layer
2 |
3 | All topes live in `#!rzk TOPE` universe.
4 |
5 | Here are all the ways to build a tope:
6 |
7 | 1. Introduce a variable, e.g. `#!rzk (psi : TOPE) -> ...`;
8 |
9 | - Usually, topes depend on point variables from some cube(s). To indicate that, we usually introduce topes as "functions" from some cube to `#!rzk TOPE`. For example, `#!rzk (psi : I -> TOPE) -> ...`.
10 |
11 | 2. Use a constant:
12 |
13 | - top tope \(\top\) is written `#!rzk TOP`
14 | - bottom tope \(\bot\) is written `#!rzk BOT`
15 |
16 | 3. Usa a tope connective:
17 | - tope conjunction \(\psi \land \phi\) is written `#!rzk psi /\ phi`
18 | - tope disjunction \(\psi \lor \phi\) is written `#!rzk psi \/ phi`
19 | - equality tope \(t \equiv s\) is written `#!rzk t === s`, whenever `#!rzk t` and `#!rzk s` are points of the same cube
20 | - inequality tope \(t \leq s\) is written `#!rzk t <= s` whenever `#!rzk t : 2` and `#!rzk s : 2`
21 |
22 |
--------------------------------------------------------------------------------
/docs/docs/en/reference/type-layer.rzk.md:
--------------------------------------------------------------------------------
1 | # Types and terms
2 |
3 | ```rzk
4 | #lang rzk-1
5 | ```
6 |
7 | ## Functions (dependent products)
8 |
9 | Function (dependent product) types \(\prod_{x : A} B\) are written `#!rzk (x : A) -> B x`. Values of function types are \(\lambda\)-abstractions written in one of the following ways:
10 |
11 | - `#!rzk \x -> ` — this is usually fine;
12 | - `#!rzk \(x : A) -> ` — this sometimes helps the typechecker.
13 |
14 | ## Dependent sums
15 |
16 | Dependent sum type \(\sum_{x : A} B\) is written `#!rzk ∑ (x : A), B` or `#!rzk Sigma (x : A), B`. Values of dependent sum types are pairs written as `#!rzk (x, y)`.
17 |
18 | To access components of a dependent pair `#!rzk p`, use `#!rzk first p` and `#!rzk second p`.
19 |
20 | !!! warning
21 | `#!rzk first` and `#!rzk second` are not valid syntax without an argument!
22 |
23 | ## Identity types
24 |
25 | Identity (path) type \(x =_A y\) is written `#!rzk x =_{A} y`.
26 |
27 | !!! tip
28 | Specifying the type `#!rzk A` is optional: `#!rzk x = y` is valid syntax!
29 |
30 | Any identity type has value `#!rzk refl_{x : A}` whose type is `#!rzk x =_{A} x` whenever `#!rzk x : A`
31 |
32 | !!! tip
33 | Specifying term and type of `#!rzk refl_{x : A}` is optional: `#!rzk refl_{x}` and `#!rzk refl` are both valid syntax.
34 |
35 | Path induction is done using \(\mathcal{J}\) path eliminator:
36 |
37 | - for
38 | - any type \(A\) and \(a : A\),
39 | - type family \(C : \prod_{x : A} ((a =_A x) \to \mathcal{U})\) and
40 | - \(d : C(a,\mathsf{refl}_a)\) and
41 | - \(x : A\) and \(p : a =_A x\)
42 | - we have \(\mathcal{J}(A, a, C, d, x, p) : C(x, p)\)
43 |
44 | In `#!rzk rzk-1` we write `#!rzk idJ(A, a, C, d, x, p)`
45 |
46 | !!! warning
47 | `#!rzk idJ` is not valid syntax without exactly 6-tuple provided as an argument!
48 |
49 |
--------------------------------------------------------------------------------
/docs/docs/en/rzk.yaml:
--------------------------------------------------------------------------------
1 | include:
2 | - getting-started/dependent-types.rzk.md
3 | - examples/recId.rzk.md
4 |
--------------------------------------------------------------------------------
/docs/docs/en/tools.md:
--------------------------------------------------------------------------------
1 | # Tools
2 |
3 | Rzk proof assistant comes with built-in language server and formatter.
4 |
5 | Other tools help enhance user experience or automate things.
6 |
7 | ### VS Code extension for Rzk
8 |
9 | See [rzk-lang/vscode-rzk](https://github.com/rzk-lang/vscode-rzk).
10 | VS Code extension offers a lot of conveniences and using VS Code is recommended for newcomers,
11 | as it is considered the primary use case and has most support from the developers.
12 |
13 | ### MkDocs plugin for Rzk
14 |
15 | See [rzk-lang/mkdocs-plugin-rzk](https://github.com/rzk-lang/mkdocs-plugin-rzk).
16 | MkDocs plugin enhances documentation build from literate Rzk Markdown files:
17 | - adds diagram rendering (experimental)
18 | - adds definition anchors (helpful to have "permalinks" to definitions)
19 |
20 | ### GitHub Action for Rzk
21 |
22 | See [rzk-lang/rzk-action](https://github.com/rzk-lang/rzk-action).
23 | This action allows to check your Rzk formalizations on GitHub automatically.
24 | It can also be used to check formatting (experimental).
25 |
26 | ### Syntax highlighting (Pygments) for Rzk
27 |
28 | See [rzk-lang/pygments-rzk](https://github.com/rzk-lang/pygments-rzk).
29 | This is a simple syntax highlighter for Pygments (used by MkDocs and `minted` package in LaTeX).
30 | Note that VS Code extension is using the Rzk Language Server for more accurate "semantic highlighting".
31 |
--------------------------------------------------------------------------------
/docs/docs/ru/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | --8<-- "rzk/ChangeLog.md"
2 |
--------------------------------------------------------------------------------
/docs/docs/ru/CONTRIBUTORS.md:
--------------------------------------------------------------------------------
1 | --8<-- "CONTRIBUTORS.md"
2 |
--------------------------------------------------------------------------------
/docs/docs/ru/blog/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Redirecting
6 |
9 |
12 |
13 |
14 | Redirecting to Blog/...
15 |
16 |
17 |
--------------------------------------------------------------------------------
/docs/docs/ru/community.md:
--------------------------------------------------------------------------------
1 | # Сообщество Rzk
2 |
3 | Вокруг Rzk собралось небольшое сообщество математиков и информатиков.
4 |
5 | ## Чат
6 |
7 | Для всех желающих доступен (преимущественно англоязычный) чат Zulip,
8 | в котором можно обсудить формализации, разработку Rzk и смежные проекты:
9 |
10 | [Присоединиться к сообществу Rzk в Zulip](https://rzk-lang.zulipchat.com/register/){ .md-button .md-button--primary }
11 |
--------------------------------------------------------------------------------
/docs/docs/ru/getting-started/index.md:
--------------------------------------------------------------------------------
1 | # Первые шаги с Rzk
2 |
3 | 1. [Установите Rzk](install.md).
4 | 2. Получите [краткий экскурс](quickstart.rzk.md) по языку Rzk.
5 | 3. Просмотрите [введение в зависимые типы](dependent-types.rzk.md) в Rzk.
6 | 4. Научитесь настраивать [проекты формализации в Rzk](project.md).
7 | 5. Узнайте больше о возможностях Rzk в [Руководстве](../reference/index.md).
8 |
--------------------------------------------------------------------------------
/docs/docs/ru/getting-started/install.md:
--------------------------------------------------------------------------------
1 | # Установка Rzk
2 |
3 | ## Через расширение VS Code (рекомендуется)
4 |
5 | Следуйте этим инструкциям, чтобы настроить работу с Rzk в редакторе VS Code.
6 |
7 | 1. Установите [VS Code](https://code.visualstudio.com/).
8 | 2. Запустите VS Code и установите [расширение `rzk`](https://marketplace.visualstudio.com/items?itemName=NikolaiKudasovfizruk.rzk-1-experimental-highlighting).
9 | 3. Создайте новый файл через "Файл > Создать текстовый файл" (Ctrl+N). Нажмите `Select a language`, введите в поиске `rzk` и выберите "Literate Rzk Markdown".
10 | 
11 | 4. Вы должны увидеть следующее сообщение:
12 | 
13 | 5. Нажмите "Yes".
14 | 6. Пока Rzk устанавливается, скопируйте и вставьте следующий текст в открытый файл:
15 |
16 | ````markdown
17 | # Пример литературного кода с Rzk
18 |
19 | ```rzk
20 | #lang rzk-1
21 |
22 | -- тождественная функция
23 | #define id (A : U)
24 | : A -> A
25 | := \ x -> x
26 | ```
27 | ````
28 |
29 | 7. Когда установка завершится, вы должны увидеть следующее сообщение:
30 | 
31 | 8. Нажмите "Reload" (перезагрузить VS Code).
32 | 9. Сохраните ваш файл (например, как `example.rzk.md`).
33 | 10. Откройте терминал внутри VS Code (Ctrl+`).
34 |
35 |
36 |
37 | 11. В терминале запустите команду
38 |
39 | ```sh
40 | rzk typecheck example.rzk.md
41 | ```
42 |
43 | 12. Вы должны увидеть что-то такое:
44 |
45 | ```text
46 | Loading file example.rzk.md
47 | Checking module from example.rzk.md
48 | [ 1 out of 1 ] Checking #define id
49 | Everything is ok!
50 | ```
51 |
52 | 13. Поздравляем! Теперь ваш VS Code настроен на работу с Rzk :) Заметьте, что расширение будет уведомлять вас о наличии обновлений Rzk и предлагать обновить автоматически.
53 |
54 | 14. Можете перейти к [Быстрому началу](quickstart.rzk.md) чтобы познакомиться с языком Rzk!
55 |
56 | ## Установка исполняемых файлов
57 |
58 | ### Через страницу релизов на GitHub
59 |
60 | Вы можете скачать исполняемые файлы (для Linux, Windows, и macOS) напрямую со страницы релизов на GitHub: .
61 | Если ваша платформа не поддержана, вы можете попробовать установить Rzk из исходников (см. ниже)
62 | или оставить пожелание о расширении поддержки на странице задач: .
63 |
64 | ## Сборка и установка из исходников
65 |
66 | Вы можете установить Rzk из исходников: вы можете либо скачать стабильную версию из репозитория пакетов Hackage, либо собрать самую свежую версию из ветки `develop` на GitHub.
67 |
68 | ### Stack
69 |
70 | Чтобы собрать и установить Rzk при помощи Stack, из репозитория Hackage:
71 |
72 | ```sh
73 | stack install rzk
74 | ```
75 |
76 | Чтобы собрать и установить Rzk при помощи Stack, из исходников на GitHub:
77 |
78 | ```sh
79 | git clone https://github.com/rzk-lang/rzk.git
80 | cd rzk
81 | git checkout develop
82 | stack build && stack install
83 | ```
84 |
85 | ### cabal-install
86 |
87 | Чтобы собрать и установить Rzk при помощи `cabal-install`, из репозитория Hackage:
88 |
89 | ```sh
90 | cabal v2-update
91 | cabal v2-install rzk
92 | ```
93 |
94 | Чтобы собрать и установить Rzk при помощи `cabal-install`, из исходников на GitHub:
95 |
96 | ```sh
97 | git clone https://github.com/rzk-lang/rzk.git
98 | cd rzk
99 | git checkout develop
100 | cabal v2-build && cabal v2-install
101 | ```
102 |
103 | ### Nix
104 |
105 | !!! warning "Раздел в работе."
106 |
107 | Раздел нуждается в доработке.
108 |
--------------------------------------------------------------------------------
/docs/docs/ru/getting-started/project.md:
--------------------------------------------------------------------------------
1 | # Настройка проекта
2 |
3 | !!! warning "Раздел в работе"
4 | Скоро здесь будет описание работы с проектами формализации.
5 | До тех пор вы можете воспользоваться шаблонным проектом: .
6 | Также см. для примера реального проекта.
7 |
--------------------------------------------------------------------------------
/docs/docs/ru/getting-started/quickstart.rzk.md:
--------------------------------------------------------------------------------
1 | # Быстрое начало
2 |
3 | !!! warning "Раздел в работе"
4 | Этот раздел нуждается в доработке.
5 |
6 | Для начала, [установите Rzk](install.md).
7 |
8 | Этот раздел является литературным файлом Rzk:
9 |
10 | ```rzk
11 | #lang rzk-1
12 | ```
13 |
--------------------------------------------------------------------------------
/docs/docs/ru/index.md:
--------------------------------------------------------------------------------
1 | # Решатель теорем Rzk
2 |
3 | Rzk — это экспериментальный интерактивный решатель теорем,
4 | основанный на [«Теории типов для синтетических ∞-категорий](https://arxiv.org/abs/1705.07442)[^1].
5 |
6 | [Первые шаги с Rzk](getting-started/install.md){ .md-button .md-button--primary }
7 | [Попробовать Rzk в онлайн-песочнице](playground/index.html){ .md-button }
8 |
9 | ## Об этом проекте
10 |
11 | Проект начался с идеи воплотить "в жизнь" статью Эмили Рил и Майкла Шульмана 2017 года[^1],
12 | реализуя решатель для их теории типов с формами (type theory with shapes).
13 | На момент написания этого текста, Rzk поддерживает формальный язык, близкий к теории типов в упомянутой статье,
14 | а также вокруг решателя существует некая инструментальная поддержка
15 | (например, расширение для VS Code и языковой сервер с поддержкой подсветки синтаксиса и автоформатирования).
16 |
17 | ### Формализация теории ∞-категорий
18 |
19 | Большая часть статьи Рил и Шульмана (вплоть до леммы Йонеды для ∞-категорий) уже формализована на Rzk (см. [Yoneda for ∞-categories](https://emilyriehl.github.io/yoneda/)[^2]).
20 | Оставшие результаты, а также результаты из других работ находятся в процессе формализации (см. проект по формализации симплициальной гомопотической теории типов, [sHoTT](https://rzk-lang.github.io/sHoTT/)).
21 | Также некоторые усилия направлены на формализацию "книжной"[^6] [^7] гомотопической теории типов (см. [hottbook](https://rzk-lang.github.io/hottbook/)).
22 |
23 | ### Работа с Rzk
24 |
25 | Рекомендуемый способ работы с Rzk — через среду разработки VS Code (см. [Первые шаги](getting-started/install.md)).
26 | Тем не менее, вы также можете скачать исполняемые файлы на [странице релизов на GitHub](https://github.com/rzk-lang/rzk/releases),
27 | собрать самостоятельно [из исходников](getting-started/install.md#install-from-sources),
28 | а также попытаться интегрировать языковой сервер Rzk с вашим любимым текстовым редактором.
29 | Для небольших формализаций, умещающихся в один файл, можно также воспользоваться [онлайн-песочницей Rzk](playground/index.html).
30 |
31 | ### Реализация
32 |
33 | Помимо своей основной цели, Rzk также служит полем экспериментов для методов реализации решателей теорем (на языке Haskell).
34 | В частности, в реализации используется вариант абстрактного синтаксиса второго порядка
35 | для комфортной работы со связанными переменными и, в будущем, для вывода (зависимых) типов
36 | через унификацию высшего порядка[^3] [^4].
37 | В конечном итоге, хочется получить приемлемое общее (библиотечное) решение для унификации высшего порядка и вывода типов,
38 | оставив реализацию Rzk (по крайней мере, его ядра) небольшим, простым для поддержки, и надёжным.
39 |
40 | Ещё одна интересная деталь реализации Rzk — это автоматический решатель для слоя форм (tope layer)[^5].
41 | Это встроенный полностью автоматический решатель для варианта интуиционистской логики,
42 | необходимый для проверки типов.
43 | Хотя текущая реализация решателя относительно проста,
44 | её хватает на практике для проверки доказательств о синтетических ∞-категориях
45 | без нужды в дополнительном коде от формализующего математика.
46 |
47 | Rzk и сопутствующие инструменты разработаны всего парой человек.
48 | Вы можете ознакомится с участниками проекта в файле [CONTRIBUTORS.md](CONTRIBUTORS.md).
49 |
50 | ### Обсуждения вокруг Rzk
51 |
52 | Для всех желающих доступен (преимущественно англоязычный) чат Zulip,
53 | в котором можно обсудить формализации, разработку Rzk и смежные проекты:
54 |
55 | [Присоединиться к сообществу Rzk в Zulip](https://rzk-lang.zulipchat.com/register/){ .md-button .md-button--primary }
56 |
57 | [^1]:
58 | Emily Riehl & Michael Shulman. _A type theory for synthetic ∞-categories_.
59 | Higher Structures 1(1), 147-224. 2017.
60 |
61 | [^2]:
62 | Nikolai Kudasov, Emily Riehl, Jonathan Weinberger.
63 | _Formalizing the ∞-categorical Yoneda lemma_. 2023.
64 |
65 | [^3]:
66 | Nikolai Kudasov. _Functional Pearl: Dependent type inference via free higher-order unification_. 2022.
67 |
68 |
69 | [^4]:
70 | Nikolai Kudasov. _E-Unification for Second-Order Abstract Syntax_. In 8th International Conference on Formal Structures for Computation and Deduction (FSCD 2023). Leibniz International Proceedings in Informatics (LIPIcs), Volume 260, pp. 10:1-10:22, Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2023)
71 |
72 |
73 | [^5]:
74 | Nikolai Kudasov. Experimental prover for Tope logic. SCAN 2023, pages 37–39. 2023.
75 |
76 |
77 | [^6]:
78 | The Univalent Foundations Program. _Homotopy Type Theory: Univalent Foundations of Mathematics_.
79 | Institute for Advanced Study. 2013.
80 |
81 | [^7]:
82 | Международный коллектив авторов. _Гомотопическая теория типов: унивалентные основания математики_.
83 | ИНСТИТУТ ПЕРСПЕКТИВНЫХ ИССЛЕДОВАНИЙ. Перевод и редактирование: ГЕННАДИЙ ЧЕРНЫШЕВ.
84 |
85 |
86 | ## Другие решатели для гомотопической теории типов
87 |
88 | Rzk — не первый и не единственный решатель для (варианта) гомотопической теории типов.
89 | См. [краткое сравнение Rzk с другими решателями](related.md).
90 |
--------------------------------------------------------------------------------
/docs/docs/ru/playground/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Redirecting
6 |
12 |
13 |
14 | Redirecting...
15 |
16 |
17 |
--------------------------------------------------------------------------------
/docs/docs/ru/reference/builtins/directed-interval.rzk.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rzk-lang/rzk/3ea72b85e099e785e116a0877d37bca56cc77b7c/docs/docs/ru/reference/builtins/directed-interval.rzk.md
--------------------------------------------------------------------------------
/docs/docs/ru/reference/builtins/unit.rzk.md:
--------------------------------------------------------------------------------
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/rzk-lang/rzk/releases/tag/v0.5.1
63 |
64 | [^1]: The Univalent Foundations Program (2013). _Homotopy Type Theory: Univalent Foundations of Mathematics._
65 |
--------------------------------------------------------------------------------
/docs/docs/ru/reference/commands/check.rzk.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rzk-lang/rzk/3ea72b85e099e785e116a0877d37bca56cc77b7c/docs/docs/ru/reference/commands/check.rzk.md
--------------------------------------------------------------------------------
/docs/docs/ru/reference/commands/compute.rzk.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rzk-lang/rzk/3ea72b85e099e785e116a0877d37bca56cc77b7c/docs/docs/ru/reference/commands/compute.rzk.md
--------------------------------------------------------------------------------
/docs/docs/ru/reference/commands/define-postulate.rzk.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rzk-lang/rzk/3ea72b85e099e785e116a0877d37bca56cc77b7c/docs/docs/ru/reference/commands/define-postulate.rzk.md
--------------------------------------------------------------------------------
/docs/docs/ru/reference/commands/options.rzk.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rzk-lang/rzk/3ea72b85e099e785e116a0877d37bca56cc77b7c/docs/docs/ru/reference/commands/options.rzk.md
--------------------------------------------------------------------------------
/docs/docs/ru/reference/cube-layer.rzk.md:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/docs/docs/ru/reference/extension-types.rzk.md:
--------------------------------------------------------------------------------
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 -> ` — this is usually fine;
9 | - `#!rzk \{t : I | psi} -> ` — 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 -> ` — this is usually fine;
15 | - `#!rzk \{t : I | psi} -> ` — 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.
18 |
--------------------------------------------------------------------------------
/docs/docs/ru/reference/introduction.rzk.md:
--------------------------------------------------------------------------------
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.
71 |
72 | [^2]: In version [:octicons-tag-24: v0.1.0](https://github.com/rzk-lang/rzk/releases/tag/v0.1.0), `rzk` has supported simply typed lambda calculus, PCF, and MLTT. However, those languages have been removed.
73 |
--------------------------------------------------------------------------------
/docs/docs/ru/reference/render.rzk.md:
--------------------------------------------------------------------------------
1 | # Rendering Diagrams
2 |
3 | Starting from version `0.3.0`, `rzk` supports rendering of topes, types, and terms as diagrams.
4 |
5 | This is a literate `rzk` file:
6 |
7 | ```rzk
8 | #lang rzk-1
9 | ```
10 |
11 | To enable rendering, enable option `"render" = "svg"` (to disable, `"render" = "none"`):
12 |
13 | ```rzk
14 | #set-option "render" = "svg" -- enable rendering in SVG
15 | ```
16 |
17 | Rendering is completely automatic, and works in the following situations:
18 |
19 | 1. Mapping from a shape (including curried mappings), up to 3 dimensions, only in products of `2` cubes;
20 | 2. Type of mapping from a shape (including curried mappings), up to 3 dimensions, only in products of `2` cubes.
21 | 3. Mappings from a shape that is a section of an existing shape.
22 |
23 | The rendering assigns the following colors:
24 |
25 | - purple is assigned for parameters (context) variables;
26 | - blue is used for fillings for types (e.g. for `hom` and `hom2`);
27 | - red is used for terms (e.g. `Segal-comp-witness`);
28 | - orange is used for shapes in the tope layer;
29 | - grey is used for discarded parts of a (larger) mapping (e.g. when extracting a diagonal/face from a larger shape).
30 |
31 | The SVG pictures can be inserted directly into `.md` files before a corresponding `rzk` code block. At the bottom of a markdown file, you might want to add stylization, e.g.:
32 |
33 | ```html
34 |
38 |
39 |
40 |
57 | ```
58 |
59 | ## Examples
60 |
61 | ### Visualising Simplicial Topes
62 |
63 | Topes are visualised with **orange** color:
64 |
65 | ```rzk
66 | -- 2-simplex
67 | #define Δ² : (2 * 2) -> TOPE
68 | := \(t, s) -> s <= t
69 | ```
70 |
71 | Boundary of a tope:
72 |
73 | ```rzk
74 | -- boundary of a 2-simplex
75 | #define ∂Δ² : Δ² -> TOPE
76 | := \(t, s) -> s === 0_2 \/ t === 1_2 \/ s === t
77 | ```
78 |
79 | The busiest tope diagram involves the entire 3D cube:
80 |