Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
This file is an interpreter for the tiny programming language 1# used in my classes on theory of computation at Indiana University. For more on 1# and the class, see https://iulg.sitehost.iu.edu/trm. Right now, this is just for my students. But if the move to Cocalc turns out well, I might expand this to cover the basics of computability theory.
Image: ubuntu2004
Getting stared with 1#
This notebook is a new interpreter for 1# written for the Jupyter notebook. It is under development for use in my IU class M584 in this (current) fall 2022 semester. The main source on 1# is the web text available at https://iulg.sitehost.iu.edu/trm. If this notebook works out, then the plan is to convert all of the material on that web site to this format, and to make it available on Cocalc. To start, click on the box below and then press shift-enter.
To load the program, click above and press shift-enter.
Hopefully you have loaded in the Python programs that are going to run 1#.
Next, enter the cell below by clicking on it and then pressing shift-enter together. The output is a step-by-step explanation of a computation of the program 1#11#####1###1### when started with the word 1#1 in R1,and # in R2.
The last computation started with two inputs. Try changing those inputs to see what happens. As practice with the definition of halt, you might try yourself to predict what will happen before running it. You can add the symbols 1 or #, and you also can delete symbols. But you should not delete the quote marks. Also, you can change the program the same way. The idea is that you should explore this function step_by_step by trying it out on simple inputs. Here is another computation, with more explanation of the notation.
Here is an explanation of the form of the command called "step_by_step" that we have been using.
The first argument could be a 1# program surrounded by single quotes or double-quotes. If you use single quotes, you need to be sure to use the correct ones; on my screen they look straight, not slanted. You could also use a concatenation of quoted expressions (see below). But if you forget the quotes, you will get an error because the Python program that is running all of this will balk at 1# expressions without quotes around them.
In addition, you can name expressions ahead of time using assignment statements like
p = '1#'
and then write step_by_step(p,['11']), for example.
The program step_by_step begins with a parse of your program, and so if you input a word that is not a sequence of 1# expressions, it will stop without further ado.
The second argument to "step_by_step" is a list of words. A list in Python is enclosed by square brackets [ and ], not by parentheses. The words that go in the list are used in R1, R2, . . . in that order. It is understood that any register not represented by any input starts with the empty string. You can also represent the empty string by ' '. And the empty list of registers is denoted by two square brackets with nothing inside, [ ].
All in all, the examples below show different formats for the input to our function step_by_step.
So far in this notebook, we have only seen the function step_by_step. If we want to run things "in one fell swoop", we could use the function onesharp(p,[r1,r2, . . ., rn]). It also takes two arguments, the first a program and the second a (possibly-empty) sequence of input words.
File "/tmp/ipykernel_5912/1371534868.py", line 1
sage --pip install slabbe
^
SyntaxError: invalid syntax