Skip to content

Commit

Permalink
deploy: 32b0f8a
Browse files Browse the repository at this point in the history
  • Loading branch information
lmoss committed Jan 9, 2025
1 parent 70caf76 commit 74b2621
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 138 deletions.
190 changes: 89 additions & 101 deletions _sources/introOneSharp/instructions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"collapsed": false,
Expand All @@ -19,7 +20,7 @@
"source": [
"## First steps\n",
"\n",
"To start, either download this notebook and run it locally, or else click on 'Open in Colab' above. Then click on the triangle below. It should take some time -- 35 seconds for me -- and then a green check appears on the left. This action loads a set of Python programs which are run in the backround in the rest of this notebook. You will not need to look at those programs, and even if you want to look at them it would probably be better not to do so as you learn ```1#```."
"To start, either download this notebook and run it locally, or else click on 'Open in Colab' above. Then click on the triangle below. It should take some time (always less than a minute for me). Ignore all of the output on the screen, but look for a green check near where you clicked. This action loads a set of Python programs which are run in the backround in the rest of this notebook. You will not need to look at those programs, and even if you want to look at them it would probably be better not to do so as you learn ```1#```."
]
},
{
Expand Down Expand Up @@ -67,20 +68,51 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"%%capture\n",
"import ipywidgets as widgets\n",
"from IPython.display import display\n",
"\n",
"class date_input():\n",
" def __init__(self, \n",
" year = \"\", \n",
" month = \"\", \n",
" day = \"\"\n",
" ):\n",
" self.year = widgets.Text(description = 'program',value = year)\n",
" self.month = widgets.Text(description = 'R1',value = month)\n",
" self.day = widgets.Text(description = 'R2',value = day) \n",
" self.year.on_submit(self.handle_submit)\n",
" self.year.on_submit(self.handle_submit)\n",
" self.year.on_submit(self.handle_submit)\n",
" display(self.year, self.month, self.day)\n",
"\n",
" def handle_submit(self, text):\n",
" self.v = text.value\n",
" return self.v\n",
"\n",
"print(\"Enter a program and two registers, then press return in any field.\")\n",
"f = date_input()\n",
"# this is from\n",
"# https://stackoverflow.com/questions/43744999/using-ipython-ipywidget-text-to-create-multiple-variables"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"tags": [
"hide_code"
]
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Enter a program and two registers, then press return in any field.\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "df45f0264b554966b4e69d446c8630fa",
"model_id": "182925b268cc4b4bb84675a9ae90d6ff",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -94,7 +126,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "462ac9460c004ea0b18d05f3baf63e60",
"model_id": "47a878de51044066a025f9236012fd71",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -108,7 +140,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "8490e885e00e4b1f898b2576b8681e8e",
"model_id": "c94509a32f3c49e08ce6c01b8d8053b5",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -118,41 +150,36 @@
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6ed6b5670222459abbc74fc6032fbdb7",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Button(button_style='success', description='Run', style=ButtonStyle())"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "42ac3680b93c46f5a11a764bb3f6e7c9",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import ipywidgets as widgets\n",
"from IPython.display import display\n",
"\n",
"class date_input():\n",
" def __init__(self, \n",
" year = \"\", \n",
" month = \"\", \n",
" day = \"\"\n",
" ):\n",
" self.year = widgets.Text(description = 'program',value = year)\n",
" self.month = widgets.Text(description = 'R1',value = month)\n",
" self.day = widgets.Text(description = 'R2',value = day) \n",
" self.year.on_submit(self.handle_submit)\n",
" self.year.on_submit(self.handle_submit)\n",
" self.year.on_submit(self.handle_submit)\n",
" display(self.year, self.month, self.day)\n",
"\n",
" def handle_submit(self, text):\n",
" self.v = text.value\n",
" return self.v\n",
"\n",
"print(\"Enter a program and two registers, then press return in any field.\")\n",
"f = date_input()\n",
"# this is from\n",
"# https://stackoverflow.com/questions/43744999/using-ipython-ipywidget-text-to-create-multiple-variables"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# @title Interpreter\n",
"f = date_input()\n",
Expand All @@ -171,7 +198,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
Expand All @@ -180,16 +207,7 @@
"id": "MPjUbJF95HHZ",
"outputId": "fda582c8-6d5d-4685-9415-79963fd143d5"
},
"outputs": [
{
"ename": "SyntaxError",
"evalue": "EOL while scanning string literal (<ipython-input-16-be182edc98d2>, line 13)",
"output_type": "error",
"traceback": [
"\u001b[0;36m File \u001b[0;32m\"<ipython-input-16-be182edc98d2>\"\u001b[0;36m, line \u001b[0;32m13\u001b[0m\n\u001b[0;31m R1 = '#11#\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m EOL while scanning string literal\n"
]
}
],
"outputs": [],
"source": [
"def end_strip(list): ## removes the tail of empty registers\n",
" if list == []:\n",
Expand All @@ -203,34 +221,7 @@
"\n",
"\n",
"program = '11#####111111###111###1##1111####1#111111####' #@param {type:\"string\"}\n",
"R1 = '#11#"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'#11###111111#'"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"##1' #@param {type:\"string\"}\n",
"R1 = '#11###1' #@param {type:\"string\"}\n",
"R2 = '11111#' #@param {type:\"string\"}\n",
"#R3 = '' #@param {type:\"string\"}\n",
"\n",
Expand All @@ -243,7 +234,7 @@
"a = [R1,R2]\n",
"a = [remove_multiple_blanks(x) for x in a]\n",
"\n",
"onesharp(program,a)\n"
"onesharp(program,a)"
]
},
{
Expand Down Expand Up @@ -410,6 +401,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "kFwH6_CugCNx"
Expand All @@ -423,11 +415,11 @@
"\n",
"We have already been using this terminology. For example, we saw\n",
"\n",
"11#####111111###111###1##1111####1#111111####\n",
"```11#####111111###111###1##1111####1#111111####```\n",
"\n",
"near the top of this notebook. This is the following sequence of instructions:\n",
"near the top of this notebook. This is the following sequence of seven instructions:\n",
"\n",
"11##### 111111### 111### 1## 1111#### 1# 111111####\n",
"(```11#####```, ```111111###```, ```111###```, ```1##```, ```1111####```, ```1#```, ```111111####```)\n",
"\n",
"Dividing a program into instructions is a very easy form of *parsing*. In a real computer language, parsing is more difficult than it is for ```1#```. \n",
"\n",
Expand All @@ -436,11 +428,16 @@
"Let us emphasize something about programs.\n",
"\n",
"```{important}\n",
"Any sequence of 1# instructions is a program. A program doesn't come with an explanation of what \"it is supposed to do\".\n",
"Any sequence of ```1#``` instructions run together as a single word is a program. \n",
"\n",
"Spaces inside do not matter. \n",
"\n",
"A program doesn't come with anything else an explanation of what \"it is supposed to do\".\n",
"```\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "HQ3wlzp5eDEm"
Expand All @@ -450,9 +447,9 @@
"Words have to be *finite*, and so programs also must be finite. Further, each program $p$ of ```1#``` can only mention finitely many registers.\n",
"\n",
"(That is, there is a finite set $F\\subseteq \\N$ such that if\n",
" $\\one^k \\hash$ is an instruction in $p$, then $k\\in F$;\n",
"if $\\one^k \\hash\\hash$ is an instruction in $p$, then $k\\in F$;\n",
"and $\\one^k \\hash^5$ is an instruction in $p$, then $k\\in F$.)\n",
" ```1^k #``` is an instruction in $p$, then $k\\in F$;\n",
"if ```1^k ##``` is an instruction in $p$, then $k\\in F$;\n",
"and ```1^k #####``` is an instruction in $p$, then $k\\in F$.)\n",
"```"
]
},
Expand Down Expand Up @@ -1080,15 +1077,6 @@
"It would be good to read about the basics of Jupyter notebooks. If you got this far, perhaps you know enough already.\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "KHOJQG3lBHaH"
},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Loading

0 comments on commit 74b2621

Please sign in to comment.