{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "“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": "f77edd39-572f-4b92-8a9b-2150fa108ffe"
      },
      "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": "dc17f999-4491-40a0-99e6-48774810b261"
      },
      "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 = \"\"\n",
        "permission = True\n",
        "anonymous = True"
      ],
      "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 = \"\"\" science let machine think/act like human rationally.\"\"\" \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 = \"\"\" Your summary here \"\"\"\n",
        "chapter27_2 = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "# Russell and Norvig, AIMA 4th Edition, Chapter 2 “Intelligent Agents” (whole chapter)\n",
        "chapter2_1 = \"\"\" Your summary here \"\"\"\n",
        "chapter2_2 = \"\"\" Your summary here \"\"\"\n",
        "chapter2_3 = \"\"\" Your summary here \"\"\"\n",
        "chapter2_4 = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "# Lecture notes \n",
        "module1_lecture_notes = \"\"\"\n",
        "1.AI often concerned with consequentialism(we evalute an agent by its consequence.)\\n\n",
        "2.It don't need to be omniscience and not to forseen. The basic idea behind rational choice theory is the actions of an entire society or a market set of possible alternatives, basic assumption behind is individual\n",
        "act in a self-interested way and pick the alternatiec which most desirable to them. \\n\n",
        "3.It's better to design performance measures according to what u want to do rather how you think they should behave.\\n\n",
        "4.Design agent need Performance measure, environment, actuators, sensors.\\n\n",
        "5.Goal of rational agent designer is construct agent f max the exp value of performance measure/implement f on a particular architecture.\\n\n",
        "6.task environment: fully/partially observable;deterministic/nondeterministic/stochastic;episoid/sequential;static/dynamic;discrete/continous；single/multi agent.\\n\n",
        "7.We consider another agent when something behavior can best be described as having its own performance measure \"\"\"\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/architecture+program\",\n",
        "\"percept\" : \"the agent’s perceptual inputs at any given instance from the sensor.\",\n",
        "\"agent function\" : \"which maps a sequence of percept vectors to an action from the set(abstract mathematical description)\",\n",
        "\"rational agent\" : \"an agent each possible percept sequence select an action to max the expected value of performance measure.\",\n",
        "\"act rationally\" : \"do the right thing in all circumstances\",\n",
        "\"perform measure\" : \"an objective criterion for success of an agent's behavior given that evidence provided by the percept sequence\",\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": 948
        },
        "cellView": "form",
        "outputId": "b746938e-64c2-4827-a491-d4b8bf280c69"
      },
      "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": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 1: Rational Agents and Task Environments\n## AIMA Chapter 1.1 What is AI?\n science let machine think/act like human rationally.\n\n## AIMA Chapter 27.1 The Limits of AI\n Your summary here \n\n## AIMA Chapter 27.1 Can Machines Really Think?\n Your summary here \n\n## AIMA 2.1 Agents and Environments\n Your summary here \n\n## AIMA 2.2 Good Behavior: The Concept of Rationality\n Your summary here \n\n## AIMA 2.3 The Nature of Environments\n Your summary here \n\n## AIMA 2.4 The Structure of Agents\n Your summary here \n\n## Module 1 Lecture Notes\n\n1.AI often concerned with consequentialism(we evalute an agent by its consequence.)\n\n2.It don't need to be omniscience and not to forseen. The basic idea behind rational choice theory is the actions of an entire society or a market set of possible alternatives, basic assumption behind is individual\nact in a self-interested way and pick the alternatiec which most desirable to them. \n\n3.It's better to design performance measures according to what u want to do rather how you think they should behave.\n\n4.Design agent need Performance measure, environment, actuators, sensors.\n\n5.Goal of rational agent designer is construct agent f max the exp value of performance measure/implement f on a particular architecture.\n\n6.task environment: fully/partially observable;deterministic/nondeterministic/stochastic;episoid/sequential;static/dynamic;discrete/continous；single/multi agent.\n\n7.We consider another agent when something behavior can best be described as having its own performance measure \n\n## Module 1 Definitions\n* **Agent** - anything that can perceive and act in an environment/architecture+program\n* **Percept** - the agent’s perceptual inputs at any given instance from the sensor.\n* **Agent function** - which maps a sequence of percept vectors to an action from the set(abstract mathematical description)\n* **Rational agent** - an agent each possible percept sequence select an action to max the expected value of performance measure.\n* **Act rationally** - do the right thing in all circumstances\n* **Perform measure** - an objective criterion for success of an agent's behavior given that evidence provided by the percept sequence\n* **Etc.** - your definitions here\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 = \"\"\"\n",
        "1.Python dynamic typing. Type automatically determined.\\n\n",
        "2.String: +; no need to escape special characters: r'\\n'; print(\"%s can speak %d language\"%('',60000)); inmutable\\n\n",
        "3.== check variable point to objects of same value/is check points to same object \\n\n",
        "4.x[:] new object with same value\\n\n",
        "5.tuple immutable and mixed types; string immutable; list mutable and mixed\\n\n",
        "6.x[1] second; x[-3] negative 3; x[1:3] 2,3,4; x[1:-1] 2 to negative 2; x[:2] 0,1; x[2:] -3,-2,-1\\n\n",
        "7.sorted return a copy sorted list\\n\n",
        "8.dictionary unordered and work by hashing,key immutable\\n\n",
        "9.*args; **kwargs\\n\n",
        "10.duck typing(entity): attributeError\\n\n",
        "11.generator:less code; maintain local state automatically;values are computed one at a time; avoid storing the entire sequence in memory; agregating; curcial for infinite sequence; bad if need to inspect individual values.\\n\n",
        "12.set mutable\"\"\"\n",
        "\n",
        "# Each definition should be at most 20 words long.\n",
        "module2_definitions = {\n",
        "\"mutability\" : \"not change after creation or not\",\n",
        "\"iterator\" : \"objects with a __next__() method\",\n",
        "\"generator\" : \"iterators with __next()__ method\"\n",
        "\n",
        "}"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "ydOK__lwWgdp",
        "cellView": "form",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 513
        },
        "outputId": "d0d8998c-bbfc-4b7b-f77b-9628b10a3722"
      },
      "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": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 2: Python\n## Module 2 Lecture Notes\n\n1.Python dynamic typing. Type automatically determined.\n\n2.String: +; no need to escape special characters: r'\n'; print(\"%s can speak %d language\"%('',60000)); inmutable\n\n3.== check variable point to objects of same value/is check points to same object \n\n4.x[:] new object with same value\n\n5.tuple immutable and mixed types; string immutable; list mutable and mixed\n\n6.x[1] second; x[-3] negative 3; x[1:3] 2,3,4; x[1:-1] 2 to negative 2; x[:2] 0,1; x[2:] -3,-2,-1\n\n7.sorted return a copy sorted list\n\n8.dictionary unordered and work by hashing,key immutable\n\n9.*args; **kwargs\n\n10.duck typing(entity): attributeError\n\n11.generator:less code; maintain local state automatically;values are computed one at a time; avoid storing the entire sequence in memory; agregating; curcial for infinite sequence; bad if need to inspect individual values.\n\n12.set mutable\n\n## Module 2 Definitions\n* **Mutability** - not change after creation or not\n* **Iterator** - objects with a __next__() method\n* **Generator** - iterators with __next()__ method\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 = \"\"\" \n",
        "1.Types of solution vary since the impact of task environment.\\n\n",
        "2.States, initial state, actions, transition model(successor), path cost(performance measure), goal test are six things we need to define a search problem.\\n\n",
        "3.Formulate a search problem needs which properties matter initial state,goal, possible intermediate states; action possible operator set(action and transition model), which action next path cost function.\\n\n",
        "4.Basic search algorithm tree search enumerate in some order all possible paths from initial and search through explicit tree generation. It treat search treats different paths to same node as distinct(key difference from graph search).\\n\n",
        "5.Tree search fails to detect repeated states and turn a linear problem into expoential one. Solution graph search which check node visited or not. But it must track of all possible states use a lot of memory.\\n\n",
        "6.Uninform search aka blind search use only information available in problem definition and all non-goal nodes look equally good.\\n\n",
        "7.Dimensions for evalution: completeness(always solution),optimality(find a least cost solution first),time complexity(# of nodes generated),space complexity(# of nodes simulataneously in memory).\\n\n",
        "8.Units of space arbitary since O ignore constant multiplicative factors.\\n\n",
        "9.BFS frontier FIFO,complete if b is finit,time/space complexity O(b^d),optimal if cost=1 per step but not optimal in general. Use if possible infinite paths, some solutions have short paths, quick discard unlikely paths.\\n\n",
        "10.DFS LIFO, no complete fails in infinite-depth,time O(b^m) terrible if m is much larger than d, space O(b*m) linear space, not optimal. Use if space is restricted, there are many possible solutions with long paths and wrong paths are usually terminated quickly, can be fine-tuned quickly.\\n\n",
        "11.Depth-limited search limited depth l, l=d optimal, l<d incomplete, l>d not optimal, time O(b^l), space O(bl).\\n\n",
        "12.Iterative deepening search is to find best depth limit l, complete(no infinite paths) and optimal(if cost = 1)always find at depth d, the d of shallowest goal-node. Time O(b^d), Space O(bd).\"\"\"\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",
        "\"solution\" : \"sequence of actions from initial state to goal\",\n",
        "\"optimal solution\" : \"optimal if no solution has a lower path cost\",\n",
        "\"problem-solving agent\" : \"an agent that can formulate a plan via search\",\n",
        "\"Reflex agent\" : \"one that selects an action based only on the current percept.(ignore the rest of the percept history)\", \n",
        "\"Problem-solving agent\" : \"plan ahead, consider a sequence of actions(solution) to form a path to goal\",\n",
        "\"search\" : \"the computational process\",\n",
        "\"state space\" : \"the set of all states reachable from the initial state by any sequence of actions\",\n",
        "\"path\" : \"a sequence of actions leading from one state to another state\",\n",
        "\"search tree\" : \"a way of representing the paths that a search algorithm has explored\",\n",
        "\"frontier\" : \"those states that are available for expanding\",\n",
        "\"branching factor b\" : \"maximum branching factor of search tree\",\n",
        "\"depth d\" : \"depth of shallowest goal node\",\n",
        "\"m\" : \"maximum length of any path in the state space\"\n",
        "\n",
        "}\n",
        "\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "lvtN3p7ET3Tx",
        "cellView": "form",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "outputId": "fb23db1b-1a3e-4029-c2c1-d02092e77104"
      },
      "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": null,
      "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 \n1.Types of solution vary since the impact of task environment.\n\n2.States, initial state, actions, transition model(successor), path cost(performance measure), goal test are six things we need to define a search problem.\n\n3.Formulate a search problem needs which properties matter initial state,goal, possible intermediate states; action possible operator set(action and transition model), which action next path cost function.\n\n4.Basic search algorithm tree search enumerate in some order all possible paths from initial and search through explicit tree generation. It treat search treats different paths to same node as distinct(key difference from graph search).\n\n5.Tree search fails to detect repeated states and turn a linear problem into expoential one. Solution graph search which check node visited or not. But it must track of all possible states use a lot of memory.\n\n6.Uninform search aka blind search use only information available in problem definition and all non-goal nodes look equally good.\n\n7.Dimensions for evalution: completeness(always solution),optimality(find a least cost solution first),time complexity(# of nodes generated),space complexity(# of nodes simulataneously in memory).\n\n8.Units of space arbitary since O ignore constant multiplicative factors.\n\n9.BFS frontier FIFO,complete if b is finit,time/space complexity O(b^d),optimal if cost=1 per step but not optimal in general. Use if possible infinite paths, some solutions have short paths, quick discard unlikely paths.\n\n10.DFS LIFO, no complete fails in infinite-depth,time O(b^m) terrible if m is much larger than d, space O(b*m) linear space, not optimal. Use if space is restricted, there are many possible solutions with long paths and wrong paths are usually terminated quickly, can be fine-tuned quickly.\n\n11.Depth-limited search limited depth l, l=d optimal, l<d incomplete, l>d not optimal, time O(b^l), space O(bl).\n\n12.Iterative deepening search is to find best depth limit l, complete(no infinite paths) and optimal(if cost = 1)always find at depth d, the d of shallowest goal-node. Time O(b^d), Space O(bd).\n\n## Module 3 Definitions\n* **Solution** - sequence of actions from initial state to goal\n* **Optimal solution** - optimal if no solution has a lower path cost\n* **Problem-solving agent** - an agent that can formulate a plan via search\n* **Reflex agent** - one that selects an action based only on the current percept.(ignore the rest of the percept history)\n* **Problem-solving agent** - plan ahead, consider a sequence of actions(solution) to form a path to goal\n* **Search** - the computational process\n* **State space** - the set of all states reachable from the initial state by any sequence of actions\n* **Path** - a sequence of actions leading from one state to another state\n* **Search tree** - a way of representing the paths that a search algorithm has explored\n* **Frontier** - those states that are available for expanding\n* **Branching factor b** - maximum branching factor of search tree\n* **Depth d** - depth of shallowest goal node\n* **M** - maximum length of any path in the state space\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 = \"\"\"\n",
        "1.heuristic function take a state n and return an estimate of distance from n to the goal. \\n\n",
        "2.Greedy best first search use h(n) instead of use g(n), different from the basic best first search. \\n\n",
        "3.Greedy best first search not optimal, not complete(stuck in loop)\\n\n",
        "4.A* best known form of best first search use f(n)=h(n)+g(n)\\n\n",
        "5.A heuristic h(n) is admissible if it never overestimates the cost to reach the goal(optimal)\\n\n",
        "6.A* optiaml if h(n) is admissible(optimal)\\n\n",
        "7.The cost of an optimal solution to a relaxed problem is an admissible heuristic for the original problem\\n\n",
        "8.h2>h1,h2 dominates h1,h2 is optimistic but more accurate than h1. Both of them should be admissible.\\n\n",
        "9.The best h is h*(n) which is the true cost to a nearest goal, the worst is h teleportation.\\n\n",
        "10.h is admissible(optimistic) if 0 <= h <= h*.\\n\n",
        "11.Optimal not just mean find a goal state but find a goal state with the lowest path cost.\\n\n",
        "12.Dijkstra’s Algorithm (also called Uniform Cost Search) lets us prioritize which paths to explore. Instead of exploring all possible paths equally, it favors lower cost paths. We can assign lower costs to encourage moving on roads, higher costs to avoid forests, higher costs to discourage going near enemies, and more. When movement costs vary, we use this instead of Breadth First Search.\\n\n",
        "13.A* is a modification of Dijkstra’s Algorithm that is optimized for a single destination. Dijkstra’s Algorithm can find paths to all locations.\"\"\"\n",
        "\n",
        "# Definitions\n",
        "module4_definitions = {\n",
        "\"Uniform Cost Search(extension of bfs)\" : \"a search algorithm used for weighted graphs, extension of BFS\",   \n",
        "\"best-first search\" : \"ndoe selected for expansion based on an evalution function f(n)\",\n",
        "\"g(n)\" : \"path cost function\",\n",
        "\"relaxed problem\" : \"a problem with fewer restrictions on the actions than the original\",\n",
        "\"heuristics\" : \"cost of an exact solution to a relaxed problem\",\n",
        "\"admissibility\" : \"slow down bad plans and never overweigh true costs. True best plan always expand.\"\n",
        "}\n",
        "\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "vqtEs0gHs9sO",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 736
        },
        "cellView": "form",
        "outputId": "614acb3f-d858-438c-e843-0f8a90442386"
      },
      "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\n1.heuristic function take a state n and return an estimate of distance from n to the goal. \n\n2.Greedy best first search use h(n) instead of use g(n), different from the basic best first search. \n\n3.Greedy best first search not optimal, not complete(stuck in loop)\n\n4.A* best known form of best first search use f(n)=h(n)+g(n)\n\n5.A heuristic h(n) is admissible if it never overestimates the cost to reach the goal(optimal)\n\n6.A* optiaml if h(n) is admissible(optimal)\n\n7.The cost of an optimal solution to a relaxed problem is an admissible heuristic for the original problem\n\n8.h2>h1,h2 dominates h1,h2 is optimistic but more accurate than h1. Both of them should be admissible.\n\n9.The best h is h*(n) which is the true cost to a nearest goal, the worst is h teleportation.\n\n10.h is admissible(optimistic) if 0 <= h <= h*.\n\n11.Optimal not just mean find a goal state but find a goal state with the lowest path cost.\n\n12.Dijkstra’s Algorithm (also called Uniform Cost Search) lets us prioritize which paths to explore. Instead of exploring all possible paths equally, it favors lower cost paths. We can assign lower costs to encourage moving on roads, higher costs to avoid forests, higher costs to discourage going near enemies, and more. When movement costs vary, we use this instead of Breadth First Search.\n\n13.A* is a modification of Dijkstra’s Algorithm that is optimized for a single destination. Dijkstra’s Algorithm can find paths to all locations.\n\n## Module 4 Definitions\n* **Uniform cost search(extension of bfs)** - a search algorithm used for weighted graphs, extension of BFS\n* **Best-first search** - ndoe selected for expansion based on an evalution function f(n)\n* **G(n)** - path cost function\n* **Relaxed problem** - a problem with fewer restrictions on the actions than the original\n* **Heuristics** - cost of an exact solution to a relaxed problem\n* **Admissibility** - slow down bad plans and never overweigh true costs. True best plan always expand.\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 = \"\"\"\n",
        "1.Game are multiagent. Properties of games: two players are alternate moves, zero-sum(one player's loss is another's gain), clear set of legal moves, well-defined outcomes.\\n\n",
        "2.Formalize the game setting: two player max and min, max move first; max and min take turns move until end; winner award loser penalty.\\n\n",
        "3.Game as search: initial state, successor function, terminal test, utility function, max uses search tree to determine next move.\\n\n",
        "4.Playing: consider all legal successors to current state; evaluate each successor board position; pick the move leads to best board position; after your opponent repeat.\\n\n",
        "5.Evaluation function assigns real number scores to board positions without reference to path.\\n\n",
        "6.Terminal nodes represent ways the game could end, labeled with the desirability of that ending.(win/lose etc).\\n\n",
        "7.Alpha-Beta pruning: alpha currunt lower bound on MAX's outcome, beta current upper bound on MIN's outcome.\\n\n",
        "It decrease the number of nodes that are evaluated by the minimax algorithm.\\n\n",
        "8.Size of the tree depend on the branching factor and depth.\\n\n",
        "9.Alpha-Beta pruning happens when alpha >= beta, alpah is max(self,next level alpha, next level beta).\n",
        "10.Expectimax used in uncertain outcomes, max nodes and chance nodes. Values now reflect average-case(expectimax) outcome not worst-case(minimax) outcome.\"\"\"\n",
        "\n",
        "# Definitions\n",
        "module5_definitions = {\n",
        "\"Strategic\" : \"next state is determined bt the current state and the action excuted by agents\",    \n",
        "\"game tree\" : \"node is board position, edge is legal moves, root node is first position\",\n",
        "\"Even level\" : \"turns for MAX\",\n",
        "\"Odd level\" : \"turns for MIN\",\n",
        "\"minimax rule\" : \"make the best move for max assuming min always replies with the best moves for min\",\n",
        "\"backed-up value\" : \"values of its children, maximum for MAX, minimum for MIN\"\n",
        "}\n",
        "\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "KUc_LgzDvWf-",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "outputId": "eb2b7cd5-80f1-4834-ddd7-820b68d69e52"
      },
      "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\n1.Game are multiagent. Properties of games: two players are alternate moves, zero-sum(one player's loss is another's gain), clear set of legal moves, well-defined outcomes.\n\n2.Formalize the game setting: two player max and min, max move first; max and min take turns move until end; winner award loser penalty.\n\n3.Game as search: initial state, successor function, terminal test, utility function, max uses search tree to determine next move.\n\n4.Playing: consider all legal successors to current state; evaluate each successor board position; pick the move leads to best board position; after your opponent repeat.\n\n5.Evaluation function assigns real number scores to board positions without reference to path.\n\n6.Terminal nodes represent ways the game could end, labeled with the desirability of that ending.(win/lose etc).\n\n7.Alpha-Beta pruning: alpha currunt lower bound on MAX's outcome, beta current upper bound on MIN's outcome.\n\nIt decrease the number of nodes that are evaluated by the minimax algorithm.\n\n8.Size of the tree depend on the branching factor and depth.\n\n9.Alpha-Beta pruning happens when alpha >= beta, alpah is max(self,next level alpha, next level beta).\n10.Expectimax used in uncertain outcomes, max nodes and chance nodes. Values now reflect average-case(expectimax) outcome not worst-case(minimax) outcome.\n\n## Module 5 Definitions\n* **Strategic** - next state is determined bt the current state and the action excuted by agents\n* **Game tree** - node is board position, edge is legal moves, root node is first position\n* **Even level** - turns for MAX\n* **Odd level** - turns for MIN\n* **Minimax rule** - make the best move for max assuming min always replies with the best moves for min\n* **Backed-up value** - values of its children, maximum for MAX, minimum for MIN\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 = \"\"\"\n",
        "1.Constraint Satisfaction Problems, CSP, consists of finite set of variables, nonempty domain of possible values, finite set of constraints.\\n\n",
        "2.A consistent assignment does not violate the constraints.\\n\n",
        "3.An assignment is complete when every variable is assigned a value. Solution to CSP should be complete and consistent, which can be found by a completely general purpose algorithm, given only the formal specification of CSP.\\n\n",
        "4.Benefit of CSP: clean specification of many problems, general goal, successor function and h, instead just represent problem as CSP and solve with general package; CSP knows which variable violate a constraint; CSP automatically prune off all branches that violates constraints.\\n\n",
        "5.CSP as search problem: initial state, empty assignemnt; successor function,assume no constaint;goal test(complete); path cost a constant cost for every step.\\n\n",
        "6.Solution of CSP is always find at depth n, for n variables.\\n\n",
        "7.Assume n variables and domain size d, branching factor at the root is n*d, branching next level is (n-1)*d, n!*(d^n) leaves.\\n\n",
        "8.Variable assignment are commutative are commutative which means order not matter, so CSP is tree search not graph search.\\n\n",
        "9.We only need to consider assingment to a single variable at each time.\\n\n",
        "10.Heuristics: (1)which variable should be assigned next, most constrained variable if ties most constraining variable; (2)what order should variable's values be tried, least constraining value; (3)forward checking detect inevitable failure earyly.\\n\n",
        "11.(1)choose fewest legal values, aka minimum remaining values(MRV);choose the variable with the most constraints on remaining variables.\\n\n",
        "12.(3)keep track of remaining legal values for unassigned variables\\n\n",
        "13.Forward checking not provide early detection to all failures, so imporve to constraint propagation(inference).\\n\n",
        "14.CSP solver combine search and inference. Inference eliminate possible value for a variable if value violate local consistency(node consistency [unary] and arc consistency[binary])\\n\n",
        "15.MAC recursively propogrates constraints, whereas forward checking does not.\"\"\"\n",
        "\n",
        "# Definitions\n",
        "module6_definitions = {\n",
        "\"Constraint graph\" : \"nodes are variables, arcs are constraints\", \n",
        "\"Unary constrains\" : \"a single variable SA != green\",\n",
        "\"Binary constraints\" : \"pairs of variables SA != WA\" , \n",
        "\"Higher-order constrains\" : \"3 or more variables crypt-arithmetic column constraints\",\n",
        "\"Preference constraints\" : \"represent by a cost for each variable assignment, constrained optimization problems\",\n",
        "\"backtracking search\" : \"depth first search for CSP with single variable assignments(uninformed search for CSP)\",\n",
        "\"MRV\" : \"minimum remaining values heuristic choose a variable with fewest legal values\",\n",
        "\"ac-3 arc consistency\" : \"every value v on x is consistent with some label on y. Given d values, time worst case is O(d^2).\"\n",
        "}\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "kKWbCsbfxL3R",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "outputId": "602b5882-376f-444e-b639-f30a1f6f465a"
      },
      "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\n1.Constraint Satisfaction Problems, CSP, consists of finite set of variables, nonempty domain of possible values, finite set of constraints.\n\n2.A consistent assignment does not violate the constraints.\n\n3.An assignment is complete when every variable is assigned a value. Solution to CSP should be complete and consistent, which can be found by a completely general purpose algorithm, given only the formal specification of CSP.\n\n4.Benefit of CSP: clean specification of many problems, general goal, successor function and h, instead just represent problem as CSP and solve with general package; CSP knows which variable violate a constraint; CSP automatically prune off all branches that violates constraints.\n\n5.CSP as search problem: initial state, empty assignemnt; successor function,assume no constaint;goal test(complete); path cost a constant cost for every step.\n\n6.Solution of CSP is always find at depth n, for n variables.\n\n7.Assume n variables and domain size d, branching factor at the root is n*d, branching next level is (n-1)*d, n!*(d^n) leaves.\n\n8.Variable assignment are commutative are commutative which means order not matter, so CSP is tree search not graph search.\n\n9.We only need to consider assingment to a single variable at each time.\n\n10.Heuristics: (1)which variable should be assigned next, most constrained variable if ties most constraining variable; (2)what order should variable's values be tried, least constraining value; (3)forward checking detect inevitable failure earyly.\n\n11.(1)choose fewest legal values, aka minimum remaining values(MRV);choose the variable with the most constraints on remaining variables.\n\n12.(3)keep track of remaining legal values for unassigned variables\n\n13.Forward checking not provide early detection to all failures, so imporve to constraint propagation(inference).\n\n14.CSP solver combine search and inference. Inference eliminate possible value for a variable if value violate local consistency(node consistency [unary] and arc consistency[binary])\n\n15.MAC recursively propogrates constraints, whereas forward checking does not.\n\n## Module 6 Definitions\n* **Constraint graph** - nodes are variables, arcs are constraints\n* **Unary constrains** - a single variable SA != green\n* **Binary constraints** - pairs of variables SA != WA\n* **Higher-order constrains** - 3 or more variables crypt-arithmetic column constraints\n* **Preference constraints** - represent by a cost for each variable assignment, constrained optimization problems\n* **Backtracking search** - depth first search for CSP with single variable assignments(uninformed search for CSP)\n* **Mrv** - minimum remaining values heuristic choose a variable with fewest legal values\n* **Ac-3 arc consistency** - every value v on x is consistent with some label on y. Given d values, time worst case is O(d^2).\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 = \"\"\"\n",
        "1.Difference between knowledge based agent and problem solving agent is primarily the sophistication of the levels of repersentation that we have about the world.\\n\n",
        "2.Contain some background about world and can add to the information in the KB through its observation of the world. It can also query the KB and ask it to derive new knowledge in order to select what action it takes.\\n\n",
        "3.alpha is true in model of m, we say alpha statisfy m or alpha is model of m\\n\n",
        "4.altha entail beta iff M(alpha) is subset of M(beta). This means alpha is more specific and stronger than beta.\\n\n",
        "5.Inference algorithm is to enumerate these sentences\\n\n",
        "6.Ways to inference algorithm: propositional logic: atomic sentences are represented with a single propositional symbol.\\n\n",
        "7.Complex sentences are constructed from simpler ones using parentheses and logical connectives.\\n\n",
        "8.Search for a proof: initial state(KB), Actions(inference rules applied to sentence), result(add sentence on bottom half to KB), Goal(state contain the sentence that we are trying to prove)\\n\n",
        "9.Resolution yied a complete inference algorithm when coupled with any complete search algorithm.\\n\n",
        "10.Every sentence in propositional logic is equivalent ti a conjunction of clauses.\\n\n",
        "11.The resolution algorithm is complete.\\n\n",
        "12.Horn clause includes definite clauses and clauses with no positive literals. Horn clause are closed under resolution(we get back a horn clause when applying resolution to a horn clause)\\n\n",
        "13.Forward Chaining is a kind of data-driven reasoning. An agent can start with known data, adding premises as new percepts come in, and incrementally applay the foward chaining algorithm to derive new conclusions. No need to have a special query in mind to do so.\\n\n",
        "14.Backward Chaining works backwards from a query. If a query is true, no work is needed. Otherwise, the algorithm finds implications in KB whose conclusions is the query. If all premises of one of those can be proved to be true, the query is true.(a form of goal-directed reasoning). \"\"\"\n",
        "\n",
        "# Definitions\n",
        "module7_definitions = {\n",
        "\"knowledge based agent\" : \"use a process of reasoning over an internal representation of knowledge to decide what to do\",    \n",
        "\"Axioms\" : \"a sentence that is given\",\n",
        "\"Derived sentences\" : \"a new sentences from old sentences is called inference\", \n",
        "\"entailment\" : \"a sentence follows logically from another sentence\",\n",
        "\"knowledge base\" : \"a set of sentences\",\n",
        "\"model checking\" : \"process of enumerating all possible models that are compatible with the KB. M(KB) is subset of M(alpha)\",\n",
        "\"logical inference\" : \"entailment can be applied to derive conclusions\",\n",
        "\"propositional symnbols\" : \"stand for a sentence that can be true or false\",\n",
        "\"sound\" : \"the inference algorithm should only derive entailed sentences\",\n",
        "\"complete\" : \"an inference algorithm is complete if it can derive all sentences that are entailed\",\n",
        "\"definite clause\" : \"disjunction of literals where exactly one is positive\",\n",
        "\"horn clause\" : \"disjunction of literals where at least one is positive\"\n",
        "}\n",
        "\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "lXNcHuKjyNXa",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "outputId": "5e2a24e3-2120-43fe-c1d6-c46d9b3eec86"
      },
      "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\n1.Difference between knowledge based agent and problem solving agent is primarily the sophistication of the levels of repersentation that we have about the world.\n\n2.Contain some background about world and can add to the information in the KB through its observation of the world. It can also query the KB and ask it to derive new knowledge in order to select what action it takes.\n\n3.alpha is true in model of m, we say alpha statisfy m or alpha is model of m\n\n4.altha entail beta iff M(alpha) is subset of M(beta). This means alpha is more specific and stronger than beta.\n\n5.Inference algorithm is to enumerate these sentences\n\n6.Ways to inference algorithm: propositional logic: atomic sentences are represented with a single propositional symbol.\n\n7.Complex sentences are constructed from simpler ones using parentheses and logical connectives.\n\n8.Search for a proof: initial state(KB), Actions(inference rules applied to sentence), result(add sentence on bottom half to KB), Goal(state contain the sentence that we are trying to prove)\n\n9.Resolution yied a complete inference algorithm when coupled with any complete search algorithm.\n\n10.Every sentence in propositional logic is equivalent ti a conjunction of clauses.\n\n11.The resolution algorithm is complete.\n\n12.Horn clause includes definite clauses and clauses with no positive literals. Horn clause are closed under resolution(we get back a horn clause when applying resolution to a horn clause)\n\n13.Forward Chaining is a kind of data-driven reasoning. An agent can start with known data, adding premises as new percepts come in, and incrementally applay the foward chaining algorithm to derive new conclusions. No need to have a special query in mind to do so.\n\n14.Backward Chaining works backwards from a query. If a query is true, no work is needed. Otherwise, the algorithm finds implications in KB whose conclusions is the query. If all premises of one of those can be proved to be true, the query is true.(a form of goal-directed reasoning). \n\n## Module 7 Definitions\n* **Knowledge based agent** - use a process of reasoning over an internal representation of knowledge to decide what to do\n* **Axioms** - a sentence that is given\n* **Derived sentences** - a new sentences from old sentences is called inference\n* **Entailment** - a sentence follows logically from another sentence\n* **Knowledge base** - a set of sentences\n* **Model checking** - process of enumerating all possible models that are compatible with the KB. M(KB) is subset of M(alpha)\n* **Logical inference** - entailment can be applied to derive conclusions\n* **Propositional symnbols** - stand for a sentence that can be true or false\n* **Sound** - the inference algorithm should only derive entailed sentences\n* **Complete** - an inference algorithm is complete if it can derive all sentences that are entailed\n* **Definite clause** - disjunction of literals where exactly one is positive\n* **Horn clause** - disjunction of literals where at least one is positive\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": "f4acfcfd-fd42-4023-a248-50fc2c3c7e2f"
      },
      "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": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 1: Rational Agents and Task Environments\n## AIMA Chapter 1.1 What is AI?\n science let machine think/act like human rationally.\n\n## AIMA Chapter 27.1 The Limits of AI\n Your summary here \n\n## AIMA Chapter 27.1 Can Machines Really Think?\n Your summary here \n\n## AIMA 2.1 Agents and Environments\n Your summary here \n\n## AIMA 2.2 Good Behavior: The Concept of Rationality\n Your summary here \n\n## AIMA 2.3 The Nature of Environments\n Your summary here \n\n## AIMA 2.4 The Structure of Agents\n Your summary here \n\n## Module 1 Lecture Notes\n\n1.AI often concerned with consequentialism(we evalute an agent by its consequence.)\n\n2.It don't need to be omniscience and not to forseen. The basic idea behind rational choice theory is the actions of an entire society or a market set of possible alternatives, basic assumption behind is individual\nact in a self-interested way and pick the alternatiec which most desirable to them. \n\n3.It's better to design performance measures according to what u want to do rather how you think they should behave.\n\n4.Design agent need Performance measure, environment, actuators, sensors.\n\n5.Goal of rational agent designer is construct agent f max the exp value of performance measure/implement f on a particular architecture.\n\n6.task environment: fully/partially observable;deterministic/nondeterministic/stochastic;episoid/sequential;static/dynamic;discrete/continous；single/multi agent.\n\n7.We consider another agent when something behavior can best be described as having its own performance measure \n\n## Module 1 Definitions\n* **Agent** - anything that can perceive and act in an environment/architecture+program\n* **Percept** - the agent’s perceptual inputs at any given instance from the sensor.\n* **Agent function** - which maps a sequence of percept vectors to an action from the set(abstract mathematical description)\n* **Rational agent** - an agent each possible percept sequence select an action to max the expected value of performance measure.\n* **Act rationally** - do the right thing in all circumstances\n* **Perform measure** - an objective criterion for success of an agent's behavior given that evidence provided by the percept sequence\n* **Etc.** - your definitions here\n\n\n# Module 2: Python\n## Module 2 Lecture Notes\n\n1.Python dynamic typing. Type automatically determined.\n\n2.String: +; no need to escape special characters: r'\n'; print(\"%s can speak %d language\"%('',60000)); inmutable\n\n3.== check variable point to objects of same value/is check points to same object \n\n4.x[:] new object with same value\n\n5.tuple immutable and mixed types; string immutable; list mutable and mixed\n\n6.x[1] second; x[-3] negative 3; x[1:3] 2,3,4; x[1:-1] 2 to negative 2; x[:2] 0,1; x[2:] -3,-2,-1\n\n7.sorted return a copy sorted list\n\n8.dictionary unordered and work by hashing,key immutable\n\n9.*args; **kwargs\n\n10.duck typing(entity): attributeError\n\n11.generator:less code; maintain local state automatically;values are computed one at a time; avoid storing the entire sequence in memory; agregating; curcial for infinite sequence; bad if need to inspect individual values.\n\n12.set mutable\n\n## Module 2 Definitions\n* **Mutability** - not change after creation or not\n* **Iterator** - objects with a __next__() method\n* **Generator** - iterators with __next()__ method\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 \n1.Types of solution vary since the impact of task environment.\n\n2.States, initial state, actions, transition model(successor), path cost(performance measure), goal test are six things we need to define a search problem.\n\n3.Formulate a search problem needs which properties matter initial state,goal, possible intermediate states; action possible operator set(action and transition model), which action next path cost function.\n\n4.Basic search algorithm tree search enumerate in some order all possible paths from initial and search through explicit tree generation. It treat search treats different paths to same node as distinct(key difference from graph search).\n\n5.Tree search fails to detect repeated states and turn a linear problem into expoential one. Solution graph search which check node visited or not. But it must track of all possible states use a lot of memory.\n\n6.Uninform search aka blind search use only information available in problem definition and all non-goal nodes look equally good.\n\n7.Dimensions for evalution: completeness(always solution),optimality(find a least cost solution first),time complexity(# of nodes generated),space complexity(# of nodes simulataneously in memory).\n\n8.Units of space arbitary since O ignore constant multiplicative factors.\n\n9.BFS frontier FIFO,complete if b is finit,time/space complexity O(b^d),optimal if cost=1 per step but not optimal in general. Use if possible infinite paths, some solutions have short paths, quick discard unlikely paths.\n\n10.DFS LIFO, no complete fails in infinite-depth,time O(b^m) terrible if m is much larger than d, space O(b*m) linear space, not optimal. Use if space is restricted, there are many possible solutions with long paths and wrong paths are usually terminated quickly, can be fine-tuned quickly.\n\n11.Depth-limited search limited depth l, l=d optimal, l<d incomplete, l>d not optimal, time O(b^l), space O(bl).\n\n12.Iterative deepening search is to find best depth limit l, complete(no infinite paths) and optimal(if cost = 1)always find at depth d, the d of shallowest goal-node. Time O(b^d), Space O(bd).\n\n## Module 3 Definitions\n* **Solution** - sequence of actions from initial state to goal\n* **Optimal solution** - optimal if no solution has a lower path cost\n* **Problem-solving agent** - an agent that can formulate a plan via search\n* **Reflex agent** - one that selects an action based only on the current percept.(ignore the rest of the percept history)\n* **Problem-solving agent** - plan ahead, consider a sequence of actions(solution) to form a path to goal\n* **Search** - the computational process\n* **State space** - the set of all states reachable from the initial state by any sequence of actions\n* **Path** - a sequence of actions leading from one state to another state\n* **Search tree** - a way of representing the paths that a search algorithm has explored\n* **Frontier** - those states that are available for expanding\n* **Branching factor b** - maximum branching factor of search tree\n* **Depth d** - depth of shallowest goal node\n* **M** - maximum length of any path in the state space\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\n\n1.heuristic function take a state n and return an estimate of distance from n to the goal. \n\n2.Greedy best first search use h(n) instead of use g(n), different from the basic best first search. \n\n3.Greedy best first search not optimal, not complete(stuck in loop)\n\n4.A* best known form of best first search use f(n)=h(n)+g(n)\n\n5.A heuristic h(n) is admissible if it never overestimates the cost to reach the goal(optimal)\n\n6.A* optiaml if h(n) is admissible(optimal)\n\n7.The cost of an optimal solution to a relaxed problem is an admissible heuristic for the original problem\n\n8.h2>h1,h2 dominates h1,h2 is optimistic but more accurate than h1. Both of them should be admissible.\n\n9.The best h is h*(n) which is the true cost to a nearest goal, the worst is h teleportation.\n\n10.h is admissible(optimistic) if 0 <= h <= h*.\n\n11.Optimal not just mean find a goal state but find a goal state with the lowest path cost.\n\n12.Dijkstra’s Algorithm (also called Uniform Cost Search) lets us prioritize which paths to explore. Instead of exploring all possible paths equally, it favors lower cost paths. We can assign lower costs to encourage moving on roads, higher costs to avoid forests, higher costs to discourage going near enemies, and more. When movement costs vary, we use this instead of Breadth First Search.\n\n13.A* is a modification of Dijkstra’s Algorithm that is optimized for a single destination. Dijkstra’s Algorithm can find paths to all locations.\n\n## Module 4 Definitions\n* **Uniform cost search(extension of bfs)** - a search algorithm used for weighted graphs, extension of BFS\n* **Best-first search** - ndoe selected for expansion based on an evalution function f(n)\n* **G(n)** - path cost function\n* **Relaxed problem** - a problem with fewer restrictions on the actions than the original\n* **Heuristics** - cost of an exact solution to a relaxed problem\n* **Admissibility** - slow down bad plans and never overweigh true costs. True best plan always expand.\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\n1.Game are multiagent. Properties of games: two players are alternate moves, zero-sum(one player's loss is another's gain), clear set of legal moves, well-defined outcomes.\n\n2.Formalize the game setting: two player max and min, max move first; max and min take turns move until end; winner award loser penalty.\n\n3.Game as search: initial state, successor function, terminal test, utility function, max uses search tree to determine next move.\n\n4.Playing: consider all legal successors to current state; evaluate each successor board position; pick the move leads to best board position; after your opponent repeat.\n\n5.Evaluation function assigns real number scores to board positions without reference to path.\n\n6.Terminal nodes represent ways the game could end, labeled with the desirability of that ending.(win/lose etc).\n\n7.Alpha-Beta pruning: alpha currunt lower bound on MAX's outcome, beta current upper bound on MIN's outcome.\n\nIt decrease the number of nodes that are evaluated by the minimax algorithm.\n\n8.Size of the tree depend on the branching factor and depth.\n\n9.Alpha-Beta pruning happens when alpha >= beta, alpah is max(self,next level alpha, next level beta).\n10.Expectimax used in uncertain outcomes, max nodes and chance nodes. Values now reflect average-case(expectimax) outcome not worst-case(minimax) outcome.\n\n## Module 5 Definitions\n* **Strategic** - next state is determined bt the current state and the action excuted by agents\n* **Game tree** - node is board position, edge is legal moves, root node is first position\n* **Even level** - turns for MAX\n* **Odd level** - turns for MIN\n* **Minimax rule** - make the best move for max assuming min always replies with the best moves for min\n* **Backed-up value** - values of its children, maximum for MAX, minimum for MIN\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\n1.Constraint Satisfaction Problems, CSP, consists of finite set of variables, nonempty domain of possible values, finite set of constraints.\n\n2.A consistent assignment does not violate the constraints.\n\n3.An assignment is complete when every variable is assigned a value. Solution to CSP should be complete and consistent, which can be found by a completely general purpose algorithm, given only the formal specification of CSP.\n\n4.Benefit of CSP: clean specification of many problems, general goal, successor function and h, instead just represent problem as CSP and solve with general package; CSP knows which variable violate a constraint; CSP automatically prune off all branches that violates constraints.\n\n5.CSP as search problem: initial state, empty assignemnt; successor function,assume no constaint;goal test(complete); path cost a constant cost for every step.\n\n6.Solution of CSP is always find at depth n, for n variables.\n\n7.Assume n variables and domain size d, branching factor at the root is n*d, branching next level is (n-1)*d, n!*(d^n) leaves.\n\n8.Variable assignment are commutative are commutative which means order not matter, so CSP is tree search not graph search.\n\n9.We only need to consider assingment to a single variable at each time.\n\n10.Heuristics: (1)which variable should be assigned next, most constrained variable if ties most constraining variable; (2)what order should variable's values be tried, least constraining value; (3)forward checking detect inevitable failure earyly.\n\n11.(1)choose fewest legal values, aka minimum remaining values(MRV);choose the variable with the most constraints on remaining variables.\n\n12.(3)keep track of remaining legal values for unassigned variables\n\n13.Forward checking not provide early detection to all failures, so imporve to constraint propagation(inference).\n\n14.CSP solver combine search and inference. Inference eliminate possible value for a variable if value violate local consistency(node consistency [unary] and arc consistency[binary])\n\n15.MAC recursively propogrates constraints, whereas forward checking does not.\n\n## Module 6 Definitions\n* **Constraint graph** - nodes are variables, arcs are constraints\n* **Unary constrains** - a single variable SA != green\n* **Binary constraints** - pairs of variables SA != WA\n* **Higher-order constrains** - 3 or more variables crypt-arithmetic column constraints\n* **Preference constraints** - represent by a cost for each variable assignment, constrained optimization problems\n* **Backtracking search** - depth first search for CSP with single variable assignments(uninformed search for CSP)\n* **Mrv** - minimum remaining values heuristic choose a variable with fewest legal values\n* **Ac-3 arc consistency** - every value v on x is consistent with some label on y. Given d values, time worst case is O(d^2).\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\n1.Difference between knowledge based agent and problem solving agent is primarily the sophistication of the levels of repersentation that we have about the world.\n\n2.Contain some background about world and can add to the information in the KB through its observation of the world. It can also query the KB and ask it to derive new knowledge in order to select what action it takes.\n\n3.alpha is true in model of m, we say alpha statisfy m or alpha is model of m\n\n4.altha entail beta iff M(alpha) is subset of M(beta). This means alpha is more specific and stronger than beta.\n\n5.Inference algorithm is to enumerate these sentences\n\n6.Ways to inference algorithm: propositional logic: atomic sentences are represented with a single propositional symbol.\n\n7.Complex sentences are constructed from simpler ones using parentheses and logical connectives.\n\n8.Search for a proof: initial state(KB), Actions(inference rules applied to sentence), result(add sentence on bottom half to KB), Goal(state contain the sentence that we are trying to prove)\n\n9.Resolution yied a complete inference algorithm when coupled with any complete search algorithm.\n\n10.Every sentence in propositional logic is equivalent ti a conjunction of clauses.\n\n11.The resolution algorithm is complete.\n\n12.Horn clause includes definite clauses and clauses with no positive literals. Horn clause are closed under resolution(we get back a horn clause when applying resolution to a horn clause)\n\n13.Forward Chaining is a kind of data-driven reasoning. An agent can start with known data, adding premises as new percepts come in, and incrementally applay the foward chaining algorithm to derive new conclusions. No need to have a special query in mind to do so.\n\n14.Backward Chaining works backwards from a query. If a query is true, no work is needed. Otherwise, the algorithm finds implications in KB whose conclusions is the query. If all premises of one of those can be proved to be true, the query is true.(a form of goal-directed reasoning). \n\n## Module 7 Definitions\n* **Knowledge based agent** - use a process of reasoning over an internal representation of knowledge to decide what to do\n* **Axioms** - a sentence that is given\n* **Derived sentences** - a new sentences from old sentences is called inference\n* **Entailment** - a sentence follows logically from another sentence\n* **Knowledge base** - a set of sentences\n* **Model checking** - process of enumerating all possible models that are compatible with the KB. M(KB) is subset of M(alpha)\n* **Logical inference** - entailment can be applied to derive conclusions\n* **Propositional symnbols** - stand for a sentence that can be true or false\n* **Sound** - the inference algorithm should only derive entailed sentences\n* **Complete** - an inference algorithm is complete if it can derive all sentences that are entailed\n* **Definite clause** - disjunction of literals where exactly one is positive\n* **Horn clause** - disjunction of literals where at least one is positive\n",
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {}
        }
      ]
    }
  ]
}