DPLL.tex 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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$, Symbolmenge $S$, (partielles) Modell $M$
  18. \Procedure{DPLL}{$K$, $S$, $M$}
  19. \If{Alle Klauseln sind wahr in $M$}
  20. \State \Return \texttt{true}
  21. \EndIf
  22. \If{Eine Klausel ist falsch in $M$}
  23. \State \Return \texttt{false}
  24. \EndIf
  25. \\
  26. \State $P, Wert \gets \Call{FindeEinheitsklausel}{K, S, M}$
  27. \If{$P$ existiert}
  28. \State $M \gets \Call{SetzePInModell}{P, Wert, M}$
  29. \State \Return $\Call{DPLL}{k, S \setminus \Set{P}, M}$
  30. \EndIf
  31. \\
  32. \LineComment{Ein reines Literal ist eines, das in jeder Klausel}
  33. \LineComment{immer wahr bzw. immer falsch ist}
  34. \State $P, Wert \gets \Call{FindeReinesLiteral}{K, M}$
  35. \If{$P$ existiert}
  36. \State $m \gets \Call{SetzePInModell}{P, Wert, M}$
  37. \State \Return $\Call{DPLL}{K, S \setminus \Set{P}, M}$
  38. \EndIf
  39. \\
  40. \State $P \gets S.pop()$ \Comment{Symbolmenge schrumpft}
  41. \State $M_1 \gets \Call{SetzePInModell}{P, \texttt{true}, M}$
  42. \State $M_2 \gets \Call{SetzePInModell}{P, \texttt{false}, M}$
  43. \State \Return $\Call{DPLL}{K, S, M_1} \lor \Call{DPLL}{K, S, M_2}$
  44. \EndProcedure
  45. \end{algorithmic}
  46. \caption{DPLL-Verfahren}
  47. \label{alg:dpll}
  48. \end{algorithm}
  49. \end{preview}
  50. \end{document}