-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSugar.rkt
51 lines (40 loc) · 964 Bytes
/
Sugar.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#lang racket
(require "Extend.rkt")
(define-core-language λ
(e ::= v (e e) x)
(v ::= (λ x e))
(x ::= variable-not-otherwise-mentioned)
#:binding-forms
(λ x e #:refers-to x))
(define-context λ
(E ::= hole (E e) (v E)))
(define-reduction
λ
(--> ((λ x e) v)
(substitute e x v)
"β"))
(define-sugar Sg λ
(--> (Sg e_1)
(e_1 (λ x x))))
;(trace Sg (Sg (λ x x)))
(define-core-language Boolean
(e ::= v (e e) x (if e e e))
(v ::= (λ x e) true false)
(x ::= variable-not-otherwise-mentioned)
#:binding-forms
(λ x e #:refers-to x))
(define-context Boolean
(E ::= hole (E e) (v E) (if E e e)))
(define-reduction
Boolean
(--> ((λ x e) v)
(substitute e x v)
"β")
(--> (if true e_1 e_2)
e_1)
(--> (if false e_1 e_2)
e_2))
(define-sugar Bool-with-And Boolean
(--> (And e_1 e_2)
(if e_1 e_2 false)))
(trace-resugar Bool-with-And (And (And true false) false))