{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "Copy of FINAL Template_for CIS521_midterm notes.ipynb",
      "provenance": [],
      "collapsed_sections": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "brNDGX-kvzds"
      },
      "source": [
        "# Template for Notes for CIS 521 Midterm 1\n",
        "\n",
        "The midterm exam for CIS 521 will be **open notes**. No other matierals are allowed for the exam - you may not use the textbook, the internet, a Python envionement, or communicate with anyone during the exam. \n",
        "\n",
        "This python notebook is where you should save all of your notes.  It provides a structured template that allows you to add summaries for each of the textbook sections that are part of the required reading, plus room for lecture notes and definitions.\n",
        "\n",
        "Your summaries must be written in your own words.  Do not copy and paste from the textbook.  Do not share your notes with classmates, or copy any of your classmates' notes.  "
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "aPtM8g7R0Pds"
      },
      "source": [
        "# Instructions\n",
        "\n",
        "1. Make a copy of this Google Colab file. From the colab menu, pick **File > Save a copy in Drive**.  That will save a copy of this notebook in your Google drive.\n",
        "2. Go through each section of the notebook, and fill in all the summaries for each chapter and its corresponding sections.  Be sure to save your work frequently!\n",
        "3. Read the notes below about how you can format your summaries.\n",
        "4. In addition to these notes, you are allowed 1 page (both sides) for figures or handwritten notes.\n",
        "5. Submit your version of this notebook to Gradescope before you start the exam.\n",
        "6. If you are taking the exam in person, then you must print a copy of your notes for yourself.   Here's how to print: \n",
        "* Run the last cell of this notebook\n",
        "* Click the \"Mirror cell in tab\" button (this is located in the upper right corner of the cell, immediately to the right of the trash can).  This will open the cell.  \n",
        "* In Chrome, you can then print your notes using the **File > Print** option from the browser's menu.  \n",
        "* In the print options, change the layout from Landscape to Portrait. \n",
        "* Clicking the Save, will save a PDF that you can then print.\n",
        "\n",
        "## Formatting Notes\n",
        "\n",
        "1. The max length for each section's summary is 500 words / 3000 characters.\n",
        "2. You can also write a 2000 word summary of the lectures for each module.\n",
        "3. You may also write definitions of concepts for each module.  The definitions should be written in your own words (not copy and pasted), and they should be no more than 20 words long for each concept. \n",
        "2. You can use Markdown formatting for your summaries. \n",
        "3. You can use Latex formatting for equations. Put two dollar signs before and after your equation like this: \n",
        "$$ \\epsilon = \\frac{1}{mc^2} $$\n",
        "4. When you write python code or psuedocode algorithms, you should surround it with triple backticks like this:\n",
        "```\n",
        "def function():\n",
        "      print('hello world')\n",
        "```\n",
        "5. Write \\ whenever you want to keep writing on the next line without a newline being inserted."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "cw5IpDLCZa4W"
      },
      "source": [
        "## Example summary\n",
        "\n",
        "This is a sample summary of [Section 2.1.1](https://web.stanford.edu/~jurafsky/slp3/2.pdf ) of Jurfasky and Martin's Speech and Language Processing's book\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "lzaavW96tcxM",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "344222ad-a216-45e3-9726-b566dead59fe"
      },
      "source": [
        "chapter_2_1_example = \"\"\"\n",
        "Regular expressions are an algebraic notation for characterizing \\\n",
        "a set of strings that are useful for searching for a pattern or through a corpus.\\\n",
        "Only the first matching result will be shown. The search string is case sensitive, \\\n",
        "but it can consist of a single character or a sequence of characters. \\\n",
        "While square braces specify a disjunction of characters, the dash can more easily look \\\n",
        "for characters over a range. The caret specifies the non-existence of a character. \\\n",
        "Additionally, the (?) is used to for flexibility on a single character, meaning \\\n",
        "\"the preceding character or nothing\". More importantly, the Kleene star means zero or \\\n",
        "more occurrences of the immediately previous character or regular expression in square braces.\\\n",
        "...\n",
        "\"\"\"\n",
        "\n",
        "length = len(chapter_2_1_example.split(\" \"))\n",
        "print(\"The example summary is {len} words long, so you could write an additional \\\n",
        "{remaining} words.\".format(len=length, remaining=(500-length)))"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "The example summary is 116 words long, so you could write an additional 384 words.\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "s3Uk9gQTevcj"
      },
      "source": [
        "## Example summary length\n",
        "\n",
        "The maximum summary length for each section is 500 words / 3000 characters.  Hopefully you'll find that to be quite generous. "
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "8DvZ57A-djo1",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "ef81cd11-e574-43c8-fb57-4c2e2e3d803c"
      },
      "source": [
        "# This is an example of a 500 word placeholder\n",
        "placeholder = \"\"\"ultrices vitae auctor eu augue ut lectus arcu bibendum at varius \\\n",
        " vel pharetra vel turpis nunc eget lorem dolor sed viverra ipsum nunc aliquet \\\n",
        " bibendum enim facilisis gravida neque convallis a cras semper auctor neque vitae \\\n",
        " tempus quam pellentesque nec nam aliquam sem et tortor consequat id porta nibh \\\n",
        " venenatis cras sed felis eget velit aliquet sagittis id consectetur purus ut \\\n",
        " faucibus pulvinar elementum integer enim neque volutpat ac tincidunt vitae semper \\ \n",
        " quis lectus nulla at volutpat diam ut venenatis tellus in metus vulputate eu \\\n",
        " scelerisque felis imperdiet proin fermentum leo vel orci porta non pulvinar neque \\ \n",
        " laoreet suspendisse interdum consectetur libero id faucibus nisl tincidunt eget \\\n",
        " nullam non nisi est sit amet facilisis magna etiam tempor orci eu lobortis \\\n",
        " elementum nibh tellus molestie nunc non blandit massa enim nec dui nunc mattis \\\n",
        " enim ut tellus elementum sagittis vitae et leo duis ut diam quam nulla porttitor \\\n",
        " massa id neque aliquam vestibulum morbi blandit cursus risus at ultrices mi tempus \\\n",
        " imperdiet nulla malesuada pellentesque elit eget gravida cum sociis natoque \\\n",
        " penatibus et magnis dis parturient montes nascetur ridiculus mus mauris vitae \\\n",
        " ultricies leo integer malesuada nunc vel risus commodo viverra maecenas accumsan \\\n",
        " lacus vel facilisis volutpat est velit egestas dui id ornare arcu odio ut sem nulla \\\n",
        " pharetra diam sit amet nisl suscipit adipiscing bibendum est ultricies integer \\\n",
        " quis auctor elit sed vulputate mi sit amet mauris commodo quis imperdiet massa \\\n",
        " tincidunt nunc pulvinar sapien et ligula ullamcorper malesuada proin libero nunc \\\n",
        " consequat interdum varius sit amet mattis vulputate enim nulla aliquet porttitor \\\n",
        " lacus luctus accumsan tortor posuere ac ut consequat semper viverra nam libero \\\n",
        " justo laoreet sit amet cursus sit amet dictum sit amet justo donec enim diam \\\n",
        " vulputate ut pharetra sit amet aliquam id diam maecenas ultricies mi eget mauris \\\n",
        " pharetra et ultrices neque ornare aenean euismod elementum nisi quis eleifend quam \\\n",
        " adipiscing vitae proin sagittis nisl rhoncus mattis rhoncus urna neque viverra justo \\\n",
        " nec ultrices dui sapien eget mi proin sed libero enim sed faucibus turpis in \\\n",
        " eu mi bibendum neque egestas congue quisque egestas diam in arcu cursus euismod \\\n",
        " quis viverra nibh cras pulvinar mattis nunc sed blandit libero volutpat sed cras \\\n",
        " ornare arcu dui vivamus arcu felis bibendum ut tristique et egestas quis ipsum \\\n",
        " suspendisse ultrices gravida dictum fusce ut placerat orci nulla pellentesque \\\n",
        " dignissim enim sit amet venenatis urna cursus eget nunc scelerisque viverra mauris \\\n",
        " in aliquam sem fringilla ut morbi tincidunt augue interdum velit euismod in \\\n",
        " pellentesque massa placerat duis ultricies lacus sed turpis tincidunt id aliquet \\\n",
        " risus feugiat in ante metus dictum at tempor commodo ullamcorper a lacus vestibulum \\\n",
        " sed arcu non odio euismod lacinia at quis risus sed vulputate odio ut enim blandit \\\n",
        " volutpat maecenas volutpat blandit aliquam etiam erat velit scelerisque in \\\n",
        " dictum non consectetur a erat nam at lectus urna\"\"\"\n",
        "\n",
        "print(\"The length in words is\", len(placeholder.split(' ')))\n",
        "print(\"The length in characters is\", len(placeholder))"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "The length in words is 500\n",
            "The length in characters is 3030\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "5yG3-YncJfTB"
      },
      "source": [
        "# Permissions to use your summaries\n",
        "\n",
        "We'd like to use your summaries to help develop better educational resources like [remember.school](https://remember.school) or a question-answering system about the textbook.  \n",
        "\n",
        "1. Please enter your name.  \n",
        "\n",
        "2. If you grant permission for us to use your summaries under a [Creative Commons License](https://creativecommons.org/licenses/by/4.0/), please set ```permission = True```.  If you do not grant permission, please set it to false. Your answer won't affect your grade.\n",
        "\n",
        "3. If you grant us permission, and you'd like to remain anonymous, set ```anonymous = True```.  We'll remove your name before sharing your summaries with anyone. "
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "2RECnJArJew4"
      },
      "source": [
        "name = \"\"\n",
        "permission = True\n",
        "anonymous = False"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "GZZXyrV-xuAp"
      },
      "source": [
        "# Module 1 - Intro to AI"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Y2NfE1CKxzS-"
      },
      "source": [
        "# Russell and Norvig, AIMA 4th Edition, Chapter 1 “Introduction”, Section 1.1 “What is AI”\n",
        "\n",
        "chapter1_1 = \"\"\" Two ways to define AI: intelligent behavior, human performance.\n",
        "Computers need:\n",
        "natural language processing to communicate successfully in a human language;\n",
        "knowledge representation to store what it knows or hears;\n",
        "automated reasoning to answer questions and to draw new conclusions;\n",
        "machine learning adapts to new circumstances and to detect and extrapolate patterns.\n",
        " \n",
        "A Turing test can tell if a computer is intelligent. It does so by having a human ask questions\n",
        "and if they cannot tell if responses are human or computer it passes.\n",
        " \n",
        "A Total Turing Test requires interactions with people in the real world and to pass this,\n",
        "a computer needs:\n",
        "1. computer vision and speech recognition to perceive the world;\n",
        "2. robotics to manipulate objects and move about.\n",
        " \n",
        "Human thought is learned in 3 ways:\n",
        "1. introspection—trying to catch our own thoughts as they go by;\n",
        "2. psychological experiments—observing a person in action;\n",
        "3. brain imaging—observing the brain in action.\n",
        " \n",
        "cognitive science brings together computer models from AI and experimental techniques from psychology\n",
        " \n",
        "syllogisms provided patterns for argument structures that always yielded correct\n",
        "conclusions when given correct premises. This is a short irrefutable reasoning process.\n",
        " \n",
        "logicist tradition within artificial intelligence hopes to build on such programs to create intelligent systems.\n",
        "Meaning when programs could solve any solvable problem described in logical notation.\n",
        " \n",
        "theory of probability fills this gap, allowing rigorous reasoning with uncertain information.\n",
        " \n",
        "An agent is something that acts.\n",
        "A rational agent is one that acts so as to achieve the best outcome or, when there is uncertainty, the best expected outcome.\n",
        " \n",
        " \n",
        "AI has focused on the study and construction of agents that do the right thing.\n",
        "The right thing is the objective of a problem and we can also call this the standard model.\n",
        " \n",
        "limited rationality—acting appropriately when there is not enough time to do all the computations one might like.\n",
        "Computers use this when a problem is just too big to solve completely.\n",
        " \n",
        "The problem of achieving agreement between our true preferences and the objective we put into the machine is called the value alignment problem:\n",
        "the values or objectives put into the machine must be aligned with those of the human.\n",
        " \n",
        "AI should be provably beneficial to humans, meaning we want them to pursue our\n",
        "objectives. If we cannot get the machine to do this exactly we need to reformulate\n",
        "the problem\n",
        "\n",
        " \"\"\"\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 = \"\"\" Weak AI—the idea that machines could act as if they were intelligent\n",
        "Strong AI—the assertion that machines that do so are actually consciously thinking (not just simulating thinking)\n",
        "\n",
        "Good Old-Fashioned AI (GOFAI)- corresponds to the simplest logical agent design\n",
        "Qualification Problem- the difficulty to capture every contingency of appropriate \n",
        "behavior in a set of necessary and sufficient logical rules\n",
        "Embodied Cognition- claims that it makes no sense to consider the brain separately: \n",
        "cognition takes place within a body, which is embedded in an environment.\n",
        "Gödel sentence (G(F)): \n",
        "G(F) - is a sentence of , but cannot be proved within \n",
        "and If F is consistent, then G(F) is true\n",
        "Turing Test-  requires a program to have a conversation (via typed messages) with \n",
        "an interrogator for five minutes. Interrogator must guess if it is human, if they are fooled\n",
        "30% of the time, program passes. \n",
        "\n",
        "\"\"\"\n",
        "chapter27_2 = \"\"\" \n",
        "Polite Convention - idea of trying to generalize what all people think,\n",
        "but knowing there are differences.\n",
        "\n",
        "Chinese Room Arguement- Imagine a human, who understands only English,\n",
        "inside a room that contains a rule book, written in English, and various stacks of paper. \n",
        "From the outside this may seem like the person understand chinese by just rewriting the\n",
        "symbols, but they do not understand. Computers can easily do this and fool us into\n",
        "believing they are fully intelligent.\n",
        "\n",
        "Biological Naturalism- mental states are high-level emergent features that are caused \n",
        "by low-level physical processes in the neurons, and it is the (unspecified) properties \n",
        "of the neurons that matter. \n",
        "\n",
        "Arguements/debates about AI :\n",
        "Consciousness- awareness of the outside world, and of the self, and the subjective experience of living\n",
        "Qualia- The technical term for the intrinsic nature of experiences. \n",
        "\"\"\"\n",
        "\n",
        "# Russell and Norvig, AIMA 4th Edition, Chapter 2 “Intelligent Agents” (whole chapter)\n",
        "chapter2_1 = \"\"\"\n",
        "Agent- anything that can be viewed as perceiving its environment through sensors \n",
        "and acting upon that environment through actuators.\n",
        "Percept- the content an agent’s sensors are perceiving\n",
        "Percept Sequence- An agent's complete history of everything it has ever perceived\n",
        "\n",
        "Note in general: an agent’s choice of action at any given instant can depend on \n",
        "its built-in knowledge and on the entire percept sequence observed to date, \n",
        "but not on anything it hasn’t perceived.\n",
        "\n",
        "Agent Function- describes an agent's behavior, and maps any percept sequence to an\n",
        "action. \n",
        "Agent Program- How an agent program is implemented in an artificial agent. \n",
        "\n",
        "\"\"\"\n",
        "chapter2_2 = \"\"\" \n",
        "2.2.1 Performance Measures\n",
        "\n",
        "Rational Agent- an agent that does the right thing.\n",
        "Consequentialism- evaluating an agent’s behavior by its consequences\n",
        "Performance Measure- this evaluation and determines the desirability of a given\n",
        "squence of states an agent may produce. \n",
        "The purpose of creating AI is to help humans, so helpfulness and performance \n",
        "need to be measured and evaluated. \n",
        "In general, it is better to design performance measures according to what one actually \n",
        "wants to be achieved in the environment, rather than according to how one thinks the agent should behave.\n",
        "\n",
        "2.2.2 Rationality \n",
        "Rational depends on 4 things: \n",
        "\n",
        "1. The performance measure that defines the criterion of success.\n",
        "2. The agent’s prior knowledge of the environment.\n",
        "3. The actions that the agent can perform.\n",
        "4. The agent’s percept sequence to date.\n",
        "\n",
        "Definition of a Rational Agent- For each possible percept sequence, \n",
        "a rational agent should select an action that is expected to maximize \n",
        "its performance measure, given the evidence provided by the percept sequence\n",
        "and whatever built-in knowledge the agent has.\n",
        "\n",
        "When an environment is unknown an agent needs to explore it. \n",
        "\n",
        "2.2.3 Omniscience, learning, and autonomy\n",
        "Omniscient Agent knows the actual outcome of its actions and can act accordingly;\n",
        "but omniscience is impossible in reality. \n",
        "-rationality does not require omniscience, because the rational choice depends \n",
        "only on the percept sequence to date\n",
        "\n",
        "Information Gathering- doing actions in order to modify future percepts, it is \n",
        "important for rationality.\n",
        "--Exploration is a type of information gathering\n",
        "A rational agent needs to learn as much as possible from what it perceives \n",
        "Autonomy- an agent that has its own percepts and learning processes\n",
        "\n",
        "\"\"\"\n",
        "chapter2_3 = \"\"\" \n",
        "Task Environments- the “problems” to which rational agents are the “solutions.”\n",
        "PEAS (Performance, Environment, Actuators, Sensors)- all part of task environment \n",
        "Work throgh the above for any AI problem. \n",
        "Software Agent(softbot)- An agent in a virtual environment \n",
        "\n",
        "Fully observeable- If an agent’s sensors give it access to the complete state \n",
        "of the environment at each point in time. The agent does not need to mantain an internal\n",
        "state to track of the environment. \n",
        "\n",
        "Partially Observable- some sensors are blocked by noise or inaccurate senors\n",
        "\n",
        "Unobservable- When an agent has no senors at all \n",
        "\n",
        "Single agent- Soemthing that only needs one agent to work (solving a crossword puzzle)\n",
        "Multiagent- Something that needs more than one agent (playing chess)\n",
        "\n",
        "Multigents can be: \n",
        "competitive(chess)- two agents against each other\n",
        "cooperative(autonomous car)- all cars benefit from another car not crashing\n",
        "\n",
        "Deterministic vs. nondeterministic\n",
        "Deterministic- If the next state of the environment is completely determined by \n",
        "the current state and the action executed by the agent(s), otherwise nondeterministic\n",
        "- stochastic is  a synonym for “nondeterministic”\n",
        "\n",
        "EPISODIC VS. SEQUENTIAL\n",
        "episodic-  the agent’s experience is divided into atomic episodes. \n",
        "In each episode the agent receives a percept and then performs a single action\n",
        "(single actions performed at a time)\n",
        "Sequential- A current decision could affect all future decisions. (like chess)\n",
        "Episodic task environments are much simpler, as thinking ahead is not requried\n",
        "\n",
        "STATIC VS. DYNAMIC:\n",
        "Dynamic- An environment that can change while an agent is deliberating\n",
        "Static- Cannot change, thus easier to program a agent to work in \n",
        "Semidynamic- If the environment itself does not change with the passage of time \n",
        "but the agent’s performance score does\n",
        "\n",
        "*\n",
        "The hardest case is partially observable, multiagent, nondeterministic, \n",
        "sequential, dynamic, continuous, and unknown.\n",
        "\n",
        "DISCRETE VS. CONTINUOUS: \n",
        "the state of the environment \n",
        "chess is discrete, taxi driving is continuous (actions and perceptions constanly \n",
        "changing and updating)\n",
        "\n",
        "KNOWN VS. UNKNOWN: \n",
        "Known environments can be partially or fully observable and same with unknown.\n",
        "A unknown environment can be a video game you can see the whole screen but do not\n",
        "know the button until you test them out. \n",
        "\n",
        "Environment Class- Many environments that are grouped together for testing. \n",
        " \"\"\"\n",
        "chapter2_4 = \"\"\"\n",
        "The job of AI is to design an agent program that implements the agent function. \n",
        "A program runs something with physical senors and actuators, this is a agent architecture \n",
        "\n",
        "agent = architecture + program\n",
        "\n",
        "Agent program- they take the current percept as input from the sensors and \n",
        "return an action to the actuators\n",
        "\n",
        "4 types of agent programs that embody the principles of almost all intelligent systems.\n",
        "1. simple reflex agent- simplest, these agents select actions on the basis of \n",
        "the current percept, ignoring the rest of the percept history\n",
        "    -- condition–action rule- some processing is done on the visual input to \n",
        "    establish the condition (a smart car knows to brake if the car infront of it\n",
        "    brake lights go on)\n",
        "2.Model based reflex agent- the agent should maintain some sort of internal state \n",
        "that depends on the percept history and thereby reflects at least some of the \n",
        "unobserved aspects of the current state. Handles partial observeabiltty\n",
        "    -- transition model- knowledge of how the world works for intelligent agents\n",
        "    -- sensor model- information about how the state of the world is reflected in the agent’s percepts\n",
        "Using models makes it a model based agent.\n",
        "\n",
        "3. Goal based agents- the agent needs some sort of goal information that describes \n",
        "situations that are desirable and a current state description. Both search and \n",
        "planning are used to achieve the agent's goal.\n",
        "\n",
        "4. Utility based agents- A more general performance measure should allow a \n",
        "comparison of different world states according to exactly how \"happy\" they would make the agent.\n",
        "Utility is used to explain the happy, or satisfied conditions.\n",
        "    --Utility function- an agent's internalization of the performance measure,\n",
        "    an agent is trying to maximize this\n",
        "\n",
        "\n",
        "Expected Utility- The utility the agent expects to derive, on average, \n",
        "given the probabilities and utilities of each outcome. (best outcome is not \n",
        "always expected)\n",
        "\n",
        "All agents can improve their performance through learning. \n",
        "\n",
        "\n",
        "\"\"\"\n",
        "\n",
        "\n",
        "\n",
        "# Lecture notes \n",
        "module1_lecture_notes = \"\"\" \n",
        "For now, we will assume environment is:\n",
        "1.Static\n",
        "2.Fully Observable\n",
        "3.Deterministic\n",
        "4.Discrete\n",
        "\n",
        "Example search problem: 8-puzzle\n",
        "1.Formulate goal(Pieces to end up in order)\n",
        "2.Formulate search problem\n",
        "• States: configurations of the puzzle (9! configurations)\n",
        "• Actions: Move one of the movable pieces (≤4 possible)\n",
        "• Performance measure: minimize total moves\n",
        "3.Find solution\n",
        "• Sequence of pieces moved: 3,1,6,3,1,…\n",
        "\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\" : \"the content an agent’s sensors are perceiving\",\n",
        "\"other concepts\" : \"all definitions are in outline above\",\n",
        "}\n",
        "\n"
      ],
      "execution_count": 4,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "elCCgY64spuq"
      },
      "source": [
        "## Preview of your notes for Module 1\n",
        "\n",
        "Here's a preview of your how your notes will be displayed.  At the end of this Python notebook, we'll aggregate your notes for all modules together into a single display.\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "gYYeNcdM_maE",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "outputId": "cce1d612-74c7-4dba-8134-cc74599a3ce5"
      },
      "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": 5,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 1: Rational Agents and Task Environments\n## AIMA Chapter 1.1 What is AI?\n Two ways to define AI: intelligent behavior, human performance.\nComputers need:\nnatural language processing to communicate successfully in a human language;\nknowledge representation to store what it knows or hears;\nautomated reasoning to answer questions and to draw new conclusions;\nmachine learning adapts to new circumstances and to detect and extrapolate patterns.\n \nA Turing test can tell if a computer is intelligent. It does so by having a human ask questions\nand if they cannot tell if responses are human or computer it passes.\n \nA Total Turing Test requires interactions with people in the real world and to pass this,\na computer needs:\n1. computer vision and speech recognition to perceive the world;\n2. robotics to manipulate objects and move about.\n \nHuman thought is learned in 3 ways:\n1. introspection—trying to catch our own thoughts as they go by;\n2. psychological experiments—observing a person in action;\n3. brain imaging—observing the brain in action.\n \ncognitive science brings together computer models from AI and experimental techniques from psychology\n \nsyllogisms provided patterns for argument structures that always yielded correct\nconclusions when given correct premises. This is a short irrefutable reasoning process.\n \nlogicist tradition within artificial intelligence hopes to build on such programs to create intelligent systems.\nMeaning when programs could solve any solvable problem described in logical notation.\n \ntheory of probability fills this gap, allowing rigorous reasoning with uncertain information.\n \nAn agent is something that acts.\nA rational agent is one that acts so as to achieve the best outcome or, when there is uncertainty, the best expected outcome.\n \n \nAI has focused on the study and construction of agents that do the right thing.\nThe right thing is the objective of a problem and we can also call this the standard model.\n \nlimited rationality—acting appropriately when there is not enough time to do all the computations one might like.\nComputers use this when a problem is just too big to solve completely.\n \nThe problem of achieving agreement between our true preferences and the objective we put into the machine is called the value alignment problem:\nthe values or objectives put into the machine must be aligned with those of the human.\n \nAI should be provably beneficial to humans, meaning we want them to pursue our\nobjectives. If we cannot get the machine to do this exactly we need to reformulate\nthe problem\n\n \n\n## AIMA Chapter 27.1 The Limits of AI\n Weak AI—the idea that machines could act as if they were intelligent\nStrong AI—the assertion that machines that do so are actually consciously thinking (not just simulating thinking)\n\nGood Old-Fashioned AI (GOFAI)- corresponds to the simplest logical agent design\nQualification Problem- the difficulty to capture every contingency of appropriate \nbehavior in a set of necessary and sufficient logical rules\nEmbodied Cognition- claims that it makes no sense to consider the brain separately: \ncognition takes place within a body, which is embedded in an environment.\nGödel sentence (G(F)): \nG(F) - is a sentence of , but cannot be proved within \nand If F is consistent, then G(F) is true\nTuring Test-  requires a program to have a conversation (via typed messages) with \nan interrogator for five minutes. Interrogator must guess if it is human, if they are fooled\n30% of the time, program passes. \n\n\n\n## AIMA Chapter 27.1 Can Machines Really Think?\n \nPolite Convention - idea of trying to generalize what all people think,\nbut knowing there are differences.\n\nChinese Room Arguement- Imagine a human, who understands only English,\ninside a room that contains a rule book, written in English, and various stacks of paper. \nFrom the outside this may seem like the person understand chinese by just rewriting the\nsymbols, but they do not understand. Computers can easily do this and fool us into\nbelieving they are fully intelligent.\n\nBiological Naturalism- mental states are high-level emergent features that are caused \nby low-level physical processes in the neurons, and it is the (unspecified) properties \nof the neurons that matter. \n\nArguements/debates about AI :\nConsciousness- awareness of the outside world, and of the self, and the subjective experience of living\nQualia- The technical term for the intrinsic nature of experiences. \n\n\n## AIMA 2.1 Agents and Environments\n\nAgent- anything that can be viewed as perceiving its environment through sensors \nand acting upon that environment through actuators.\nPercept- the content an agent’s sensors are perceiving\nPercept Sequence- An agent's complete history of everything it has ever perceived\n\nNote in general: an agent’s choice of action at any given instant can depend on \nits built-in knowledge and on the entire percept sequence observed to date, \nbut not on anything it hasn’t perceived.\n\nAgent Function- describes an agent's behavior, and maps any percept sequence to an\naction. \nAgent Program- How an agent program is implemented in an artificial agent. \n\n\n\n## AIMA 2.2 Good Behavior: The Concept of Rationality\n \n2.2.1 Performance Measures\n\nRational Agent- an agent that does the right thing.\nConsequentialism- evaluating an agent’s behavior by its consequences\nPerformance Measure- this evaluation and determines the desirability of a given\nsquence of states an agent may produce. \nThe purpose of creating AI is to help humans, so helpfulness and performance \nneed to be measured and evaluated. \nIn general, it is better to design performance measures according to what one actually \nwants to be achieved in the environment, rather than according to how one thinks the agent should behave.\n\n2.2.2 Rationality \nRational depends on 4 things: \n\n1. The performance measure that defines the criterion of success.\n2. The agent’s prior knowledge of the environment.\n3. The actions that the agent can perform.\n4. The agent’s percept sequence to date.\n\nDefinition of a Rational Agent- For each possible percept sequence, \na rational agent should select an action that is expected to maximize \nits performance measure, given the evidence provided by the percept sequence\nand whatever built-in knowledge the agent has.\n\nWhen an environment is unknown an agent needs to explore it. \n\n2.2.3 Omniscience, learning, and autonomy\nOmniscient Agent knows the actual outcome of its actions and can act accordingly;\nbut omniscience is impossible in reality. \n-rationality does not require omniscience, because the rational choice depends \nonly on the percept sequence to date\n\nInformation Gathering- doing actions in order to modify future percepts, it is \nimportant for rationality.\n--Exploration is a type of information gathering\nA rational agent needs to learn as much as possible from what it perceives \nAutonomy- an agent that has its own percepts and learning processes\n\n\n\n## AIMA 2.3 The Nature of Environments\n \nTask Environments- the “problems” to which rational agents are the “solutions.”\nPEAS (Performance, Environment, Actuators, Sensors)- all part of task environment \nWork throgh the above for any AI problem. \nSoftware Agent(softbot)- An agent in a virtual environment \n\nFully observeable- If an agent’s sensors give it access to the complete state \nof the environment at each point in time. The agent does not need to mantain an internal\nstate to track of the environment. \n\nPartially Observable- some sensors are blocked by noise or inaccurate senors\n\nUnobservable- When an agent has no senors at all \n\nSingle agent- Soemthing that only needs one agent to work (solving a crossword puzzle)\nMultiagent- Something that needs more than one agent (playing chess)\n\nMultigents can be: \ncompetitive(chess)- two agents against each other\ncooperative(autonomous car)- all cars benefit from another car not crashing\n\nDeterministic vs. nondeterministic\nDeterministic- If the next state of the environment is completely determined by \nthe current state and the action executed by the agent(s), otherwise nondeterministic\n- stochastic is  a synonym for “nondeterministic”\n\nEPISODIC VS. SEQUENTIAL\nepisodic-  the agent’s experience is divided into atomic episodes. \nIn each episode the agent receives a percept and then performs a single action\n(single actions performed at a time)\nSequential- A current decision could affect all future decisions. (like chess)\nEpisodic task environments are much simpler, as thinking ahead is not requried\n\nSTATIC VS. DYNAMIC:\nDynamic- An environment that can change while an agent is deliberating\nStatic- Cannot change, thus easier to program a agent to work in \nSemidynamic- If the environment itself does not change with the passage of time \nbut the agent’s performance score does\n\n*\nThe hardest case is partially observable, multiagent, nondeterministic, \nsequential, dynamic, continuous, and unknown.\n\nDISCRETE VS. CONTINUOUS: \nthe state of the environment \nchess is discrete, taxi driving is continuous (actions and perceptions constanly \nchanging and updating)\n\nKNOWN VS. UNKNOWN: \nKnown environments can be partially or fully observable and same with unknown.\nA unknown environment can be a video game you can see the whole screen but do not\nknow the button until you test them out. \n\nEnvironment Class- Many environments that are grouped together for testing. \n \n\n## AIMA 2.4 The Structure of Agents\n\nThe job of AI is to design an agent program that implements the agent function. \nA program runs something with physical senors and actuators, this is a agent architecture \n\nagent = architecture + program\n\nAgent program- they take the current percept as input from the sensors and \nreturn an action to the actuators\n\n4 types of agent programs that embody the principles of almost all intelligent systems.\n1. simple reflex agent- simplest, these agents select actions on the basis of \nthe current percept, ignoring the rest of the percept history\n    -- condition–action rule- some processing is done on the visual input to \n    establish the condition (a smart car knows to brake if the car infront of it\n    brake lights go on)\n2.Model based reflex agent- the agent should maintain some sort of internal state \nthat depends on the percept history and thereby reflects at least some of the \nunobserved aspects of the current state. Handles partial observeabiltty\n    -- transition model- knowledge of how the world works for intelligent agents\n    -- sensor model- information about how the state of the world is reflected in the agent’s percepts\nUsing models makes it a model based agent.\n\n3. Goal based agents- the agent needs some sort of goal information that describes \nsituations that are desirable and a current state description. Both search and \nplanning are used to achieve the agent's goal.\n\n4. Utility based agents- A more general performance measure should allow a \ncomparison of different world states according to exactly how \"happy\" they would make the agent.\nUtility is used to explain the happy, or satisfied conditions.\n    --Utility function- an agent's internalization of the performance measure,\n    an agent is trying to maximize this\n\n\nExpected Utility- The utility the agent expects to derive, on average, \ngiven the probabilities and utilities of each outcome. (best outcome is not \nalways expected)\n\nAll agents can improve their performance through learning. \n\n\n\n\n## Module 1 Lecture Notes\n \nFor now, we will assume environment is:\n1.Static\n2.Fully Observable\n3.Deterministic\n4.Discrete\n\nExample search problem: 8-puzzle\n1.Formulate goal(Pieces to end up in order)\n2.Formulate search problem\n• States: configurations of the puzzle (9! configurations)\n• Actions: Move one of the movable pieces (≤4 possible)\n• Performance measure: minimize total moves\n3.Find solution\n• Sequence of pieces moved: 3,1,6,3,1,…\n\n\n\n## Module 1 Definitions\n* **Agent** - anything that can perceive and act in an environment\n* **Percept** - the content an agent’s sensors are perceiving\n* **Other concepts** - all definitions are in outline above\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",
        "Good features of Python\n",
        "Fast development:\n",
        "-Concise, intuitive syntax that is whitespace delimited\n",
        "-Garbage collected\n",
        "Portable:\n",
        "-Programs run on major platforms withoutchange\n",
        "Various built-in types:\n",
        "-lists, dictionaries, sets: useful for AI\n",
        "Large collection of support libraries:\n",
        "-NumPy for Matlab like programming\n",
        "-Pandas for data analysis\n",
        "-Sklearn for machine learning\n",
        "-Pytorch and TensorFlow for deep learning\n",
        "\n",
        "Objects and Types\n",
        "All data treated as objects:\n",
        "An object is deleted (by garbage collection) once unreachable.\n",
        "\n",
        "Strong Typing:\n",
        "Every object has a fixed type, interpreter doesn’t allow things incompatible with\n",
        "that type (eg. “foo” + 2)\n",
        "type(object)\n",
        "isinstance(object, type)\n",
        "\n",
        "Examples of Types:\n",
        "int, float\n",
        "str, tuple, dict, list\n",
        "bool: True, False\n",
        "None, generator, function\n",
        "\n",
        "Python has dynmaic typing: Variables come into existence when first assigned.\n",
        "Strings are immutabile, lists are mutable\n",
        "\n",
        "Sequence Types\n",
        "Tuple:\n",
        "-A simple immutable ordered sequence of items\n",
        "-Immutable: a tuple cannot be modified once created\n",
        "-Items can be of mixed types, including collection types\n",
        "\n",
        "Strings:\n",
        "-Immutable\n",
        "-Regular strings are Unicode and use 2-byte characters (Regular strings in\n",
        "Python 2 use 8-bit characters)\n",
        "List:\n",
        "-Mutable ordered sequence of items of mixed types\n",
        "\n",
        "\n",
        "Pyhton allows multiple return values. \n",
        "It does not have function overloading. \n",
        "Not all arguments need to be called for the function to be called. \n",
        "\n",
        "Functions are first class \n",
        "First class object:\n",
        "-An entity that can be dynamically created, destroyed, passed to a function,\n",
        "returned as a value, and have all the rights as other variables in the\n",
        "programming language have\n",
        "Functions are “first-class citizens”:\n",
        "-Pass functions as arguments to other functions\n",
        "-Return functions as the values from other functions\n",
        "-Assign functions to variables or store them in data structures\n",
        "Higher order functions: take functions as input\n",
        "\n",
        "Subclasses:\n",
        "-no extend keyword\n",
        "-multiple inheritance is allowed\n",
        "\n",
        "Methods that behave like built ins: \n",
        "__init__: The constructor for the class.\n",
        "__len__ : Define how len( obj ) works.\n",
        "__copy__: Define how to copy a class.\n",
        "__cmp__ : Define how == works for class.\n",
        "__add__ : Define how + works for class\n",
        "__neg__ : Define how unary negation works for class\n",
        "\n",
        "Iterator Objects: \n",
        "Iterable objects can be used in a for loop because they have an __iter__ magic\n",
        "method, which converts them to iterator objects\n",
        "- no hasNext in python\n",
        "\n",
        "Generators: \n",
        "-Generators are iterators (with __next()__ method)\n",
        "-Creating Generators: yield\n",
        "\n",
        "YIELD: Each time we call the __next__ method of the generator, the method runs until it\n",
        "encounters a yield statement, and then it stops and returns the value that was yielded.\n",
        "Next time, it resumes where it left off\n",
        "\n",
        "Benefits of generators: \n",
        "-Less code than writing a standard iterator\n",
        "-Maintains local state automatically\n",
        "-Values are computed one at a time, as they’re needed\n",
        "-Avoids storing the entire sequence in memory\n",
        "-Good for aggregating (summing, counting) items. One pass.\n",
        "-Crucial for infinite sequences\n",
        "-Bad if you need to inspect the individual values\n",
        "\"\"\"\n",
        "\n",
        "# Each definition should be at most 20 words long.\n",
        "module2_definitions = {\n",
        "\"mutability\" : \"if something can be changed\",\n",
        "\"PriorityQueue\" : \"useful for search algorithms\",\n",
        "\"importlib\" : \"useful for reloading code from a file\",\n",
        "\"ModuleNotFoundError\" : \"need to run pip install module\",\n",
        "\"Method\" : \"when a function is defined inside a class\",\n",
        "}"
      ],
      "execution_count": 10,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "ydOK__lwWgdp",
        "cellView": "form",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 617
        },
        "outputId": "4720e4e9-fb41-44ce-c2e0-407e266abeb7"
      },
      "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": 8,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 2: Python\n## Module 2 Lecture Notes\n\nGood features of Python\nFast development:\n-Concise, intuitive syntax that is whitespace delimited\n-Garbage collected\nPortable:\n-Programs run on major platforms withoutchange\nVarious built-in types:\n-lists, dictionaries, sets: useful for AI\nLarge collection of support libraries:\n-NumPy for Matlab like programming\n-Pandas for data analysis\n-Sklearn for machine learning\n-Pytorch and TensorFlow for deep learning\n\nObjects and Types\nAll data treated as objects:\nAn object is deleted (by garbage collection) once unreachable.\n\nStrong Typing:\nEvery object has a fixed type, interpreter doesn’t allow things incompatible with\nthat type (eg. “foo” + 2)\ntype(object)\nisinstance(object, type)\n\nExamples of Types:\nint, float\nstr, tuple, dict, list\nbool: True, False\nNone, generator, function\n\nPython has dynmaic typing: Variables come into existence when first assigned.\nStrings are immutabile, lists are mutable\n\nSequence Types\nTuple:\n-A simple immutable ordered sequence of items\n-Immutable: a tuple cannot be modified once created\n-Items can be of mixed types, including collection types\n\nStrings:\n-Immutable\n-Regular strings are Unicode and use 2-byte characters (Regular strings in\nPython 2 use 8-bit characters)\nList:\n-Mutable ordered sequence of items of mixed types\n\n\nPyhton allows multiple return values. \nIt does not have function overloading. \nNot all arguments need to be called for the function to be called. \n\nFunctions are first class \nFirst class object:\n-An entity that can be dynamically created, destroyed, passed to a function,\nreturned as a value, and have all the rights as other variables in the\nprogramming language have\nFunctions are “first-class citizens”:\n-Pass functions as arguments to other functions\n-Return functions as the values from other functions\n-Assign functions to variables or store them in data structures\nHigher order functions: take functions as input\n\nSubclasses:\n-no extend keyword\n-multiple inheritance is allowed\n\nMethods that behave like built ins: \n__init__: The constructor for the class.\n__len__ : Define how len( obj ) works.\n__copy__: Define how to copy a class.\n__cmp__ : Define how == works for class.\n__add__ : Define how + works for class\n__neg__ : Define how unary negation works for class\n\n\n## Module 2 Definitions\n* **Mutability** - if something can be changed\n* **Priorityqueue** - useful for search algorithms\n* **Importlib** - useful for reloading code from a file\n* **Modulenotfounderror** - need to run pip install module\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",
        "# Definitions of concepts from Module 3.\n",
        "# You can define any bolded term in the textbook, \n",
        "# but you most use your own words for the definitions.\n",
        "# Each definition should be at most 20 words long.\n",
        "module3_definitions = {\n",
        "\"problem-solving agent\" : \"an agent that can formulate a plan via search\",    \n",
        "}\n",
        "\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "lvtN3p7ET3Tx",
        "cellView": "form",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "f8c6dc37-627d-494b-d493-ce53672224a4"
      },
      "source": [
        "#@title Preview of your summary\n",
        "#@markdown You don't need to modify anything in this cell. Just press play.\n",
        "module3_sections = [\n",
        "  (\"AIMA Chapter 3.1 Problem-Solving Agents\", chapter3_1),\n",
        "  (\"AIMA Chapter 3.2 Example Problems\", chapter3_2),\n",
        "  (\"AIMA Chapter 3.3 Search Algorithms\", chapter3_3),\n",
        "  (\"AIMA Chapter 3.4 Uninformed Search Strategies\", chapter3_4),\n",
        "  (\"Module 3 Lecture Notes\", module3_lecture_notes),\n",
        "]\n",
        "\n",
        "module3_markdown = format_module(3, \"Search Problems\", module3_sections, module3_definitions)\n",
        "display(Markdown(module3_markdown))"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 3: Search Problems\n## AIMA Chapter 3.1 Problem-Solving Agents\n Your summary here \n\n## AIMA Chapter 3.2 Example Problems\n Your summary here \n\n## AIMA Chapter 3.3 Search Algorithms\n Your summary here \n\n## AIMA Chapter 3.4 Uninformed Search Strategies\n Your summary here \n\n## Module 3 Lecture Notes\n Your summary here \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 = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "# Definitions\n",
        "module4_definitions = {\n",
        "\"concept\" : \"definition\",    \n",
        "}\n",
        "\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "vqtEs0gHs9sO",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "cellView": "form",
        "outputId": "6a33bad1-c16f-44e7-b70a-5755faa0ad38"
      },
      "source": [
        "#@title Preview of your summary\n",
        "#@markdown You don't need to modify anything in this cell. Just press play.\n",
        "module4_sections = [\n",
        "  (\"AIMA Chapter 3.5 Informed (Heuristic) Search Strategies\", chapter3_5),\n",
        "  (\"AIMA Chapter 3.6 Heuristic Functions\", chapter3_6),\n",
        "  (\"Module 4 Lecture Notes\", module4_lecture_notes),\n",
        "]\n",
        "\n",
        "module4_markdown = format_module(4, \"Informed Search\", \n",
        "                         module4_sections, \n",
        "                         module4_definitions)\n",
        "display(Markdown(module4_markdown))"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 4: Informed Search\n## AIMA Chapter 3.5 Informed (Heuristic) Search Strategies\n Your summary here \n\n## AIMA Chapter 3.6 Heuristic Functions\n Your summary here \n\n## Module 4 Lecture Notes\n Your summary here \n\n## Module 4 Definitions\n* **Concept** - definition\n",
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "F3FPMzG9yUls"
      },
      "source": [
        "#Module 5 - Adversarial Search and Games"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "iEIOpL7vyWcc"
      },
      "source": [
        "# Russell and Norvig, AIMA chapter 5 \"Adversarial Search\"”\" (5.1-5.3, and 5.5).\n",
        "chapter5_1 = \"\"\" 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 = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "# Definitions\n",
        "module5_definitions = {\n",
        "\"concept\" : \"definition\",    \n",
        "}\n",
        "\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "KUc_LgzDvWf-",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "39ec8635-89e2-4f2f-99f8-00aecd47f6ca"
      },
      "source": [
        "#@title Preview of your summary\n",
        "#@markdown You don't need to modify anything in this cell. Just press play.\n",
        "module5_sections = [\n",
        "  (\"AIMA Chapter 5.1 Game Theory\", chapter5_1),\n",
        "  (\"AIMA Chapter 5.2 Optimal Decisions in Games\", chapter5_2),\n",
        "  (\"AIMA Chapter 5.3 Heuristic Alpha–Beta Tree Search\", chapter5_3),\n",
        "  (\"AIMA Chapter 5.5 Stochastic Games\", chapter5_5),\n",
        "  (\"AIMA Chapter 16.1 Combining Beliefs and Desires under Uncertainty\", chapter16_1),\n",
        "  (\"AIMA Chapter 16.2 The Basis of Utility Theory\", chapter16_2),\n",
        "  (\"AIMA Chapter 16.3 Utility Functions\", chapter16_3),\n",
        "  (\"Module 5 Lecture Notes\", module5_lecture_notes),\n",
        "]\n",
        "\n",
        "module5_markdown = format_module(5, \"Adversarial Search and Games\", \n",
        "                         module5_sections, \n",
        "                         module5_definitions)\n",
        "display(Markdown(module5_markdown))"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 5: Adversarial Search and Games\n## AIMA Chapter 5.1 Game Theory\n Your summary here \n\n## AIMA Chapter 5.2 Optimal Decisions in Games\n Your summary here \n\n## AIMA Chapter 5.3 Heuristic Alpha–Beta Tree Search\n Your summary here \n\n## AIMA Chapter 5.5 Stochastic Games\n Your summary here \n\n## AIMA Chapter 16.1 Combining Beliefs and Desires under Uncertainty\n Your summary here \n\n## AIMA Chapter 16.2 The Basis of Utility Theory\n Your summary here \n\n## AIMA Chapter 16.3 Utility Functions\n Your summary here \n\n## Module 5 Lecture Notes\n Your summary here \n\n## Module 5 Definitions\n* **Concept** - definition\n",
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "qVSQhTVSyYYO"
      },
      "source": [
        "#Module 6 - \"Constraint Satisfaction Problems\""
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Wm4mfW82yaRH"
      },
      "source": [
        "# Russell and Norvig, AIMA, Chapter 6 “Constraint Satisfaction Problems” (6.1-6.5)\n",
        "chapter6_1 = \"\"\" 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 = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "# Definitions\n",
        "module6_definitions = {\n",
        "\"concept\" : \"definition\",    \n",
        "}\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "kKWbCsbfxL3R",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "5f3d2500-dfb2-42e4-9373-fb3bec356333"
      },
      "source": [
        "#@title Preview of your summary\n",
        "#@markdown You don't need to modify anything in this cell. Just press play.\n",
        "module6_sections = [\n",
        "  (\"AIMA Chapter 6.1 Defining Constraint Satisfaction Problems\", chapter6_1),\n",
        "  (\"AIMA Chapter 6.2 Constraint Propagation: Inference in CSPs\", chapter6_2),\n",
        "  (\"AIMA Chapter 6.3 Backtracking Search for CSPs\", chapter6_3),\n",
        "  (\"AIMA Chapter 6.4 Local Search for CSPs\", chapter6_4),\n",
        "  (\"AIMA Chapter 6.5 The Structure of Problems\", chapter6_5),\n",
        "  (\"Module 6 Lecture Notes\", module6_lecture_notes),\n",
        "]\n",
        "\n",
        "module6_markdown = format_module(6, \"Constraint Satisfaction Problems\", \n",
        "                         module6_sections, \n",
        "                         module6_definitions)\n",
        "display(Markdown(module6_markdown))"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 6: Constraint Satisfaction Problems\n## AIMA Chapter 6.1 Defining Constraint Satisfaction Problems\n Your summary here \n\n## AIMA Chapter 6.2 Constraint Propagation: Inference in CSPs\n Your summary here \n\n## AIMA Chapter 6.3 Backtracking Search for CSPs\n Your summary here \n\n## AIMA Chapter 6.4 Local Search for CSPs\n Your summary here \n\n## AIMA Chapter 6.5 The Structure of Problems\n Your summary here \n\n## Module 6 Lecture Notes\n Your summary here \n\n## Module 6 Definitions\n* **Concept** - definition\n",
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "RYESi2kMybL8"
      },
      "source": [
        "#Module 7 - Logical Agents"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "qIRJ4YYCzNHL"
      },
      "source": [
        "# Russell and Norvig, AIMA Chapter 7 “Logical Agents” (Sections 7.1-7.5)\n",
        "\n",
        "chapter7_1 = \"\"\" 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 = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "# Definitions\n",
        "module7_definitions = {\n",
        "\"concept\" : \"definition\",    \n",
        "}\n",
        "\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "lXNcHuKjyNXa",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "2fc31cf5-b9c0-41b0-9a0e-5f7744a61e68"
      },
      "source": [
        "#@title Preview of your summary\n",
        "#@markdown You don't need to modify anything in this cell. Just press play.\n",
        "module7_sections = [\n",
        "  (\"AIMA Chapter 7.1 Knowledge-Based Agents\", chapter7_1),\n",
        "  (\"AIMA Chapter 7.2 The Wumpus World\", chapter7_2),\n",
        "  (\"AIMA Chapter 7.3 Logic\", chapter7_3),\n",
        "  (\"AIMA Chapter 7.4 Propositional Logic: A Very Simple Logic\", chapter7_4),\n",
        "  (\"AIMA 7.5 Propositional Theorem Proving\", chapter7_5),\n",
        "  (\"Module 7 Lecture Notes\", module7_lecture_notes),\n",
        "]\n",
        "\n",
        "module7_markdown = format_module(7, \"Logical Agents\", \n",
        "                         module7_sections, \n",
        "                         module7_definitions)\n",
        "display(Markdown(module7_markdown))"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 7: Logical Agents\n## AIMA Chapter 7.1 Knowledge-Based Agents\n Your summary here \n\n## AIMA Chapter 7.2 The Wumpus World\n Your summary here \n\n## AIMA Chapter 7.3 Logic\n Your summary here \n\n## AIMA Chapter 7.4 Propositional Logic: A Very Simple Logic\n Your summary here \n\n## AIMA 7.5 Propositional Theorem Proving\n Your summary here \n\n## Module 7 Lecture Notes\n Your summary here \n\n## Module 7 Definitions\n* **Concept** - definition\n",
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "vX7lbnJd4sT5"
      },
      "source": [
        "# Your Exam Notes\n",
        "\n",
        "Here are your full set of exam notes that you can use on your midterm.  Choose **Runtime > Run all**, then your notes will be displayed.\n",
        "\n",
        "If you are taking the exam in person, then you must print a copy of your notes for yourself.   Here's how to print:\n",
        "* Run the cell below. \n",
        "* Click its \"Mirror cell in tab\" button (this is located in the upper right corner of the cell, immediately to the right of the trash can).  This will open the cell.  \n",
        "* In Chrome, you can then print your notes using the **File > Print** option from the browser's menu.  \n",
        "* In the print options, change the layout from Landscape to Portrait. \n",
        "* Clicking the Save, will save a PDF that you can then print.\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "T3cm1WV542_a",
        "outputId": "1e35f8dc-8712-4aad-fced-e8d79768a61b"
      },
      "source": [
        "# This will generate the full set of notes that you can use for your exam.\n",
        "full_markdown = \"\\n\\n\".join([module1_markdown, \n",
        "                             module2_markdown, \n",
        "                             module3_markdown, \n",
        "                             module4_markdown, \n",
        "                             module5_markdown,\n",
        "                             module6_markdown,\n",
        "                             module7_markdown,]\n",
        "                       )\n",
        "display(Markdown(full_markdown))"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 1: Rational Agents and Task Environments\n## AIMA Chapter 1.1 What is AI?\n 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 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 Your summary here \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\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\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 Your 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 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": {}
        }
      ]
    }
  ]
}