Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
evaluation
[[ 1 ]] σ = 1
^ meaning functions
[[ v ]] σ = σ(v)
^ state, mapping ids to values
[[e1 + e2]] σ = [[e1]]σ + [[e2]]σ
[[x + 2 * 7]]{(x,4)} = [[x]]{(x,4)} + [[2 * 7]]σ
= 4 + [[2]]σ * [[7]]σ
= 4 + 2 * 7
= 18
eval_exp (BINARY(PLUS,e1,e2)) state =
(eval_exp e1 state) + (eval_exp e2 state)
[[e1 && e2]]σ = [[e1]]σ ^ [[e2]]σ
[[if e1 then e2 else e3]]σ = [[e2]]σ , if [[e1]]σ = true
= [[e3]]σ , otherwise
= if [[e1]]σ
then [[e2]]σ
else [[e3]]σ
[[e1 && e2]]σ = if [[e1]]σ
then [[e2]]σ
else false
[[e1 || e2]]σ = if [[e1]]σ
then true
else [[e2]]σ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.