Add files via upload

This commit is contained in:
Peter Norvig 2020-04-15 20:20:37 -07:00 committed by GitHub
parent 5de6713d8b
commit 554e9c9fe1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 243 additions and 129 deletions

View File

@ -261,7 +261,7 @@
"source": [
"The function `statement3` takes as input a single possible birthdate and returns `True` if Albert's statement is true for that birthdate. How do we go from Albert's English statement to a Python function? Let's paraphrase it in a form that uses the concepts we have defined:\n",
"\n",
"> **Albert**: After Cheryl **told** me the **month** of her birthdate, my **belief set** was such that I didn't **know** her birthday. I do know that Bernard does not know. How do I know that? I can see that for **all** the possible dates in my **belief set**, if Bernard was **told** the **day** of that date, he would **not know** Cheryl's birthday.\n",
"> **Albert**: After Cheryl **told** me the **month** of her birthdate, my **belief set** was such that I didn't **know** her birthday. And I know that Bernard does not know; in other words he could not make the statement that he knows. How do I know that? I can see that for all the possible dates in my **belief set**, if Bernard was **told** the **day** of that date, he would **not know** Cheryl's birthday.\n",
"\n",
"That I can translate directly into code:"
]
@ -275,9 +275,9 @@
"def statement3(date) -> bool:\n",
" \"\"\"Albert: I don't know when Cheryl's birthday is, but I know that Bernard does not know too.\"\"\"\n",
" albert_beliefs = told(month(date))\n",
" return (not know(albert_beliefs) \n",
" and all(not know(told(day(d))) \n",
" for d in albert_beliefs))"
" return not know(albert_beliefs) and not satisfy(albert_beliefs, bernard_knows)\n",
"\n",
"def bernard_knows(date) -> bool: return know(told(day(date))) "
]
},
{
@ -481,7 +481,8 @@
}
],
"source": [
"dates = '06:32, 06:43, 06:50, 07:17, 07:46, 08:19, 08:32, 09:17, 09:19, 09:50'.replace(':', ' ').split(', ')\n",
"times = '06:32 06:43 06:50 07:17 07:46 08:19 08:32 09:17 09:19 09:50'.split()\n",
"dates = [t.replace(':', ' ') for t in times]\n",
"\n",
"cheryls_birthday()"
]

File diff suppressed because one or more lines are too long