mirror of
https://github.com/janishutz/eth-summaries.git
synced 2026-07-28 03:39:08 +02:00
[FMFP] Mostly finish exercises section
This commit is contained in:
@@ -1 +1,9 @@
|
||||
\subsubsection{IMP}
|
||||
\subsubsection{IMP Proofs}
|
||||
\begin{examdetails}
|
||||
Typically, the exam contains some operational semantics tasks,
|
||||
rarely proofs of properties of IMP.
|
||||
\end{examdetails}
|
||||
The property proofs can be acheived either using a direct proof of the implication, or using an induction proof.
|
||||
The latter of which is more common and we typically define $P$ in such a way that we bind everything apart from variables, natural numbers and constant values
|
||||
using quantifiers, then prove $\forall n \in \N . P(n)$, if we have a free natural numbers.
|
||||
Before the definition of $P$ we typically state ``Let $<$variables, constants$>$ be arbitrary'', as with any induction proof.
|
||||
|
||||
@@ -1,5 +1,34 @@
|
||||
\subsubsection{Operational Semantics}
|
||||
\paragraph{Big Step Semantics}
|
||||
\paragraph{Big Step Semantics (Natural Semantics, NS)}
|
||||
Proving something using the big step semantics rules tends to be fairly easy if you understand how natural deduction and the like work.
|
||||
The concept is very similar, just with other rules. It is advisable to name each sub-statement in the main statement, to reduce the required amount writing.
|
||||
|
||||
Sometimes, Induction on (the shape of) Proof Trees may be required, for that, see Section~\ref{sec:induction-on-proof-trees}
|
||||
|
||||
Where it gets more interesting and challenging, is providing rules in the big step semantics.
|
||||
Here, it is important to think about the different cases that could be introduced by the statement.
|
||||
|
||||
For instance, for loops, there will (almost certainly) be two cases, one in which some boolean expression (denoted $\cB \llbracket e \rrbracket \sigma$) is \texttt{ff},
|
||||
the other in which it is \texttt{tt}.
|
||||
For these, you need to make sure to state the side condition (i.e. that the boolean expression is true or false, respectively).
|
||||
|
||||
In addition, think thoroughly about how to define the states of the rules. For instance, for a \texttt{time} statement, that counts the number of assignments,
|
||||
the state we map to would ideally be defined as $\sigma' [x \mapsto n]$, where $n$ is the number of assignments.
|
||||
|
||||
|
||||
\paragraph{Small Step Semantics}
|
||||
\paragraph{Small Step Semantics (Structural Operational Semantics, SOS)}
|
||||
Small Step semantics proofs tend to be a bit more challenging. Unlike Natural Semantics, here we can't create a single derivation tree, but one per step.
|
||||
This means, that we do one single step transition at a time, denoted $\rightarrow_1^1$, and justify each step with a proof tree and SO Semantics (SOS).
|
||||
Typically, only \textit{some} of the statements are asked to be proven in the exam, as proving all is time intensive due to the typically fairly
|
||||
large number of steps in the proofs.
|
||||
For the proof trees, they need to be complete for each transition that we prove, i.e. no hypothesis in any branches.
|
||||
|
||||
Defining rules here is similar in concept as with the Natural Semantics.
|
||||
We want to make sure, to also consider the effects it has on other rules, as with Natural Semantics.
|
||||
|
||||
The sole difference here is that we return \textit{both} the next statement to be evaluated \textit{and} the next state,
|
||||
unlike with Natural Semantics, where we only return the next state.
|
||||
|
||||
|
||||
\paragraph{Other proofs}
|
||||
Induction proofs for these two are also outlined in Section~\ref{sec:induction-on-proof-trees} and subsequent subsections.
|
||||
|
||||
@@ -1 +1,11 @@
|
||||
\subsubsection{Axiomatic Semantics}
|
||||
Here, we need to find pre- and postconditions for expressions and prove that they are correct.
|
||||
|
||||
To do the proofs, we again apply transition rules, as was the case already with operational semantics.
|
||||
Contrary to those however, we have pre- and postconditions, which we typically need to define ourselves.
|
||||
|
||||
This typically involves finding a loop invariant that holds before and after each iteration of the loop.
|
||||
This invariant should mention every variable used in the loop.
|
||||
Any other variable should also be mentioned in it. The loop \textit{variant} may also be added for proving termination.
|
||||
A typical for-loop loop variant would be \texttt{n - x}, as the next value of the loop variant has to be lower than the previous one.
|
||||
Of course, if \texttt{x} is decreasing, it itself can become the variant, as it fulfils the condition.
|
||||
|
||||
@@ -1 +1,12 @@
|
||||
\subsubsection{Modelling}
|
||||
Many of the tasks here are pretty straight forward, converting IMP into Promela,
|
||||
and putting an \texttt{assert} (or more) into the \texttt{init} block, to check if the required state is reached.
|
||||
|
||||
Note that for non-determinism, we use Promela conditionals without conditions.
|
||||
|
||||
For parallelism, we can use the \texttt{run} keyword for a \texttt{proctype}, then we wait for the processes to terminate using
|
||||
\texttt{\_nr\_pr == 1} and do our assertion.
|
||||
|
||||
|
||||
If we are given a text description only however, things get more challenging, as we need to model the properties given there.
|
||||
A possible simplification of the process may be to model things one property at a time, then combine them as needed.
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
\subsubsection{Linear Time Properties (LTL)}
|
||||
We refer to Section~\ref{sec:ltl} for intuition, as these tend to mostly be intuition exercises.
|
||||
|
||||
Reference in New Issue
Block a user