DFA.ipynb 33.6 KB
Newer Older
Michael Leuschel's avatar
Michael Leuschel committed
1
2
3
4
5
6
7
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Endliche Automaten : DFA\n",
Michael Leuschel's avatar
Michael Leuschel committed
8
9
10
11
12
13
14
15
16
17
    "\n",
    "\n",
    "Jede Klasse der Chomsky-Hierarchie kann durch einen geeigneten Automatentypen charakterisiert\n",
    "werden. Beispielsweise kann jede reguläre Sprache (Typ 3) durch einen endlichen Automaten\n",
    "erkannt werden, und jede von einem endlichen Automaten erkannte Sprache ist\n",
    "regulär.\n",
    "\n",
    "Endliche Automaten sind weit verbreitet. Ein Beispiel ist die Spezifikation des [DHCP Protokolls](http://www.tcpipguide.com/free/t_DHCPGeneralOperationandClientFiniteStateMachine.htm#Figure_262):\n",
    "\n",
    "<img src=\"http://www.tcpipguide.com/free/diagrams/dhcpfsm.png\" width=\"500\"/>"
Michael Leuschel's avatar
Michael Leuschel committed
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### DFA\n",
    "\n",
    "Ein __deterministischer endlicher Automat__ (kurz DFA für\n",
    "  deterministic finite automaton) ist ein Quintupel \n",
    "  $M =(\\Sigma, Z, \\delta , z_0, F)$, wobei\n",
    "* $\\Sigma$ ein Alphabet ist,\n",
    "* $Z$ eine endliche Menge von Zuständen mit\n",
    "  $\\Sigma \\cap Z = \\emptyset$,\n",
    "* $\\delta : Z \\times \\Sigma \\rightarrow Z$ die Überführungsfunktion,\n",
    "* $z_0 \\in Z$ der Startzustand und\n",
    "* $F \\subseteq Z$ die Menge der Endzustände (Finalzustände).\n"
   ]
  },
  {
   "cell_type": "code",
40
   "execution_count": 1,
Michael Leuschel's avatar
Michael Leuschel committed
41
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
42
43
44
45
46
47
48
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Loaded machine: DFA"
      ]
     },
49
     "execution_count": 1,
Michael Leuschel's avatar
Michael Leuschel committed
50
51
52
53
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
54
55
56
57
58
59
60
61
62
63
64
65
   "source": [
    "::load\n",
    "MACHINE DFA\n",
    "SETS\n",
    "   Z = {z0,z1,z2,z3}\n",
    "CONSTANTS Σ, F, δ\n",
    "PROPERTIES\n",
    " F ⊆ Z ∧\n",
    " δ ∈ (Z×Σ) → Z\n",
    " ∧\n",
    " /* Der Automat von Folie 10: */\n",
    " Σ = {0,1} ∧\n",
Michael Leuschel's avatar
Michael Leuschel committed
66
    " F = {z2} ∧\n",
Michael Leuschel's avatar
Michael Leuschel committed
67
68
69
70
    " δ = {     (z0,0)↦z1, (z0,1)↦z3,\n",
    "           (z1,0)↦z3, (z1,1)↦z2,\n",
    "           (z2,0)↦z2, (z2,1)↦z2,\n",
    "           (z3,0)↦z3, (z3,1)↦z3 }\n",
Michael Leuschel's avatar
Michael Leuschel committed
71
72
73
    "DEFINITIONS // Für den Zustandsgraphen:\n",
    "  CUSTOM_GRAPH_NODES1 == rec(shape:\"doublecircle\",nodes:F); // Endzustände\n",
    "  CUSTOM_GRAPH_NODES2 == rec(shape:\"circle\",nodes:Z\\F); // andere Zustände\n",
Michael Leuschel's avatar
Michael Leuschel committed
74
    "  CUSTOM_GRAPH_NODES3 == rec(shape:\"none\",color:\"white\",style:\"none\",nodes:{\"\"});\n",
Michael Leuschel's avatar
Michael Leuschel committed
75
    "  CUSTOM_GRAPH_EDGES1 == rec(color:\"red\",label:\"0\",edges:{a,b|(a,0)|->b:δ}); \n",
Michael Leuschel's avatar
Michael Leuschel committed
76
    "  CUSTOM_GRAPH_EDGES2 == rec(color:\"green\",label:\"1\",edges:{a,b|(a,1)|->b:δ});\n",
Michael Leuschel's avatar
Michael Leuschel committed
77
    "  CUSTOM_GRAPH_EDGES3 == rec(color:\"black\",label:\"\",edges:{\"\" |-> z0}) // Kante für den Startknoten\n",
Michael Leuschel's avatar
Michael Leuschel committed
78
79
80
81
82
    "END"
   ]
  },
  {
   "cell_type": "code",
83
   "execution_count": 2,
Michael Leuschel's avatar
Michael Leuschel committed
84
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
85
86
87
88
89
90
91
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Machine constants set up using operation 0: $setup_constants()"
      ]
     },
92
     "execution_count": 2,
Michael Leuschel's avatar
Michael Leuschel committed
93
94
95
96
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
97
98
99
100
101
102
103
104
   "source": [
    ":constants"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
Michael Leuschel's avatar
Michael Leuschel committed
105
106
107
    "Ein Automat befindet sich jeweils in einem der Zustände aus Z. Am Anfang befindet er sich in $z_0$. \n",
    "Der Automat kann jeweils in einem Zustand $z$ ein Symbol $x$ aus $\\Sigma$ verarbeiten und wechselt dann in den Zustand $\\delta(z,x)$.\n",
    "Zum Beispiel, wenn der DFA im Startzustand z0 das Symbol $0$ erhält wechselt er nach:"
Michael Leuschel's avatar
Michael Leuschel committed
108
109
110
111
   ]
  },
  {
   "cell_type": "code",
112
   "execution_count": 3,
Michael Leuschel's avatar
Michael Leuschel committed
113
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
114
115
116
117
118
119
120
121
122
123
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "$\\mathit{z1}$"
      ],
      "text/plain": [
       "z1"
      ]
     },
124
     "execution_count": 3,
Michael Leuschel's avatar
Michael Leuschel committed
125
126
127
128
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
129
130
131
132
133
134
135
136
137
138
139
140
141
   "source": [
    "δ(z0,0)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Wenn der Automat dann das Symbol 1 erhält wechselt er von Zustand $z1$ nach:"
   ]
  },
  {
   "cell_type": "code",
142
   "execution_count": 4,
Michael Leuschel's avatar
Michael Leuschel committed
143
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
144
145
146
147
148
149
150
151
152
153
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "$\\mathit{z2}$"
      ],
      "text/plain": [
       "z2"
      ]
     },
