{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "Copy of DRAFT Template_for CIS521_midterm notes.ipynb",
      "provenance": [],
      "collapsed_sections": [],
      "toc_visible": true
    },
    "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/",
          "height": 0
        },
        "outputId": "939bae8d-716d-460b-e17e-d48195c78d32"
      },
      "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": 29,
      "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/",
          "height": 0
        },
        "outputId": "e68084c6-fb61-45b1-f3f4-e50c9300e51c"
      },
      "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": 30,
      "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": 31,
      "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 =  r\"\"\" $$\\alpha \\implies \\beta$$\"\"\"\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 = \"\"\" 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": 32,
      "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": 729
        },
        "outputId": "01ee1952-deee-4244-85fe-cc787c78e1b9"
      },
      "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": 33,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 1: Rational Agents and Task Environments\n## AIMA Chapter 1.1 What is AI?\n $$\\alpha \\implies \\beta$$\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 Your summary here \n\n## Module 1 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",
            "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",
        "# use y = x[:] to get a (shallow) copy of any sequence, ie. a new object of the same value\n",
        "# t = (23, 'abc', 4.56, (2,3), 'def')\n",
        "# t[1:4] #slicing ends before last index\n",
        "# ('abc', 4.56, (2,3))\n",
        "# t[1:-1] #using negative index\n",
        "# ('abc', 4.56, (2,3))\n",
        "# t[1:-1:2] # selection of every nth item.\n",
        "# ('abc', (2,3))\n",
        "# t[:2] # copy from beginning of sequence\n",
        "# (23, 'abc')\n",
        "# t[2:] # copy to the very end of the sequence\n",
        "# (4.56, (2,3), 'def')\n",
        "# t[::-1] # reverses the list\n",
        "# (‘def’, (2,3), 4.56, ‘abc’, 23)\n",
        "\n",
        "# List Comprehesion [ expression for name in list ] \n",
        "# li = [3, 6, 2, 7, 1, 9]\n",
        "# [elem * 2 for elem in li if elem > 4]\n",
        "# [12, 14, 18]\n",
        "\n",
        "# def extract_and_apply(l, p, f):\n",
        "  #  return [f(x) for x in l if p(x)]\n",
        "# l = [2, 4, 6, 3]\n",
        "# f = lambda x: x*x\n",
        "# p = lambda x: x < 4\n",
        "# print(extract_and_apply(l, p, f))\n",
        "\n",
        "# def concatenate(seqs):\n",
        "    # result = []\n",
        "    # for x in seqs:\n",
        "    #     for y in x:\n",
        "    #         result.append(y)\n",
        "    # return result\n",
        "   # return [y for x in seqs for y in x]\n",
        "# concatenate([\"abc\", (0, [0])])\n",
        " # ['a', 'b', 'c', 0, [0]]\n",
        "\n",
        "# def transpose(matrix):\n",
        "  #  return [[matrix[y][x] for y in range(len(matrix))] for x in range(len(matrix[0]))]\n",
        "# transpose([[1, 2], [3, 4], [5, 6]])\n",
        "# [[1, 3, 5], [2, 4, 6]]\n",
        "\n",
        "\"\"\"\n",
        "\n",
        "# Each definition should be at most 20 words long.\n",
        "module2_definitions = {\n",
        "\"mutability\" : \"your definition here\",\n",
        "}"
      ],
      "execution_count": 34,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "ydOK__lwWgdp",
        "cellView": "form",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 2031
        },
        "outputId": "87d25e85-3666-46bb-92c0-0767c10dd8a5"
      },
      "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": 35,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 2: Python\n## Module 2 Lecture Notes\n\n# use y = x[:] to get a (shallow) copy of any sequence, ie. a new object of the same value\n# t = (23, 'abc', 4.56, (2,3), 'def')\n# t[1:4] #slicing ends before last index\n# ('abc', 4.56, (2,3))\n# t[1:-1] #using negative index\n# ('abc', 4.56, (2,3))\n# t[1:-1:2] # selection of every nth item.\n# ('abc', (2,3))\n# t[:2] # copy from beginning of sequence\n# (23, 'abc')\n# t[2:] # copy to the very end of the sequence\n# (4.56, (2,3), 'def')\n# t[::-1] # reverses the list\n# (‘def’, (2,3), 4.56, ‘abc’, 23)\n\n# List Comprehesion [ expression for name in list ] \n# li = [3, 6, 2, 7, 1, 9]\n# [elem * 2 for elem in li if elem > 4]\n# [12, 14, 18]\n\n# def extract_and_apply(l, p, f):\n  #  return [f(x) for x in l if p(x)]\n# l = [2, 4, 6, 3]\n# f = lambda x: x*x\n# p = lambda x: x < 4\n# print(extract_and_apply(l, p, f))\n\n# def concatenate(seqs):\n    # result = []\n    # for x in seqs:\n    #     for y in x:\n    #         result.append(y)\n    # return result\n   # return [y for x in seqs for y in x]\n# concatenate([\"abc\", (0, [0])])\n # ['a', 'b', 'c', 0, [0]]\n\n# def transpose(matrix):\n  #  return [[matrix[y][x] for y in range(len(matrix))] for x in range(len(matrix[0]))]\n# transpose([[1, 2], [3, 4], [5, 6]])\n# [[1, 3, 5], [2, 4, 6]]\n\n\n\n## Module 2 Definitions\n* **Mutability** - your definition here\n",
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "46MQLR-Gx8dZ"
      },
      "source": [
        "#Module 3 - Search Problems"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "BN0b1eVYx-nd"
      },
      "source": [
        "# Russell and Norvig, AIMA 4th Edition, AIMA Chapter 3 “Problem Solving by Search” (3.1-3.4)\n",
        "chapter3_1 = \"\"\" Your summary here \"\"\"\n",
        "chapter3_2 = \"\"\" Your summary here \"\"\"\n",
        "chapter3_3 = \"\"\" Your summary here \"\"\"\n",
        "chapter3_4 = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "\n",
        "# Lecture notes \n",
        "module3_lecture_notes = \"\"\" Your summary here\n",
        "\n",
        "A problem-solving agent must plan ahead.\n",
        "The computational process that it undertakes is called search.\n",
        "It will consider a sequence of actions that form a path to a goal state.\n",
        "Solution is who this sequence is called.\n",
        "\n",
        "A solution is a fixed sequence of actions it its fully observable, determnistic\n",
        "and has a known environment. \n",
        "\n",
        "If the envrionment is partioally observable or nondeterministic, then solution \n",
        "has to recommend different future actions based on what percepts it receives. This is called a branching strategy\n",
        "\n",
        "Formal Definition of a Search Problem:\n",
        "1) States (initial state)\n",
        "2) Actions (set of actions that can be executed in a state s)\n",
        "3) Transition Model (the succesor of the previous state after performing the action)\n",
        "4) Path cost (must be additive)\n",
        "5) Goal test\n",
        "\n",
        "Formulation greatly affects combinatorics of search space and therefore\n",
        "speed of search\n",
        "\n",
        "State space: set of all states reachable from the initial state by any sequence of actions\n",
        "path: sequence of actions leadring from one state a, to another state b\n",
        "solution: path from initial state a, to state f, which satisfies the goal test\n",
        "Frontier: those states that are available for expanding (as the search proceeds, the frontier expands into the unexplored nodes until a goal node is encountored)\n",
        "optimal solution: lowest path cost\n",
        "\n",
        "tree search: it enumerates all possible paths from the inital state\n",
        "graph search: it also takes into account redundant paths (nodes that have already been visited)\n",
        "\n",
        "# function TREE-SEARCH(problem) returns a solution, or failure\n",
        "# initialize the frontier using the initial state of problem\n",
        "# loop do\n",
        "# if the frontier is empty then return failure\n",
        "# choose a leaf nose and remove it from the frontier\n",
        "# if the node contains a goal state then return the corresponding solution\n",
        "# expand the chosen node, adding the resulting nodes to the frontier\n",
        "\n",
        "# function GRAPH-SEARCH(problem) returns a solution, or failure\n",
        "# initialize the frontier using the initial state of problem\n",
        "# initialize the explored set to be empty\n",
        "# loop do\n",
        "# if the frontier is empty then return failure\n",
        "# choose a leaf node and remove it from the frontier\n",
        "# if the node contains a goal state then return the corresponding solution\n",
        "# add node to the explored set\n",
        "# expand the chosen node, adding the resulting nodes to the frontier\n",
        "# only if not in the frontier of explored set\n",
        "\n",
        "uninformed search: all the same\n",
        "informed search: some nodes better ranked than others\n",
        "\n",
        "BFS: \n",
        "function BREADTH-FIRST-SEARCH returns a solution node or failure\n",
        "node <- NODE(problem.initial)\n",
        "if problem is goal(node.state) then return node\n",
        "frontier <- FIFO queue with node as an element\n",
        "frontier <- {problem initial}\n",
        "while not is empty (frontier) do\n",
        "node <- pop(frontier)\n",
        "for each child in Expand(problem, node) do\n",
        "s <- child.state\n",
        "if problem is goal then return child\n",
        "if s is not in reached then\n",
        "add s to reached add child to frontier\n",
        "return failure\n",
        "\n",
        "function expand(problem, node) yields nodes\n",
        "s <- node.state\n",
        "for each action in problem.actions(s) do\n",
        "s' <- problem.result(s.action)\n",
        "cost <- node.path-cost + problem action-cost(s, action,s')\n",
        "yield node(state = s', parent = node, action = action, path-cost = cost)\n",
        "\n",
        "used:\n",
        "possible infinite paths\n",
        "some solutions have short paths\n",
        "can quickly discard unlikely paths\n",
        "\n",
        "DFS: \n",
        "used\n",
        "space is restricted\n",
        "many possible solutions with long paths, and wrong paths are usually terminated quickly\n",
        "\n",
        "\n",
        "\n",
        "\n",
        " \"\"\"\n",
        "\n",
        "# Definitions of concepts from Module 3.\n",
        "# You can define any bolded term in the textbook, \n",
        "# but you most use your own words for the definitions.\n",
        "# Each definition should be at most 20 words long.\n",
        "module3_definitions = {\n",
        "\"problem-solving agent\" : \"an agent that can formulate a plan via search\",    \n",
        "}\n",
        "\n"
      ],
      "execution_count": 36,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "lvtN3p7ET3Tx",
        "cellView": "form",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1885
        },
        "outputId": "e299311f-3bff-4d66-80c5-212595ee1686"
      },
      "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": 37,
      "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 Your summary here\n\nA problem-solving agent must plan ahead.\nThe computational process that it undertakes is called search.\nIt will consider a sequence of actions that form a path to a goal state.\nSolution is who this sequence is called.\n\nA solution is a fixed sequence of actions it its fully observable, determnistic\nand has a known environment. \n\nIf the envrionment is partioally observable or nondeterministic, then solution \nhas to recommend different future actions based on what percepts it receives. This is called a branching strategy\n\nFormal Definition of a Search Problem:\n1) States (initial state)\n2) Actions (set of actions that can be executed in a state s)\n3) Transition Model (the succesor of the previous state after performing the action)\n4) Path cost (must be additive)\n5) Goal test\n\nFormulation greatly affects combinatorics of search space and therefore\nspeed of search\n\nState space: set of all states reachable from the initial state by any sequence of actions\npath: sequence of actions leadring from one state a, to another state b\nsolution: path from initial state a, to state f, which satisfies the goal test\nFrontier: those states that are available for expanding (as the search proceeds, the frontier expands into the unexplored nodes until a goal node is encountored)\noptimal solution: lowest path cost\n\ntree search: it enumerates all possible paths from the inital state\ngraph search: it also takes into account redundant paths (nodes that have already been visited)\n\n# function TREE-SEARCH(problem) returns a solution, or failure\n# initialize the frontier using the initial state of problem\n# loop do\n# if the frontier is empty then return failure\n# choose a leaf nose and remove it from the frontier\n# if the node contains a goal state then return the corresponding solution\n# expand the chosen node, adding the resulting nodes to the frontier\n\n# function GRAPH-SEARCH(problem) returns a solution, or failure\n# initialize the frontier using the initial state of problem\n# initialize the explored set to be empty\n# loop do\n# if the frontier is empty then return failure\n# choose a leaf node and remove it from the frontier\n# if the node contains a goal state then return the corresponding solution\n# add node to the explored set\n# expand the chosen node, adding the resulting nodes to the frontier\n# only if not in the frontier of explored set\n\nuninformed search: all the same\ninformed search: some nodes better ranked than others\n\nBFS: \nfunction BREADTH-FIRST-SEARCH returns a solution node or failure\nnode <- NODE(problem.initial)\nif problem is goal(node.state) then return node\nfrontier <- FIFO queue with node as an element\nfrontier <- {problem initial}\nwhile not is empty (frontier) do\nnode <- pop(frontier)\nfor each child in Expand(problem, node) do\ns <- child.state\nif problem is goal then return child\nif s is not in reached then\nadd s to reached add child to frontier\nreturn failure\n\nfunction expand(problem, node) yields nodes\ns <- node.state\nfor each action in problem.actions(s) do\ns' <- problem.result(s.action)\ncost <- node.path-cost + problem action-cost(s, action,s')\nyield node(state = s', parent = node, action = action, path-cost = cost)\n\nused:\npossible infinite paths\nsome solutions have short paths\ncan quickly discard unlikely paths\n\nDFS: \nused\nspace is restricted\nmany possible solutions with long paths, and wrong paths are usually terminated quickly\n\n\n\n\n \n\n## Module 3 Definitions\n* **Problem-solving agent** - an agent that can formulate a plan via search\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",
        "\n",
        "# UNIFORM COST SEARCH (UCS)\n",
        "In computer science, uniform-cost search (UCS) is a tree search\n",
        "algorithm used for traversing or searching a weighted tree, tree\n",
        "structure, or graph\n",
        "\n",
        "cost = # of nodes in path-1\n",
        "g(N) = the cost to get to n\n",
        "\n",
        "extension of BFS: expand node with lowest path cost\n",
        "frontier = priority queue ordered by g(n)\n",
        "different from BFS -> tests if a node is a goal state when it is selected for expansion, not when it is added to the frontier\n",
        "updates a node on the frontier if a better path to the same state is found\n",
        "so always enqueues a node before checking whether it is a goal\n",
        "it let us prioritize which paths to explore. Instead of exploring all possible paths equally, it favors lower cost paths. its frontier is a priority queue. this results in cost\" contours\"\n",
        "\n",
        "# GREEDY BEST-FIRST SEARCH\n",
        "select node for expansion with minimal evaluation function f(n)\n",
        "where f(n) is some funciton that includes estimate heuristic h(n) of the remaining distance to goal\n",
        "implement using priority queue\n",
        "f(n) = h(n) -> it expands the node that is estimated to be closest to the goal (heuristic function)\n",
        "it ignores g(n) (the cost to get to n)\n",
        "same as Uniform cost search, but instead of using g(n), it uses f(n)\n",
        "not optimal nor complete (can get stuck in loops)\n",
        "\n",
        "frontier = PriorityQueue()\n",
        "frontier.put(start, 0)\n",
        "came_from = {}\n",
        "came_from[start] = None\n",
        "\n",
        "while not frontier.empty():\n",
        "  current = frontier.get\n",
        "\n",
        "if current == goal:\n",
        "  break\n",
        "\n",
        "for next in graph.neighbors(current):\n",
        "  if next not in came_from:\n",
        "    priority = heuristic(goal, next)\n",
        "    frontier.put(next, priority)\n",
        "    came_from[next] = current\n",
        "\n",
        "# A* SEARCH\n",
        "f(n) = g(n) + h(n)\n",
        "g(n) = actual cost (so far) to reach the node\n",
        "h(n) = estimated cost to get from the node to the goal\n",
        "f(n) = total cost\n",
        "key idea: avoid expanding paths that are already expansive, but expand most promising first\n",
        "implementation: frontier queue as priority queue by increasing f(n)\n",
        "\n",
        "h(n) is admissible if it never overestimates the cost to reach the goal\n",
        "other words, it has to be optmistic\n",
        "if h(n) is admissible, A* is optimal (using tree search)\n",
        "\n",
        "the cost of an optimal solution to a relaxed problem (fewer restrictions) is an admisible heuristic for the original problem\n",
        "\n",
        "if h_2 > h_1, then h_2 dominates h_1 (if optimistic, h_2 is superior)\n",
        "\n",
        "unoiform-cost expands equally in all \"directions\"\n",
        "A* expands mainly toward the goal, but does hedge its bets to ensure optimality\n",
        "\n",
        "\n",
        "\n",
        "\n",
        "Your summary here \"\"\"\n",
        "\n",
        "# Definitions\n",
        "module4_definitions = {\n",
        "\"concept\" : \"definition\",    \n",
        "}\n",
        "\n"
      ],
      "execution_count": 38,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "vqtEs0gHs9sO",
        "cellView": "form",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1752
        },
        "outputId": "f7a6c7f7-c315-4b8a-ffa0-d512b628912f"
      },
      "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\", module3_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": 39,
      "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\nA problem-solving agent must plan ahead.\nThe computational process that it undertakes is called search.\nIt will consider a sequence of actions that form a path to a goal state.\nSolution is who this sequence is called.\n\nA solution is a fixed sequence of actions it its fully observable, determnistic\nand has a known environment. \n\nIf the envrionment is partioally observable or nondeterministic, then solution \nhas to recommend different future actions based on what percepts it receives. This is called a branching strategy\n\nFormal Definition of a Search Problem:\n1) States (initial state)\n2) Actions (set of actions that can be executed in a state s)\n3) Transition Model (the succesor of the previous state after performing the action)\n4) Path cost (must be additive)\n5) Goal test\n\nFormulation greatly affects combinatorics of search space and therefore\nspeed of search\n\nState space: set of all states reachable from the initial state by any sequence of actions\npath: sequence of actions leadring from one state a, to another state b\nsolution: path from initial state a, to state f, which satisfies the goal test\nFrontier: those states that are available for expanding (as the search proceeds, the frontier expands into the unexplored nodes until a goal node is encountored)\noptimal solution: lowest path cost\n\ntree search: it enumerates all possible paths from the inital state\ngraph search: it also takes into account redundant paths (nodes that have already been visited)\n\n# function TREE-SEARCH(problem) returns a solution, or failure\n# initialize the frontier using the initial state of problem\n# loop do\n# if the frontier is empty then return failure\n# choose a leaf nose and remove it from the frontier\n# if the node contains a goal state then return the corresponding solution\n# expand the chosen node, adding the resulting nodes to the frontier\n\n# function GRAPH-SEARCH(problem) returns a solution, or failure\n# initialize the frontier using the initial state of problem\n# initialize the explored set to be empty\n# loop do\n# if the frontier is empty then return failure\n# choose a leaf node and remove it from the frontier\n# if the node contains a goal state then return the corresponding solution\n# add node to the explored set\n# expand the chosen node, adding the resulting nodes to the frontier\n# only if not in the frontier of explored set\n\nuninformed search: all the same\ninformed search: some nodes better ranked than others\n\nBFS: \nfunction BREADTH-FIRST-SEARCH returns a solution node or failure\nnode <- NODE(problem.initial)\nif problem is goal(node.state) then return node\nfrontier <- FIFO queue with node as an element\nfrontier <- {problem initial}\nwhile not is empty (frontier) do\nnode <- pop(frontier)\nfor each child in Expand(problem, node) do\ns <- child.state\nif problem is goal then return child\nif s is not in reached then\nadd s to reached add child to frontier\nreturn failure\n\nfunction expand(problem, node) yields nodes\ns <- node.state\nfor each action in problem.actions(s) do\ns' <- problem.result(s.action)\ncost <- node.path-cost + problem action-cost(s, action,s')\nyield node(state = s', parent = node, action = action, path-cost = cost)\n\nused:\npossible infinite paths\nsome solutions have short paths\ncan quickly discard unlikely paths\n\nDFS: \nused\nspace is restricted\nmany possible solutions with long paths, and wrong paths are usually terminated quickly\n\n\n\n\n \n\n## Module 4 Definitions\n* **Concept** - definition\n",
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "F3FPMzG9yUls"
      },
      "source": [
        "#Module 5 - Adversarial Search and Games"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "iEIOpL7vyWcc"
      },
      "source": [
        "# Russell and Norvig, AIMA chapter 5 \"Adversarial Search\"”\" (5.1-5.3, and 5.5).\n",
        "chapter5_1 = \"\"\" Your summary here \"\"\"\n",
        "chapter5_2 = \"\"\" Your summary here \"\"\"\n",
        "chapter5_3 = \"\"\" Your summary here \"\"\"\n",
        "chapter5_5 = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "# Russell and Norvig, AIMA Chapter 16 “Making Simple Decisions” (16.1-16.3)\n",
        "chapter16_1 = \"\"\" Your summary here \"\"\"\n",
        "chapter16_2 = \"\"\" Your summary here \"\"\"\n",
        "chapter16_3 = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "# Lecture notes \n",
        "module5_lecture_notes = \"\"\" \n",
        "\n",
        "multiagent, static, discrete, fully observable, strategic\n",
        "two players who alternate moves, zero-sum, clear set of legal moves, well defined outcomes\n",
        "\n",
        "alpha-beta pruning:\n",
        "alpha: MAX's current lower bound on MAX's outcome (starts with negative infinity)\n",
        "MAX will never allow a move that could lead to a worse score for MAX than alpha (MAX's best already explored option on path to root)\n",
        "beta: MIN's current upper bound on MIN's outcome\n",
        "MIN will never allow a move that could lead to a better score (for MAX) than beta (MIN's best already explored option on path to root)\n",
        "\n",
        "Your summary here \"\"\"\n",
        "\n",
        "# Definitions\n",
        "module5_definitions = {\n",
        "\"concept\" : \"definition\",    \n",
        "}\n",
        "\n"
      ],
      "execution_count": 47,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "KUc_LgzDvWf-",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 754
        },
        "outputId": "42be1899-0d2e-4a29-f1dc-88188bf0d9ec"
      },
      "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": 48,
      "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 \n\nmultiagent, static, discrete, fully observable, strategic\ntwo players who alternate moves, zero-sum, clear set of legal moves, well defined outcomes\n\nalpha-beta pruning:\nalpha: MAX's current lower bound on MAX's outcome (starts with negative infinity)\nMAX will never allow a move that could lead to a worse score for MAX than alpha (MAX's best already explored option on path to root)\nbeta: MIN's current upper bound on MIN's outcome\nMIN will never allow a move that could lead to a better score (for MAX) than beta (MIN's best already explored option on path to root)\n\nYour 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 = \"\"\" 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",
        "\n",
        "represent the constraints that solutions must satisfy in a uniform declarative language\n",
        "find solutions by general purpose search algorithms with no changes from problem to problem\n",
        "\n",
        "A CSP consists of:\n",
        "1) Finite set of variables\n",
        "2) nonempty domain of possible values for each variable\n",
        "3) finite set of constraints\n",
        "each constraint limits the values that variables can take. a state is an assignment of values to some or all variables\n",
        "an assignment is consistent if it does not violate the constraints\n",
        "is complete when every variable is assigned a value\n",
        "\n",
        "a solution must be complete and consistent\n",
        "\n",
        "applications: map coloring, scheduling problems (job shop scheduling, scheduling the hubble space telescope), floor planning for VLSI, sudoku\n",
        "\n",
        "benefits\n",
        "clean specification of many problems, generic goal, successor function & heuristics\n",
        "\n",
        "CSP knows which variables violate a constraint, and thereby, can focus wehre to search\n",
        "\n",
        "it automatically prunes off all branches that violate constraints\n",
        "\n",
        "CSP Representations\n",
        "1) Constraint graph: nodes are variables, arcs are (binary) constraints\n",
        "2) standard representation pattern (variables with values)\n",
        "a binary CSP: each constraint relates two variables\n",
        "\n",
        "Varieties of CSPs:\n",
        "1) Discrete variables:\n",
        "finite domains -> domain size d -> O(d^n) complete assignments\n",
        "inifite domains: hob scheduling, need a constraint language\n",
        "2) Continuous vairbles\n",
        "\n",
        "Types of constraints:\n",
        "unary: constraints involve a single variable: A != green\n",
        "Binary: constraints involve pairs of variables:  A!= B\n",
        "higher-order constraints involve 3 or more variables\n",
        "Preference (soft constraints): cost optimoation problems, A is better than B\n",
        "\n",
        "CSP as a search problem:\n",
        "initial state is empty assignment\n",
        "sucessor funciton: assign value to any unassigned variable provided that there is not a constraint conflict\n",
        "goal test: the current assignment is complete\n",
        "path cost: a constant cost for every step\n",
        "Solution is always found at depth n, for n variables -> DFS can be used\n",
        "\n",
        "DFS used:\n",
        "n variables of domain size d\n",
        "branding factor at the root is n*d\n",
        "branching factor at next level is (n-1)*d\n",
        "Tree has n!*d^n leaves\n",
        "\n",
        "DFS for CSP with single-variable assignments is called backtracking search\n",
        "Backtracking search is a DFS that chooses values for one variable at a time and backtracks when a variable has no legal values left to assign\n",
        "is the basic uninformed algorithm for CSPs\n",
        "\n",
        "use of heuristics:\n",
        "which variable should be assigned next?\n",
        "1) most constrainted variable -> variable with fewest legal values (Minimum remaing values MRV, heuristic)\n",
        "2) if ties, most constraining variable, variable with most constraints on remainng variables\n",
        "3) least constraining value\n",
        "4) forward checking: keep track of remaining legal values for unassigned variables. Terminate search when any unassigned variable has no remaining legal values\n",
        "it propoagates information from assigned to unassigned variables, but doesn't provide early detection for all failures\n",
        "\n",
        "AC3\n",
        "nodes are variables\n",
        "edges are constraints\n",
        "For a connected pair of nodes X_i, X_j, there are 2 arcs that connect them: (i, j) and (j, i)\n",
        "\n",
        "ARc consistency: simplest form of propagation makes each arc consistent\n",
        "X -> Y is consistent iff for every value of x of X there is some allowed y\n",
        "it detects failure earlier than forward checking\n",
        "\n",
        "inneficiences of WALTZ/ MACK...\n",
        "1) at each iteration, we only need to examine those Xi where at least one neighbor of X_i has lost a value in the previous iteration\n",
        "2) if x_i loses a value only because of arc inconsistencies, with Y_j, we don't need to check Y_j on the enxt iteration\n",
        "3) mremoving a value on X_i can only make Y_j arc-inconsistent with respect to X_i itself. thus we only need to check that (j, i) is still arc consistent\n",
        "\n",
        "o All nodes can be connected to every other node,\n",
        "so each ofn nodes must be compared against n-1 other nodes,\n",
        "so total # of arcs is 2*n*(n-1), i.e. O(n2)\n",
        "o If there are d values, checking arc (i,j) takes O(d2) time\n",
        "o Each arc (i,j) can only be inserted into the queue d times\n",
        "o Worst case complexity: O(n2d3)\n",
        "\n",
        "\n",
        "\n",
        "\n",
        "\n",
        "\n",
        "\n",
        "\n",
        "\n",
        " Your summary here \"\"\"\n",
        "\n",
        "# Definitions\n",
        "module6_definitions = {\n",
        "\"concept\" : \"definition\",    \n",
        "}\n"
      ],
      "execution_count": 49,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "kKWbCsbfxL3R",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1090
        },
        "outputId": "ecd11ec5-ea78-4085-cf1d-9bcbd26da07d"
      },
      "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": 50,
      "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\n\nrepresent the constraints that solutions must satisfy in a uniform declarative language\nfind solutions by general purpose search algorithms with no changes from problem to problem\n\nA CSP consists of:\n1) Finite set of variables\n2) nonempty domain of possible values for each variable\n3) finite set of constraints\neach constraint limits the values that variables can take. a state is an assignment of values to some or all variables\nan assignment is consistent if it does not violate the constraints\nis complete when every variable is assigned a value\n\na solution must be complete and consistent\n\napplications: map coloring, scheduling problems (job shop scheduling, scheduling the hubble space telescope), floor planning for VLSI, sudoku\n\nbenefits\nclean specification of many problems, generic goal, successor function & heuristics\n\nCSP knows which variables violate a constraint, and thereby, can focus wehre to search\n\nit automatically prunes off all branches that violate constraints\n\nCSP Representations\n1) Constraint graph: nodes are variables, arcs are (binary) constraints\n2) standard representation pattern (variables with values)\na binary CSP: each constraint relates two variables\n\nVarieties of CSPs:\n1) Discrete variables:\nfinite domains -> domain size d -> O(d^n) complete assignments\ninifite domains: hob scheduling, need a constraint language\n2) Continuous vairbles\n\nTypes of constraints:\nunary: constraints involve a single variable: A != green\nBinary: constraints involve pairs of variables:  A!= B\nhigher-order constraints involve 3 or more variables\nPreference (soft constraints): cost optimoation problems, A is better than B\n\nCSP as a search problem:\ninitial state is empty assignment\nsucessor funciton: assign value to any unassigned variable provided that there is not a constraint conflict\ngoal test: the current assignment is complete\npath cost: a constant cost for every step\nSolution is always found at depth n, for n variables -> DFS can be used\n\nDFS used:\nn variables of domain size d\nbranding factor at the root is n*d\nbranching factor at next level is (n-1)*d\nTree has n!*d^n leaves\n\nDFS for CSP with single-variable assignments is called backtracking search\nBacktracking search is a DFS that chooses values for one variable at a time and backtracks when a variable has no legal values left to assign\nis the basic uninformed algorithm for CSPs\n\nuse of heuristics:\nwhich variable should be assigned next?\n1) most constrainted variable -> variable with fewest legal values (Minimum remaing values MRV, heuristic)\n2) if ties, most constraining variable, variable with most constraints on remainng variables\n3) least constraining value\n4) forward checking: keep track of remaining legal values for unassigned variables. Terminate search when any unassigned variable has no remaining legal values\nit propoagates information from assigned to unassigned variables, but doesn't provide early detection for all failures\n\nAC3\nnodes are variables\nedges are constraints\n\n\n\n\n\n\n\n\n\n\n\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 = \"\"\" 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",
        "\n",
        "Knowledge-based agents use a process of reasoning over an internal\n",
        "representation of knowledge to decide what action to take.\n",
        "our problem-solving agents have performed a search over states in order to\n",
        "find a plan. The representation of states has been atomic\n",
        "\n",
        "Logic can serve as a general class of representations for knowledge-based agents.\n",
        "Here we are going to examine Propositional Logic.\n",
        "• KB consists of sentences in the representation language\n",
        "• Representation language has a syntax that specifies sentences that are well-formed\n",
        "• A logic defines the semantics of the sentences, which is their meaning\n",
        "• The semantics defines the truth of each sentence with respect to a possible world,\n",
        "which we will often call a model.\n",
        "\n",
        "• Models are mathematical abstractions that have a fixed set of truth values which\n",
        "are {true, false} for each sentence.\n",
        "• If sentence 𝛂 is true in model m then we say\n",
        "• m satisfies 𝛂, or\n",
        "• m is a model of 𝛂\n",
        "• We use the notation M(𝛂) to mean the set of all models of 𝛂.\n",
        "For instance, 𝛂 could be a sentence that means “there is no pit in [2,2]”. In that case,\n",
        "M(𝛂) would be all instances of Wampa World where [2,2] doesn’t have a pit.\n",
        "\n",
        "In plain English, entailment is the idea that a sentence follows logically from another\n",
        "sentence\n",
        "\n",
        "Entailment can be applied to derive conclusions, which is the process of logical\n",
        "inference.\n",
        "\n",
        "Two sentences 𝛂 and β are logically equivalent if they are true in the same set of\n",
        "models.\n",
        "\n",
        "\n",
        "Your summary here \"\"\"\n",
        "\n",
        "# Definitions\n",
        "module7_definitions = {\n",
        "\"concept\" : \"definition\",    \n",
        "}\n",
        "\n"
      ],
      "execution_count": 44,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "lXNcHuKjyNXa",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 541
        },
        "outputId": "c88ac867-7599-4b00-aa2c-54cc0fa01040"
      },
      "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": 45,
      "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": 8642
        },
        "id": "T3cm1WV542_a",
        "outputId": "85b627d6-bed6-41f0-cfd0-33bceec5e1d3"
      },
      "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": 51,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 1: Rational Agents and Task Environments\n## AIMA Chapter 1.1 What is AI?\n $$\\alpha \\implies \\beta$$\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 Your summary here \n\n## Module 1 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# Module 2: Python\n## Module 2 Lecture Notes\n\n# use y = x[:] to get a (shallow) copy of any sequence, ie. a new object of the same value\n# t = (23, 'abc', 4.56, (2,3), 'def')\n# t[1:4] #slicing ends before last index\n# ('abc', 4.56, (2,3))\n# t[1:-1] #using negative index\n# ('abc', 4.56, (2,3))\n# t[1:-1:2] # selection of every nth item.\n# ('abc', (2,3))\n# t[:2] # copy from beginning of sequence\n# (23, 'abc')\n# t[2:] # copy to the very end of the sequence\n# (4.56, (2,3), 'def')\n# t[::-1] # reverses the list\n# (‘def’, (2,3), 4.56, ‘abc’, 23)\n\n# List Comprehesion [ expression for name in list ] \n# li = [3, 6, 2, 7, 1, 9]\n# [elem * 2 for elem in li if elem > 4]\n# [12, 14, 18]\n\n# def extract_and_apply(l, p, f):\n  #  return [f(x) for x in l if p(x)]\n# l = [2, 4, 6, 3]\n# f = lambda x: x*x\n# p = lambda x: x < 4\n# print(extract_and_apply(l, p, f))\n\n# def concatenate(seqs):\n    # result = []\n    # for x in seqs:\n    #     for y in x:\n    #         result.append(y)\n    # return result\n   # return [y for x in seqs for y in x]\n# concatenate([\"abc\", (0, [0])])\n # ['a', 'b', 'c', 0, [0]]\n\n# def transpose(matrix):\n  #  return [[matrix[y][x] for y in range(len(matrix))] for x in range(len(matrix[0]))]\n# transpose([[1, 2], [3, 4], [5, 6]])\n# [[1, 3, 5], [2, 4, 6]]\n\n\n\n## Module 2 Definitions\n* **Mutability** - your definition here\n\n\n# Module 3: Search Problems\n## AIMA Chapter 3.1 Problem-Solving Agents\n Your summary here \n\n## AIMA Chapter 3.2 Example Problems\n Your summary here \n\n## AIMA Chapter 3.3 Search Algorithms\n Your summary here \n\n## AIMA Chapter 3.4 Uninformed Search Strategies\n Your summary here \n\n## Module 3 Lecture Notes\n Your summary here\n\nA problem-solving agent must plan ahead.\nThe computational process that it undertakes is called search.\nIt will consider a sequence of actions that form a path to a goal state.\nSolution is who this sequence is called.\n\nA solution is a fixed sequence of actions it its fully observable, determnistic\nand has a known environment. \n\nIf the envrionment is partioally observable or nondeterministic, then solution \nhas to recommend different future actions based on what percepts it receives. This is called a branching strategy\n\nFormal Definition of a Search Problem:\n1) States (initial state)\n2) Actions (set of actions that can be executed in a state s)\n3) Transition Model (the succesor of the previous state after performing the action)\n4) Path cost (must be additive)\n5) Goal test\n\nFormulation greatly affects combinatorics of search space and therefore\nspeed of search\n\nState space: set of all states reachable from the initial state by any sequence of actions\npath: sequence of actions leadring from one state a, to another state b\nsolution: path from initial state a, to state f, which satisfies the goal test\nFrontier: those states that are available for expanding (as the search proceeds, the frontier expands into the unexplored nodes until a goal node is encountored)\noptimal solution: lowest path cost\n\ntree search: it enumerates all possible paths from the inital state\ngraph search: it also takes into account redundant paths (nodes that have already been visited)\n\n# function TREE-SEARCH(problem) returns a solution, or failure\n# initialize the frontier using the initial state of problem\n# loop do\n# if the frontier is empty then return failure\n# choose a leaf nose and remove it from the frontier\n# if the node contains a goal state then return the corresponding solution\n# expand the chosen node, adding the resulting nodes to the frontier\n\n# function GRAPH-SEARCH(problem) returns a solution, or failure\n# initialize the frontier using the initial state of problem\n# initialize the explored set to be empty\n# loop do\n# if the frontier is empty then return failure\n# choose a leaf node and remove it from the frontier\n# if the node contains a goal state then return the corresponding solution\n# add node to the explored set\n# expand the chosen node, adding the resulting nodes to the frontier\n# only if not in the frontier of explored set\n\nuninformed search: all the same\ninformed search: some nodes better ranked than others\n\nBFS: \nfunction BREADTH-FIRST-SEARCH returns a solution node or failure\nnode <- NODE(problem.initial)\nif problem is goal(node.state) then return node\nfrontier <- FIFO queue with node as an element\nfrontier <- {problem initial}\nwhile not is empty (frontier) do\nnode <- pop(frontier)\nfor each child in Expand(problem, node) do\ns <- child.state\nif problem is goal then return child\nif s is not in reached then\nadd s to reached add child to frontier\nreturn failure\n\nfunction expand(problem, node) yields nodes\ns <- node.state\nfor each action in problem.actions(s) do\ns' <- problem.result(s.action)\ncost <- node.path-cost + problem action-cost(s, action,s')\nyield node(state = s', parent = node, action = action, path-cost = cost)\n\nused:\npossible infinite paths\nsome solutions have short paths\ncan quickly discard unlikely paths\n\nDFS: \nused\nspace is restricted\nmany possible solutions with long paths, and wrong paths are usually terminated quickly\n\n\n\n\n \n\n## Module 3 Definitions\n* **Problem-solving agent** - an agent that can formulate a plan via search\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 Your summary here\n\nA problem-solving agent must plan ahead.\nThe computational process that it undertakes is called search.\nIt will consider a sequence of actions that form a path to a goal state.\nSolution is who this sequence is called.\n\nA solution is a fixed sequence of actions it its fully observable, determnistic\nand has a known environment. \n\nIf the envrionment is partioally observable or nondeterministic, then solution \nhas to recommend different future actions based on what percepts it receives. This is called a branching strategy\n\nFormal Definition of a Search Problem:\n1) States (initial state)\n2) Actions (set of actions that can be executed in a state s)\n3) Transition Model (the succesor of the previous state after performing the action)\n4) Path cost (must be additive)\n5) Goal test\n\nFormulation greatly affects combinatorics of search space and therefore\nspeed of search\n\nState space: set of all states reachable from the initial state by any sequence of actions\npath: sequence of actions leadring from one state a, to another state b\nsolution: path from initial state a, to state f, which satisfies the goal test\nFrontier: those states that are available for expanding (as the search proceeds, the frontier expands into the unexplored nodes until a goal node is encountored)\noptimal solution: lowest path cost\n\ntree search: it enumerates all possible paths from the inital state\ngraph search: it also takes into account redundant paths (nodes that have already been visited)\n\n# function TREE-SEARCH(problem) returns a solution, or failure\n# initialize the frontier using the initial state of problem\n# loop do\n# if the frontier is empty then return failure\n# choose a leaf nose and remove it from the frontier\n# if the node contains a goal state then return the corresponding solution\n# expand the chosen node, adding the resulting nodes to the frontier\n\n# function GRAPH-SEARCH(problem) returns a solution, or failure\n# initialize the frontier using the initial state of problem\n# initialize the explored set to be empty\n# loop do\n# if the frontier is empty then return failure\n# choose a leaf node and remove it from the frontier\n# if the node contains a goal state then return the corresponding solution\n# add node to the explored set\n# expand the chosen node, adding the resulting nodes to the frontier\n# only if not in the frontier of explored set\n\nuninformed search: all the same\ninformed search: some nodes better ranked than others\n\nBFS: \nfunction BREADTH-FIRST-SEARCH returns a solution node or failure\nnode <- NODE(problem.initial)\nif problem is goal(node.state) then return node\nfrontier <- FIFO queue with node as an element\nfrontier <- {problem initial}\nwhile not is empty (frontier) do\nnode <- pop(frontier)\nfor each child in Expand(problem, node) do\ns <- child.state\nif problem is goal then return child\nif s is not in reached then\nadd s to reached add child to frontier\nreturn failure\n\nfunction expand(problem, node) yields nodes\ns <- node.state\nfor each action in problem.actions(s) do\ns' <- problem.result(s.action)\ncost <- node.path-cost + problem action-cost(s, action,s')\nyield node(state = s', parent = node, action = action, path-cost = cost)\n\nused:\npossible infinite paths\nsome solutions have short paths\ncan quickly discard unlikely paths\n\nDFS: \nused\nspace is restricted\nmany possible solutions with long paths, and wrong paths are usually terminated quickly\n\n\n\n\n \n\n## Module 4 Definitions\n* **Concept** - definition\n\n\n# Module 5: Adversarial Search and Games\n## AIMA Chapter 5.1 Game Theory\n Your summary here \n\n## AIMA Chapter 5.2 Optimal Decisions in Games\n Your summary here \n\n## AIMA Chapter 5.3 Heuristic Alpha–Beta Tree Search\n Your summary here \n\n## AIMA Chapter 5.5 Stochastic Games\n Your summary here \n\n## AIMA Chapter 16.1 Combining Beliefs and Desires under Uncertainty\n Your summary here \n\n## AIMA Chapter 16.2 The Basis of Utility Theory\n Your summary here \n\n## AIMA Chapter 16.3 Utility Functions\n Your summary here \n\n## Module 5 Lecture Notes\n \n\nmultiagent, static, discrete, fully observable, strategic\ntwo players who alternate moves, zero-sum, clear set of legal moves, well defined outcomes\n\nalpha-beta pruning:\nalpha: MAX's current lower bound on MAX's outcome (starts with negative infinity)\nMAX will never allow a move that could lead to a worse score for MAX than alpha (MAX's best already explored option on path to root)\nbeta: MIN's current upper bound on MIN's outcome\nMIN will never allow a move that could lead to a better score (for MAX) than beta (MIN's best already explored option on path to root)\n\nYour summary here \n\n## Module 5 Definitions\n* **Concept** - definition\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\n\nrepresent the constraints that solutions must satisfy in a uniform declarative language\nfind solutions by general purpose search algorithms with no changes from problem to problem\n\nA CSP consists of:\n1) Finite set of variables\n2) nonempty domain of possible values for each variable\n3) finite set of constraints\neach constraint limits the values that variables can take. a state is an assignment of values to some or all variables\nan assignment is consistent if it does not violate the constraints\nis complete when every variable is assigned a value\n\na solution must be complete and consistent\n\napplications: map coloring, scheduling problems (job shop scheduling, scheduling the hubble space telescope), floor planning for VLSI, sudoku\n\nbenefits\nclean specification of many problems, generic goal, successor function & heuristics\n\nCSP knows which variables violate a constraint, and thereby, can focus wehre to search\n\nit automatically prunes off all branches that violate constraints\n\nCSP Representations\n1) Constraint graph: nodes are variables, arcs are (binary) constraints\n2) standard representation pattern (variables with values)\na binary CSP: each constraint relates two variables\n\nVarieties of CSPs:\n1) Discrete variables:\nfinite domains -> domain size d -> O(d^n) complete assignments\ninifite domains: hob scheduling, need a constraint language\n2) Continuous vairbles\n\nTypes of constraints:\nunary: constraints involve a single variable: A != green\nBinary: constraints involve pairs of variables:  A!= B\nhigher-order constraints involve 3 or more variables\nPreference (soft constraints): cost optimoation problems, A is better than B\n\nCSP as a search problem:\ninitial state is empty assignment\nsucessor funciton: assign value to any unassigned variable provided that there is not a constraint conflict\ngoal test: the current assignment is complete\npath cost: a constant cost for every step\nSolution is always found at depth n, for n variables -> DFS can be used\n\nDFS used:\nn variables of domain size d\nbranding factor at the root is n*d\nbranching factor at next level is (n-1)*d\nTree has n!*d^n leaves\n\nDFS for CSP with single-variable assignments is called backtracking search\nBacktracking search is a DFS that chooses values for one variable at a time and backtracks when a variable has no legal values left to assign\nis the basic uninformed algorithm for CSPs\n\nuse of heuristics:\nwhich variable should be assigned next?\n1) most constrainted variable -> variable with fewest legal values (Minimum remaing values MRV, heuristic)\n2) if ties, most constraining variable, variable with most constraints on remainng variables\n3) least constraining value\n4) forward checking: keep track of remaining legal values for unassigned variables. Terminate search when any unassigned variable has no remaining legal values\nit propoagates information from assigned to unassigned variables, but doesn't provide early detection for all failures\n\nAC3\nnodes are variables\nedges are constraints\n\n\n\n\n\n\n\n\n\n\n\n Your summary here \n\n## Module 6 Definitions\n* **Concept** - definition\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 Your summary here \n\n## Module 7 Definitions\n* **Concept** - definition\n",
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {}
        }
      ]
    }
  ]
}