Skip to content

Commit c019576

Browse files
committed
prose: start on assemblies
1 parent a2b0219 commit c019576

File tree

4 files changed

+67
-4
lines changed

4 files changed

+67
-4
lines changed

src/Cat/Instances/Assemblies.lagda.md

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,62 @@ private variable
3737

3838
# Assemblies over a PCA
3939

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+
4089
```agda
4190
record Assembly (𝔸 : PCA ℓA) ℓ : Type (lsuc ℓ ⊔ ℓA) where
4291
no-eta-equality
4392
field
4493
Ob : Type ℓ
4594
has-is-set : is-set Ob
46-
realisers : Ob → ℙ⁺ ⌞ 𝔸 ⌟
95+
realisers : Ob → ℙ⁺ 𝔸
4796
realised : ∀ x → ∃[ a ∈ ↯ ⌞ 𝔸 ⌟ ] (a ∈ realisers x)
4897
```
4998
@@ -80,6 +129,15 @@ subst⊩ X {x} hx p = subst (_∈ X .realisers x) (sym p) hx
80129
```
81130
-->
82131
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+
83141
```agda
84142
record Assembly-hom {𝔸 : PCA ℓA} (X : Assembly 𝔸 ℓ) (Y : Assembly 𝔸 ℓ') : Type (ℓA ⊔ ℓ ⊔ ℓ') where
85143
open Logic 𝔸 using ([_]_⊢_)
@@ -136,6 +194,10 @@ module _ (𝔸 : PCA ℓA) where
136194
```
137195
-->
138196
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+
139201
```agda
140202
Assemblies : ∀ ℓ → Precategory (lsuc ℓ ⊔ ℓA) (ℓA ⊔ ℓ)
141203
Assemblies ℓ .Ob = Assembly 𝔸 ℓ
@@ -192,7 +254,7 @@ module _ (𝔸 : PCA ℓA) where
192254
Forget⊣∇ .zag = ext λ _ → refl
193255
```
194256
195-
## The assembly of booleans
257+
## The assembly of booleans
196258
197259
```agda
198260
𝟚 : Assembly 𝔸 lzero

src/Realisability/Data/Pair.lagda.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ private variable
2424
```
2525
-->
2626

27-
# Pairs in a PCA
27+
# Pairs in a PCA {defines="pairs-in-a-pca"}
2828

2929
```agda
3030
`true : ↯⁺ 𝔸

src/Realisability/PCA.lagda.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ open import Data.Vec.Base
1414
module Realisability.PCA where
1515
```
1616

17-
# Partial combinatory algebras
17+
# Partial combinatory algebras {defines="partial-combinatory-algebra"}
1818

1919
<!--
2020
```agda

src/preamble.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
\renewcommand{\rm}[1]{\mathrm{#1}}
77
\newcommand{\bb}[1]{\mathbb{#1}}
88
\renewcommand{\bf}[1]{\mathbf{#1}}
9+
\renewcommand{\tt}[1]{\mathtt{#1}}
910

1011
% Define \cA..\cZ
1112
\definealphabet{c}{\mathcal}{A}{Z}

0 commit comments

Comments
 (0)