154
     "execution_count": 4,
Michael Leuschel's avatar
Michael Leuschel committed
155
156
157
158
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
159
160
161
162
163
164
165
166
   "source": [
    "δ(z1,1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
Michael Leuschel's avatar
Michael Leuschel committed
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
    "Da $z2\\in F$ ein Endzustand ist, akzeptiert der DFA das Wort $01$ (oder $[0,1]$ in der Notation vom Notebook).\n",
    "\n",
    "\n",
    "### Arbeitsweise eines DFAs\n",
    "\n",
    "Ein DFA $M= (\\Sigma, Z, \\delta , z_0, F)$ akzeptiert bzw. verwirft  eine\n",
    "Eingabe $x$ wie folgt:\n",
    "* $M$ beginnt beim Anfangszustand $z_0$ und führt insgesamt $|x|$ Schritte aus.\n",
    "* Der Lesekopf wandert dabei v.l.n.r. über das Eingabewort $x$, Symbol\n",
    "  für Symbol, und ändert dabei seinen Zustand jeweils gemäß der\n",
    "  Überführungsfunktion $\\delta$:\n",
    "  Ist $M$ im Zustand $z \\in Z$ und liest das\n",
    "  Symbol $a \\in \\Sigma$ und gilt $\\delta(z,a) = z'$, so ändert $M$ seinen\n",
    "  Zustand in $z'$.\n",
    "* Ist der letzte erreichte Zustand (nachdem $x$ abgearbeitet ist)\n",
    " * ein  Endzustand, so akzeptiert $M$ die Eingabe $x$;\n",
    " * andernfalls lehnt $M$ sie ab.\n",
    "\n",
    "![Arbeitsweise](./img/endl_auto.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Da in diesem Automaten z0 kein Endzustand ist, wird zum Beispiel das leere Wort abgelehnt:"
   ]
  },
  {
   "cell_type": "code",
197
   "execution_count": 5,
Michael Leuschel's avatar
Michael Leuschel committed
198
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
199
200
201
202
203
204
205
206
207
208
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "$\\mathit{FALSE}$"
      ],
      "text/plain": [
       "FALSE"
      ]
     },
209
     "execution_count": 5,
