Commit 4874a9f3 authored by Brian Guadalupe's avatar Brian Guadalupe

Updated installation steps

parent 59009bf7
......@@ -5,7 +5,7 @@ This is a Racket library for CSCI 71, which aims to implement simulators for dif
## Installation
```
raco pkg install "https://gitlab.discs.ateneo.edu/brian/csci71-lib.git?path=tm"
raco pkg install --deps search-auto "https://gitlab.discs.ateneo.edu/brian/csci71-lib.git?path=tm"
```
## Update (untested)
......
......@@ -20,17 +20,44 @@ More precisely, it is based on a formulation of the Post--Turing machine by Davi
To be able to design, test, and debug your Turing machines, you will need to set up Racket on your machine first. Most of you have taken CSCI 70 last semester anyway, so most likely you already have it installed. If not, download and install the latest version @hyperlink["https://download.racket-lang.org/" "here"].
Next, open your terminal and run the following command:
@commandline{raco pkg install "https://gitlab.discs.ateneo.edu/brian/csci71-lib.git?path=csci71-tm"}
Next, we will install the @tt{tm} package; this will make the @tt{tm} language accessible from you Racket installation through @tt{#lang tm}, as well as provide a debugger interface to test your programs.
This will install the @tt{tm} package and makes the @tt{tm} language accessible from DrRacket through @tt{#lang tm}.
To do this, first open DrRacket and click on @menuitem["File" "Install Package..."].
The Package Installer dialog should pop up.
Set the @onscreen{Package Source} to the following URL:
@centered{
@url{https://gitlab.discs.ateneo.edu/brian/csci71-lib.git?path=tm}
}
We also want for the prerequisite packages to be installed as well, so click on @onscreen{Show Details} and make sure @onscreen{Dependencies Mode} is set to @onscreen{Auto}.
@image[#:scale 0.38]{doc_imgs/tm_install.png}
Finally, click the @onscreen{Install} button near the top-right corner. You may close this window once installation is finished.
For avid terminal users, you may do the same process as above by opening your terminal and running the following command:
@commandline{raco pkg install --deps search-auto "https://gitlab.discs.ateneo.edu/brian/csci71-lib.git?path=tm"}
@subsection{The editor}
To create and edit TM programs, we will be using the DrRacket editor that comes with a typical Racket installation (most likely you already have it).
Note that every program starts with the @tt{#lang tm} header.
@subsection{Sample programs}
To help you develop your own TM programs, here is a list of sample programs so that you can see some strategies for solving problems with Turing machines.
To help you develop your own TM programs, here is a list of sample programs located in @hyperlink["http://penoy.admu.edu.ph/~guadalupe154884/classes/csci71/tm_samples/" "this directory"] so that you can see some strategies for solving problems with Turing machines.
@itemlist[
@item{@tt{anbn.tm} --- a program that recognizes strings of the form @math{@tt{a}^n@tt{b}^n} where @math{n 0}.}
@item{@tt{anbn.tm} --- a program that recognizes strings of the form @math{@tt{a}^n@tt{b}^n} where @math{n 0}; this is an example of a language that is not regular but is context-free.}
@item{@tt{anbncn.tm} --- a program that recognizes strings of the form @math{@tt{a}^n@tt{b}^n@tt{c}^n} where @math{n 0}; this is an example of a language that is neither regular nor context-free.}
@item{@tt{unary_fibo.tm} --- a program that recognizes strings of the form @math{@tt{a}^n} where @math{n} is a Fibonacci number.}
@item{@tt{sort_ab.tm} --- a program (transducer) that sorts a string consisting of @tt{a}'s and @tt{b}'s so that all @tt{a}'s appear first before @tt{b}'s.}
@item{@tt{binary_plus1.tm} --- a program that, given a binary number (i.e., a string in {@tt{0}, @tt{1}}*), increments that number by 1.}
@item{@tt{hailstone.tm} --- a program that, given a string of the form @math{@tt{a}^n} for some nonnegative integer @math{n}, accepts iff the hailstone sequence terminates for @math{n}.}
]
......@@ -50,8 +77,6 @@ Start:
Goto Start
}
Note that every program starts with the @tt{#lang tm} header.
@subsection{Labels}
Labels indicate different sections of code. Labels have no effect when executed; we just move to the next line.
The name @tt{Start} is special and means ``begin here''; this is where the program starts execution.
......@@ -85,19 +110,26 @@ Indentation serves no syntactic purpose other than to maintain or preserve clari
@section{The debugger interface}
The debugger allows you to input arbitrary strings as input to Turing machine programs and doesn't validate that your input strings have the correct alphabet.
@subsection{Using the debugger}
To launch the debugger, click the ``Run'' button on the top-right corner in the DrRacket window, or press @tt{Ctrl+R} (or @tt{Cmd-R} for macOS, I think).
@subsection{Launching the debugger}
To launch the debugger, click the @onscreen{Run} button on the top-right corner in the DrRacket window, or press @tt{Ctrl+R} (or @tt{Cmd-R} for macOS, I think).
The interactions panel will then pop up (usually below your code) and ask for the input string. The input string can be empty.
The interactions window will then pop up (usually below your code) and ask for the input string. The input string can be empty.
@image[#:scale 0.35]{scribblings/tm_debugger_input.png}
@image[#:scale 0.35]{doc_imgs/tm_debugger_input.png}
The interpreter will generate the animation frames, after which you will be presented with the debugger GUI:
@image[#:scale 0.35]{scribblings/tm_debugger_start.png}
@image[#:scale 0.35]{doc_imgs/tm_debugger_start.png}
Note that the debugger GUI will not appear if your program takes more than 100,000 steps to run; this is the hard limit imposed by the interpreter.
The debugger GUI has three main parts:
@itemlist[
@item{The @emph{program listing} shows a portion of the program (omitting any blank lines and comments) and highlights the current line in the program to be executed.}
@item{The @emph{tape} shows the current state of a portion of the (infinite) tape. The position of the tape is indicated by the blue triangle. To prevent the tape head from going out of view, the tape itself will scroll left or right.}
@item{The @emph{status line} shows the number of steps taken by the program, and the current status of the TM (whether it has accepted, rejected, or still running).}
]
@subsection{Keyboard controls}
The GUI is driven by keyboard controls. In particular:
@itemlist[@item{@tt{<space>} pauses and resumes the simulation}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment