Add files via upload

This commit is contained in:
Peter Norvig 2020-04-19 16:09:08 -07:00 committed by GitHub
parent 6c6221b868
commit 507d42f8f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,7 +62,18 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 3,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"data": {
"text/plain": [
"'May'"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"month('May 15')" "month('May 15')"
] ]
@ -71,7 +82,18 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 4,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"data": {
"text/plain": [
"'15'"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"day('May 15')" "day('May 15')"
] ]
@ -129,7 +151,18 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 6,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"data": {
"text/plain": [
"{'May 15', 'May 16', 'May 19'}"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"told('May')" "told('May')"
] ]
@ -196,7 +229,7 @@
"\n", "\n",
"Here is the main function, `cheryls_birthday`, which computes the subset of dates in the global variable `dates` that satisfy statements 3 through 5. We will define a **statement** as a boolean function that takes a single date as input and returns true if the statement would be true in the condition that the given date is Cheryl's actual birthday. So a statement only has to consider one date at a time. But the code within a statement may have to consider the belief states of Albert and Bernard, to determine if the statement is true.\n", "Here is the main function, `cheryls_birthday`, which computes the subset of dates in the global variable `dates` that satisfy statements 3 through 5. We will define a **statement** as a boolean function that takes a single date as input and returns true if the statement would be true in the condition that the given date is Cheryl's actual birthday. So a statement only has to consider one date at a time. But the code within a statement may have to consider the belief states of Albert and Bernard, to determine if the statement is true.\n",
"\n", "\n",
"The function `satisfy` takes a collection of dates and some statement(s) and returns the subset that satisfies all the statements:" "The function `satisfy` takes a collection of dates and some statement(s) and returns the subset of dates that satisfies all the statements."
] ]
}, },
{ {
@ -240,7 +273,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"def albert1(date) -> bool:\n", "def albert1(date) -> bool:\n",
" \"\"\"Albert: I don't know when Cheryl's birthday is, but I know that Bernard does not know too.\"\"\"\n", " \"Albert: I don't know when Cheryl's birthday is, and I know that Bernard does not know.\"\n",
" albert_beliefs = told(month(date))\n", " albert_beliefs = told(month(date))\n",
" return not know(albert_beliefs) and not satisfy(albert_beliefs, bernard_knows)\n", " return not know(albert_beliefs) and not satisfy(albert_beliefs, bernard_knows)\n",
"\n", "\n",