Michael Leuschel's avatar
Michael Leuschel committed
210
211
212
213
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
214
215
   "source": [
    "z0 ∈ F"
Michael Leuschel's avatar
Michael Leuschel committed
216
217
218
219
220
221
222
223
224
225
226
227
228
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Zustandgraph\n",
    "\n",
    "Man kann den DFA auch grafisch darstellen: Endzustände sind mit einem doppelten Kreis gekennzeichnet, der Anfangszustand wird durch eine besondere Startkante gekennzeichnet.\n",
    "\n",
    "Formal ist dies so definiert:\n",
    "Ein DFA $M= (\\Sigma, Z, \\delta , z_0, F)$ lässt sich anschaulich durch \n",
    "seinen __Zustandsgraphen__ darstellen,\n",
Michael Leuschel's avatar
Michael Leuschel committed
229
    "\n",
Michael Leuschel's avatar
Michael Leuschel committed
230
    "* dessen Knoten die Zustände von $M$ und\n",
Michael Leuschel's avatar
Michael Leuschel committed
231
232
233
    "* dessen Kanten Zustandsübergänge gemäß der\n",
    "  Überführungsfunktion $\\delta$ repräsentieren.\n",
    "* Gilt $\\delta(z,a) = z'$ für ein Symbol $a \\in \\Sigma$ und für\n",
Michael Leuschel's avatar
Michael Leuschel committed
234
    "  zwei Zustände $z, z' \\in Z$, so hat dieser Graph eine gerichtete\n",
Michael Leuschel's avatar
Michael Leuschel committed
235
    "  Kante von $z$ nach $z'$, die mit $a$ beschriftet ist.\n",
Michael Leuschel's avatar
Michael Leuschel committed
236
237
238
239
    "* Der Startzustand wird durch einen Pfeil auf $z_0$ dargestellt.\n",
    "* Endzustände sind durch einen Doppelkreis markiert.\n",
    "\n",
    "Für den Automaten oben ergiebt dies folgenden Zustandsgraphen.\n",
Michael Leuschel's avatar
Michael Leuschel committed
240
    "(Anmerkung: diese Darstellung erfordert eine neue Version des ProB-Jupyter-Kernels. Falls diese bei ihnen nicht funktioniert schauen Sie sich die Abbildung auf den Folien an)."
Michael Leuschel's avatar
Michael Leuschel committed
241
242
243
244
   ]
  },
  {
   "cell_type": "code",
245
   "execution_count": 6,
Michael Leuschel's avatar
Michael Leuschel committed
246
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
247
248
249
250
251
252
253
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
254
       "<!-- Generated by graphviz version 2.44.1 (0)\n",
Michael Leuschel's avatar
Michael Leuschel committed
255
256
       " -->\n",
       "<!-- Title: prob_graph Pages: 1 -->\n",
257
258
259
       "<svg width=\"540pt\" height=\"716pt\"\n",
       " viewBox=\"0.00 0.00 540.00 716.10\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(0.98 0.98) rotate(0) translate(4 726.01)\">\n",
Michael Leuschel's avatar
Michael Leuschel committed
260
       "<title>prob_graph</title>\n",
261
       "<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-726.01 546.49,-726.01 546.49,4 -4,4\"/>\n",
Michael Leuschel's avatar
Michael Leuschel committed
262
       "<!-- 0 -->\n",
263
264
265
266
267
       "<g id=\"node1\" class=\"node\">\n",
       "<title>0</title>\n",
       "<ellipse fill=\"lightgrey\" stroke=\"black\" cx=\"59.74\" cy=\"-56\" rx=\"18.44\" ry=\"18.44\"/>\n",
       "<ellipse fill=\"none\" stroke=\"black\" cx=\"59.74\" cy=\"-56\" rx=\"22.44\" ry=\"22.44\"/>\n",
       "<text text-anchor=\"middle\" x=\"59.74\" y=\"-52.9\" font-family=\"Times,serif\" font-size=\"12.00\">z2</text>\n",
Michael Leuschel's avatar
Michael Leuschel committed
268
269
       "</g>\n",
       "<!-- 0&#45;&gt;0 -->\n",
270
271
272
273
274
       "<g id=\"edge3\" class=\"edge\">\n",
       "<title>0&#45;&gt;0</title>\n",
       "<path fill=\"none\" stroke=\"green\" d=\"M79.72,-66.43C90.44,-68.2 100.2,-64.72 100.2,-56 100.2,-50.28 96,-46.81 90.08,-45.61\"/>\n",
       "<polygon fill=\"green\" stroke=\"green\" points=\"89.74,-42.11 79.72,-45.57 89.71,-49.11 89.74,-42.11\"/>\n",
       "<text text-anchor=\"middle\" x=\"104.2\" y=\"-52.9\" font-family=\"Times,serif\" font-size=\"12.00\">1</text>\n",
Michael Leuschel's avatar
Michael Leuschel committed
275
276
       "</g>\n",
       "<!-- 0&#45;&gt;0 -->\n",
277
278
279
280
281
       "<g id=\"edge7\" class=\"edge\">\n",
       "<title>0&#45;&gt;0</title>\n",
       "<path fill=\"none\" stroke=\"red\" d=\"M75.9,-71.61C95.36,-83.41 118.2,-78.2 118.2,-56 118.2,-37.27 101.94,-30.63 85.17,-36.1\"/>\n",
       "<polygon fill=\"red\" stroke=\"red\" points=\"83.51,-33.02 75.9,-40.39 86.44,-39.37 83.51,-33.02\"/>\n",
       "<text text-anchor=\"middle\" x=\"122.2\" y=\"-52.9\" font-family=\"Times,serif\" font-size=\"12.00\">0</text>\n",
Michael Leuschel's avatar
Michael Leuschel committed
282
283
       "</g>\n",
       "<!-- 1 -->\n",
284
285
286
287
       "<g id=\"node2\" class=\"node\">\n",
       "<title>1</title>\n",
       "<ellipse fill=\"lightgrey\" stroke=\"black\" cx=\"282.74\" cy=\"-494\" rx=\"18.44\" ry=\"18.44\"/>\n",
       "<text text-anchor=\"middle\" x=\"282.74\" y=\"-490.9\" font-family=\"Times,serif\" font-size=\"12.00\">z0</text>\n",
Michael Leuschel's avatar
Michael Leuschel committed
288
289
       "</g>\n",
       "<!-- 2 -->\n",
290
291
292
293
       "<g id=\"node3\" class=\"node\">\n",
       "<title>2</title>\n",
       "<ellipse fill=\"lightgrey\" stroke=\"black\" cx=\"211.74\" cy=\"-280\" rx=\"18.44\" ry=\"18.44\"/>\n",
       "<text text-anchor=\"middle\" x=\"211.74\" y=\"-276.9\" font-family=\"Times,serif\" font-size=\"12.00\">z1</text>\n",
Michael Leuschel's avatar
Michael Leuschel committed
294
295
       "</g>\n",
       "<!-- 1&#45;&gt;2 -->\n",
296
297
298
299
300
       "<g id=\"edge5\" class=\"edge\">\n",
       "<title>1&#45;&gt;2</title>\n",
       "<path fill=\"none\" stroke=\"red\" d=\"M277.17,-476.36C264.88,-439.69 235.39,-351.63 220.56,-307.36\"/>\n",
       "<polygon fill=\"red\" stroke=\"red\" points=\"223.87,-306.22 217.38,-297.85 217.24,-308.45 223.87,-306.22\"/>\n",
       "<text text-anchor=\"middle\" x=\"253.74\" y=\"-383.9\" font-family=\"Times,serif\" font-size=\"12.00\">0</text>\n",
Michael Leuschel's avatar
Michael Leuschel committed
301
302
       "</g>\n",
       "<!-- 3 -->\n",
303
304
305
306
       "<g id=\"node4\" class=\"node\">\n",
       "<title>3</title>\n",
       "<ellipse fill=\"lightgrey\" stroke=\"black\" cx=\"354.74\" cy=\"-56\" rx=\"18.44\" ry=\"18.44\"/>\n",
       "<text text-anchor=\"middle\" x=\"354.74\" y=\"-52.9\" font-family=\"Times,serif\" font-size=\"12.00\">z3</text>\n",
Michael Leuschel's avatar
Michael Leuschel committed
307
308
       "</g>\n",
       "<!-- 1&#45;&gt;3 -->\n",
309
310
311
312
313
       "<g id=\"edge1\" class=\"edge\">\n",
       "<title>1&#45;&gt;3</title>\n",
       "<path fill=\"none\" stroke=\"green\" d=\"M285.6,-475.64C296.67,-408.64 336.64,-166.59 350.2,-84.47\"/>\n",
       "<polygon fill=\"green\" stroke=\"green\" points=\"353.69,-84.85 351.86,-74.41 346.78,-83.71 353.69,-84.85\"/>\n",
       "<text text-anchor=\"middle\" x=\"324.74\" y=\"-276.9\" font-family=\"Times,serif\" font-size=\"12.00\">1</text>\n",
Michael Leuschel's avatar
Michael Leuschel committed
314
315
       "</g>\n",
       "<!-- 2&#45;&gt;0 -->\n",
316
317
318
319
320
       "<g id=\"edge2\" class=\"edge\">\n",
       "<title>2&#45;&gt;0</title>\n",
       "<path fill=\"none\" stroke=\"green\" d=\"M201.76,-264.43C176.57,-227.64 110.09,-130.55 77.82,-83.42\"/>\n",
       "<polygon fill=\"green\" stroke=\"green\" points=\"80.57,-81.23 72.03,-74.96 74.79,-85.18 80.57,-81.23\"/>\n",
       "<text text-anchor=\"middle\" x=\"144.74\" y=\"-169.9\" font-family=\"Times,serif\" font-size=\"12.00\">1</text>\n",
Michael Leuschel's avatar
Michael Leuschel committed
321
322
       "</g>\n",
       "<!-- 2&#45;&gt;3 -->\n",
323
324
325
326
327
       "<g id=\"edge6\" class=\"edge\">\n",
       "<title>2&#45;&gt;3</title>\n",
       "<path fill=\"none\" stroke=\"red\" d=\"M221.34,-264.09C245.71,-226.25 310.11,-126.28 339.6,-80.5\"/>\n",
       "<polygon fill=\"red\" stroke=\"red\" points=\"342.7,-82.15 345.17,-71.85 336.82,-78.36 342.7,-82.15\"/>\n",
       "<text text-anchor=\"middle\" x=\"287.74\" y=\"-169.9\" font-family=\"Times,serif\" font-size=\"12.00\">0</text>\n",
Michael Leuschel's avatar
Michael Leuschel committed
328
329
       "</g>\n",
       "<!-- 3&#45;&gt;3 -->\n",
330
331
332
333
334
       "<g id=\"edge4\" class=\"edge\">\n",
       "<title>3&#45;&gt;3</title>\n",
       "<path fill=\"none\" stroke=\"green\" d=\"M370.48,-65.92C380.98,-68.71 391.2,-65.4 391.2,-56 391.2,-49.83 386.8,-46.29 380.81,-45.37\"/>\n",
       "<polygon fill=\"green\" stroke=\"green\" points=\"380.21,-41.9 370.48,-46.08 380.7,-48.88 380.21,-41.9\"/>\n",
       "<text text-anchor=\"middle\" x=\"395.2\" y=\"-52.9\" font-family=\"Times,serif\" font-size=\"12.00\">1</text>\n",
Michael Leuschel's avatar
Michael Leuschel committed
335
336
       "</g>\n",
       "<!-- 3&#45;&gt;3 -->\n",
337
338
339
340
341
       "<g id=\"edge8\" class=\"edge\">\n",
       "<title>3&#45;&gt;3</title>\n",
       "<path fill=\"none\" stroke=\"red\" d=\"M367.32,-69.88C385.92,-83.85 409.2,-79.22 409.2,-56 409.2,-36.41 392.63,-30.05 376.27,-36.93\"/>\n",
       "<polygon fill=\"red\" stroke=\"red\" points=\"374.22,-34.08 367.32,-42.12 377.73,-40.14 374.22,-34.08\"/>\n",
       "<text text-anchor=\"middle\" x=\"413.2\" y=\"-52.9\" font-family=\"Times,serif\" font-size=\"12.00\">0</text>\n",
Michael Leuschel's avatar
Michael Leuschel committed
342
343
       "</g>\n",
       "<!-- 4 -->\n",
344
345
       "<g id=\"node5\" class=\"node\">\n",
       "<title>4</title>\n",
Michael Leuschel's avatar
Michael Leuschel committed
346
347
       "</g>\n",
       "<!-- 4&#45;&gt;1 -->\n",
348
349
350
351
       "<g id=\"edge9\" class=\"edge\">\n",
       "<title>4&#45;&gt;1</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M282.74,-658.97C282.74,-627.73 282.74,-561 282.74,-523\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"286.24,-522.65 282.74,-512.65 279.24,-522.65 286.24,-522.65\"/>\n",
Michael Leuschel's avatar
Michael Leuschel committed
352
353
354
355
356
357
358
359
       "</g>\n",
       "</g>\n",
       "</svg>"
      ],
      "text/plain": [
       "<Dot visualization: custom_graph []>"
      ]
     },
