Created
February 2, 2018 15:05
-
-
Save prepor/367ebe1abb104137ca55bce1cf73d3c6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| require "substitution.k" | |
| module LAMBDA | |
| imports SUBSTITUTION | |
| syntax Val ::= Id | |
| | "lambda" Id "." Exp [binder, latex(\lambda{#1}.{#2})] | |
| syntax Exp ::= Val | |
| | Exp Exp [strict, left] | |
| | "(" Exp ")" [bracket] | |
| syntax KVariable ::= Id | |
| syntax KResult ::= Val | |
| rule (lambda X:Id . E:Exp) V:Val => E[V / X] | |
| syntax Val ::= Int | Bool | |
| syntax Exp ::= Exp "*" Exp [strict, left] | |
| | Exp "/" Exp [strict] | |
| > Exp "+" Exp [strict, left] | |
| > Exp "<=" Exp [strict] | |
| rule I1 * I2 => I1 *Int I2 | |
| rule I1 / I2 => I1 /Int I2 requires I2 =/=Int 0 | |
| rule I1 + I2 => I1 +Int I2 | |
| rule I1 <= I2 => I1 <=Int I2 | |
| syntax Exp ::= "if" Exp "then" Exp "else" Exp [strict(1)] | |
| rule if true then E else _ => E | |
| rule if false then _ else E => E | |
| syntax Exp ::= "let" Id "=" Exp "in" Exp | |
| rule let X = E in E':Exp => (lambda X . E') E [macro] | |
| syntax Exp ::= "letrec" Id Id "=" Exp "in" Exp | |
| | "mu" Id "." Exp [binder, latex(\mu{#1}.{#2})] | |
| rule letrec F:Id X = E in E' => let F = mu F . lambda X . E in E' [macro] | |
| rule mu X . E => E[(mu X . E) / X] | |
| syntax Exp ::= "callcc" Exp [strict] | |
| syntax Val ::= cc(K) | |
| rule <k> (callcc V:Val => V cc(K)) ~> K </k> | |
| rule <k> cc(K) V ~> _ => V ~> K </k> | |
| endmodule |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment