diff options
author | Chloe Brown <chloe.brown.00@outlook.com> | 2025-05-02 16:00:17 +0100 |
---|---|---|
committer | Chloe Brown <chloe.brown.00@outlook.com> | 2025-05-02 16:04:51 +0100 |
commit | 931dae7cc9fe0e38794bb7de1daf149c2da373da (patch) | |
tree | 03a5243701bd4382bb676521b7194ab621141ab4 /sec/encoding.ltx | |
parent | 1a2f7ef166828651cfea7d2d4a15579c987a9cc9 (diff) |
Give the encoding of `cons`.
Diffstat (limited to 'sec/encoding.ltx')
-rw-r--r-- | sec/encoding.ltx | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sec/encoding.ltx b/sec/encoding.ltx index 14c6079..be049b8 100644 --- a/sec/encoding.ltx +++ b/sec/encoding.ltx @@ -255,10 +255,17 @@ indices, we can give an arbitrary indexing function. Recall that all System~T types are inhabited which allows us to construct this arbitrary value. +We encode \(\mathsf{cons}~t~u\), adding element \(t\) to the head of +the list \(u\), by +\[\tuple{\suc~u.0 , \lambda x.~\domatch{x}{\zero. t; \suc~x. {u.1}~x}}\] +The length of our new list is one larger that +the tail. To lookup a value, we first pattern match on the +index. Index zero represents the head, which we return +directly. Otherwise we lookup the index in the tail. + \TODO{ \begin{itemize} \item explain why a list is a pair of length and index function - \item give the encoding of cons \item give the encoding of snoc \item give the encoding of max \item give the encoding of head |