360
     "execution_count": 6,
Michael Leuschel's avatar
Michael Leuschel committed
361
362
363
364
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
   "source": [
    ":dot custom_graph"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Erweiterte Überführungsfunktion und akzeptierte Sprache\n",
    "\n",
    "Wir hatten gesehen, dass der Automat von $z0$ bei der Eingabe von $0$ nach $z1=\\delta(z0,0)$\n",
    "wechselt und nach einer weiteren Eingabe von $1$ in den Zustand $z2 = \\delta(z1,1)$ wechselt.\n",
    "Den aktuellen Zustand nach der Eingabe von dem Wort $01$ kann man also so berechnen: "
   ]
  },
  {
   "cell_type": "code",
382
   "execution_count": 7,
Michael Leuschel's avatar
Michael Leuschel committed
383
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
384
385
386
387
388
389
390
391
392
393
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "$\\mathit{z2}$"
      ],
      "text/plain": [
       "z2"
      ]
     },
394
     "execution_count": 7,
Michael Leuschel's avatar
Michael Leuschel committed
395
396
397
398
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
399
400
401
402
403
404
405
406
407
408
409
410
411
   "source": [
    "δ(δ(z0,0),1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Dies führt zu der folgenden Definition, mit der man den Zustand nach einer beliebigen Folge von Eingabesymbolen berechnen kann:\n",
    "\n",
    "Sei $M = (\\Sigma, Z, \\delta , z_0, F)$  ein DFA.\n",
    "Die __erweiterte Überführungsfunktion \n",
    "$\\widehat{\\delta} : Z \\times \\Sigma^* \\rightarrow Z$ von $M$ ist induktiv definiert:\n",
Michael Leuschel's avatar
Michael Leuschel committed
412
413
    "* $\\widehat{\\delta}(z, \\lambda)  =  z$\n",
    "* $\\widehat{\\delta}(z, ax)       =  \\widehat{\\delta}(\\delta(z,a), x) $\n",
Michael Leuschel's avatar
Michael Leuschel committed
414
415
416
417
418
419
420
421
422
423
424
    "für alle $z \\in Z$, $a \\in \\Sigma$ und $x \\in \\Sigma^*$.\n",
    "\n",
    "Die vom DFA $M$ __akzeptierte Sprache__ ist definiert durch\n",
    "* $L(M) = \\{w \\in \\Sigma^* \\Longleftrightarrow \\widehat{\\delta}(z_0,w) \\in F\\}$\n",
    "\n",
    "Diese Definitionen sind in der folgenden B Maschine umgesetzt.\n",
    "$\\widehat{\\delta}$ wird durch die rekursive Funktion $\\delta s$ dargestellt."
   ]
  },
  {
   "cell_type": "code",
425
   "execution_count": 8,
Michael Leuschel's avatar
Michael Leuschel committed
426
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
427
428
429
430
431
432
433
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Loaded machine: DFA"
      ]
     },
434
     "execution_count": 8,
