cur/nat.rkt
William J. Bowman 1c94591c27 Fixed various errors in expansion
* Expansion now proceeds correctly on all examples, although reduction
  does not
* Drastically reorganized how wrapper work.
* Added/remove TODOs
2015-01-28 19:56:50 -05:00

34 lines
682 B
Racket

#lang s-exp "cur-redex.rkt"
(require "sugar.rkt")
(module+ test
(require rackunit))
(data nat : Type
(z : nat)
(s : (-> nat nat)))
(define (add1 (n : nat)) (s n))
(module+ test
(check-equal? (add1 (s z)) (s (s z))))
(define (sub1 (n : nat))
(case n
[z z]
[s (lambda (x : nat) x)]))
(module+ test
(check-equal? (sub1 (s z)) z))
(define plus
(fix (plus : (forall* (n1 : nat) (n2 : nat) nat))
(lambda (n1 : nat)
(lambda (n2 : nat)
(case n1
[z n2]
[s (λ (x : nat) (plus x (s n2)))])))))
(module+ test
(check-equal? (plus z z) z)
(check-equal? (plus (s (s z)) (s (s z))) (s (s (s (s z))))))
(add1 (s z))
(sub1 (s z))