-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathF1.agda
166 lines (130 loc) · 6.09 KB
/
F1.agda
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
{-# OPTIONS --without-K #-}
module F1 where
open import Data.Unit
open import Data.Sum hiding (map)
open import Data.Product hiding (map)
open import Data.List
open import Data.Nat
open import Data.Bool
{--
infixr 90 _⊗_
infixr 80 _⊕_
infixr 60 _∘_
infix 30 _⟷_
--}
---------------------------------------------------------------------------
-- Paths
-- Path relation should be an equivalence
data Path (A : Set) : Set where
_↝_ : (a : A) → (b : A) → Path A
id↝ : {A : Set} → (a : A) → Path A
id↝ a = a ↝ a
ap : {A B : Set} → (f : A → B) → Path A → Path B
ap f (a ↝ a') = f a ↝ f a'
pathProd : {A B : Set} → Path A → Path B → Path (A × B)
pathProd (a ↝ a') (b ↝ b') = (a , b) ↝ (a' , b')
pathProdL : {A B : Set} → List (Path A) → List (Path B) → List (Path (A × B))
pathProdL pas pbs = concatMap (λ pa → map (pathProd pa) pbs) pas
-- pi types with exactly one level of reciprocals
data B0 : Set where
ONE : B0
PLUS0 : B0 → B0 → B0
TIMES0 : B0 → B0 → B0
data B1 : Set where
LIFT0 : B0 → B1
PLUS1 : B1 → B1 → B1
TIMES1 : B1 → B1 → B1
RECIP1 : B0 → B1
-- interpretation of B0 as discrete groupoids
record 0-type : Set₁ where
constructor G₀
field
∣_∣₀ : Set
open 0-type public
plus : 0-type → 0-type → 0-type
plus t₁ t₂ = G₀ (∣ t₁ ∣₀ ⊎ ∣ t₂ ∣₀)
times : 0-type → 0-type → 0-type
times t₁ t₂ = G₀ (∣ t₁ ∣₀ × ∣ t₂ ∣₀)
⟦_⟧₀ : B0 → 0-type
⟦ ONE ⟧₀ = G₀ ⊤
⟦ PLUS0 b₁ b₂ ⟧₀ = plus ⟦ b₁ ⟧₀ ⟦ b₂ ⟧₀
⟦ TIMES0 b₁ b₂ ⟧₀ = times ⟦ b₁ ⟧₀ ⟦ b₂ ⟧₀
elems0 : (b : B0) → List ∣ ⟦ b ⟧₀ ∣₀
elems0 ONE = [ tt ]
elems0 (PLUS0 b b') = map inj₁ (elems0 b) ++ map inj₂ (elems0 b')
elems0 (TIMES0 b b') =
concatMap (λ a → map (λ b → (a , b)) (elems0 b')) (elems0 b)
-- interpretation of B1 types as 2-types
record 2-type : Set₁ where
constructor G₂
field
∣_∣₁ : Set
1-paths : List (Path ∣_∣₁)
2-paths : List (Path (Path ∣_∣₁))
open 2-type public
_⊎↝_ : {A B : Set} → List (Path A) → List (Path B) → List (Path (A ⊎ B))
p₁ ⊎↝ p₂ = map (ap inj₁) p₁ ++ map (ap inj₂) p₂
⟦_⟧₁ : B1 → 2-type
⟦ LIFT0 b0 ⟧₁ = G₂ ∣ ⟦ b0 ⟧₀ ∣₀ (map id↝ (elems0 b0)) []
⟦ PLUS1 b₁ b₂ ⟧₁ with ⟦ b₁ ⟧₁ | ⟦ b₂ ⟧₁
... | G₂ 0p₁ 1p₁ 2p₁ | G₂ 0p₂ 1p₂ 2p₂ = G₂ (0p₁ ⊎ 0p₂) (1p₁ ⊎↝ 1p₂) []
⟦ TIMES1 b₁ b₂ ⟧₁ = G₂ {!!} {!!} []
⟦ RECIP1 b0 ⟧₁ = G₂ ⊤ (map (λ _ → tt ↝ tt) (elems0 b0)) []
test10 = ⟦ LIFT0 ONE ⟧₁
test11 = ⟦ LIFT0 (PLUS0 ONE ONE) ⟧₁
test12 = ⟦ RECIP1 (PLUS0 ONE ONE) ⟧₁
{--
-- isos
data _⟷_ : B → B → Set where
-- +
swap₊ : { b₁ b₂ : B } → PLUS b₁ b₂ ⟷ PLUS b₂ b₁
assocl₊ : { b₁ b₂ b₃ : B } → PLUS b₁ (PLUS b₂ b₃) ⟷ PLUS (PLUS b₁ b₂) b₃
assocr₊ : { b₁ b₂ b₃ : B } → PLUS (PLUS b₁ b₂) b₃ ⟷ PLUS b₁ (PLUS b₂ b₃)
-- *
unite⋆ : { b : B } → TIMES ONE b ⟷ b
uniti⋆ : { b : B } → b ⟷ TIMES ONE b
swap⋆ : { b₁ b₂ : B } → TIMES b₁ b₂ ⟷ TIMES b₂ b₁
assocl⋆ : { b₁ b₂ b₃ : B } → TIMES b₁ (TIMES b₂ b₃) ⟷ TIMES (TIMES b₁ b₂) b₃
assocr⋆ : { b₁ b₂ b₃ : B } → TIMES (TIMES b₁ b₂) b₃ ⟷ TIMES b₁ (TIMES b₂ b₃)
-- * distributes over +
dist : { b₁ b₂ b₃ : B } →
TIMES (PLUS b₁ b₂) b₃ ⟷ PLUS (TIMES b₁ b₃) (TIMES b₂ b₃)
factor : { b₁ b₂ b₃ : B } →
PLUS (TIMES b₁ b₃) (TIMES b₂ b₃) ⟷ TIMES (PLUS b₁ b₂) b₃
-- congruence
id⟷ : { b : B } → b ⟷ b
sym : { b₁ b₂ : B } → (b₁ ⟷ b₂) → (b₂ ⟷ b₁)
_∘_ : { b₁ b₂ b₃ : B } → (b₁ ⟷ b₂) → (b₂ ⟷ b₃) → (b₁ ⟷ b₃)
_⊕_ : { b₁ b₂ b₃ b₄ : B } →
(b₁ ⟷ b₃) → (b₂ ⟷ b₄) → (PLUS b₁ b₂ ⟷ PLUS b₃ b₄)
_⊗_ : { b₁ b₂ b₃ b₄ : B } →
(b₁ ⟷ b₃) → (b₂ ⟷ b₄) → (TIMES b₁ b₂ ⟷ TIMES b₃ b₄)
-- interpret isos as functors
record 0-functor (A B : 0-type) : Set where
constructor F₀
field
fobj : ∣ A ∣ → ∣ B ∣
fmor : {a b : ∣ A ∣} → (a ≡ b) → (fobj a ≡ fobj b)
fmor {a} {.a} (refl .a) = refl (fobj a)
open 0-functor public
swap⊎ : {A B : Set} → A ⊎ B → B ⊎ A
swap⊎ (inj₁ a) = inj₂ a
swap⊎ (inj₂ b) = inj₁ b
eval : {b₁ b₂ : B} → (b₁ ⟷ b₂) → 0-functor ⟦ b₁ ⟧ ⟦ b₂ ⟧
eval swap₊ = F₀ swap⊎
eval assocl₊ = ? -- : { b₁ b₂ b₃ : B } → PLUS b₁ (PLUS b₂ b₃) ⟷ PLUS (PLUS b₁ b₂) b₃
eval assocr₊ = ? -- : { b₁ b₂ b₃ : B } → PLUS (PLUS b₁ b₂) b₃ ⟷ PLUS b₁ (PLUS b₂ b₃)
eval unite⋆ = ? -- : { b : B } → TIMES ONE b ⟷ b
eval uniti⋆ = ? -- : { b : B } → b ⟷ TIMES ONE b
eval swap⋆ = ? -- : { b₁ b₂ : B } → TIMES b₁ b₂ ⟷ TIMES b₂ b₁
eval assocl⋆ = ? -- : { b₁ b₂ b₃ : B } → TIMES b₁ (TIMES b₂ b₃) ⟷ TIMES (TIMES b₁ b₂) b₃
eval assocr⋆ = ? -- : { b₁ b₂ b₃ : B } → TIMES (TIMES b₁ b₂) b₃ ⟷ TIMES b₁ (TIMES b₂ b₃)
eval dist = ? -- : { b₁ b₂ b₃ : B } → TIMES (PLUS b₁ b₂) b₃ ⟷ PLUS (TIMES b₁ b₃) (TIMES b₂ b₃)
eval factor = ? -- : { b₁ b₂ b₃ : B } → PLUS (TIMES b₁ b₃) (TIMES b₂ b₃) ⟷ TIMES (PLUS b₁ b₂) b₃
eval id⟷ = ? -- : { b : B } → b ⟷ b
eval (sym c) = ? -- : { b₁ b₂ : B } → (b₁ ⟷ b₂) → (b₂ ⟷ b₁)
eval (c₁ ∘ c₂) = ? -- : { b₁ b₂ b₃ : B } → (b₁ ⟷ b₂) → (b₂ ⟷ b₃) → (b₁ ⟷ b₃)
eval (c₁ ⊕ c₂) = ? -- : { b₁ b₂ b₃ b₄ : B } → (b₁ ⟷ b₃) → (b₂ ⟷ b₄) → (PLUS b₁ b₂ ⟷ PLUS b₃ b₄)
eval (c₁ ⊗ c₂) = ? -- : { b₁ b₂ b₃ b₄ : B } → (b₁ ⟷ b₃) → (b₂ ⟷ b₄) → (TIMES b₁ b₂ ⟷ TIMES b₃ b₄)
---------------------------------------------------------------------------
--}