Michael Leuschel's avatar
Michael Leuschel committed
435
436
437
438
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
   "source": [
    "::load\n",
    "MACHINE DFA\n",
    "SETS\n",
    "   Z = {z0,z1,z2,z3}\n",
    "ABSTRACT_CONSTANTS δs, L\n",
    "CONSTANTS Σ, F, δ\n",
    "PROPERTIES\n",
    " F ⊆ Z ∧ δ ∈ (Z×Σ) → Z ∧\n",
    "\n",
    " /* Definition der erweiterten Überführungsfunktion */\n",
    " δs ∈ (Z×seq(Σ)) → Z ∧\n",
    " δs = λ(z,s).(z∈Z ∧ s∈seq(Σ) | \n",
    "           IF s=[] THEN z\n",
    "           ELSE         δs(δ(z,first(s)),tail(s)) END)\n",
    " ∧\n",
    " /* Die vom Automaten akzeptierte Sprache L */\n",
    " L = {ω|ω∈seq(Σ) ∧ δs(z0,ω) ∈ F}\n",
    " ∧\n",
    " /* Der Automat von Folie 10: */\n",
    " Σ = {0,1} ∧\n",
    " F = {z2} ∧\n",
    " δ = {     (z0,0)↦z1, (z0,1)↦z3,\n",
    "           (z1,0)↦z3, (z1,1)↦z2,\n",
    "           (z2,0)↦z2, (z2,1)↦z2,\n",
    "           (z3,0)↦z3, (z3,1)↦z3 }\n",
    "DEFINITIONS\n",
    "  CUSTOM_GRAPH_NODES1 == rec(shape:\"doublecircle\",nodes:F);\n",
    "  CUSTOM_GRAPH_NODES2 == rec(shape:\"circle\",nodes:Z\\F);\n",
    "  CUSTOM_GRAPH_NODES3 == rec(shape:\"none\",color:\"white\",style:\"none\",nodes:{\"\"});\n",
    "  CUSTOM_GRAPH_EDGES1 == rec(color:\"red\",label:\"0\",edges:{a,b|(a,0)|->b:δ});\n",
    "  CUSTOM_GRAPH_EDGES2 == rec(color:\"green\",label:\"1\",edges:{a,b|(a,1)|->b:δ});\n",
    "  CUSTOM_GRAPH_EDGES3 == rec(color:\"black\",label:\"\",edges:{\"\" |-> z0})\n",
    "END"
   ]
  },
  {
   "cell_type": "code",
477
   "execution_count": 9,
Michael Leuschel's avatar
Michael Leuschel committed
478
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
479
480
481
482
483
484
485
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Machine constants set up using operation 0: $setup_constants()"
      ]
     },
486
     "execution_count": 9,
Michael Leuschel's avatar
Michael Leuschel committed
487
488
489
490
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
491
492
493
494
495
496
497
498
499
500
501
502
503
   "source": [
    ":constants"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Man kann mit der erweiterten Überführungsfunktion den Zustand nach der Eingabe [0,1] so bestimmen:"
   ]
  },
  {
   "cell_type": "code",
504
   "execution_count": 10,
Michael Leuschel's avatar
Michael Leuschel committed
505
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
506
507
508
509
510
511
512
513
514
515
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "$\\mathit{z2}$"
      ],
      "text/plain": [
       "z2"
      ]
     },
516
     "execution_count": 10,
Michael Leuschel's avatar
Michael Leuschel committed
517
518
519
520
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
521
522
523
524
525
526
527
528
   "source": [
    "δs(z0,[0,1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
Michael Leuschel's avatar
Michael Leuschel committed
529
    "Da $z2\\in F$ gilt:"
Michael Leuschel's avatar
Michael Leuschel committed
530
531
532
533
   ]
  },
  {
   "cell_type": "code",
534
   "execution_count": 11,
Michael Leuschel's avatar
Michael Leuschel committed
535
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
536
537
538
539
540
541
542
543
544
545
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "$\\mathit{TRUE}$"
      ],
      "text/plain": [
       "TRUE"
      ]
     },
546
     "execution_count": 11,
Michael Leuschel's avatar
Michael Leuschel committed
547
548
549
550
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
551
552
553
554
555
556
   "source": [
    "[0,1] ∈ L"
   ]
  },
  {
   "cell_type": "code",
557
   "execution_count": 12,
Michael Leuschel's avatar
Michael Leuschel committed
558
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
559
560
561
562
563
564
565
566
567
568
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "$\\mathit{z3}$"
      ],
      "text/plain": [
       "z3"
      ]
     },
569
     "execution_count": 12,
Michael Leuschel's avatar
Michael Leuschel committed
570
571
572
573
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
574
575
576
577
578
579
580
581
582
583
584
585
586
   "source": [
    "δs(z0,[1,0])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Da $z3\\not\\in F$"
   ]
  },
  {
   "cell_type": "code",
587
   "execution_count": 13,
Michael Leuschel's avatar
Michael Leuschel committed
588
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
589
590
591
592
593
594
595
596
597
598
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "$\\mathit{FALSE}$"
      ],
      "text/plain": [
       "FALSE"
      ]
     },
599
     "execution_count": 13,
Michael Leuschel's avatar
Michael Leuschel committed
600
601
602
603
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
604
605
606
607
608
609
610
611
612
613
614
615
616
   "source": [
    "[1,0] ∈ L"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Hier sind die Wörter der Länge 3 und 4 die vom DFA akzeptiert werden:"
   ]
  },
  {
   "cell_type": "code",
617
   "execution_count": 14,
Michael Leuschel's avatar
Michael Leuschel committed
618
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "|w1|w2|w3|\n",
       "|---|---|---|\n",
       "|$0$|$1$|$0$|\n",
       "|$0$|$1$|$1$|\n"
      ],
      "text/plain": [
       "w1\tw2\tw3\n",
       "0\t1\t0\n",
       "0\t1\t1\n"
      ]
     },
634
     "execution_count": 14,
Michael Leuschel's avatar
Michael Leuschel committed
635
636
637
638
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
639
640
641
642
643
644
   "source": [
    ":table {w1,w2,w3| [w1,w2,w3] : L}"
   ]
  },
  {
   "cell_type": "code",
645
   "execution_count": 15,
Michael Leuschel's avatar
Michael Leuschel committed
646
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "|w1|w2|w3|w4|\n",
       "|---|---|---|---|\n",
       "|$0$|$1$|$0$|$0$|\n",
       "|$0$|$1$|$0$|$1$|\n",
       "|$0$|$1$|$1$|$0$|\n",
       "|$0$|$1$|$1$|$1$|\n"
      ],
      "text/plain": [
       "w1\tw2\tw3\tw4\n",
       "0\t1\t0\t0\n",
       "0\t1\t0\t1\n",
       "0\t1\t1\t0\n",
       "0\t1\t1\t1\n"
      ]
     },
