(module lambda-gradual mzscheme
(require "siek-taha.ss"
"herman-tomb-flanagan.ss"
(all-except "front-end.ss" next)
(rename "front-end.ss" front-end:next next)
"text-ui.ss")
(define (next s x)
(front-end:next (semantics-reduction-relation s) x))
(define omega
'(let (D : (dynamic -> dynamic) = (lambda (x : (dynamic -> dynamic))
(x x)))
(D D)))
(define untyped-example
'((lambda (x) x)
((lambda (y) y)
(lambda (z) z))))
(define typed-example
'((lambda (x : int)
(if #t (+ x 1) (- x 1)))
42))
(define cormacs-example
'(let (Y = (lambda (f)
((lambda (x)
(f (lambda (y) ((x x) y))))
(lambda (x)
(f (lambda (y) ((x x) y)))))))
(let (fix : (((int -> int) -> (int -> int)) -> (int -> int)) = Y)
(let (count = (fix (lambda (c : (int -> int))
(lambda (n : int)
(if (= n 0)
0
(+ 1 (c (- n 1))))))))
(count 10)))))
(define even/odd
'(letrec ([even? : (int -> bool) = (lambda (n : int)
(if (= n 0) #t (odd? (- n 1))))]
[odd? : (int -> bool) = (lambda (n : int)
(if (= n 0) #f (odd? (- n 1))))])
(even? 0)))
(define (tail-recursion-example size)
`(letrec ([even? = (lambda (n : int)
(if (= n 0) #t (odd? (- n 1))))]
[odd? : (int -> bool) =
(lambda (n : int)
(if (= n 0) #f (even? (- n 1))))])
(even? ,size)))
(define (cast-growth-example size)
`(letrec ([even : (int -> ((dynamic -> dynamic) -> dynamic)) =
(lambda (n : int)
(lambda (f : (dynamic -> dynamic))
(if (= n 0)
(f #t)
((odd (- n 1)) f))))]
[odd : (int -> ((bool -> bool) -> bool)) =
(lambda (n : int)
(lambda (f : (bool -> bool))
(if (= n 0)
(f #f)
((even (- n 1)) f))))])
((even ,size) (lambda (b : bool) #t))))
(define (time-complexity-example size)
`(letrec ([id : (dynamic -> dynamic) =
(lambda (x : dynamic) x)]
[iter : ((int -> int) -> (int -> int)) =
(lambda (f : (int -> int))
(lambda (n : int)
(if (= n 0)
0
(f ((iter (id f)) (- n 1))))))])
((iter (lambda (n : int)
(+ n 1)))
,size)))
(provide (all-defined)
semantics?
st htf
type-check
count trace pretty))