assignment3_solution.tex 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. \documentclass[11pt,a4paper]{article}
  2. \usepackage{latexsym}
  3. \usepackage{paralist}
  4. \usepackage{amssymb}
  5. \usepackage{amsmath}
  6. \usepackage{url}
  7. \usepackage{tikz}
  8. \usetikzlibrary{calc,intersections,angles,quotes}
  9. \usepackage{stmaryrd}
  10. \usepackage{float}
  11. \let\origfigure\figure
  12. \let\endorigfigure\endfigure
  13. \renewenvironment{figure}[1][2] {
  14. \expandafter\origfigure\expandafter[H]
  15. } {
  16. \endorigfigure
  17. }
  18. \newcommand\ctlA{\textsf{\textbf{A}}\,}
  19. \newcommand\ctlE{\textsf{\textbf{E}}}
  20. \newcommand\ltlF{\textsf{\textbf{F}}\,}
  21. \newcommand\ltlG{\textsf{\textbf{G}}\,}
  22. \newcommand\ltlU{\,\textsf{\textbf{U}}\,}
  23. \newcommand\ltlX{\textsf{\textbf{X}}\,}
  24. \newcommand\LTL[0]{$\mbox{\textsf{LTL}}$}
  25. \parskip 0mm
  26. \oddsidemargin 0in
  27. \evensidemargin 0in
  28. \textwidth 6in
  29. \topmargin 0in
  30. \marginparwidth 30pt
  31. \textheight 9.2in
  32. \headheight .1in
  33. \headsep .1mm
  34. \title{VU Programm- und Systemverifikation\\
  35. \Large Homework: Temporal Logic and Automated Reasoning}
  36. \author{~}
  37. \date{{\bf Due date:} May 27, 2021, \underline{1pm}}
  38. \usepackage{listings}
  39. \lstset{
  40. basicstyle=\footnotesize\ttfamily, % Standardschrift
  41. numbers=left, % Ort der Zeilennummern
  42. numberstyle=\tiny, % Stil der Zeilennummern
  43. numbersep=5pt, % Abstand der Nummern zum Text
  44. tabsize=2, % Groesse von Tabs
  45. extendedchars=true, %
  46. breaklines=true, % Zeilen werden Umgebrochen
  47. keywordstyle=\ttfamily,
  48. stringstyle=\ttfamily, % Farbe der String
  49. showspaces=false, % Leerzeichen anzeigen ?
  50. showtabs=false, % Tabs anzeigen ?
  51. xleftmargin=17pt,
  52. framexleftmargin=17pt,
  53. framexrightmargin=5pt,
  54. framexbottommargin=4pt,
  55. showstringspaces=false % Leerzeichen in Strings anzeigen ?
  56. }
  57. \lstloadlanguages{
  58. C , C++, ml
  59. }
  60. \gdef\dash---{\thinspace---\hskip.16667em\relax}
  61. \gdef\smdash--{\thinspace--\hskip.16667em\relax}
  62. \newcommand{\emn}[1]{{\em #1\/}}
  63. \gdef\op|{\,|\;}
  64. \newcommand{\true}{{\sc true}}
  65. \begin{document}
  66. \maketitle
  67. \paragraph{Task 1 (5 points):}
  68. Consider the following Kripke Structure:
  69. \begin{center}
  70. \begin{tikzpicture}[>=latex,->,scale=0.7,label distance=-3mm,node distance=2cm]
  71. \tikzstyle{every node}=[draw,shape=circle,minimum size=9mm,font=\footnotesize];
  72. \tikzstyle{every path} = [draw,thick];
  73. \node (s0) [label=below:$s_0$] {$a$};
  74. \node[right of=s0] (s1) [label=below:$s_1$] {$b$};
  75. \node[right of=s1] (s2) [label=below:$s_2$] {$a$};
  76. \draw ($(s0)-(2cm,0)$)--(s0);
  77. \draw (s0) to (s1);
  78. \draw (s1) to (s2);
  79. % \draw[loop above] (s0) to (s0);
  80. \draw[loop above] (s1) to (s1);
  81. \draw[loop above] (s2) to (s2);
  82. \end{tikzpicture}
  83. \end{center}
  84. For each formula, give the
  85. \underline{states of the Kripke structure for which the formula holds}.
  86. In other words, for each of the states from the set
  87. $\{s_0, s_1, s_2\}$,
  88. consider the computation trees starting at that state,
  89. and for each tree, check whether the given formula holds on it or not.
  90. \begin{enumerate}
  91. \item $\ctlA \ltlF \ltlG a$
  92. $\{s_2\}$
  93. \vskip.5cm
  94. \item $\ctlA\ltlF \ctlA\ltlG b$
  95. $\emptyset$
  96. \vskip.5cm
  97. \item $\ctlA (a \wedge \ltlX b)$
  98. $\{s_0\}$
  99. \vskip.5cm
  100. \item $\ctlA (b \ltlU a)$
  101. $\{s_0, s_2\}$
  102. \vskip.5cm
  103. \item $\ctlA \ltlX \ltlX a$
  104. $\{s_2\}$
  105. \vskip.5cm
  106. \item $\ctlA \ltlG \ltlF a$
  107. $\{s_2\}$
  108. \vskip.5cm
  109. \item $\ctlA \ltlG \ltlF b$
  110. $\emptyset$
  111. \vskip.5cm
  112. \item $\ctlE \ltlG \ltlF b$
  113. $\{s_0, s_1\}$
  114. \vskip.5cm
  115. \item $\ctlA (a \ltlU b)$
  116. $\{s_0, s_1\}$
  117. \vskip.5cm
  118. \item $\ctlE (b \ltlU a)$
  119. $\{s_0, s_1, s_2\}$
  120. \vskip1cm
  121. \end{enumerate}
  122. \clearpage
  123. \paragraph{Task 2 (3 points):}
  124. Consider the following Kripke Structure with initial state $s_0$:
  125. \begin{center}
  126. \begin{tikzpicture}[>=latex,->,scale=0.7,label distance=-3mm,node distance=2cm]
  127. \tikzstyle{every node}=[draw,shape=circle,minimum size=9mm,font=\footnotesize];
  128. \tikzstyle{every path} = [draw,thick];
  129. \node (s0) [label=below:$s_0$] {$a$};
  130. \node[right of=s0] (s1) [label=below:$s_1$] {$b$};
  131. \node[right of=s1] (s2) [label=below:$s_2$] {$a$};
  132. \draw ($(s0)-(2cm,0)$)--(s0);
  133. \draw (s0) to (s1);
  134. \draw (s1) to (s2);
  135. % \draw[loop above] (s0) to (s0);
  136. \draw[loop above] (s1) to (s1);
  137. \draw[loop above] (s2) to (s2);
  138. \end{tikzpicture}
  139. \end{center}
  140. \newcommand{\wedgi}{\;\wedge\; }
  141. \begin{enumerate}
  142. \vskip1cm
  143. \item Does the LTL formula $\ctlA\ltlF\ltlG b$ hold in the initial
  144. state $s_0$?
  145. \begin{center}
  146. $\Box$ yes \qquad $\Box$ no
  147. \end{center}
  148. Justify your answer!
  149. \begin{figure}
  150. \centering
  151. \includegraphics[scale=.6]{./res/2-1.png}
  152. \label{fig:justification-1}
  153. \end{figure}
  154. % {s1, s2}
  155. \item Does the CTL formula $\ctlA\ltlF\ctlE\ltlG b$ hold in the initial
  156. state $s_0$?
  157. \begin{center}
  158. $\Box$ yes \qquad $\Box$ no
  159. \end{center}
  160. Justify your answer!
  161. \begin{figure}
  162. \centering
  163. \includegraphics[scale=.6]{./res/2-2.png}
  164. \label{fig:justification-2}
  165. \end{figure}
  166. \item Do the formulas (i) and (ii) above express the same property?
  167. \begin{center}
  168. $\Box$ yes \qquad $\Box$ no
  169. \end{center}
  170. If not, explain why.
  171. \begin{figure}
  172. \centering
  173. \includegraphics[scale=.6]{./res/2-3.png}
  174. \label{fig:justification-3}
  175. \end{figure}
  176. \end{enumerate}
  177. \clearpage
  178. \paragraph{Task 3 (2 points):}
  179. Encode the following statements in temporal logic
  180. (LTL if possible, CTL otherwise):
  181. \begin{enumerate}
  182. \vskip.5cm
  183. \item Whenever the execution of a program encounters a
  184. {\em fault} it is possible to {\em recover} eventually.
  185. \begin{figure}
  186. \centering
  187. \includegraphics[scale=.6]{./res/3-1.png}
  188. \label{fig:encoding-1}
  189. \end{figure}
  190. \item If an execution encounters {\em fault}s in three
  191. subsequent states, it will never {\em recover} again.
  192. \begin{figure}
  193. \centering
  194. \includegraphics[scale=.6]{./res/3-2.png}
  195. \label{fig:encoding-2}
  196. \end{figure}
  197. \item Whenever a state labeled with $a$ is reached, a state labeled
  198. with $b$ will be reached at a \emph{strictly later} point.
  199. \begin{figure}
  200. \centering
  201. \includegraphics[scale=.6]{./res/3-3.png}
  202. \label{fig:encoding-3}
  203. \end{figure}
  204. \item All paths starting at the initial state lead to a
  205. cycle that does not contain a state labeled $a$.
  206. \begin{figure}
  207. \centering
  208. \includegraphics[scale=.6]{./res/3-4.png}
  209. \label{fig:encoding-4}
  210. \end{figure}
  211. \end{enumerate}
  212. \clearpage
  213. \paragraph{Task 4 (5 points):}
  214. Consider the following formula in propositional logic; is it satisfiable?
  215. If yes, provide a satisfying assignment, if not,
  216. \underline{give the reasoning that leads to this conclusion}.
  217. \begin{multline}
  218. \overbrace{(x_{11} \vee x_{12})}^{C1} \wedgi
  219. \overbrace{(x_{21} \vee x_{22})}^{C2} \wedgi
  220. \overbrace{(x_{31} \vee x_{32})}^{C3}
  221. \wedgi \\
  222. \underbrace{(\neg x_{11} \vee \neg x_{21})}_{C4} \wedgi
  223. \underbrace{(\neg x_{11} \vee \neg x_{31})}_{C5} \wedgi
  224. \overbrace{(\neg x_{12} \vee \neg x_{22})}^{C6} \wedgi
  225. \overbrace{(\neg x_{12} \vee \neg x_{32})}^{C7} \wedgi \\
  226. \underbrace{(\neg x_{21} \vee \neg x_{31})}_{C8} \wedgi
  227. \underbrace{(\neg x_{22} \vee \neg x_{32})}_{C9}
  228. \end{multline}
  229. (The clauses in Formula (1) are labelled $C1$ to $C9$.)
  230. \begin{itemize}
  231. \item For each decision, provide the resulting implication/conflict graph!
  232. \item For each conflict you reach, provide a corresponding learned clause!
  233. \end{itemize}
  234. \begin{figure}
  235. \centering
  236. \includegraphics[scale=.65]{./res/4-solution.png}
  237. \caption{implication/conflict graph and learnt clauses}
  238. \label{fig:implication-conflict-graph}
  239. \end{figure}
  240. \clearpage
  241. \paragraph{Task 5 (3 points):}
  242. \begin{enumerate}
  243. \item Consider the following formulas in propositional logic; are they satisfiable? If
  244. yes, provide a satisfying assignment over booleans, if not, give
  245. the reasoning that leads to this conclusion.
  246. \begin{figure}
  247. \centering
  248. \includegraphics[scale=.65]{./res/5-1.png}
  249. \label{fig:prop-logic}
  250. \end{figure}
  251. \item
  252. Consider the following formulas in Equality Logic; are they satisfiable? If
  253. yes, provide a satisfying assignment over integers, if not, give
  254. the reasoning based on equivalence classes that leads to this
  255. conclusion.
  256. NOTE: I have done this exercise before I have learned about the merging of equivalence classes, but this particular "algorithm" is based on the same idea: reduce equivalent statements
  257. \begin{equation}
  258. i = j \wedgi j = k \wedgi k = l \wedgi l \neq m \wedgi l \neq n \wedgi m = n \wedgi o \neq p \wedge o = q
  259. \end{equation}
  260. \begin{figure}
  261. \centering
  262. \includegraphics[scale=.65]{./res/5-2-1.png}
  263. \label{fig:eq-logic-1}
  264. \end{figure}
  265. \begin{equation}
  266. i = j \wedgi j = k \wedgi k = l \wedgi l \neq n \wedgi m = n \wedgi
  267. g(i) \neq g(m)
  268. \wedgi f(i) \neq f(l)
  269. \end{equation}
  270. \begin{figure}
  271. \centering
  272. \includegraphics[scale=.65]{./res/5-2-2.png}
  273. \label{fig:eq-logic-2}
  274. \end{figure}
  275. \vfill
  276. \clearpage
  277. \item
  278. Check the satisfiability of the following SMT formulas.
  279. Assume that $x, y \in {\mathbb Z}$ are integer constants, and $f:
  280. {\mathbb Z} \rightarrow {\mathbb Z}$ and $g: {\mathbb Z} \times {\mathbb Z}
  281. \rightarrow {\mathbb Z}$ are unary and binary uninterpreted functions
  282. over integers respectively.
  283. Whenever a formula is satisfiable, give a satisfying assignment for it, i.e.,
  284. integer values for all constants and function interpetations over integers
  285. that make the formula true under the assignment.
  286. Whenever a formula is not satisfiable, give a reason why it is unsatisfiable.
  287. \begin{equation}
  288. g(3, y) = 5 \wedgi g(y, 3) = 4 \wedgi g(y, x) = g(x, y)
  289. \end{equation}
  290. \begin{figure}
  291. \centering
  292. \includegraphics[scale=.65]{./res/5-3-1.png}
  293. \label{fig:smt-1}
  294. \end{figure}
  295. \begin{multline}
  296. x = y \wedgi f(f(y)) = f(x) \wedgi f(1) \ne g(1, y)
  297. \wedgi 1 = f(x) \wedgi g(1, x) = f(f(x))
  298. \end{multline}
  299. \end{enumerate}
  300. \begin{figure}
  301. \centering
  302. \includegraphics[scale=.65]{./res/5-3-2.png}
  303. \label{fig:smt-2}
  304. \end{figure}
  305. \vfill
  306. \clearpage
  307. \paragraph{Task 6 (2 points):}
  308. \noindent
  309. Indicate whether the following statements are true or false!\\[2ex]
  310. \noindent
  311. \begin{tabular}{p{.65\textwidth}cc}
  312. {\bf Statement} & {\bf True} & {\bf False}\\[1ex]
  313. Any CTL formula starting with {\bf A} can be expressed in LTL
  314. & $\bigcirc$ & $\bigotimes$\\
  315. &&\\
  316. CTL$^{*}$ is the union of all CTL and LTL formulas. & $\bigcirc$ & $\bigotimes$\\
  317. \vskip0.2cm
  318. NOTE: consider ELTL
  319. \vskip0.2cm
  320. &&\\
  321. Every CTL formula has an equivalent CTL formula containing only
  322. ${\bf AF}$, ${\bf EX}$, and ${\bf EU}$. & $\bigotimes$ & $\bigcirc$\\ % false
  323. \vskip0.2cm
  324. NOTE: $AF \varphi \mapsto \neg EG \neg \varphi$
  325. \vskip0.2cm
  326. &&\\
  327. There is a non-empty Kripke structure~$K$ that satisfies
  328. $({\bf AG}\,{\bf AF} p) \wedge ({\bf EF}\,{\bf EG} \neg p)$. & $\bigcirc$ & $\bigotimes$\\
  329. \vskip0.2cm
  330. NOTE: $(AGAF p) \land (EFEG \neg p) = (\neg EF \neg(\neg EG \neg p)) \land (EFEG \neg p) = (\neg EFEG \neg p) \land (EFEG \neg p)$
  331. \end{tabular}
  332. \vfill
  333. Upload a pdf file with your solutions to TUWEL by May 27, 2021.
  334. \end{document}