aboutsummaryrefslogtreecommitdiff
path: root/entries/pkoronkevich/tex
diff options
context:
space:
mode:
authorfunemy2022-10-25 07:14:52 +0000
committerfunemy2022-10-25 07:14:52 +0000
commit998ef837b43203319397f191036a97a5adc42220 (patch)
tree920558bd60d282c663fd2da1cd4144cac1849a1d /entries/pkoronkevich/tex
parentfdac6c60e115297a58f5b81da0c4b7f18ac758f2 (diff)
parentce7544a6db594f7d3dfad0d7dc65d01515e57ad6 (diff)
Merge branch 'main' of github.com:braxtonhall/fib
Diffstat (limited to 'entries/pkoronkevich/tex')
-rw-r--r--entries/pkoronkevich/tex/README.md1
-rw-r--r--entries/pkoronkevich/tex/fib.tex29
-rw-r--r--entries/pkoronkevich/tex/render.pdfbin0 -> 21807 bytes
-rw-r--r--entries/pkoronkevich/tex/render.pngbin0 -> 387387 bytes
4 files changed, 30 insertions, 0 deletions
diff --git a/entries/pkoronkevich/tex/README.md b/entries/pkoronkevich/tex/README.md
new file mode 100644
index 0000000..225773b
--- /dev/null
+++ b/entries/pkoronkevich/tex/README.md
@@ -0,0 +1 @@
+<img src="./render.png" alt="fib.tex preview"> \ No newline at end of file
diff --git a/entries/pkoronkevich/tex/fib.tex b/entries/pkoronkevich/tex/fib.tex
new file mode 100644
index 0000000..cef9138
--- /dev/null
+++ b/entries/pkoronkevich/tex/fib.tex
@@ -0,0 +1,29 @@
+\documentclass[11pt]{article}
+\usepackage[fleqn]{amsmath}
+
+\newcommand{\one}{\lambda f . \lambda x . f \ x}
+\newcommand{\two}{\lambda f . \lambda x . f \ (f \ x)}
+\newcommand{\tru}{\lambda x . \lambda y . x}
+\newcommand{\flse}{\lambda x . \lambda y . y}
+\newcommand{\isz}{\lambda n . n \ (\lambda c . \flse) \ \tru}
+\newcommand{\ife}{\lambda p . \lambda a . \lambda b . p \ a \ b}
+\newcommand{\suc}{\lambda n . \lambda f . \lambda x . f \ (n \ f \ x)}
+\newcommand{\plus}{\lambda m . \lambda n . m \ (\suc) \ n}
+\newcommand{\pred}{\lambda n . \lambda f . \lambda x . n \ (\lambda g . \lambda h . h \ (g \ f)) \ (\lambda u . x) \ (\lambda u . u)}
+\newcommand{\sub}{\lambda m . \lambda n . n \ (\pred) \ m}
+\newcommand{\lleq}{\lambda m . \lambda n . \\ \qquad \isz \ ((\sub) \\ \qquad \ m \ n)}
+\newcommand{\fix}{\lambda g . (\lambda x . g \ (x \ x)) \ (\lambda x . g \ (x \ x))}
+\newcommand{\appo}[2]{#1 \ #2}
+\newcommand{\appt}[3]{#1 \ #2 \ #3}
+
+\begin{document}
+\begin{gather*}
+ \fix \\ % recursive function application
+ \quad \lambda r . \lambda n . (\ife) \\ % of fib, which takes itself and n, if expression
+ \quad \ \appt{(\lleq)}{n}{\one} \\ % if n less than or equal to one
+ \quad \ (\one) \\ % if so, return 1
+ \quad \ (\plus) \\ % if not, add
+ \qquad \appo{r}{(\appo{(\pred)}{n})} \\ % the first recursive call, n - 1, to
+ \qquad \appo{r}{(\appt{(\sub)}{n}{\two})} % the second recursive call, n - 2
+\end{gather*}
+\end{document}
diff --git a/entries/pkoronkevich/tex/render.pdf b/entries/pkoronkevich/tex/render.pdf
new file mode 100644
index 0000000..8ee60c7
--- /dev/null
+++ b/entries/pkoronkevich/tex/render.pdf
Binary files differ
diff --git a/entries/pkoronkevich/tex/render.png b/entries/pkoronkevich/tex/render.png
new file mode 100644
index 0000000..a1896a2
--- /dev/null
+++ b/entries/pkoronkevich/tex/render.png
Binary files differ