Last active
November 8, 2024 15:26
-
-
Save coppeliaMLA/87d21ec8fe6672386dbb9896b636ab48 to your computer and use it in GitHub Desktop.
Indy World
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Indy world (a knock off Wumpus world)\n", | |
"\n", | |
"Now we move into AI proper by creating an agent powered by propositional logic. \n", | |
"\n", | |
"I will now explain the puzzle our agent must solve.\n", | |
"\n", | |
"<img src=\"indy_world.png\" width=\"600\">\n" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Let's first construct the initial knowledge base. Notice the direction of implication. The pit implies the breeze, not the other way around." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/latex": [ | |
"$\\displaystyle \\left(P_{1 1} \\Rightarrow B_{0 1}\\right) \\wedge \\left(P_{1 1} \\Rightarrow B_{1 0}\\right) \\wedge \\left(P_{1 1} \\Rightarrow B_{1 2}\\right) \\wedge \\left(P_{1 1} \\Rightarrow B_{2 1}\\right) \\wedge \\left(P_{1 2} \\Rightarrow B_{0 2}\\right) \\wedge \\left(P_{1 2} \\Rightarrow B_{1 1}\\right) \\wedge \\left(P_{1 2} \\Rightarrow B_{1 3}\\right) \\wedge \\left(P_{1 2} \\Rightarrow B_{2 2}\\right) \\wedge \\left(P_{1 3} \\Rightarrow B_{0 3}\\right) \\wedge \\left(P_{1 3} \\Rightarrow B_{1 2}\\right) \\wedge \\left(P_{1 3} \\Rightarrow B_{1 4}\\right) \\wedge \\left(P_{1 3} \\Rightarrow B_{2 3}\\right) \\wedge \\left(P_{1 4} \\Rightarrow B_{0 4}\\right) \\wedge \\left(P_{1 4} \\Rightarrow B_{1 3}\\right) \\wedge \\left(P_{1 4} \\Rightarrow B_{1 5}\\right) \\wedge \\left(P_{1 4} \\Rightarrow B_{2 4}\\right) \\wedge \\left(P_{2 1} \\Rightarrow B_{1 1}\\right) \\wedge \\left(P_{2 1} \\Rightarrow B_{2 0}\\right) \\wedge \\left(P_{2 1} \\Rightarrow B_{2 2}\\right) \\wedge \\left(P_{2 1} \\Rightarrow B_{3 1}\\right) \\wedge \\left(P_{2 2} \\Rightarrow B_{1 2}\\right) \\wedge \\left(P_{2 2} \\Rightarrow B_{2 1}\\right) \\wedge \\left(P_{2 2} \\Rightarrow B_{2 3}\\right) \\wedge \\left(P_{2 2} \\Rightarrow B_{3 2}\\right) \\wedge \\left(P_{2 3} \\Rightarrow B_{1 3}\\right) \\wedge \\left(P_{2 3} \\Rightarrow B_{2 2}\\right) \\wedge \\left(P_{2 3} \\Rightarrow B_{2 4}\\right) \\wedge \\left(P_{2 3} \\Rightarrow B_{3 3}\\right) \\wedge \\left(P_{2 4} \\Rightarrow B_{1 4}\\right) \\wedge \\left(P_{2 4} \\Rightarrow B_{2 3}\\right) \\wedge \\left(P_{2 4} \\Rightarrow B_{2 5}\\right) \\wedge \\left(P_{2 4} \\Rightarrow B_{3 4}\\right) \\wedge \\left(P_{3 1} \\Rightarrow B_{2 1}\\right) \\wedge \\left(P_{3 1} \\Rightarrow B_{3 0}\\right) \\wedge \\left(P_{3 1} \\Rightarrow B_{3 2}\\right) \\wedge \\left(P_{3 1} \\Rightarrow B_{4 1}\\right) \\wedge \\left(P_{3 2} \\Rightarrow B_{2 2}\\right) \\wedge \\left(P_{3 2} \\Rightarrow B_{3 1}\\right) \\wedge \\left(P_{3 2} \\Rightarrow B_{3 3}\\right) \\wedge \\left(P_{3 2} \\Rightarrow B_{4 2}\\right) \\wedge \\left(P_{3 3} \\Rightarrow B_{2 3}\\right) \\wedge \\left(P_{3 3} \\Rightarrow B_{3 2}\\right) \\wedge \\left(P_{3 3} \\Rightarrow B_{3 4}\\right) \\wedge \\left(P_{3 3} \\Rightarrow B_{4 3}\\right) \\wedge \\left(P_{3 4} \\Rightarrow B_{2 4}\\right) \\wedge \\left(P_{3 4} \\Rightarrow B_{3 3}\\right) \\wedge \\left(P_{3 4} \\Rightarrow B_{3 5}\\right) \\wedge \\left(P_{3 4} \\Rightarrow B_{4 4}\\right) \\wedge \\left(P_{4 1} \\Rightarrow B_{3 1}\\right) \\wedge \\left(P_{4 1} \\Rightarrow B_{4 0}\\right) \\wedge \\left(P_{4 1} \\Rightarrow B_{4 2}\\right) \\wedge \\left(P_{4 1} \\Rightarrow B_{5 1}\\right) \\wedge \\left(P_{4 2} \\Rightarrow B_{3 2}\\right) \\wedge \\left(P_{4 2} \\Rightarrow B_{4 1}\\right) \\wedge \\left(P_{4 2} \\Rightarrow B_{4 3}\\right) \\wedge \\left(P_{4 2} \\Rightarrow B_{5 2}\\right) \\wedge \\left(P_{4 3} \\Rightarrow B_{3 3}\\right) \\wedge \\left(P_{4 3} \\Rightarrow B_{4 2}\\right) \\wedge \\left(P_{4 3} \\Rightarrow B_{4 4}\\right) \\wedge \\left(P_{4 3} \\Rightarrow B_{5 3}\\right) \\wedge \\left(P_{4 4} \\Rightarrow B_{3 4}\\right) \\wedge \\left(P_{4 4} \\Rightarrow B_{4 3}\\right) \\wedge \\left(P_{4 4} \\Rightarrow B_{4 5}\\right) \\wedge \\left(P_{4 4} \\Rightarrow B_{5 4}\\right) \\wedge \\left(T_{1 1} \\Rightarrow S_{0 1}\\right) \\wedge \\left(T_{1 1} \\Rightarrow S_{1 0}\\right) \\wedge \\left(T_{1 1} \\Rightarrow S_{1 2}\\right) \\wedge \\left(T_{1 1} \\Rightarrow S_{2 1}\\right) \\wedge \\left(T_{1 2} \\Rightarrow S_{0 2}\\right) \\wedge \\left(T_{1 2} \\Rightarrow S_{1 1}\\right) \\wedge \\left(T_{1 2} \\Rightarrow S_{1 3}\\right) \\wedge \\left(T_{1 2} \\Rightarrow S_{2 2}\\right) \\wedge \\left(T_{1 3} \\Rightarrow S_{0 3}\\right) \\wedge \\left(T_{1 3} \\Rightarrow S_{1 2}\\right) \\wedge \\left(T_{1 3} \\Rightarrow S_{1 4}\\right) \\wedge \\left(T_{1 3} \\Rightarrow S_{2 3}\\right) \\wedge \\left(T_{1 4} \\Rightarrow S_{0 4}\\right) \\wedge \\left(T_{1 4} \\Rightarrow S_{1 3}\\right) \\wedge \\left(T_{1 4} \\Rightarrow S_{1 5}\\right) \\wedge \\left(T_{1 4} \\Rightarrow S_{2 4}\\right) \\wedge \\left(T_{2 1} \\Rightarrow S_{1 1}\\right) \\wedge \\left(T_{2 1} \\Rightarrow S_{2 0}\\right) \\wedge \\left(T_{2 1} \\Rightarrow S_{2 2}\\right) \\wedge \\left(T_{2 1} \\Rightarrow S_{3 1}\\right) \\wedge \\left(T_{2 2} \\Rightarrow S_{1 2}\\right) \\wedge \\left(T_{2 2} \\Rightarrow S_{2 1}\\right) \\wedge \\left(T_{2 2} \\Rightarrow S_{2 3}\\right) \\wedge \\left(T_{2 2} \\Rightarrow S_{3 2}\\right) \\wedge \\left(T_{2 3} \\Rightarrow S_{1 3}\\right) \\wedge \\left(T_{2 3} \\Rightarrow S_{2 2}\\right) \\wedge \\left(T_{2 3} \\Rightarrow S_{2 4}\\right) \\wedge \\left(T_{2 3} \\Rightarrow S_{3 3}\\right) \\wedge \\left(T_{2 4} \\Rightarrow S_{1 4}\\right) \\wedge \\left(T_{2 4} \\Rightarrow S_{2 3}\\right) \\wedge \\left(T_{2 4} \\Rightarrow S_{2 5}\\right) \\wedge \\left(T_{2 4} \\Rightarrow S_{3 4}\\right) \\wedge \\left(T_{3 1} \\Rightarrow S_{2 1}\\right) \\wedge \\left(T_{3 1} \\Rightarrow S_{3 0}\\right) \\wedge \\left(T_{3 1} \\Rightarrow S_{3 2}\\right) \\wedge \\left(T_{3 1} \\Rightarrow S_{4 1}\\right) \\wedge \\left(T_{3 2} \\Rightarrow S_{2 2}\\right) \\wedge \\left(T_{3 2} \\Rightarrow S_{3 1}\\right) \\wedge \\left(T_{3 2} \\Rightarrow S_{3 3}\\right) \\wedge \\left(T_{3 2} \\Rightarrow S_{4 2}\\right) \\wedge \\left(T_{3 3} \\Rightarrow S_{2 3}\\right) \\wedge \\left(T_{3 3} \\Rightarrow S_{3 2}\\right) \\wedge \\left(T_{3 3} \\Rightarrow S_{3 4}\\right) \\wedge \\left(T_{3 3} \\Rightarrow S_{4 3}\\right) \\wedge \\left(T_{3 4} \\Rightarrow S_{2 4}\\right) \\wedge \\left(T_{3 4} \\Rightarrow S_{3 3}\\right) \\wedge \\left(T_{3 4} \\Rightarrow S_{3 5}\\right) \\wedge \\left(T_{3 4} \\Rightarrow S_{4 4}\\right) \\wedge \\left(T_{4 1} \\Rightarrow S_{3 1}\\right) \\wedge \\left(T_{4 1} \\Rightarrow S_{4 0}\\right) \\wedge \\left(T_{4 1} \\Rightarrow S_{4 2}\\right) \\wedge \\left(T_{4 1} \\Rightarrow S_{5 1}\\right) \\wedge \\left(T_{4 2} \\Rightarrow S_{3 2}\\right) \\wedge \\left(T_{4 2} \\Rightarrow S_{4 1}\\right) \\wedge \\left(T_{4 2} \\Rightarrow S_{4 3}\\right) \\wedge \\left(T_{4 2} \\Rightarrow S_{5 2}\\right) \\wedge \\left(T_{4 3} \\Rightarrow S_{3 3}\\right) \\wedge \\left(T_{4 3} \\Rightarrow S_{4 2}\\right) \\wedge \\left(T_{4 3} \\Rightarrow S_{4 4}\\right) \\wedge \\left(T_{4 3} \\Rightarrow S_{5 3}\\right) \\wedge \\left(T_{4 4} \\Rightarrow S_{3 4}\\right) \\wedge \\left(T_{4 4} \\Rightarrow S_{4 3}\\right) \\wedge \\left(T_{4 4} \\Rightarrow S_{4 5}\\right) \\wedge \\left(T_{4 4} \\Rightarrow S_{5 4}\\right) \\wedge \\neg B_{1 1} \\wedge \\neg P_{1 1} \\wedge \\neg S_{1 1} \\wedge \\neg T_{1 1}$" | |
], | |
"text/plain": [ | |
"~B_1_1 & ~P_1_1 & ~S_1_1 & ~T_1_1 & (Implies(P_1_1, B_0_1)) & (Implies(P_1_1, B_1_0)) & (Implies(P_1_1, B_1_2)) & (Implies(P_1_1, B_2_1)) & (Implies(P_1_2, B_0_2)) & (Implies(P_1_2, B_1_1)) & (Implies(P_1_2, B_1_3)) & (Implies(P_1_2, B_2_2)) & (Implies(P_1_3, B_0_3)) & (Implies(P_1_3, B_1_2)) & (Implies(P_1_3, B_1_4)) & (Implies(P_1_3, B_2_3)) & (Implies(P_1_4, B_0_4)) & (Implies(P_1_4, B_1_3)) & (Implies(P_1_4, B_1_5)) & (Implies(P_1_4, B_2_4)) & (Implies(P_2_1, B_1_1)) & (Implies(P_2_1, B_2_0)) & (Implies(P_2_1, B_2_2)) & (Implies(P_2_1, B_3_1)) & (Implies(P_2_2, B_1_2)) & (Implies(P_2_2, B_2_1)) & (Implies(P_2_2, B_2_3)) & (Implies(P_2_2, B_3_2)) & (Implies(P_2_3, B_1_3)) & (Implies(P_2_3, B_2_2)) & (Implies(P_2_3, B_2_4)) & (Implies(P_2_3, B_3_3)) & (Implies(P_2_4, B_1_4)) & (Implies(P_2_4, B_2_3)) & (Implies(P_2_4, B_2_5)) & (Implies(P_2_4, B_3_4)) & (Implies(P_3_1, B_2_1)) & (Implies(P_3_1, B_3_0)) & (Implies(P_3_1, B_3_2)) & (Implies(P_3_1, B_4_1)) & (Implies(P_3_2, B_2_2)) & (Implies(P_3_2, B_3_1)) & (Implies(P_3_2, B_3_3)) & (Implies(P_3_2, B_4_2)) & (Implies(P_3_3, B_2_3)) & (Implies(P_3_3, B_3_2)) & (Implies(P_3_3, B_3_4)) & (Implies(P_3_3, B_4_3)) & (Implies(P_3_4, B_2_4)) & (Implies(P_3_4, B_3_3)) & (Implies(P_3_4, B_3_5)) & (Implies(P_3_4, B_4_4)) & (Implies(P_4_1, B_3_1)) & (Implies(P_4_1, B_4_0)) & (Implies(P_4_1, B_4_2)) & (Implies(P_4_1, B_5_1)) & (Implies(P_4_2, B_3_2)) & (Implies(P_4_2, B_4_1)) & (Implies(P_4_2, B_4_3)) & (Implies(P_4_2, B_5_2)) & (Implies(P_4_3, B_3_3)) & (Implies(P_4_3, B_4_2)) & (Implies(P_4_3, B_4_4)) & (Implies(P_4_3, B_5_3)) & (Implies(P_4_4, B_3_4)) & (Implies(P_4_4, B_4_3)) & (Implies(P_4_4, B_4_5)) & (Implies(P_4_4, B_5_4)) & (Implies(T_1_1, S_0_1)) & (Implies(T_1_1, S_1_0)) & (Implies(T_1_1, S_1_2)) & (Implies(T_1_1, S_2_1)) & (Implies(T_1_2, S_0_2)) & (Implies(T_1_2, S_1_1)) & (Implies(T_1_2, S_1_3)) & (Implies(T_1_2, S_2_2)) & (Implies(T_1_3, S_0_3)) & (Implies(T_1_3, S_1_2)) & (Implies(T_1_3, S_1_4)) & (Implies(T_1_3, S_2_3)) & (Implies(T_1_4, S_0_4)) & (Implies(T_1_4, S_1_3)) & (Implies(T_1_4, S_1_5)) & (Implies(T_1_4, S_2_4)) & (Implies(T_2_1, S_1_1)) & (Implies(T_2_1, S_2_0)) & (Implies(T_2_1, S_2_2)) & (Implies(T_2_1, S_3_1)) & (Implies(T_2_2, S_1_2)) & (Implies(T_2_2, S_2_1)) & (Implies(T_2_2, S_2_3)) & (Implies(T_2_2, S_3_2)) & (Implies(T_2_3, S_1_3)) & (Implies(T_2_3, S_2_2)) & (Implies(T_2_3, S_2_4)) & (Implies(T_2_3, S_3_3)) & (Implies(T_2_4, S_1_4)) & (Implies(T_2_4, S_2_3)) & (Implies(T_2_4, S_2_5)) & (Implies(T_2_4, S_3_4)) & (Implies(T_3_1, S_2_1)) & (Implies(T_3_1, S_3_0)) & (Implies(T_3_1, S_3_2)) & (Implies(T_3_1, S_4_1)) & (Implies(T_3_2, S_2_2)) & (Implies(T_3_2, S_3_1)) & (Implies(T_3_2, S_3_3)) & (Implies(T_3_2, S_4_2)) & (Implies(T_3_3, S_2_3)) & (Implies(T_3_3, S_3_2)) & (Implies(T_3_3, S_3_4)) & (Implies(T_3_3, S_4_3)) & (Implies(T_3_4, S_2_4)) & (Implies(T_3_4, S_3_3)) & (Implies(T_3_4, S_3_5)) & (Implies(T_3_4, S_4_4)) & (Implies(T_4_1, S_3_1)) & (Implies(T_4_1, S_4_0)) & (Implies(T_4_1, S_4_2)) & (Implies(T_4_1, S_5_1)) & (Implies(T_4_2, S_3_2)) & (Implies(T_4_2, S_4_1)) & (Implies(T_4_2, S_4_3)) & (Implies(T_4_2, S_5_2)) & (Implies(T_4_3, S_3_3)) & (Implies(T_4_3, S_4_2)) & (Implies(T_4_3, S_4_4)) & (Implies(T_4_3, S_5_3)) & (Implies(T_4_4, S_3_4)) & (Implies(T_4_4, S_4_3)) & (Implies(T_4_4, S_4_5)) & (Implies(T_4_4, S_5_4))" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"# B_i_j There is a breeze on the ith row and jth column of the grid\n", | |
"# P_i_j There is a pit at the ith row and jth column of the grid\n", | |
"# S_i_j There are some steps at the ith row and jth column of the grid\n", | |
"# T_i_j The idol is at the ith row and jth column of the grid\n", | |
"\n", | |
"import numpy as np\n", | |
"from sympy import sympify, satisfiable\n", | |
"\n", | |
"initial_knowledge_base = sympify(\"~B_1_1 & ~P_1_1 & ~S_1_1 & ~T_1_1\")\n", | |
"\n", | |
"# Adding the rule that if there is a pit at a location, there is a breeze in the adjacent locations\n", | |
"for i in range(1, 5):\n", | |
" for j in range(1, 5):\n", | |
" initial_knowledge_base &= sympify(f\"P_{i}_{j} >> B_{i+1}_{j}\")\n", | |
" initial_knowledge_base &= sympify(f\"P_{i}_{j} >> B_{i-1}_{j}\")\n", | |
" initial_knowledge_base &= sympify(f\"P_{i}_{j} >> B_{i}_{j+1}\")\n", | |
" initial_knowledge_base &= sympify(f\"P_{i}_{j} >> B_{i}_{j-1}\")\n", | |
"\n", | |
"# Adding the rule that if there is an idol at a location, there are some steps in the adjacent locations\n", | |
"for i in range(1, 5):\n", | |
" for j in range(1, 5):\n", | |
" initial_knowledge_base &= sympify(f\"T_{i}_{j} >> S_{i+1}_{j}\")\n", | |
" initial_knowledge_base &= sympify(f\"T_{i}_{j} >> S_{i-1}_{j}\")\n", | |
" initial_knowledge_base &= sympify(f\"T_{i}_{j} >> S_{i}_{j+1}\")\n", | |
" initial_knowledge_base &= sympify(f\"T_{i}_{j} >> S_{i}_{j-1}\")\n", | |
"\n", | |
"initial_knowledge_base" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"This 2D array represents the environment:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"environment = [ [\"Empty\", \"Empty\", \"Breeze\", \"Pit\"],\n", | |
" [\"Breeze\", \"Empty\", \"Empty\", \"Breeze\"],\n", | |
" [\"Pit\", \"Breeze\", \"Empty\", \"Stairs\"],\n", | |
" [\"Breeze\", \"Empty\", \"Stairs\", \"Idol\"]]\n", | |
"\n", | |
"\n" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"We need a function for Indy to perceive the environment at a given point on the grid." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"I feel a breeze\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"'B_1_3 & ~P_1_3 & ~S_1_3 & ~T_1_3'" | |
] | |
}, | |
"execution_count": 3, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"def percieve(i, j):\n", | |
" if environment[i-1][j-1] == \"Empty\":\n", | |
" print(\"nothing here\")\n", | |
" return f\"~B_{i}_{j} & ~P_{i}_{j} & ~S_{i}_{j} & ~T_{i}_{j}\"\n", | |
" elif environment[i-1][j-1] == \"Breeze\":\n", | |
" print(\"I feel a breeze\")\n", | |
" return f\"B_{i}_{j} & ~P_{i}_{j} & ~S_{i}_{j} & ~T_{i}_{j}\"\n", | |
" elif environment[i-1][j-1] == \"Pit\":\n", | |
" print(\"aghhhhhh!\")\n", | |
" return f\"~B_{i}_{j} & P_{i}_{j} & ~S_{i}_{j} & ~T_{i}_{j}\"\n", | |
" elif environment[i-1][j-1] == \"Stairs\":\n", | |
" print(\"ah some stairs!\")\n", | |
" return f\"~B_{i}_{j} & ~P_{i}_{j} & S_{i}_{j} & ~T_{i}_{j}\"\n", | |
" elif environment[i-1][j-1] == \"Idol\":\n", | |
" print(\"at last the idol!\")\n", | |
" return f\"~B_{i}_{j} & ~P_{i}_{j} & ~S_{i}_{j} & T_{i}_{j}\"\n", | |
"\n", | |
"\n", | |
"percieve(1, 3)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"And now a function for making inferences about what will happen if he moves a given direction from his current location" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def inferences_about_direction(knowledge_base, current_location, direction):\n", | |
"\n", | |
" i, j = current_location\n", | |
" if direction == \"down\":\n", | |
" i += 1\n", | |
" elif direction == \"up\":\n", | |
" i -= 1\n", | |
" elif direction == \"right\":\n", | |
" j += 1\n", | |
" elif direction == \"left\":\n", | |
" j -= 1\n", | |
" else:\n", | |
" return \"Invalid direction\"\n", | |
"\n", | |
" if i<1 or i>4 or j<1 or j>4:\n", | |
" return \"blocked\"\n", | |
" pit = sympify(f\"P_{i}_{j}\")\n", | |
" idol = sympify(f\"T_{i}_{j}\")\n", | |
" if not satisfiable(knowledge_base & pit) is False:\n", | |
" return \"dangerous\"\n", | |
" elif not satisfiable(knowledge_base & idol) is False:\n", | |
" return \"promising\"\n", | |
" else:\n", | |
" return \"worth exploring\"\n" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Finally we put it all together." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"--------------------\n", | |
"Indy is on row 1 and column 1\n", | |
"nothing here\n", | |
"up is blocked\n", | |
"down is worth exploring\n", | |
"left is blocked\n", | |
"right is worth exploring\n", | |
"Chosing down\n", | |
"--------------------\n", | |
"Indy is on row 2 and column 1\n", | |
"I feel a breeze\n", | |
"up is worth exploring\n", | |
"down is dangerous\n", | |
"left is blocked\n", | |
"right is dangerous\n", | |
"Chosing up\n", | |
"--------------------\n", | |
"Indy is on row 1 and column 1\n", | |
"nothing here\n", | |
"up is blocked\n", | |
"down is worth exploring\n", | |
"left is blocked\n", | |
"right is worth exploring\n", | |
"Chosing right\n", | |
"--------------------\n", | |
"Indy is on row 1 and column 2\n", | |
"nothing here\n", | |
"up is blocked\n", | |
"down is worth exploring\n", | |
"left is worth exploring\n", | |
"right is worth exploring\n", | |
"Chosing right\n", | |
"--------------------\n", | |
"Indy is on row 1 and column 3\n", | |
"I feel a breeze\n", | |
"up is blocked\n", | |
"down is dangerous\n", | |
"left is worth exploring\n", | |
"right is dangerous\n", | |
"Chosing left\n", | |
"--------------------\n", | |
"Indy is on row 1 and column 2\n", | |
"nothing here\n", | |
"up is blocked\n", | |
"down is worth exploring\n", | |
"left is worth exploring\n", | |
"right is worth exploring\n", | |
"Chosing down\n", | |
"--------------------\n", | |
"Indy is on row 2 and column 2\n", | |
"nothing here\n", | |
"up is worth exploring\n", | |
"down is worth exploring\n", | |
"left is worth exploring\n", | |
"right is worth exploring\n", | |
"Chosing up\n", | |
"--------------------\n", | |
"Indy is on row 1 and column 2\n", | |
"nothing here\n", | |
"up is blocked\n", | |
"down is worth exploring\n", | |
"left is worth exploring\n", | |
"right is worth exploring\n", | |
"Chosing down\n", | |
"--------------------\n", | |
"Indy is on row 2 and column 2\n", | |
"nothing here\n", | |
"up is worth exploring\n", | |
"down is worth exploring\n", | |
"left is worth exploring\n", | |
"right is worth exploring\n", | |
"Chosing up\n", | |
"--------------------\n", | |
"Indy is on row 1 and column 2\n", | |
"nothing here\n", | |
"up is blocked\n", | |
"down is worth exploring\n", | |
"left is worth exploring\n", | |
"right is worth exploring\n", | |
"Chosing down\n", | |
"--------------------\n", | |
"Indy is on row 2 and column 2\n", | |
"nothing here\n", | |
"up is worth exploring\n", | |
"down is worth exploring\n", | |
"left is worth exploring\n", | |
"right is worth exploring\n", | |
"Chosing right\n", | |
"--------------------\n", | |
"Indy is on row 2 and column 3\n", | |
"nothing here\n", | |
"up is worth exploring\n", | |
"down is worth exploring\n", | |
"left is worth exploring\n", | |
"right is worth exploring\n", | |
"Chosing right\n", | |
"--------------------\n", | |
"Indy is on row 2 and column 4\n", | |
"I feel a breeze\n", | |
"up is dangerous\n", | |
"down is dangerous\n", | |
"left is worth exploring\n", | |
"right is blocked\n", | |
"Chosing left\n", | |
"--------------------\n", | |
"Indy is on row 2 and column 3\n", | |
"nothing here\n", | |
"up is worth exploring\n", | |
"down is worth exploring\n", | |
"left is worth exploring\n", | |
"right is worth exploring\n", | |
"Chosing up\n", | |
"--------------------\n", | |
"Indy is on row 1 and column 3\n", | |
"I feel a breeze\n", | |
"up is blocked\n", | |
"down is worth exploring\n", | |
"left is worth exploring\n", | |
"right is dangerous\n", | |
"Chosing down\n", | |
"--------------------\n", | |
"Indy is on row 2 and column 3\n", | |
"nothing here\n", | |
"up is worth exploring\n", | |
"down is worth exploring\n", | |
"left is worth exploring\n", | |
"right is worth exploring\n", | |
"Chosing down\n", | |
"--------------------\n", | |
"Indy is on row 3 and column 3\n", | |
"nothing here\n", | |
"up is worth exploring\n", | |
"down is worth exploring\n", | |
"left is worth exploring\n", | |
"right is worth exploring\n", | |
"Chosing left\n", | |
"--------------------\n", | |
"Indy is on row 3 and column 2\n", | |
"I feel a breeze\n", | |
"up is worth exploring\n", | |
"down is dangerous\n", | |
"left is dangerous\n", | |
"right is worth exploring\n", | |
"Chosing right\n", | |
"--------------------\n", | |
"Indy is on row 3 and column 3\n", | |
"nothing here\n", | |
"up is worth exploring\n", | |
"down is worth exploring\n", | |
"left is worth exploring\n", | |
"right is worth exploring\n", | |
"Chosing down\n", | |
"--------------------\n", | |
"Indy is on row 4 and column 3\n", | |
"ah some stairs!\n", | |
"up is worth exploring\n", | |
"down is blocked\n", | |
"left is worth exploring\n", | |
"right is promising\n", | |
"Chosing right\n", | |
"--------------------\n", | |
"Indy is on row 4 and column 4\n", | |
"at last the idol!\n", | |
"up is worth exploring\n", | |
"down is blocked\n", | |
"left is worth exploring\n", | |
"right is blocked\n", | |
"Chosing left\n" | |
] | |
} | |
], | |
"source": [ | |
"import random\n", | |
"knowledge_base = initial_knowledge_base\n", | |
"\n", | |
"# Start Indy in the top left corner\n", | |
"indy = (1, 1)\n", | |
"\n", | |
"# He sees nothing in the first location\n", | |
"percept = '~B_1_1 & ~P_1_1 & ~S_1_1 & ~T_1_1'\n", | |
"\n", | |
"# Continue until Indy finds the idol\n", | |
"while percept != \"~B_4_4 & ~P_4_4 & ~S_4_4 & T_4_4\":\n", | |
" \n", | |
" print(\"-\"*20)\n", | |
" print(f\"Indy is on row {indy[0]} and column {indy[1]}\")\n", | |
"\n", | |
" # Perceive the environment\n", | |
" percept = percieve(indy[0], indy[1])\n", | |
"\n", | |
" # Add the percept to the knowledge base\n", | |
" knowledge_base &= sympify(percept)\n", | |
" \n", | |
" # Make a decision\n", | |
" options = []\n", | |
" for d in [\"up\", \"down\", \"left\", \"right\"]:\n", | |
" inference = inferences_about_direction(knowledge_base, indy, d)\n", | |
" options.append((d, inference))\n", | |
" print(f\"{d} is {inference}\")\n", | |
"\n", | |
" # First chose from the promising options if there are any\n", | |
" promising_options = [x[0] for x in options if x[1] == \"promising\"]\n", | |
"\n", | |
" if promising_options:\n", | |
" direction = random.choice(promising_options)\n", | |
" # If there are no promising options, chose from the safe options\n", | |
" else:\n", | |
" safe_options = [x[0] for x in options if x[1] == \"worth exploring\"]\n", | |
" direction = random.choice(safe_options)\n", | |
" print(f\"Chosing {direction}\")\n", | |
"\n", | |
" # Move Indy\n", | |
" if direction == \"up\":\n", | |
" indy = (indy[0]-1, indy[1])\n", | |
" elif direction == \"down\":\n", | |
" indy = (indy[0]+1, indy[1])\n", | |
" elif direction == \"left\":\n", | |
" indy = (indy[0], indy[1]-1)\n", | |
" elif direction == \"right\":\n", | |
" indy = (indy[0], indy[1]+1)\n" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Note as knowledge accumulates Indy's inferences about where the pits are become more and more precise. For example, feeling a breeze at 2,1 he no longer thinks there is a pit at 1,1.\n", | |
"\n", | |
"It is very satisfying to see what he has learnt!" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/latex": [ | |
"$\\displaystyle B_{1 3} \\wedge B_{2 1} \\wedge B_{2 4} \\wedge B_{3 2} \\wedge S_{3 4} \\wedge T_{4 4} \\wedge \\left(P_{1 1} \\Rightarrow B_{0 1}\\right) \\wedge \\left(P_{1 1} \\Rightarrow B_{1 0}\\right) \\wedge \\left(P_{1 1} \\Rightarrow B_{1 2}\\right) \\wedge \\left(P_{1 1} \\Rightarrow B_{2 1}\\right) \\wedge \\left(P_{1 2} \\Rightarrow B_{0 2}\\right) \\wedge \\left(P_{1 2} \\Rightarrow B_{1 1}\\right) \\wedge \\left(P_{1 2} \\Rightarrow B_{1 3}\\right) \\wedge \\left(P_{1 2} \\Rightarrow B_{2 2}\\right) \\wedge \\left(P_{1 3} \\Rightarrow B_{0 3}\\right) \\wedge \\left(P_{1 3} \\Rightarrow B_{1 2}\\right) \\wedge \\left(P_{1 3} \\Rightarrow B_{1 4}\\right) \\wedge \\left(P_{1 3} \\Rightarrow B_{2 3}\\right) \\wedge \\left(P_{1 4} \\Rightarrow B_{0 4}\\right) \\wedge \\left(P_{1 4} \\Rightarrow B_{1 3}\\right) \\wedge \\left(P_{1 4} \\Rightarrow B_{1 5}\\right) \\wedge \\left(P_{1 4} \\Rightarrow B_{2 4}\\right) \\wedge \\left(P_{2 1} \\Rightarrow B_{1 1}\\right) \\wedge \\left(P_{2 1} \\Rightarrow B_{2 0}\\right) \\wedge \\left(P_{2 1} \\Rightarrow B_{2 2}\\right) \\wedge \\left(P_{2 1} \\Rightarrow B_{3 1}\\right) \\wedge \\left(P_{2 2} \\Rightarrow B_{1 2}\\right) \\wedge \\left(P_{2 2} \\Rightarrow B_{2 1}\\right) \\wedge \\left(P_{2 2} \\Rightarrow B_{2 3}\\right) \\wedge \\left(P_{2 2} \\Rightarrow B_{3 2}\\right) \\wedge \\left(P_{2 3} \\Rightarrow B_{1 3}\\right) \\wedge \\left(P_{2 3} \\Rightarrow B_{2 2}\\right) \\wedge \\left(P_{2 3} \\Rightarrow B_{2 4}\\right) \\wedge \\left(P_{2 3} \\Rightarrow B_{3 3}\\right) \\wedge \\left(P_{2 4} \\Rightarrow B_{1 4}\\right) \\wedge \\left(P_{2 4} \\Rightarrow B_{2 3}\\right) \\wedge \\left(P_{2 4} \\Rightarrow B_{2 5}\\right) \\wedge \\left(P_{2 4} \\Rightarrow B_{3 4}\\right) \\wedge \\left(P_{3 1} \\Rightarrow B_{2 1}\\right) \\wedge \\left(P_{3 1} \\Rightarrow B_{3 0}\\right) \\wedge \\left(P_{3 1} \\Rightarrow B_{3 2}\\right) \\wedge \\left(P_{3 1} \\Rightarrow B_{4 1}\\right) \\wedge \\left(P_{3 2} \\Rightarrow B_{2 2}\\right) \\wedge \\left(P_{3 2} \\Rightarrow B_{3 1}\\right) \\wedge \\left(P_{3 2} \\Rightarrow B_{3 3}\\right) \\wedge \\left(P_{3 2} \\Rightarrow B_{4 2}\\right) \\wedge \\left(P_{3 3} \\Rightarrow B_{2 3}\\right) \\wedge \\left(P_{3 3} \\Rightarrow B_{3 2}\\right) \\wedge \\left(P_{3 3} \\Rightarrow B_{3 4}\\right) \\wedge \\left(P_{3 3} \\Rightarrow B_{4 3}\\right) \\wedge \\left(P_{3 4} \\Rightarrow B_{2 4}\\right) \\wedge \\left(P_{3 4} \\Rightarrow B_{3 3}\\right) \\wedge \\left(P_{3 4} \\Rightarrow B_{3 5}\\right) \\wedge \\left(P_{3 4} \\Rightarrow B_{4 4}\\right) \\wedge \\left(P_{4 1} \\Rightarrow B_{3 1}\\right) \\wedge \\left(P_{4 1} \\Rightarrow B_{4 0}\\right) \\wedge \\left(P_{4 1} \\Rightarrow B_{4 2}\\right) \\wedge \\left(P_{4 1} \\Rightarrow B_{5 1}\\right) \\wedge \\left(P_{4 2} \\Rightarrow B_{3 2}\\right) \\wedge \\left(P_{4 2} \\Rightarrow B_{4 1}\\right) \\wedge \\left(P_{4 2} \\Rightarrow B_{4 3}\\right) \\wedge \\left(P_{4 2} \\Rightarrow B_{5 2}\\right) \\wedge \\left(P_{4 3} \\Rightarrow B_{3 3}\\right) \\wedge \\left(P_{4 3} \\Rightarrow B_{4 2}\\right) \\wedge \\left(P_{4 3} \\Rightarrow B_{4 4}\\right) \\wedge \\left(P_{4 3} \\Rightarrow B_{5 3}\\right) \\wedge \\left(P_{4 4} \\Rightarrow B_{3 4}\\right) \\wedge \\left(P_{4 4} \\Rightarrow B_{4 3}\\right) \\wedge \\left(P_{4 4} \\Rightarrow B_{4 5}\\right) \\wedge \\left(P_{4 4} \\Rightarrow B_{5 4}\\right) \\wedge \\left(T_{1 1} \\Rightarrow S_{0 1}\\right) \\wedge \\left(T_{1 1} \\Rightarrow S_{1 0}\\right) \\wedge \\left(T_{1 1} \\Rightarrow S_{1 2}\\right) \\wedge \\left(T_{1 1} \\Rightarrow S_{2 1}\\right) \\wedge \\left(T_{1 2} \\Rightarrow S_{0 2}\\right) \\wedge \\left(T_{1 2} \\Rightarrow S_{1 1}\\right) \\wedge \\left(T_{1 2} \\Rightarrow S_{1 3}\\right) \\wedge \\left(T_{1 2} \\Rightarrow S_{2 2}\\right) \\wedge \\left(T_{1 3} \\Rightarrow S_{0 3}\\right) \\wedge \\left(T_{1 3} \\Rightarrow S_{1 2}\\right) \\wedge \\left(T_{1 3} \\Rightarrow S_{1 4}\\right) \\wedge \\left(T_{1 3} \\Rightarrow S_{2 3}\\right) \\wedge \\left(T_{1 4} \\Rightarrow S_{0 4}\\right) \\wedge \\left(T_{1 4} \\Rightarrow S_{1 3}\\right) \\wedge \\left(T_{1 4} \\Rightarrow S_{1 5}\\right) \\wedge \\left(T_{1 4} \\Rightarrow S_{2 4}\\right) \\wedge \\left(T_{2 1} \\Rightarrow S_{1 1}\\right) \\wedge \\left(T_{2 1} \\Rightarrow S_{2 0}\\right) \\wedge \\left(T_{2 1} \\Rightarrow S_{2 2}\\right) \\wedge \\left(T_{2 1} \\Rightarrow S_{3 1}\\right) \\wedge \\left(T_{2 2} \\Rightarrow S_{1 2}\\right) \\wedge \\left(T_{2 2} \\Rightarrow S_{2 1}\\right) \\wedge \\left(T_{2 2} \\Rightarrow S_{2 3}\\right) \\wedge \\left(T_{2 2} \\Rightarrow S_{3 2}\\right) \\wedge \\left(T_{2 3} \\Rightarrow S_{1 3}\\right) \\wedge \\left(T_{2 3} \\Rightarrow S_{2 2}\\right) \\wedge \\left(T_{2 3} \\Rightarrow S_{2 4}\\right) \\wedge \\left(T_{2 3} \\Rightarrow S_{3 3}\\right) \\wedge \\left(T_{2 4} \\Rightarrow S_{1 4}\\right) \\wedge \\left(T_{2 4} \\Rightarrow S_{2 3}\\right) \\wedge \\left(T_{2 4} \\Rightarrow S_{2 5}\\right) \\wedge \\left(T_{2 4} \\Rightarrow S_{3 4}\\right) \\wedge \\left(T_{3 1} \\Rightarrow S_{2 1}\\right) \\wedge \\left(T_{3 1} \\Rightarrow S_{3 0}\\right) \\wedge \\left(T_{3 1} \\Rightarrow S_{3 2}\\right) \\wedge \\left(T_{3 1} \\Rightarrow S_{4 1}\\right) \\wedge \\left(T_{3 2} \\Rightarrow S_{2 2}\\right) \\wedge \\left(T_{3 2} \\Rightarrow S_{3 1}\\right) \\wedge \\left(T_{3 2} \\Rightarrow S_{3 3}\\right) \\wedge \\left(T_{3 2} \\Rightarrow S_{4 2}\\right) \\wedge \\left(T_{3 3} \\Rightarrow S_{2 3}\\right) \\wedge \\left(T_{3 3} \\Rightarrow S_{3 2}\\right) \\wedge \\left(T_{3 3} \\Rightarrow S_{3 4}\\right) \\wedge \\left(T_{3 3} \\Rightarrow S_{4 3}\\right) \\wedge \\left(T_{3 4} \\Rightarrow S_{2 4}\\right) \\wedge \\left(T_{3 4} \\Rightarrow S_{3 3}\\right) \\wedge \\left(T_{3 4} \\Rightarrow S_{3 5}\\right) \\wedge \\left(T_{3 4} \\Rightarrow S_{4 4}\\right) \\wedge \\left(T_{4 1} \\Rightarrow S_{3 1}\\right) \\wedge \\left(T_{4 1} \\Rightarrow S_{4 0}\\right) \\wedge \\left(T_{4 1} \\Rightarrow S_{4 2}\\right) \\wedge \\left(T_{4 1} \\Rightarrow S_{5 1}\\right) \\wedge \\left(T_{4 2} \\Rightarrow S_{3 2}\\right) \\wedge \\left(T_{4 2} \\Rightarrow S_{4 1}\\right) \\wedge \\left(T_{4 2} \\Rightarrow S_{4 3}\\right) \\wedge \\left(T_{4 2} \\Rightarrow S_{5 2}\\right) \\wedge \\left(T_{4 3} \\Rightarrow S_{3 3}\\right) \\wedge \\left(T_{4 3} \\Rightarrow S_{4 2}\\right) \\wedge \\left(T_{4 3} \\Rightarrow S_{4 4}\\right) \\wedge \\left(T_{4 3} \\Rightarrow S_{5 3}\\right) \\wedge \\left(T_{4 4} \\Rightarrow S_{3 4}\\right) \\wedge \\left(T_{4 4} \\Rightarrow S_{4 3}\\right) \\wedge \\left(T_{4 4} \\Rightarrow S_{4 5}\\right) \\wedge \\left(T_{4 4} \\Rightarrow S_{5 4}\\right) \\wedge \\neg B_{1 1} \\wedge \\neg B_{1 2} \\wedge \\neg B_{2 2} \\wedge \\neg B_{2 3} \\wedge \\neg B_{3 3} \\wedge \\neg B_{3 4} \\wedge \\neg B_{4 4} \\wedge \\neg P_{1 1} \\wedge \\neg P_{1 2} \\wedge \\neg P_{1 3} \\wedge \\neg P_{2 1} \\wedge \\neg P_{2 2} \\wedge \\neg P_{2 3} \\wedge \\neg P_{2 4} \\wedge \\neg P_{3 2} \\wedge \\neg P_{3 3} \\wedge \\neg P_{3 4} \\wedge \\neg P_{4 4} \\wedge \\neg S_{1 1} \\wedge \\neg S_{1 2} \\wedge \\neg S_{1 3} \\wedge \\neg S_{2 1} \\wedge \\neg S_{2 2} \\wedge \\neg S_{2 3} \\wedge \\neg S_{2 4} \\wedge \\neg S_{3 2} \\wedge \\neg S_{3 3} \\wedge \\neg S_{4 4} \\wedge \\neg T_{1 1} \\wedge \\neg T_{1 2} \\wedge \\neg T_{1 3} \\wedge \\neg T_{2 1} \\wedge \\neg T_{2 2} \\wedge \\neg T_{2 3} \\wedge \\neg T_{2 4} \\wedge \\neg T_{3 2} \\wedge \\neg T_{3 3} \\wedge \\neg T_{3 4}$" | |
], | |
"text/plain": [ | |
"B_1_3 & B_2_1 & B_2_4 & B_3_2 & S_3_4 & T_4_4 & ~B_1_1 & ~B_1_2 & ~B_2_2 & ~B_2_3 & ~B_3_3 & ~B_3_4 & ~B_4_4 & ~P_1_1 & ~P_1_2 & ~P_1_3 & ~P_2_1 & ~P_2_2 & ~P_2_3 & ~P_2_4 & ~P_3_2 & ~P_3_3 & ~P_3_4 & ~P_4_4 & ~S_1_1 & ~S_1_2 & ~S_1_3 & ~S_2_1 & ~S_2_2 & ~S_2_3 & ~S_2_4 & ~S_3_2 & ~S_3_3 & ~S_4_4 & ~T_1_1 & ~T_1_2 & ~T_1_3 & ~T_2_1 & ~T_2_2 & ~T_2_3 & ~T_2_4 & ~T_3_2 & ~T_3_3 & ~T_3_4 & (Implies(P_1_1, B_0_1)) & (Implies(P_1_1, B_1_0)) & (Implies(P_1_1, B_1_2)) & (Implies(P_1_1, B_2_1)) & (Implies(P_1_2, B_0_2)) & (Implies(P_1_2, B_1_1)) & (Implies(P_1_2, B_1_3)) & (Implies(P_1_2, B_2_2)) & (Implies(P_1_3, B_0_3)) & (Implies(P_1_3, B_1_2)) & (Implies(P_1_3, B_1_4)) & (Implies(P_1_3, B_2_3)) & (Implies(P_1_4, B_0_4)) & (Implies(P_1_4, B_1_3)) & (Implies(P_1_4, B_1_5)) & (Implies(P_1_4, B_2_4)) & (Implies(P_2_1, B_1_1)) & (Implies(P_2_1, B_2_0)) & (Implies(P_2_1, B_2_2)) & (Implies(P_2_1, B_3_1)) & (Implies(P_2_2, B_1_2)) & (Implies(P_2_2, B_2_1)) & (Implies(P_2_2, B_2_3)) & (Implies(P_2_2, B_3_2)) & (Implies(P_2_3, B_1_3)) & (Implies(P_2_3, B_2_2)) & (Implies(P_2_3, B_2_4)) & (Implies(P_2_3, B_3_3)) & (Implies(P_2_4, B_1_4)) & (Implies(P_2_4, B_2_3)) & (Implies(P_2_4, B_2_5)) & (Implies(P_2_4, B_3_4)) & (Implies(P_3_1, B_2_1)) & (Implies(P_3_1, B_3_0)) & (Implies(P_3_1, B_3_2)) & (Implies(P_3_1, B_4_1)) & (Implies(P_3_2, B_2_2)) & (Implies(P_3_2, B_3_1)) & (Implies(P_3_2, B_3_3)) & (Implies(P_3_2, B_4_2)) & (Implies(P_3_3, B_2_3)) & (Implies(P_3_3, B_3_2)) & (Implies(P_3_3, B_3_4)) & (Implies(P_3_3, B_4_3)) & (Implies(P_3_4, B_2_4)) & (Implies(P_3_4, B_3_3)) & (Implies(P_3_4, B_3_5)) & (Implies(P_3_4, B_4_4)) & (Implies(P_4_1, B_3_1)) & (Implies(P_4_1, B_4_0)) & (Implies(P_4_1, B_4_2)) & (Implies(P_4_1, B_5_1)) & (Implies(P_4_2, B_3_2)) & (Implies(P_4_2, B_4_1)) & (Implies(P_4_2, B_4_3)) & (Implies(P_4_2, B_5_2)) & (Implies(P_4_3, B_3_3)) & (Implies(P_4_3, B_4_2)) & (Implies(P_4_3, B_4_4)) & (Implies(P_4_3, B_5_3)) & (Implies(P_4_4, B_3_4)) & (Implies(P_4_4, B_4_3)) & (Implies(P_4_4, B_4_5)) & (Implies(P_4_4, B_5_4)) & (Implies(T_1_1, S_0_1)) & (Implies(T_1_1, S_1_0)) & (Implies(T_1_1, S_1_2)) & (Implies(T_1_1, S_2_1)) & (Implies(T_1_2, S_0_2)) & (Implies(T_1_2, S_1_1)) & (Implies(T_1_2, S_1_3)) & (Implies(T_1_2, S_2_2)) & (Implies(T_1_3, S_0_3)) & (Implies(T_1_3, S_1_2)) & (Implies(T_1_3, S_1_4)) & (Implies(T_1_3, S_2_3)) & (Implies(T_1_4, S_0_4)) & (Implies(T_1_4, S_1_3)) & (Implies(T_1_4, S_1_5)) & (Implies(T_1_4, S_2_4)) & (Implies(T_2_1, S_1_1)) & (Implies(T_2_1, S_2_0)) & (Implies(T_2_1, S_2_2)) & (Implies(T_2_1, S_3_1)) & (Implies(T_2_2, S_1_2)) & (Implies(T_2_2, S_2_1)) & (Implies(T_2_2, S_2_3)) & (Implies(T_2_2, S_3_2)) & (Implies(T_2_3, S_1_3)) & (Implies(T_2_3, S_2_2)) & (Implies(T_2_3, S_2_4)) & (Implies(T_2_3, S_3_3)) & (Implies(T_2_4, S_1_4)) & (Implies(T_2_4, S_2_3)) & (Implies(T_2_4, S_2_5)) & (Implies(T_2_4, S_3_4)) & (Implies(T_3_1, S_2_1)) & (Implies(T_3_1, S_3_0)) & (Implies(T_3_1, S_3_2)) & (Implies(T_3_1, S_4_1)) & (Implies(T_3_2, S_2_2)) & (Implies(T_3_2, S_3_1)) & (Implies(T_3_2, S_3_3)) & (Implies(T_3_2, S_4_2)) & (Implies(T_3_3, S_2_3)) & (Implies(T_3_3, S_3_2)) & (Implies(T_3_3, S_3_4)) & (Implies(T_3_3, S_4_3)) & (Implies(T_3_4, S_2_4)) & (Implies(T_3_4, S_3_3)) & (Implies(T_3_4, S_3_5)) & (Implies(T_3_4, S_4_4)) & (Implies(T_4_1, S_3_1)) & (Implies(T_4_1, S_4_0)) & (Implies(T_4_1, S_4_2)) & (Implies(T_4_1, S_5_1)) & (Implies(T_4_2, S_3_2)) & (Implies(T_4_2, S_4_1)) & (Implies(T_4_2, S_4_3)) & (Implies(T_4_2, S_5_2)) & (Implies(T_4_3, S_3_3)) & (Implies(T_4_3, S_4_2)) & (Implies(T_4_3, S_4_4)) & (Implies(T_4_3, S_5_3)) & (Implies(T_4_4, S_3_4)) & (Implies(T_4_4, S_4_3)) & (Implies(T_4_4, S_4_5)) & (Implies(T_4_4, S_5_4))" | |
] | |
}, | |
"execution_count": 8, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"knowledge_base" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "symbolic", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.13.0" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment