Skip to content

Commit 66e336e

Browse files
committed
Update workshop files
1 parent 1a6c071 commit 66e336e

File tree

2 files changed

+35
-20
lines changed

2 files changed

+35
-20
lines changed

constructive-programming/common.org

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
#+AUTHOR: Rodolfo Hansen
21
#+KEYWORDS: ADT, Software, Types, CorrectByConstruction
2+
#+LaTeX_HEADER: \usepackage{minted}
3+
#+LaTeX_HEADER: \usepackage{indentfirst}
4+
#+LaTeX_HEADER: \usepackage[a4paper, margin=2cm]{geometry}
35
#+OPTIONS: toc:2
46
#+OPTIONS: reveal_width:1600 reveal_height:1200
7+
#+REVEAL_ROOT: https://cdn.jsdelivr.net/npm/reveal.js
58
#+REVEAL_HLEVEL: 2
69
#+REVEAL_TRANS: slide
710
#+REVEAL_THEME: moon

constructive-programming/workshop-one.org

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -108,27 +108,39 @@
108108

109109
* Simple Logic Excercises (but not predicate logic) (prove)
110110
#+BEGIN_SRC scala
111+
112+
type And[A, B] = (A, B)
113+
type Or[A, B] = Either[A, B]
111114
type /\[A, B] = (A, B)
112115
type \/[A, B] = Either[A, B]
113116
// type =>[A, B] = A => B
114-
type <==>[A, B] = A => B /\ B => A
117+
type <==>[A, B] = (A => B) /\ (B => A)
115118
// What could go wrong here?!
116119
type Not[A] = A => Nothing
117120

118121
// Corrolaries / Universal Constructions
119-
def and_1[A, B](n: A /\ B): A = ???
120-
def and_2[A, B](n: A /\ B): B = ???
121-
def or_1[A, B](a: A): A \/ B = ???
122-
def or_2[A, B](b: B): A \/ B = ???
123-
def mp[A, B](a: A, f: A => B): B = ???
124-
def exp[A, B, C](a: A, g: (A /\ B) => C): B => C = ???
125-
def bicond_1[A, B](f: A <==> B): A => B = ???
126-
def bicond_2[A, B](f: A <==> B): B => A = ???
127-
128-
def ex_falso_1[A](n: Nothing): A = ???
129-
def ex_falso_2[A](n: Nothing): Not[A] = ???
130-
def dist_law[A, B, C](h: A \/ (B \/ C)) = (A \/ B) \/ (A \/ C) = ???
131-
def shunting[A, B, C](n: A /\ B => C) = A => B => C = ???
122+
def and_1[A, B](n: A /\ B): A = n._1
123+
def and_2[A, B](n: A /\ B): B = n._2
124+
def or_1[A, B](a: A): A \/ B = Left(a)
125+
def or_2[A, B](b: B): A \/ B = Right(b)
126+
def mp[A, B](a: A, f: A => B): B = f(a)
127+
def exp[A, B, C](a: A, g: (A /\ B) => C): B => C = b => g(a, b)
128+
def bicond_1[A, B](f: A <==> B): A => B = f._1
129+
def bicond_2[A, B](f: A <==> B): B => A = f._2
130+
131+
def dist_law[A, B, C](h: A \/ (B /\ C)): (A /\ B) \/ (A /\ C) = ???
132+
133+
def dist_law_2[A, B, C](h: A Or (B And C)): (A Or B) And (A Or C) =
134+
h
135+
136+
def dist_law_1[A, B, C](h: A And (B Or C)): (A Or B) And (A Or C) =
137+
((), ())
138+
139+
def shunting[A, B, C](n: A /\ B => C): A => B => C = ???
140+
141+
def ex_falso_1[A](n: Nothing): A = n
142+
def ex_falso_2[A](n: Nothing): Not[A] = (a) => n
143+
132144
#+END_SRC
133145

134146
* Quantifying (ways of leaving the zeroth order logic)
@@ -195,22 +207,22 @@
195207
2. Come up with some functions that interact with this domain.
196208
2.1. Let's calculate the possible number of pure total functions that exist for those function types.
197209
2.2. Let's think of some propositions.
198-
210+
199211
** Possible suggestion: ATM (Automatic Teller Machine)
200212

201213
1. Person's Account Balance.
202214
1. Person's Name, Email and Details.
203215
1. Transactions between people.
204216
1. New type of account: Legal Business.
205217
1. Add minimum transaction ammount and different fee for person and business.
206-
207-
218+
219+
208220

209221
* Extras
210222
** Optics
211223
*** Did we write any optics?
212-
1. Let's write a library, for what we have written already. This type of code is called Optics.
213-
224+
1. Let's write a library, for what we have written already. This type of code is called Optics.
225+
214226
** Exponent laws, Logic and Cats
215227
[[https://ncatlab.org/nlab/show/relation+between+type+theory+and+category+theory][https://ncatlab.org/nlab/show/relation+between+type+theory+and+category+theory]]
216228
[[https://www.infoq.com/presentations/category-theory-propositions-principle]]

0 commit comments

Comments
 (0)