summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChloe Brown <chloe.brown.00@outlook.com>2025-04-29 15:12:56 +0100
committerChloe Brown <chloe.brown.00@outlook.com>2025-04-29 15:12:56 +0100
commit10a046389c7a200b5b137faabab9eacf16b5393a (patch)
treeb94f2f10dfaa8c189318fecd44801452c8dd5a03
parent4effb07fd8c301eb1f98df7774da5900ffc21a31 (diff)
Update examples for end of phase 2.
-rw-r--r--sec/encoding.ltx34
1 files changed, 34 insertions, 0 deletions
diff --git a/sec/encoding.ltx b/sec/encoding.ltx
index d68ff72..4afc43f 100644
--- a/sec/encoding.ltx
+++ b/sec/encoding.ltx
@@ -149,6 +149,40 @@ index of the given child.
\end{itemize}
}
+After some beta reduction we recover the following definition for \systemtinline{balanced}:
+\begin{listing}[H]
+\begin{systemt}
+let balanced n f = primrec n with
+ Zero => (1, fun xs =>
+ match xs with
+ [] => Leaf f
+ | x :: xs => arb)
+| Suc (depth, heap) => (1 + max [depth, depth], fun xs =>
+ match xs with
+ [] => Branch (0, 1)
+ | x :: xs => match x with
+ 0 => heap xs
+ | 1 => heap xs)
+\end{systemt}
+\vspace{-\baselineskip}
+\end{listing}
+
+And here is the updated definition of \systemtinline{compose}:
+\begin{listing}[H]
+\begin{systemt}
+let compose (depth, heap) =
+ let go = primrec depth with
+ Zero => arb
+ | Suc ih => fun index =>
+ let x = map (heap index) (fun x => ih (snoc xs x)) in
+ match x with
+ Leaf f => f
+ | Branch (f, g) => fun x => f (g x)
+ in go []
+\end{systemt}
+\vspace{-\baselineskip}
+\end{listing}
+
\TODO{
\begin{itemize}
\item state that we encode lists using their eliminators