Skip to content

Commit

Permalink
changes in several notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
lmoss committed Jan 22, 2025
1 parent 1e2bca0 commit 871b862
Show file tree
Hide file tree
Showing 15 changed files with 115 additions and 448 deletions.
Binary file modified _build/.doctrees/environment.pickle
Binary file not shown.
Binary file modified _build/.doctrees/introOneSharp/functions.doctree
Binary file not shown.
Binary file modified _build/.doctrees/introOneSharp/instructions.doctree
Binary file not shown.
Binary file modified _build/.doctrees/introOneSharp/move_copy_write.doctree
Binary file not shown.
51 changes: 38 additions & 13 deletions _build/html/_sources/introOneSharp/functions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -257,28 +257,33 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "PQzllCr-Fu2y"
},
"source": [
"# Functions of two or more arguments\n",
"\n",
"A program $p$ of $\\one\\hash$ can also be used as a function of two or more arguments. Here is the relevant definition.\n",
"A program $p$ of $\\one\\hash$ can also be used as a function of zero or more arguments. Here is the relevant definition.\n",
"\n",
"\n",
"```{prf:definition}\n",
"Every word $p$ gives us a function\n",
"called $\\phifn^n_p$ on $n$-tuples words. \n",
"\n",
"$\\phifn^n_p (x_1,\\ldots, x_n) \\simeq y$ means that\n",
"$$\n",
"\\phifn^n_p (x_1,\\ldots, x_n) \\simeq y\n",
"$$\n",
"\n",
"means that\n",
" $p$ is a program,\n",
" and\n",
"when we \n",
"run it\n",
"$p$ with $x_i$ in register $i$ (for $1\\leq i \\leq n$) and all other registers empty,\n",
"$p$ with $x_i$ in R$i$ (for $1\\leq i \\leq n$) and all other registers empty,\n",
"then the register machine \n",
"eventually halts with $y$ in $\\Rone$ and all other \n",
"eventually halts with $y$ in R1 and all other \n",
"registers \n",
"empty. \n",
" \n",
Expand All @@ -288,7 +293,7 @@
"or if $p$ does not halt when run on $x$, \n",
"or if\n",
"$p$ does halt when run on $x$\n",
" but upon halting, not all of the registers besides $\\Rone$ are empty),\n",
" but upon halting, not all of the registers besides R1 are empty),\n",
"then we say that $\\phifn_p (x)$\n",
"is *undefined*.\n",
"```"
Expand Down Expand Up @@ -374,6 +379,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "WOy1_0mpgsJ9"
Expand All @@ -383,14 +389,18 @@
"\n",
"We started by associating to each program $p$ a function $\\phifn_p$ of one argument, and then for each $n \\geq 2$ we associated a function $\\phifn_p^n$ of $n$ arguments. This general definition works in case $n = 0$ also. For the record: \n",
"\n",
"$\\phifn^0_p (\\ ) \\simeq y$ means that\n",
"$$\n",
"\\phifn^0_p (\\ ) \\simeq y\n",
"$$\n",
"\n",
"means that\n",
" $p$ is a program,\n",
" and\n",
"when we \n",
"run it\n",
"$p$ with\n",
"all registers empty, the register machine \n",
"eventually halts with $y$ in $\\Rone$ and all other \n",
"eventually halts with $y$ in R1 and all other \n",
"registers \n",
"empty. \n",
"\n",
Expand Down Expand Up @@ -424,6 +434,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "ZkwdFYl1iXHH"
Expand All @@ -432,22 +443,34 @@
"\n",
"```{admonition} Definition\n",
":class: tip\n",
"A set $A\\subseteq \\words$ is *$\\one\\hash$-computable* if $\\chi_A$ is a computable function. Other names for \"computable\" include \"decidable\" and \"recursive\".\n",
"For any set $A$, the *characteristic function of $A$* is the function $\\chi_A$ given by\n",
"\n",
"$$\n",
"\\chi_A(x) = \\left\\{ \\begin{array}{ll} 1 &\\mbox{if $x\\in A$} \\\\ 0 &\\mbox{if $x\\notin A$} \\end{array}\\right.\n",
"$$\n",
"\n",
"A set $A\\subseteq \\words$ is *```1#```-computable* if $\\chi_A$ is a computable function. Other names for \"computable\" include \"decidable\" and \"recursive\".\n",
"```\n",
"\n",
"```{important}\n",
"Our work will also involve other notions of \"computable\" besides $\\one\\hash$-computability. For example, we'll see *intuitive computability*, *Turing maching computability*, *Python computability*, and other notions besides. So it will be important to keep these straight. This is why we put the \"$\\one\\hash$\" in the name \"$\\one\\hash$-computable\". But at this stage, the notion which we'll study the most is $\\one\\hash$-computability.\n",
"Our work will also involve other notions of \"computable\" besides ```1#```-computability. \n",
"We have already seen \n",
"*intuitive computability*, and this is not exactly a mathematical concept.\n",
"But we will see *Turing maching computability*, *Python computability*, and other notions besides. So it will be important to keep these straight. This is why we put the ```1#``` in the name \"```1#``` -computable\". \n",
"\n",
"The notion which we'll study the most is ```1#``` -computability.\n",
"``` "
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "aE3MtTwEk3-a"
},
"source": [
"```{exercise}\n",
"Let $A$ and $B$ be $\\one\\hash$-computable sets. Show that $A\\cap B$, $A\\cup B$, and $\\overline{A}$ are also $\\one\\hash$-computable, where \n",
"Let $A$ and $B$ be ```1#```-computable sets. Show that $A\\cap B$, $A\\cup B$, and $\\overline{A}$ are also ```1#```-computable, where \n",
"\n",
"$$\n",
"\\begin{array}{lcl}\n",
Expand All @@ -472,13 +495,14 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "J4bEhcqH41D-"
},
"source": [
"```{exercise}\n",
"Show that the following function is $\\one\\hash$-computable:\n",
"Show that the following function is ```1#```-computable:\n",
"\n",
"$$\n",
"f(w) = \\left\\{ \n",
Expand All @@ -492,6 +516,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "3NawzDg0_aea"
Expand All @@ -500,9 +525,9 @@
"```{exercise}\n",
"\n",
"(a)\n",
"As a parallel to how we defined $\\one\\hash$-computability, define what it means for a function from words to words to be *Python-computable*\n",
"As a parallel to how we defined ```1#```-computability, define what it means for a function from words to words to be *Python-computable*\n",
"\n",
"(b) There is a Python program called ```onesharp``` which takes two arguments, a $\\one\\hash$ program and a finite sequence of $\\one\\hash$-words. Assuming that ```onesharp``` behaves correctly, show that every $\\one\\hash$-computable function is Python computable.\n",
"(b) There is a Python program called ```onesharp``` which takes two arguments, a ```1#``` program and a finite sequence of ```1#``` -words. Assuming that ```onesharp``` behaves correctly, show that every ```1#``` -computable function is Python computable.\n",
"\n",
"[Hint: you will need to say clearly what \"behaves correctly\" means.]\n",
"```"
Expand Down
2 changes: 1 addition & 1 deletion _build/html/_sources/introOneSharp/instructions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@
"metadata": {},
"source": [
"```{exercise}\n",
"If you know about \\emph{formal language theory}, verify that the set of ```1#``` programs is a regular language.\n",
"If you know about *formal language theory*, verify that the set of ```1#``` programs is a regular language.\n",
"```"
]
},
Expand Down
146 changes: 2 additions & 144 deletions _build/html/_sources/introOneSharp/move_copy_write.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,57 +26,11 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {
"id": "ZUEj49fx7gDq"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: setuptools in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (75.3.0)\n",
"Collecting git+https://github.com/lmoss/onesharp.git@main\n",
" Cloning https://github.com/lmoss/onesharp.git (to revision main) to /private/var/folders/kt/458_ttf57hvdmjpsh88m1fzh0000gp/T/pip-req-build-zicec85x\n",
" Running command git clone --filter=blob:none --quiet https://github.com/lmoss/onesharp.git /private/var/folders/kt/458_ttf57hvdmjpsh88m1fzh0000gp/T/pip-req-build-zicec85x\n",
" warning: the following paths have collided (e.g. case-sensitive paths\n",
" on a case-insensitive filesystem) and only one from the same\n",
" colliding group is in the working tree:\n",
"\n",
" 'T_predicate.ipynb'\n",
" 't_predicate.ipynb'\n",
" Resolved https://github.com/lmoss/onesharp.git to commit 29e23c524bb19181fbe0f16954193237f9060116\n",
" Installing build dependencies ... \u001b[?25ldone\n",
"\u001b[?25h Getting requirements to build wheel ... \u001b[?25ldone\n",
"\u001b[?25h Preparing metadata (pyproject.toml) ... \u001b[?25ldone\n",
"\u001b[?25hRequirement already satisfied: numpy in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from onesharp==0.0.0) (1.24.4)\n",
"Requirement already satisfied: pandas in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from onesharp==0.0.0) (2.0.3)\n",
"Requirement already satisfied: IPython in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from onesharp==0.0.0) (8.12.3)\n",
"Requirement already satisfied: backcall in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from IPython->onesharp==0.0.0) (0.2.0)\n",
"Requirement already satisfied: decorator in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from IPython->onesharp==0.0.0) (5.1.1)\n",
"Requirement already satisfied: jedi>=0.16 in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from IPython->onesharp==0.0.0) (0.19.2)\n",
"Requirement already satisfied: matplotlib-inline in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from IPython->onesharp==0.0.0) (0.1.7)\n",
"Requirement already satisfied: pickleshare in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from IPython->onesharp==0.0.0) (0.7.5)\n",
"Requirement already satisfied: prompt-toolkit!=3.0.37,<3.1.0,>=3.0.30 in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from IPython->onesharp==0.0.0) (3.0.48)\n",
"Requirement already satisfied: pygments>=2.4.0 in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from IPython->onesharp==0.0.0) (2.18.0)\n",
"Requirement already satisfied: stack-data in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from IPython->onesharp==0.0.0) (0.6.3)\n",
"Requirement already satisfied: traitlets>=5 in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from IPython->onesharp==0.0.0) (5.14.3)\n",
"Requirement already satisfied: typing-extensions in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from IPython->onesharp==0.0.0) (4.12.2)\n",
"Requirement already satisfied: pexpect>4.3 in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from IPython->onesharp==0.0.0) (4.9.0)\n",
"Requirement already satisfied: appnope in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from IPython->onesharp==0.0.0) (0.1.4)\n",
"Requirement already satisfied: python-dateutil>=2.8.2 in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from pandas->onesharp==0.0.0) (2.9.0.post0)\n",
"Requirement already satisfied: pytz>=2020.1 in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from pandas->onesharp==0.0.0) (2024.2)\n",
"Requirement already satisfied: tzdata>=2022.1 in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from pandas->onesharp==0.0.0) (2024.2)\n",
"Requirement already satisfied: parso<0.9.0,>=0.8.4 in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from jedi>=0.16->IPython->onesharp==0.0.0) (0.8.4)\n",
"Requirement already satisfied: ptyprocess>=0.5 in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from pexpect>4.3->IPython->onesharp==0.0.0) (0.7.0)\n",
"Requirement already satisfied: wcwidth in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from prompt-toolkit!=3.0.37,<3.1.0,>=3.0.30->IPython->onesharp==0.0.0) (0.2.13)\n",
"Requirement already satisfied: six>=1.5 in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from python-dateutil>=2.8.2->pandas->onesharp==0.0.0) (1.17.0)\n",
"Requirement already satisfied: executing>=1.2.0 in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from stack-data->IPython->onesharp==0.0.0) (2.1.0)\n",
"Requirement already satisfied: asttokens>=2.1.0 in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from stack-data->IPython->onesharp==0.0.0) (3.0.0)\n",
"Requirement already satisfied: pure-eval in /Users/lsm/Dropbox/book2025/jupyter-book-demo/.venv/lib/python3.8/site-packages (from stack-data->IPython->onesharp==0.0.0) (0.2.3)\n"
]
}
],
"outputs": [],
"source": [
"!python -m pip install -U setuptools\n",
"!python -m pip install -U git+https://github.com/lmoss/onesharp.git@main\n",
Expand Down Expand Up @@ -182,102 +136,6 @@
"Even better, we can get an parse with glosses, as follows:"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 269
},
"id": "S-4FiMeLHFcP",
"outputId": "182a9974-e843-4eb4-f32c-ece4236b9eca"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting Jinja2\n",
" Using cached jinja2-3.1.5-py3-none-any.whl.metadata (2.6 kB)\n",
"Collecting MarkupSafe>=2.0 (from Jinja2)\n",
" Using cached MarkupSafe-2.1.5-cp38-cp38-macosx_10_9_universal2.whl.metadata (3.0 kB)\n",
"Using cached jinja2-3.1.5-py3-none-any.whl (134 kB)\n",
"Downloading MarkupSafe-2.1.5-cp38-cp38-macosx_10_9_universal2.whl (18 kB)\n",
"Installing collected packages: MarkupSafe, Jinja2\n",
"Successfully installed Jinja2-3.1.5 MarkupSafe-2.1.5\n"
]
},
{
"data": {
"text/html": [
"<style type=\"text/css\">\n",
"#T_a8fee_row0_col0, #T_a8fee_row0_col1, #T_a8fee_row1_col0, #T_a8fee_row1_col1, #T_a8fee_row2_col0, #T_a8fee_row2_col1, #T_a8fee_row3_col0, #T_a8fee_row3_col1, #T_a8fee_row4_col0, #T_a8fee_row4_col1, #T_a8fee_row5_col0, #T_a8fee_row5_col1, #T_a8fee_row6_col0, #T_a8fee_row6_col1 {\n",
" background-color: #C9DFEC;\n",
" text-align: left;\n",
"}\n",
"</style>\n",
"<table id=\"T_a8fee\">\n",
" <thead>\n",
" <tr>\n",
" <th class=\"blank level0\" >&nbsp;</th>\n",
" <th id=\"T_a8fee_level0_col0\" class=\"col_heading level0 col0\" >instruction</th>\n",
" <th id=\"T_a8fee_level0_col1\" class=\"col_heading level0 col1\" >explanation</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th id=\"T_a8fee_level0_row0\" class=\"row_heading level0 row0\" >1</th>\n",
" <td id=\"T_a8fee_row0_col0\" class=\"data row0 col0\" >11#####</td>\n",
" <td id=\"T_a8fee_row0_col1\" class=\"data row0 col1\" >cases on R2</td>\n",
" </tr>\n",
" <tr>\n",
" <th id=\"T_a8fee_level0_row1\" class=\"row_heading level0 row1\" >2</th>\n",
" <td id=\"T_a8fee_row1_col0\" class=\"data row1 col0\" >111111###</td>\n",
" <td id=\"T_a8fee_row1_col1\" class=\"data row1 col1\" >go forward 6 to instruction 8</td>\n",
" </tr>\n",
" <tr>\n",
" <th id=\"T_a8fee_level0_row2\" class=\"row_heading level0 row2\" >3</th>\n",
" <td id=\"T_a8fee_row2_col0\" class=\"data row2 col0\" >111###</td>\n",
" <td id=\"T_a8fee_row2_col1\" class=\"data row2 col1\" >go forward 3 to instruction 6</td>\n",
" </tr>\n",
" <tr>\n",
" <th id=\"T_a8fee_level0_row3\" class=\"row_heading level0 row3\" >4</th>\n",
" <td id=\"T_a8fee_row3_col0\" class=\"data row3 col0\" >1##</td>\n",
" <td id=\"T_a8fee_row3_col1\" class=\"data row3 col1\" >add # to R1</td>\n",
" </tr>\n",
" <tr>\n",
" <th id=\"T_a8fee_level0_row4\" class=\"row_heading level0 row4\" >5</th>\n",
" <td id=\"T_a8fee_row4_col0\" class=\"data row4 col0\" >1111####</td>\n",
" <td id=\"T_a8fee_row4_col1\" class=\"data row4 col1\" >go backward 4 to instruction 1</td>\n",
" </tr>\n",
" <tr>\n",
" <th id=\"T_a8fee_level0_row5\" class=\"row_heading level0 row5\" >6</th>\n",
" <td id=\"T_a8fee_row5_col0\" class=\"data row5 col0\" >1#</td>\n",
" <td id=\"T_a8fee_row5_col1\" class=\"data row5 col1\" >add 1 to R1</td>\n",
" </tr>\n",
" <tr>\n",
" <th id=\"T_a8fee_level0_row6\" class=\"row_heading level0 row6\" >7</th>\n",
" <td id=\"T_a8fee_row6_col0\" class=\"data row6 col0\" >111111####</td>\n",
" <td id=\"T_a8fee_row6_col1\" class=\"data row6 col1\" >go backward 6 to instruction 1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n"
],
"text/plain": [
"<pandas.io.formats.style.Styler at 0x11cf6b640>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"!pip install Jinja2\n",
"import pandas as pd\n",
"parse_explain(move_2_1)"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand Down
Loading

0 comments on commit 871b862

Please sign in to comment.