{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "Copy of FINAL Template_for CIS521_midterm notes.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": "58b00386-d2c9-4919-9c75-4a045466ab29"
      },
      "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": null,
      "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": "ef81cd11-e574-43c8-fb57-4c2e2e3d803c"
      },
      "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": null,
      "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 = \"David Zhang\"\n",
        "permission = True\n",
        "anonymous = False"
      ],
      "execution_count": null,
      "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 = \"\"\"\n",
        "A computer passes the Turing test if a human interrogator cannot determine if the written responses come from a human/computer.\\\n",
        "A computer that could do this would have natural language processing, knowledge representation, automated reasoning and machine learning.\\\n",
        "Total turing test requires interactions with objects/people so a computer would need computer vision and robotics.\\\n",
        "Human thought can be studied by introspection, psychological experiments and brain imaging. \\\n",
        "Agent is something that acts and rational agent acts to achieve the optimal outcome.\\\n",
        "Limited rationality is acting appropriately when time is a constraint.\"\"\" \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 = \"\"\"\n",
        "Weak AI act as if intelligent, while strong AI consiously think.\\\n",
        "Embodied cognition is the idea that cognition happens within the entire body, not just the brain.13\n",
        "\"\"\"\n",
        "chapter27_2 = \"\"\"\n",
        "According to biological naturalism, high level mental states are caused by low level physical processes in neurons.\\\n",
        "Consiousness is awareness of outter and inner world and experience of living, aka qualia.\n",
        "\"\"\"\n",
        "\n",
        "# Russell and Norvig, AIMA 4th Edition, Chapter 2 “Intelligent Agents” (whole chapter)\n",
        "chapter2_1 = \"\"\"\n",
        "Agent is something that perceives its environment via sensors and acts on that info with actuators.\\\n",
        "Percept is something agent is perceiving.\\\n",
        "Agent function abstractly maps percept sequence to action. \\\n",
        "Agent program is implementation of agent function. \\\n",
        "\"\"\"\n",
        "chapter2_2 = \"\"\" \n",
        "Consequentalism is the idea that agent's behavior is evaluated by its consequences. \\\n",
        "Permance measure evaluates sequence of environment states agent goes through as a result of the actions it takes according to its percepts. \\\n",
        "Rational Agent selects an actions that maximized its expected performance measure for any given percept sequence. \\\n",
        "Geograph of environment is priori.\\\n",
        "Omniscient agents knows actual outcome of actions, but is impossible.\\\n",
        "Information gathering is an agent acting to modify percepts in the future. \\\n",
        "\"\"\"\n",
        "chapter2_3 = \"\"\"\n",
        "Task environment includes PEAS(performance measure, environment, actuators, sensors). \\\n",
        "In a fully observable task environment, agent has complete information of environment. \\\n",
        "In a deterministic environment, next state is guaranteed by current state and specific action. \\\n",
        "In a episodic environment, agent's experience is through distinct episodes. So next episode is independent of current episode. Sequential is opposite. \\\n",
        "In a dynamic environment, the environment can change. \\\n",
        "In a discrete enviornment, finite number of states, percepts and actions (Ex. Chess). Driving is in a continuous environment \\\n",
        "In a known environment, agent knows result of actiosn or probabilities of each result. \\\n",
        "\"\"\"\n",
        "chapter2_4 = \"\"\"\n",
        "Agent architecture is the computer that agent program is run, includes sensors/actuators.\\\n",
        "Simple reflex agent selects action based only on current percept.\\\n",
        "Model based reflex agent maintains an internal state that depends on percept history, using sensor model/transition model.\\\n",
        "Goal based agent keeps track of current state and goals it is trying to reach. \\\n",
        "Utility based agent uses a utility function to measure states, acting accordingly.  \\\n",
        "Learning agent has learnign element, responsible for making improvements and performance element, responsible for choosing actions. \\\n",
        "Learning elem takes feedback from critic to modify performance element. Problem generator suggests actions for new/informative\n",
        "experiences for agent.\\\n",
        "Atomic representation - each state is indivisible\\\n",
        "Factored representation - each state has attributes \\\n",
        "Structure representation - each state has objects, which may have attributes and relationships with other objects\n",
        "localist representation - 1-to-1 mapping between concepts and memory addresses. \\\n",
        "distributed representation - concepts spread over many memory addresses\\\n",
        "\"\"\"\n",
        "\n",
        "# Lecture notes \n",
        "module1_lecture_notes = \"\"\" Your summary here \"\"\"\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",
        "\"percept\" : \"your definitions here\",\n",
        "\"other concept\" : \"your definitions here\",\n",
        "\"etc.\": \"your definitions here\",\n",
        "}\n",
        "\n"
      ],
      "execution_count": null,
      "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": 238
        },
        "outputId": "de62c087-ef1d-4e95-fb31-dde8f80a0e7a"
      },
      "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": 1,
      "outputs": [
        {
          "output_type": "error",
          "ename": "NameError",
          "evalue": "ignored",
          "traceback": [
            "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
            "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
            "\u001b[0;32m<ipython-input-1-c7f8edcc347d>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      5\u001b[0m module1_sections = [\n\u001b[0;32m----> 6\u001b[0;31m   \u001b[0;34m(\u001b[0m\u001b[0;34m\"AIMA Chapter 1.1 What is AI?\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mchapter1_1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      7\u001b[0m   \u001b[0;34m(\u001b[0m\u001b[0;34m\"AIMA Chapter 27.1 The Limits of AI\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mchapter27_1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      8\u001b[0m   \u001b[0;34m(\u001b[0m\u001b[0;34m\"AIMA Chapter 27.1 Can Machines Really Think?\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mchapter27_2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
            "\u001b[0;31mNameError\u001b[0m: name 'chapter1_1' is not defined"
          ]
        }
      ]
    },
    {
      "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 = \"\"\"\n",
        "Java uses static typing but python uses dynamic typing. == checks if same value, is check if same object.\\\n",
        "Strings/tuples are immutable. Lists are mutable.\n",
        "List methods: append, insert, count, index, remove, reverse, sort\n",
        "Duck typing checks if an object is suitable based on if it has a certain method\n",
        "\"\"\"\n",
        "\n",
        "# Each definition should be at most 20 words long.\n",
        "module2_definitions = {\n",
        "\"mutability\" : \"your definition here\",\n",
        "}"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "ydOK__lwWgdp",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 238
        },
        "outputId": "079b87d9-c289-4074-a5dc-051ca1459410"
      },
      "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": 2,
      "outputs": [
        {
          "output_type": "error",
          "ename": "NameError",
          "evalue": "ignored",
          "traceback": [
            "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
            "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
            "\u001b[0;32m<ipython-input-2-39c5aa0ae6ff>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      3\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      4\u001b[0m module2_sections = [\n\u001b[0;32m----> 5\u001b[0;31m   \u001b[0;34m(\u001b[0m\u001b[0;34m\"Module 2 Lecture Notes\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmodule2_lecture_notes\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      6\u001b[0m ]\n\u001b[1;32m      7\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
            "\u001b[0;31mNameError\u001b[0m: name 'module2_lecture_notes' is not defined"
          ]
        }
      ]
    },
    {
      "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 = \"\"\"\n",
        "problem solving agent needs to plan ahead and figure out a path to goal. They use atomic representations.\\\n",
        "Planning agents use factored/structured representations.\\\n",
        "Informed algo can estimate distance to goal. \\\n",
        "In a fully observable, deterministic, known environment, solution is fixed sequence of actions.\\\n",
        "In an open-loop system, agent can find solution, close its eyes and follow steps to goal. \\\n",
        "A search problem is defined by state space, initial state, goal states, actions, transition model and action cost function.\\\n",
        "\"\"\"\n",
        "chapter3_2 = \"\"\"\n",
        "Traveling salesman problem(TSP) requires every city on a map to be visited.\\\n",
        "\"\"\"\n",
        "chapter3_3 = \"\"\"\n",
        "In best-first search, the node with the minimum f(n) is chosen on the frontier. Goal is only checked when node is expanded. \\\n",
        "Priority queue used in best-first, FIFO queue used in BFS, LIFO queue used in DFS. \\\n",
        "Graph search checks for redundant paths but tree search does not.\\\n",
        "Algo is complete if guaranteed to find solution or report failute if there isnt one.\\\n",
        "Cost optimal if finds solution with lowest path cost. \\\n",
        "\"\"\"\n",
        "chapter3_4 = \"\"\"\n",
        "BFS has space and time complexity of O(b^d).\\\n",
        "Dijkstras/uniform-cost search is best-first search with path cost g(n) as evaluation function.\\\n",
        "It has time/space complexity of O(b^{1+floor(C*/e)}) where C* is cost of optimal solution and e is lower bound on cost of each action.\\\n",
        "It is complete and cost-optimal.\\\n",
        "DFS is not cost-optimal and not complete for infinite spaces.\\\n",
        "DFS has time complexity O(|V|) and space complexity of O(bm) where m is max depth.\\\n",
        "Backtracking search uses O(m) space and only one new node is generated at a time.\\\n",
        "Depth limited search uses O(b^l) time and O(bl) space.\\\n",
        "Iterative deepening search uses O(bd) space and O(b^d) time when there is a solution and O(bm) and O(b^m) when there isn't.\\\n",
        "It is also complete and optimal.\\\n",
        "Bidirectional search takes O(b^{d/2}) time and space and is complete and optimal.\\\n",
        "\"\"\"\n",
        "\n",
        "\n",
        "# Lecture notes \n",
        "module3_lecture_notes = \"\"\" Your summary here \"\"\"\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",
        "}\n",
        "\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "lvtN3p7ET3Tx",
        "cellView": "form",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 238
        },
        "outputId": "71c63427-c88b-4080-ac7f-fb536df543f9"
      },
      "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": 4,
      "outputs": [
        {
          "output_type": "error",
          "ename": "NameError",
          "evalue": "ignored",
          "traceback": [
            "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
            "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
            "\u001b[0;32m<ipython-input-4-0a3759060351>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      2\u001b[0m \u001b[0;31m#@markdown You don't need to modify anything in this cell. Just press play.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      3\u001b[0m module3_sections = [\n\u001b[0;32m----> 4\u001b[0;31m   \u001b[0;34m(\u001b[0m\u001b[0;34m\"AIMA Chapter 3.1 Problem-Solving Agents\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mchapter3_1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      5\u001b[0m   \u001b[0;34m(\u001b[0m\u001b[0;34m\"AIMA Chapter 3.2 Example Problems\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mchapter3_2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      6\u001b[0m   \u001b[0;34m(\u001b[0m\u001b[0;34m\"AIMA Chapter 3.3 Search Algorithms\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mchapter3_3\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
            "\u001b[0;31mNameError\u001b[0m: name 'chapter3_1' is not defined"
          ]
        }
      ]
    },
    {
      "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 = \"\"\"\n",
        "Heuristic function h(n) is estimated lowest cost from node n to goal state.\\\n",
        "Greedy best-first search expands node with minimum h(n). It is complete\n",
        "if space is finite and space/time complexity of O(|V|).\\\n",
        "A* search uses f(n) = g(n) + h(n) where g(n) is cost from initial state to n.\n",
        "An admissible/optimistic heuristic NEVER overstimates cost to reach goal. With\n",
        "an admissible heurisitc, A* is cost-optimal.\\\n",
        "A heurisitc is consistent if for all n and successor n', h(n) <= c(n, a, n') + h(n')\\\n",
        "Every consistent heuristic is admissible, but not every admissible heuristic is consistent.\\\n",
        "Costs are monotonic if they increase along a path (Ex. g cost).\\\n",
        "Bidirectional A* sometimes more efficient than A*.\\\n",
        "IDA* saves memory.\\\n",
        "In weighted A*, f(n) = g(n) + W * h(n).\\\n",
        "To save memory beam search limits size of frontier, keeping nodes with best f scores.\\\n",
        "Simplified Mmory bounded A*(SMA) drops node with highest f value when memory capacity \\\n",
        "is reached. It is complete if depth of shallowest goal node is less than\n",
        "size of memeory. It is optimal if optimal solution is reachable.\\\n",
        "Bidirectional heuristic search is not cost optimal. \n",
        "\"\"\"\n",
        "chapter3_6 = \"\"\"\n",
        "If h2(n) >= h1(n) for any node n, h2 dominates h1 and is more efficient. An effective\\\n",
        "branching factor closer to 1 is better.\n",
        "\"\"\"\n",
        "\n",
        "\n",
        "# Lecture notes \n",
        "module4_lecture_notes = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "# Definitions\n",
        "module4_definitions = {\n",
        "\"concept\" : \"definition\",    \n",
        "}\n",
        "\n"
      ],
      "execution_count": 5,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "cDfXVzDGRcjs"
      },
      "source": [
        ""
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "vqtEs0gHs9sO",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "cellView": "form",
        "outputId": "6a33bad1-c16f-44e7-b70a-5755faa0ad38"
      },
      "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": null,
      "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\n Your summary here \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 = \"\"\"\n",
        "Perfect information = zero-sum.\\\n",
        "zero-sum - a positive for one player is just as much a negative for other.\\\n",
        "\"\"\"\n",
        "chapter5_2 = \"\"\"\n",
        "minimax value of a state is utility of being in that state for max.\\\n",
        "Time complexity is O(b^m) and space complexity is O(bm) if algo generates all\\\n",
        "actions at once or O(m) if 1 action at a time.\\\n",
        "alpha - highest-value choice along path to root for MAX\\\n",
        "beta - lowest-value choice along path to root for MIN.\\\n",
        "\"\"\"\n",
        "chapter5_3 = \"\"\"\n",
        "forward pruning prunes what appear to be bad moves.\\\n",
        "beam search only looks at the x best moves, but not guaranteed to not prune away\\\n",
        "best move.\\\n",
        "late move reduction reduces the search depth of moves that appear to be worse.\\\n",
        "\"\"\"\n",
        "chapter5_5 = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "# Russell and Norvig, AIMA Chapter 16 “Making Simple Decisions” (16.1-16.3)\n",
        "chapter16_1 = \"\"\" \n",
        "The Maximum Expected Utility principle states a rational agent should pick the action\\\n",
        "that maximizes it's expected utility.\\\n",
        "\"\"\"\n",
        "chapter16_2 = \"\"\"\n",
        "Reasonable preference relation must obey orderability, transitivity, continuity,\\\n",
        "substitutability, monotonicity and decomposability.\\\n",
        "Orderability - Either A > B, B > A or A = B.\\\n",
        "Transitivity - A > B ^ B > C -> A > C\\\n",
        "Continuity - A > B > C -> Exists p [p, A; 1 - p; C] = B\\\n",
        "Substitutability - A = B -> [p, A; 1 - p, C] = [p, B; 1 - p, C]\\\n",
        "Monotonicity - A > B -> (p > q - >  [p, A; 1 - p, B] > [q, A; 1 - q, B])\\\n",
        "Decomposability - [p, A; 1 - p, [q, B; 1 - q, C]] = [p, A; (1-p)q, B; (1-p)(1-q), C]\\\n",
        "\"\"\"\n",
        "chapter16_3 = \"\"\"\n",
        "preference elicitation is the process of asking a human for preferences to determine\\\n",
        "the utility function.\\\n",
        "micromort - 1 in a million chance of death\\\n",
        "risk averse agents prefer sure payoff less than expected value from gamble.\\\n",
        "Oppoisite is risk seeking.\\\n",
        "Certainty effect - people are attracted to certain gains.\\\n",
        "Ambiguity aversion suggest people are attracted to known probabilities.\\\n",
        "framign effect - wording of decision problem has effect\\\n",
        "anchoring effect - people are more inclinded to make relative utility judgements.\\\n",
        "\"\"\"\n",
        "\n",
        "# Lecture notes \n",
        "module5_lecture_notes = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "# Definitions\n",
        "module5_definitions = {\n",
        "\"concept\" : \"definition\",    \n",
        "}\n",
        "\n"
      ],
      "execution_count": 1,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "EBzePPZsJD8k"
      },
      "source": [
        ""
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "KUc_LgzDvWf-",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "39ec8635-89e2-4f2f-99f8-00aecd47f6ca"
      },
      "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": null,
      "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 Your summary here \n\n## Module 5 Definitions\n* **Concept** - definition\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 = \"\"\"\n",
        "CSP = constraint satisfaction problem\\\n",
        "A solution to CSP is consistent(doesnt violate any constraints) and complete\\\n",
        "(each variable is assigned a value).\\\n",
        "Constrained optimization problem(COP) is CSP with preferences.\\\n",
        "\"\"\"\n",
        "chapter6_2 = \"\"\"\n",
        "constraint propogation - using constraints to reduce consistent values for a var,\\\n",
        "which reduces consistent values for other vars, etc.\\\n",
        "A var is node-consistent if all vals in its domain satisfy unary constraints for that var.\\\n",
        "X_i is arc-consistent with X_j if for every value in X_i's domain there exists a value\\\n",
        "in X_j's domain that satisfies binary constraint on (X_i, X_j)\\\n",
        "AC-3 enforces arc consistency.\\\n",
        "Begins with queue of all arcs, pops off an arc and makes it arc consistent. If domain\\\n",
        "becomes smaller, add all neighbors of X_i.\\\n",
        "AC-3 with domain size <= d and c binary constraints has runtime O(cd^3)\\\n",
        "X_i, X_j are path-consistent with X_m if for every consistent assignment for X_i\\\n",
        "and X_j, there exists an assignment for X_m that satisfies (X_i, X_m) and (X_m, X_j)\\\n",
        "k-consistent if for any k-1 vars, for any consistent assignment to them, there exists\\\n",
        "a consistent value for the kth var.\\\n",
        "strongly k-consistent if k-consistent, k-1-consistent,..., 1-consistent.\\\n",
        "\"\"\"\n",
        "chapter6_3 = \"\"\"\n",
        "Backtracking search for CSP is used when still vars with multiple values in domain.\\\n",
        "by Minimum-returning-values(MRV) heuristic choose var with fewest vals in domain first.\\\n",
        "degree heuristic chooses var with most arcs.\\\n",
        "least-constraining-value heuristic picks value that rules out fewest choices for \\\n",
        "neighbors. \\\n",
        "forward checking is a form of inference where whenever a variable is assigned,\\\n",
        "it establishes arc consistency for it.\\\n",
        "Maintaining arc consistency(MAC): when X_i is assigned, AC-3 is called with all\\\n",
        "arcs (X_j, X_i). Mac recursively propogates constraints.\\\n",
        "\"\"\"\n",
        "chapter6_4 = \"\"\" \n",
        "min conflicts heuristic selects value with min conflicts with other vars.\\\n",
        "constraint weighing focuses on important constraints, chooses a var/val pair\\\n",
        "to change that will cause lowest total weight of all violated constraints.\\\n",
        "\"\"\"\n",
        "chapter6_5 = \"\"\"\n",
        "directional arc consistency(DAC) iff every X_i is arc consistent with X_j for j > i.\\\n",
        "for tree structure csp, solution takes linear time to find\\\n",
        "cutset conditioning involves assigning vals to some vars(cycle cutset) such that\\\n",
        "remaining vars make a tree. runtime becomes O(d^c - (n-c)d^2)\\\n",
        "tree decomposition transforms graph into tree. satisfies:\\\n",
        "every var in orginal appears in at least 1 tree node, if 2 vars connected in og,\\\n",
        "then must appear together in a at least 1 tree node, if var is in 2 nodes in tree,\\\n",
        "must be in every node along path connecting the 2 nodes\\\n",
        "When choosing decomp, minimize tree width w(1 less than size of largest node)\\\n",
        "Tree decomp takes O(nd^{w+1}).\\\n",
        "tree decomp better time wise but worse memeory wise.\\\n",
        "\"\"\"\n",
        "\n",
        "\n",
        "# Lecture notes \n",
        "module6_lecture_notes = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "# Definitions\n",
        "module6_definitions = {\n",
        "\"concept\" : \"definition\",    \n",
        "}\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "kKWbCsbfxL3R",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "5f3d2500-dfb2-42e4-9373-fb3bec356333"
      },
      "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": null,
      "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 Your summary here \n\n## Module 6 Definitions\n* **Concept** - definition\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 = \"\"\"\n",
        "knowledge base (KB) is a set of sentences, each of which is expressed in knowledge\\\n",
        "representation language. If a sentence is taken without being derived from others,\\\n",
        "it is an axiom.\\\n",
        "declarative approaches tells sentences 1 by 1, while procedural approach encodes\\\n",
        "behavior.\\\n",
        "\"\"\"\n",
        "chapter7_2 = \"\"\" Your summary here \"\"\"\n",
        "chapter7_3 = \"\"\"\n",
        "If a sentence a is true in model m, m satifies a.\\\n",
        "M(a) is set of all models of a.\\\n",
        "a entails b iff M(a) \\subseteq M(b). a is stronger assertion here.\\\n",
        "inference algo is compelte if can derive any sentence entailed.\\\n",
        " \"\"\"\n",
        "chapter7_4 = \"\"\" Your summary here \"\"\"\n",
        "chapter7_5 = \"\"\"\n",
        "sentence is valid if true in all models. aka tautology.\\\n",
        "sentence is satisifiable is true in some model.\\\n",
        "a -> b = -a or b\\\n",
        "(a and (b or c)) = ((a and b) or (a and c)) distribute and over or\\\n",
        "(a or (b and c)) = ((a or b) and (a or c)) distribute or over and\\\n",
        "a is valid -ff -a is unsatisfiable\\\n",
        "monotonicity states set of entailed sentences only increases with new info.\\\n",
        "Conjunctive normative form(CNF) is a sentence of conjunctions of clauses.\\\n",
        "clause - disjunction of literals\\\n",
        "definite clause - disjunction of literals where 1 is positive\\\n",
        "horn clause - disjunction of literals where at most 1 is positive\\\n",
        "goal clause - disjunction of literals with 0 positives.\\\n",
        "k-CNF sentence - each clause has at most k literals\\\n",
        "forward chaining algo begins from known facts, adds conclusions to set of facts,\\\n",
        "until no inferences can be made or the query q is is added.\\\n",
        "\"\"\"\n",
        "\n",
        "# Lecture notes \n",
        "module7_lecture_notes = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "# Definitions\n",
        "module7_definitions = {\n",
        "\"concept\" : \"definition\",    \n",
        "}\n",
        "\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "lXNcHuKjyNXa",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "2fc31cf5-b9c0-41b0-9a0e-5f7744a61e68"
      },
      "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": null,
      "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 Your summary here \n\n## Module 7 Definitions\n* **Concept** - definition\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": 238
        },
        "id": "T3cm1WV542_a",
        "outputId": "e90f66a9-e8f2-4c00-c040-aef0b4c25e2d"
      },
      "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": 2,
      "outputs": [
        {
          "output_type": "error",
          "ename": "NameError",
          "evalue": "ignored",
          "traceback": [
            "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
            "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
            "\u001b[0;32m<ipython-input-2-197fd754e469>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[0;31m# This will generate the full set of notes that you can use for your exam.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m full_markdown = \"\\n\\n\".join([module1_markdown, \n\u001b[0m\u001b[1;32m      3\u001b[0m                              \u001b[0mmodule2_markdown\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      4\u001b[0m                              \u001b[0mmodule3_markdown\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      5\u001b[0m                              \u001b[0mmodule4_markdown\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
            "\u001b[0;31mNameError\u001b[0m: name 'module1_markdown' is not defined"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "8xsflKDoYUYP"
      },
      "source": [
        ""
      ]
    }
  ]
}