Lecture 5: Big-Step Operational Semantics

Operational Semantics

The goal of operational semantics is, given a programming language, to be able to describe how to use it to compute.

There are several approaches:

Structural Operational Semantics

Rules are specified in a syntax directed way

Multiple kinds:

Transition System

The operational semantics of a language is given by a transition system that is made up of:

For example, in the λ\lambda-Calculus states can just be λ\lambda-terms

In languages with references, states can be pairs of a program and a store. Where the store contains the values currently held in the memory

The transition relation can be defined as a proof system consisting of derivation rules in a natural deduction style.

We say: There is a transition from MM to NN if there is a derivation that MM and NN are related.

The Transition System of the λ\lambda-Calculus

In the λ\lambda-Calculus:

1st Rule:

λx.M    vλx.MVAL\overline{ \lambda x.M \implies_v \lambda x.M}^\texttt{VAL}

2nd Rule:
M    vλx.P      N    vQ      P[x\Q]    vVMN    vVAPP{\frac{M \implies_v \lambda x.P \;\;\; N \implies_v Q \;\;\; P[x \backslash Q] \implies_v V}{M N \implies_v V}}\texttt{APP}

Evaluation Strategies

The examples seen in slide 11 require evaluating the argument before doing a β\beta-reduction.

Here we say that these semantics employ a strategy known as call-by-value, strict or eager, where the arguments to functions are always evaluated whether or not they are used in the body of the function.

Often λ\lambda-terms have several redexes. An evaluation strategy fixes the order in which redexes must be reduced.

The semantics seen so far is called call-by-value big step operational semantics This is why we have used the vv notation on     v\implies_v

We will go on to see the call-by-name (lazy) evaluation strategy.

Call-by-Name big-step semantics of the untyped λ\lambda-Calculus

This also has 2 rules:

λx.M    nλx.MVAL\overline{ \lambda x.M \implies_n \lambda x.M}^\texttt{VAL}

M    nλx.P      P[x\N]    nVMN    nVAPP\frac{M \implies_n \lambda x.P \;\;\; P[x \backslash N] \implies_n V}{M N \implies_n V}\texttt{APP}

Properties

Values:

Deterministic

β\beta-equality

Implementation of an interpreter in Haskell