Checked Trinitarianism.

This commit is contained in:
kl-i 2021-07-29 22:55:16 +01:00
parent 995c54894e
commit 064691b029
11 changed files with 134 additions and 92 deletions

View File

@ -1,10 +1,11 @@
The HoTT Game The HoTT Game
============= =============
The Homotopy Type Theory (HoTT) Game is a project aimed at The Homotopy Type Theory (HoTT) Game is a project written by mathematicians
introducing mathematicians with no experience for mathematicians interested in HoTT and no experience in proof verification,
in proof verification interested in HoTT and able to use Agda for HoTT. with the aim of introducing Cubical Agda as a tool for
This guide will help you get the Game working for you. trying out mathematics in HoTT.
This page will help you get the Game working for you.
## Installing Agda and the Cubical Agda library ## Installing Agda and the Cubical Agda library
@ -15,8 +16,8 @@ It is recommended that you use Agda in the text editor
[emacs]( [emacs](
https://www.gnu.org/software/emacs/tour/index.html), https://www.gnu.org/software/emacs/tour/index.html),
in particular in particular
[Doom Emacs](https://github.com/hlissner/doom-emacs) is a bit nicer if you [Doom Emacs](https://github.com/hlissner/doom-emacs),
can't be bothered to do a bunch of configuration. if you can't be bothered to do a bunch of configuration.
Once you have Emacs and Agda, get the [Cubical Library]( Once you have Emacs and Agda, get the [Cubical Library](
https://github.com/agda/cubical) (version 0.3) https://github.com/agda/cubical) (version 0.3)
@ -38,19 +39,28 @@ the-directory/HoTTGameLib.agda
``` ```
to your `libraries` file as above. to your `libraries` file as above.
Try opening up `Trinitarianism/AsProps/Quest0.agda` in Emacs Try opening `Trinitarianism/Quest0.agda` in Emacs
and do `Ctrl-c Ctrl-l`. and do `Ctrl-c Ctrl-l`.
Some text should be highlighted, and any `?` should turn into `{ }`. Some text should be highlighted, and any `?` should turn into `{ }`.
## How the game works ## How the game works
Our Game is under development. Please contact the devs. Our Game is under development. Please contact the devs.
Currently you can try `Trinitarianism/AsProps/Quest0.agda`, Currently you can try the _quests_ in the `Trinitarianism` folder.
making use of the accompanying solutions Agda file. Each quest consists of three files, for example :
- `Trinitarianism/Quest0.md` is the guide for the quest
In there, you will find details of the tasks
you must finish in order to complete the quest.
For now, it is recommended that
you view these online within github.
- `Trinitarianism/Quest0.agda` is the actual file in which
you do the quest.
- `Trinitarianism/Quest0Solutions.agda` contains
solutions to the tasks in the quest.
## Emacs and Agda usage ## Emacs and Agda usage
We have a file with a list of basic Emacs commands and We will have a file with a list of basic Emacs commands,
you _should_ be able to learn how to use Agda as you go along. but you _should_ be able to learn how to use Agda as you go along.
## Feedback ## Feedback
If you have any feedback please contact the devs. If you have any feedback please contact the devs.

BIN
Trinitarianism/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -13,10 +13,10 @@ we have another type `A → B : Type` which can be seen as
- internal hom of the category `Type` - internal hom of the category `Type`
To give examples of this, let's make some types first! To give examples of this, let's make some types first!
Here is how we define 'true'.
```agda ```agda
-- Here is how we define 'true' data : Type where
data : Type u where
tt : tt :
``` ```
@ -40,14 +40,14 @@ TrueToTrue :
TrueToTrue = {!!} TrueToTrue = {!!}
``` ```
- press `C-c C-l` (this means `Ctrl-c Ctrl-l`) to load the document, - enter `C-c C-l` (this means `Ctrl-c Ctrl-l`) to load the document,
and now you can fill the holes and now you can fill the hole `{ }`
- navigate to the hole `{ }` using `C-c C-f` (forward) or `C-c C-b` (backward) - navigate to the hole `{ }` using `C-c C-f` (forward) or `C-c C-b` (backward)
- press `C-c C-r` and agda will try to help you (r for refine) - enter `C-c C-r` and agda will try to help you (`r` stands for _refine_)
- you should see `λ x → { }` - you should see `λ x → { }`
- navigate to the new hole - navigate to the new hole
- `C-c C-,` to check the goal (`C-c C-comma`) - enter `C-c C-,` to check the _goal_ (`C-c C-comma`)
- the Goal area should look like - the Goal area ('agda information' window) should look like
```agda ```agda
Goal: Goal:
@ -56,10 +56,12 @@ TrueToTrue = {!!}
``` ```
- you have a proof/recipe/generalized element `x : ` - you have a proof/recipe/generalized element `x : `
and you need to give a p/r/g.e. of `` and you need to give a proof/recipe/generalized element of ``
- you can give it a p/r/g.e. of `` and press `C-c C-SPC` to fill the hole - you can give it a proof/recipe/generalized element of ``
and press `C-c C-SPC` to fill the hole (`SPC` means the space button)
There is more than one proof (see solutions) - are they 'the same'? There is more than one proof (see solutions) -
are they 'the same'?
What is 'the same'? What is 'the same'?
Here is an important solution: Here is an important solution:
@ -72,7 +74,10 @@ TrueToTrue' x = {!!}
- Naviagate to the hole and check the goal. - Naviagate to the hole and check the goal.
- Note `x` is already taken out for you. - Note `x` is already taken out for you.
- You can try type `x` in the hole and `C-c C-c` - You can try type `x` in the hole and `C-c C-c`
- `c` stands for 'cases on `x`' and the only case is `tt`. - `c` stands for 'cases'.
Doing `C-c C-c` with `x` in the hole
tells agda to 'do cases on `x`'.
The only case is `tt`.
Built into the definition of `` is agda's way of making a map out of Built into the definition of `` is agda's way of making a map out of
into another type A, which we have just used. into another type A, which we have just used.
@ -107,7 +112,9 @@ explosion x = {!!}
Agda knows that there are no cases so there is nothing to do! Agda knows that there are no cases so there is nothing to do!
This has three interpretations: This has three interpretations:
- false implies anything (principle of explosion) - false implies anything (principle of explosion)
- ? - One can convert recipes of `⊥` to recipes of
any other construction since
there are no recipes of `⊥`.
- `⊥` is initial in the category `Type` - `⊥` is initial in the category `Type`
We can also encode "natural numbers" as a type. We can also encode "natural numbers" as a type.
@ -118,14 +125,13 @@ data : Type where
suc : suc :
``` ```
As a construction, this reads ' As a construction, this reads :
- `` is a type of construction - `` is a type of construction
- `zero` is a recipe for `` - `zero` is a recipe for ``
- `suc` takes an existing recipe for `` and gives - `suc` takes an existing recipe for `` and gives
another recipe for ``. another recipe for ``.
'
We can see `` categorically : We can also see `` categorically :
is a natural numbers object in the category `Type`. is a natural numbers object in the category `Type`.
This means it is equipped with morphisms `zero : ` This means it is equipped with morphisms `zero : `
and `suc : ` such that and `suc : ` such that
@ -136,7 +142,7 @@ such that the diagram commutes:
width="500" width="500"
class="center"/> class="center"/>
This has no interpretation as a proposition since `` has no interpretation as a proposition since
there are 'too many proofs' - there are 'too many proofs' -
mathematicians classically don't distinguish mathematicians classically don't distinguish
between proofs of a single proposition. between proofs of a single proposition.
@ -151,16 +157,19 @@ go to Quest1!
You may have noticed the notational similarities between You may have noticed the notational similarities between
`zero : ` and ` : Type`. `zero : ` and ` : Type`.
This may have lead you to the question, `Type : ?`. This may have lead you to the question, `Type : ?`.
In type theory, we simply assert `Type : Type 1`. In type theory, we simply assert `Type : Type₁`.
But then we are chasing our tail, asking `Type 1 : ?`. But then we are chasing our tail, asking `Type₁ : Type₂`.
Type theorists make sure that every type (the thing on the right side of the `:`) Type theorists make sure that every type
itself is a term, and every term has a type. (i.e. anything the right side of `:`)
itself is a term (i.e. anything on the left of `:`),
and every term has a type.
So what we really need is So what we really need is
``` ```
Type : Type₁, Type₁ : Type₂, Type₂ : Type₃, ⋯ Type : Type₁, Type₁ : Type₂, Type₂ : Type₃, ⋯
``` ```
These are called _universes_. These are called _universes_.
The numberings of universes are called _levels_. The numberings of universes are called _levels_.
We will start using universes in the next quest.
<!-- <!--
Everything we will make will be closed in Everything we will make will be closed in

View File

@ -5,5 +5,11 @@ open import Trinitarianism.Preambles.P1
isEven : Type isEven : Type
isEven n = {!!} isEven n = {!!}
{-
This is a comment block.
Remove this comment block and formulate
'there exists an even natural' here.
-}
div2 : Σ isEven div2 : Σ isEven
div2 x = {!!} div2 x = {!!}

View File

@ -33,7 +33,7 @@ isEven n = ?
`zero` and `suc n`, `zero` and `suc n`,
since these are the only constructors given since these are the only constructors given
in the definition of ``." in the definition of ``."
This has the following interpretations, This has the following interpretations :
- propositionally, this is the _principle of mathematical induction_. - propositionally, this is the _principle of mathematical induction_.
- categorically, this is the universal property of a - categorically, this is the universal property of a
natural numbers object. natural numbers object.
@ -74,17 +74,16 @@ isEven n = ?
The reason we have access to the term `isEven n` is again The reason we have access to the term `isEven n` is again
because we are in the 'inductive step'. because we are in the 'inductive step'.
- There should now be nothing in the 'agda info' window. - There should now be nothing in the 'agda info' window.
Everything is working! This means everything is working.
There are three interpretations of `isEven : → Type`. There are three interpretations of `isEven : → Type`.
- Already mentioned, `isEven` is a predicate on ``. - Already mentioned, `isEven` is a predicate on ``.
- `isEven` is a _dependent construction_. - `isEven` is a _dependent construction_.
Specifically, it is either `` or `⊥` depending on `n : `. Specifically, `isEven n` is either `` or `⊥` depending on `n : `.
- `isEven` is a _bundle over ``_, - `isEven` is a _bundle over ``_,
i.e. an object in the over-category `Type↓`. i.e. an object in the over-category `Type↓`.
Pictorially, it looks like Pictorially, it looks like
<img src="images/isEven.png" <img src="images/isEven.png"
alt="isEven" alt="isEven"
width="500"/> width="500"/>
@ -96,8 +95,8 @@ There are three interpretations of `isEven : → Type`.
In general given a type `A : Type`, In general given a type `A : Type`,
a _dependent type over `A`_ is a term of type `A → Type`. a _dependent type over `A`_ is a term of type `A → Type`.
You can check if `2` is even by asking agda to 'normalize' it: You can check if `2` is even by asking agda to 'reduce' the term `isEven 2`:
do `C-c C-n` (`n` for normalize) and type in `isEven 2`. do `C-c C-n` (`n` for normalize) and type in `isEven 2`.
(By the way you can write in numerals since we are now secretly (By the way you can write in numerals since we are now secretly
using `` from the cubical agda library.) using `` from the cubical agda library.)
@ -105,24 +104,25 @@ using `` from the cubical agda library.)
Now that we have expressed `isEven` we need to be able write down "existence". Now that we have expressed `isEven` we need to be able write down "existence".
In maths we might write In maths we might write
```∃ x ∈ , isEven x``` ```∃ x ∈ , isEven x```
which in Agda notation is which in agda notation is
```Σ isEven``` ```Σ isEven```
This is called a _sigma type_, which has three interpretations: This is called a _sigma type_, which has three interpretations:
- the proposition 'there exists an even natural' - the proposition 'there exists an even natural'
- the constructions 'naturals `n` with recipes of `isEven n`' - the construction
'keep a recipe `n` of naturals together with a recipe of `isEven n`'
- the total space of the bundle `isEven` over ``, - the total space of the bundle `isEven` over ``,
which is the space consisting of the all the fibers. which is the space obtained by putting together all the fibers.
Pictorially, it looks like Pictorially, it looks like
<img src="images/isEvenBundle.png" <img src="images/isEvenBundle.png"
alt="SigmaTypeOfIsEven" alt="SigmaTypeOfIsEven"
width="500"/> width="500"/>
which can also be viewed as the subset of even naturals, which can also be viewed as the subset of even naturals,
since the fibers are either empty or singleton since the fibers are either empty or singleton.
(it is a _subsingleton bundle_). (It is a _subsingleton bundle_).
Making a term of this type has three interpretations: Making a term of this type has three interpretations:
- giving a term `n : ` and a proof `hn : isEven n` that `n` is even. - a natural `n : ` together with a proof `hn : isEven n` that `n` is even.
- constructing a natural `n : ` and a recipe `hn : isEven n`. - a recipe `n : ` together with a recipe `hn : isEven n`.
- a point in the total space is a point `n : ` downstairs - a point in the total space is a point `n : ` downstairs
together with a point `hn : isEven n` in its fiber. together with a point `hn : isEven n` in its fiber.
@ -135,11 +135,11 @@ Name = ?
- Load the file, go to the hole and refine the goal. - Load the file, go to the hole and refine the goal.
- If you formulated the statement right it should split into `{!!} , {!!}` - If you formulated the statement right it should split into `{!!} , {!!}`
and you can check the types of terms the holes require. and you can check the types of terms the holes require.
- Fill the holes, there are many proofs you can do! - Fill the holes. There are many proofs you can do!
In general when `A : Type` is a type and `B : A → Type` is a In general when `A : Type` is a type and `B : A → Type` is a
predicate/dependent construction/bundle over `A`, predicate/dependent construction/bundle over `A`,
we can write `Σ A B` as the collection of pairs `a , b` we can write the type `Σ A B` whose terms are pairs `a , b`
where `a : A` and `b : B a`. where `a : A` and `b : B a`.
There are two ways of using a term in a sigma type. There are two ways of using a term in a sigma type.
@ -147,7 +147,7 @@ We can extract the first part using `fst` or the second part using `snd`.
Given `x : Σ A B` there are three interpretations of `fst` and `snd`: Given `x : Σ A B` there are three interpretations of `fst` and `snd`:
- Viewing `x` as a proof of existence - Viewing `x` as a proof of existence
`fst x` provides the witness of existence and `snd` provides the proof `fst x` provides the witness of existence and `snd` provides the proof
of the property that the witness `fst x` has the desired property
- Viewing `x` as a recipe `fst` extracts the first component and - Viewing `x` as a recipe `fst` extracts the first component and
`snd` extracts the second component `snd` extracts the second component
- Viewing `x` as a point in the total space of a bundle - Viewing `x` as a point in the total space of a bundle
@ -156,37 +156,45 @@ Given `x : Σ A B` there are three interpretations of `fst` and `snd`:
In particular you can interpret `fst` as projection from the total space In particular you can interpret `fst` as projection from the total space
to the base space, collapsing fibers. to the base space, collapsing fibers.
For example to define a map that takes an even natural and divides it by two For example to define a map that takes an even natural and divides it by two
we can we can do
```agda ```agda
div2 : Σ isEven → div2 : Σ isEven →
div2 x = ? div2 x = ?
``` ```
- Load the file, go to the hole and case on `x` - Load the file, go to the hole and case on `x`.
(you might want to rename `fst₁` and `snd₁`). You might want to rename `fst₁` and `snd₁`.
```agda ```agda
div2 : Σ isEven → div2 : Σ isEven →
div2 (fst₁ , snd₁) = {!!} div2 (fst₁ , snd₁) = {!!}
``` ```
- Case on `fst₁` and tell it what to give for `0 , _` - Case on `fst₁` and tell agda what to give for `0 , _`,
```agda i.e. what 'zero divided by two' ought to be.
div2 : Σ isEven → ```agda
div2 (zero , snd₁) = {!!} div2 : Σ isEven →
div2 (suc fst₁ , snd₁) = {!!} div2 (zero , snd₁) = {!!}
``` div2 (suc fst₁ , snd₁) = {!!}
```
- Navigate to the second hole and case on `fst₁` again. - Navigate to the second hole and case on `fst₁` again.
Notice that agda knows there is no term looking like `1 , _` Notice that agda knows there is no term looking like `1 , _`
so it has skipped that case for us. so it has skipped that case for us.
- `n + 2 / 2` should just be `n/2 + 1` so try writing in `suc` and refining the goal ```agda
div2 : Σ isEven →
div2 (zero , snd₁) = 0
div2 (suc (suc fst₁) , snd₁) = {!!}
```
- `(n + 2) / 2` should just be `n/2 + 1`
so try writing in `suc` and refining the goal
- How do you write down `n/2`? Hint: we are in the 'inductive step'. - How do you write down `n/2`? Hint: we are in the 'inductive step'.
Try dividing some terms by `2`: Try dividing some terms by `2`:
- Use `C-c C-n` and write `div2 (2 , tt)` for example. - Use `C-c C-n` and write `div2 (2 , tt)` for example.
- Try dividing `36` by `2`. - Try dividing `36` by `2`.
Important observation: the two proofs `2 , tt` and `36 , tt` of the statement *Important Observation* :
the two proofs `2 , tt` and `36 , tt` of the statement
'there exists an even natural' are not 'the same' in any sense, 'there exists an even natural' are not 'the same' in any sense,
since if they were `div2 (2 , tt)` would be 'the same' `div2 (36/2 , tt)`, since if they were `div2 (2 , tt)` would be 'the same' `div2 (36/2 , tt)`,
hence `1` would be 'the same' as `18`. and hence `1` would be 'the same' as `18`.
> Are they 'the same'? What is 'the same'? > Are they 'the same'? What is 'the same'?
<!-- see Arc/Quest smth? --> <!-- see Arc/Quest smth? -->

View File

@ -3,8 +3,8 @@
We will try to formulate and prove the statement We will try to formulate and prove the statement
> The sum of two even naturals is even. > The sum of two even naturals is even.
To do so we must define `+` on the naturals. To do so we must define `+` on the naturals.
Addition takes in two naturals and spits out a Addition takes in two naturals and spits out a natural,
natural, so it should have type ``. so it should have type ``.
```agda ```agda
_+_ : _+_ :
n + m = ? n + m = ?
@ -12,8 +12,8 @@ n + m = ?
Agda supports the notation `_+_` (without spaces) Agda supports the notation `_+_` (without spaces)
which means from now on you can write `0 + 1` which means from now on you can write `0 + 1`
and so on (with spaces). and so on (with spaces).
Try coming up with a sensible definition yourself, Try coming up with a sensible definition.
it may not look exactly like ours. It may not look 'the same' as ours.
<details> <details>
<summary>Hint</summary> <summary>Hint</summary>
`n + 0` should be `n` and `n + (m + 1)` should be `(n + m) + 1` `n + 0` should be `n` and `n + (m + 1)` should be `(n + m) + 1`
@ -38,27 +38,30 @@ There are three ways to interpret this:
- `isEven (_ .fst + _ .fst)` is a bundle over the categorical product - `isEven (_ .fst + _ .fst)` is a bundle over the categorical product
isEven × Σ isEven` and `SumOfEven` is a _section_ of the bundle. isEven × Σ isEven` and `SumOfEven` is a _section_ of the bundle.
More generally given `A : Type` and `B : A → Type` we can form the _pi type_ More generally given `A : Type` and `B : A → Type`
`(x : A) → B x : Type` (in other languages `Π (x : ), isEven n`). we can form the _pi type_ `(x : A) → B x : Type`
(in other languages `Π (x : ), isEven n`).
The notation suggests that these behave like functions, The notation suggests that these behave like functions,
and indeed in the special case where the fiber is constant and indeed in the special case where the fiber is constant
with respect to the base a section is just a term of type `A → B`, with respect to the base space
i.e. a function. Hence pi types are also known as a section is just a term of type `A → B`, i.e. a function.
_dependent function types_. Hence pi types are also known as _dependent function types_.
We are now in a position to prove the statement. Have fun! We are now in a position to prove the statement. Have fun!
_Important_: Once you have proven the statement, _Important_: Once you have proven the statement,
check out our two ways of defining addition `_+_` and `_+'_` check out our two ways of defining addition `_+_` and `_+'_`
(in the solutions). (in the solutions).
Use `C-c C-n` to check that they compute the same values - Use `C-c C-n` to check that they compute the same values
on different examples. on different examples.
Uncomment the code for `Sum'OfEven` in the solutions, - Uncomment the code for `Sum'OfEven` in the solutions.
it is just `SumOfEven` but with `+`s changed for `+'`s. It is just `SumOfEven` but with `+`s changed for `+'`s.
Load the file. Does the proof still work? - Load the file. Does the proof still work?
In our proof of `SumOfEven` we explicitely used the definition of `_+_`, Our proof `SumOfEven` relied on
which means that if we wanted to use our proof on someone else's the explicit definition of `_+_`,
definition of addition, things might break. which means if we wanted to use our proof on
someone else's definition of addition,
it might not work anymore.
> But `_+_` and `_+'_` compute the same values. > But `_+_` and `_+'_` compute the same values.
> Are `_+_` and `_+'_` 'the same'? What is 'the same'? > Are `_+_` and `_+'_` 'the same'? What is 'the same'?

View File

@ -1,7 +1,7 @@
Trinitarianism Trinitarianism
============== ==============
By the end of this arc we will have 'a place to do maths'. By the end of this arc we will (almost) have 'a place to do maths'.
The 'types' that will populated this 'place' The 'types' that will populated this 'place'
will have three interpretations: will have three interpretations:
- Proof theoretically, with types as propositions - Proof theoretically, with types as propositions
@ -16,12 +16,14 @@ will have three interpretations:
## Terms and Types ## Terms and Types
Here are some things that we could like to have in a 'place to do maths' Here are some things that we could like to have in a 'place to do maths'
- objects to reason about (like ) - objects to reason about (E.g. ``)
- recipes for making things inside objects (like + 1) - recipes for making things inside objects
- propositions to reason with (with the data of proofs) (like _ = 0) (E.g. `n + m` for `n` and `m` in naturals.)
- propositions to reason with (E.g. `n = 0` for `n` in naturals.)
In proof theory, types are propositions and terms of a type are their proofs. In proof theory, types are propositions and terms of a type are their proofs.
In type theory, types are programs and terms are algorithms. In type theory, types are programs / constructions and
terms are algorithms / recipes.
In category theory, types are objects and terms are generalised elements. In category theory, types are objects and terms are generalised elements.
## Non-dependent Types ## Non-dependent Types
@ -34,10 +36,14 @@ In category theory, types are objects and terms are generalised elements.
## Dependent Types ## Dependent Types
- predicate / type family / over category - predicate / type family / bundle
- substitution / substitution / pullback - substitution / substitution / pullback (of bundles)
- existence / Σ type / left adjoint to pullback - existence / Σ type / total space of bundles
- for all / Π type / right adjoint to pullback - for all / Π type / space of sections of bundles
## Something doesn't feel the Same
> Question: how do we talk about equality? There will be one thing missing from this 'place to do maths'
and that is a notion of _equality_.
This is where HoTT deviates from its predecessors,
and is the theme of the next arc.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.