Created
May 7, 2014 03:41
-
-
Save danking/d2682500fd54bbe5e1e3 to your computer and use it in GitHub Desktop.
untyped lambda calculus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require redex) | |
(require redex/tut-subst) | |
(define-language L | |
(e (e e) | |
x | |
v) | |
(v (lambda (x) e)) | |
(c (v c) | |
(c e) | |
hole) | |
(x variable-not-otherwise-mentioned)) | |
(define red | |
(reduction-relation | |
L | |
#:domain e | |
(--> (in-hole c ((lambda (x) e) v)) | |
(in-hole c (subst x v e)) | |
"beta"))) | |
;; subst : [Listof LTerm] [Listof LTerm] LTerm -> LTerm | |
(define-metafunction L | |
subst : x v e -> e | |
[(subst x v e) | |
,(subst/proc x? (list (term x)) (list (term v)) (term e))]) | |
;; x? : LTerm -> Boolean | |
(define x? (redex-match L x)) | |
(traces red (term ((lambda (x) x) (lambda (y) y)))) | |
(traces red (term ((lambda (x) (lambda (y) (y (x x)))) (lambda (z) z)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment