Updated Trinitarianism/Quest2
This commit is contained in:
parent
d60ad6a227
commit
e49f5a5717
@ -45,15 +45,15 @@ 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 currently under development.
|
||||||
Currently you can try the _quests_ in the `Trinitarianism` folder.
|
As of now you can try the _quests_ in the `Trinitarianism` folder.
|
||||||
Each quest consists of three files, for example :
|
Each quest consists of three files, for example :
|
||||||
- `Trinitarianism/Quest0.md` is the guide for the quest
|
- `Trinitarianism/Quest0.md` is the guide for the quest.
|
||||||
In there, you will find details of the tasks
|
In there, you will find details of the tasks
|
||||||
you must finish in order to complete the quest.
|
you must finish in order to complete the quest.
|
||||||
For now, it is recommended that
|
For now, it is recommended that
|
||||||
you view these online within github.
|
you view these online within github.
|
||||||
- `Trinitarianism/Quest0.agda` is the actual file in which
|
- `Trinitarianism/Quest0.agda` is the agda file in which
|
||||||
you do the quest.
|
you do the quest.
|
||||||
- `Trinitarianism/Quest0Solutions.agda` contains
|
- `Trinitarianism/Quest0Solutions.agda` contains
|
||||||
solutions to the tasks in the quest.
|
solutions to the tasks in the quest.
|
||||||
|
BIN
Trinitarianism/.DS_Store
vendored
BIN
Trinitarianism/.DS_Store
vendored
Binary file not shown.
@ -3,3 +3,4 @@ module Trinitarianism.Preambles.P2 where
|
|||||||
open import Cubical.Core.Everything public
|
open import Cubical.Core.Everything public
|
||||||
open import Cubical.Data.Nat public hiding (_+_ ; isEven)
|
open import Cubical.Data.Nat public hiding (_+_ ; isEven)
|
||||||
open import Trinitarianism.Quest1Solutions public
|
open import Trinitarianism.Quest1Solutions public
|
||||||
|
open import Cubical.Data.Empty public using (⊥)
|
||||||
|
@ -44,7 +44,8 @@ TrueToTrue = {!!}
|
|||||||
and now you can fill the hole `{ }`
|
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)
|
||||||
- enter `C-c C-r` and agda will try to help you (`r` stands 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 → { }`. This is agda's notation for `x ↦ { }`
|
||||||
|
and is called `λ` abstraction, `λ` for 'let'.
|
||||||
- navigate to the new hole
|
- navigate to the new hole
|
||||||
- enter `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 ('agda information' window) should look like
|
- the Goal area ('agda information' window) should look like
|
||||||
|
@ -11,5 +11,8 @@ Remove this comment block and formulate
|
|||||||
'there exists an even natural' here.
|
'there exists an even natural' here.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
_×_ : Type → Type → Type
|
||||||
|
A × C = Σ A (λ a → C)
|
||||||
|
|
||||||
div2 : Σ ℕ isEven → ℕ
|
div2 : Σ ℕ isEven → ℕ
|
||||||
div2 x = {!!}
|
div2 x = {!!}
|
||||||
|
@ -103,9 +103,13 @@ 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 construction
|
- the construction
|
||||||
@ -139,8 +143,27 @@ Name = ?
|
|||||||
|
|
||||||
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 the type `Σ A B` whose terms are pairs `a , b`
|
we can write the sigma type `Σ A B` whose terms are pairs `a , b`
|
||||||
where `a : A` and `b : B a`.
|
where `a : A` and `b : B a`.
|
||||||
|
In the special case when `B` is not dependent on `a : A`,
|
||||||
|
i.e. it looks like `λ a → C` for some `C : Type` then
|
||||||
|
`Σ A B` is just
|
||||||
|
- the proposition '`A` and `C`'
|
||||||
|
since giving a proof of this is the same as giving a proof
|
||||||
|
of `A` and a proof of `C`
|
||||||
|
- a recipe `a : A` together with a recipe `c : C`
|
||||||
|
- `B` is now a _trivial bundle_ since the fibers `B a` are
|
||||||
|
constant with respect to `a : A`.
|
||||||
|
In other words it is just a _product_ `Σ A B ≅ A × C`.
|
||||||
|
For this reason,
|
||||||
|
some refer to the sigma type as the _dependent product_,
|
||||||
|
but we will avoid this terminology.
|
||||||
|
```agda
|
||||||
|
_×_ : Type → Type → Type
|
||||||
|
A × C = Σ A (λ a → C)
|
||||||
|
```
|
||||||
|
Agda supports the notation `_×_` (without spaces)
|
||||||
|
which means from now on you can write `A × C` (with spaces).
|
||||||
|
|
||||||
There are two ways of using a term in a sigma type.
|
There are two ways of using a term in a sigma type.
|
||||||
We can extract the first part using `fst` or the second part using `snd`.
|
We can extract the first part using `fst` or the second part using `snd`.
|
||||||
|
@ -7,10 +7,12 @@ isEven zero = ⊤
|
|||||||
isEven (suc zero) = ⊥
|
isEven (suc zero) = ⊥
|
||||||
isEven (suc (suc n)) = isEven n
|
isEven (suc (suc n)) = isEven n
|
||||||
|
|
||||||
|
|
||||||
existsEven : Σ ℕ isEven
|
existsEven : Σ ℕ isEven
|
||||||
existsEven = 4 , tt
|
existsEven = 4 , tt
|
||||||
|
|
||||||
|
_×_ : Type → Type → Type
|
||||||
|
A × C = Σ A (λ a → C)
|
||||||
|
|
||||||
div2 : Σ ℕ isEven → ℕ
|
div2 : Σ ℕ isEven → ℕ
|
||||||
div2 (0 , tt) = 0
|
div2 (0 , tt) = 0
|
||||||
div2 (suc (suc n) , hn) = suc (div2 (n , hn))
|
div2 (suc (suc n) , hn) = suc (div2 (n , hn))
|
||||||
|
@ -9,9 +9,6 @@ so it should have type `ℕ → ℕ → ℕ`.
|
|||||||
_+_ : ℕ → ℕ → ℕ
|
_+_ : ℕ → ℕ → ℕ
|
||||||
n + m = ?
|
n + m = ?
|
||||||
```
|
```
|
||||||
Agda supports the notation `_+_` (without spaces)
|
|
||||||
which means from now on you can write `0 + 1`
|
|
||||||
and so on (with spaces).
|
|
||||||
Try coming up with a sensible definition.
|
Try coming up with a sensible definition.
|
||||||
It may not look 'the same' as ours.
|
It may not look 'the same' as ours.
|
||||||
<p>
|
<p>
|
||||||
@ -68,3 +65,26 @@ someone else's definition of addition,
|
|||||||
it might not work anymore.
|
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'?
|
||||||
|
|
||||||
|
As the final task of the Quest,
|
||||||
|
try to express and prove in agda the statement
|
||||||
|
> For any natural number it is even or is is not even.
|
||||||
|
We will make a summary of what is needed:
|
||||||
|
- a definition of the type `A ⊕ B` (input `\oplus`),
|
||||||
|
which has three interpretations
|
||||||
|
- the proposition '`A` or `B`'
|
||||||
|
- the construction with two ways of making recipes
|
||||||
|
`left : A → A ⊕ B`
|
||||||
|
and `right : B → A ⊕ B`.
|
||||||
|
- the coproduct of two objects `A` and `B`.
|
||||||
|
The type needs to take in parameters `A : Type` and `B : Type`
|
||||||
|
```agda
|
||||||
|
data _⊕_ (A : Type) (B : Type) : Type where
|
||||||
|
???
|
||||||
|
```
|
||||||
|
- a definition of negation. One can motivate it by the following
|
||||||
|
- Define `A ↔ B : Type` for two types `A : Type` and `B : Type`.
|
||||||
|
- Show that for any `A : Type` we have `(A ↔ ⊥) ↔ (A → ⊥)`
|
||||||
|
- Define `¬ : Type → Type` to be `λ A → (A → ⊥)`.
|
||||||
|
- a formulation and proof of the statement above
|
||||||
|
|
||||||
|
@ -21,3 +21,38 @@ Sum'OfEven x (zero , hy) = x .snd
|
|||||||
Sum'OfEven x (suc (suc y) , hy) = Sum'OfEven x (y , hy)
|
Sum'OfEven x (suc (suc y) , hy) = Sum'OfEven x (y , hy)
|
||||||
|
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
data _⊕_ (A : Type) (B : Type) : Type where
|
||||||
|
left : A → A ⊕ B
|
||||||
|
right : B → A ⊕ B
|
||||||
|
|
||||||
|
_↔_ : Type → Type → Type
|
||||||
|
_↔_ A B = (A → B) × (B → A)
|
||||||
|
|
||||||
|
¬Motivation : (A : Type) → ((A ↔ ⊥) ↔ (A → ⊥))
|
||||||
|
¬Motivation A =
|
||||||
|
-- forward direction
|
||||||
|
(
|
||||||
|
-- suppose we have a proof `hiff : A ↔ ⊥`
|
||||||
|
λ hiff →
|
||||||
|
-- give the forward map only
|
||||||
|
fst hiff
|
||||||
|
) ,
|
||||||
|
-- backward direction; assume a proof hto : A → ⊥
|
||||||
|
λ hto →
|
||||||
|
-- we need to show A → ⊥ which we have already
|
||||||
|
hto
|
||||||
|
,
|
||||||
|
-- we need to show ⊥ → A, which is the principle of explosion
|
||||||
|
λ ()
|
||||||
|
|
||||||
|
¬ : Type → Type
|
||||||
|
¬ A = A → ⊥
|
||||||
|
|
||||||
|
isEvenDecidable : (n : ℕ) → isEven n ⊕ ¬ (isEven n)
|
||||||
|
-- zero is even; go left
|
||||||
|
isEvenDecidable zero = left tt
|
||||||
|
-- one is not even; go right
|
||||||
|
isEvenDecidable (suc zero) = right (λ ())
|
||||||
|
-- inductive step
|
||||||
|
isEvenDecidable (suc (suc n)) = isEvenDecidable n
|
||||||
|
@ -41,9 +41,9 @@ In category theory, types are objects and terms are generalised elements.
|
|||||||
- existence / Σ type / total space of bundles
|
- existence / Σ type / total space of bundles
|
||||||
- for all / Π type / space of sections of bundles
|
- for all / Π type / space of sections of bundles
|
||||||
|
|
||||||
## Something doesn't feel the Same
|
## What is 'the Same'?
|
||||||
|
|
||||||
There will be one thing missing from this 'place to do maths'
|
There will be one thing missing from this 'place to do maths'
|
||||||
and that is a notion of _equality_.
|
and that is a notion of _equality_.
|
||||||
This is where HoTT deviates from its predecessors,
|
How HoTT treats equality is where it deviates from its predecessors.
|
||||||
and is the theme of the next arc.
|
This is the theme of the next arc.
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user