diff --git a/info4/kapitel-1/Grammatiken.ipynb b/info4/kapitel-1/Grammatiken.ipynb index c136d3c456810956405a70c5a7d2e57c1c577b70..1ed187c67de310e6051920a1f79d8057a39d7df1 100644 --- a/info4/kapitel-1/Grammatiken.ipynb +++ b/info4/kapitel-1/Grammatiken.ipynb @@ -29,7 +29,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -38,7 +38,7 @@ "Loaded machine: Grammatik" ] }, - "execution_count": 1, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -65,7 +65,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -74,7 +74,7 @@ "Machine constants set up using operation 0: $setup_constants()" ] }, - "execution_count": 2, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -85,7 +85,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -103,7 +103,7 @@ "\tRHS = []" ] }, - "execution_count": 3, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -121,7 +121,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -133,13 +133,13 @@ "{[],[a,S,b]}" ] }, - "execution_count": 4, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "P[{[S]}]" + "P[{ [S] }]" ] }, { @@ -159,7 +159,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -168,7 +168,7 @@ "Loaded machine: Grammatik" ] }, - "execution_count": 5, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -199,7 +199,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -208,7 +208,7 @@ "Machine constants set up using operation 0: $setup_constants()" ] }, - "execution_count": 6, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -221,12 +221,35 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Da diese Relation unendlich ist wird diese im Notebook symbolisch gehalten. Wir können aber prüfen ob Paare an Folgen in der Relation sind:" + "Da diese Relation ```abl``` unendlich ist wird diese im Notebook symbolisch gehalten. Wir können aber prüfen ob Paare an Folgen in der Relation sind:" ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\newcommand{\\qdot}{\\mathord{\\mkern1mu\\cdot\\mkern1mu}}/*@symbolic*/ \\{\\mathit{u},\\mathit{v}\\mid\\exists(\\mathit{x},\\mathit{z},\\mathit{p},\\mathit{q})\\qdot(\\mathit{p} \\mapsto \\mathit{q} \\in \\{([S]\\mapsto []),([S]\\mapsto [a,\\mathit{S},b])\\} \\land \\mathit{u} = \\mathit{x} ⌒ \\mathit{p} ⌒ \\mathit{z} \\land \\mathit{v} = \\mathit{x} ⌒ \\mathit{q} ⌒ \\mathit{z})\\}$" + ], + "text/plain": [ + "/*@symbolic*/ {u,v∣∃(x,z,p,q)·(p ↦ q ∈ {([S]↦[]),([S]↦[a,S,b])} ∧ u = x ⌒ p ⌒ z ∧ v = x ⌒ q ⌒ z)}" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "abl" + ] + }, + { + "cell_type": "code", + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -238,18 +261,18 @@ "TRUE" ] }, - "execution_count": 7, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "[S] ↦ [a,S,b] ∈ abl" + "[a,S,b,S] ↦ [a,S,b,a,S,b] ∈ abl" ] }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -261,7 +284,7 @@ "FALSE" ] }, - "execution_count": 8, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -272,7 +295,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 15, "metadata": {}, "outputs": [ { @@ -290,13 +313,13 @@ "\tx = []" ] }, - "execution_count": 9, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "[S] ↦ x : abl" + "[S] ↦ x ∈ abl" ] }, { @@ -308,7 +331,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -320,36 +343,36 @@ "{[],[a,S,b]}" ] }, - "execution_count": 10, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "abl[ {[S]} ]" + "abl[ { [S] } ]" ] }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ - "$\\{[a,b],[a,\\mathit{a},\\mathit{S},\\mathit{b},b]\\}$" + "$\\{[a,\\mathit{b},S],[a,\\mathit{S},b],[a,\\mathit{S},\\mathit{b},\\mathit{a},\\mathit{S},b],[a,\\mathit{a},\\mathit{S},\\mathit{b},\\mathit{b},S]\\}$" ], "text/plain": [ - "{[a,b],[a,a,S,b,b]}" + "{[a,b,S],[a,S,b],[a,S,b,a,S,b],[a,a,S,b,b,S]}" ] }, - "execution_count": 11, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "abl[ {[a,S,b]} ]" + "abl[ {[a,S,b,S]} ]" ] }, { @@ -361,7 +384,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 19, "metadata": {}, "outputs": [ { @@ -373,7 +396,7 @@ "{[a,b],[a,a,S,b,b]}" ] }, - "execution_count": 12, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -384,7 +407,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 20, "metadata": {}, "outputs": [ { @@ -396,7 +419,7 @@ "{[a,a,b,b],[a,a,a,S,b,b,b]}" ] }, - "execution_count": 13, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -420,7 +443,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 23, "metadata": {}, "outputs": [ { @@ -432,7 +455,7 @@ "TRUE" ] }, - "execution_count": 14, + "execution_count": 23, "metadata": {}, "output_type": "execute_result" } @@ -450,7 +473,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 24, "metadata": {}, "outputs": [ { @@ -462,7 +485,7 @@ "{[S]}" ] }, - "execution_count": 15, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" } @@ -473,7 +496,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 25, "metadata": {}, "outputs": [ { @@ -485,7 +508,7 @@ "{[],[a,S,b]}" ] }, - "execution_count": 16, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } @@ -496,7 +519,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 26, "metadata": {}, "outputs": [ { @@ -508,7 +531,7 @@ "{[a,b],[a,a,S,b,b]}" ] }, - "execution_count": 17, + "execution_count": 26, "metadata": {}, "output_type": "execute_result" } @@ -519,7 +542,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 27, "metadata": {}, "outputs": [ { @@ -531,7 +554,7 @@ "{[a,a,b,b],[a,a,a,S,b,b,b]}" ] }, - "execution_count": 18, + "execution_count": 27, "metadata": {}, "output_type": "execute_result" } @@ -542,7 +565,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 28, "metadata": {}, "outputs": [ { @@ -554,7 +577,7 @@ "{[a,a,a,b,b,b],[a,a,a,a,S,b,b,b,b]}" ] }, - "execution_count": 19, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } @@ -577,7 +600,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 29, "metadata": {}, "outputs": [ { @@ -589,7 +612,7 @@ "{[],[a,b],[S],[a,a,b,b],[a,S,b],[a,a,a,b,b,b],[a,a,S,b,b],[a,a,a,S,b,b,b],[a,a,a,a,S,b,b,b,b]}" ] }, - "execution_count": 20, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } @@ -607,7 +630,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 30, "metadata": {}, "outputs": [ { @@ -619,7 +642,7 @@ "{[],[a,b],[a,a,b,b],[a,a,a,b,b,b]}" ] }, - "execution_count": 21, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } @@ -637,7 +660,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 31, "metadata": {}, "outputs": [ { @@ -649,7 +672,7 @@ "{[],[a,b],[S],[a,a,b,b],[a,S,b],[a,a,a,b,b,b],[a,a,S,b,b],[a,a,a,S,b,b,b],[a,a,a,a,S,b,b,b,b]}" ] }, - "execution_count": 22, + "execution_count": 31, "metadata": {}, "output_type": "execute_result" } @@ -660,7 +683,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 32, "metadata": {}, "outputs": [ { @@ -669,7 +692,7 @@ "Preference changed: DOT_DECOMPOSE_NODES = FALSE\n" ] }, - "execution_count": 23, + "execution_count": 32, "metadata": {}, "output_type": "execute_result" } @@ -680,7 +703,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 33, "metadata": {}, "outputs": [ { @@ -797,7 +820,7 @@ "<Dot visualization: expr_as_graph [SFSF={[],[a,b],[S],[a,a,b,b],[a,S,b],[a,a,a,b,b,b],[a,a,S,b,b],[a,a,a,S,b,b,b],[a,a,a,a,S,b,b,b,b]}(\"abl\",SF<|abl|>SF)]>" ] }, - "execution_count": 24, + "execution_count": 33, "metadata": {}, "output_type": "execute_result" } @@ -815,7 +838,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 34, "metadata": {}, "outputs": [ { @@ -824,7 +847,7 @@ "Loaded machine: Grammatik2" ] }, - "execution_count": 25, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } @@ -860,7 +883,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 35, "metadata": {}, "outputs": [ { @@ -869,7 +892,7 @@ "Machine constants set up using operation 0: $setup_constants()" ] }, - "execution_count": 26, + "execution_count": 35, "metadata": {}, "output_type": "execute_result" } @@ -880,7 +903,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 36, "metadata": {}, "outputs": [ { @@ -892,7 +915,7 @@ "{[S],[a,b,c],[a,b,C],[a,S,B,C],[a,B,C],[a,a,b,c,B,C],[a,a,b,C,B,C],[a,a,b,B,C,C],[a,a,B,C,B,C],[a,a,B,B,C,C],[a,a,S,B,C,B,C],[a,a,S,B,B,C,C],[a,a,a,S,B,C,B,B,C,C],[a,a,a,S,B,B,C,C,B,C],[a,a,a,S,B,C,B,C,B,C],[a,a,a,B,B,C,C,B,C],[a,a,a,b,C,B,C,B,C],[a,a,a,B,C,B,B,C,C],[a,a,a,B,C,B,C,B,C],[a,a,a,a,B,C,B,C,B,C,B,C],[a,a,a,a,S,B,C,B,C,B,C,B,C]}" ] }, - "execution_count": 27, + "execution_count": 36, "metadata": {}, "output_type": "execute_result" } @@ -903,7 +926,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 37, "metadata": {}, "outputs": [ { @@ -915,7 +938,7 @@ "{[a,b,c]}" ] }, - "execution_count": 28, + "execution_count": 37, "metadata": {}, "output_type": "execute_result" } @@ -926,7 +949,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 38, "metadata": {}, "outputs": [ { @@ -935,7 +958,7 @@ "Preference changed: DOT_DECOMPOSE_NODES = FALSE\n" ] }, - "execution_count": 29, + "execution_count": 38, "metadata": {}, "output_type": "execute_result" } @@ -946,7 +969,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 39, "metadata": {}, "outputs": [ { @@ -1213,7 +1236,7 @@ "<Dot visualization: expr_as_graph [SFSF={[S],[a,b,c],[a,b,C],[a,S,B,C],[a,B,C],[a,a,b,c,B,C],[a,a,b,C,B,C],[a,a,b,B,C,C],[a,a,B,C,B,C],[a,a,B,B,C,C],[a,a,S,B,C,B,C],[a,a,S,B,B,C,C],[a,a,a,S,B,C,B,B,C,C],[a,a,a,S,B,B,C,C,B,C],[a,a,a,S,B,C,B,C,B,C],[a,a,a,B,B,C,C,B,C],[a,a,a,b,C,B,C,B,C],[a,a,a,B,C,B,B,C,C],[a,a,a,B,C,B,C,B,C],[a,a,a,a,B,C,B,C,B,C,B,C],[a,a,a,a,S,B,C,B,C,B,C,B,C]}(\"abl\",SF<|abl|>SF)]>" ] }, - "execution_count": 30, + "execution_count": 39, "metadata": {}, "output_type": "execute_result" } @@ -1224,7 +1247,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 40, "metadata": {}, "outputs": [], "source": [ @@ -1246,9 +1269,9 @@ "* $G$ ist eine __Typ-1-Grammatik__ (bzw. __kontextsensitiv__ bzw. _nichtverkürzend_ oder __monoton__), falls für alle Regeln $p \\rightarrow q$ in\n", " $P$ gilt: $|p| \\leq |q|$.\n", " \n", - "* Eine Typ-1-Grammatik $G$ ist __vom Typ 2__ (bzw. ___kontextfrei__), falls für alle Regeln $p \\rightarrow q$ in $P$ gilt: $p \\in N$.\n", + "* Eine Typ-1-Grammatik $G$ ist __vom Typ 2__ (bzw. __kontextfrei__), falls für alle Regeln $p \\rightarrow q$ in $P$ gilt: $p \\in N$.\n", " \n", - "* Eine Typ-2-Grammatik $G$ ist __vom Typ 3__ (bzw. __regulär__ bzw. __rechtslinear__), falls f\"ur\n", + "* Eine Typ-2-Grammatik $G$ ist __vom Typ 3__ (bzw. __regulär__ bzw. __rechtslinear__), falls für\n", " alle Regeln $p \\rightarrow q$ in $P$ gilt: $p \\in N$ und $q \\in \\Sigma \\cup \\Sigma N$.\n", "\n", "Eine Sprache $A \\subseteq \\Sigma^*$ ist genau dann vom Typ $i \\in\n", @@ -1257,23 +1280,9 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/markdown": [ - "$\\{([a,B]\\mapsto [a,b]),([b,B]\\mapsto [b,b]),([b,C]\\mapsto [b,c]),([c,C]\\mapsto [c,c]),([S]\\mapsto [a,\\mathit{S},\\mathit{B},C]),([S]\\mapsto [a,\\mathit{B},C]),([C,B]\\mapsto [B,C])\\}$" - ], - "text/plain": [ - "{([a,B]↦[a,b]),([b,B]↦[b,b]),([b,C]↦[b,c]),([c,C]↦[c,c]),([S]↦[a,S,B,C]),([S]↦[a,B,C]),([C,B]↦[B,C])}" - ] - }, - "execution_count": 32, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "P" ] @@ -1288,7 +1297,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 42, "metadata": {}, "outputs": [ { @@ -1300,7 +1309,7 @@ "TRUE" ] }, - "execution_count": 33, + "execution_count": 42, "metadata": {}, "output_type": "execute_result" } @@ -1309,6 +1318,29 @@ "∀(p,q).( p↦q ∈ P ⇒ size(p) ≤ size(q))" ] }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{([a,B]\\mapsto [a,b]),([b,B]\\mapsto [b,b]),([b,C]\\mapsto [b,c]),([c,C]\\mapsto [c,c]),([S]\\mapsto [a,\\mathit{S},\\mathit{B},C]),([S]\\mapsto [a,\\mathit{B},C]),([C,B]\\mapsto [B,C])\\}$" + ], + "text/plain": [ + "{([a,B]↦[a,b]),([b,B]↦[b,b]),([b,C]↦[b,c]),([c,C]↦[c,c]),([S]↦[a,S,B,C]),([S]↦[a,B,C]),([C,B]↦[B,C])}" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "P" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -1318,7 +1350,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 43, "metadata": {}, "outputs": [ { @@ -1330,7 +1362,7 @@ "FALSE" ] }, - "execution_count": 34, + "execution_count": 43, "metadata": {}, "output_type": "execute_result" } @@ -1349,7 +1381,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 44, "metadata": {}, "outputs": [ { @@ -1376,7 +1408,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 45, "metadata": {}, "outputs": [ { @@ -1388,7 +1420,7 @@ "{([S]↦[]),([S]↦[a,S,b])}" ] }, - "execution_count": 36, + "execution_count": 45, "metadata": {}, "output_type": "execute_result" } @@ -1399,7 +1431,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 46, "metadata": {}, "outputs": [ { @@ -1417,7 +1449,7 @@ "\tP1 = {([S]↦[]),([S]↦[a,S,b])}" ] }, - "execution_count": 37, + "execution_count": 46, "metadata": {}, "output_type": "execute_result" } @@ -1435,7 +1467,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 47, "metadata": {}, "outputs": [ { @@ -1447,7 +1479,7 @@ "FALSE" ] }, - "execution_count": 38, + "execution_count": 47, "metadata": {}, "output_type": "execute_result" } @@ -1458,7 +1490,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 48, "metadata": {}, "outputs": [ { @@ -1480,7 +1512,7 @@ "\tP1 = {([S]↦[]),([S]↦[a,S,b])}" ] }, - "execution_count": 39, + "execution_count": 48, "metadata": {}, "output_type": "execute_result" }