Resolutionsalgorithmus.tex 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. \documentclass{article}
  2. \usepackage[pdftex,active,tightpage]{preview}
  3. \setlength\PreviewBorder{2mm}
  4. \usepackage[utf8]{inputenc} % this is needed for umlauts
  5. \usepackage[ngerman]{babel} % this is needed for umlauts
  6. \usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf
  7. \usepackage{amssymb,amsmath,amsfonts} % nice math rendering
  8. \usepackage{braket} % needed for \Set
  9. \usepackage{algorithm,algpseudocode}
  10. \algnewcommand\True{\textbf{true}\space}
  11. \algnewcommand\False{\textbf{false}\space}
  12. \algnewcommand{\LineComment}[1]{\State \(\triangleright\) #1}
  13. \begin{document}
  14. \begin{preview}
  15. \begin{algorithm}[H]
  16. \begin{algorithmic}
  17. \Require Klauselmenge $K$ in KNF (jede Klausel wird durch ein mit den
  18. Werten $\Set{-1,0,1}$ Array
  19. repräsentiert, dessen Länge gleich der Anzahl $n$ der Symbole ist),\\
  20. zu beweisende Aussage ist $\alpha$,\\
  21. $\beta := \neg \alpha$ in KNF
  22. \Procedure{Resolutionsalgorithmus}{$K$, $\beta$}
  23. \State $\gamma \gets K \cup \Set{\beta}$
  24. \State $foundMatch \gets$ \True
  25. \While{$foundMatch$}
  26. \State $foundMatch \gets$ \False
  27. \LineComment{Finde zwei Klauseln, bei denen ein Symbol verneint bzw. nicht-verneint vorkommt. Wende darauf die Resolutionsregel an}
  28. \For{$i \in \Set{1, \dots, |\gamma|-1}$}
  29. \For{$j \in \Set{i+1, \dots |\gamma|}$}
  30. \For{$k \in \Set{0, \dots, n-1}$}
  31. \If{$\gamma_i[k] \cdot \gamma_j[k] == (-1)$}
  32. \State $foundMatch \gets$ \True
  33. \State $tmp \gets $ Array der Länge $n$
  34. \For{$l \in \Set{0, \dots, n-1}$}
  35. \If{$\gamma_i[l] \cdot \gamma_j[l] == (-1)$ and
  36. $l \neq k$}
  37. \State $tmp \gets $ leere Klausel
  38. \State break
  39. \ElsIf{$\gamma_i[l] \neq 0$}
  40. \State $tmp[l] \gets \gamma_i[l]$
  41. \Else
  42. \State $tmp[l] \gets \gamma_j[l]$
  43. \EndIf
  44. \EndFor
  45. \State $\gamma \gets (\gamma \cup \Set{tmp}) \setminus
  46. \Set{\gamma_i, \gamma_j}$
  47. \State break
  48. \EndIf
  49. \EndFor
  50. \If{$foundMatch$}
  51. \State break
  52. \EndIf
  53. \EndFor
  54. \If{$foundMatch$}
  55. \State break
  56. \EndIf
  57. \EndFor
  58. \EndWhile
  59. \EndProcedure
  60. \end{algorithmic}
  61. \caption{Resolutionsalgorithmus}
  62. \label{alg:resolutionsalgorithmus}
  63. \end{algorithm}
  64. \end{preview}
  65. \end{document}