diff --git a/info4/kapitel-0/Mengentheorie.ipynb b/info4/kapitel-0/Mengentheorie.ipynb index 2ce3414ef4d19f763799e2b20e2f23df4aa292bc..c19600aa07de8e57d1c90c2c0bdb8cd443db5fcb 100644 --- a/info4/kapitel-0/Mengentheorie.ipynb +++ b/info4/kapitel-0/Mengentheorie.ipynb @@ -6020,7 +6020,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 73, "metadata": {}, "outputs": [ { @@ -6032,7 +6032,7 @@ "{(2↦1),(4↦2),(6↦3),(8↦4),(10↦5)}" ] }, - "execution_count": 14, + "execution_count": 73, "metadata": {}, "output_type": "execute_result" } @@ -7080,64 +7080,114 @@ "# Transitive und Reflexive Hülle\n", " \n", "Gegeben eine Relation $r$ von $A$ nach $A$\n", - "* $r^0 = \\{(a,a) \\mid a\\in A\\}$\n", "* $r^1 = r$\n", "* $r^k = (r^{k-1} ; r) = (r ; r^{k-1})$\n", - "* $r^*$ = $\\bigcup_{i\\geq 0} r^i$\n", "\n", - "Die transitive Hülle von $r$ ist:\n", "* $r^+$ = $\\bigcup_{i\\geq 1} r^i$" ] }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 74, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ - "$\\{1,2,3\\}$" + "$\\{(4\\mapsto 1),(8\\mapsto 2)\\}$" ], "text/plain": [ - "{1,2,3}" + "{(4↦1),(8↦2)}" ] }, - "execution_count": 51, + "execution_count": 74, "metadata": {}, "output_type": "execute_result" } ], "source": [ - ":let A {1,2,3}" + "(h;h)" ] }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 75, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ - "$\\{(1\\mapsto 2),(2\\mapsto 3)\\}$" + "$\\{(8\\mapsto 1)\\}$" ], "text/plain": [ - "{(1↦2),(2↦3)}" + "{(8↦1)}" ] }, - "execution_count": 52, + "execution_count": 75, "metadata": {}, "output_type": "execute_result" } ], "source": [ - ":let r {(1,2), (2,3)}" + "(h;h;h)" + ] + }, + { + "cell_type": "code", + "execution_count": 76, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\emptyset$" + ], + "text/plain": [ + "∅" + ] + }, + "execution_count": 76, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(h;h;h;h)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Die transitive Hülle wird in B als ```closure1``` geschrieben:" + ] + }, + { + "cell_type": "code", + "execution_count": 81, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{(2\\mapsto 1),(4\\mapsto 1),(4\\mapsto 2),(6\\mapsto 3),(8\\mapsto 1),(8\\mapsto 2),(8\\mapsto 4),(10\\mapsto 5)\\}$" + ], + "text/plain": [ + "{(2↦1),(4↦1),(4↦2),(6↦3),(8↦1),(8↦2),(8↦4),(10↦5)}" + ] + }, + "execution_count": 81, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "closure1(h)" ] }, { "cell_type": "code", - "execution_count": 62, + "execution_count": 79, "metadata": {}, "outputs": [ { @@ -7149,140 +7199,315 @@ "<!-- Generated by graphviz version 2.28.0 (20110509.1545)\n", " -->\n", "<!-- Title: state Pages: 1 -->\n", - "<svg width=\"62pt\" height=\"224pt\"\n", - " viewBox=\"0.00 0.00 62.00 224.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n", - "<g id=\"graph1\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 220)\">\n", + "<svg width=\"299pt\" height=\"314pt\"\n", + " viewBox=\"0.00 0.00 299.00 314.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n", + "<g id=\"graph1\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 310)\">\n", "<title>state</title>\n", - "<polygon fill=\"white\" stroke=\"white\" points=\"-4,5 -4,-220 59,-220 59,5 -4,5\"/>\n", - "<!-- 2 -->\n", - "<g id=\"node1\" class=\"node\"><title>2</title>\n", - "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"54,-126 0,-126 0,-90 54,-90 54,-126\"/>\n", - "<text text-anchor=\"middle\" x=\"27\" y=\"-103.8\" font-family=\"Times,serif\" font-size=\"14.00\">2</text>\n", + "<polygon fill=\"white\" stroke=\"white\" points=\"-4,5 -4,-310 296,-310 296,5 -4,5\"/>\n", + "<!-- 10 -->\n", + "<g id=\"node1\" class=\"node\"><title>10</title>\n", + "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"54,-306 0,-306 0,-270 54,-270 54,-306\"/>\n", + "<text text-anchor=\"middle\" x=\"27\" y=\"-283.8\" font-family=\"Times,serif\" font-size=\"14.00\">10</text>\n", "</g>\n", - "<!-- 3 -->\n", - "<g id=\"node3\" class=\"node\"><title>3</title>\n", - "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"54,-36 0,-36 0,-0 54,-0 54,-36\"/>\n", - "<text text-anchor=\"middle\" x=\"27\" y=\"-13.8\" font-family=\"Times,serif\" font-size=\"14.00\">3</text>\n", + "<!-- 5 -->\n", + "<g id=\"node3\" class=\"node\"><title>5</title>\n", + "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"54,-216 0,-216 0,-180 54,-180 54,-216\"/>\n", + "<text text-anchor=\"middle\" x=\"27\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">5</text>\n", "</g>\n", - "<!-- 2->3 -->\n", - "<g id=\"edge2\" class=\"edge\"><title>2->3</title>\n", - "<path fill=\"none\" stroke=\"firebrick\" d=\"M27,-89.614C27,-77.2403 27,-60.3686 27,-46.2198\"/>\n", - "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"30.5001,-46.0504 27,-36.0504 23.5001,-46.0504 30.5001,-46.0504\"/>\n", - "<text text-anchor=\"middle\" x=\"29.3303\" y=\"-58.8\" font-family=\"Times,serif\" font-size=\"14.00\">r</text>\n", + "<!-- 10->5 -->\n", + "<g id=\"edge2\" class=\"edge\"><title>10->5</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M27,-269.614C27,-257.24 27,-240.369 27,-226.22\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"30.5001,-226.05 27,-216.05 23.5001,-226.05 30.5001,-226.05\"/>\n", + "<text text-anchor=\"middle\" x=\"34.4473\" y=\"-238.8\" font-family=\"Times,serif\" font-size=\"14.00\">h+</text>\n", + "</g>\n", + "<!-- 8 -->\n", + "<g id=\"node4\" class=\"node\"><title>8</title>\n", + "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"189,-306 135,-306 135,-270 189,-270 189,-306\"/>\n", + "<text text-anchor=\"middle\" x=\"162\" y=\"-283.8\" font-family=\"Times,serif\" font-size=\"14.00\">8</text>\n", + "</g>\n", + "<!-- 4 -->\n", + "<g id=\"node6\" class=\"node\"><title>4</title>\n", + "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"126,-216 72,-216 72,-180 126,-180 126,-216\"/>\n", + "<text text-anchor=\"middle\" x=\"99\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">4</text>\n", + "</g>\n", + "<!-- 8->4 -->\n", + "<g id=\"edge4\" class=\"edge\"><title>8->4</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M147.181,-269.876C142.531,-264.288 137.475,-257.981 133.105,-252 126.782,-243.344 120.303,-233.552 114.715,-224.76\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"117.532,-222.665 109.256,-216.05 111.601,-226.382 117.532,-222.665\"/>\n", + "<text text-anchor=\"middle\" x=\"141.447\" y=\"-238.8\" font-family=\"Times,serif\" font-size=\"14.00\">h+</text>\n", + "</g>\n", + "<!-- 2 -->\n", + "<g id=\"node8\" class=\"node\"><title>2</title>\n", + "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"181,-126 127,-126 127,-90 181,-90 181,-126\"/>\n", + "<text text-anchor=\"middle\" x=\"154\" y=\"-103.8\" font-family=\"Times,serif\" font-size=\"14.00\">2</text>\n", + "</g>\n", + "<!-- 8->2 -->\n", + "<g id=\"edge6\" class=\"edge\"><title>8->2</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M161.233,-269.933C159.841,-238.966 156.89,-173.299 155.219,-136.129\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"158.71,-135.848 154.765,-126.016 151.717,-136.163 158.71,-135.848\"/>\n", + "<text text-anchor=\"middle\" x=\"166.447\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">h+</text>\n", "</g>\n", "<!-- 1 -->\n", - "<g id=\"node4\" class=\"node\"><title>1</title>\n", - "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"54,-216 0,-216 0,-180 54,-180 54,-216\"/>\n", - "<text text-anchor=\"middle\" x=\"27\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">1</text>\n", + "<g id=\"node10\" class=\"node\"><title>1</title>\n", + "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"181,-36 127,-36 127,-0 181,-0 181,-36\"/>\n", + "<text text-anchor=\"middle\" x=\"154\" y=\"-13.8\" font-family=\"Times,serif\" font-size=\"14.00\">1</text>\n", "</g>\n", - "<!-- 1->2 -->\n", - "<g id=\"edge4\" class=\"edge\"><title>1->2</title>\n", - "<path fill=\"none\" stroke=\"firebrick\" d=\"M27,-179.614C27,-167.24 27,-150.369 27,-136.22\"/>\n", - "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"30.5001,-136.05 27,-126.05 23.5001,-136.05 30.5001,-136.05\"/>\n", - "<text text-anchor=\"middle\" x=\"29.3303\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">r</text>\n", + "<!-- 8->1 -->\n", + "<g id=\"edge8\" class=\"edge\"><title>8->1</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M169.31,-269.807C171.436,-264.215 173.569,-257.923 175,-252 191.981,-181.714 206.613,-160.374 190,-90 186.27,-74.1976 178.381,-57.946 170.937,-44.9857\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"173.804,-42.9612 165.66,-36.1837 167.8,-46.5603 173.804,-42.9612\"/>\n", + "<text text-anchor=\"middle\" x=\"205.447\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">h+</text>\n", + "</g>\n", + "<!-- 4->2 -->\n", + "<g id=\"edge12\" class=\"edge\"><title>4->2</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M109.866,-179.614C117.903,-166.755 128.976,-149.038 138.02,-134.568\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"141.011,-136.385 143.343,-126.05 135.075,-132.675 141.011,-136.385\"/>\n", + "<text text-anchor=\"middle\" x=\"139.447\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">h+</text>\n", + "</g>\n", + "<!-- 4->1 -->\n", + "<g id=\"edge14\" class=\"edge\"><title>4->1</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M96.6879,-179.769C94.4498,-158.152 92.7399,-120.248 103.105,-90 108.913,-73.0524 120.197,-56.6281 130.667,-43.8525\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"133.529,-45.8913 137.365,-36.0151 128.207,-41.3438 133.529,-45.8913\"/>\n", + "<text text-anchor=\"middle\" x=\"111.447\" y=\"-103.8\" font-family=\"Times,serif\" font-size=\"14.00\">h+</text>\n", + "</g>\n", + "<!-- 2->1 -->\n", + "<g id=\"edge16\" class=\"edge\"><title>2->1</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M154,-89.614C154,-77.2403 154,-60.3686 154,-46.2198\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"157.5,-46.0504 154,-36.0504 150.5,-46.0504 157.5,-46.0504\"/>\n", + "<text text-anchor=\"middle\" x=\"161.447\" y=\"-58.8\" font-family=\"Times,serif\" font-size=\"14.00\">h+</text>\n", + "</g>\n", + "<!-- 6 -->\n", + "<g id=\"node11\" class=\"node\"><title>6</title>\n", + "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"291,-306 237,-306 237,-270 291,-270 291,-306\"/>\n", + "<text text-anchor=\"middle\" x=\"264\" y=\"-283.8\" font-family=\"Times,serif\" font-size=\"14.00\">6</text>\n", + "</g>\n", + "<!-- 3 -->\n", + "<g id=\"node13\" class=\"node\"><title>3</title>\n", + "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"291,-216 237,-216 237,-180 291,-180 291,-216\"/>\n", + "<text text-anchor=\"middle\" x=\"264\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">3</text>\n", + "</g>\n", + "<!-- 6->3 -->\n", + "<g id=\"edge10\" class=\"edge\"><title>6->3</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M264,-269.614C264,-257.24 264,-240.369 264,-226.22\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"267.5,-226.05 264,-216.05 260.5,-226.05 267.5,-226.05\"/>\n", + "<text text-anchor=\"middle\" x=\"271.447\" y=\"-238.8\" font-family=\"Times,serif\" font-size=\"14.00\">h+</text>\n", "</g>\n", "</g>\n", "</svg>" ], "text/plain": [ - "<Dot visualization: expr_as_graph [ArhA={1,2,3} & r={(1,2),(2,3)} & h={(2,1),(4,2),(6,3),(8,4),(10,5)}(\"r\",r)]>" + "<Dot visualization: expr_as_graph [ArhA={1,2,3} & r={(1,2),(2,3)} & h={(2,1),(4,2),(6,3),(8,4),(10,5)}(\"h+\",closure1(h))]>" ] }, - "execution_count": 62, + "execution_count": 79, "metadata": {}, "output_type": "execute_result" } ], "source": [ - ":dot expr_as_graph (\"r\",r)" + ":dot expr_as_graph (\"h+\",closure1(h))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Ein weiteres Beispiel ist folgende abgeänderte strikte Untermengenrelation $\\subset$ für $\\pow(1 .. 3) $:" ] }, { "cell_type": "code", - "execution_count": 56, + "execution_count": 83, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ - "$\\{(1\\mapsto 3)\\}$" + "$\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\{(\\emptyset\\mapsto\\{1\\}),(\\emptyset\\mapsto\\{2\\}),(\\emptyset\\mapsto\\{3\\}),(\\{1\\}\\mapsto\\{1,2\\}),(\\{1\\}\\mapsto\\{1,3\\}),(\\{1,2\\}\\mapsto\\{1,2,3\\}),(\\{1,3\\}\\mapsto\\{1,2,3\\}),(\\{2\\}\\mapsto\\{1,2\\}),(\\{2\\}\\mapsto\\{2,3\\}),(\\{2,3\\}\\mapsto\\{1,2,3\\}),(\\{3\\}\\mapsto\\{1,3\\}),(\\{3\\}\\mapsto\\{2,3\\})\\}$" ], "text/plain": [ - "{(1↦3)}" + "{(∅↦{1}),(∅↦{2}),(∅↦{3}),({1}↦{1,2}),({1}↦{1,3}),({1,2}↦{1,2,3}),({1,3}↦{1,2,3}),({2}↦{1,2}),({2}↦{2,3}),({2,3}↦{1,2,3}),({3}↦{1,3}),({3}↦{2,3})}" ] }, - "execution_count": 56, + "execution_count": 83, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "(r;r)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In B kann man $r^0$ auch als die Identitätsrelation über A beschreiben:" + ":let sub1 {x,y|y:POW(1..3) & x <<:y & card(x)+1=card(y)}" ] }, { "cell_type": "code", - "execution_count": 67, + "execution_count": 89, "metadata": {}, "outputs": [ { "data": { - "text/markdown": [ - "$\\{(1\\mapsto 1),(2\\mapsto 2),(3\\mapsto 3)\\}$" - ], "text/plain": [ - "{(1↦1),(2↦2),(3↦3)}" + "Preference changed: DOT_DECOMPOSE_NODES = false\n" ] }, - "execution_count": 67, + "execution_count": 89, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "id(A)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Die transitive und reflexive Hülle ist hier:" + ":pref DOT_DECOMPOSE_NODES=false" ] }, { "cell_type": "code", - "execution_count": 60, + "execution_count": 90, "metadata": {}, "outputs": [ { "data": { - "text/markdown": [ - "$\\{(1\\mapsto 1),(1\\mapsto 2),(1\\mapsto 3),(2\\mapsto 2),(2\\mapsto 3),(3\\mapsto 3)\\}$" + "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", + "<!-- Generated by graphviz version 2.28.0 (20110509.1545)\n", + " -->\n", + "<!-- Title: state Pages: 1 -->\n", + "<svg width=\"261pt\" height=\"314pt\"\n", + " viewBox=\"0.00 0.00 260.64 314.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n", + "<g id=\"graph1\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 310)\">\n", + "<title>state</title>\n", + "<polygon fill=\"white\" stroke=\"white\" points=\"-4,5 -4,-310 257.637,-310 257.637,5 -4,5\"/>\n", + "<!-- \\{3\\} -->\n", + "<g id=\"node1\" class=\"node\"><title>\\{3\\}</title>\n", + "<polygon fill=\"#cae1ff\" stroke=\"#cae1ff\" points=\"78.1929,-216 24.1929,-216 24.1929,-180 78.1929,-180 78.1929,-216\"/>\n", + "<text text-anchor=\"middle\" x=\"51.1929\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">{3}</text>\n", + "</g>\n", + "<!-- \\{2,3\\} -->\n", + "<g id=\"node3\" class=\"node\"><title>\\{2,3\\}</title>\n", + "<polygon fill=\"#cae1ff\" stroke=\"#cae1ff\" points=\"151.193,-126 97.1929,-126 97.1929,-90 151.193,-90 151.193,-126\"/>\n", + "<text text-anchor=\"middle\" x=\"124.193\" y=\"-103.8\" font-family=\"Times,serif\" font-size=\"14.00\">{2,3}</text>\n", + "</g>\n", + "<!-- \\{3\\}->\\{2,3\\} -->\n", + "<g id=\"edge2\" class=\"edge\"><title>\\{3\\}->\\{2,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M47.0235,-179.946C45.3038,-168.863 45.0413,-154.566 51.7483,-144 52.0451,-143.532 69.8441,-134.93 87.7229,-126.372\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"89.4743,-129.414 96.9873,-121.944 86.4556,-123.099 89.4743,-129.414\"/>\n", + "<text text-anchor=\"middle\" x=\"65.4152\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{1,3\\} -->\n", + "<g id=\"node5\" class=\"node\"><title>\\{1,3\\}</title>\n", + "<polygon fill=\"#cae1ff\" stroke=\"#cae1ff\" points=\"79.1929,-126 25.1929,-126 25.1929,-90 79.1929,-90 79.1929,-126\"/>\n", + "<text text-anchor=\"middle\" x=\"52.1929\" y=\"-103.8\" font-family=\"Times,serif\" font-size=\"14.00\">{1,3}</text>\n", + "</g>\n", + "<!-- \\{3\\}->\\{1,3\\} -->\n", + "<g id=\"edge4\" class=\"edge\"><title>\\{3\\}->\\{1,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M24.1554,-183.975C15.7282,-178.453 7.42392,-171.146 2.74827,-162 -0.893163,-154.877 -0.927551,-151.106 2.74827,-144 6.02749,-137.661 11.0425,-132.224 16.6425,-127.655\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"19.037,-130.245 25.132,-121.579 14.963,-124.553 19.037,-130.245\"/>\n", + "<text text-anchor=\"middle\" x=\"16.4152\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{1,2,3\\} -->\n", + "<g id=\"node7\" class=\"node\"><title>\\{1,2,3\\}</title>\n", + "<polygon fill=\"#cae1ff\" stroke=\"#cae1ff\" points=\"152.77,-36 95.616,-36 95.616,-0 152.77,-0 152.77,-36\"/>\n", + "<text text-anchor=\"middle\" x=\"124.193\" y=\"-13.8\" font-family=\"Times,serif\" font-size=\"14.00\">{1,2,3}</text>\n", + "</g>\n", + "<!-- \\{2,3\\}->\\{1,2,3\\} -->\n", + "<g id=\"edge6\" class=\"edge\"><title>\\{2,3\\}->\\{1,2,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M124.193,-89.614C124.193,-77.2403 124.193,-60.3686 124.193,-46.2198\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"127.693,-46.0504 124.193,-36.0504 120.693,-46.0504 127.693,-46.0504\"/>\n", + "<text text-anchor=\"middle\" x=\"137.415\" y=\"-58.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{1,3\\}->\\{1,2,3\\} -->\n", + "<g id=\"edge12\" class=\"edge\"><title>\\{1,3\\}->\\{1,2,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M65.4484,-89.6378C73.503,-79.2032 84.0678,-65.719 93.7483,-54 96.4602,-50.717 99.3507,-47.297 102.23,-43.9367\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"104.944,-46.1494 108.84,-36.2969 99.6503,-41.5693 104.944,-46.1494\"/>\n", + "<text text-anchor=\"middle\" x=\"106.415\" y=\"-58.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{2\\} -->\n", + "<g id=\"node8\" class=\"node\"><title>\\{2\\}</title>\n", + "<polygon fill=\"#cae1ff\" stroke=\"#cae1ff\" points=\"225.193,-216 171.193,-216 171.193,-180 225.193,-180 225.193,-216\"/>\n", + "<text text-anchor=\"middle\" x=\"198.193\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">{2}</text>\n", + "</g>\n", + "<!-- \\{2\\}->\\{2,3\\} -->\n", + "<g id=\"edge8\" class=\"edge\"><title>\\{2\\}->\\{2,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M193.88,-179.893C190.447,-168.788 184.775,-154.485 176.193,-144 171.549,-138.326 165.748,-133.215 159.72,-128.762\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"161.678,-125.861 151.447,-123.109 157.729,-131.641 161.678,-125.861\"/>\n", + "<text text-anchor=\"middle\" x=\"199.415\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{1,2\\} -->\n", + "<g id=\"node11\" class=\"node\"><title>\\{1,2\\}</title>\n", + "<polygon fill=\"#cae1ff\" stroke=\"#cae1ff\" points=\"223.193,-126 169.193,-126 169.193,-90 223.193,-90 223.193,-126\"/>\n", + "<text text-anchor=\"middle\" x=\"196.193\" y=\"-103.8\" font-family=\"Times,serif\" font-size=\"14.00\">{1,2}</text>\n", + "</g>\n", + "<!-- \\{2\\}->\\{1,2\\} -->\n", + "<g id=\"edge10\" class=\"edge\"><title>\\{2\\}->\\{1,2\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M215,-179.823C219.142,-174.525 223.014,-168.392 225.193,-162 227.774,-154.428 227.906,-151.526 225.193,-144 224.006,-140.708 222.361,-137.506 220.451,-134.463\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"223.255,-132.368 214.529,-126.358 217.603,-136.497 223.255,-132.368\"/>\n", + "<text text-anchor=\"middle\" x=\"239.415\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{1,2\\}->\\{1,2,3\\} -->\n", + "<g id=\"edge14\" class=\"edge\"><title>\\{1,2\\}->\\{1,2,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M182.74,-89.68C174.58,-79.2604 163.901,-65.7771 154.193,-54 151.501,-50.7347 148.642,-47.3251 145.799,-43.9702\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"148.435,-41.668 139.28,-36.3348 143.111,-46.2129 148.435,-41.668\"/>\n", + "<text text-anchor=\"middle\" x=\"181.415\" y=\"-58.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{1\\} -->\n", + "<g id=\"node14\" class=\"node\"><title>\\{1\\}</title>\n", + "<polygon fill=\"#cae1ff\" stroke=\"#cae1ff\" points=\"152.193,-216 98.1929,-216 98.1929,-180 152.193,-180 152.193,-216\"/>\n", + "<text text-anchor=\"middle\" x=\"125.193\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">{1}</text>\n", + "</g>\n", + "<!-- \\{1\\}->\\{1,3\\} -->\n", + "<g id=\"edge16\" class=\"edge\"><title>\\{1\\}->\\{1,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M110.77,-179.614C99.9021,-166.512 84.8505,-148.368 72.7263,-133.753\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"75.4154,-131.512 66.337,-126.05 70.0278,-135.982 75.4154,-131.512\"/>\n", + "<text text-anchor=\"middle\" x=\"108.415\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{1\\}->\\{1,2\\} -->\n", + "<g id=\"edge18\" class=\"edge\"><title>\\{1\\}->\\{1,2\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M130.79,-179.564C134.882,-168.597 141.21,-154.571 149.748,-144 153.073,-139.884 156.983,-135.986 161.099,-132.39\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"163.591,-134.876 169.169,-125.868 159.191,-129.432 163.591,-134.876\"/>\n", + "<text text-anchor=\"middle\" x=\"162.415\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{\\} -->\n", + "<g id=\"node17\" class=\"node\"><title>\\{\\}</title>\n", + "<polygon fill=\"#cae1ff\" stroke=\"#cae1ff\" points=\"152.193,-306 98.1929,-306 98.1929,-270 152.193,-270 152.193,-306\"/>\n", + "<text text-anchor=\"middle\" x=\"125.193\" y=\"-283.8\" font-family=\"Times,serif\" font-size=\"14.00\">{}</text>\n", + "</g>\n", + "<!-- \\{\\}->\\{3\\} -->\n", + "<g id=\"edge20\" class=\"edge\"><title>\\{\\}->\\{3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M110.231,-269.993C105.269,-264.302 99.7402,-257.904 94.7483,-252 87.0945,-242.948 78.8083,-232.923 71.5385,-224.05\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"74.2326,-221.816 65.1951,-216.287 68.8119,-226.245 74.2326,-221.816\"/>\n", + "<text text-anchor=\"middle\" x=\"107.415\" y=\"-238.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{\\}->\\{2\\} -->\n", + "<g id=\"edge22\" class=\"edge\"><title>\\{\\}->\\{2\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M139.934,-269.989C144.823,-264.297 150.272,-257.9 155.193,-252 162.669,-243.035 170.759,-233.122 177.883,-224.317\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"180.811,-226.262 184.366,-216.282 175.363,-221.867 180.811,-226.262\"/>\n", + "<text text-anchor=\"middle\" x=\"182.415\" y=\"-238.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{\\}->\\{1\\} -->\n", + "<g id=\"edge24\" class=\"edge\"><title>\\{\\}->\\{1\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M125.193,-269.614C125.193,-257.24 125.193,-240.369 125.193,-226.22\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"128.693,-226.05 125.193,-216.05 121.693,-226.05 128.693,-226.05\"/>\n", + "<text text-anchor=\"middle\" x=\"138.415\" y=\"-238.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "</g>\n", + "</svg>" ], "text/plain": [ - "{(1↦1),(1↦2),(1↦3),(2↦2),(2↦3),(3↦3)}" + "<Dot visualization: expr_as_graph [Arsub1hA={1,2,3} & r={(1,2),(2,3)} & sub1={({},{1}),({},{2}),({},{3}),({1},{1,2}),({1},{1,3}),({1,2},{1,2,3}),({1,3},{1,2,3}),({2},{1,2}),({2},{2,3}),({2,3},{1,2,3}),({3},{1,3}),({3},{2,3})} & h={(2,1),(4,2),(6,3),(8,4),(10,5)}(\"sub1\",sub1)]>" ] }, - "execution_count": 60, + "execution_count": 90, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "id(A) \\/ r \\/ (r;r) \\/ (r;r;r) \\/ (r;r;r;r)" + ":dot expr_as_graph (\"sub1\",sub1)" ] }, { "cell_type": "code", - "execution_count": 61, + "execution_count": 92, "metadata": {}, "outputs": [ { @@ -7294,111 +7519,243 @@ "<!-- Generated by graphviz version 2.28.0 (20110509.1545)\n", " -->\n", "<!-- Title: state Pages: 1 -->\n", - "<svg width=\"127pt\" height=\"224pt\"\n", - " viewBox=\"0.00 0.00 126.66 224.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n", - "<g id=\"graph1\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 220)\">\n", + "<svg width=\"470pt\" height=\"314pt\"\n", + " viewBox=\"0.00 0.00 470.44 314.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n", + "<g id=\"graph1\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 310)\">\n", "<title>state</title>\n", - "<polygon fill=\"white\" stroke=\"white\" points=\"-4,5 -4,-220 123.661,-220 123.661,5 -4,5\"/>\n", - "<!-- 3 -->\n", - "<g id=\"node1\" class=\"node\"><title>3</title>\n", - "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"54,-36 0,-36 0,-0 54,-0 54,-36\"/>\n", - "<text text-anchor=\"middle\" x=\"27\" y=\"-13.8\" font-family=\"Times,serif\" font-size=\"14.00\">3</text>\n", - "</g>\n", - "<!-- 3->3 -->\n", - "<g id=\"edge2\" class=\"edge\"><title>3->3</title>\n", - "<path fill=\"none\" stroke=\"firebrick\" d=\"M54.2408,-26.2419C64.0239,-26.4192 72,-23.6719 72,-18 72,-14.5437 69.0382,-12.1734 64.5105,-10.8891\"/>\n", - "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"64.5639,-7.3739 54.2408,-9.75806 63.7975,-14.3318 64.5639,-7.3739\"/>\n", - "<text text-anchor=\"middle\" x=\"77.8303\" y=\"-13.8\" font-family=\"Times,serif\" font-size=\"14.00\">r*</text>\n", - "</g>\n", - "<!-- 2 -->\n", - "<g id=\"node3\" class=\"node\"><title>2</title>\n", - "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"89,-126 35,-126 35,-90 89,-90 89,-126\"/>\n", - "<text text-anchor=\"middle\" x=\"62\" y=\"-103.8\" font-family=\"Times,serif\" font-size=\"14.00\">2</text>\n", - "</g>\n", - "<!-- 2->3 -->\n", - "<g id=\"edge4\" class=\"edge\"><title>2->3</title>\n", - "<path fill=\"none\" stroke=\"firebrick\" d=\"M55.0851,-89.614C50.0673,-76.9977 43.1896,-59.7052 37.4963,-45.3907\"/>\n", - "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"40.7294,-44.0489 33.7814,-36.0504 34.225,-46.636 40.7294,-44.0489\"/>\n", - "<text text-anchor=\"middle\" x=\"52.8303\" y=\"-58.8\" font-family=\"Times,serif\" font-size=\"14.00\">r*</text>\n", - "</g>\n", - "<!-- 2->2 -->\n", - "<g id=\"edge6\" class=\"edge\"><title>2->2</title>\n", - "<path fill=\"none\" stroke=\"firebrick\" d=\"M89.2408,-116.242C99.0239,-116.419 107,-113.672 107,-108 107,-104.544 104.038,-102.173 99.5105,-100.889\"/>\n", - "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"99.5639,-97.3739 89.2408,-99.7581 98.7975,-104.332 99.5639,-97.3739\"/>\n", - "<text text-anchor=\"middle\" x=\"112.83\" y=\"-103.8\" font-family=\"Times,serif\" font-size=\"14.00\">r*</text>\n", - "</g>\n", - "<!-- 1 -->\n", - "<g id=\"node6\" class=\"node\"><title>1</title>\n", - "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"54,-216 0,-216 0,-180 54,-180 54,-216\"/>\n", - "<text text-anchor=\"middle\" x=\"27\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">1</text>\n", - "</g>\n", - "<!-- 1->3 -->\n", - "<g id=\"edge8\" class=\"edge\"><title>1->3</title>\n", - "<path fill=\"none\" stroke=\"firebrick\" d=\"M23.0751,-179.897C20.0025,-165.587 15.9833,-144.583 14.3394,-126 12.9295,-110.062 12.9295,-105.938 14.3394,-90 15.6366,-75.3365 18.4126,-59.1664 21.0356,-45.9664\"/>\n", - "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"24.4777,-46.6042 23.0751,-36.1026 17.6227,-45.1867 24.4777,-46.6042\"/>\n", - "<text text-anchor=\"middle\" x=\"20.8303\" y=\"-103.8\" font-family=\"Times,serif\" font-size=\"14.00\">r*</text>\n", - "</g>\n", - "<!-- 1->2 -->\n", - "<g id=\"edge10\" class=\"edge\"><title>1->2</title>\n", - "<path fill=\"none\" stroke=\"firebrick\" d=\"M33.9149,-179.614C38.9327,-166.998 45.8104,-149.705 51.5037,-135.391\"/>\n", - "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"54.775,-136.636 55.2186,-126.05 48.2706,-134.049 54.775,-136.636\"/>\n", - "<text text-anchor=\"middle\" x=\"52.8303\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">r*</text>\n", - "</g>\n", - "<!-- 1->1 -->\n", - "<g id=\"edge12\" class=\"edge\"><title>1->1</title>\n", - "<path fill=\"none\" stroke=\"firebrick\" d=\"M54.2408,-206.242C64.0239,-206.419 72,-203.672 72,-198 72,-194.544 69.0382,-192.173 64.5105,-190.889\"/>\n", - "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"64.5639,-187.374 54.2408,-189.758 63.7975,-194.332 64.5639,-187.374\"/>\n", - "<text text-anchor=\"middle\" x=\"77.8303\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">r*</text>\n", + "<polygon fill=\"white\" stroke=\"white\" points=\"-4,5 -4,-310 467.445,-310 467.445,5 -4,5\"/>\n", + "<!-- \\{3\\} -->\n", + "<g id=\"node1\" class=\"node\"><title>\\{3\\}</title>\n", + "<polygon fill=\"#cae1ff\" stroke=\"#cae1ff\" points=\"197,-216 143,-216 143,-180 197,-180 197,-216\"/>\n", + "<text text-anchor=\"middle\" x=\"170\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">{3}</text>\n", + "</g>\n", + "<!-- \\{2,3\\} -->\n", + "<g id=\"node3\" class=\"node\"><title>\\{2,3\\}</title>\n", + "<polygon fill=\"#cae1ff\" stroke=\"#cae1ff\" points=\"123,-126 69,-126 69,-90 123,-90 123,-126\"/>\n", + "<text text-anchor=\"middle\" x=\"96\" y=\"-103.8\" font-family=\"Times,serif\" font-size=\"14.00\">{2,3}</text>\n", + "</g>\n", + "<!-- \\{3\\}->\\{2,3\\} -->\n", + "<g id=\"edge2\" class=\"edge\"><title>\\{3\\}->\\{2,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M143.178,-179.965C136.246,-174.754 129.164,-168.629 123.555,-162 116.964,-154.209 111.368,-144.576 106.976,-135.669\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"110.069,-134.017 102.694,-126.41 103.715,-136.955 110.069,-134.017\"/>\n", + "<text text-anchor=\"middle\" x=\"137.222\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{1,2,3\\} -->\n", + "<g id=\"node5\" class=\"node\"><title>\\{1,2,3\\}</title>\n", + "<polygon fill=\"#cae1ff\" stroke=\"#cae1ff\" points=\"266.577,-36 209.423,-36 209.423,-0 266.577,-0 266.577,-36\"/>\n", + "<text text-anchor=\"middle\" x=\"238\" y=\"-13.8\" font-family=\"Times,serif\" font-size=\"14.00\">{1,2,3}</text>\n", + "</g>\n", + "<!-- \\{3\\}->\\{1,2,3\\} -->\n", + "<g id=\"edge4\" class=\"edge\"><title>\\{3\\}->\\{1,2,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M167.547,-179.95C165.15,-158.192 163.421,-119.805 175.555,-90 182.851,-72.0797 196.666,-55.6101 209.45,-43.0542\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"211.92,-45.5358 216.801,-36.1323 207.122,-40.4395 211.92,-45.5358\"/>\n", + "<text text-anchor=\"middle\" x=\"188.222\" y=\"-103.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{1,3\\} -->\n", + "<g id=\"node7\" class=\"node\"><title>\\{1,3\\}</title>\n", + "<polygon fill=\"#cae1ff\" stroke=\"#cae1ff\" points=\"371,-126 317,-126 317,-90 371,-90 371,-126\"/>\n", + "<text text-anchor=\"middle\" x=\"344\" y=\"-103.8\" font-family=\"Times,serif\" font-size=\"14.00\">{1,3}</text>\n", + "</g>\n", + "<!-- \\{3\\}->\\{1,3\\} -->\n", + "<g id=\"edge6\" class=\"edge\"><title>\\{3\\}->\\{1,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M197.035,-186.304C203.214,-184.057 209.79,-181.82 216,-180 251.807,-169.508 265.921,-181.057 298,-162 304.426,-158.183 315.258,-145.851 324.797,-134.043\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"327.653,-136.074 331.124,-126.063 322.168,-131.725 327.653,-136.074\"/>\n", + "<text text-anchor=\"middle\" x=\"329.222\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{2,3\\}->\\{1,2,3\\} -->\n", + "<g id=\"edge8\" class=\"edge\"><title>\\{2,3\\}->\\{1,2,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M100.972,-89.9363C105.201,-78.2675 112.395,-63.2874 123.555,-54 144.936,-36.2072 175.252,-27.4522 199.312,-23.1483\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"199.876,-26.6026 209.195,-21.5629 198.767,-19.691 199.876,-26.6026\"/>\n", + "<text text-anchor=\"middle\" x=\"137.222\" y=\"-58.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{1,3\\}->\\{1,2,3\\} -->\n", + "<g id=\"edge16\" class=\"edge\"><title>\\{1,3\\}->\\{1,2,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M323.31,-89.8238C307.114,-76.3774 284.407,-57.5263 266.491,-42.6529\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"268.567,-39.8275 258.637,-36.1329 264.096,-45.2134 268.567,-39.8275\"/>\n", + "<text text-anchor=\"middle\" x=\"313.222\" y=\"-58.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{2\\} -->\n", + "<g id=\"node9\" class=\"node\"><title>\\{2\\}</title>\n", + "<polygon fill=\"#cae1ff\" stroke=\"#cae1ff\" points=\"54,-216 0,-216 0,-180 54,-180 54,-216\"/>\n", + "<text text-anchor=\"middle\" x=\"27\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">{2}</text>\n", + "</g>\n", + "<!-- \\{2\\}->\\{2,3\\} -->\n", + "<g id=\"edge10\" class=\"edge\"><title>\\{2\\}->\\{2,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M31.8611,-179.554C35.5078,-168.582 41.3007,-154.556 49.5554,-144 52.8149,-139.832 56.6862,-135.904 60.7823,-132.292\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"63.2762,-134.775 68.8344,-125.755 58.8645,-129.34 63.2762,-134.775\"/>\n", + "<text text-anchor=\"middle\" x=\"63.2223\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{2\\}->\\{1,2,3\\} -->\n", + "<g id=\"edge12\" class=\"edge\"><title>\\{2\\}->\\{1,2,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M23.1487,-179.796C19.1041,-157.18 15.5597,-117.147 33.5554,-90 69.6268,-35.5863 150.912,-22.3289 199.42,-19.427\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"199.716,-22.9169 209.538,-18.9433 199.382,-15.9249 199.716,-22.9169\"/>\n", + "<text text-anchor=\"middle\" x=\"47.2223\" y=\"-103.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{1,2\\} -->\n", + "<g id=\"node13\" class=\"node\"><title>\\{1,2\\}</title>\n", + "<polygon fill=\"#cae1ff\" stroke=\"#cae1ff\" points=\"265,-126 211,-126 211,-90 265,-90 265,-126\"/>\n", + "<text text-anchor=\"middle\" x=\"238\" y=\"-103.8\" font-family=\"Times,serif\" font-size=\"14.00\">{1,2}</text>\n", + "</g>\n", + "<!-- \\{2\\}->\\{1,2\\} -->\n", + "<g id=\"edge14\" class=\"edge\"><title>\\{2\\}->\\{1,2\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M54.0863,-184.938C58.677,-183.135 63.4354,-181.41 68,-180 105.31,-168.471 117.802,-176.651 154,-162 172.706,-154.429 191.864,-142.703 207.152,-132.205\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"209.511,-134.824 215.673,-126.205 205.481,-129.1 209.511,-134.824\"/>\n", + "<text text-anchor=\"middle\" x=\"200.222\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{1,2\\}->\\{1,2,3\\} -->\n", + "<g id=\"edge18\" class=\"edge\"><title>\\{1,2\\}->\\{1,2,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M238,-89.614C238,-77.2403 238,-60.3686 238,-46.2198\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"241.5,-46.0504 238,-36.0504 234.5,-46.0504 241.5,-46.0504\"/>\n", + "<text text-anchor=\"middle\" x=\"251.222\" y=\"-58.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{1\\} -->\n", + "<g id=\"node16\" class=\"node\"><title>\\{1\\}</title>\n", + "<polygon fill=\"#cae1ff\" stroke=\"#cae1ff\" points=\"355,-216 301,-216 301,-180 355,-180 355,-216\"/>\n", + "<text text-anchor=\"middle\" x=\"328\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">{1}</text>\n", + "</g>\n", + "<!-- \\{1\\}->\\{1,2,3\\} -->\n", + "<g id=\"edge20\" class=\"edge\"><title>\\{1\\}->\\{1,2,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M355.07,-184.33C363.916,-178.772 372.796,-171.352 378,-162 393.566,-134.027 394.595,-118.492 380,-90 360.271,-51.485 311.332,-33.5069 276.431,-25.362\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"277.062,-21.9174 266.548,-23.2271 275.584,-28.7596 277.062,-21.9174\"/>\n", + "<text text-anchor=\"middle\" x=\"403.222\" y=\"-103.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{1\\}->\\{1,3\\} -->\n", + "<g id=\"edge22\" class=\"edge\"><title>\\{1\\}->\\{1,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M339.475,-179.902C342.54,-174.419 345.434,-168.165 347,-162 349.073,-153.835 349.284,-144.744 348.697,-136.429\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"352.171,-136.001 347.608,-126.44 345.212,-136.76 352.171,-136.001\"/>\n", + "<text text-anchor=\"middle\" x=\"361.222\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{1\\}->\\{1,2\\} -->\n", + "<g id=\"edge24\" class=\"edge\"><title>\\{1\\}->\\{1,2\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M300.943,-183.562C290.987,-177.798 280.074,-170.44 271.555,-162 263.664,-154.182 256.734,-144.18 251.252,-134.976\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"254.233,-133.137 246.271,-126.148 248.137,-136.577 254.233,-133.137\"/>\n", + "<text text-anchor=\"middle\" x=\"284.222\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{\\} -->\n", + "<g id=\"node20\" class=\"node\"><title>\\{\\}</title>\n", + "<polygon fill=\"#cae1ff\" stroke=\"#cae1ff\" points=\"265,-306 211,-306 211,-270 265,-270 265,-306\"/>\n", + "<text text-anchor=\"middle\" x=\"238\" y=\"-283.8\" font-family=\"Times,serif\" font-size=\"14.00\">{}</text>\n", + "</g>\n", + "<!-- \\{\\}->\\{3\\} -->\n", + "<g id=\"edge26\" class=\"edge\"><title>\\{\\}->\\{3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M215.15,-269.849C208.982,-264.553 202.62,-258.413 197.555,-252 191.23,-243.991 185.696,-234.308 181.28,-225.421\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"184.368,-223.764 176.942,-216.207 178.035,-226.746 184.368,-223.764\"/>\n", + "<text text-anchor=\"middle\" x=\"210.222\" y=\"-238.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{\\}->\\{2,3\\} -->\n", + "<g id=\"edge28\" class=\"edge\"><title>\\{\\}->\\{2,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M210.898,-280.359C180.301,-271.324 131.654,-251.995 107.555,-216 91.8517,-192.544 90.6583,-159.509 92.3181,-136.369\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"95.823,-136.481 93.2751,-126.197 88.8537,-135.825 95.823,-136.481\"/>\n", + "<text text-anchor=\"middle\" x=\"121.222\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{\\}->\\{1,2,3\\} -->\n", + "<g id=\"edge30\" class=\"edge\"><title>\\{\\}->\\{1,2,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M265.311,-285.247C305.834,-280.98 380.482,-266.325 412,-216 441.783,-168.444 445.582,-139.942 420,-90 393.677,-38.6105 321.879,-24.171 276.728,-20.2638\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"276.925,-16.7689 266.696,-19.53 276.414,-23.7503 276.925,-16.7689\"/>\n", + "<text text-anchor=\"middle\" x=\"449.222\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{\\}->\\{1,3\\} -->\n", + "<g id=\"edge34\" class=\"edge\"><title>\\{\\}->\\{1,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M265.242,-279.991C295.081,-270.742 341.661,-251.338 364,-216 381.419,-188.445 390.257,-174.207 378,-144 376.579,-140.497 374.62,-137.152 372.354,-134.016\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"374.919,-131.628 365.797,-126.238 369.567,-136.14 374.919,-131.628\"/>\n", + "<text text-anchor=\"middle\" x=\"395.222\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{\\}->\\{2\\} -->\n", + "<g id=\"edge32\" class=\"edge\"><title>\\{\\}->\\{2\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M210.708,-285.076C164.627,-281.325 74.0197,-271.624 49.5554,-252 41.3922,-245.452 36.1339,-235.401 32.7696,-225.805\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"36.1018,-224.731 29.9069,-216.136 29.3898,-226.718 36.1018,-224.731\"/>\n", + "<text text-anchor=\"middle\" x=\"63.2223\" y=\"-238.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{\\}->\\{1,2\\} -->\n", + "<g id=\"edge36\" class=\"edge\"><title>\\{\\}->\\{1,2\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M238,-269.933C238,-238.966 238,-173.299 238,-136.129\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"241.5,-136.016 238,-126.016 234.5,-136.016 241.5,-136.016\"/>\n", + "<text text-anchor=\"middle\" x=\"251.222\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{\\}->\\{1\\} -->\n", + "<g id=\"edge38\" class=\"edge\"><title>\\{\\}->\\{1\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M255.781,-269.614C269.305,-256.391 288.081,-238.032 303.099,-223.348\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"305.859,-225.544 310.562,-216.05 300.965,-220.539 305.859,-225.544\"/>\n", + "<text text-anchor=\"middle\" x=\"304.222\" y=\"-238.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", "</g>\n", "</g>\n", "</svg>" ], "text/plain": [ - "<Dot visualization: expr_as_graph [ArhA={1,2,3} & r={(1,2),(2,3)} & h={(2,1),(4,2),(6,3),(8,4),(10,5)}(\"r*\",id(A)\\/r\\/(r;r)\\/((r;r);r)\\/(((r;r);r);r))]>" + "<Dot visualization: expr_as_graph [Arsub1hA={1,2,3} & r={(1,2),(2,3)} & sub1={({},{1}),({},{2}),({},{3}),({1},{1,2}),({1},{1,3}),({1,2},{1,2,3}),({1,3},{1,2,3}),({2},{1,2}),({2},{2,3}),({2,3},{1,2,3}),({3},{1,3}),({3},{2,3})} & h={(2,1),(4,2),(6,3),(8,4),(10,5)}(\"sub1\",closure1(sub1))]>" ] }, - "execution_count": 61, + "execution_count": 92, "metadata": {}, "output_type": "execute_result" } ], "source": [ - ":dot expr_as_graph (\"r*\",id(A) \\/ r \\/ (r;r) \\/ (r;r;r) \\/ (r;r;r;r))" + ":dot expr_as_graph (\"sub1\",closure1(sub1))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Die transitive Hülle wird in B als ```closure1``` geschrieben:" + "# Transitive und Reflexive Hülle\n", + " \n", + "Gegeben eine Relation $r$ von $A$ nach $A$\n", + "* $r^0 = \\{(a,a) \\mid a\\in A\\}$\n", + "* $r^1 = r$\n", + "* $r^k = (r^{k-1} ; r) = (r ; r^{k-1})$\n", + "* $r^*$ = $\\bigcup_{i\\geq 0} r^i$\n" ] }, { "cell_type": "code", - "execution_count": 63, + "execution_count": 51, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ - "$\\{(1\\mapsto 2),(1\\mapsto 3),(2\\mapsto 3)\\}$" + "$\\{1,2,3\\}$" ], "text/plain": [ - "{(1↦2),(1↦3),(2↦3)}" + "{1,2,3}" ] }, - "execution_count": 63, + "execution_count": 51, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "closure1(r)" + ":let A {1,2,3}" ] }, { "cell_type": "code", - "execution_count": 65, + "execution_count": 93, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{(1\\mapsto 2),(2\\mapsto 3)\\}$" + ], + "text/plain": [ + "{(1↦2),(2↦3)}" + ] + }, + "execution_count": 93, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + ":let r {(1,2), (2,3)}" + ] + }, + { + "cell_type": "code", + "execution_count": 94, "metadata": {}, "outputs": [ { @@ -7410,11 +7767,11 @@ "<!-- Generated by graphviz version 2.28.0 (20110509.1545)\n", " -->\n", "<!-- Title: state Pages: 1 -->\n", - "<svg width=\"102pt\" height=\"224pt\"\n", - " viewBox=\"0.00 0.00 102.00 224.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n", + "<svg width=\"62pt\" height=\"224pt\"\n", + " viewBox=\"0.00 0.00 62.00 224.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n", "<g id=\"graph1\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 220)\">\n", "<title>state</title>\n", - "<polygon fill=\"white\" stroke=\"white\" points=\"-4,5 -4,-220 99,-220 99,5 -4,5\"/>\n", + "<polygon fill=\"white\" stroke=\"white\" points=\"-4,5 -4,-220 59,-220 59,5 -4,5\"/>\n", "<!-- 2 -->\n", "<g id=\"node1\" class=\"node\"><title>2</title>\n", "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"54,-126 0,-126 0,-90 54,-90 54,-126\"/>\n", @@ -7422,140 +7779,1384 @@ "</g>\n", "<!-- 3 -->\n", "<g id=\"node3\" class=\"node\"><title>3</title>\n", - "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"94,-36 40,-36 40,-0 94,-0 94,-36\"/>\n", - "<text text-anchor=\"middle\" x=\"67\" y=\"-13.8\" font-family=\"Times,serif\" font-size=\"14.00\">3</text>\n", + "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"54,-36 0,-36 0,-0 54,-0 54,-36\"/>\n", + "<text text-anchor=\"middle\" x=\"27\" y=\"-13.8\" font-family=\"Times,serif\" font-size=\"14.00\">3</text>\n", "</g>\n", "<!-- 2->3 -->\n", "<g id=\"edge2\" class=\"edge\"><title>2->3</title>\n", - "<path fill=\"none\" stroke=\"firebrick\" d=\"M34.9027,-89.614C40.6374,-76.9977 48.4976,-59.7052 55.0042,-45.3907\"/>\n", - "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"58.298,-46.6024 59.2498,-36.0504 51.9254,-43.7058 58.298,-46.6024\"/>\n", - "<text text-anchor=\"middle\" x=\"57.2776\" y=\"-58.8\" font-family=\"Times,serif\" font-size=\"14.00\">r+</text>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M27,-89.614C27,-77.2403 27,-60.3686 27,-46.2198\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"30.5001,-46.0504 27,-36.0504 23.5001,-46.0504 30.5001,-46.0504\"/>\n", + "<text text-anchor=\"middle\" x=\"29.3303\" y=\"-58.8\" font-family=\"Times,serif\" font-size=\"14.00\">r</text>\n", "</g>\n", "<!-- 1 -->\n", "<g id=\"node4\" class=\"node\"><title>1</title>\n", - "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"94,-216 40,-216 40,-180 94,-180 94,-216\"/>\n", - "<text text-anchor=\"middle\" x=\"67\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">1</text>\n", + "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"54,-216 0,-216 0,-180 54,-180 54,-216\"/>\n", + "<text text-anchor=\"middle\" x=\"27\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">1</text>\n", "</g>\n", "<!-- 1->2 -->\n", - "<g id=\"edge6\" class=\"edge\"><title>1->2</title>\n", - "<path fill=\"none\" stroke=\"firebrick\" d=\"M59.0973,-179.614C53.3626,-166.998 45.5024,-149.705 38.9958,-135.391\"/>\n", - "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"42.0746,-133.706 34.7502,-126.05 35.702,-136.602 42.0746,-133.706\"/>\n", - "<text text-anchor=\"middle\" x=\"57.2776\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">r+</text>\n", - "</g>\n", - "<!-- 1->3 -->\n", - "<g id=\"edge4\" class=\"edge\"><title>1->3</title>\n", - "<path fill=\"none\" stroke=\"firebrick\" d=\"M67,-179.933C67,-148.966 67,-83.2989 67,-46.1292\"/>\n", - "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"70.5001,-46.0157 67,-36.0157 63.5001,-46.0158 70.5001,-46.0157\"/>\n", - "<text text-anchor=\"middle\" x=\"73.2776\" y=\"-103.8\" font-family=\"Times,serif\" font-size=\"14.00\">r+</text>\n", + "<g id=\"edge4\" class=\"edge\"><title>1->2</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M27,-179.614C27,-167.24 27,-150.369 27,-136.22\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"30.5001,-136.05 27,-126.05 23.5001,-136.05 30.5001,-136.05\"/>\n", + "<text text-anchor=\"middle\" x=\"29.3303\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">r</text>\n", "</g>\n", "</g>\n", "</svg>" ], "text/plain": [ - "<Dot visualization: expr_as_graph [ArhA={1,2,3} & r={(1,2),(2,3)} & h={(2,1),(4,2),(6,3),(8,4),(10,5)}(\"r+\",closure1(r))]>" + "<Dot visualization: expr_as_graph [Arsub1hA={1,2,3} & r={(1,2),(2,3)} & sub1={({},{1}),({},{2}),({},{3}),({1},{1,2}),({1},{1,3}),({1,2},{1,2,3}),({1,3},{1,2,3}),({2},{1,2}),({2},{2,3}),({2,3},{1,2,3}),({3},{1,3}),({3},{2,3})} & h={(2,1),(4,2),(6,3),(8,4),(10,5)}(\"r\",r)]>" ] }, - "execution_count": 65, + "execution_count": 94, "metadata": {}, "output_type": "execute_result" } ], "source": [ - ":dot expr_as_graph (\"r+\",closure1(r))" + ":dot expr_as_graph (\"r\",r)" + ] + }, + { + "cell_type": "code", + "execution_count": 95, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{(1\\mapsto 3)\\}$" + ], + "text/plain": [ + "{(1↦3)}" + ] + }, + "execution_count": 95, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(r;r)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Man kann die transitive Hülle natürlich mit den anderen Operatoren verknüpfen, zum Beispiel um auszurechnen von welchen Knoten aus man den Knoten 3 erreichen kann:" + "In B kann man $r^0$ auch als die Identitätsrelation über A beschreiben:" ] }, { "cell_type": "code", - "execution_count": 69, + "execution_count": 96, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ - "$\\{1,2\\}$" + "$\\{(1\\mapsto 1),(2\\mapsto 2),(3\\mapsto 3)\\}$" ], "text/plain": [ - "{1,2}" + "{(1↦1),(2↦2),(3↦3)}" ] }, - "execution_count": 69, + "execution_count": 96, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "closure1(r)~[{3}]" + "id(A)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Anmerkung: die reflexive und transitive Hülle in B wird als ```closure``` geschrieben, ist bei Relationen über Zahlen immer unendlich." + "Die transitive und reflexive Hülle ist hier:" ] }, { "cell_type": "code", - "execution_count": 72, + "execution_count": 60, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ - "$/*@symbolic*/ \\{\\mathit{z\\_},\\mathit{z\\_\\_}\\mid \\mathit{z\\_} \\mapsto \\mathit{z\\_\\_} \\in \\{(1\\mapsto 2),(1\\mapsto 3),(2\\mapsto 3)\\} \\lor \\mathit{z\\_} = \\mathit{z\\_\\_}\\}$" + "$\\{(1\\mapsto 1),(1\\mapsto 2),(1\\mapsto 3),(2\\mapsto 2),(2\\mapsto 3),(3\\mapsto 3)\\}$" ], "text/plain": [ - "/*@symbolic*/ {z_,z__∣z_ ↦ z__ ∈ {(1↦2),(1↦3),(2↦3)} ∨ z_ = z__}" + "{(1↦1),(1↦2),(1↦3),(2↦2),(2↦3),(3↦3)}" ] }, - "execution_count": 72, + "execution_count": 60, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "closure(r)" + "id(A) \\/ r \\/ (r;r) \\/ (r;r;r) \\/ (r;r;r;r)" ] }, { "cell_type": "code", - "execution_count": 71, + "execution_count": 61, "metadata": {}, "outputs": [ { "data": { - "text/markdown": [ - "$\\{1,2,3\\}$" + "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", + "<!-- Generated by graphviz version 2.28.0 (20110509.1545)\n", + " -->\n", + "<!-- Title: state Pages: 1 -->\n", + "<svg width=\"127pt\" height=\"224pt\"\n", + " viewBox=\"0.00 0.00 126.66 224.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n", + "<g id=\"graph1\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 220)\">\n", + "<title>state</title>\n", + "<polygon fill=\"white\" stroke=\"white\" points=\"-4,5 -4,-220 123.661,-220 123.661,5 -4,5\"/>\n", + "<!-- 3 -->\n", + "<g id=\"node1\" class=\"node\"><title>3</title>\n", + "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"54,-36 0,-36 0,-0 54,-0 54,-36\"/>\n", + "<text text-anchor=\"middle\" x=\"27\" y=\"-13.8\" font-family=\"Times,serif\" font-size=\"14.00\">3</text>\n", + "</g>\n", + "<!-- 3->3 -->\n", + "<g id=\"edge2\" class=\"edge\"><title>3->3</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M54.2408,-26.2419C64.0239,-26.4192 72,-23.6719 72,-18 72,-14.5437 69.0382,-12.1734 64.5105,-10.8891\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"64.5639,-7.3739 54.2408,-9.75806 63.7975,-14.3318 64.5639,-7.3739\"/>\n", + "<text text-anchor=\"middle\" x=\"77.8303\" y=\"-13.8\" font-family=\"Times,serif\" font-size=\"14.00\">r*</text>\n", + "</g>\n", + "<!-- 2 -->\n", + "<g id=\"node3\" class=\"node\"><title>2</title>\n", + "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"89,-126 35,-126 35,-90 89,-90 89,-126\"/>\n", + "<text text-anchor=\"middle\" x=\"62\" y=\"-103.8\" font-family=\"Times,serif\" font-size=\"14.00\">2</text>\n", + "</g>\n", + "<!-- 2->3 -->\n", + "<g id=\"edge4\" class=\"edge\"><title>2->3</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M55.0851,-89.614C50.0673,-76.9977 43.1896,-59.7052 37.4963,-45.3907\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"40.7294,-44.0489 33.7814,-36.0504 34.225,-46.636 40.7294,-44.0489\"/>\n", + "<text text-anchor=\"middle\" x=\"52.8303\" y=\"-58.8\" font-family=\"Times,serif\" font-size=\"14.00\">r*</text>\n", + "</g>\n", + "<!-- 2->2 -->\n", + "<g id=\"edge6\" class=\"edge\"><title>2->2</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M89.2408,-116.242C99.0239,-116.419 107,-113.672 107,-108 107,-104.544 104.038,-102.173 99.5105,-100.889\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"99.5639,-97.3739 89.2408,-99.7581 98.7975,-104.332 99.5639,-97.3739\"/>\n", + "<text text-anchor=\"middle\" x=\"112.83\" y=\"-103.8\" font-family=\"Times,serif\" font-size=\"14.00\">r*</text>\n", + "</g>\n", + "<!-- 1 -->\n", + "<g id=\"node6\" class=\"node\"><title>1</title>\n", + "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"54,-216 0,-216 0,-180 54,-180 54,-216\"/>\n", + "<text text-anchor=\"middle\" x=\"27\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">1</text>\n", + "</g>\n", + "<!-- 1->3 -->\n", + "<g id=\"edge8\" class=\"edge\"><title>1->3</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M23.0751,-179.897C20.0025,-165.587 15.9833,-144.583 14.3394,-126 12.9295,-110.062 12.9295,-105.938 14.3394,-90 15.6366,-75.3365 18.4126,-59.1664 21.0356,-45.9664\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"24.4777,-46.6042 23.0751,-36.1026 17.6227,-45.1867 24.4777,-46.6042\"/>\n", + "<text text-anchor=\"middle\" x=\"20.8303\" y=\"-103.8\" font-family=\"Times,serif\" font-size=\"14.00\">r*</text>\n", + "</g>\n", + "<!-- 1->2 -->\n", + "<g id=\"edge10\" class=\"edge\"><title>1->2</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M33.9149,-179.614C38.9327,-166.998 45.8104,-149.705 51.5037,-135.391\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"54.775,-136.636 55.2186,-126.05 48.2706,-134.049 54.775,-136.636\"/>\n", + "<text text-anchor=\"middle\" x=\"52.8303\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">r*</text>\n", + "</g>\n", + "<!-- 1->1 -->\n", + "<g id=\"edge12\" class=\"edge\"><title>1->1</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M54.2408,-206.242C64.0239,-206.419 72,-203.672 72,-198 72,-194.544 69.0382,-192.173 64.5105,-190.889\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"64.5639,-187.374 54.2408,-189.758 63.7975,-194.332 64.5639,-187.374\"/>\n", + "<text text-anchor=\"middle\" x=\"77.8303\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">r*</text>\n", + "</g>\n", + "</g>\n", + "</svg>" ], "text/plain": [ - "{1,2,3}" + "<Dot visualization: expr_as_graph [ArhA={1,2,3} & r={(1,2),(2,3)} & h={(2,1),(4,2),(6,3),(8,4),(10,5)}(\"r*\",id(A)\\/r\\/(r;r)\\/((r;r);r)\\/(((r;r);r);r))]>" ] }, - "execution_count": 71, + "execution_count": 61, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "closure(r)~[{3}]" + ":dot expr_as_graph (\"r*\",id(A) \\/ r \\/ (r;r) \\/ (r;r;r) \\/ (r;r;r;r))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "# Funktionen\n", - " \n", - "Was unterscheidet Funktionen von Relationen?\n", - "Wie kann man Funktionen in Mengentheorie und Logik darstellen?" + "Die transitive Hülle wird in B als ```closure1``` geschrieben:" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{(1\\mapsto 2),(1\\mapsto 3),(2\\mapsto 3)\\}$" + ], + "text/plain": [ + "{(1↦2),(1↦3),(2↦3)}" + ] + }, + "execution_count": 63, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "closure1(r)" ] + }, + { + "cell_type": "code", + "execution_count": 65, + "metadata": {}, + "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", + "<!-- Generated by graphviz version 2.28.0 (20110509.1545)\n", + " -->\n", + "<!-- Title: state Pages: 1 -->\n", + "<svg width=\"102pt\" height=\"224pt\"\n", + " viewBox=\"0.00 0.00 102.00 224.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n", + "<g id=\"graph1\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 220)\">\n", + "<title>state</title>\n", + "<polygon fill=\"white\" stroke=\"white\" points=\"-4,5 -4,-220 99,-220 99,5 -4,5\"/>\n", + "<!-- 2 -->\n", + "<g id=\"node1\" class=\"node\"><title>2</title>\n", + "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"54,-126 0,-126 0,-90 54,-90 54,-126\"/>\n", + "<text text-anchor=\"middle\" x=\"27\" y=\"-103.8\" font-family=\"Times,serif\" font-size=\"14.00\">2</text>\n", + "</g>\n", + "<!-- 3 -->\n", + "<g id=\"node3\" class=\"node\"><title>3</title>\n", + "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"94,-36 40,-36 40,-0 94,-0 94,-36\"/>\n", + "<text text-anchor=\"middle\" x=\"67\" y=\"-13.8\" font-family=\"Times,serif\" font-size=\"14.00\">3</text>\n", + "</g>\n", + "<!-- 2->3 -->\n", + "<g id=\"edge2\" class=\"edge\"><title>2->3</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M34.9027,-89.614C40.6374,-76.9977 48.4976,-59.7052 55.0042,-45.3907\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"58.298,-46.6024 59.2498,-36.0504 51.9254,-43.7058 58.298,-46.6024\"/>\n", + "<text text-anchor=\"middle\" x=\"57.2776\" y=\"-58.8\" font-family=\"Times,serif\" font-size=\"14.00\">r+</text>\n", + "</g>\n", + "<!-- 1 -->\n", + "<g id=\"node4\" class=\"node\"><title>1</title>\n", + "<polygon fill=\"#cdba96\" stroke=\"#cdba96\" points=\"94,-216 40,-216 40,-180 94,-180 94,-216\"/>\n", + "<text text-anchor=\"middle\" x=\"67\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">1</text>\n", + "</g>\n", + "<!-- 1->2 -->\n", + "<g id=\"edge6\" class=\"edge\"><title>1->2</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M59.0973,-179.614C53.3626,-166.998 45.5024,-149.705 38.9958,-135.391\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"42.0746,-133.706 34.7502,-126.05 35.702,-136.602 42.0746,-133.706\"/>\n", + "<text text-anchor=\"middle\" x=\"57.2776\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">r+</text>\n", + "</g>\n", + "<!-- 1->3 -->\n", + "<g id=\"edge4\" class=\"edge\"><title>1->3</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M67,-179.933C67,-148.966 67,-83.2989 67,-46.1292\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"70.5001,-46.0157 67,-36.0157 63.5001,-46.0158 70.5001,-46.0157\"/>\n", + "<text text-anchor=\"middle\" x=\"73.2776\" y=\"-103.8\" font-family=\"Times,serif\" font-size=\"14.00\">r+</text>\n", + "</g>\n", + "</g>\n", + "</svg>" + ], + "text/plain": [ + "<Dot visualization: expr_as_graph [ArhA={1,2,3} & r={(1,2),(2,3)} & h={(2,1),(4,2),(6,3),(8,4),(10,5)}(\"r+\",closure1(r))]>" + ] + }, + "execution_count": 65, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + ":dot expr_as_graph (\"r+\",closure1(r))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Man kann die transitive Hülle natürlich mit den anderen Operatoren verknüpfen, zum Beispiel um auszurechnen von welchen Knoten aus man den Knoten 3 erreichen kann:" + ] + }, + { + "cell_type": "code", + "execution_count": 69, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{1,2\\}$" + ], + "text/plain": [ + "{1,2}" + ] + }, + "execution_count": 69, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "closure1(r)~[{3}]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Anmerkung: die reflexive und transitive Hülle in B wird als ```closure``` geschrieben, ist bei Relationen über Zahlen immer unendlich." + ] + }, + { + "cell_type": "code", + "execution_count": 72, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$/*@symbolic*/ \\{\\mathit{z\\_},\\mathit{z\\_\\_}\\mid \\mathit{z\\_} \\mapsto \\mathit{z\\_\\_} \\in \\{(1\\mapsto 2),(1\\mapsto 3),(2\\mapsto 3)\\} \\lor \\mathit{z\\_} = \\mathit{z\\_\\_}\\}$" + ], + "text/plain": [ + "/*@symbolic*/ {z_,z__∣z_ ↦ z__ ∈ {(1↦2),(1↦3),(2↦3)} ∨ z_ = z__}" + ] + }, + "execution_count": 72, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "closure(r)" + ] + }, + { + "cell_type": "code", + "execution_count": 71, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{1,2,3\\}$" + ], + "text/plain": [ + "{1,2,3}" + ] + }, + "execution_count": 71, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "closure(r)~[{3}]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Funktionen\n", + " \n", + "Was unterscheidet Funktionen von Relationen?\n", + "Wie kann man Funktionen in Mengentheorie und Logik darstellen?\n", + "\n", + "Eine Funktion kann als Menge an Paaren angesehen werden.\n", + "Zum Beispiel ist die Inkrementfunktion (+1) eine unendliche Mengen an Paaren.\n", + "Die linke Komponente des Paares ist die Eingabe der Funktion, die rechte Komponente die Ausgabe.\n", + "Eingeschränkt auf den Bereich 1..10 sieht dies Funktion so aus:" + ] + }, + { + "cell_type": "code", + "execution_count": 101, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{(1\\mapsto 2),(2\\mapsto 3),(3\\mapsto 4),(4\\mapsto 5),(5\\mapsto 6),(6\\mapsto 7),(7\\mapsto 8),(8\\mapsto 9),(9\\mapsto 10),(10\\mapsto 11)\\}$" + ], + "text/plain": [ + "{(1↦2),(2↦3),(3↦4),(4↦5),(5↦6),(6↦7),(7↦8),(8↦9),(9↦10),(10↦11)}" + ] + }, + "execution_count": 101, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "{x,y|x:1..10 & y=x+1}" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Eine Funktion kann also als Mengen von Paaren dargestellt werden. Es sind aber nicht alle Mengen an Paaren auch Funktionen. Zum Beispiel, unsere Relation sub1 von oben ist keine Funktion:" + ] + }, + { + "cell_type": "code", + "execution_count": 100, + "metadata": {}, + "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", + "<!-- Generated by graphviz version 2.28.0 (20110509.1545)\n", + " -->\n", + "<!-- Title: state Pages: 1 -->\n", + "<svg width=\"261pt\" height=\"314pt\"\n", + " viewBox=\"0.00 0.00 260.64 314.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n", + "<g id=\"graph1\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 310)\">\n", + "<title>state</title>\n", + "<polygon fill=\"white\" stroke=\"white\" points=\"-4,5 -4,-310 257.637,-310 257.637,5 -4,5\"/>\n", + "<!-- \\{3\\} -->\n", + "<g id=\"node1\" class=\"node\"><title>\\{3\\}</title>\n", + "<polygon fill=\"#cae1ff\" stroke=\"#cae1ff\" points=\"78.1929,-216 24.1929,-216 24.1929,-180 78.1929,-180 78.1929,-216\"/>\n", + "<text text-anchor=\"middle\" x=\"51.1929\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">{3}</text>\n", + "</g>\n", + "<!-- \\{2,3\\} -->\n", + "<g id=\"node3\" class=\"node\"><title>\\{2,3\\}</title>\n", + "<polygon fill=\"#cae1ff\" stroke=\"#cae1ff\" points=\"151.193,-126 97.1929,-126 97.1929,-90 151.193,-90 151.193,-126\"/>\n", + "<text text-anchor=\"middle\" x=\"124.193\" y=\"-103.8\" font-family=\"Times,serif\" font-size=\"14.00\">{2,3}</text>\n", + "</g>\n", + "<!-- \\{3\\}->\\{2,3\\} -->\n", + "<g id=\"edge2\" class=\"edge\"><title>\\{3\\}->\\{2,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M47.0235,-179.946C45.3038,-168.863 45.0413,-154.566 51.7483,-144 52.0451,-143.532 69.8441,-134.93 87.7229,-126.372\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"89.4743,-129.414 96.9873,-121.944 86.4556,-123.099 89.4743,-129.414\"/>\n", + "<text text-anchor=\"middle\" x=\"65.4152\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{1,3\\} -->\n", + "<g id=\"node5\" class=\"node\"><title>\\{1,3\\}</title>\n", + "<polygon fill=\"#cae1ff\" stroke=\"#cae1ff\" points=\"79.1929,-126 25.1929,-126 25.1929,-90 79.1929,-90 79.1929,-126\"/>\n", + "<text text-anchor=\"middle\" x=\"52.1929\" y=\"-103.8\" font-family=\"Times,serif\" font-size=\"14.00\">{1,3}</text>\n", + "</g>\n", + "<!-- \\{3\\}->\\{1,3\\} -->\n", + "<g id=\"edge4\" class=\"edge\"><title>\\{3\\}->\\{1,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M24.1554,-183.975C15.7282,-178.453 7.42392,-171.146 2.74827,-162 -0.893163,-154.877 -0.927551,-151.106 2.74827,-144 6.02749,-137.661 11.0425,-132.224 16.6425,-127.655\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"19.037,-130.245 25.132,-121.579 14.963,-124.553 19.037,-130.245\"/>\n", + "<text text-anchor=\"middle\" x=\"16.4152\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{1,2,3\\} -->\n", + "<g id=\"node7\" class=\"node\"><title>\\{1,2,3\\}</title>\n", + "<polygon fill=\"#cae1ff\" stroke=\"#cae1ff\" points=\"152.77,-36 95.616,-36 95.616,-0 152.77,-0 152.77,-36\"/>\n", + "<text text-anchor=\"middle\" x=\"124.193\" y=\"-13.8\" font-family=\"Times,serif\" font-size=\"14.00\">{1,2,3}</text>\n", + "</g>\n", + "<!-- \\{2,3\\}->\\{1,2,3\\} -->\n", + "<g id=\"edge6\" class=\"edge\"><title>\\{2,3\\}->\\{1,2,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M124.193,-89.614C124.193,-77.2403 124.193,-60.3686 124.193,-46.2198\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"127.693,-46.0504 124.193,-36.0504 120.693,-46.0504 127.693,-46.0504\"/>\n", + "<text text-anchor=\"middle\" x=\"137.415\" y=\"-58.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{1,3\\}->\\{1,2,3\\} -->\n", + "<g id=\"edge12\" class=\"edge\"><title>\\{1,3\\}->\\{1,2,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M65.4484,-89.6378C73.503,-79.2032 84.0678,-65.719 93.7483,-54 96.4602,-50.717 99.3507,-47.297 102.23,-43.9367\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"104.944,-46.1494 108.84,-36.2969 99.6503,-41.5693 104.944,-46.1494\"/>\n", + "<text text-anchor=\"middle\" x=\"106.415\" y=\"-58.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{2\\} -->\n", + "<g id=\"node8\" class=\"node\"><title>\\{2\\}</title>\n", + "<polygon fill=\"#cae1ff\" stroke=\"#cae1ff\" points=\"225.193,-216 171.193,-216 171.193,-180 225.193,-180 225.193,-216\"/>\n", + "<text text-anchor=\"middle\" x=\"198.193\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">{2}</text>\n", + "</g>\n", + "<!-- \\{2\\}->\\{2,3\\} -->\n", + "<g id=\"edge8\" class=\"edge\"><title>\\{2\\}->\\{2,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M193.88,-179.893C190.447,-168.788 184.775,-154.485 176.193,-144 171.549,-138.326 165.748,-133.215 159.72,-128.762\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"161.678,-125.861 151.447,-123.109 157.729,-131.641 161.678,-125.861\"/>\n", + "<text text-anchor=\"middle\" x=\"199.415\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{1,2\\} -->\n", + "<g id=\"node11\" class=\"node\"><title>\\{1,2\\}</title>\n", + "<polygon fill=\"#cae1ff\" stroke=\"#cae1ff\" points=\"223.193,-126 169.193,-126 169.193,-90 223.193,-90 223.193,-126\"/>\n", + "<text text-anchor=\"middle\" x=\"196.193\" y=\"-103.8\" font-family=\"Times,serif\" font-size=\"14.00\">{1,2}</text>\n", + "</g>\n", + "<!-- \\{2\\}->\\{1,2\\} -->\n", + "<g id=\"edge10\" class=\"edge\"><title>\\{2\\}->\\{1,2\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M215,-179.823C219.142,-174.525 223.014,-168.392 225.193,-162 227.774,-154.428 227.906,-151.526 225.193,-144 224.006,-140.708 222.361,-137.506 220.451,-134.463\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"223.255,-132.368 214.529,-126.358 217.603,-136.497 223.255,-132.368\"/>\n", + "<text text-anchor=\"middle\" x=\"239.415\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{1,2\\}->\\{1,2,3\\} -->\n", + "<g id=\"edge14\" class=\"edge\"><title>\\{1,2\\}->\\{1,2,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M182.74,-89.68C174.58,-79.2604 163.901,-65.7771 154.193,-54 151.501,-50.7347 148.642,-47.3251 145.799,-43.9702\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"148.435,-41.668 139.28,-36.3348 143.111,-46.2129 148.435,-41.668\"/>\n", + "<text text-anchor=\"middle\" x=\"181.415\" y=\"-58.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{1\\} -->\n", + "<g id=\"node14\" class=\"node\"><title>\\{1\\}</title>\n", + "<polygon fill=\"#cae1ff\" stroke=\"#cae1ff\" points=\"152.193,-216 98.1929,-216 98.1929,-180 152.193,-180 152.193,-216\"/>\n", + "<text text-anchor=\"middle\" x=\"125.193\" y=\"-193.8\" font-family=\"Times,serif\" font-size=\"14.00\">{1}</text>\n", + "</g>\n", + "<!-- \\{1\\}->\\{1,3\\} -->\n", + "<g id=\"edge16\" class=\"edge\"><title>\\{1\\}->\\{1,3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M110.77,-179.614C99.9021,-166.512 84.8505,-148.368 72.7263,-133.753\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"75.4154,-131.512 66.337,-126.05 70.0278,-135.982 75.4154,-131.512\"/>\n", + "<text text-anchor=\"middle\" x=\"108.415\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{1\\}->\\{1,2\\} -->\n", + "<g id=\"edge18\" class=\"edge\"><title>\\{1\\}->\\{1,2\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M130.79,-179.564C134.882,-168.597 141.21,-154.571 149.748,-144 153.073,-139.884 156.983,-135.986 161.099,-132.39\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"163.591,-134.876 169.169,-125.868 159.191,-129.432 163.591,-134.876\"/>\n", + "<text text-anchor=\"middle\" x=\"162.415\" y=\"-148.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{\\} -->\n", + "<g id=\"node17\" class=\"node\"><title>\\{\\}</title>\n", + "<polygon fill=\"#cae1ff\" stroke=\"#cae1ff\" points=\"152.193,-306 98.1929,-306 98.1929,-270 152.193,-270 152.193,-306\"/>\n", + "<text text-anchor=\"middle\" x=\"125.193\" y=\"-283.8\" font-family=\"Times,serif\" font-size=\"14.00\">{}</text>\n", + "</g>\n", + "<!-- \\{\\}->\\{3\\} -->\n", + "<g id=\"edge20\" class=\"edge\"><title>\\{\\}->\\{3\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M110.231,-269.993C105.269,-264.302 99.7402,-257.904 94.7483,-252 87.0945,-242.948 78.8083,-232.923 71.5385,-224.05\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"74.2326,-221.816 65.1951,-216.287 68.8119,-226.245 74.2326,-221.816\"/>\n", + "<text text-anchor=\"middle\" x=\"107.415\" y=\"-238.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{\\}->\\{2\\} -->\n", + "<g id=\"edge22\" class=\"edge\"><title>\\{\\}->\\{2\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M139.934,-269.989C144.823,-264.297 150.272,-257.9 155.193,-252 162.669,-243.035 170.759,-233.122 177.883,-224.317\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"180.811,-226.262 184.366,-216.282 175.363,-221.867 180.811,-226.262\"/>\n", + "<text text-anchor=\"middle\" x=\"182.415\" y=\"-238.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "<!-- \\{\\}->\\{1\\} -->\n", + "<g id=\"edge24\" class=\"edge\"><title>\\{\\}->\\{1\\}</title>\n", + "<path fill=\"none\" stroke=\"firebrick\" d=\"M125.193,-269.614C125.193,-257.24 125.193,-240.369 125.193,-226.22\"/>\n", + "<polygon fill=\"firebrick\" stroke=\"firebrick\" points=\"128.693,-226.05 125.193,-216.05 121.693,-226.05 128.693,-226.05\"/>\n", + "<text text-anchor=\"middle\" x=\"138.415\" y=\"-238.8\" font-family=\"Times,serif\" font-size=\"14.00\">sub1</text>\n", + "</g>\n", + "</g>\n", + "</svg>" + ], + "text/plain": [ + "<Dot visualization: expr_as_graph [Arsub1hA={1,2,3} & r={(1,2),(2,3)} & sub1={({},{1}),({},{2}),({},{3}),({1},{1,2}),({1},{1,3}),({1,2},{1,2,3}),({1,3},{1,2,3}),({2},{1,2}),({2},{2,3}),({2,3},{1,2,3}),({3},{1,3}),({3},{2,3})} & h={(2,1),(4,2),(6,3),(8,4),(10,5)}(\"sub1\",sub1)]>" + ] + }, + "execution_count": 100, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + ":dot expr_as_graph (\"sub1\",sub1)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Die Eingabe ```{1}``` hat zwei mögliche Ausgaben (Nachfolger): ```{1,3}``` und ```{1,2}```. Die Eingabe $\\emptyset$ hat drei mögliche Ausgaben:" + ] + }, + { + "cell_type": "code", + "execution_count": 102, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\{(\\emptyset\\mapsto\\{1\\}),(\\emptyset\\mapsto\\{2\\}),(\\emptyset\\mapsto\\{3\\}),(\\{1\\}\\mapsto\\{1,2\\}),(\\{1\\}\\mapsto\\{1,3\\}),(\\{1,2\\}\\mapsto\\{1,2,3\\}),(\\{1,3\\}\\mapsto\\{1,2,3\\}),(\\{2\\}\\mapsto\\{1,2\\}),(\\{2\\}\\mapsto\\{2,3\\}),(\\{2,3\\}\\mapsto\\{1,2,3\\}),(\\{3\\}\\mapsto\\{1,3\\}),(\\{3\\}\\mapsto\\{2,3\\})\\}$" + ], + "text/plain": [ + "{(∅↦{1}),(∅↦{2}),(∅↦{3}),({1}↦{1,2}),({1}↦{1,3}),({1,2}↦{1,2,3}),({1,3}↦{1,2,3}),({2}↦{1,2}),({2}↦{2,3}),({2,3}↦{1,2,3}),({3}↦{1,3}),({3}↦{2,3})}" + ] + }, + "execution_count": 102, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sub1" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Eine (totale) Funktion $F$ von $A$ nach $B$ ist \n", + "* eine Relation von $A$ nach $B$ (also eine Untermenge von $A\\times B$),so dass\n", + " * $\\forall a.( a\\in A \\Rightarrow \\exists b.( (a,b) \\in F))$\n", + " * $\\forall (a,b,c).(((a,b)\\in F \\wedge (a,c)\\in F) \\Rightarrow b=c)$\n", + " \n", + " Wir schreiben dann $F \\in A \\rightarrow B$." + ] + }, + { + "cell_type": "code", + "execution_count": 104, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\mathit{FALSE}$" + ], + "text/plain": [ + "FALSE" + ] + }, + "execution_count": 104, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "∀(a,b,c).((a,b)∈sub1 & (a,c)∈sub1 ⇒ b=c)" + ] + }, + { + "cell_type": "code", + "execution_count": 114, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\mathit{FALSE}$" + ], + "text/plain": [ + "FALSE" + ] + }, + "execution_count": 114, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sub1 ∈ POW(1..3) --> POW(1..3)" + ] + }, + { + "cell_type": "code", + "execution_count": 107, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{(1\\mapsto 2),(2\\mapsto 3),(3\\mapsto 4),(4\\mapsto 5),(5\\mapsto 6),(6\\mapsto 7),(7\\mapsto 8),(8\\mapsto 9),(9\\mapsto 10),(10\\mapsto 11)\\}$" + ], + "text/plain": [ + "{(1↦2),(2↦3),(3↦4),(4↦5),(5↦6),(6↦7),(7↦8),(8↦9),(9↦10),(10↦11)}" + ] + }, + "execution_count": 107, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + ":let i10 {x,y|x:1..10 & y=x+1}" + ] + }, + { + "cell_type": "code", + "execution_count": 108, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\mathit{TRUE}$\n", + "\n", + "**Solution:**\n", + "* $\\mathit{A} = \\{1,2,3\\}$\n", + "* $\\mathit{r} = \\{(1\\mapsto 2),(2\\mapsto 3)\\}$\n", + "* $\\mathit{sub1} = \\{(\\emptyset\\mapsto\\{1\\}),(\\emptyset\\mapsto\\{2\\}),(\\emptyset\\mapsto\\{3\\}),(\\{1\\}\\mapsto\\{1,2\\}),(\\{1\\}\\mapsto\\{1,3\\}),(\\{1,2\\}\\mapsto\\{1,2,3\\}),(\\{1,3\\}\\mapsto\\{1,2,3\\}),(\\{2\\}\\mapsto\\{1,2\\}),(\\{2\\}\\mapsto\\{2,3\\}),(\\{2,3\\}\\mapsto\\{1,2,3\\}),(\\{3\\}\\mapsto\\{1,3\\}),(\\{3\\}\\mapsto\\{2,3\\})\\}$\n", + "* $\\mathit{h} = \\{(2\\mapsto 1),(4\\mapsto 2),(6\\mapsto 3),(8\\mapsto 4),(10\\mapsto 5)\\}$\n", + "* $\\mathit{i10} = \\{(1\\mapsto 2),(2\\mapsto 3),(3\\mapsto 4),(4\\mapsto 5),(5\\mapsto 6),(6\\mapsto 7),(7\\mapsto 8),(8\\mapsto 9),(9\\mapsto 10),(10\\mapsto 11)\\}$" + ], + "text/plain": [ + "TRUE\n", + "\n", + "Solution:\n", + "\tA = {1,2,3}\n", + "\tr = {(1↦2),(2↦3)}\n", + "\tsub1 = {(∅↦{1}),(∅↦{2}),(∅↦{3}),({1}↦{1,2}),({1}↦{1,3}),({1,2}↦{1,2,3}),({1,3}↦{1,2,3}),({2}↦{1,2}),({2}↦{2,3}),({2,3}↦{1,2,3}),({3}↦{1,3}),({3}↦{2,3})}\n", + "\th = {(2↦1),(4↦2),(6↦3),(8↦4),(10↦5)}\n", + "\ti10 = {(1↦2),(2↦3),(3↦4),(4↦5),(5↦6),(6↦7),(7↦8),(8↦9),(9↦10),(10↦11)}" + ] + }, + "execution_count": 108, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "∀(a,b,c).((a,b)∈i10 & (a,c)∈i10 ⇒ b=c)" + ] + }, + { + "cell_type": "code", + "execution_count": 111, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\mathit{TRUE}$\n", + "\n", + "**Solution:**\n", + "* $\\mathit{A} = \\{1,2,3\\}$\n", + "* $\\mathit{r} = \\{(1\\mapsto 2),(2\\mapsto 3)\\}$\n", + "* $\\mathit{sub1} = \\{(\\emptyset\\mapsto\\{1\\}),(\\emptyset\\mapsto\\{2\\}),(\\emptyset\\mapsto\\{3\\}),(\\{1\\}\\mapsto\\{1,2\\}),(\\{1\\}\\mapsto\\{1,3\\}),(\\{1,2\\}\\mapsto\\{1,2,3\\}),(\\{1,3\\}\\mapsto\\{1,2,3\\}),(\\{2\\}\\mapsto\\{1,2\\}),(\\{2\\}\\mapsto\\{2,3\\}),(\\{2,3\\}\\mapsto\\{1,2,3\\}),(\\{3\\}\\mapsto\\{1,3\\}),(\\{3\\}\\mapsto\\{2,3\\})\\}$\n", + "* $\\mathit{h} = \\{(2\\mapsto 1),(4\\mapsto 2),(6\\mapsto 3),(8\\mapsto 4),(10\\mapsto 5)\\}$\n", + "* $\\mathit{i10} = \\{(1\\mapsto 2),(2\\mapsto 3),(3\\mapsto 4),(4\\mapsto 5),(5\\mapsto 6),(6\\mapsto 7),(7\\mapsto 8),(8\\mapsto 9),(9\\mapsto 10),(10\\mapsto 11)\\}$" + ], + "text/plain": [ + "TRUE\n", + "\n", + "Solution:\n", + "\tA = {1,2,3}\n", + "\tr = {(1↦2),(2↦3)}\n", + "\tsub1 = {(∅↦{1}),(∅↦{2}),(∅↦{3}),({1}↦{1,2}),({1}↦{1,3}),({1,2}↦{1,2,3}),({1,3}↦{1,2,3}),({2}↦{1,2}),({2}↦{2,3}),({2,3}↦{1,2,3}),({3}↦{1,3}),({3}↦{2,3})}\n", + "\th = {(2↦1),(4↦2),(6↦3),(8↦4),(10↦5)}\n", + "\ti10 = {(1↦2),(2↦3),(3↦4),(4↦5),(5↦6),(6↦7),(7↦8),(8↦9),(9↦10),(10↦11)}" + ] + }, + "execution_count": 111, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "i10 ∈ 1..10 --> 2..11" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Anmerkung: es wird nicht geprüft ob der komplette Wertebereich abgedeckt wird:" + ] + }, + { + "cell_type": "code", + "execution_count": 115, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\mathit{TRUE}$\n", + "\n", + "**Solution:**\n", + "* $\\mathit{A} = \\{1,2,3\\}$\n", + "* $\\mathit{r} = \\{(1\\mapsto 2),(2\\mapsto 3)\\}$\n", + "* $\\mathit{sub1} = \\{(\\emptyset\\mapsto\\{1\\}),(\\emptyset\\mapsto\\{2\\}),(\\emptyset\\mapsto\\{3\\}),(\\{1\\}\\mapsto\\{1,2\\}),(\\{1\\}\\mapsto\\{1,3\\}),(\\{1,2\\}\\mapsto\\{1,2,3\\}),(\\{1,3\\}\\mapsto\\{1,2,3\\}),(\\{2\\}\\mapsto\\{1,2\\}),(\\{2\\}\\mapsto\\{2,3\\}),(\\{2,3\\}\\mapsto\\{1,2,3\\}),(\\{3\\}\\mapsto\\{1,3\\}),(\\{3\\}\\mapsto\\{2,3\\})\\}$\n", + "* $\\mathit{h} = \\{(2\\mapsto 1),(4\\mapsto 2),(6\\mapsto 3),(8\\mapsto 4),(10\\mapsto 5)\\}$\n", + "* $\\mathit{i10} = \\{(1\\mapsto 2),(2\\mapsto 3),(3\\mapsto 4),(4\\mapsto 5),(5\\mapsto 6),(6\\mapsto 7),(7\\mapsto 8),(8\\mapsto 9),(9\\mapsto 10),(10\\mapsto 11)\\}$" + ], + "text/plain": [ + "TRUE\n", + "\n", + "Solution:\n", + "\tA = {1,2,3}\n", + "\tr = {(1↦2),(2↦3)}\n", + "\tsub1 = {(∅↦{1}),(∅↦{2}),(∅↦{3}),({1}↦{1,2}),({1}↦{1,3}),({1,2}↦{1,2,3}),({1,3}↦{1,2,3}),({2}↦{1,2}),({2}↦{2,3}),({2,3}↦{1,2,3}),({3}↦{1,3}),({3}↦{2,3})}\n", + "\th = {(2↦1),(4↦2),(6↦3),(8↦4),(10↦5)}\n", + "\ti10 = {(1↦2),(2↦3),(3↦4),(4↦5),(5↦6),(6↦7),(7↦8),(8↦9),(9↦10),(10↦11)}" + ] + }, + "execution_count": 115, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "i10 ∈ 1..10 --> 0..100" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Es wird aber wohl geprüft ob der Definitionsbereich komplett abgedeckt wird:" + ] + }, + { + "cell_type": "code", + "execution_count": 116, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\mathit{FALSE}$" + ], + "text/plain": [ + "FALSE" + ] + }, + "execution_count": 116, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "i10 ∈ 2..10 --> 0..100" + ] + }, + { + "cell_type": "code", + "execution_count": 117, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\mathit{FALSE}$" + ], + "text/plain": [ + "FALSE" + ] + }, + "execution_count": 117, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "i10 ∈ 0..10 --> 0..100" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Was kann man mit Funktionen machen? Da Funktionen *nur* besondere Relationen sind, und Relationen *nur* besondere Mengen sind, kann man alle Mengen und Relationsoperatoren anwenden:" + ] + }, + { + "cell_type": "code", + "execution_count": 118, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\mathit{TRUE}$\n", + "\n", + "**Solution:**\n", + "* $\\mathit{A} = \\{1,2,3\\}$\n", + "* $\\mathit{r} = \\{(1\\mapsto 2),(2\\mapsto 3)\\}$\n", + "* $\\mathit{sub1} = \\{(\\emptyset\\mapsto\\{1\\}),(\\emptyset\\mapsto\\{2\\}),(\\emptyset\\mapsto\\{3\\}),(\\{1\\}\\mapsto\\{1,2\\}),(\\{1\\}\\mapsto\\{1,3\\}),(\\{1,2\\}\\mapsto\\{1,2,3\\}),(\\{1,3\\}\\mapsto\\{1,2,3\\}),(\\{2\\}\\mapsto\\{1,2\\}),(\\{2\\}\\mapsto\\{2,3\\}),(\\{2,3\\}\\mapsto\\{1,2,3\\}),(\\{3\\}\\mapsto\\{1,3\\}),(\\{3\\}\\mapsto\\{2,3\\})\\}$\n", + "* $\\mathit{h} = \\{(2\\mapsto 1),(4\\mapsto 2),(6\\mapsto 3),(8\\mapsto 4),(10\\mapsto 5)\\}$\n", + "* $\\mathit{i10} = \\{(1\\mapsto 2),(2\\mapsto 3),(3\\mapsto 4),(4\\mapsto 5),(5\\mapsto 6),(6\\mapsto 7),(7\\mapsto 8),(8\\mapsto 9),(9\\mapsto 10),(10\\mapsto 11)\\}$\n", + "* $\\mathit{z} = 5$" + ], + "text/plain": [ + "TRUE\n", + "\n", + "Solution:\n", + "\tA = {1,2,3}\n", + "\tr = {(1↦2),(2↦3)}\n", + "\tsub1 = {(∅↦{1}),(∅↦{2}),(∅↦{3}),({1}↦{1,2}),({1}↦{1,3}),({1,2}↦{1,2,3}),({1,3}↦{1,2,3}),({2}↦{1,2}),({2}↦{2,3}),({2,3}↦{1,2,3}),({3}↦{1,3}),({3}↦{2,3})}\n", + "\th = {(2↦1),(4↦2),(6↦3),(8↦4),(10↦5)}\n", + "\ti10 = {(1↦2),(2↦3),(3↦4),(4↦5),(5↦6),(6↦7),(7↦8),(8↦9),(9↦10),(10↦11)}\n", + "\tz = 5" + ] + }, + "execution_count": 118, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(4,z) ∈ i10" + ] + }, + { + "cell_type": "code", + "execution_count": 119, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{1,2,3,4,5,6,7,8,9,10\\}$" + ], + "text/plain": [ + "{1,2,3,4,5,6,7,8,9,10}" + ] + }, + "execution_count": 119, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dom(i10)" + ] + }, + { + "cell_type": "code", + "execution_count": 120, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{2,3,4,5,6,7,8,9,10,11\\}$" + ], + "text/plain": [ + "{2,3,4,5,6,7,8,9,10,11}" + ] + }, + "execution_count": 120, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ran(i10)" + ] + }, + { + "cell_type": "code", + "execution_count": 122, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{5,6\\}$" + ], + "text/plain": [ + "{5,6}" + ] + }, + "execution_count": 122, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "i10[{4,5}]" + ] + }, + { + "cell_type": "code", + "execution_count": 123, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{5\\}$" + ], + "text/plain": [ + "{5}" + ] + }, + "execution_count": 123, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "i10[{4}]" + ] + }, + { + "cell_type": "code", + "execution_count": 124, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{3\\}$" + ], + "text/plain": [ + "{3}" + ] + }, + "execution_count": 124, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "i10~[{4}]" + ] + }, + { + "cell_type": "code", + "execution_count": 125, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{6\\}$" + ], + "text/plain": [ + "{6}" + ] + }, + "execution_count": 125, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(i10 ; i10)[{4}]" + ] + }, + { + "cell_type": "code", + "execution_count": 126, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{5,6,7,8,9,10,11\\}$" + ], + "text/plain": [ + "{5,6,7,8,9,10,11}" + ] + }, + "execution_count": 126, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "closure1(i10)[{4}]" + ] + }, + { + "cell_type": "code", + "execution_count": 127, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{1,2,3\\}$" + ], + "text/plain": [ + "{1,2,3}" + ] + }, + "execution_count": 127, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "closure1(i10~)[{4}]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Anmerkung: um den Wert einer Funktion $F$ für eine Eingabe $x$ zu berechnen, kann man das relationale Bild $F[\\{x\\}]$ verwenden. Aber: das Ergebnis ist eine Menge! Man kann also nicht direkt zB arithmetische Operatoren anwenden. Dafür wird eine neue Operation für Funktionen eingeführt: die **Funktionsanwendung**: ```F(x)```." + ] + }, + { + "cell_type": "code", + "execution_count": 128, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$5$" + ], + "text/plain": [ + "5" + ] + }, + "execution_count": 128, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "i10(4)" + ] + }, + { + "cell_type": "code", + "execution_count": 129, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$10$" + ], + "text/plain": [ + "10" + ] + }, + "execution_count": 129, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "i10(4) + i10(4)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Es ist ein Fehler eine Funktion ausserhalb des Definitionsbereiches anzuwenden. Beim relationalen Bild ist dies erlaubt und man bekommt dort die leere Menge als Ausgabe." + ] + }, + { + "cell_type": "code", + "execution_count": 130, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\emptyset$" + ], + "text/plain": [ + "∅" + ] + }, + "execution_count": 130, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "i10[{100}]" + ] + }, + { + "cell_type": "code", + "execution_count": 131, + "metadata": {}, + "outputs": [ + { + "ename": "CommandExecutionException", + "evalue": ":eval: NOT-WELL-DEFINED: \nfunction applied outside of domain (#7): Function argument: 100, function value: {}\n ### Line: 1, Column: 316 until 324\n\n", + "output_type": "error", + "traceback": [ + "\u001b[1m\u001b[31m:eval: NOT-WELL-DEFINED: \u001b[0m", + "\u001b[1m\u001b[31mfunction applied outside of domain (#7): Function argument: 100, function value: {}\u001b[0m", + "\u001b[1m\u001b[31m ### Line: 1, Column: 316 until 324\u001b[0m" + ] + } + ], + "source": [ + "i10(100)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Alle möglichen Funktionen über einen Definitionsbereich ergeben wieder eine Menge:" + ] + }, + { + "cell_type": "code", + "execution_count": 135, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{\\{(1\\mapsto 1),(2\\mapsto 1)\\},\\{(1\\mapsto 1),(2\\mapsto 2)\\},\\{(1\\mapsto 2),(2\\mapsto 1)\\},\\{(1\\mapsto 2),(2\\mapsto 2)\\}\\}$" + ], + "text/plain": [ + "{{(1↦1),(2↦1)},{(1↦1),(2↦2)},{(1↦2),(2↦1)},{(1↦2),(2↦2)}}" + ] + }, + "execution_count": 135, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "1..2 --> 1..2" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Es gibt auch noch andere Arten an Funktionen:\n", + "* partielle Funktionen, +->\n", + "* injektive (umkehrbare) Funktionen >->\n", + "* surjektive Funktionen die den Wertebereich komplett abdecken -->>\n", + "* injektive und surjektive Funktionen >->>, auch Bijektionen gennant\n", + "\n", + "(Die Pfeilsymbole sind sehr spezifisch für die B Sprache. Wir werden diese nicht im Skript verwenden.)" + ] + }, + { + "cell_type": "code", + "execution_count": 137, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\{\\emptyset,\\{(1\\mapsto 1)\\},\\{(1\\mapsto 1),(2\\mapsto 1)\\},\\{(1\\mapsto 1),(2\\mapsto 2)\\},\\{(1\\mapsto 2)\\},\\{(1\\mapsto 2),(2\\mapsto 1)\\},\\{(1\\mapsto 2),(2\\mapsto 2)\\},\\{(2\\mapsto 1)\\},\\{(2\\mapsto 2)\\}\\}$" + ], + "text/plain": [ + "{∅,{(1↦1)},{(1↦1),(2↦1)},{(1↦1),(2↦2)},{(1↦2)},{(1↦2),(2↦1)},{(1↦2),(2↦2)},{(2↦1)},{(2↦2)}}" + ] + }, + "execution_count": 137, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "1..2 +-> 1..2" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Folgende fünf Funktionen sind partiell und nicht total:" + ] + }, + { + "cell_type": "code", + "execution_count": 141, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\{\\emptyset,\\{(1\\mapsto 1)\\},\\{(1\\mapsto 2)\\},\\{(2\\mapsto 1)\\},\\{(2\\mapsto 2)\\}\\}$" + ], + "text/plain": [ + "{∅,{(1↦1)},{(1↦2)},{(2↦1)},{(2↦2)}}" + ] + }, + "execution_count": 141, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(1..2 +-> 1..2) \\ (1..2 --> 1..2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Das sind die totalen umkehrbaren Funktionen:" + ] + }, + { + "cell_type": "code", + "execution_count": 143, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{\\{(1\\mapsto 1),(2\\mapsto 2)\\},\\{(1\\mapsto 2),(2\\mapsto 1)\\}\\}$" + ], + "text/plain": [ + "{{(1↦1),(2↦2)},{(1↦2),(2↦1)}}" + ] + }, + "execution_count": 143, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "1..2 >-> 1..2" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In diesem Falle sind diese identisch zu den surjektiven Funktionen und den Bijektionen:" + ] + }, + { + "cell_type": "code", + "execution_count": 139, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{\\{(1\\mapsto 1),(2\\mapsto 2)\\},\\{(1\\mapsto 2),(2\\mapsto 1)\\}\\}$" + ], + "text/plain": [ + "{{(1↦1),(2↦2)},{(1↦2),(2↦1)}}" + ] + }, + "execution_count": 139, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "1..2 -->> 1..2" + ] + }, + { + "cell_type": "code", + "execution_count": 140, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{\\{(1\\mapsto 1),(2\\mapsto 2)\\},\\{(1\\mapsto 2),(2\\mapsto 1)\\}\\}$" + ], + "text/plain": [ + "{{(1↦1),(2↦2)},{(1↦2),(2↦1)}}" + ] + }, + "execution_count": 140, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "1..2 >->> 1..2" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": {