[FMFP] IMP intro, start of operational semantics

This commit is contained in:
2026-04-24 12:00:28 +02:00
parent 86152fc82e
commit bf5b0e1407
9 changed files with 264 additions and 3 deletions
@@ -0,0 +1,20 @@
\newpage
\subsection{Operational Semantics}
\subsubsection{Transition Systems}
\inlinedefinition[Transition System] is a tuple $(\Gamma, T, \rightarrow)$, where $\Gamma$ is a set of \bi{configurations},
$T$ is a set of terminal configurations, with $T \subseteq \Gamma$ and $\rightarrow$ is a transition relation, with $\rightarrow \; \subseteq \Gamma \times \Gamma$,
which describes how executions take place. Big-step transitions are of form $\langle s, \sigma \rangle \rightarrow \sigma'$,
e.g. $\langle \texttt{skip}, \sigma \rangle \rightarrow \sigma$
The transition relations are specified as rules of the form ($^*$ optional side-condition, $\varphi_i$ and $\psi$ transitions)
\[
\begin{prooftree}
\hypo{\varphi_1}
\hypo{\dots}
\hypo{\varphi_n}
\infer3[(Name)$^*$]{\psi}
\end{prooftree}
\]
or spelled out, ``If $\varpi_1, \ldots, \varphi_n$ are transitions (and the \textit{side-condition} is true), then $\psi$ is a transition''.
Herein, $\varphi_1, \ldots, \varphi_n$ are called \bi{premises} of the rule and $\psi$ is the \bi{conclusion}. A rule without premises is an \bi{axiom rule}.
@@ -0,0 +1,54 @@
\subsubsection{Big-Step Semantics of IMP}
\[
\begin{prooftree}
\infer0[\textsc{Skip}$_{NS}$]{\langle \texttt{skip}, \sigma \rangle \rightarrow \sigma}
\end{prooftree}
\qquad
\begin{prooftree}
\infer0[\textsc{Ass}$_{NS}$]{\langle x := e, \sigma \rangle \rightarrow \sigma[x \mapsto \cA\llbracket e \rrbracket \sigma ]}
\end{prooftree}
\]
\shade{gray}{Sequential Composition} $s;s'$ ($s$ is executed in state $\sigma$, then $s'$ in resulting $\sigma'$, resulting in $\sigma''$)
\[
\begin{prooftree}
\hypo{\langle s, \sigma \rangle \rightarrow \sigma'}
\hypo{\langle s', \sigma' \rangle \rightarrow \sigma''}
\infer2[\textsc{Seq}$_{NS}$]{\langle s;s', \sigma \rangle \rightarrow \sigma''}
\end{prooftree}
\]
\shade{gray}{Conditional Statements} $\texttt{if}\; b \; \texttt{then} \; s \; \texttt{else} \; s' \; \texttt{end}$ (If $b$ holds, execute $s$, otherwise execute $s'$)
\[
\begin{prooftree}
\hypo{\langle s, \sigma \rangle \rightarrow \sigma'}
\infer1[\textsc{IfT}$_{NS}$]{\langle \texttt{if}\; b \; \texttt{then} \; s \; \texttt{else} \; s' \; \texttt{end}, \sigma \rangle \rightarrow \sigma'}
\end{prooftree}
\qquad
\begin{prooftree}
\hypo{\langle s, \sigma \rangle \rightarrow \sigma'}
\infer1[\textsc{IfF}$_{NS}$]{\langle \texttt{if}\; b \; \texttt{then} \; s \; \texttt{else} \; s' \; \texttt{end}, \sigma \rangle \rightarrow \sigma'}
\end{prooftree}
\]
Where the first rule applies if $\cB\llbracket b \rrbracket \sigma = \texttt{tt}$
\shade{gray}{Loop statements} $\texttt{while} \; b \; \texttt{do} \; s \; \texttt{end}$ (If $b$ holds, execute $s$ once, whole statement executed in resulting state $\sigma$)
\[
\begin{prooftree}
\hypo{\langle s, \sigma \rangle \rightarrow \sigma'}
\hypo{\langle \texttt{while} \; b \; \texttt{do} \; s \; \texttt{end}, \sigma' \rangle \rightarrow \sigma''}
\infer2[\textsc{WhT}$_{NS}$]{\langle \texttt{while} \; b \; \texttt{do} \; s \; \texttt{end}, \sigma \rangle \rightarrow \sigma''}
\end{prooftree}
\qquad
\text{if }
\cB\llbracket b \rrbracket \sigma = \texttt{tt}
\]
If $b$ does not hold, the while statement does \textit{not} modify the state
\[
\begin{prooftree}
\infer0[\textsc{WhF}$_{NS}$]{\langle \texttt{while} \; b \; \texttt{do} \; s \; \texttt{end}, \sigma \rangle \rightarrow \sigma}
\end{prooftree}
\qquad
\text{if }
\cB\llbracket b \rrbracket \sigma = \texttt{ff}
\]