-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainers.agda
More file actions
192 lines (132 loc) · 4.16 KB
/
Copy pathContainers.agda
File metadata and controls
192 lines (132 loc) · 4.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
{-
Please do not move this file. Changes should only be made if
necessary.
This file contains pointers to the code examples and main results from
the paper:
Formalising inductive and coinductive containers
-}
-- The "--safe" flag ensures that there are no postulates or
-- unfinished goals
{-# OPTIONS --safe --cubical --guardedness #-}
module Cubical.Papers.Containers where
-------------------------------------
-------------- IMPORTS --------------
-------------------------------------
-- 2
open import Cubical.Data.Unit as UnitType
open import Cubical.Data.Empty as EmptyType
open import Cubical.Data.Nat as Nat hiding (isEven)
open import Cubical.Codata.Stream as StreamType
open StreamType.Equality≅Bisimulation renaming (bisim to id)
open import Cubical.Foundations.Prelude as Foundations
open import Cubical.Data.W.W as W-Type
open import Cubical.Codata.M.MRecord as M-Type
open import Cubical.Data.Maybe as Maybe
open import Cubical.Data.Containers.WildCat as Container
-- 3
open import Cubical.Data.Containers.Algebras as ContAlg
open import Cubical.Codata.Containers.Coalgebras as ContCoAlg
-- 4
open import Cubical.Data.Containers.InductiveContainers as IndCon
open import Cubical.Codata.Containers.CoinductiveContainers as CoIndCon
-------------------------------------
------ SUMMARY OF FORMALISATION -----
-------------------------------------
---- 2.1 Agda and Cubical Agda ----
-- Unit type:
open UnitType renaming (Unit to ⊤)
-- Empty type:
open EmptyType using (⊥)
-- Natural numbers:
open Nat using (ℕ)
-- Σ-type:
-- omitted (we use a primitive version)
-- Streams
open StreamType using (Stream)
-- isEven
isEven : ℕ → Type
isEven zero = ⊤
isEven (suc zero) = ⊥
isEven (suc (suc n)) = isEven n
-- from
open Stream renaming (head to hd ; tail to tl)
from : ℕ → Stream ℕ
hd (from n) = n
tl (from n) = from (suc n)
-- The interval type
open Foundations using (I ; ~_ ; i0 ; i1)
-- The path type
open Foundations using (_≡_)
-- refl and ⁻¹
open Foundations using (refl ; sym)
-- Dependent path type
open Foundations using (PathP)
-- transport
open Foundations using (transport)
-- funExt
open Foundations using (funExt)
-- Bisimulation and identity type of streams
open StreamType.Equality≅Bisimulation
using (_≈_) renaming (bisim to id)
---- 2.2 The W-type and the M-type ----
-- The W-type
open W-Type using (W)
-- The M-type
open M-Type using (M)
-- ℕ∞
record N∞ : Type where
coinductive
field
pred∞ : Maybe N∞
-- M-R
open M-Type using (M-R)
-- MCoind
open M-Type using (MCoind)
---- 2.3 Containers ----
-- Definition 3
open Container using (Container)
-- Definition 4
open Container using (IContainer)
-- Definition 6
open ⟦_⟧F using (⟦_⟧)
-- Definition 9
open Container using (Alg⟦_⟧)
-- Definition 10
open Container using (isInitialAlg⟦_⟧)
-- Dual definitions (coalgebras)
open Container using (CoAlg⟦_⟧ ; isTerminalCoAlg⟦_⟧)
------ 3 Setting up ------
---- 3.1 Calculation of the initial algebra and terminal coalgebra ----
-- Fixed points
open ContAlg.Algs using (FixedPoint)
-- WAlg
open ContAlg.Algs using (WAlg)
-- MAlg
open ContCoAlg.Coalgs using (MAlg)
-- Pos
open ContAlg.Algs using (Pos)
-- PosM
module _ (S : Type) (Q : S → Type) where
open M
data PosM : M S Q → Type where
here : {m : M S Q} → Q (shape m) → PosM m
below : {m : M S Q} (p : Q (shape m)) → PosM ((pos m) p) → PosM m
---- 3.2 Generalised induction principle for Pos ----
-- Definition 11
-- Omitted (used implicitly)
-- Lemma 12
open ContAlg.Algs using (PosIndFun)
------ 4 Fixed points ------
-- Theorem 13
open IndCon using (into ; α̅ ; α̅Comm ; α̅Unique)
-- Theorem 14
open CoIndCon using (out; β̅Unique)
open CoIndCon.β1.β2 using (β̅ ; β̅Comm)
-- Lemma 15
open CoIndCon.β1.β2 using (β̅)
-- Lemma 16 (fstEq and sndEq)
open CoIndCon using (fstEq ; sndEq)
-- Lemma 17
open CoIndCon using (preFstEqId)
-- Lemma 18
-- Omitted (never used explicitly)