#lang racket (require redex "subst.rkt") ;; ------------------------------------------------------------------ ;; SYNTAX (define-language Lam (e x (λ (x ...) e) (e e ...)) (x variable-not-otherwise-mentioned)) (define-extended-language Lam-cbn Lam (v x (λ (x ...) e)) (E hole ;; call by name (E e ...))) ;; ------------------------------------------------------------------ ;; REDUCTION : Call by name (define ->n (reduction-relation Lam-cbn #:domain e (--> (in-hole E ((λ (x ..._c) e_body) e ..._c)) (in-hole E (subst-n (x e) ... e_body))))) ;; ------------------------------------------------------------------ ;; TESTS (module+ test (test-equal (apply-reduction-relation* ->n (term ((λ (x) w) z))) (list (term w))) (test-equal (apply-reduction-relation* ->n (term (((λ (x) (λ (y) x)) w) z))) (list (term w))) (define example (term (((λ (x) (λ (y) (x y))) (λ (z) y)) w))) (test-equal (apply-reduction-relation* ->n example) (list (term y))) ;(traces ->n example) (define omega (term ((λ (x) (x x)) (λ (x) (x x))))) ;(apply-reduction-relation* ->n omega) ;(traces ->n omega) ; which of the following diverge? (traces ->n (term ((λ (y) (λ (z) z)) ,omega))) (traces ->n (term ((λ (y) (λ (z) a)) ,omega))) (traces ->n (term ((λ (y) (λ (z) y)) ,omega))) )