mirror of
https://github.com/janishutz/eth-summaries.git
synced 2026-07-27 21:29:09 +02:00
[FMFP] Restructure summary
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
\subsubsection{Induction}
|
||||
To prove recursive formulas, or more precisely formulated, a formula $P$ (with free variable $n$) for all $n \in \N$,
|
||||
we can't really do a proof by cases, as there are infinitely many cases (one for each input).
|
||||
Thus: We can use induction to prove recursive formulas or functions.
|
||||
|
||||
|
||||
\paragraph{The schema}
|
||||
To prove $\forall n \in \N. P$ (with $n$ free in $P$), we do the following:
|
||||
|
||||
\shade{blue}{Base case} We show that $P[n \mapsto 0]$ is correct
|
||||
|
||||
\shade{green}{Step case} For an arbitrary $m$ not free in $P$, we show that $P[n \mapsto m + 1]$ is correct under the assumption that $P[n \mapsto m]$ is correct.
|
||||
|
||||
For \bi{well-founded} domains, we have to adjust the induction hypothesis slightly: We assume $\forall l \in \N. l < m \rightarrow P[n \mapsto l]$
|
||||
and then prove $P[n \mapsto m]$ under our assumption.
|
||||
|
||||
|
||||
\paragraph{Induction over Lists}
|
||||
To prove $P$ for all $xs$ in \texttt{[T]}, we do the following:
|
||||
|
||||
\shade{blue}{Base case} We prove that $P[xs \mapsto []]$ is correct
|
||||
|
||||
\shade{green}{Step case} We prove that $\forall y :: T, ys :: [T]. P[xs \mapsto ys] \rightarrow P[xs \mapsto y : ys]$, or in other words:
|
||||
We fix arbitrary $y :: T$ and $ys :: [T]$, which both are not free in $P$.
|
||||
We then apply our induction hypothesis $P[xs \mapsto ys]$ to prove $P[xs \mapsto y : ys]$
|
||||
@@ -0,0 +1,6 @@
|
||||
To prove recursive formulas, or more precisely formulated, a formula $P$ (with free variable $n$) for all $n \in \N$,
|
||||
we have can use weak or strong induction.
|
||||
Weak induction may be a \textit{slightly} misleading term, because it isn't necessarily weaker than strong induction.
|
||||
|
||||
This section has been moved to the very start of the theory part, even though many of the topics mentioned have not been covered in the summary yet,
|
||||
such that all the induction proofs can be covered in the same place.
|
||||
@@ -0,0 +1,24 @@
|
||||
\subsection{Mathematical Induction}
|
||||
{\small NOTE: These types of induction were (primarily) mentioned in the Formal Methods part of the course, but made most sense to be put here}
|
||||
|
||||
\subsubsection{Weak Mathematical Induction}
|
||||
To prove $\forall n \in \N. P$ (with $n$ free in $P$), we do the following:
|
||||
|
||||
\shade{blue}{Base case} We show that $P[n \mapsto 0]$ is correct
|
||||
|
||||
\shade{green}{Step case} For an arbitrary $m$ not free in $P$, we show that $P[n \mapsto m + 1]$ is correct under the assumption that $P[n \mapsto m]$ is correct.
|
||||
|
||||
For \bi{well-founded} domains, we have to adjust the induction hypothesis slightly: We assume $\forall l \in \N. l < m \rightarrow P[n \mapsto l]$
|
||||
and then prove $P[n \mapsto m]$ under our assumption.
|
||||
|
||||
The same, but expressed as a Natural Deduction rule:
|
||||
\[
|
||||
\begin{prooftree}
|
||||
\hypo{\Gamma \vdash P(0)}
|
||||
\hypo{\Gamma, P(n) \vdash P(n + 1)}
|
||||
\infer2{\Gamma \vdash \forall n. P(n)}
|
||||
\end{prooftree}
|
||||
\]
|
||||
|
||||
|
||||
\subsubsection{Strong Mathematical Induction}
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
\subsubsection{Structural Induction}
|
||||
\subsection{Structural Induction}
|
||||
\subsubsection{Weak Structural Induction}
|
||||
Induction is based on the structure of terms
|
||||
\mint{haskell}+data T t = Leaf t | Node1 (T t) | Node2 t (T t) (T t)+
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
\subsection{Other types of induction}
|
||||
\subsubsection{Induction over Lists}
|
||||
To prove $P$ for all $xs$ in \texttt{[T]}, we do the following:
|
||||
|
||||
\shade{blue}{Base case} We prove that $P[xs \mapsto []]$ is correct
|
||||
|
||||
\shade{green}{Step case} We prove that $\forall y :: T, ys :: [T]. P[xs \mapsto ys] \rightarrow P[xs \mapsto y : ys]$, or in other words:
|
||||
We fix arbitrary $y :: T$ and $ys :: [T]$, which both are not free in $P$.
|
||||
We then apply our induction hypothesis $P[xs \mapsto ys]$ to prove $P[xs \mapsto y : ys]$
|
||||
|
||||
|
||||
+1
-1
@@ -41,4 +41,4 @@ We then show that the function is correct for both cases (i.e. LHS and RHS of OR
|
||||
\end{enumerate}
|
||||
In this proof we used the \textbf{TND} and \textbf{$\lor$-E} (here also called \bi{Case Split}) rules.
|
||||
|
||||
So what we have to show, given $Q \lor R$ for any proposition $P$ with case split is that \bi{(1)} $P$ follows from $Q$ and \bi{(2)} $P$ follows from $R$
|
||||
What we have to show, given $Q \lor R$ for any proposition $P$ with case split, is that \bi{(1)} $P$ follows from $Q$ and \bi{(2)} $P$ follows from $R$
|
||||
+2
-1
@@ -1,3 +1,4 @@
|
||||
\newpage
|
||||
\subsubsection{The semantics}
|
||||
\paragraph{Numerals}
|
||||
The semantic function $\cN : \texttt{Numeral} \rightarrow \texttt{Val}$ maps a numeral $n$ to an integer value $\cN\llbracket n \rrbracket$,
|
||||
@@ -27,7 +28,7 @@ $\cA : \texttt{Aexp} \rightarrow \texttt{State} \rightarrow \texttt{Val}$ maps a
|
||||
given by:
|
||||
\begin{align*}
|
||||
\cA\llbracket x \rrbracket \sigma & = \sigma(x) \\
|
||||
\cA\llbracket n \rrbracket \sigma & = \cN\llbracket x \rrbracket \\
|
||||
\cA\llbracket n \rrbracket \sigma & = \cN\llbracket n \rrbracket \\
|
||||
\cA\llbracket e_1 \; \texttt{op} \; e_2 \rrbracket \sigma & = \cA\llbracket e_1 \rrbracket \sigma \; \overline{\texttt{op}} \; \cA\llbracket e_2 \rrbracket \sigma
|
||||
\end{align*}
|
||||
For $\texttt{op} \in \texttt{Op}$, $\overline{\texttt{op}}$ is the corresponding operation $\texttt{Val} \times \texttt{Val} \rightarrow \texttt{Val}$
|
||||
+2
-3
@@ -24,7 +24,6 @@ If on the other hand we define $\cA\llbracket -e \rrbracket \sigma = \cA\llbrack
|
||||
it is \textit{not} an inductive definition because $0 - e$ is \textit{not} a subterm of $-e$
|
||||
|
||||
|
||||
\newpage
|
||||
\paragraph{Free Variables}
|
||||
For Arithmetic Expressions
|
||||
\begin{align*}
|
||||
@@ -36,7 +35,7 @@ For Arithmetic Expressions
|
||||
For Boolean Expressions
|
||||
\begin{align*}
|
||||
FV(b_1 \; \texttt{op} \; b_2) & = FV(b_1) \cup FV(b_2) \\
|
||||
FV(\texttt{not} b) & = FV(b) \\
|
||||
FV(\texttt{not}\; b) & = FV(b) \\
|
||||
FV(b_1 \; \texttt{or} \; b_2) & = FV(b_1) \cup FV(b_2) \\
|
||||
FV(b_1 \; \texttt{and} \; b_2) & = FV(b_1) \cup FV(b_2)
|
||||
\end{align*}
|
||||
@@ -56,7 +55,7 @@ And finally for Statements:
|
||||
|
||||
A substitution $f[x \mapsto e]$ replaces each free occurrence of variable $x$ in $f$ by $e$, where $f$ is any expression.
|
||||
|
||||
Detailed rules for arithmetic expressions:
|
||||
Detailed rules for arithmetic expressions (for the last, if variable $y$ is $x$, it is replaced, otherwise not):
|
||||
\begin{align*}
|
||||
(e_1 \; \texttt{op} \; e_2)[x \mapsto e] & \equiv (e_1[x \mapsto e] \; \texttt{op} \; e_2[x \mapsto e]) \\
|
||||
n[x \mapsto e] & \equiv n \\
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
\newpage
|
||||
\subsection{Operational Semantics}
|
||||
Big-step semantics describe how the \bi{overall} results of the execution are obtained and use Natural semantics rules.
|
||||
Small-step semantics describe how the individual steps of the computations take place and use Structural Operational Semantics (SOS)
|
||||
\textbf{Big-step semantics} describe how the \bi{overall} results of the execution are obtained and use Natural semantics rules.
|
||||
\textbf{Small-step semantics} describe how the individual steps of the computations take place and use Structural Operational Semantics (SOS)
|
||||
|
||||
\subsubsection{Big-Step Semantics}
|
||||
\paragraph{Transition Systems}
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
Each inference rule is actually a rule scheme, where the meta-variables are placeholders for statements, states, etc.
|
||||
Each rule scheme describes infinitely many \bi{rule instances}.
|
||||
|
||||
A rule is \bi{instantiated} when all meta-variables are replaced with syntactic elements
|
||||
Assignment rule scheme vs. instance
|
||||
A rule is \bi{instantiated} when all meta-variables are replaced with syntactic elements.
|
||||
Assignment rule scheme vs. instance:
|
||||
\[
|
||||
\begin{prooftree}
|
||||
\infer0[\textsc{Ass}$_{NS}$]{\langle x := e, \sigma \rangle \rightarrow \sigma[x \mapsto \cA\llbracket e \rrbracket \sigma]}
|
||||
Reference in New Issue
Block a user