@@ -37,13 +37,62 @@ private variable
37
37
38
38
# Assemblies over a PCA
39
39
40
+ When working over a [[ partial combinatory algebra]] $\bA$, it's often
41
+ the case that we're interested in programs $\tt{p} : \bA$ as concrete
42
+ * implementations* of some mathematical datum $x : X$. For example, we
43
+ can implement the successor function on natural numbers to be
44
+ $$
45
+ \tt{suc} = \langle n \rangle \langle f \rangle \langle x \rangle\ f(nfx)
46
+ $$,
47
+ representing a numeral $n : \bN$ as a *Church numeral*, taking the
48
+ defining property of $\operatorname{suc} n$ to be that if we have some
49
+ iterable process $f : A \to A$ starting at $x : A$, then the
50
+ $(\operatorname{suc} n)$-th iteration is $f$ applied to the $n$th
51
+ iteration; But we could just as well implement
52
+ $$
53
+ \tt{suc} = \langle n \rangle\ \tt{pair}(\tt{false}, n)
54
+ $$
55
+ representing a numeral $n : \bN$ as a *Curry numeral*, a pair containing
56
+ the information of whether the number is zero and its predecessor (if
57
+ any). These implementations are extensionally identical, in that they
58
+ both denote the same actual natural number, but for a concrete pca $\bA$,
59
+ they might genuinely be different --- we could imagine measuring the
60
+ time complexity of the predecessor function, which is $O(1)$ for Curry
61
+ numbers and $O(n)$ for Church numbers. Therefore, if we are to
62
+ investigate the computational content of constructive mathematics, we
63
+ need a way to track the connection between the mathematical elements $x
64
+ : X$ and the programs $\tt{p} : \bA$ which denote them.
65
+
66
+ :::{.definition #assembly}
67
+ An **assembly** over a pca $\bA$ is a [[set]] $X$ equipped with a
68
+ [[propositional|proposition]] relation $\tt{p} \Vdash x$ between
69
+ programs $\tt{p} : \bA$ and elements $x : X$; when this holds, we say
70
+ $\tt{p}$ **realises** $x$. Moreover, for every $x : X$, we require that
71
+ there be at least one $\tt{p}$ which realises it.
72
+ :::
73
+
74
+ A prototypical example is the assembly of booleans, `𝟚`{.Agda}, defined
75
+ [below](#the-assembly-of-booleans). Its set of elements is
76
+ `Bool`{.Agda}, and we fix realisers
77
+ $$
78
+ \begin{align* }
79
+ \left(\langle x \rangle \langle y \rangle\ x\right) \Vdash&\ \rm{true}\\
80
+ \left(\langle x \rangle \langle y \rangle\ y\right) \Vdash&\ \rm{false;}
81
+ \end{align* }
82
+ $$
83
+ see [[pairs in a PCA]] for the details of the construction. This is not
84
+ the only possible choice: we could, for example, invert the realisers,
85
+ and say that the value `true`{.Agda} is implemented by the *program*
86
+ $\tt{false}$ (and vice-versa). This results in a genuinely different
87
+ assembly, though with the same denotational data.
88
+
40
89
```agda
41
90
record Assembly (𝔸 : PCA ℓA) ℓ : Type (lsuc ℓ ⊔ ℓA) where
42
91
no-eta-equality
43
92
field
44
93
Ob : Type ℓ
45
94
has-is-set : is-set Ob
46
- realisers : Ob → ℙ⁺ ⌞ 𝔸 ⌟
95
+ realisers : Ob → ℙ⁺ 𝔸
47
96
realised : ∀ x → ∃[ a ∈ ↯ ⌞ 𝔸 ⌟ ] (a ∈ realisers x)
48
97
```
49
98
@@ -80,6 +129,15 @@ subst⊩ X {x} hx p = subst (_∈ X .realisers x) (sym p) hx
80
129
```
81
130
-->
82
131
132
+ To understand the difference --- and similarity --- between the ordinary
133
+ assembly of booleans and the swapped booleans, we define a morphism of
134
+ assemblies $(X, \Vdash_X) \to (Y, \Vdash_Y)$ to be a function $f : X \to
135
+ Y$ satisfying the [[*property*|propositional truncation]] that there
136
+ exists a program $\tt{f} : \bA$ which sends realisers of $x : X$ to
137
+ realisers of $f(x) : Y$. Note the force of the propositional truncation
138
+ in this definition: maps of assemblies are identical *when they have the
139
+ same underlying function*, regardless of what program implements them.
140
+
83
141
```agda
84
142
record Assembly-hom {𝔸 : PCA ℓA} (X : Assembly 𝔸 ℓ) (Y : Assembly 𝔸 ℓ') : Type (ℓA ⊔ ℓ ⊔ ℓ') where
85
143
open Logic 𝔸 using ([_]_⊢_)
@@ -136,6 +194,10 @@ module _ (𝔸 : PCA ℓA) where
136
194
```
137
195
-->
138
196
197
+ This consideration is necessary for assemblies and assembly morphisms to
198
+ be a category: in an arbitrary PCA $\bA$, composition of programs need
199
+ not be unital or associative.
200
+
139
201
```agda
140
202
Assemblies : ∀ ℓ → Precategory (lsuc ℓ ⊔ ℓA) (ℓA ⊔ ℓ)
141
203
Assemblies ℓ .Ob = Assembly 𝔸 ℓ
@@ -192,7 +254,7 @@ module _ (𝔸 : PCA ℓA) where
192
254
Forget⊣∇ .zag = ext λ _ → refl
193
255
```
194
256
195
- ## The assembly of booleans
257
+ ## The assembly of booleans
196
258
197
259
```agda
198
260
𝟚 : Assembly 𝔸 lzero
0 commit comments