This git project presents the Jupyter notebooks that go with Ganesh L. Gopalakrishnan's book
Automata and Computability: Programmer's Perspective
We may abbreviate this book's title by ``ACPP''
The Github URL for this README.md is https://github.com/ganeshutah/Jove.git
The code collection is called "Jove" (which the reader may recognize as another name for planet Jupiter). We will refer to the software offering as a whole as "Jove notebooks" but sometimes also as Jupyter notebooks (when referring to the individual notebooks).
Jove is a collection of Jupyter notebooks illustrating many principles:
Some of the Jupyter notebooks start with a Youtube video link describing the notebook's content and operation. This can serve as a handy ``self-tutorial'' of the notebook. Even without such a video, all notebooks are documented to some extent as are the functions introduced.
PLEASE NOTE: The Youtube videos often contain class lecture screen recordings. Feel free to scroll around in these videos to locate Jove (Jupyter notebook) sessions, and follow those.
Jove's structure is kept deliberately simple to cater to a broad audience. We do not employ classes or objects. All automata are simple structs. A functional style of programming is preferred where each function takes an automaton-struct and returns another.
We often prefer a side-effect-free functional/recursive/higher-order style of coding to make the logic of the function stand out. When iteration makes sense (e.g. NFA to RE conversion) we do employ the more familiar iterative style.
The section contents specifies how we offer all the files belonging to Jove.
Most automata (NFA, DFA, PDA, and Turing machines) have "Def..." files that define basic operations on these machine-types. We then provide "Drive..." files that drive these definitions to illustrate the use of the functions.
In order to include the "Def..." files into the "Drive..." files, we prefer to generate Python [.py] files from the former, store these files into an jove/ directory, and include those [.py] files into the "Drive_..." files. While the direct importing of Jupyter notebooks into other notebooks is supported, we once ran into bugs, and felt that this arrangement was more foolproof.
A key requirement is to have lex.py and yacc.py in the top-level directory. This will be invoked during parsing.
All automata are displayed using Graphiviz for which your Jupyter notebook must have Graphiviz installed; we provide [complete instructions in this section.] (#obtaining-and-setting-up-jupyter-for-running-jove).
Please consider installing Jupyter Lab after you setup Jupyter. It makes Jove shine! Here is info on the just-released Jupyter Lab
In order to run Jove, you need to set up Jupyter on your machine. Detailed instructions for setting up Jupyter are provided IN THIS OVERLEAF DOCUMENT. (which will be kept updated) and also in THIS SECTION (which may become obsolete; hopefully not)
Salient contents of this git directory are now described:
Begin by taking tutorials from the tutorials directory. This directory contains [.ipynb] notebooks that have embedded Youtube links. The [Jove Tutorials are described in detail here] (#jove-tutorials-are-described-in-detail-here). Just go to this directory and type 'jupyter notebook' and execute the cells in tutorial notebooks you see here.
While drawing is a good way to create small machines, larger machines are like assembly code: you must create them with good documentation and well-chosen state names. For this, we provide a convenient markdown syntax.
You may descend into any of these directories and execute the Jupyter notebooks you find there. Here are more specifics:
Module_... contained in the notebooks/modules directory:
- These files were created before we designed Jove's input markdown language. They are still valuable illustrations.
Notice that some of the very well-coded Turing machines (by Ian Briggs) are available only in the ``low-level'' form (specifically inside Module10_TM.ipynb) -- and not in the markdown form yet. Thus, this module directory has great value for studying some non-trivial TMs.
The machines directory contains four directories dfafiles, nfafiles, pdafiles, and tmfiles that contain examples of Jove markdown files. This is how you can build machines using an editor and load into Jove via the command md2mc.
Def_.. files contained in notebooks/src directory
- This is a directory containing Jove definitions. We exported these Jupyter notebooks into [.py] and stuck them within the jove directory
Drive_... files contained in the notebooks/driver
- This is a directory containing many useful illustrations of Jove. Some are called out in the Jove tutorial to follow in the next section. All these Drive_... files have a fairly high pedagogical value (in our estimate, anyway)
We now provide a tutorial introduction to Jove. We encourage you to load-up these [.ipynb] files, watch the Youtube video at its beginning (assuming it has one), and then experiment with its contents. We will mention the names of the [.ipynb] files below, and in case they are backed by a Youtube video, then mention that video's link as well. We mention the youtube links because in case you have not successfully set up Jupyter notebooks, you can still experience Jove.
Once you follow the instructions listed under [Obtaining and Setting up Jupyter for running Jove] (#obtaining-and-setting-up-jupyter-for-running-jove), you can run the Jupyter file [.ipynb] either cell by cell or by the ``run all cells'' command.
PLEASE NOTE: Some of the Youtubes are live class-lecture recordings, and may contain material that you do not care about. Feel free to zoom forward till I illustrate things on Jupyter notebooks.
We now describe the tutorials provided.
[THIS YOUTUBE VIDEO] (https://youtu.be/FQJ4qN44Syg) sets the stage for the ACPP book, and introduces some basics, including how you can become proficient in Jupyter notebooks and also learn a subset of the markdown language (usable to create documentation within Jupyter notebooks.
- The associated Jupyter notebook is Module1_Computability.ipynb
[THIS YOUTUBE VIDEO] (https://youtu.be/gaWmjvJ-mP4) demonstrates how to define strings and languages in Jove. It also describes how one can perform language operations, including union, intersection, and Kleene-star.
The Jupyter notebook to practice these ideas is Module2_LanguageOps.ipynb
DFA definition and operations on DFA are presented in THIS YOUTUBE VIDEO
- The associated Jupyter notebooks are Def_DFA.ipynb and Drive_DFA_Unit1.ipynb go with the above video.
These notebooks introduce the markdown syntax, how to build a DFA, etc. Testing DFAs can be achieved by introducing a way to generate strings as per the numeric order. This ensures that all short strings are exhaustively tested before longer strings are tried.
Another useful Youtube that introduces DFA is in THIS YOUTUBE VIDEO
The Jupyter file DFAUnit2.ipynb goes with this video. This covers more DFA operations.
NFA operations, including using Jupyter widgets to show EClosure are shown in THIS YOUTUBE VIDEO and also THIS YOUTUBE VIDEO
- The associated Jupyter notebook is Drive_NFA.ipynb.
THIS YOUTUBE VIDEO describes the material.
- The associated Jupyter notebook is Drive_NFA_9_26_17_Class.ipynb
These two neat topics are presented in THIS YOUTUBE VIDEO
- The associated Jupyter notebook is Drive_NFA_9_28_17_Class.ipynb
THIS YOUTUBE VIDEO presents the basics
- The associated Jupyter notebooks are A4J.ipynb and A4JSoln.ipynb
Pushdown Automata (with a CFG-parsing perspective) are explained here in THIS YOUTUBE VIDEO
- The associated Jupyter notebook is Drive_PDA_Ch12_Recording.ipynb
PDA design with acceptance of various inputs (by empty stack or final state) are explained in THIS YOUTUBE VIDEO
- The associated Jupyter notebook is Drive_PDA_w_asg5_possibilities_emptystk_a1b2.ipynb
Turing Machines are explained in THIS YOUTUBE VIDEO
- The associated Jupyter Notebook is Ch13_Recording.ipynb
Much of the convenience of defining machines stems from Jove's ability to handle machines described via a markdown syntax.
- Please peruse Def_md2mc.ipynb and Drive_md2mc.ipynb to fully appreciate how Jove's own markdown processing works. In a sense, this is a mini compiler that takes Jove's markdown and produces the ``machine'' (hash-table) version of Jove's code
Code written prior to this markdown facility being developed is in ModuleN_... files
We perform all the processing of ``machine'' (hash-table) descriptions and convert them into Graphviz objects.
- File DotBashers.ipynb is the heart of this markdown processing. This file also checks for the well-formedness of machines. It also has utilities such as fuse-edges to collapse multiple machine-edges into one
Start the installer (instructions assume 64-bit)
To install system-wide:
To install only for your user:
In the installer, do the following:
Exit that terminal and open a new one.
Install the graphviz command-line module (use 'sudo -H' if you installed Anaconda 3 system-wide)
Now install the python module for using graphviz. First, make sure the 'pip' tool used is the one from the Anaconda 3 install.
Now for the installing of the graphviz python module. If you installed Anaconda 3 into your home directory, then do the following:
If you installed Anaconda 3 system-wide, you can install the graphviz module system-wide:
Go to Make sure the install works section at the end to verify correct installation.
Run the installer installing into your home directory. Open a terminal. Install the graphviz command-line tools.
Now install the graphviz python module
Go to Make sure the install works section at the end to verify correct installation.
Run the installer installing into your home directory. You do not need to add the Anaconda 3 directories to your system PATH.
After the install, open an Anaconda Prompt (go to the start menu and search ``Anaconda Prompt'').
In this prompt, install graphviz
Now install the python graphviz module
Now the graphviz module (or arguably the subprocess module) has a bug that we will need to work around. Basically, calling subprocess.check_call(['dot']) doesn't match with dot.bat that is in the system PATH. There are two fixes for this. Choose whichever one you want.
The first is to add the graphviz command-line tool directory to your system path
The second is to replace 'dot' with 'dot.bat' in the graphviz python module.
Go to the section Make sure the install works
Now, start the Jupyter notebook
jupyter notebook
If this doesn't open a browser to your notebook, it should print instructions on what to do. Primarily it should give you something to copy and paste into a browser.
Try out some graph generation in your Jupyter notebook. Enter the following in the first cell and press Shift-Enter.