summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChloe Brown <chloe.brown.00@outlook.com>2025-05-06 17:09:52 +0100
committerChloe Brown <chloe.brown.00@outlook.com>2025-05-06 17:09:52 +0100
commit8444f560f56dc27d7d5280011bae95bdedb95802 (patch)
tree19f0d0f3eaf7d16da25bbd115cdfb8456aa85098
parent3f8ebf8871ba5d6dd0d639e22cc8264a696865b6 (diff)
Give the encoding of products.
-rw-r--r--sec/encoding.ltx23
1 files changed, 16 insertions, 7 deletions
diff --git a/sec/encoding.ltx b/sec/encoding.ltx
index 95d9be3..ff4bc5c 100644
--- a/sec/encoding.ltx
+++ b/sec/encoding.ltx
@@ -449,13 +449,22 @@ let compose' (depth, heap) =
\subsection{Phase 5: Encoding Products}%
\label{subsec:products}
-\TODO{
- \begin{itemize}
- \item state that we encode products as functions from naturals to unions
- \item explain that products are heterogenous vectors
- \item justify implementing products as homogenous functional vectors
- \end{itemize}
-}
+We will continue following the work of \textcite{oleg} to encode away
+products. A product \(\prod_i A_i\) is encoded as a function \(\nat \to
+\bigsqcup_i A_i\) from indices to values. This is similar to the
+encoding for lists, with only a couple of small variations. First, we
+statically know the length of a product, so we do not need to include
+it within its type. Secondly, a product can store values from
+different types whilst a list is homogenous, so we need to use the
+union to make it homogenous.
+
+We encode tupling \(\tuple{\rangeover{t_i}{i}}\) as the case split \(\lambda
+x. \casetm{x}{i}{\mathsf{inj}~i~t_i}{i}\). The projection \(t.i\) is
+encoded as the application \(\mathsf{prj}~(t~i)~i\).
+
+At this phase the encodings of our example functions,
+\systemtinline{balanced} and \systemtinline{compose'}, become too
+cluttered to be useful. \TODO{suggest an alternative}.
\subsection{Phase 6: Encoding Unions}%
\label{subsec:unions}