mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-25 14:28:05 +02:00
union find; paterson-wegeman
This commit is contained in:
parent
2f943ff667
commit
c2db4122e7
3 changed files with 46 additions and 0 deletions
Binary file not shown.
|
@ -53,6 +53,17 @@
|
||||||
\usepackage{wasysym}
|
\usepackage{wasysym}
|
||||||
\usepackage[binary-units = true]{siunitx} % this package is for units!
|
\usepackage[binary-units = true]{siunitx} % this package is for units!
|
||||||
\sisetup{locale=DE}
|
\sisetup{locale=DE}
|
||||||
|
|
||||||
|
%%% Pseudocode settings
|
||||||
|
\usepackage{algorithm,algpseudocode}
|
||||||
|
\algtext*{EndIf} % Remove "end if" text
|
||||||
|
\algtext*{EndWhile} % Remove "end while" text
|
||||||
|
\algtext*{EndFunction} % Remove "end while" text
|
||||||
|
\algnewcommand\Global{\textbf{global }}
|
||||||
|
\makeatletter
|
||||||
|
\addto\captionsngerman{\renewcommand{\ALG@name}{Algorithmus}}
|
||||||
|
\makeatother
|
||||||
|
%%% End of Pseudocode settings
|
||||||
\usepackage{shortcuts}
|
\usepackage{shortcuts}
|
||||||
|
|
||||||
\usepackage{fancyhdr}
|
\usepackage{fancyhdr}
|
||||||
|
|
|
@ -181,4 +181,39 @@ Manchmal werden Seiteneffekte auch als Nebeneffekt oder Wirkung bezeichnet.
|
||||||
\end{beispiel}
|
\end{beispiel}
|
||||||
\footnotetext{Folie 268 von Prof. Snelting}
|
\footnotetext{Folie 268 von Prof. Snelting}
|
||||||
|
|
||||||
|
\begin{algorithm}[h]
|
||||||
|
\begin{algorithmic}
|
||||||
|
\Function{unify}{Gleichungsmenge $C$}
|
||||||
|
\If{$C == \emptyset$}
|
||||||
|
\State \Return $[]$
|
||||||
|
\Else
|
||||||
|
\State Es sei $\Set{\theta_l = \theta_r} \cup C' == C$
|
||||||
|
|
||||||
|
\If{$\theta_l == \theta_r$}
|
||||||
|
\State \Call{unify}{$C'$}
|
||||||
|
\ElsIf{$\theta_l == Y$ and $Y \notin FV(\theta_r)$}
|
||||||
|
\State \Call{unify}{$[Y \text{\pointer} \theta_r] C'$} $\circ [Y \text{\pointer} \theta_r]$
|
||||||
|
\ElsIf{$\theta_r == Y$ and $Y \notin FV(\theta_l)$}
|
||||||
|
\State \Call{unify}{$[Y \text{\pointer} \theta_l] C'$} $\circ [Y \text{\pointer} \theta_l]$
|
||||||
|
\ElsIf{$\theta_l == f(\theta_l^1, \dots, \theta_l^n)$ and $\theta_r == f(\theta_r^1, \dots, \theta_r^n$}
|
||||||
|
\State \Call{unify}{$C' \cup \Set{\theta_l^1 = \theta_r^1, \dots \theta_l^n = \theta_r^n}$}
|
||||||
|
\Else
|
||||||
|
\State fail
|
||||||
|
\EndIf
|
||||||
|
\EndIf
|
||||||
|
\EndFunction
|
||||||
|
\end{algorithmic}
|
||||||
|
\caption{Klassischer Unifikationsalgorithmus}
|
||||||
|
\label{alg:klassischer-unifikationsalgorithmus}
|
||||||
|
\end{algorithm}
|
||||||
|
|
||||||
|
Dieser klassische Algorithmus hat eine Laufzeit von $\mathcal{O}(2^n)$ für folgendes
|
||||||
|
Beispiel:
|
||||||
|
|
||||||
|
\[f(X_1, X_2, \dots, X_n) = f(g(X_0, X_0), g(X_1, X_1), \dots, g(X_{n-1}, X_{n-1}) )\]
|
||||||
|
|
||||||
|
Der \textit{Paterson-Wegman-Unifikationsalgorithmus}\xindex{Paterson-Wegman-Unifikationsalgorithmus} ist deutlich effizienter.
|
||||||
|
Er basiert auf dem \textit{Union-Find-Algorithmus}\xindex{Union-Find-Algorithmus}.
|
||||||
|
|
||||||
|
|
||||||
\footnotetext{\url{https://de.wikipedia.org/w/index.php?title=Unifikation\_(Logik)&oldid=116848554\#Beispiel}}
|
\footnotetext{\url{https://de.wikipedia.org/w/index.php?title=Unifikation\_(Logik)&oldid=116848554\#Beispiel}}
|
Loading…
Add table
Add a link
Reference in a new issue