666
     "execution_count": 15,
Michael Leuschel's avatar
Michael Leuschel committed
667
668
669
670
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
671
672
673
674
675
676
677
678
679
   "source": [
    ":table {w1,w2,w3,w4| [w1,w2,w3,w4] : L}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Anmerkung:\n",
680
681
    "\n",
    "Für $a \\in \\Sigma$ gilt $\\widehat{\\delta}(z, a) = \\delta(z, a)$, und für $x = a_1 a_2 \\cdots a_n$ in $\\Sigma^*$ gilt:\n",
Michael Leuschel's avatar
Michael Leuschel committed
682
683
684
685
686
687
688
    "* $\\widehat{\\delta}(z, x) = \\delta( \\cdots \\delta(\\delta(z, a_1), a_2)\\cdots , a_n).$\n",
    "\n",
    "Zum Beispiel:"
   ]
  },
  {
   "cell_type": "code",
689
   "execution_count": 16,
Michael Leuschel's avatar
Michael Leuschel committed
690
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
691
692
693
694
695
696
697
698
699
700
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "$\\mathit{z2}$"
      ],
      "text/plain": [
       "z2"
      ]
     },
701
     "execution_count": 16,
Michael Leuschel's avatar
Michael Leuschel committed
702
703
704
705
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
706
707
708
709
710
711
712
713
714
715
716
717
718
   "source": [
    "δs(z0,[0,1,1,1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "ist identisch zu:"
   ]
  },
  {
   "cell_type": "code",
719
   "execution_count": 17,
Michael Leuschel's avatar
Michael Leuschel committed
720
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
721
722
723
724
725
726
727
728
729
730
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "$\\mathit{z2}$"
      ],
      "text/plain": [
       "z2"
      ]
     },
731
     "execution_count": 17,
Michael Leuschel's avatar
Michael Leuschel committed
732
733
734
735
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
736
737
738
739
740
741
742
743
744
745
746
747
748
   "source": [
    "δ(δ(δ(δ(z0,0),1),1),1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Was man schrittweise ausrechnen kann:"
   ]
  },
  {
   "cell_type": "code",
749
   "execution_count": 18,
Michael Leuschel's avatar
Michael Leuschel committed
750
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
751
752
753
754
755
756
757
758
759
760
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "$\\mathit{z2}$"
      ],
      "text/plain": [
       "z2"
      ]
     },
761
     "execution_count": 18,
Michael Leuschel's avatar
Michael Leuschel committed
762
763
764
765
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
766
767
768
769
770
771
   "source": [
    "δ(δ(δ(z1,1),1),1)"
   ]
  },
  {
   "cell_type": "code",
772
   "execution_count": 19,
Michael Leuschel's avatar
Michael Leuschel committed
773
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
774
775
776
777
778
779
780
781
782
783
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "$\\mathit{z2}$"
      ],
      "text/plain": [
       "z2"
      ]
     },
784
     "execution_count": 19,
Michael Leuschel's avatar
Michael Leuschel committed
785
786
787
788
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
789
790
791
792
793
794
   "source": [
    "δ(δ(z2,1),1)"
   ]
  },
  {
   "cell_type": "code",
795
   "execution_count": 20,
Michael Leuschel's avatar
Michael Leuschel committed
796
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
797
798
799
800
801
802
803
804
805
806
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "$\\mathit{z2}$"
      ],
      "text/plain": [
       "z2"
      ]
     },
807
     "execution_count": 20,
Michael Leuschel's avatar
Michael Leuschel committed
808
809
810
811
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
812
813
814
815
   "source": [
    "δ(z2,1)"
   ]
  },
Michael Leuschel's avatar
Michael Leuschel committed
816
817
818
819
820
821
822
823
824
825
826
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Der Automat oben akzeptiert alle Wörter die mit 01 beginnen.\n",
    "\n",
    "Unten zeigen wir noch ein weiteres Beispiel.\n"
   ]
  },
  {
   "cell_type": "code",
827
   "execution_count": 21,
Michael Leuschel's avatar
Michael Leuschel committed
828
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
829
830
831
832
833
834
835
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Loaded machine: DFA"
      ]
     },
836
     "execution_count": 21,
Michael Leuschel's avatar
Michael Leuschel committed
837
838
839
840
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
   "source": [
    "::load\n",
    "MACHINE DFA\n",
    "SETS\n",
    "   Z = {z0,z1,z2}\n",
    "ABSTRACT_CONSTANTS δs, L\n",
    "CONSTANTS Σ, F, δ\n",
    "PROPERTIES\n",
    " F ⊆ Z ∧ δ ∈ (Z×Σ) → Z ∧\n",
    "\n",
    " /* Definition der erweiterten Überführungsfunktion */\n",
    " δs ∈ (Z×seq(Σ)) → Z ∧\n",
    " δs = λ(z,s).(z∈Z ∧ s∈seq(Σ) | \n",
    "           IF s=[] THEN z\n",
    "           ELSE         δs(δ(z,first(s)),tail(s)) END)\n",
    " ∧\n",
    " /* Die vom Automaten akzeptierte Sprache L */\n",
    " L = {ω|ω∈seq(Σ) ∧ δs(z0,ω) ∈ F}\n",
    " ∧\n",
    " Σ = {0,1} ∧\n",
    " F = {z0} ∧\n",
    " δ = {     (z0,0)↦z1, (z0,1)↦z2,\n",
    "           (z1,0)↦z2, (z1,1)↦z0,\n",
    "           (z2,0)↦z2, (z2,1)↦z2 }\n",
    "DEFINITIONS\n",
    "  CUSTOM_GRAPH_NODES1 == rec(shape:\"doublecircle\",nodes:F);\n",
    "  CUSTOM_GRAPH_NODES2 == rec(shape:\"circle\",nodes:Z\\F);\n",
    "  CUSTOM_GRAPH_NODES3 == rec(shape:\"none\",color:\"white\",style:\"none\",nodes:{\"\"});\n",
    "  CUSTOM_GRAPH_EDGES1 == rec(color:\"red\",label:\"0\",edges:{a,b|(a,0)|->b:δ});\n",
    "  CUSTOM_GRAPH_EDGES2 == rec(color:\"green\",label:\"1\",edges:{a,b|(a,1)|->b:δ});\n",
    "  CUSTOM_GRAPH_EDGES3 == rec(color:\"black\",label:\"\",edges:{\"\" |-> z0})\n",
    "END"
   ]
  },
  {
   "cell_type": "code",
877
   "execution_count": 22,
Michael Leuschel's avatar
Michael Leuschel committed
878
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
879
880
881
882
883
884
885
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Machine constants set up using operation 0: $setup_constants()"
      ]
     },
