{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "FINAL Template_for CIS521_midterm notes (Reeda).ipynb",
      "provenance": [],
      "collapsed_sections": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "brNDGX-kvzds"
      },
      "source": [
        "# Template for Notes for CIS 521 Midterm 1\n",
        "\n",
        "The midterm exam for CIS 521 will be **open notes**. No other matierals are allowed for the exam - you may not use the textbook, the internet, a Python envionement, or communicate with anyone during the exam. \n",
        "\n",
        "This python notebook is where you should save all of your notes.  It provides a structured template that allows you to add summaries for each of the textbook sections that are part of the required reading, plus room for lecture notes and definitions.\n",
        "\n",
        "Your summaries must be written in your own words.  Do not copy and paste from the textbook.  Do not share your notes with classmates, or copy any of your classmates' notes.  "
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "aPtM8g7R0Pds"
      },
      "source": [
        "# Instructions\n",
        "\n",
        "1. Make a copy of this Google Colab file. From the colab menu, pick **File > Save a copy in Drive**.  That will save a copy of this notebook in your Google drive.\n",
        "2. Go through each section of the notebook, and fill in all the summaries for each chapter and its corresponding sections.  Be sure to save your work frequently!\n",
        "3. Read the notes below about how you can format your summaries.\n",
        "4. In addition to these notes, you are allowed 1 page (both sides) for figures or handwritten notes.\n",
        "5. Submit your version of this notebook to Gradescope before you start the exam.\n",
        "6. If you are taking the exam in person, then you must print a copy of your notes for yourself.   Here's how to print: \n",
        "* Run the last cell of this notebook\n",
        "* Click the \"Mirror cell in tab\" button (this is located in the upper right corner of the cell, immediately to the right of the trash can).  This will open the cell.  \n",
        "* In Chrome, you can then print your notes using the **File > Print** option from the browser's menu.  \n",
        "* In the print options, change the layout from Landscape to Portrait. \n",
        "* Clicking the Save, will save a PDF that you can then print.\n",
        "\n",
        "## Formatting Notes\n",
        "\n",
        "1. The max length for each section's summary is 500 words / 3000 characters.\n",
        "2. You can also write a 2000 word summary of the lectures for each module.\n",
        "3. You may also write definitions of concepts for each module.  The definitions should be written in your own words (not copy and pasted), and they should be no more than 20 words long for each concept. \n",
        "2. You can use Markdown formatting for your summaries. \n",
        "3. You can use Latex formatting for equations. Put two dollar signs before and after your equation like this: \n",
        "$$ \\epsilon = \\frac{1}{mc^2} $$\n",
        "4. When you write python code or psuedocode algorithms, you should surround it with triple backticks like this:\n",
        "```\n",
        "def function():\n",
        "      print('hello world')\n",
        "```\n",
        "5. Write \\ whenever you want to keep writing on the next line without a newline being inserted."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "cw5IpDLCZa4W"
      },
      "source": [
        "## Example summary\n",
        "\n",
        "This is a sample summary of [Section 2.1.1](https://web.stanford.edu/~jurafsky/slp3/2.pdf ) of Jurfasky and Martin's Speech and Language Processing's book\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "lzaavW96tcxM",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "e3d9f996-7dfd-4d18-bec3-b6a5c7fa5a2a"
      },
      "source": [
        "chapter_2_1_example = \"\"\"\n",
        "Regular expressions are an algebraic notation for characterizing \\\n",
        "a set of strings that are useful for searching for a pattern or through a corpus.\\\n",
        "Only the first matching result will be shown. The search string is case sensitive, \\\n",
        "but it can consist of a single character or a sequence of characters. \\\n",
        "While square braces specify a disjunction of characters, the dash can more easily look \\\n",
        "for characters over a range. The caret specifies the non-existence of a character. \\\n",
        "Additionally, the (?) is used to for flexibility on a single character, meaning \\\n",
        "\"the preceding character or nothing\". More importantly, the Kleene star means zero or \\\n",
        "more occurrences of the immediately previous character or regular expression in square braces.\\\n",
        "...\n",
        "\"\"\"\n",
        "\n",
        "length = len(chapter_2_1_example.split(\" \"))\n",
        "print(\"The example summary is {len} words long, so you could write an additional \\\n",
        "{remaining} words.\".format(len=length, remaining=(500-length)))"
      ],
      "execution_count": 23,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "The example summary is 116 words long, so you could write an additional 384 words.\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "s3Uk9gQTevcj"
      },
      "source": [
        "## Example summary length\n",
        "\n",
        "The maximum summary length for each section is 500 words / 3000 characters.  Hopefully you'll find that to be quite generous. "
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "8DvZ57A-djo1",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "58a71691-2cd3-485c-e830-e1dd24b7f2d4"
      },
      "source": [
        "# This is an example of a 500 word placeholder\n",
        "placeholder = \"\"\"ultrices vitae auctor eu augue ut lectus arcu bibendum at varius \\\n",
        " vel pharetra vel turpis nunc eget lorem dolor sed viverra ipsum nunc aliquet \\\n",
        " bibendum enim facilisis gravida neque convallis a cras semper auctor neque vitae \\\n",
        " tempus quam pellentesque nec nam aliquam sem et tortor consequat id porta nibh \\\n",
        " venenatis cras sed felis eget velit aliquet sagittis id consectetur purus ut \\\n",
        " faucibus pulvinar elementum integer enim neque volutpat ac tincidunt vitae semper \\ \n",
        " quis lectus nulla at volutpat diam ut venenatis tellus in metus vulputate eu \\\n",
        " scelerisque felis imperdiet proin fermentum leo vel orci porta non pulvinar neque \\ \n",
        " laoreet suspendisse interdum consectetur libero id faucibus nisl tincidunt eget \\\n",
        " nullam non nisi est sit amet facilisis magna etiam tempor orci eu lobortis \\\n",
        " elementum nibh tellus molestie nunc non blandit massa enim nec dui nunc mattis \\\n",
        " enim ut tellus elementum sagittis vitae et leo duis ut diam quam nulla porttitor \\\n",
        " massa id neque aliquam vestibulum morbi blandit cursus risus at ultrices mi tempus \\\n",
        " imperdiet nulla malesuada pellentesque elit eget gravida cum sociis natoque \\\n",
        " penatibus et magnis dis parturient montes nascetur ridiculus mus mauris vitae \\\n",
        " ultricies leo integer malesuada nunc vel risus commodo viverra maecenas accumsan \\\n",
        " lacus vel facilisis volutpat est velit egestas dui id ornare arcu odio ut sem nulla \\\n",
        " pharetra diam sit amet nisl suscipit adipiscing bibendum est ultricies integer \\\n",
        " quis auctor elit sed vulputate mi sit amet mauris commodo quis imperdiet massa \\\n",
        " tincidunt nunc pulvinar sapien et ligula ullamcorper malesuada proin libero nunc \\\n",
        " consequat interdum varius sit amet mattis vulputate enim nulla aliquet porttitor \\\n",
        " lacus luctus accumsan tortor posuere ac ut consequat semper viverra nam libero \\\n",
        " justo laoreet sit amet cursus sit amet dictum sit amet justo donec enim diam \\\n",
        " vulputate ut pharetra sit amet aliquam id diam maecenas ultricies mi eget mauris \\\n",
        " pharetra et ultrices neque ornare aenean euismod elementum nisi quis eleifend quam \\\n",
        " adipiscing vitae proin sagittis nisl rhoncus mattis rhoncus urna neque viverra justo \\\n",
        " nec ultrices dui sapien eget mi proin sed libero enim sed faucibus turpis in \\\n",
        " eu mi bibendum neque egestas congue quisque egestas diam in arcu cursus euismod \\\n",
        " quis viverra nibh cras pulvinar mattis nunc sed blandit libero volutpat sed cras \\\n",
        " ornare arcu dui vivamus arcu felis bibendum ut tristique et egestas quis ipsum \\\n",
        " suspendisse ultrices gravida dictum fusce ut placerat orci nulla pellentesque \\\n",
        " dignissim enim sit amet venenatis urna cursus eget nunc scelerisque viverra mauris \\\n",
        " in aliquam sem fringilla ut morbi tincidunt augue interdum velit euismod in \\\n",
        " pellentesque massa placerat duis ultricies lacus sed turpis tincidunt id aliquet \\\n",
        " risus feugiat in ante metus dictum at tempor commodo ullamcorper a lacus vestibulum \\\n",
        " sed arcu non odio euismod lacinia at quis risus sed vulputate odio ut enim blandit \\\n",
        " volutpat maecenas volutpat blandit aliquam etiam erat velit scelerisque in \\\n",
        " dictum non consectetur a erat nam at lectus urna\"\"\"\n",
        "\n",
        "print(\"The length in words is\", len(placeholder.split(' ')))\n",
        "print(\"The length in characters is\", len(placeholder))"
      ],
      "execution_count": 24,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "The length in words is 500\n",
            "The length in characters is 3030\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "5yG3-YncJfTB"
      },
      "source": [
        "# Permissions to use your summaries\n",
        "\n",
        "We'd like to use your summaries to help develop better educational resources like [remember.school](https://remember.school) or a question-answering system about the textbook.  \n",
        "\n",
        "1. Please enter your name.  \n",
        "\n",
        "2. If you grant permission for us to use your summaries under a [Creative Commons License](https://creativecommons.org/licenses/by/4.0/), please set ```permission = True```.  If you do not grant permission, please set it to false. Your answer won't affect your grade.\n",
        "\n",
        "3. If you grant us permission, and you'd like to remain anonymous, set ```anonymous = True```.  We'll remove your name before sharing your summaries with anyone. "
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "2RECnJArJew4"
      },
      "source": [
        "name = \"\"\n",
        "permission = True\n",
        "anonymous = False"
      ],
      "execution_count": 25,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "GZZXyrV-xuAp"
      },
      "source": [
        "# Module 1 - Intro to AI"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Y2NfE1CKxzS-"
      },
      "source": [
        "# Russell and Norvig, AIMA 4th Edition, Chapter 1 “Introduction”, Section 1.1 “What is AI”\n",
        "\n",
        "chapter1_1 = \"\"\"Some people define intelligence in terms of human performance while others choose rationaility, doing the right thing. From these \n",
        "there are 4 combinations of approachs: The first is the turing test approach, acting humanly (defined below). The human would need the following \n",
        "capabilities to pass the Turing test: NLP, knowledge representation, automated reasoning, machine learning. Turing did not think physical \n",
        "representation of machine was necessary for intelligence, but some others did and they proposed the Total Turing Test, where computer also needs \n",
        "computer vision and robotics. The second approach is the cognitive modelling approach: to say program thinks like human, we need to see how humans \n",
        "think. We can observe the thoughts of humans by doing introspection, phychological experiments, brain imaging. If programs input-output matches this\n",
        "definition of human behavior then we can say it is intelligent. Allen Newell and Herbert Simon used this and it helped create cognitive science. Combination \n",
        "of cognitive science and AI is more apparent in computer vision. The third approach is the \"Law of Thoughts\" approach. It is based on syllogisms that will \n",
        "always yield the correct answer. This created logic field which builds on this to create intelligent systems. However, this is not enough since \n",
        "we need probability to represent things in the world. Rational thought is not enough, you need theory for rational action for model of intelligent behavior.\n",
        "The last approach is the rational agent approach. The rational agent has two primary advantages, which are it is more general than \"laws of thought\" and \n",
        "rationaility is mathematically well defined. This is the most prevailing definition of AI, and it focuses on \"agents that will do the right thing\", and this \n",
        "way of thinking is so general that we call it the standard model. However, the standard model does not work well when we do not supply a defined\n",
        "objective to the machine. This comes out in real world where the objective is not well defined. We want machines that will go do our objectives well and \n",
        "not their objectives, and therefore standard model may not be enough, so that machines can be provably beneficial to humans\"\"\" \n",
        "\n",
        "# Russell and Norvig, AIMA 4th Edition, Chapter 27 “Philosophical Foundations”, Sections 27.1 “The Limits of AI” and 27.2 “Can Machines Really Think?”\n",
        "chapter27_1 = \"\"\" Turing said human behavior was too complex to be captured by set of rules for computer, and Dreyfus expanded that by providing\n",
        "critiques of AI. Dreyfus said AI was impossible based on this. It is clear computers cannot be exactly humans and argument from disability by Turing \n",
        "claims that they cannot do things like fall in love, be friendly, or have sense of humor, etc. We also have the mathematical objection to intelligence \n",
        "which comes from Godel's incompleteness theorem, proving that machines are mentally inferior to humans. Issue is this applies to math and not machines \n",
        "and it assumes humans own consistency which is invalid. Turing proposed that we should ask if machines can pass a behavioral test instead of seeing \n",
        "if they can think. Test requires program to have conversation with human for 30 mins and if it can fool interrogator into thinking it is a human 30% of the time\n",
        "then it passes.\"\"\"\n",
        "chapter27_2 = \"\"\" Djikstra does not think machines can think, whereas Turing says we should have polite convention that everyone thinks\n",
        "and that we should extend that to machines as well. Searle rejects the polite convention by the Chinese room argument: saying that if we have human \n",
        "who only understands english in room with code to translate stuff from english to chinese. The output will show a correct translation, but neither \n",
        "the human or the codes know Chinese so it makes no sense to say they understand, saying this is how computers operate. Searle believed in biological naturalism.\n",
        "Big question about whether machines can have qualia, which means consiousness. Issue is that even conciousness itself is not well defined. Book argues \n",
        "that you can program some aspects onf consiousness in machines, but making it exactly like humans is not somehting we should take on, but they do agree that \n",
        "some tasks require computer to have awareness. Humans have clear advantage over machines in modelling experiences because they can try it out for themselves. \"\"\"\n",
        "\n",
        "# Russell and Norvig, AIMA 4th Edition, Chapter 2 “Intelligent Agents” (whole chapter)\n",
        "chapter2_1 = \"\"\" Agents actions depend on what is has seen previously and currently but not on anything it hasnt seen. Agent function is mathematical defintion\n",
        "where agent program is implementation with physcial attributes. \"\"\"\n",
        "chapter2_2 = \"\"\" Agent does right thing based on consequences, and agent does well if sequence is desirable. Rationality at period of times depends on performance measure, \n",
        "prior knowledge of environment, actions agent can perform, and percept sequence to date. Rationality is very different from omniscience. When \n",
        "machine does things to help with future percept then it is information gathering. Rational agent should also be autonomous, meaning that it should learn \n",
        "what it can to compensate for not enough information\"\"\"\n",
        "chapter2_3 = \"\"\" First step when we design an agent is to specify task environment which is composed of PEAS (Performance, Environment, Actuators, Sensors). Actuators are \n",
        "components of machine where sensors detect change in environment. Fully vs partially observable. We say an environment is multi-agent if \n",
        "it maximizes performance measure that is depdent on B's behavior. Competitive multiagent is when increasing performance of one decreases others\n",
        "while cooperative, like taxi example, where increasing ones performance helps everyone. Episodic vs. sequential where sequential is opposite where there \n",
        "are no episodes. Discrete vs continuos applies to state, time, percepts, and actions. In known environment, we know outcomes of actions in environment, where\n",
        "unknown means agent has to learn how environment works to make reasonable decisions. Known environment does not mean fully observable and vice versa\"\"\"\n",
        "chapter2_4 = \"\"\" AGENT = ARCHITECTURE + PROGRAM. Agents programs take in an agent percept and return an agent actuator. Agent program only takes current percept\n",
        "whereas agent function can take in percept sequence. We cannot create a table of all possible combinations since that would be infite, instead we try to get \n",
        "rational behavior from small program that acts like table. Simple Reflex Agent will only take into consideration the current percept and will ignore the percept history.\n",
        "Simple Reflex Agents only work when environment is fully observable. Infinite loops are sometimes inevitable and the solution is to randomize next action. Model based reflex agents\n",
        "have internal state that maps percept history so that you can observe some unobserved aspects of environment. Agent that uses transition and sensor models is\n",
        "a model based agent. Goal based agents need goal information so that correct decision also depends on what goal we are trying to get to. Utility based agents try to maximize expected utlity \n",
        "based on a utility function. These agents have hardwired performance standards that either see percept as reward or penalty. Localist Representation is \n",
        "when one to one mapping between concepts and memory locations whereas distributed representation is opposite.\n",
        "\"\"\"\n",
        "\n",
        "# Lecture notes \n",
        "module1_lecture_notes = \"\"\" Hardest case is Continuous Partially Observable Stochastic Multiagent. Reflex agent only takes current percept whereas \n",
        "problem solving agent plans ahead. \"\"\"\n",
        "\n",
        "\n",
        "# Definitions of concepts from Module 1.\n",
        "# You can define any bolded term in the textbook, \n",
        "# but you most use your own words for the definitions.\n",
        "# Each definition should be at most 20 words long.\n",
        "module1_definitions = {\n",
        "\"agent\" : \"anything that can perceive and act in an environment\",\n",
        "\"Rational Agent\" : \"acts to achieve best outcome\",\n",
        "\"percept\" : \"what sensors of agent are seeing\",\n",
        "\"percept sequence\" : \"everything agent has perceived so far till now\",\n",
        "\"agent function\" : \"maps percepts to sequence of an action\",\n",
        "\"Turing Test\" : \"passes test if human after posing question cannot tell if response from machine or human\",\n",
        "\"knowledge representation\": \"the machine will keep what it already knows\",\n",
        "\"Total Turing Test\": \"machine needs to interact with things and people in real world\",\n",
        "\"Cognitive Science\": \"combo of comp sci and psych for human mind study\",\n",
        "\"Syllogism\": \"patterns for structure of arguments that give you right solution every time, creating field of logic\",\n",
        "\"Limited Rationality\": \"acting in good way when no time to have calcs for best decisions\",\n",
        "\"Value Alignment Problem\": \"values in machine supposed to be similar to those of a human\",\n",
        "\"Strong AI\": \"machines are actually consiously thinking -> human level thinking\",\n",
        "\"Weak AI\": \"machines simulate thinking\",\n",
        "\"Good Old Fashioned AI\": \"logical agent design\",\n",
        "\"Qualification Problem\": \"hard to specify all rules for program to run intelligently\",\n",
        "\"Embodied Cognition Approach\": \"brain and body as one, and in this approach robotics and vision are needed\",\n",
        "\"Biological naturalism\": \"cells have something that transistors do not and so only humans can think and machines cant\",\n",
        "\"Consequentialism\": \"we say whether agent is doing right thing based on its consequences\",\n",
        "\"Performance Measure\": \"evaluates sequence of enviornment states to say if machine did well\",\n",
        "\"Omniscience\": \"agent knows ACTUAL outcome of task and acts accordingly; impossible in real life\",\n",
        "\"Priori\": \"when environment is completely known\",\n",
        "\"Task Environment\": \"problem to be solved by rational agent\",\n",
        "\"Fully Observable\": \"if sensors give agent all information about environment in time period\",\n",
        "\"Unobservable\": \"agent has no sensors\",\n",
        "\"Deterministic\": \"environment is only determinded by action and curr state\",\n",
        "\"Stochastic\": \"undeterministic but has probabilities, where undeterministic does not have probabilities\",\n",
        "\"Episodic\": \"divided into episodes where agent sees percept and performs one action in each, next epi doesnt depend on first\",\n",
        "\"Dynamic environent\": \"environment can change in agent decision making process\",\n",
        "\"Semi-dynamic\": \"performance score changes with time but environment doesnt in decision making\",\n",
        "\"Agent Architecture\": \"Computing device with physical sensors where program is run\",\n",
        "\"Condition Action Rule\": \"basically an if statement for condition then do action\",\n",
        "\"Transition Model\": \"model for how world works used to make next decision in model based reflex agent\",\n",
        "\"Sensor Model\": \"what happens to sensors when action is taken\",\n",
        "\"Utility\": \"quality of being useful\",\n",
        "\"Learning Element\": \"sees how performance element should be modified based on how its doing from critic feedback\",\n",
        "\"Performance Element\": \"the entire agent\",\n",
        "\"Problem Generator\": \"last part of learning agent that suggests exploring options that could be worse now but better later\",\n",
        "\"Atomic Representation\": \"Each state of world is one unit and you cannot divide\",\n",
        "\"Factored Representation\": \"Splits states into smaller chunks which can inlcude variables\",\n",
        "\"Structured Representation\": \"the one used in which objects described as objects\",\n",
        "\n",
        "}\n",
        "\n"
      ],
      "execution_count": 26,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "elCCgY64spuq"
      },
      "source": [
        "## Preview of your notes for Module 1\n",
        "\n",
        "Here's a preview of your how your notes will be displayed.  At the end of this Python notebook, we'll aggregate your notes for all modules together into a single display.\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "gYYeNcdM_maE",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "cellView": "form",
        "outputId": "25439037-ae67-4480-e040-f71f55396b07"
      },
      "source": [
        "#@title Preview of your summary\n",
        "#@markdown You don't need to modify anything in this cell. Just press play.\n",
        "from IPython.display import display, Markdown, Latex\n",
        "\n",
        "module1_sections = [\n",
        "  (\"AIMA Chapter 1.1 What is AI?\", chapter1_1),\n",
        "  (\"AIMA Chapter 27.1 The Limits of AI\", chapter27_1),\n",
        "  (\"AIMA Chapter 27.1 Can Machines Really Think?\", chapter27_2),\n",
        "  (\"AIMA 2.1 Agents and Environments\", chapter2_1),\n",
        "  (\"AIMA 2.2 Good Behavior: The Concept of Rationality\", chapter2_2),\n",
        "  (\"AIMA 2.3 The Nature of Environments\", chapter2_3),\n",
        "  (\"AIMA 2.4 The Structure of Agents\", chapter2_4),\n",
        "  (\"Module 1 Lecture Notes\", module1_lecture_notes),\n",
        "]\n",
        "\n",
        "\n",
        "def length_check(sections):\n",
        "  warnings = \"\"\n",
        "  for section, summary in sections:\n",
        "    max_word_length = 500\n",
        "    max_character_length = 3000\n",
        "    if \"lecture\" in section.lower():\n",
        "      # It's OK to do longer summaries of the lectures\n",
        "      max_word_length = 2000\n",
        "      max_character_length = 12000  \n",
        "    if (len(summary) > max_character_length or len(summary.split(' ')) > max_word_length):\n",
        "      warnings += \"WARNING: Your summary of '{section}' is too long!\\n\".format(section=section)\n",
        "  return warnings\n",
        "\n",
        "def length_check_definitions(definitions):\n",
        "  warnings = \"\"\n",
        "  for concept, definition in definitions.items():\n",
        "    if(len(definition.split(' ')) > 20):\n",
        "      warnings += \"WARNING: Your definition of '{concept}' is too long!\\n\".format(concept=concept)\n",
        "  return warnings\n",
        "\n",
        "\n",
        "def format_module(module_num, title, sections, definitions, show_placeholder=False):\n",
        "  markdown = \"\"\n",
        "\n",
        "  # Check summary lengths\n",
        "  warnings = length_check(sections)\n",
        "  if warnings != \"\":\n",
        "    markdown += \"## \" + warnings\n",
        "\n",
        "  # Check definition lengths\n",
        "  warnings = length_check_definitions(definitions)\n",
        "  if warnings != \"\":\n",
        "    markdown += \"## \" + warnings\n",
        "\n",
        "  markdown += \"# Module {num}: {title}\\n\".format(num=module_num, title=title)\n",
        "\n",
        "\n",
        "  for section, summary in sections:\n",
        "    if show_placeholder and summary == \" Your summary here \":\n",
        "      summary = placeholder\n",
        "    markdown += \"## {section}\\n{summary}\\n\\n\".format(section=section, summary=summary)\n",
        "  \n",
        "  markdown += \"## Module {num} Definitions\\n\".format(num=module_num)\n",
        "  for concept, definition in definitions.items():\n",
        "    markdown += \"* **{concept}** - {definition}\\n\".format(concept=concept.capitalize(), definition=definition)\n",
        "  return markdown\n",
        "\n",
        "\n",
        "module1_markdown = format_module(1, \"Rational Agents and Task Environments\", module1_sections, module1_definitions)\n",
        "display(Markdown(module1_markdown))"
      ],
      "execution_count": 27,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 1: Rational Agents and Task Environments\n## AIMA Chapter 1.1 What is AI?\nSome people define intelligence in terms of human performance while others choose rationaility, doing the right thing. From these \nthere are 4 combinations of approachs: The first is the turing test approach, acting humanly (defined below). The human would need the following \ncapabilities to pass the Turing test: NLP, knowledge representation, automated reasoning, machine learning. Turing did not think physical \nrepresentation of machine was necessary for intelligence, but some others did and they proposed the Total Turing Test, where computer also needs \ncomputer vision and robotics. The second approach is the cognitive modelling approach: to say program thinks like human, we need to see how humans \nthink. We can observe the thoughts of humans by doing introspection, phychological experiments, brain imaging. If programs input-output matches this\ndefinition of human behavior then we can say it is intelligent. Allen Newell and Herbert Simon used this and it helped create cognitive science. Combination \nof cognitive science and AI is more apparent in computer vision. The third approach is the \"Law of Thoughts\" approach. It is based on syllogisms that will \nalways yield the correct answer. This created logic field which builds on this to create intelligent systems. However, this is not enough since \nwe need probability to represent things in the world. Rational thought is not enough, you need theory for rational action for model of intelligent behavior.\nThe last approach is the rational agent approach. The rational agent has two primary advantages, which are it is more general than \"laws of thought\" and \nrationaility is mathematically well defined. This is the most prevailing definition of AI, and it focuses on \"agents that will do the right thing\", and this \nway of thinking is so general that we call it the standard model. However, the standard model does not work well when we do not supply a defined\nobjective to the machine. This comes out in real world where the objective is not well defined. We want machines that will go do our objectives well and \nnot their objectives, and therefore standard model may not be enough, so that machines can be provably beneficial to humans\n\n## AIMA Chapter 27.1 The Limits of AI\n Turing said human behavior was too complex to be captured by set of rules for computer, and Dreyfus expanded that by providing\ncritiques of AI. Dreyfus said AI was impossible based on this. It is clear computers cannot be exactly humans and argument from disability by Turing \nclaims that they cannot do things like fall in love, be friendly, or have sense of humor, etc. We also have the mathematical objection to intelligence \nwhich comes from Godel's incompleteness theorem, proving that machines are mentally inferior to humans. Issue is this applies to math and not machines \nand it assumes humans own consistency which is invalid. Turing proposed that we should ask if machines can pass a behavioral test instead of seeing \nif they can think. Test requires program to have conversation with human for 30 mins and if it can fool interrogator into thinking it is a human 30% of the time\nthen it passes.\n\n## AIMA Chapter 27.1 Can Machines Really Think?\n Djikstra does not think machines can think, whereas Turing says we should have polite convention that everyone thinks\nand that we should extend that to machines as well. Searle rejects the polite convention by the Chinese room argument: saying that if we have human \nwho only understands english in room with code to translate stuff from english to chinese. The output will show a correct translation, but neither \nthe human or the codes know Chinese so it makes no sense to say they understand, saying this is how computers operate. Searle believed in biological naturalism.\nBig question about whether machines can have qualia, which means consiousness. Issue is that even conciousness itself is not well defined. Book argues \nthat you can program some aspects onf consiousness in machines, but making it exactly like humans is not somehting we should take on, but they do agree that \nsome tasks require computer to have awareness. Humans have clear advantage over machines in modelling experiences because they can try it out for themselves. \n\n## AIMA 2.1 Agents and Environments\n Agents actions depend on what is has seen previously and currently but not on anything it hasnt seen. Agent function is mathematical defintion\nwhere agent program is implementation with physcial attributes. \n\n## AIMA 2.2 Good Behavior: The Concept of Rationality\n Agent does right thing based on consequences, and agent does well if sequence is desirable. Rationality at period of times depends on performance measure, \nprior knowledge of environment, actions agent can perform, and percept sequence to date. Rationality is very different from omniscience. When \nmachine does things to help with future percept then it is information gathering. Rational agent should also be autonomous, meaning that it should learn \nwhat it can to compensate for not enough information\n\n## AIMA 2.3 The Nature of Environments\n First step when we design an agent is to specify task environment which is composed of PEAS (Performance, Environment, Actuators, Sensors). Actuators are \ncomponents of machine where sensors detect change in environment. Fully vs partially observable. We say an environment is multi-agent if \nit maximizes performance measure that is depdent on B's behavior. Competitive multiagent is when increasing performance of one decreases others\nwhile cooperative, like taxi example, where increasing ones performance helps everyone. Episodic vs. sequential where sequential is opposite where there \nare no episodes. Discrete vs continuos applies to state, time, percepts, and actions. In known environment, we know outcomes of actions in environment, where\nunknown means agent has to learn how environment works to make reasonable decisions. Known environment does not mean fully observable and vice versa\n\n## AIMA 2.4 The Structure of Agents\n AGENT = ARCHITECTURE + PROGRAM. Agents programs take in an agent percept and return an agent actuator. Agent program only takes current percept\nwhereas agent function can take in percept sequence. We cannot create a table of all possible combinations since that would be infite, instead we try to get \nrational behavior from small program that acts like table. Simple Reflex Agent will only take into consideration the current percept and will ignore the percept history.\nSimple Reflex Agents only work when environment is fully observable. Infinite loops are sometimes inevitable and the solution is to randomize next action. Model based reflex agents\nhave internal state that maps percept history so that you can observe some unobserved aspects of environment. Agent that uses transition and sensor models is\na model based agent. Goal based agents need goal information so that correct decision also depends on what goal we are trying to get to. Utility based agents try to maximize expected utlity \nbased on a utility function. These agents have hardwired performance standards that either see percept as reward or penalty. Localist Representation is \nwhen one to one mapping between concepts and memory locations whereas distributed representation is opposite.\n\n\n## Module 1 Lecture Notes\n Hardest case is Continuous Partially Observable Stochastic Multiagent. Reflex agent only takes current percept whereas \nproblem solving agent plans ahead. \n\n## Module 1 Definitions\n* **Agent** - anything that can perceive and act in an environment\n* **Rational agent** - acts to achieve best outcome\n* **Percept** - what sensors of agent are seeing\n* **Percept sequence** - everything agent has perceived so far till now\n* **Agent function** - maps percepts to sequence of an action\n* **Turing test** - passes test if human after posing question cannot tell if response from machine or human\n* **Knowledge representation** - the machine will keep what it already knows\n* **Total turing test** - machine needs to interact with things and people in real world\n* **Cognitive science** - combo of comp sci and psych for human mind study\n* **Syllogism** - patterns for structure of arguments that give you right solution every time, creating field of logic\n* **Limited rationality** - acting in good way when no time to have calcs for best decisions\n* **Value alignment problem** - values in machine supposed to be similar to those of a human\n* **Strong ai** - machines are actually consiously thinking -> human level thinking\n* **Weak ai** - machines simulate thinking\n* **Good old fashioned ai** - logical agent design\n* **Qualification problem** - hard to specify all rules for program to run intelligently\n* **Embodied cognition approach** - brain and body as one, and in this approach robotics and vision are needed\n* **Biological naturalism** - cells have something that transistors do not and so only humans can think and machines cant\n* **Consequentialism** - we say whether agent is doing right thing based on its consequences\n* **Performance measure** - evaluates sequence of enviornment states to say if machine did well\n* **Omniscience** - agent knows ACTUAL outcome of task and acts accordingly; impossible in real life\n* **Priori** - when environment is completely known\n* **Task environment** - problem to be solved by rational agent\n* **Fully observable** - if sensors give agent all information about environment in time period\n* **Unobservable** - agent has no sensors\n* **Deterministic** - environment is only determinded by action and curr state\n* **Stochastic** - undeterministic but has probabilities, where undeterministic does not have probabilities\n* **Episodic** - divided into episodes where agent sees percept and performs one action in each, next epi doesnt depend on first\n* **Dynamic environent** - environment can change in agent decision making process\n* **Semi-dynamic** - performance score changes with time but environment doesnt in decision making\n* **Agent architecture** - Computing device with physical sensors where program is run\n* **Condition action rule** - basically an if statement for condition then do action\n* **Transition model** - model for how world works used to make next decision in model based reflex agent\n* **Sensor model** - what happens to sensors when action is taken\n* **Utility** - quality of being useful\n* **Learning element** - sees how performance element should be modified based on how its doing from critic feedback\n* **Performance element** - the entire agent\n* **Problem generator** - last part of learning agent that suggests exploring options that could be worse now but better later\n* **Atomic representation** - Each state of world is one unit and you cannot divide\n* **Factored representation** - Splits states into smaller chunks which can inlcude variables\n* **Structured representation** - the one used in which objects described as objects\n",
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "9xRbdqDox2zD"
      },
      "source": [
        "#Module 2 - Python"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "DpBvu7EMx7sy"
      },
      "source": [
        "# No readings for this module.  Instead you can summarize the lecture instead.\n",
        "\n",
        "# Lecture notes \n",
        "module2_lecture_notes = \"\"\" Positives of python are that it is fast, portable, lots of libraries. Every object has a fixed type so you cannot \n",
        "do things incomptaible with type. So int + string not allowed you have to do str(int) + str. Also, strings are immutable in python where lists are mutable.\n",
        "Tuples are immutable. negatibe index at end in sliving indicates one before last, [:6] says copy from begining and [2:] is copy to end. You can use\n",
        "insert for list to insert element at specific index. join method joins that elements in list with specified element at beginning. .items for dictionary gives \n",
        "you list of tuples. You can have mutiple return values in python and the return type would be a tuple. You CANNOT have functions with same name in java even if \n",
        "you have different inputs. you can overload operators however. Arguments in python can be specified out of order and you can put default values for functions.\n",
        "You can use *args to provide variable number of non-keyword arguments. **kwargs for variable keyword arguments. Python uses the most current value of variable. You can pass\n",
        "functions into other functions. To define subclass put name of superclass in parantheses. You can call method on any class that implements a method and do not \n",
        "need to specificy interface like in Java. Yield returns value then goes back to where function left off and continues.\"\"\"\n",
        "\n",
        "# Each definition should be at most 20 words long.\n",
        "module2_definitions = {\n",
        "\"mutability\" : \"your definition here\",\n",
        "}"
      ],
      "execution_count": 28,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "ydOK__lwWgdp",
        "cellView": "form",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 345
        },
        "outputId": "0b972c99-fc87-4ae9-a9f7-0f4c3760c1d8"
      },
      "source": [
        "#@title Preview of your summary\n",
        "#@markdown You don't need to modify anything in this cell. Just press play.\n",
        "\n",
        "module2_sections = [\n",
        "  (\"Module 2 Lecture Notes\", module2_lecture_notes),\n",
        "]\n",
        "\n",
        "module2_markdown = format_module(2, \"Python\", module2_sections, module2_definitions)\n",
        "display(Markdown(module2_markdown))"
      ],
      "execution_count": 29,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 2: Python\n## Module 2 Lecture Notes\n Positives of python are that it is fast, portable, lots of libraries. Every object has a fixed type so you cannot \ndo things incomptaible with type. So int + string not allowed you have to do str(int) + str. Also, strings are immutable in python where lists are mutable.\nTuples are immutable. negatibe index at end in sliving indicates one before last, [:6] says copy from begining and [2:] is copy to end. You can use\ninsert for list to insert element at specific index. join method joins that elements in list with specified element at beginning. .items for dictionary gives \nyou list of tuples. You can have mutiple return values in python and the return type would be a tuple. You CANNOT have functions with same name in java even if \nyou have different inputs. you can overload operators however. Arguments in python can be specified out of order and you can put default values for functions.\nYou can use *args to provide variable number of non-keyword arguments. **kwargs for variable keyword arguments. Python uses the most current value of variable. You can pass\nfunctions into other functions. To define subclass put name of superclass in parantheses. You can call method on any class that implements a method and do not \nneed to specificy interface like in Java. Yield returns value then goes back to where function left off and continues.\n\n## Module 2 Definitions\n* **Mutability** - your definition here\n",
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "46MQLR-Gx8dZ"
      },
      "source": [
        "#Module 3 - Search Problems"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "BN0b1eVYx-nd"
      },
      "source": [
        "# Russell and Norvig, AIMA 4th Edition, AIMA Chapter 3 “Problem Solving by Search” (3.1-3.4)\n",
        "chapter3_1 = \"\"\" Your summary here \"\"\"\n",
        "chapter3_2 = \"\"\" Your summary here \"\"\"\n",
        "chapter3_3 = \"\"\" Your summary here \"\"\"\n",
        "chapter3_4 = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "\n",
        "# Lecture notes \n",
        "module3_lecture_notes = \"\"\" For a search problem we need: a goal, states, actions, and a performance measure. The definition of a search problem:\n",
        "1. states, 2. initial state, 3. transition model, 4. path cost, 5. goal test. A solution is optimal if no other solution has a lower path cost. Tree Search is \n",
        "when you enumerate in some order all possible paths from initial state.root is intial state and nodes in search tree are generated through transition model. Tree search \n",
        "has property where diff paths to same state are diff. A node is part of search tree that stores parent, child, board, etc. The state is just the phsycial representation \"board\" \n",
        "of the curr node. The issue with tree search is we can have repeated sgtates so runtime becomes very large. Graph Search is same as tree search but it checks if node \n",
        "has been visited before going down path. Uninformed search is where all non-goal nodes are equal in terms of how good they are, where informed search algorithms have each node where \n",
        "they each have different weights based on how far they are from goal node. b is max branching factor of tree, d is the depth of the tree. m is the max length of \n",
        "any path in state space. For BFS we first expand the most shallow unexpanded node, and you use FIFO queue for BFS. Time complexity of BFS is O(b^d) and DFS is O(b^d). DFS uses a LIFO queue, and expands\n",
        "the deepest unexpanded node. DFS has O(b^m) time complexity and O(bm) space complexity. For BFS vs. DFS, BFS could have probable infinite paths and for DFS space can become restricted quickly. BFS is complete, optimal, but con is \n",
        "that it uses O(b^d) space. DFS is not complete (may be complete if m is bounded), not optimal, and uses O(b^m) time, however, a pro is that it uses O(bm) space. To get the \n",
        "best of both we can do depth limited search. For depth limited search we do DFS but restrict depth and this makes it so no infinite path problem. If level = depth\n",
        "then it is optimal, but if l < d -> incomplete and if l > d -> not optimal. The time complexity is O(b^l) and space complexity is O(bl). We can do Iterative Deepening Search, which is Depth Limited search \n",
        "but we start from l = 0 to infinity. The time complexity would be O(b^d) and space complexity is O(bd), and it is complete and optimal.\n",
        "\"\"\"\n",
        "\n",
        "# Definitions of concepts from Module 3.\n",
        "# You can define any bolded term in the textbook, \n",
        "# but you most use your own words for the definitions.\n",
        "# Each definition should be at most 20 words long.\n",
        "module3_definitions = {\n",
        "\"problem-solving agent\" : \"an agent that can formulate a plan via search\",\n",
        "\"Completeness\" : \"algo will always find solution \", \n",
        "\"Optimality\" : \"algo will find solution with least cost\", \n",
        "\"Optimality\" : \"algo will find solution with least cost\",         \n",
        "}\n",
        "\n"
      ],
      "execution_count": 30,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "lvtN3p7ET3Tx",
        "cellView": "form",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 760
        },
        "outputId": "c3865f90-636d-48b2-b3f3-820d663347aa"
      },
      "source": [
        "#@title Preview of your summary\n",
        "#@markdown You don't need to modify anything in this cell. Just press play.\n",
        "module3_sections = [\n",
        "  (\"AIMA Chapter 3.1 Problem-Solving Agents\", chapter3_1),\n",
        "  (\"AIMA Chapter 3.2 Example Problems\", chapter3_2),\n",
        "  (\"AIMA Chapter 3.3 Search Algorithms\", chapter3_3),\n",
        "  (\"AIMA Chapter 3.4 Uninformed Search Strategies\", chapter3_4),\n",
        "  (\"Module 3 Lecture Notes\", module3_lecture_notes),\n",
        "]\n",
        "\n",
        "module3_markdown = format_module(3, \"Search Problems\", module3_sections, module3_definitions)\n",
        "display(Markdown(module3_markdown))"
      ],
      "execution_count": 31,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 3: Search Problems\n## AIMA Chapter 3.1 Problem-Solving Agents\n Your summary here \n\n## AIMA Chapter 3.2 Example Problems\n Your summary here \n\n## AIMA Chapter 3.3 Search Algorithms\n Your summary here \n\n## AIMA Chapter 3.4 Uninformed Search Strategies\n Your summary here \n\n## Module 3 Lecture Notes\n For a search problem we need: a goal, states, actions, and a performance measure. The definition of a search problem:\n1. states, 2. initial state, 3. transition model, 4. path cost, 5. goal test. A solution is optimal if no other solution has a lower path cost. Tree Search is \nwhen you enumerate in some order all possible paths from initial state.root is intial state and nodes in search tree are generated through transition model. Tree search \nhas property where diff paths to same state are diff. A node is part of search tree that stores parent, child, board, etc. The state is just the phsycial representation \"board\" \nof the curr node. The issue with tree search is we can have repeated sgtates so runtime becomes very large. Graph Search is same as tree search but it checks if node \nhas been visited before going down path. Uninformed search is where all non-goal nodes are equal in terms of how good they are, where informed search algorithms have each node where \nthey each have different weights based on how far they are from goal node. b is max branching factor of tree, d is the depth of the tree. m is the max length of \nany path in state space. For BFS we first expand the most shallow unexpanded node, and you use FIFO queue for BFS. Time complexity of BFS is O(b^d) and DFS is O(b^d). DFS uses a LIFO queue, and expands\nthe deepest unexpanded node. DFS has O(b^m) time complexity and O(bm) space complexity. For BFS vs. DFS, BFS could have probable infinite paths and for DFS space can become restricted quickly. BFS is complete, optimal, but con is \nthat it uses O(b^d) space. DFS is not complete (may be complete if m is bounded), not optimal, and uses O(b^m) time, however, a pro is that it uses O(bm) space. To get the \nbest of both we can do depth limited search. For depth limited search we do DFS but restrict depth and this makes it so no infinite path problem. If level = depth\nthen it is optimal, but if l < d -> incomplete and if l > d -> not optimal. The time complexity is O(b^l) and space complexity is O(bl). We can do Iterative Deepening Search, which is Depth Limited search \nbut we start from l = 0 to infinity. The time complexity would be O(b^d) and space complexity is O(bd), and it is complete and optimal.\n\n\n## Module 3 Definitions\n* **Problem-solving agent** - an agent that can formulate a plan via search\n* **Completeness** - algo will always find solution \n* **Optimality** - algo will find solution with least cost\n",
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "WHREsHSSyA-h"
      },
      "source": [
        "#Module 4 - Informed Search"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "tuFC8w7CyCns"
      },
      "source": [
        "# Russell and Norvig, AIMA Chapter 3 “Problem Solving by Search” (3.5-3.6)\n",
        "chapter3_5 = \"\"\" Your summary here \"\"\"\n",
        "chapter3_6 = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "\n",
        "# Lecture notes \n",
        "module4_lecture_notes = \"\"\"Uniform Cost Search (Djikstra's) is tree search that is used to traverse a weighted tree. For Uniform cost search you \n",
        "expand node with the lowest path cost, and it tests whether node is goal when popped from queue. A heuristic function is an estimate for cost from curr\n",
        "to goal. Greedy Best First Search expands nodes with minimal huerisitc value without adding the cost of the node we are on. Greedy best first search is not optimal or complete\n",
        "A* search is where you expand nodes with least f(n) = g(n) + h(n). A heuristic is admissable if it never overestimates the cost to the goal. If the heuristic \n",
        "is admissable then A* is optimal and complete. The cost of optimal solution to relaxed problem is an admissable heuristic to main problem. If two heuristics and \n",
        "h2(n) > h1(n) then h2(n) dominates h1(n), and so h2(n) is more accurate and we use that. A heurisitc is admissable if 0 <= h(n) <= h*(n) where h*(n) is the true \n",
        "distance\"\"\"\n",
        "\n",
        "# Definitions\n",
        "module4_definitions = {\n",
        "\"concept\" : \"definition\",    \n",
        "}\n",
        "\n"
      ],
      "execution_count": 32,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "vqtEs0gHs9sO",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 426
        },
        "cellView": "form",
        "outputId": "b2eea679-fec7-4195-992e-e25437e9c301"
      },
      "source": [
        "#@title Preview of your summary\n",
        "#@markdown You don't need to modify anything in this cell. Just press play.\n",
        "module4_sections = [\n",
        "  (\"AIMA Chapter 3.5 Informed (Heuristic) Search Strategies\", chapter3_5),\n",
        "  (\"AIMA Chapter 3.6 Heuristic Functions\", chapter3_6),\n",
        "  (\"Module 4 Lecture Notes\", module4_lecture_notes),\n",
        "]\n",
        "\n",
        "module4_markdown = format_module(4, \"Informed Search\", \n",
        "                         module4_sections, \n",
        "                         module4_definitions)\n",
        "display(Markdown(module4_markdown))"
      ],
      "execution_count": 33,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 4: Informed Search\n## AIMA Chapter 3.5 Informed (Heuristic) Search Strategies\n Your summary here \n\n## AIMA Chapter 3.6 Heuristic Functions\n Your summary here \n\n## Module 4 Lecture Notes\nUniform Cost Search (Djikstra's) is tree search that is used to traverse a weighted tree. For Uniform cost search you \nexpand node with the lowest path cost, and it tests whether node is goal when popped from queue. A heuristic function is an estimate for cost from curr\nto goal. Greedy Best First Search expands nodes with minimal huerisitc value without adding the cost of the node we are on. Greedy best first search is not optimal or complete\nA* search is where you expand nodes with least f(n) = g(n) + h(n). A heuristic is admissable if it never overestimates the cost to the goal. If the heuristic \nis admissable then A* is optimal and complete. The cost of optimal solution to relaxed problem is an admissable heuristic to main problem. If two heuristics and \nh2(n) > h1(n) then h2(n) dominates h1(n), and so h2(n) is more accurate and we use that. A heurisitc is admissable if 0 <= h(n) <= h*(n) where h*(n) is the true \ndistance\n\n## Module 4 Definitions\n* **Concept** - definition\n",
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "F3FPMzG9yUls"
      },
      "source": [
        "#Module 5 - Adversarial Search and Games"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "iEIOpL7vyWcc"
      },
      "source": [
        "# Russell and Norvig, AIMA chapter 5 \"Adversarial Search\"”\" (5.1-5.3, and 5.5).\n",
        "chapter5_1 = \"\"\" Your summary here \"\"\"\n",
        "chapter5_2 = \"\"\" Your summary here \"\"\"\n",
        "chapter5_3 = \"\"\" Your summary here \"\"\"\n",
        "chapter5_5 = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "# Russell and Norvig, AIMA Chapter 16 “Making Simple Decisions” (16.1-16.3)\n",
        "chapter16_1 = \"\"\" Your summary here \"\"\"\n",
        "chapter16_2 = \"\"\" Your summary here \"\"\"\n",
        "chapter16_3 = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "# Lecture notes \n",
        "module5_lecture_notes = \"\"\" The simplest game environment is multi-agent, static, discrete, fully observable, strategic. We have two players MIN and MAX.\n",
        "For games as search, the game should have initial state, successor function, terminal test, utility function, MAX. All play from MAXs vantage point. \n",
        "When MAX plays he maximizes MAX outcome, and when MIN moves she has to minimze MAX outcome. We can have one function f(n) that determines whose winning. \n",
        "If f(n) > 0 then MAX is winning, if f(n) < 0 then MIN is winning, and if f(n) = 0, then the game is tied. During MINIMAX, WE have to start at leaves and back out values till \n",
        "we get to the top, and we do this by choosing largest value of MAX children and min value of MIN children. Optimal play means that we maximize the worst \n",
        "case outcome for MAX. In alpha-beta pruning we keep track of alpha and beta (defined below). MAX will now allow move that leads to worse than alpha and MIN will never allow \n",
        "move that leads to better score for MAX than beta. Therefore, when evaluating a MAX node: if find value v >= beta then we stop search and prune other leaves, wherease when evaluating \n",
        "a MIN node, if find a value of v <= alpha then stop and prune. In Expectimax Search, values are going to be average case and not worst case like minimax, and chance nodes \n",
        "are like min nodes but we calculate expected utlity since outcome is not certain\"\"\"\n",
        "\n",
        "# Definitions\n",
        "module5_definitions = {\n",
        "\"EVEN LEVELS\" : \"MAX Turn\",\n",
        "\"ODD LEVELS\" : \"MIN Turn\",  \n",
        "\"Minimax Rule\" : \"Make best move for MAX assuming MIN always responds with best move for MIN\",\n",
        "\"alpha\" : \"MAX's lower bound on MAX's outcome\",\n",
        "\"beta\" : \"upper bound on MIN's outcome\",   \n",
        "}\n",
        "\n"
      ],
      "execution_count": 34,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "KUc_LgzDvWf-",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 878
        },
        "outputId": "ea7176b2-7796-4e3f-d482-429319b5bf64"
      },
      "source": [
        "#@title Preview of your summary\n",
        "#@markdown You don't need to modify anything in this cell. Just press play.\n",
        "module5_sections = [\n",
        "  (\"AIMA Chapter 5.1 Game Theory\", chapter5_1),\n",
        "  (\"AIMA Chapter 5.2 Optimal Decisions in Games\", chapter5_2),\n",
        "  (\"AIMA Chapter 5.3 Heuristic Alpha–Beta Tree Search\", chapter5_3),\n",
        "  (\"AIMA Chapter 5.5 Stochastic Games\", chapter5_5),\n",
        "  (\"AIMA Chapter 16.1 Combining Beliefs and Desires under Uncertainty\", chapter16_1),\n",
        "  (\"AIMA Chapter 16.2 The Basis of Utility Theory\", chapter16_2),\n",
        "  (\"AIMA Chapter 16.3 Utility Functions\", chapter16_3),\n",
        "  (\"Module 5 Lecture Notes\", module5_lecture_notes),\n",
        "]\n",
        "\n",
        "module5_markdown = format_module(5, \"Adversarial Search and Games\", \n",
        "                         module5_sections, \n",
        "                         module5_definitions)\n",
        "display(Markdown(module5_markdown))"
      ],
      "execution_count": 35,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 5: Adversarial Search and Games\n## AIMA Chapter 5.1 Game Theory\n Your summary here \n\n## AIMA Chapter 5.2 Optimal Decisions in Games\n Your summary here \n\n## AIMA Chapter 5.3 Heuristic Alpha–Beta Tree Search\n Your summary here \n\n## AIMA Chapter 5.5 Stochastic Games\n Your summary here \n\n## AIMA Chapter 16.1 Combining Beliefs and Desires under Uncertainty\n Your summary here \n\n## AIMA Chapter 16.2 The Basis of Utility Theory\n Your summary here \n\n## AIMA Chapter 16.3 Utility Functions\n Your summary here \n\n## Module 5 Lecture Notes\n The simplest game environment is multi-agent, static, discrete, fully observable, strategic. We have two players MIN and MAX.\nFor games as search, the game should have initial state, successor function, terminal test, utility function, MAX. All play from MAXs vantage point. \nWhen MAX plays he maximizes MAX outcome, and when MIN moves she has to minimze MAX outcome. We can have one function f(n) that determines whose winning. \nIf f(n) > 0 then MAX is winning, if f(n) < 0 then MIN is winning, and if f(n) = 0, then the game is tied. During MINIMAX, WE have to start at leaves and back out values till \nwe get to the top, and we do this by choosing largest value of MAX children and min value of MIN children. Optimal play means that we maximize the worst \ncase outcome for MAX. In alpha-beta pruning we keep track of alpha and beta (defined below). MAX will now allow move that leads to worse than alpha and MIN will never allow \nmove that leads to better score for MAX than beta. Therefore, when evaluating a MAX node: if find value v >= beta then we stop search and prune other leaves, wherease when evaluating \na MIN node, if find a value of v <= alpha then stop and prune. In Expectimax Search, values are going to be average case and not worst case like minimax, and chance nodes \nare like min nodes but we calculate expected utlity since outcome is not certain\n\n## Module 5 Definitions\n* **Even levels** - MAX Turn\n* **Odd levels** - MIN Turn\n* **Minimax rule** - Make best move for MAX assuming MIN always responds with best move for MIN\n* **Alpha** - MAX's lower bound on MAX's outcome\n* **Beta** - upper bound on MIN's outcome\n",
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "qVSQhTVSyYYO"
      },
      "source": [
        "#Module 6 - \"Constraint Satisfaction Problems\""
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Wm4mfW82yaRH"
      },
      "source": [
        "# Russell and Norvig, AIMA, Chapter 6 “Constraint Satisfaction Problems” (6.1-6.5)\n",
        "chapter6_1 = \"\"\" Your summary here \"\"\"\n",
        "chapter6_2 = \"\"\" Your summary here \"\"\"\n",
        "chapter6_3 = \"\"\" Your summary here \"\"\"\n",
        "chapter6_4 = \"\"\" Your summary here \"\"\"\n",
        "chapter6_5 = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "\n",
        "# Lecture notes \n",
        "module6_lecture_notes = \"\"\" A CSP has set of variables, domain of possible values for every variable, set of constraints. For a CSP it is complete if \n",
        "every variable has a value, and a solution to CSP has to be complete. We only need to say what spec of CSP is to solve using general algorithm. CSP can \n",
        "be represented as search problem where final sol is found in depth n -> use DFS. When we are doing CSP, choose most constrained variable first, meaning \n",
        "it has lowest number of legal moves possible. If tied with another then choose most constraining variable -> which adds most constraints on others. This would be \n",
        "heuristic in our search. We can do forward checking but issue is that it doesnt detect early values for all failures. FORWARD CHECKING CHECKS ONE IN ADVANCE. Therefore, we put constraint propogation \n",
        "or inference step. In this step we remove all states that would go against local consistency. For this we will add back edge and forward edge (look like arcs). Arc Consistency\n",
        "is when, a and b are arc consis if for every value in tail a there is a value in head b such that we can pick tail a. If we remove values from domain in arc consis, then \n",
        "we recheck the neighbors to maintain arc consistency. Checking arcs take O(d^2) time. AC3 algo steps are 1. all nodes start with all possible values. \n",
        "2. for every node i check its neighbors j and remove any values that are not arc consistent. 3. Add the neighbors of the nodes which had values that changed back to queue. 4. Repeat process and stop when values do not change\n",
        "Complexity is O(n^2d^3)\"\"\"\n",
        "\n",
        "# Definitions\n",
        "module6_definitions = {\n",
        "\"unary\" : \"constraint with one variable\", \n",
        "\"binary\" : \"constraint with pairs for variables\", \n",
        "\"higher order\" : \"3 or more variables\",\n",
        "\"backtracking\" : \"DFS with single variable assignments\",  \n",
        "\"Forward Checking\" : \"end search when any unassinged variable has 0 moves, by keeping track of all possible values\",  \n",
        "\"Local Consistency\" : \"Node consistency where it satisfies unary constraints or arc consistency\", \n",
        "}\n"
      ],
      "execution_count": 36,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "kKWbCsbfxL3R",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 793
        },
        "outputId": "7cb48744-fb77-4342-e7b3-33751b22c3ff"
      },
      "source": [
        "#@title Preview of your summary\n",
        "#@markdown You don't need to modify anything in this cell. Just press play.\n",
        "module6_sections = [\n",
        "  (\"AIMA Chapter 6.1 Defining Constraint Satisfaction Problems\", chapter6_1),\n",
        "  (\"AIMA Chapter 6.2 Constraint Propagation: Inference in CSPs\", chapter6_2),\n",
        "  (\"AIMA Chapter 6.3 Backtracking Search for CSPs\", chapter6_3),\n",
        "  (\"AIMA Chapter 6.4 Local Search for CSPs\", chapter6_4),\n",
        "  (\"AIMA Chapter 6.5 The Structure of Problems\", chapter6_5),\n",
        "  (\"Module 6 Lecture Notes\", module6_lecture_notes),\n",
        "]\n",
        "\n",
        "module6_markdown = format_module(6, \"Constraint Satisfaction Problems\", \n",
        "                         module6_sections, \n",
        "                         module6_definitions)\n",
        "display(Markdown(module6_markdown))"
      ],
      "execution_count": 37,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 6: Constraint Satisfaction Problems\n## AIMA Chapter 6.1 Defining Constraint Satisfaction Problems\n Your summary here \n\n## AIMA Chapter 6.2 Constraint Propagation: Inference in CSPs\n Your summary here \n\n## AIMA Chapter 6.3 Backtracking Search for CSPs\n Your summary here \n\n## AIMA Chapter 6.4 Local Search for CSPs\n Your summary here \n\n## AIMA Chapter 6.5 The Structure of Problems\n Your summary here \n\n## Module 6 Lecture Notes\n A CSP has set of variables, domain of possible values for every variable, set of constraints. For a CSP it is complete if \nevery variable has a value, and a solution to CSP has to be complete. We only need to say what spec of CSP is to solve using general algorithm. CSP can \nbe represented as search problem where final sol is found in depth n -> use DFS. When we are doing CSP, choose most constrained variable first, meaning \nit has lowest number of legal moves possible. If tied with another then choose most constraining variable -> which adds most constraints on others. This would be \nheuristic in our search. We can do forward checking but issue is that it doesnt detect early values for all failures. FORWARD CHECKING CHECKS ONE IN ADVANCE. Therefore, we put constraint propogation \nor inference step. In this step we remove all states that would go against local consistency. For this we will add back edge and forward edge (look like arcs). Arc Consistency\nis when, a and b are arc consis if for every value in tail a there is a value in head b such that we can pick tail a. If we remove values from domain in arc consis, then \nwe recheck the neighbors to maintain arc consistency. Checking arcs take O(d^2) time. AC3 algo steps are 1. all nodes start with all possible values. \n2. for every node i check its neighbors j and remove any values that are not arc consistent. 3. Add the neighbors of the nodes which had values that changed back to queue. 4. Repeat process and stop when values do not change\nComplexity is O(n^2d^3)\n\n## Module 6 Definitions\n* **Unary** - constraint with one variable\n* **Binary** - constraint with pairs for variables\n* **Higher order** - 3 or more variables\n* **Backtracking** - DFS with single variable assignments\n* **Forward checking** - end search when any unassinged variable has 0 moves, by keeping track of all possible values\n* **Local consistency** - Node consistency where it satisfies unary constraints or arc consistency\n",
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "RYESi2kMybL8"
      },
      "source": [
        "#Module 7 - Logical Agents"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "qIRJ4YYCzNHL"
      },
      "source": [
        "# Russell and Norvig, AIMA Chapter 7 “Logical Agents” (Sections 7.1-7.5)\n",
        "\n",
        "chapter7_1 = \"\"\" Your summary here \"\"\"\n",
        "chapter7_2 = \"\"\" Your summary here \"\"\"\n",
        "chapter7_3 = \"\"\" Your summary here \"\"\"\n",
        "chapter7_4 = \"\"\" Your summary here \"\"\"\n",
        "chapter7_5 = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "# Lecture notes \n",
        "module7_lecture_notes = \"\"\" The knowledge base will at the start contain background info about the world. Our knowledge based agent will get points \n",
        "for doing right thing and lose for doing wrong thing. Logic will help us represent what is happening to knowledge based agent. To write A entails B in \n",
        "math notation we do a |= b. Knowledge Base is false when current model contradicts what agent knows about world already. <=> is if and only if. We can use \n",
        "entailment to derive conclusions while going through world, and inference algorithms will enumerate sentences as true or false. three lines over each other \n",
        "means logically equivalent. Rules: a -> b is same as not(a) U b, a <-> is same as ((a -> b) intersection (b -> a)), ((a intersect b) U C) is same as \n",
        "((a intersect b) U (a intersect c)), ((a U b) intersect C) is same as \n",
        "((a U b) intersect (a U c)), a -> b is same as not(b) -> not(a). For inference rules, whenever we have a -> b and a is given then b can be inferred.\n",
        "CNF is a bunch of ors anded together. For resolution algorithm, to show kb |= a we can show kb intersect not(a) is unsatisfiable.\"\"\"\n",
        "\n",
        "# Definitions\n",
        "module7_definitions = {\n",
        "\"Knowledge Based Agents\" : \"reason over knowledge given of state to see what action to take\", \n",
        "\"Knowledge Base\" : \"sentence in knowledge rep languange that tells us something about state \", \n",
        "\"Axiom\" : \"given sentence\",\n",
        "\"Derived Sentences\" : \"derive new sentences from old using inference\",\n",
        "\"Model\" : \"our world\",\n",
        "\"Logical Inference\" : \"Deriving Conclusions\",\n",
        "\"Propositional Symbol\" : \"Either true or false depending on sentence it represents is true or false\",\n",
        "\"Sound\" : \"inference algo is sound if it only derives entailed sentences\",\n",
        "\"complete\" : \"all sentences that can be entailed can be derived\",\n",
        "\"CNF\" : \"bunch of ors anded together \",\n",
        "\n",
        "}\n",
        "\n"
      ],
      "execution_count": 38,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "lXNcHuKjyNXa",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 796
        },
        "outputId": "275cbb23-6172-4646-da85-97c362ccf327"
      },
      "source": [
        "#@title Preview of your summary\n",
        "#@markdown You don't need to modify anything in this cell. Just press play.\n",
        "module7_sections = [\n",
        "  (\"AIMA Chapter 7.1 Knowledge-Based Agents\", chapter7_1),\n",
        "  (\"AIMA Chapter 7.2 The Wumpus World\", chapter7_2),\n",
        "  (\"AIMA Chapter 7.3 Logic\", chapter7_3),\n",
        "  (\"AIMA Chapter 7.4 Propositional Logic: A Very Simple Logic\", chapter7_4),\n",
        "  (\"AIMA 7.5 Propositional Theorem Proving\", chapter7_5),\n",
        "  (\"Module 7 Lecture Notes\", module7_lecture_notes),\n",
        "]\n",
        "\n",
        "module7_markdown = format_module(7, \"Logical Agents\", \n",
        "                         module7_sections, \n",
        "                         module7_definitions)\n",
        "display(Markdown(module7_markdown))"
      ],
      "execution_count": 39,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 7: Logical Agents\n## AIMA Chapter 7.1 Knowledge-Based Agents\n Your summary here \n\n## AIMA Chapter 7.2 The Wumpus World\n Your summary here \n\n## AIMA Chapter 7.3 Logic\n Your summary here \n\n## AIMA Chapter 7.4 Propositional Logic: A Very Simple Logic\n Your summary here \n\n## AIMA 7.5 Propositional Theorem Proving\n Your summary here \n\n## Module 7 Lecture Notes\n The knowledge base will at the start contain background info about the world. Our knowledge based agent will get points \nfor doing right thing and lose for doing wrong thing. Logic will help us represent what is happening to knowledge based agent. To write A entails B in \nmath notation we do a |= b. Knowledge Base is false when current model contradicts what agent knows about world already. <=> is if and only if. We can use \nentailment to derive conclusions while going through world, and inference algorithms will enumerate sentences as true or false. three lines over each other \nmeans logically equivalent. Rules: a -> b is same as not(a) U b, a <-> is same as ((a -> b) intersection (b -> a)), ((a intersect b) U C) is same as \n((a intersect b) U (a intersect c)), ((a U b) intersect C) is same as \n((a U b) intersect (a U c)), a -> b is same as not(b) -> not(a). For inference rules, whenever we have a -> b and a is given then b can be inferred.\nCNF is a bunch of ors anded together. For resolution algorithm, to show kb |= a we can show kb intersect not(a) is unsatisfiable.\n\n## Module 7 Definitions\n* **Knowledge based agents** - reason over knowledge given of state to see what action to take\n* **Knowledge base** - sentence in knowledge rep languange that tells us something about state \n* **Axiom** - given sentence\n* **Derived sentences** - derive new sentences from old using inference\n* **Model** - our world\n* **Logical inference** - Deriving Conclusions\n* **Propositional symbol** - Either true or false depending on sentence it represents is true or false\n* **Sound** - inference algo is sound if it only derives entailed sentences\n* **Complete** - all sentences that can be entailed can be derived\n* **Cnf** - bunch of ors anded together \n",
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "vX7lbnJd4sT5"
      },
      "source": [
        "# Your Exam Notes\n",
        "\n",
        "Here are your full set of exam notes that you can use on your midterm.  Choose **Runtime > Run all**, then your notes will be displayed.\n",
        "\n",
        "If you are taking the exam in person, then you must print a copy of your notes for yourself.   Here's how to print:\n",
        "* Run the cell below. \n",
        "* Click its \"Mirror cell in tab\" button (this is located in the upper right corner of the cell, immediately to the right of the trash can).  This will open the cell.  \n",
        "* In Chrome, you can then print your notes using the **File > Print** option from the browser's menu.  \n",
        "* In the print options, change the layout from Landscape to Portrait. \n",
        "* Clicking the Save, will save a PDF that you can then print.\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "id": "T3cm1WV542_a",
        "outputId": "b377a72c-55af-4d59-8f54-c9f72259c90d"
      },
      "source": [
        "# This will generate the full set of notes that you can use for your exam.\n",
        "full_markdown = \"\\n\\n\".join([module1_markdown, \n",
        "                             module2_markdown, \n",
        "                             module3_markdown, \n",
        "                             module4_markdown, \n",
        "                             module5_markdown,\n",
        "                             module6_markdown,\n",
        "                             module7_markdown,]\n",
        "                       )\n",
        "display(Markdown(full_markdown))"
      ],
      "execution_count": 40,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 1: Rational Agents and Task Environments\n## AIMA Chapter 1.1 What is AI?\nSome people define intelligence in terms of human performance while others choose rationaility, doing the right thing. From these \nthere are 4 combinations of approachs: The first is the turing test approach, acting humanly (defined below). The human would need the following \ncapabilities to pass the Turing test: NLP, knowledge representation, automated reasoning, machine learning. Turing did not think physical \nrepresentation of machine was necessary for intelligence, but some others did and they proposed the Total Turing Test, where computer also needs \ncomputer vision and robotics. The second approach is the cognitive modelling approach: to say program thinks like human, we need to see how humans \nthink. We can observe the thoughts of humans by doing introspection, phychological experiments, brain imaging. If programs input-output matches this\ndefinition of human behavior then we can say it is intelligent. Allen Newell and Herbert Simon used this and it helped create cognitive science. Combination \nof cognitive science and AI is more apparent in computer vision. The third approach is the \"Law of Thoughts\" approach. It is based on syllogisms that will \nalways yield the correct answer. This created logic field which builds on this to create intelligent systems. However, this is not enough since \nwe need probability to represent things in the world. Rational thought is not enough, you need theory for rational action for model of intelligent behavior.\nThe last approach is the rational agent approach. The rational agent has two primary advantages, which are it is more general than \"laws of thought\" and \nrationaility is mathematically well defined. This is the most prevailing definition of AI, and it focuses on \"agents that will do the right thing\", and this \nway of thinking is so general that we call it the standard model. However, the standard model does not work well when we do not supply a defined\nobjective to the machine. This comes out in real world where the objective is not well defined. We want machines that will go do our objectives well and \nnot their objectives, and therefore standard model may not be enough, so that machines can be provably beneficial to humans\n\n## AIMA Chapter 27.1 The Limits of AI\n Turing said human behavior was too complex to be captured by set of rules for computer, and Dreyfus expanded that by providing\ncritiques of AI. Dreyfus said AI was impossible based on this. It is clear computers cannot be exactly humans and argument from disability by Turing \nclaims that they cannot do things like fall in love, be friendly, or have sense of humor, etc. We also have the mathematical objection to intelligence \nwhich comes from Godel's incompleteness theorem, proving that machines are mentally inferior to humans. Issue is this applies to math and not machines \nand it assumes humans own consistency which is invalid. Turing proposed that we should ask if machines can pass a behavioral test instead of seeing \nif they can think. Test requires program to have conversation with human for 30 mins and if it can fool interrogator into thinking it is a human 30% of the time\nthen it passes.\n\n## AIMA Chapter 27.1 Can Machines Really Think?\n Djikstra does not think machines can think, whereas Turing says we should have polite convention that everyone thinks\nand that we should extend that to machines as well. Searle rejects the polite convention by the Chinese room argument: saying that if we have human \nwho only understands english in room with code to translate stuff from english to chinese. The output will show a correct translation, but neither \nthe human or the codes know Chinese so it makes no sense to say they understand, saying this is how computers operate. Searle believed in biological naturalism.\nBig question about whether machines can have qualia, which means consiousness. Issue is that even conciousness itself is not well defined. Book argues \nthat you can program some aspects onf consiousness in machines, but making it exactly like humans is not somehting we should take on, but they do agree that \nsome tasks require computer to have awareness. Humans have clear advantage over machines in modelling experiences because they can try it out for themselves. \n\n## AIMA 2.1 Agents and Environments\n Agents actions depend on what is has seen previously and currently but not on anything it hasnt seen. Agent function is mathematical defintion\nwhere agent program is implementation with physcial attributes. \n\n## AIMA 2.2 Good Behavior: The Concept of Rationality\n Agent does right thing based on consequences, and agent does well if sequence is desirable. Rationality at period of times depends on performance measure, \nprior knowledge of environment, actions agent can perform, and percept sequence to date. Rationality is very different from omniscience. When \nmachine does things to help with future percept then it is information gathering. Rational agent should also be autonomous, meaning that it should learn \nwhat it can to compensate for not enough information\n\n## AIMA 2.3 The Nature of Environments\n First step when we design an agent is to specify task environment which is composed of PEAS (Performance, Environment, Actuators, Sensors). Actuators are \ncomponents of machine where sensors detect change in environment. Fully vs partially observable. We say an environment is multi-agent if \nit maximizes performance measure that is depdent on B's behavior. Competitive multiagent is when increasing performance of one decreases others\nwhile cooperative, like taxi example, where increasing ones performance helps everyone. Episodic vs. sequential where sequential is opposite where there \nare no episodes. Discrete vs continuos applies to state, time, percepts, and actions. In known environment, we know outcomes of actions in environment, where\nunknown means agent has to learn how environment works to make reasonable decisions. Known environment does not mean fully observable and vice versa\n\n## AIMA 2.4 The Structure of Agents\n AGENT = ARCHITECTURE + PROGRAM. Agents programs take in an agent percept and return an agent actuator. Agent program only takes current percept\nwhereas agent function can take in percept sequence. We cannot create a table of all possible combinations since that would be infite, instead we try to get \nrational behavior from small program that acts like table. Simple Reflex Agent will only take into consideration the current percept and will ignore the percept history.\nSimple Reflex Agents only work when environment is fully observable. Infinite loops are sometimes inevitable and the solution is to randomize next action. Model based reflex agents\nhave internal state that maps percept history so that you can observe some unobserved aspects of environment. Agent that uses transition and sensor models is\na model based agent. Goal based agents need goal information so that correct decision also depends on what goal we are trying to get to. Utility based agents try to maximize expected utlity \nbased on a utility function. These agents have hardwired performance standards that either see percept as reward or penalty. Localist Representation is \nwhen one to one mapping between concepts and memory locations whereas distributed representation is opposite.\n\n\n## Module 1 Lecture Notes\n Hardest case is Continuous Partially Observable Stochastic Multiagent. Reflex agent only takes current percept whereas \nproblem solving agent plans ahead. \n\n## Module 1 Definitions\n* **Agent** - anything that can perceive and act in an environment\n* **Rational agent** - acts to achieve best outcome\n* **Percept** - what sensors of agent are seeing\n* **Percept sequence** - everything agent has perceived so far till now\n* **Agent function** - maps percepts to sequence of an action\n* **Turing test** - passes test if human after posing question cannot tell if response from machine or human\n* **Knowledge representation** - the machine will keep what it already knows\n* **Total turing test** - machine needs to interact with things and people in real world\n* **Cognitive science** - combo of comp sci and psych for human mind study\n* **Syllogism** - patterns for structure of arguments that give you right solution every time, creating field of logic\n* **Limited rationality** - acting in good way when no time to have calcs for best decisions\n* **Value alignment problem** - values in machine supposed to be similar to those of a human\n* **Strong ai** - machines are actually consiously thinking -> human level thinking\n* **Weak ai** - machines simulate thinking\n* **Good old fashioned ai** - logical agent design\n* **Qualification problem** - hard to specify all rules for program to run intelligently\n* **Embodied cognition approach** - brain and body as one, and in this approach robotics and vision are needed\n* **Biological naturalism** - cells have something that transistors do not and so only humans can think and machines cant\n* **Consequentialism** - we say whether agent is doing right thing based on its consequences\n* **Performance measure** - evaluates sequence of enviornment states to say if machine did well\n* **Omniscience** - agent knows ACTUAL outcome of task and acts accordingly; impossible in real life\n* **Priori** - when environment is completely known\n* **Task environment** - problem to be solved by rational agent\n* **Fully observable** - if sensors give agent all information about environment in time period\n* **Unobservable** - agent has no sensors\n* **Deterministic** - environment is only determinded by action and curr state\n* **Stochastic** - undeterministic but has probabilities, where undeterministic does not have probabilities\n* **Episodic** - divided into episodes where agent sees percept and performs one action in each, next epi doesnt depend on first\n* **Dynamic environent** - environment can change in agent decision making process\n* **Semi-dynamic** - performance score changes with time but environment doesnt in decision making\n* **Agent architecture** - Computing device with physical sensors where program is run\n* **Condition action rule** - basically an if statement for condition then do action\n* **Transition model** - model for how world works used to make next decision in model based reflex agent\n* **Sensor model** - what happens to sensors when action is taken\n* **Utility** - quality of being useful\n* **Learning element** - sees how performance element should be modified based on how its doing from critic feedback\n* **Performance element** - the entire agent\n* **Problem generator** - last part of learning agent that suggests exploring options that could be worse now but better later\n* **Atomic representation** - Each state of world is one unit and you cannot divide\n* **Factored representation** - Splits states into smaller chunks which can inlcude variables\n* **Structured representation** - the one used in which objects described as objects\n\n\n# Module 2: Python\n## Module 2 Lecture Notes\n Positives of python are that it is fast, portable, lots of libraries. Every object has a fixed type so you cannot \ndo things incomptaible with type. So int + string not allowed you have to do str(int) + str. Also, strings are immutable in python where lists are mutable.\nTuples are immutable. negatibe index at end in sliving indicates one before last, [:6] says copy from begining and [2:] is copy to end. You can use\ninsert for list to insert element at specific index. join method joins that elements in list with specified element at beginning. .items for dictionary gives \nyou list of tuples. You can have mutiple return values in python and the return type would be a tuple. You CANNOT have functions with same name in java even if \nyou have different inputs. you can overload operators however. Arguments in python can be specified out of order and you can put default values for functions.\nYou can use *args to provide variable number of non-keyword arguments. **kwargs for variable keyword arguments. Python uses the most current value of variable. You can pass\nfunctions into other functions. To define subclass put name of superclass in parantheses. You can call method on any class that implements a method and do not \nneed to specificy interface like in Java. Yield returns value then goes back to where function left off and continues.\n\n## Module 2 Definitions\n* **Mutability** - your definition here\n\n\n# Module 3: Search Problems\n## AIMA Chapter 3.1 Problem-Solving Agents\n Your summary here \n\n## AIMA Chapter 3.2 Example Problems\n Your summary here \n\n## AIMA Chapter 3.3 Search Algorithms\n Your summary here \n\n## AIMA Chapter 3.4 Uninformed Search Strategies\n Your summary here \n\n## Module 3 Lecture Notes\n For a search problem we need: a goal, states, actions, and a performance measure. The definition of a search problem:\n1. states, 2. initial state, 3. transition model, 4. path cost, 5. goal test. A solution is optimal if no other solution has a lower path cost. Tree Search is \nwhen you enumerate in some order all possible paths from initial state.root is intial state and nodes in search tree are generated through transition model. Tree search \nhas property where diff paths to same state are diff. A node is part of search tree that stores parent, child, board, etc. The state is just the phsycial representation \"board\" \nof the curr node. The issue with tree search is we can have repeated sgtates so runtime becomes very large. Graph Search is same as tree search but it checks if node \nhas been visited before going down path. Uninformed search is where all non-goal nodes are equal in terms of how good they are, where informed search algorithms have each node where \nthey each have different weights based on how far they are from goal node. b is max branching factor of tree, d is the depth of the tree. m is the max length of \nany path in state space. For BFS we first expand the most shallow unexpanded node, and you use FIFO queue for BFS. Time complexity of BFS is O(b^d) and DFS is O(b^d). DFS uses a LIFO queue, and expands\nthe deepest unexpanded node. DFS has O(b^m) time complexity and O(bm) space complexity. For BFS vs. DFS, BFS could have probable infinite paths and for DFS space can become restricted quickly. BFS is complete, optimal, but con is \nthat it uses O(b^d) space. DFS is not complete (may be complete if m is bounded), not optimal, and uses O(b^m) time, however, a pro is that it uses O(bm) space. To get the \nbest of both we can do depth limited search. For depth limited search we do DFS but restrict depth and this makes it so no infinite path problem. If level = depth\nthen it is optimal, but if l < d -> incomplete and if l > d -> not optimal. The time complexity is O(b^l) and space complexity is O(bl). We can do Iterative Deepening Search, which is Depth Limited search \nbut we start from l = 0 to infinity. The time complexity would be O(b^d) and space complexity is O(bd), and it is complete and optimal.\n\n\n## Module 3 Definitions\n* **Problem-solving agent** - an agent that can formulate a plan via search\n* **Completeness** - algo will always find solution \n* **Optimality** - algo will find solution with least cost\n\n\n# Module 4: Informed Search\n## AIMA Chapter 3.5 Informed (Heuristic) Search Strategies\n Your summary here \n\n## AIMA Chapter 3.6 Heuristic Functions\n Your summary here \n\n## Module 4 Lecture Notes\nUniform Cost Search (Djikstra's) is tree search that is used to traverse a weighted tree. For Uniform cost search you \nexpand node with the lowest path cost, and it tests whether node is goal when popped from queue. A heuristic function is an estimate for cost from curr\nto goal. Greedy Best First Search expands nodes with minimal huerisitc value without adding the cost of the node we are on. Greedy best first search is not optimal or complete\nA* search is where you expand nodes with least f(n) = g(n) + h(n). A heuristic is admissable if it never overestimates the cost to the goal. If the heuristic \nis admissable then A* is optimal and complete. The cost of optimal solution to relaxed problem is an admissable heuristic to main problem. If two heuristics and \nh2(n) > h1(n) then h2(n) dominates h1(n), and so h2(n) is more accurate and we use that. A heurisitc is admissable if 0 <= h(n) <= h*(n) where h*(n) is the true \ndistance\n\n## Module 4 Definitions\n* **Concept** - definition\n\n\n# Module 5: Adversarial Search and Games\n## AIMA Chapter 5.1 Game Theory\n Your summary here \n\n## AIMA Chapter 5.2 Optimal Decisions in Games\n Your summary here \n\n## AIMA Chapter 5.3 Heuristic Alpha–Beta Tree Search\n Your summary here \n\n## AIMA Chapter 5.5 Stochastic Games\n Your summary here \n\n## AIMA Chapter 16.1 Combining Beliefs and Desires under Uncertainty\n Your summary here \n\n## AIMA Chapter 16.2 The Basis of Utility Theory\n Your summary here \n\n## AIMA Chapter 16.3 Utility Functions\n Your summary here \n\n## Module 5 Lecture Notes\n The simplest game environment is multi-agent, static, discrete, fully observable, strategic. We have two players MIN and MAX.\nFor games as search, the game should have initial state, successor function, terminal test, utility function, MAX. All play from MAXs vantage point. \nWhen MAX plays he maximizes MAX outcome, and when MIN moves she has to minimze MAX outcome. We can have one function f(n) that determines whose winning. \nIf f(n) > 0 then MAX is winning, if f(n) < 0 then MIN is winning, and if f(n) = 0, then the game is tied. During MINIMAX, WE have to start at leaves and back out values till \nwe get to the top, and we do this by choosing largest value of MAX children and min value of MIN children. Optimal play means that we maximize the worst \ncase outcome for MAX. In alpha-beta pruning we keep track of alpha and beta (defined below). MAX will now allow move that leads to worse than alpha and MIN will never allow \nmove that leads to better score for MAX than beta. Therefore, when evaluating a MAX node: if find value v >= beta then we stop search and prune other leaves, wherease when evaluating \na MIN node, if find a value of v <= alpha then stop and prune. In Expectimax Search, values are going to be average case and not worst case like minimax, and chance nodes \nare like min nodes but we calculate expected utlity since outcome is not certain\n\n## Module 5 Definitions\n* **Even levels** - MAX Turn\n* **Odd levels** - MIN Turn\n* **Minimax rule** - Make best move for MAX assuming MIN always responds with best move for MIN\n* **Alpha** - MAX's lower bound on MAX's outcome\n* **Beta** - upper bound on MIN's outcome\n\n\n# Module 6: Constraint Satisfaction Problems\n## AIMA Chapter 6.1 Defining Constraint Satisfaction Problems\n Your summary here \n\n## AIMA Chapter 6.2 Constraint Propagation: Inference in CSPs\n Your summary here \n\n## AIMA Chapter 6.3 Backtracking Search for CSPs\n Your summary here \n\n## AIMA Chapter 6.4 Local Search for CSPs\n Your summary here \n\n## AIMA Chapter 6.5 The Structure of Problems\n Your summary here \n\n## Module 6 Lecture Notes\n A CSP has set of variables, domain of possible values for every variable, set of constraints. For a CSP it is complete if \nevery variable has a value, and a solution to CSP has to be complete. We only need to say what spec of CSP is to solve using general algorithm. CSP can \nbe represented as search problem where final sol is found in depth n -> use DFS. When we are doing CSP, choose most constrained variable first, meaning \nit has lowest number of legal moves possible. If tied with another then choose most constraining variable -> which adds most constraints on others. This would be \nheuristic in our search. We can do forward checking but issue is that it doesnt detect early values for all failures. FORWARD CHECKING CHECKS ONE IN ADVANCE. Therefore, we put constraint propogation \nor inference step. In this step we remove all states that would go against local consistency. For this we will add back edge and forward edge (look like arcs). Arc Consistency\nis when, a and b are arc consis if for every value in tail a there is a value in head b such that we can pick tail a. If we remove values from domain in arc consis, then \nwe recheck the neighbors to maintain arc consistency. Checking arcs take O(d^2) time. AC3 algo steps are 1. all nodes start with all possible values. \n2. for every node i check its neighbors j and remove any values that are not arc consistent. 3. Add the neighbors of the nodes which had values that changed back to queue. 4. Repeat process and stop when values do not change\nComplexity is O(n^2d^3)\n\n## Module 6 Definitions\n* **Unary** - constraint with one variable\n* **Binary** - constraint with pairs for variables\n* **Higher order** - 3 or more variables\n* **Backtracking** - DFS with single variable assignments\n* **Forward checking** - end search when any unassinged variable has 0 moves, by keeping track of all possible values\n* **Local consistency** - Node consistency where it satisfies unary constraints or arc consistency\n\n\n# Module 7: Logical Agents\n## AIMA Chapter 7.1 Knowledge-Based Agents\n Your summary here \n\n## AIMA Chapter 7.2 The Wumpus World\n Your summary here \n\n## AIMA Chapter 7.3 Logic\n Your summary here \n\n## AIMA Chapter 7.4 Propositional Logic: A Very Simple Logic\n Your summary here \n\n## AIMA 7.5 Propositional Theorem Proving\n Your summary here \n\n## Module 7 Lecture Notes\n The knowledge base will at the start contain background info about the world. Our knowledge based agent will get points \nfor doing right thing and lose for doing wrong thing. Logic will help us represent what is happening to knowledge based agent. To write A entails B in \nmath notation we do a |= b. Knowledge Base is false when current model contradicts what agent knows about world already. <=> is if and only if. We can use \nentailment to derive conclusions while going through world, and inference algorithms will enumerate sentences as true or false. three lines over each other \nmeans logically equivalent. Rules: a -> b is same as not(a) U b, a <-> is same as ((a -> b) intersection (b -> a)), ((a intersect b) U C) is same as \n((a intersect b) U (a intersect c)), ((a U b) intersect C) is same as \n((a U b) intersect (a U c)), a -> b is same as not(b) -> not(a). For inference rules, whenever we have a -> b and a is given then b can be inferred.\nCNF is a bunch of ors anded together. For resolution algorithm, to show kb |= a we can show kb intersect not(a) is unsatisfiable.\n\n## Module 7 Definitions\n* **Knowledge based agents** - reason over knowledge given of state to see what action to take\n* **Knowledge base** - sentence in knowledge rep languange that tells us something about state \n* **Axiom** - given sentence\n* **Derived sentences** - derive new sentences from old using inference\n* **Model** - our world\n* **Logical inference** - Deriving Conclusions\n* **Propositional symbol** - Either true or false depending on sentence it represents is true or false\n* **Sound** - inference algo is sound if it only derives entailed sentences\n* **Complete** - all sentences that can be entailed can be derived\n* **Cnf** - bunch of ors anded together \n",
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {}
        }
      ]
    }
  ]
}