Revert "Removed ticked syntax exercise."

This reverts commit 598747b8e9.
This commit is contained in:
Wen Kokke 2019-09-18 16:13:22 +01:00
parent dba3a4ae84
commit c0086ca017

View file

@ -209,6 +209,40 @@ definition may use `plusᶜ` as defined earlier (or may not
```
#### Exercise `primed` (stretch)
Some people find it annoying to write `` ` "x" `` instead of `x`.
We can make examples with lambda terms slightly easier to write
by adding the following definitions:
```
ƛ_⇒_ : Term → Term → Term
ƛ′ (` x) ⇒ N = ƛ x ⇒ N
ƛ′ _ ⇒ _ = ⊥-elim impossible
where postulate impossible : ⊥
case_[zero⇒_|suc_⇒_] : Term → Term → Term → Term → Term
case L [zero⇒ M |suc (` x) ⇒ N ] = case L [zero⇒ M |suc x ⇒ N ]
case _ [zero⇒ _ |suc _ ⇒ _ ] = ⊥-elim impossible
where postulate impossible : ⊥
μ_⇒_ : Term → Term → Term
μ′ (` x) ⇒ N = μ x ⇒ N
μ′ _ ⇒ _ = ⊥-elim impossible
where postulate impossible : ⊥
```
The definition of `plus` can now be written as follows:
```
plus : Term
plus = μ′ + ⇒ ƛ′ m ⇒ ƛ′ n ⇒
case m
[zero⇒ n
|suc m ⇒ `suc (+ · m · n) ]
where
+ = ` "+"
m = ` "m"
n = ` "n"
```
Write out the definition of multiplication in the same style.
### Formal vs informal