886
     "execution_count": 22,
Michael Leuschel's avatar
Michael Leuschel committed
887
888
889
890
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
891
892
893
894
895
896
897
898
899
900
901
902
903
904
   "source": [
    ":constants"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Dieser Automat akzeptiert zum Beispiel das leere Wort, da $z0 \\in F$.\n",
    "Er akzeptiert auch:"
   ]
  },
  {
   "cell_type": "code",
905
   "execution_count": 23,
Michael Leuschel's avatar
Michael Leuschel committed
906
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
907
908
909
910
911
912
913
914
915
916
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "$\\mathit{z0}$"
      ],
      "text/plain": [
       "z0"
      ]
     },
917
     "execution_count": 23,
Michael Leuschel's avatar
Michael Leuschel committed
918
919
920
921
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
922
923
924
925
926
927
928
929
930
931
932
933
934
   "source": [
    "δs(z0,[0,1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Er akzeptiert aber nicht das Wort [0]:"
   ]
  },
  {
   "cell_type": "code",
935
   "execution_count": 24,
Michael Leuschel's avatar
Michael Leuschel committed
936
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
937
938
939
940
941
942
943
944
945
946
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "$\\mathit{z1}$"
      ],
      "text/plain": [
       "z1"
      ]
     },
947
     "execution_count": 24,
Michael Leuschel's avatar
Michael Leuschel committed
948
949
950
951
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
952
953
954
955
956
957
   "source": [
    "δs(z0,[0])"
   ]
  },
  {
   "cell_type": "code",
958
   "execution_count": 25,
Michael Leuschel's avatar
Michael Leuschel committed
959
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
960
961
962
963
964
965
966
967
968
969
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "$\\mathit{TRUE}$"
      ],
      "text/plain": [
       "TRUE"
      ]
     },
970
     "execution_count": 25,
Michael Leuschel's avatar
Michael Leuschel committed
971
972
973
974
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
975
976
977
978
979
980
   "source": [
    "{[], [0,1], [0,1,0,1], [0,1,0,1,0,1]}  ⊆ L"
   ]
  },
  {
   "cell_type": "code",
981
   "execution_count": 26,
Michael Leuschel's avatar
Michael Leuschel committed
982
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
983
984
985
986
987
988
989
990
991
992
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "$\\mathit{FALSE}$"
      ],
      "text/plain": [
       "FALSE"
      ]
     },
993
     "execution_count": 26,
Michael Leuschel's avatar
Michael Leuschel committed
994
995
996
997
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
   "source": [
    "[0] ∈ L"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Der Zustandsgraph ist wie folgt:"
   ]
  },
