{
  "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",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "lzaavW96tcxM",
        "outputId": "a0f53276-fe2a-4592-fcdb-c02a0dccdbad"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "The example summary is 116 words long, so you could write an additional 384 words.\n"
          ]
        }
      ],
      "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)))"
      ]
    },
    {
      "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",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "8DvZ57A-djo1",
        "outputId": "9117b995-7eac-438d-806d-eac8265dbbfd"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "The length in words is 500\n",
            "The length in characters is 3030\n"
          ]
        }
      ],
      "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))"
      ]
    },
    {
      "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",
      "execution_count": 43,
      "metadata": {
        "id": "2RECnJArJew4"
      },
      "outputs": [],
      "source": [
        "name = \"\"\n",
        "permission = True\n",
        "anonymous = True"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "GZZXyrV-xuAp"
      },
      "source": [
        "# Module 1 - Intro to AI"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "Y2NfE1CKxzS-"
      },
      "outputs": [],
      "source": [
        "# Russell and Norvig, AIMA 4th Edition, Chapter 1 “Introduction”, Section 1.1 “What is AI”\n",
        "\n",
        "chapter1_1 = \"\"\" Chapter 1.1 summary. \"\"\" \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 = \"\"\" An agent is specified by an agent function f:P -> a that maps a\n",
        "sequence of percept vectors P to an action a from a set A. \\\n",
        "In other words, an agent takes in inputs from its perceptrons and as a result, acts accordingly\\\n",
        "An agent function runs on the physical architecture to produce an agent function.\n",
        "Performance measures are used to evaluate an agents behavior. \\\n",
        "It is important to make the performance measure based on what it should achieve over how it should achieve it. \\\n",
        "We want to maximize the expected value of an action for each possible input according to the performance measure. \\\n",
        "PEAS - performance measure, environment, actuators, sensors. \\\n",
        "fully observable vs partially observable, deterministic vs nondeterministic vs stochastic, episodic vs sequential, \\\n",
        "static vs dynamic, discrete vs continuous, single agent vs multi agent \\\n",
        "When something behavior can best be described as having its own performance\n",
        "measure, then we should consider it to be an agent. \\\n",
        "\"\"\"\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\" : \"is the agent’s perceptual inputs at any given instance\",\n",
        "\"sensors\": \"what an agent uses to sense the environment\"\n",
        "}\n",
        "\n"
      ]
    },
    {
      "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",
      "execution_count": null,
      "metadata": {
        "cellView": "form",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 803
        },
        "id": "gYYeNcdM_maE",
        "outputId": "2d4a4835-0394-4779-e6af-026e485eee26"
      },
      "outputs": [
        {
          "data": {
            "text/markdown": [
              "# Module 1: Rational Agents and Task Environments\n",
              "## AIMA Chapter 1.1 What is AI?\n",
              " Chapter 1.1 summary. \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",
              " An agent is specified by an agent function f:P -> a that maps a\n",
              "sequence of percept vectors P to an action a from a set A. In other words, an agent takes in inputs from its perceptrons and as a result, acts accordinglyAn agent function runs on the physical architecture to produce an agent function.\n",
              "Performance measures are used to evaluate an agents behavior. It is important to make the performance measure based on what it should achieve over how it should achieve it. We want to maximize the expected value of an action for each possible input according to the performance measure. PEAS - performance measure, environment, actuators, sensors. fully observable vs partially observable, deterministic vs nondeterministic vs stochastic, episodic vs sequential, static vs dynamic, discrete vs continuous, single agent vs multi agent When something behavior can best be described as having its own performance\n",
              "measure, then we should consider it to be an agent. \n",
              "\n",
              "## Module 1 Definitions\n",
              "* **Agent** - anything that can perceive and act in an environment\n",
              "* **Percept** - is the agent’s perceptual inputs at any given instance\n",
              "* **Sensors** - what an agent uses to sense the environment\n"
            ],
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "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))"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "9xRbdqDox2zD"
      },
      "source": [
        "#Module 2 - Python"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "DpBvu7EMx7sy",
        "outputId": "d80d7227-d66a-472d-bc62-e6358423fc1a"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "The length in words is 408\n",
            "The length in characters is 2403\n"
          ]
        }
      ],
      "source": [
        "# No readings for this module.  Instead you can summarize the lecture instead.\n",
        "\n",
        "# Lecture notes \n",
        "module2_lecture_notes = \"\"\" Python is strongly typed, which means the interpreter does not \\\n",
        "allow things incompatible with that type. For example, string + int is not allowed. \\\n",
        "Python is dynamically typed, or the type of varible is determined at runtime. \\\n",
        "Strings can be created using single or double quotes. \\\n",
        "Can concatenate strings using + (creates a copy). \\\n",
        "Strings can be created with % as in C (\"%s can speak %d languages\" % (\"C3PO\", 6000000)). \\\n",
        "Lists are mutable, use x[:] to get a shallow copy. \\\n",
        "== checks if two objects have the same value, use is to check if two variables point to same object. \\\n",
        "Tuples and strings are an immutable sequences, and tuples can contain mixed types ex. (5, \"foo\"). \\\n",
        "Slicing - creates copy from [start:end:step] \\\n",
        "list methods - append adds element to the end, insert(i, elt) inserts elt at index i, \\\n",
        "index(elt) finds first index of elt, count(elt) returns num of occurences, remove(elt) removes it, \\\n",
        "reverse reverses list in place, sort sorts in place (can add a lambda function). \\\n",
        "Sorted(list) returns a copy of a sorted list. \\\n",
        "Dictionaries require immutable keys (so tuples and strings are fine) \\\n",
        "dict.keys() returns list of keys, dict.values() returns list of values, dict.items() returns (K, V) pair of items.\\\n",
        "Functions can return multiple values. Functions do not allow for overloading (multiple functions with same name). \\\n",
        "Can also provide default values for parameters in a function. Can also specify arguments out of order by providing keywords (index=5)\\\n",
        "If you want to accept variable number of arguments, use *args or **kwargs (keyword arguments) which takes in a pointer to a list or dict respectively. \\\n",
        "Functions in python are first class objects. \\\n",
        "Can create classes in python, and redefine certain magic methods (__init__, __len__, __copy__, __cmp__). \\\n",
        "if __name__ == '__main__' is Pythons main method. \\\n",
        "range(i, j) returns an iterator from i to j (non including j). Use in to interate through an iterable object \\\n",
        "List comprehension - [3 * x  for x in list], returns copy of a new list. [3 * x  for x in list if x > 2], can add if statements. \\\n",
        "Dict comprehension - {k:v for k,v in list}, where list is a list of size 2 tuples. \\\n",
        "Set comprehension - {x for x in list}. \\\n",
        "Iterators - i.next() returns next elemen, but throws error if no more elements. Iterators do not have hasNext, so catch StopIteration. \\\n",
        "Generators - use yield to yield elements in a generator (returns an iterator over yielded elements).\n",
        "\"\"\"\n",
        "\n",
        "# Each definition should be at most 20 words long.\n",
        "module2_definitions = {\n",
        "\"mutability\" : \"your definition here\",\n",
        "}\n",
        "\n",
        "print(\"The length in words is\", len(module2_lecture_notes.split(' ')))\n",
        "print(\"The length in characters is\", len(module2_lecture_notes))"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "cellView": "form",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 376
        },
        "id": "ydOK__lwWgdp",
        "outputId": "f7db06bd-8bfc-4835-cb3a-841f8cfec555"
      },
      "outputs": [
        {
          "data": {
            "text/markdown": [
              "# Module 2: Python\n",
              "## Module 2 Lecture Notes\n",
              " Python is strongly typed, which means the interpreter does not allow things incompatible with that type. For example, string + int is not allowed. Python is dynamically typed, or the type of varible is determined at runtime. Strings can be created using single or double quotes. Can concatenate strings using + (creates a copy). Strings can be created with % as in C (\"%s can speak %d languages\" % (\"C3PO\", 6000000)). Lists are mutable, use x[:] to get a shallow copy. == checks if two objects have the same value, use is to check if two variables point to same object. Tuples and strings are an immutable sequences, and tuples can contain mixed types ex. (5, \"foo\"). Slicing - creates copy from [start:end:step] list methods - append adds element to the end, insert(i, elt) inserts elt at index i, index(elt) finds first index of elt, count(elt) returns num of occurences, remove(elt) removes it, reverse reverses list in place, sort sorts in place (can add a lambda function). Sorted(list) returns a copy of a sorted list. Dictionaries require immutable keys (so tuples and strings are fine) dict.keys() returns list of keys, dict.values() returns list of values, dict.items() returns (K, V) pair of items.Functions can return multiple values. Functions do not allow for overloading (multiple functions with same name). Can also provide default values for parameters in a function. Can also specify arguments out of order by providing keywords (index=5)If you want to accept variable number of arguments, use *args or **kwargs (keyword arguments) which takes in a pointer to a list or dict respectively. Functions in python are first class objects.\n",
              "\n",
              "\n",
              "\n",
              "## Module 2 Definitions\n",
              "* **Mutability** - your definition here\n"
            ],
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "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))"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "46MQLR-Gx8dZ"
      },
      "source": [
        "#Module 3 - Search Problems"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "BN0b1eVYx-nd"
      },
      "outputs": [],
      "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 = \"\"\" search problems have states, actions, transition models, path cost, and goal tests. /\n",
        " Initially states just contain the initial state. /\n",
        " Then generate successors of an action by applying transition model to the state and each possible action. /\n",
        " Tree search - root is initial state, children are successors, and edges are actions that take a node to its successor. /\n",
        " Different paths to the same node are distinct, so repeated states can lead to exponential algorithms. /\n",
        " Graph search stores visited states, so it only expands unvisited states. /\n",
        " b is max branching factor, d is depth, and m is maximum length of any path. /\n",
        "BFS is complete and optimal if the cost is 1 per edge traversed, O(b^d) time complexity and O(b^d) space complexity. /\n",
        "DFS is not complete or optimal. O(b^d) time complexity and O(bm) space complexity. /\n",
        "Iterative deepening - run dfs with a depth limit of i, and increment i in each iteration. /\n",
        "Repeat until goal is found or limit is reached.  /\n",
        "It is complete, optimal, O(b^m) time complexity and O(bm) space complexity. \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",
        "\"reflex agent\" : \"agent that selects action based on current input, ignoring the past results\",\n",
        "\"problem-solving agent\" : \"an agent that can formulate a plan via search\",\n",
        "\"states\": \"the set of possible configurations of the problem.\",\n",
        "\"actions\": \"the set of actions that can be executed in s, that are applicable in s.\",\n",
        "\"transition model\": \"a mapping of state and action pairs to s_r, the new state after performing action a in state s\",\n",
        "\"path cost\":  \"Must be additive. step cost is c(x,a,y) >= 0. Action a moves us from state x to y\",\n",
        "\"goal test\": \"test used to check if s is a goal state\",\n",
        "\"state space\": \"set of all reachable states from inital state\",\n",
        "\"path\": \"a sequence of actions leading from one state sj to another state sk\",\n",
        "\"Solution\": \"a path from the initial state si to a state sf that satisfies the goal test\",\n",
        "\"Search tree:\": \"a way to represent seen states. Root is the initial state, leaves are successor states.\",\n",
        "\"Frontier\": \"states available for expanding (states in queue)\",\n",
        "\"Uninformed search\": \"All non-goal nodes in frontier look equally good\",\n",
        "\"Informed search\": \"Some non-goal nodes can be ranked above others.\", \n",
        "\"complete\": \"an algorithm always finds a solution\",\n",
        "\"optimal\": \"an algorithm finds the lowest cost solution\"\n",
        "}\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "cellView": "form",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 824
        },
        "id": "lvtN3p7ET3Tx",
        "outputId": "3a808c35-b931-449d-e579-386651c35b71"
      },
      "outputs": [
        {
          "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",
              " search problems have states, actions, transition models, path cost, and goal tests. /\n",
              " Initially states just contain the initial state. /\n",
              " Then generate successors of an action by applying transition model to the state and each possible action. /\n",
              " Tree search - root is initial state, children are successors, and edges are actions that take a node to its successor. /\n",
              " Different paths to the same node are distinct, so repeated states can lead to exponential algorithms. /\n",
              " Graph search stores visited states, so it only expands unvisited states. /\n",
              " b is max branching factor, d is depth, and m is maximum length of any path. /\n",
              "BFS is complete and optimal if the cost is 1 per edge traversed, O(b^d) time complexity and O(b^d) space complexity. /\n",
              "DFS is not complete or optimal. O(b^d) time complexity and O(bm) space complexity. /\n",
              "Iterative deepening - run dfs with a depth limit of i, and increment i in each iteration. /\n",
              "Repeat until goal is found or limit is reached.  /\n",
              "It is complete, optimal, O(b^m) time complexity and O(bm) space complexity. \n",
              "\n",
              " \n",
              "\n",
              "## Module 3 Definitions\n",
              "* **Reflex agent** - agent that selects action based on current input, ignoring the past results\n",
              "* **Problem-solving agent** - an agent that can formulate a plan via search\n",
              "* **States** - the set of possible configurations of the problem.\n",
              "* **Actions** - the set of actions that can be executed in s, that are applicable in s.\n",
              "* **Transition model** - a mapping of state and action pairs to s_r, the new state after performing action a in state s\n",
              "* **Path cost** - Must be additive. step cost is c(x,a,y) >= 0. Action a moves us from state x to y\n",
              "* **Goal test** - test used to check if s is a goal state\n",
              "* **State space** - set of all reachable states from inital state\n",
              "* **Path** - a sequence of actions leading from one state sj to another state sk\n",
              "* **Solution** - a path from the initial state si to a state sf that satisfies the goal test\n",
              "* **Search tree:** - a way to represent seen states. Root is the initial state, leaves are successor states.\n",
              "* **Frontier** - states available for expanding (states in queue)\n",
              "* **Uninformed search** - All non-goal nodes in frontier look equally good\n",
              "* **Informed search** - Some non-goal nodes can be ranked above others.\n",
              "* **Complete** - an algorithm always finds a solution\n",
              "* **Optimal** - an algorithm finds the lowest cost solution\n"
            ],
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "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))"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "WHREsHSSyA-h"
      },
      "source": [
        "#Module 4 - Informed Search"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "tuFC8w7CyCns"
      },
      "outputs": [],
      "source": [
        "# Russell and Norvig, AIMA Chapter 3 “Problem Solving by Search” (3.5-3.6)\n",
        "chapter3_5 = \"\"\" Your summary here \"\"\"\n",
        "chapter3_6 = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "\n",
        "# Lecture notes \n",
        "module4_lecture_notes = \"\"\" Uniform cost search - BFS but expand node with lowest path cost. /\n",
        "However, only check if a state is a goal when selected for expansion, rather than when adding to the queue. /\n",
        "\n",
        "Greedy best first search - expand nodes with minimal h(n) values. Not optimal or complete \n",
        "A* search - Expand nodes with lowest g(n) + f(n) values. /\n",
        "Heuristic is admissable if it never overestimates the cost to reach the goal. If h is admissable, then A* is optimal. /\n",
        "The cost of an optimal solution to a relaxed problem is an admissible heuristic for the original problem. /\n",
        "If h2(n) ≥ h1(n) for all n (both admissible) then h2 dominates h1. /\n",
        "h*(n) or oracle heuristic, is the true distance from n to the goal. /\n",
        "\"\"\"\n",
        "\n",
        "# Definitions\n",
        "module4_definitions = {\n",
        "\"f(n)\" : \"function used inthe queue to order by polling\",\n",
        "\"g(n)\": \"cost from intial to current state\",\n",
        "\"h(n)\": \"heuristic or estimated cost from current node to a goal\",\n",
        "\"Relaxed Problem\": \"A problem with fewer restrictions on the actions than the original\",\n",
        "\n",
        "}\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "cellView": "form",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 480
        },
        "id": "vqtEs0gHs9sO",
        "outputId": "242e0432-0a72-4bb1-cc61-f9001e5c0dae"
      },
      "outputs": [
        {
          "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",
              " Uniform cost search - BFS but expand node with lowest path cost. /\n",
              "However, only check if a state is a goal when selected for expansion, rather than when adding to the queue. /\n",
              "\n",
              "Greedy best first search - expand nodes with minimal h(n) values. Not optimal or complete \n",
              "A* search - Expand nodes with lowest g(n) + f(n) values. /\n",
              "Heuristic is admissable if it never overestimates the cost to reach the goal. If h is admissable, then A* is optimal. /\n",
              "The cost of an optimal solution to a relaxed problem is an admissible heuristic for the original problem. /\n",
              "If h2(n) ≥ h1(n) for all n (both admissible) then h2 dominates h1. /\n",
              "h*(n) or oracle heuristic, is the true distance from n to the goal. /\n",
              "\n",
              "\n",
              "## Module 4 Definitions\n",
              "* **F(n)** - function used inthe queue to order by polling\n",
              "* **G(n)** - cost from intial to current state\n",
              "* **H(n)** - heuristic or estimated cost from current node to a goal\n",
              "* **Relaxed problem** - A problem with fewer restrictions on the actions than the original\n"
            ],
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "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))"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "F3FPMzG9yUls"
      },
      "source": [
        "#Module 5 - Adversarial Search and Games"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "iEIOpL7vyWcc"
      },
      "outputs": [],
      "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",
        "Simplist game definition - multiagent, static (game doesnt change while thinking), /\n",
        "discrete(finite set of percepts and actions), fully observable, /\n",
        "strategic(The next state is determined by the current state and the action executed\n",
        "by the agent and the actions of one other agent. /\n",
        "In simple games two players - max and min, and max moves first. /\n",
        "Start at max mode, then evaluate children. If at a max layer, choose max values of children. If at min node, choose min of children. /\n",
        "alpha beta pruning - store alpha and beta values where alpha is the highest value currently at the max layer. /\n",
        "beta is the lowest value currently at the min layer. If current value is lower than alpha in min layer or opposite in max then no need to traverse that branch. /\n",
        "In expectimax, now you base decisions off of expected value. \n",
        "\n",
        ") \"\"\"\n",
        "\n",
        "# Definitions\n",
        "module5_definitions = {\n",
        "\"Zero-sum\" : \"one player’s loss is another’s gain\",\n",
        "\n",
        "}\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "cellView": "form",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 775
        },
        "id": "KUc_LgzDvWf-",
        "outputId": "750677ad-3de4-46cd-e231-953227753fea"
      },
      "outputs": [
        {
          "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",
              "Simplist game definition - multiagent, static (game doesnt change while thinking), /\n",
              "discrete(finite set of percepts and actions), fully observable, /\n",
              "strategic(The next state is determined by the current state and the action executed\n",
              "by the agent and the actions of one other agent. /\n",
              "In simple games two players - max and min, and max moves first. /\n",
              "Start at max mode, then evaluate children. If at a max layer, choose max values of children. If at min node, choose min of children. /\n",
              "alpha beta pruning - store alpha and beta values where alpha is the highest value currently at the max layer. /\n",
              "beta is the lowest value currently at the min layer. If current value is lower than alpha in min layer or opposite in max then no need to traverse that branch. /\n",
              "In expectimax, now you base decisions off of expected value. \n",
              "\n",
              ") \n",
              "\n",
              "## Module 5 Definitions\n",
              "* **Zero-sum** - one player’s loss is another’s gain\n"
            ],
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "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))"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "qVSQhTVSyYYO"
      },
      "source": [
        "#Module 6 - \"Constraint Satisfaction Problems\""
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "Wm4mfW82yaRH"
      },
      "outputs": [],
      "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 = \"\"\" CSPs contain a finite set of variables, and a domain of possible values a variable can take. /\n",
        "Constraints are added between variables to limit values the variables can take. /\n",
        "CSP solutions are consistant and complete (often optimal does not have any meaning in these problems). /\n",
        "Discrete variables - with n variables and d domain size there are d^n configurations. \n",
        "CSPs can be represented as search problems with constant path cost. Can apply dfs to this since max depth is n. /\n",
        "Can improve this approach by apllying heuristics to backtracking. / \n",
        "Forward Checking - update the remaining legal values for unassigned variables. Terminate when unassigned variable has no legal values. /\n",
        "Inference (Constraint Propogation) - for constraint (X_i, X_j), remove x in X if there are no values that are legal with it in X_j (O(d^2)). /\n",
        "AC-3 - If you remove a value from (X_i) add (X_k, X_i) to queue for all k / {j} neighbors of X_i. Runtime n^2d^3. For planar graphs - nd^3. /\n",
        "\n",
        "\"\"\"\n",
        "\n",
        "# Definitions\n",
        "module6_definitions = {\n",
        "\"consistent\" : \"the current state does not violate any constraints\",\n",
        "\"complete\": \"every variable is assigned a value\",\n",
        "\"Most constrained\": \"choose variable with fewest legal values.\",\n",
        "\"Most constraining variable\": \"choose variable that has the most constraints on remaining variables. Used in tiebreaker for previous\",\n",
        "\"least constraining value\": \"given a variable, choose the value that rules out the fewest values in remaining variables\",\n",
        "\"Arc consistent\": \"for arc X->Y, for every x in X there is some legal y in Y\"\n",
        "}\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "cellView": "form",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 722
        },
        "id": "kKWbCsbfxL3R",
        "outputId": "72170ce6-2c6e-4513-fc64-79c5c76a609a"
      },
      "outputs": [
        {
          "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",
              " CSPs contain a finite set of variables, and a domain of possible values a variable can take. /\n",
              "Constraints are added between variables to limit values the variables can take. /\n",
              "CSP solutions are consistant and complete (often optimal does not have any meaning in these problems). /\n",
              "Discrete variables - with n variables and d domain size there are d^n configurations. \n",
              "CSPs can be represented as search problems with constant path cost. Can apply dfs to this since max depth is n. /\n",
              "Can improve this approach by apllying heuristics to backtracking. / \n",
              "Forward Checking - update the remaining legal values for unassigned variables. Terminate when unassigned variable has no legal values. /\n",
              "Inference (Constraint Propogation) - for constraint (X_i, X_j), remove x in X if there are no values that are legal with it in X_j (O(d^2)). /\n",
              "AC-3 - If you remove a value from (X_i) add (X_k, X_i) to queue for all k / {j} neighbors of X_i. Runtime n^2d^3. For planar graphs - nd^3. /\n",
              "\n",
              "\n",
              "\n",
              "## Module 6 Definitions\n",
              "* **Consistent** - the current state does not violate any constraints\n",
              "* **Complete** - every variable is assigned a value\n",
              "* **Most constrained** - choose variable with fewest legal values.\n",
              "* **Most constraining variable** - choose variable that has the most constraints on remaining variables. Used in tiebreaker for previous\n",
              "* **Least constraining value** - given a variable, choose the value that rules out the fewest values in remaining variables\n",
              "* **Arc consistent** - for arc X->Y, for every x in X there is some legal y in Y\n"
            ],
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "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))"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "RYESi2kMybL8"
      },
      "source": [
        "#Module 7 - Logical Agents"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 48,
      "metadata": {
        "id": "qIRJ4YYCzNHL"
      },
      "outputs": [],
      "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 = \"\"\" a entials b if M(a) is a subset of M(b). /\n",
        "KB ⊢i a means that a was inferred from KB via inference method i. /\n",
        "Resolution - inference method which yields a complete inference algorithm. /\n",
        "CNF is a logical representation of a KB by representing it as an and of ors. /\n",
        "First, use biconditional elimination by converting it into two implications. \n",
        "Then, eliminate the implications with not a or b. \n",
        "Then use demorgans to make all nots move inwards.\n",
        "Lastly use distributivity of ors over ands to convert it to CNF. /\n",
        "Can prove KB |= a by showing KB and not a leads to an empty clause using Resolution. /\n",
        "Inference with Horn Clauses can be done using forward-chaining or backward-chaining. /\n",
        "Deciding entailment with Horn clauses can be done in linear time with respect to\n",
        "the size of the KB. /\n",
        "\n",
        "Inference Rules:\n",
        "\n",
        "A => b, a: b --- modus ponens /\n",
        "A and b: a --- and elimination /\n",
        "A iff b: (a =>b) and (b => a) --- biconditional elimination /\n",
        "(a =>b) and (b => a): a iff b --- biconditional elimination /\n",
        "All of the logical equivalence rules can be re-written as inference rules\n",
        "\n",
        "A or b === b or a ------ commutativity of or /\n",
        "(a and b) and c === a and (b and c) --------- associativity of and / \n",
        "(a or b) or c === a or (b or c) ----------- associativity of or /\n",
        "A => b === not b => not a ----------- contraposition /\n",
        "A => b === not a or b -------- implication elimination / \n",
        "A iff b === (a =>b) and (b => a) ---------- biconditional elimination / \n",
        "A and (b or c) === (a and b) or (a and c) ------- distributivity of and over or /\n",
        "A or (b and c) === (a or b) and (a or c) ---------- distributivity of or over and\n",
        " \"\"\"\n",
        "\n",
        "# Definitions\n",
        "module7_definitions = {\n",
        "\"knowledge base (KB)\" : \"contains set of sentences written in knowledge representation language. The sentence contains some assertion about the world\",\n",
        "\"Axiom\": \"sentence that is given\",\n",
        "\"derived sentences\": \"new sentences derived from others using inference\",\n",
        "\"models\": \"mathematical abstraction that has a fixed set of truth values which are {true, false} for each sentence.\",\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",
        "\"Horn Clause\": \"disjunction of literals where at most one is positive\",\n",
        "\"Definite Clause\": \"disjunction of literals where exactly one is positive\",\n",
        "\n",
        "\n",
        "}\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 49,
      "metadata": {
        "cellView": "form",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 891
        },
        "id": "lXNcHuKjyNXa",
        "outputId": "e9ac6900-06e6-4015-b82b-b396e196d688"
      },
      "outputs": [
        {
          "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",
              " a entials b if M(a) is a subset of M(b). /\n",
              "KB ⊢i a means that a was inferred from KB via inference method i. /\n",
              "Resolution - inference method which yields a complete inference algorithm. /\n",
              "CNF is a logical representation of a KB by representing it as an and of ors. /\n",
              "First, use biconditional elimination by converting it into two implications. \n",
              "Then, eliminate the implications with not a or b. \n",
              "Then use demorgans to make all nots move inwards.\n",
              "Lastly use distributivity of ors over ands to convert it to CNF. /\n",
              "Can prove KB |= a by showing KB and not a leads to an empty clause using Resolution. /\n",
              "Inference with Horn Clauses can be done using forward-chaining or backward-chaining. /\n",
              "Deciding entailment with Horn clauses can be done in linear time with respect to\n",
              "the size of the KB. /\n",
              "\n",
              "Inference Rules:\n",
              "\n",
              "A => b, a: b --- modus ponens /\n",
              "A and b: a --- and elimination /\n",
              "A iff b: (a =>b) and (b => a) --- biconditional elimination /\n",
              "(a =>b) and (b => a): a iff b --- biconditional elimination /\n",
              "All of the logical equivalence rules can be re-written as inference rules\n",
              "\n",
              "A or b === b or a ------ commutativity of or /\n",
              "(a and b) and c === a and (b and c) --------- associativity of and / \n",
              "(a or b) or c === a or (b or c) ----------- associativity of or /\n",
              "A => b === not b => not a ----------- contraposition /\n",
              "A => b === not a or b -------- implication elimination / \n",
              "A iff b === (a =>b) and (b => a) ---------- biconditional elimination / \n",
              "A and (b or c) === (a and b) or (a and c) ------- distributivity of and over or /\n",
              "A or (b and c) === (a or b) and (a or c) ---------- distributivity of or over and\n",
              " \n",
              "\n",
              "## Module 7 Definitions\n",
              "* **Knowledge base (kb)** - contains set of sentences written in knowledge representation language. The sentence contains some assertion about the world\n",
              "* **Axiom** - sentence that is given\n",
              "* **Derived sentences** - new sentences derived from others using inference\n",
              "* **Models** - mathematical abstraction that has a fixed set of truth values which are {true, false} for each sentence.\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",
              "* **Horn clause** - disjunction of literals where at most one is positive\n",
              "* **Definite clause** - disjunction of literals where exactly one is positive\n"
            ],
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "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))"
      ]
    },
    {
      "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",
      "execution_count": 50,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "id": "T3cm1WV542_a",
        "outputId": "a1bd3467-dfda-44a5-a526-d695d1117568"
      },
      "outputs": [
        {
          "data": {
            "text/markdown": [
              "# Module 1: Rational Agents and Task Environments\n",
              "## AIMA Chapter 1.1 What is AI?\n",
              " Chapter 1.1 summary. \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",
              " An agent is specified by an agent function f:P -> a that maps a\n",
              "sequence of percept vectors P to an action a from a set A. In other words, an agent takes in inputs from its perceptrons and as a result, acts accordinglyAn agent function runs on the physical architecture to produce an agent function.\n",
              "Performance measures are used to evaluate an agents behavior. It is important to make the performance measure based on what it should achieve over how it should achieve it. We want to maximize the expected value of an action for each possible input according to the performance measure. PEAS - performance measure, environment, actuators, sensors. fully observable vs partially observable, deterministic vs nondeterministic vs stochastic, episodic vs sequential, static vs dynamic, discrete vs continuous, single agent vs multi agent When something behavior can best be described as having its own performance\n",
              "measure, then we should consider it to be an agent. \n",
              "\n",
              "## Module 1 Definitions\n",
              "* **Agent** - anything that can perceive and act in an environment\n",
              "* **Percept** - is the agent’s perceptual inputs at any given instance\n",
              "* **Sensors** - what an agent uses to sense the environment\n",
              "\n",
              "\n",
              "# Module 2: Python\n",
              "## Module 2 Lecture Notes\n",
              " Python is strongly typed, which means the interpreter does not allow things incompatible with that type. For example, string + int is not allowed. Python is dynamically typed, or the type of varible is determined at runtime. Strings can be created using single or double quotes. Can concatenate strings using + (creates a copy). Strings can be created with % as in C (\"%s can speak %d languages\" % (\"C3PO\", 6000000)). Lists are mutable, use x[:] to get a shallow copy. == checks if two objects have the same value, use is to check if two variables point to same object. Tuples and strings are an immutable sequences, and tuples can contain mixed types ex. (5, \"foo\"). Slicing - creates copy from [start:end:step] list methods - append adds element to the end, insert(i, elt) inserts elt at index i, index(elt) finds first index of elt, count(elt) returns num of occurences, remove(elt) removes it, reverse reverses list in place, sort sorts in place (can add a lambda function). Sorted(list) returns a copy of a sorted list. Dictionaries require immutable keys (so tuples and strings are fine) dict.keys() returns list of keys, dict.values() returns list of values, dict.items() returns (K, V) pair of items.Functions can return multiple values. Functions do not allow for overloading (multiple functions with same name). Can also provide default values for parameters in a function. Can also specify arguments out of order by providing keywords (index=5)If you want to accept variable number of arguments, use *args or **kwargs (keyword arguments) which takes in a pointer to a list or dict respectively. Functions in python are first class objects.\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",
              " search problems have states, actions, transition models, path cost, and goal tests. /\n",
              " Initially states just contain the initial state. /\n",
              " Then generate successors of an action by applying transition model to the state and each possible action. /\n",
              " Tree search - root is initial state, children are successors, and edges are actions that take a node to its successor. /\n",
              " Different paths to the same node are distinct, so repeated states can lead to exponential algorithms. /\n",
              " Graph search stores visited states, so it only expands unvisited states. /\n",
              " b is max branching factor, d is depth, and m is maximum length of any path. /\n",
              "BFS is complete and optimal if the cost is 1 per edge traversed, O(b^d) time complexity and O(b^d) space complexity. /\n",
              "DFS is not complete or optimal. O(b^d) time complexity and O(bm) space complexity. /\n",
              "Iterative deepening - run dfs with a depth limit of i, and increment i in each iteration. /\n",
              "Repeat until goal is found or limit is reached.  /\n",
              "It is complete, optimal, O(b^m) time complexity and O(bm) space complexity. \n",
              "\n",
              " \n",
              "\n",
              "## Module 3 Definitions\n",
              "* **Reflex agent** - agent that selects action based on current input, ignoring the past results\n",
              "* **Problem-solving agent** - an agent that can formulate a plan via search\n",
              "* **States** - the set of possible configurations of the problem.\n",
              "* **Actions** - the set of actions that can be executed in s, that are applicable in s.\n",
              "* **Transition model** - a mapping of state and action pairs to s_r, the new state after performing action a in state s\n",
              "* **Path cost** - Must be additive. step cost is c(x,a,y) >= 0. Action a moves us from state x to y\n",
              "* **Goal test** - test used to check if s is a goal state\n",
              "* **State space** - set of all reachable states from inital state\n",
              "* **Path** - a sequence of actions leading from one state sj to another state sk\n",
              "* **Solution** - a path from the initial state si to a state sf that satisfies the goal test\n",
              "* **Search tree:** - a way to represent seen states. Root is the initial state, leaves are successor states.\n",
              "* **Frontier** - states available for expanding (states in queue)\n",
              "* **Uninformed search** - All non-goal nodes in frontier look equally good\n",
              "* **Informed search** - Some non-goal nodes can be ranked above others.\n",
              "* **Complete** - an algorithm always finds a solution\n",
              "* **Optimal** - an algorithm finds the lowest cost solution\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",
              " Uniform cost search - BFS but expand node with lowest path cost. /\n",
              "However, only check if a state is a goal when selected for expansion, rather than when adding to the queue. /\n",
              "\n",
              "Greedy best first search - expand nodes with minimal h(n) values. Not optimal or complete \n",
              "A* search - Expand nodes with lowest g(n) + f(n) values. /\n",
              "Heuristic is admissable if it never overestimates the cost to reach the goal. If h is admissable, then A* is optimal. /\n",
              "The cost of an optimal solution to a relaxed problem is an admissible heuristic for the original problem. /\n",
              "If h2(n) ≥ h1(n) for all n (both admissible) then h2 dominates h1. /\n",
              "h*(n) or oracle heuristic, is the true distance from n to the goal. /\n",
              "\n",
              "\n",
              "## Module 4 Definitions\n",
              "* **F(n)** - function used inthe queue to order by polling\n",
              "* **G(n)** - cost from intial to current state\n",
              "* **H(n)** - heuristic or estimated cost from current node to a goal\n",
              "* **Relaxed problem** - A problem with fewer restrictions on the actions than the original\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",
              "Simplist game definition - multiagent, static (game doesnt change while thinking), /\n",
              "discrete(finite set of percepts and actions), fully observable, /\n",
              "strategic(The next state is determined by the current state and the action executed\n",
              "by the agent and the actions of one other agent. /\n",
              "In simple games two players - max and min, and max moves first. /\n",
              "Start at max mode, then evaluate children. If at a max layer, choose max values of children. If at min node, choose min of children. /\n",
              "alpha beta pruning - store alpha and beta values where alpha is the highest value currently at the max layer. /\n",
              "beta is the lowest value currently at the min layer. If current value is lower than alpha in min layer or opposite in max then no need to traverse that branch. /\n",
              "In expectimax, now you base decisions off of expected value. \n",
              "\n",
              ") \n",
              "\n",
              "## Module 5 Definitions\n",
              "* **Zero-sum** - one player’s loss is another’s gain\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",
              " CSPs contain a finite set of variables, and a domain of possible values a variable can take. /\n",
              "Constraints are added between variables to limit values the variables can take. /\n",
              "CSP solutions are consistant and complete (often optimal does not have any meaning in these problems). /\n",
              "Discrete variables - with n variables and d domain size there are d^n configurations. \n",
              "CSPs can be represented as search problems with constant path cost. Can apply dfs to this since max depth is n. /\n",
              "Can improve this approach by apllying heuristics to backtracking. / \n",
              "Forward Checking - update the remaining legal values for unassigned variables. Terminate when unassigned variable has no legal values. /\n",
              "Inference (Constraint Propogation) - for constraint (X_i, X_j), remove x in X if there are no values that are legal with it in X_j (O(d^2)). /\n",
              "AC-3 - If you remove a value from (X_i) add (X_k, X_i) to queue for all k / {j} neighbors of X_i. Runtime n^2d^3. For planar graphs - nd^3. /\n",
              "\n",
              "\n",
              "\n",
              "## Module 6 Definitions\n",
              "* **Consistent** - the current state does not violate any constraints\n",
              "* **Complete** - every variable is assigned a value\n",
              "* **Most constrained** - choose variable with fewest legal values.\n",
              "* **Most constraining variable** - choose variable that has the most constraints on remaining variables. Used in tiebreaker for previous\n",
              "* **Least constraining value** - given a variable, choose the value that rules out the fewest values in remaining variables\n",
              "* **Arc consistent** - for arc X->Y, for every x in X there is some legal y in Y\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",
              " a entials b if M(a) is a subset of M(b). /\n",
              "KB ⊢i a means that a was inferred from KB via inference method i. /\n",
              "Resolution - inference method which yields a complete inference algorithm. /\n",
              "CNF is a logical representation of a KB by representing it as an and of ors. /\n",
              "First, use biconditional elimination by converting it into two implications. \n",
              "Then, eliminate the implications with not a or b. \n",
              "Then use demorgans to make all nots move inwards.\n",
              "Lastly use distributivity of ors over ands to convert it to CNF. /\n",
              "Can prove KB |= a by showing KB and not a leads to an empty clause using Resolution. /\n",
              "Inference with Horn Clauses can be done using forward-chaining or backward-chaining. /\n",
              "Deciding entailment with Horn clauses can be done in linear time with respect to\n",
              "the size of the KB. /\n",
              "\n",
              "Inference Rules:\n",
              "\n",
              "A => b, a: b --- modus ponens /\n",
              "A and b: a --- and elimination /\n",
              "A iff b: (a =>b) and (b => a) --- biconditional elimination /\n",
              "(a =>b) and (b => a): a iff b --- biconditional elimination /\n",
              "All of the logical equivalence rules can be re-written as inference rules\n",
              "\n",
              "A or b === b or a ------ commutativity of or /\n",
              "(a and b) and c === a and (b and c) --------- associativity of and / \n",
              "(a or b) or c === a or (b or c) ----------- associativity of or /\n",
              "A => b === not b => not a ----------- contraposition /\n",
              "A => b === not a or b -------- implication elimination / \n",
              "A iff b === (a =>b) and (b => a) ---------- biconditional elimination / \n",
              "A and (b or c) === (a and b) or (a and c) ------- distributivity of and over or /\n",
              "A or (b and c) === (a or b) and (a or c) ---------- distributivity of or over and\n",
              " \n",
              "\n",
              "## Module 7 Definitions\n",
              "* **Knowledge base (kb)** - contains set of sentences written in knowledge representation language. The sentence contains some assertion about the world\n",
              "* **Axiom** - sentence that is given\n",
              "* **Derived sentences** - new sentences derived from others using inference\n",
              "* **Models** - mathematical abstraction that has a fixed set of truth values which are {true, false} for each sentence.\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",
              "* **Horn clause** - disjunction of literals where at most one is positive\n",
              "* **Definite clause** - disjunction of literals where exactly one is positive\n"
            ],
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "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))"
      ]
    }
  ],
  "metadata": {
    "colab": {
      "collapsed_sections": [],
      "name": "Copy of FINAL Template_for CIS521_midterm notes.ipynb",
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
