📚 The CoCalc Library - books, templates and other resources
cocalc-examples / martinthoma-latex-examples / source-code / Pseudocode / Resolutionsalgorithmus / Resolutionsalgorithmus.tex
132932 viewsLicense: OTHER
\documentclass{article}1\usepackage[pdftex,active,tightpage]{preview}2\setlength\PreviewBorder{2mm}34\usepackage[utf8]{inputenc} % this is needed for umlauts5\usepackage[ngerman]{babel} % this is needed for umlauts6\usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf7\usepackage{amssymb,amsmath,amsfonts} % nice math rendering8\usepackage{braket} % needed for \Set9\usepackage{algorithm,algpseudocode}1011\algnewcommand\True{\textbf{true}\space}12\algnewcommand\False{\textbf{false}\space}13\algnewcommand{\LineComment}[1]{\State \(\triangleright\) #1}14\begin{document}15\begin{preview}16\begin{algorithm}[H]17\begin{algorithmic}18\Require Klauselmenge $K$ in KNF (jede Klausel wird durch ein mit den19Werten $\Set{-1,0,1}$ Array20repräsentiert, dessen Länge gleich der Anzahl $n$ der Symbole ist),\\21zu beweisende Aussage ist $\alpha$,\\22$\beta := \neg \alpha$ in KNF23\Procedure{Resolutionsalgorithmus}{$K$, $\beta$}24\State $\gamma \gets K \cup \Set{\beta}$25\State $foundMatch \gets$ \True26\While{$foundMatch$}27\State $foundMatch \gets$ \False2829\LineComment{Finde zwei Klauseln, bei denen ein Symbol verneint bzw. nicht-verneint vorkommt. Wende darauf die Resolutionsregel an}30\For{$i \in \Set{1, \dots, |\gamma|-1}$}31\For{$j \in \Set{i+1, \dots |\gamma|}$}32\For{$k \in \Set{0, \dots, n-1}$}33\If{$\gamma_i[k] \cdot \gamma_j[k] == (-1)$}34\State $foundMatch \gets$ \True35\State $tmp \gets $ Array der Länge $n$36\For{$l \in \Set{0, \dots, n-1}$}37\If{$\gamma_i[l] \cdot \gamma_j[l] == (-1)$ and38$l \neq k$}39\State $tmp \gets $ leere Klausel40\State break41\ElsIf{$\gamma_i[l] \neq 0$}42\State $tmp[l] \gets \gamma_i[l]$43\Else44\State $tmp[l] \gets \gamma_j[l]$45\EndIf46\EndFor47\State $\gamma \gets (\gamma \cup \Set{tmp}) \setminus48\Set{\gamma_i, \gamma_j}$49\State break50\EndIf51\EndFor5253\If{$foundMatch$}54\State break55\EndIf56\EndFor5758\If{$foundMatch$}59\State break60\EndIf61\EndFor62\EndWhile63\EndProcedure64\end{algorithmic}65\caption{Resolutionsalgorithmus}66\label{alg:resolutionsalgorithmus}67\end{algorithm}68\end{preview}69\end{document}707172