Michael Leuschel's avatar
Michael Leuschel committed
1009
1010
  {
   "cell_type": "code",
1011
   "execution_count": 27,
Michael Leuschel's avatar
Michael Leuschel committed
1012
   "metadata": {},
Michael Leuschel's avatar
Michael Leuschel committed
1013
1014
1015
1016
1017
1018
1019
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
1020
       "<!-- Generated by graphviz version 2.44.1 (0)\n",
Michael Leuschel's avatar
Michael Leuschel committed
1021
1022
       " -->\n",
       "<!-- Title: prob_graph Pages: 1 -->\n",
1023
1024
1025
       "<svg width=\"540pt\" height=\"714pt\"\n",
       " viewBox=\"0.00 0.00 540.00 713.63\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(0.98 0.98) rotate(0) translate(4 726.01)\">\n",
Michael Leuschel's avatar
Michael Leuschel committed
1026
       "<title>prob_graph</title>\n",
1027
       "<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-726.01 548.39,-726.01 548.39,4 -4,4\"/>\n",
Michael Leuschel's avatar
Michael Leuschel committed
1028
       "<!-- 0 -->\n",
1029
1030
1031
1032
1033
       "<g id=\"node1\" class=\"node\">\n",
       "<title>0</title>\n",
       "<ellipse fill=\"lightgrey\" stroke=\"black\" cx=\"232.28\" cy=\"-484\" rx=\"18.44\" ry=\"18.44\"/>\n",
       "<ellipse fill=\"none\" stroke=\"black\" cx=\"232.28\" cy=\"-484\" rx=\"22.44\" ry=\"22.44\"/>\n",
       "<text text-anchor=\"middle\" x=\"232.28\" y=\"-480.9\" font-family=\"Times,serif\" font-size=\"12.00\">z0</text>\n",
Michael Leuschel's avatar
Michael Leuschel committed
1034
1035
       "</g>\n",
       "<!-- 1 -->\n",
1036
1037
1038
1039
       "<g id=\"node2\" class=\"node\">\n",
       "<title>1</title>\n",
       "<ellipse fill=\"lightgrey\" stroke=\"black\" cx=\"86.28\" cy=\"-260\" rx=\"18.44\" ry=\"18.44\"/>\n",
       "<text text-anchor=\"middle\" x=\"86.28\" y=\"-256.9\" font-family=\"Times,serif\" font-size=\"12.00\">z1</text>\n",
Michael Leuschel's avatar
Michael Leuschel committed
1040
1041
       "</g>\n",
       "<!-- 0&#45;&gt;1 -->\n",
1042
1043
1044
1045
1046
       "<g id=\"edge4\" class=\"edge\">\n",
       "<title>0&#45;&gt;1</title>\n",
       "<path fill=\"none\" stroke=\"red\" d=\"M217.23,-466.78C198.51,-446.12 166.22,-408.84 143.28,-373.5 124.82,-345.06 107.83,-309.85 97.3,-286.48\"/>\n",
       "<polygon fill=\"red\" stroke=\"red\" points=\"100.45,-284.96 93.19,-277.24 94.05,-287.8 100.45,-284.96\"/>\n",
       "<text text-anchor=\"middle\" x=\"147.28\" y=\"-363.9\" font-family=\"Times,serif\" font-size=\"12.00\">0</text>\n",
Michael Leuschel's avatar
Michael Leuschel committed
1047
1048
       "</g>\n",
       "<!-- 2 -->\n",
1049
1050
1051
1052
       "<g id=\"node3\" class=\"node\">\n",
       "<title>2</title>\n",
       "<ellipse fill=\"lightgrey\" stroke=\"black\" cx=\"213.28\" cy=\"-46\" rx=\"18.44\" ry=\"18.44\"/>\n",
       "<text text-anchor=\"middle\" x=\"213.28\" y=\"-42.9\" font-family=\"Times,serif\" font-size=\"12.00\">z2</text>\n",
Michael Leuschel's avatar
Michael Leuschel committed
1053
1054
       "</g>\n",
       "<!-- 0&#45;&gt;2 -->\n",
1055
1056
1057
1058
1059
       "<g id=\"edge1\" class=\"edge\">\n",
       "<title>0&#45;&gt;2</title>\n",
       "<path fill=\"none\" stroke=\"green\" d=\"M231.34,-461.38C228.19,-389.17 218.05,-156.34 214.51,-75.2\"/>\n",
       "<polygon fill=\"green\" stroke=\"green\" points=\"217.99,-74.63 214.06,-64.79 211,-74.94 217.99,-74.63\"/>\n",
       "<text text-anchor=\"middle\" x=\"227.28\" y=\"-256.9\" font-family=\"Times,serif\" font-size=\"12.00\">1</text>\n",
Michael Leuschel's avatar
Michael Leuschel committed
1060
1061
       "</g>\n",
       "<!-- 1&#45;&gt;0 -->\n",
1062
1063
1064
1065
1066
       "<g id=\"edge2\" class=\"edge\">\n",
       "<title>1&#45;&gt;0</title>\n",
       "<path fill=\"none\" stroke=\"green\" d=\"M96.04,-275.83C120.33,-312.77 183.8,-409.27 214.77,-456.37\"/>\n",
       "<polygon fill=\"green\" stroke=\"green\" points=\"211.92,-458.4 220.33,-464.83 217.76,-454.55 211.92,-458.4\"/>\n",
       "<text text-anchor=\"middle\" x=\"163.28\" y=\"-363.9\" font-family=\"Times,serif\" font-size=\"12.00\">1</text>\n",
Michael Leuschel's avatar
Michael Leuschel committed
1067
1068
       "</g>\n",
       "<!-- 1&#45;&gt;2 -->\n",
1069
1070
1071
1072
1073
       "<g id=\"edge5\" class=\"edge\">\n",
       "<title>1&#45;&gt;2</title>\n",
       "<path fill=\"none\" stroke=\"red\" d=\"M95.42,-243.75C117.29,-207.24 172.82,-114.54 199.09,-70.69\"/>\n",
       "<polygon fill=\"red\" stroke=\"red\" points=\"202.1,-72.49 204.23,-62.11 196.09,-68.89 202.1,-72.49\"/>\n",
       "<text text-anchor=\"middle\" x=\"158.28\" y=\"-149.9\" font-family=\"Times,serif\" font-size=\"12.00\">0</text>\n",
Michael Leuschel's avatar
Michael Leuschel committed
1074
1075
       "</g>\n",
       "<!-- 2&#45;&gt;2 -->\n",
1076
1077
1078
1079
1080
       "<g id=\"edge3\" class=\"edge\">\n",
       "<title>2&#45;&gt;2</title>\n",
       "<path fill=\"none\" stroke=\"green\" d=\"M229.41,-55.15C239.77,-57.54 249.75,-54.49 249.75,-46 249.75,-40.43 245.45,-37.2 239.57,-36.31\"/>\n",
       "<polygon fill=\"green\" stroke=\"green\" points=\"239.21,-32.83 229.41,-36.85 239.58,-39.82 239.21,-32.83\"/>\n",
       "<text text-anchor=\"middle\" x=\"253.75\" y=\"-42.9\" font-family=\"Times,serif\" font-size=\"12.00\">1</text>\n",
Michael Leuschel's avatar
Michael Leuschel committed
1081
1082
       "</g>\n",
       "<!-- 2&#45;&gt;2 -->\n",
1083
1084
1085
1086
1087
       "<g id=\"edge6\" class=\"edge\">\n",
       "<title>2&#45;&gt;2</title>\n",
       "<path fill=\"none\" stroke=\"red\" d=\"M226.41,-59.05C244.92,-71.36 267.75,-67.01 267.75,-46 267.75,-28.43 251.79,-22.51 235.75,-28.23\"/>\n",
       "<polygon fill=\"red\" stroke=\"red\" points=\"233.76,-25.32 226.41,-32.95 236.91,-31.57 233.76,-25.32\"/>\n",
       "<text text-anchor=\"middle\" x=\"271.75\" y=\"-42.9\" font-family=\"Times,serif\" font-size=\"12.00\">0</text>\n",
Michael Leuschel's avatar
Michael Leuschel committed
1088
1089
       "</g>\n",
       "<!-- 3 -->\n",
1090
1091
       "<g id=\"node4\" class=\"node\">\n",
       "<title>3</title>\n",
Michael Leuschel's avatar
Michael Leuschel committed
1092
1093
       "</g>\n",
       "<!-- 3&#45;&gt;0 -->\n",
1094
1095
1096
1097
       "<g id=\"edge7\" class=\"edge\">\n",
       "<title>3&#45;&gt;0</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M232.28,-658.71C232.28,-626.68 232.28,-557.66 232.28,-516.92\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"235.78,-516.73 232.28,-506.73 228.78,-516.73 235.78,-516.73\"/>\n",
Michael Leuschel's avatar
Michael Leuschel committed
1098
1099
1100
1101
1102
1103
1104
1105
       "</g>\n",
       "</g>\n",
       "</svg>"
      ],
      "text/plain": [
       "<Dot visualization: custom_graph []>"
      ]
     },
1106
     "execution_count": 27,
Michael Leuschel's avatar
Michael Leuschel committed
1107
1108
1109
1110
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Michael Leuschel's avatar
Michael Leuschel committed
1111
1112
1113
   "source": [
    ":dot custom_graph"
   ]
Michael Leuschel's avatar
Michael Leuschel committed
1114
1115
1116
1117
1118
1119
1120
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
Michael Leuschel's avatar
Michael Leuschel committed
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "ProB 2",
   "language": "prob",
   "name": "prob2"
  },
  "language_info": {
   "codemirror_mode": "prob2_jupyter_repl",
   "file_extension": ".prob",
   "mimetype": "text/x-prob2-jupyter-repl",
   "name": "prob"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}