Foundations of Computer Science, Spring 2007
School of Computing, University of Utah
Course Numbers: CPSC 5100 and 6100
FAQ on Tools

Let me begin with Lu's new README file.

0.1  Lu's README File for BED

Two Ways to run BED Tools
  1. I Use it directly in CS machines:
    1. Log into your CS account, add the following two lines into your .bash_profile file and source it.

      export PATH=$PATH:/home/luzhao/course/6100/grail/bin:/home/luzhao/course/6100/bed-2.5/bin

      export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/luzhao/course/6100/bed-2.5/lib

      If you use C shell family, use the following syntax in your .tcshrc or .cshrc

      set PATH = ($PATH path_to_bed_bin) set LD_LIBRARY_PATH = ($LD_LIBRARY_PATH path_to_bed_lib)

      and source it.

    2. Then you're ready to go by typing "bed". It's said better to use "ssh -Y" option to your cs account for X11 forwarding if you don't directly sit in front of a CS machine.


  2. Compile and Install it in your own linux home directory
    1. Download it at http://www.itu.dk/research/bed/. Sometime it's unreachable, so you need to check it periodically until it's online.

    2. Compile. The compilation instruction is in its README file, and it's pretty easy to follow. If your gcc is 3.3, there should be any problem. However, if your gcc is 4.1, you may get a compiler error, which is caused by a stricter checking in 4.1. Then you need to change the is_push macro defined in libutil/istack.h into a function. Jeremy rewrote the function as the following:
      inline int is_push( iStack *s, int e )
      {
        if( s->top == s->arr_end ) {
          *is_expand( s ) = e;
        } else {
          *(s->top++) = e;
        }
        return e;
      }
           
      Then your gcc 4.1 should be able compile it.

0.2  Lu's README File for Grail


Three ways to use grail tools.

I. USE Grail TOOLS on CADE Machine

1. Login to any CADE linux box by using lab1-*.eng.utah.edu or best-linux.eng.utah.edu.

2. Add the following envrionment variables in your .bash_profile or .csh,
    I'm using bash syntax here.

export FA2GRAIL_PERL=/home/zhao/course/6100/grail/bin/fa2grail.perl
export GRAIL2PS_PERL=/home/zhao/course/6100/grail/bin/grail2ps.perl
export PATH=/home/zhao/course/6100/grail/bin:$PATH

3. Update your shell environment by "source ~/.bash_profile" or the corresponding
   csh command.

4. Run test piped command at your own working directory:

fa2grail.perl /home/zhao/course/6100/grail/bin/fa.txt |fmdeterm |perl $GRAIL2PS_PERL - |gv -

echo "a*" | retofm | fmdeterm | fmmin | perl $GRAIL2PS_PERL - |gv -

you should see different state machines. If you want to save the output ps file,
use redirection symbol > to put it into a file like the following:

echo "a*" | retofm | fmdeterm | fmmin | perl $GRAIL2PS_PERL - > adfa.ps

5. If you want customize the output, like save the generated dot file,
   make a copy of $GRAIL2PS_PERL into your home directory and comment out the line of

system("/bin/rm -rf ".$arg.".dot");

and use your own pathname in the perl command.


II. USE Grail TOOLS on CS Machine

1. Login to your CS account.

2. Add the following envrionment variables in your .bash_profile or .csh,
   I'm using bash syntax here.

export FA2GRAIL_PERL=/home/luzhao/course/6100/grail/bin/fa2grail.perl
export GRAIL2PS_PERL=/home/luzhao/course/6100/grail/bin/grail2ps.perl
export PATH=/home/luzhao/course/6100/grail/bin:$PATH

3. Update your shell environment by "source .bash_profile" or the corresponding csh command.

4. Run test piped command at your own working directory:

fa2grail.perl /home/luzhao/course/6100/grail/bin/fa.txt |fmdeterm |perl $GRAIL2PS_PERL - | ggv -

echo "a*" | retofm | fmdeterm | fmmin | perl $GRAIL2PS_PERL - |ggv -

you should see different state machines. If you want to save the output ps file,
use redirection symbol > to put it into a file like the following:

echo "a*" | retofm | fmdeterm | fmmin | perl $GRAIL2PS_PERL - > adfa.ps

5. If you want customize the output, like save the generated dot file, make a copy
    of $GRAIL2PS_PERL into your home directory and comment out the line of

system("/bin/rm -rf ".$arg.".dot");

and use your own pathname in the perl command.


III. INSTALL YOUR OWN COPY of GRAIL TOOLS

by downloading it at http://www.cs.utah.edu/ganesh-comp-engg-book/grail.tar.gz.
It's a precompiled version for linux. It's almost ready to go after decompression.
You need to check the command locations in the two perl scripts to fit your system.
  
See Section 0.3 for Ocaml and other tools to be used in Chapter 6, Section 0.4 for BED, Grail, and JFLAP (usage begins around Chapter 8), and 0.5 for Spin, and TLC.

0.3  Tools for Chapter 6

In Chapter 6, I hope to present to you a Lambda reducer written using the functional language Ocaml. This also illustrates many of the concepts you have studied, including signatures.

Ocaml has been installed on the EMCB 220 Windows machines, apparently. However, the easiest is to get Ocaml from http://caml.inria.fr. It installs very easily, both on Windows and on Linux machines. It's one of the world's most productivity-enhancing as well as efficient programming languages!

We will need Ocaml in about a week (with respect to 1/21/07).

0.4  Checklist to ensure you can run Grail, BED, and JFLAP

We will soon begin using multiple tools. In order to be able to use them, please go through this checklist by the class of 1/25/07. If you go through this checklist successfully, you are good to go as far as Grail and BDDs (using the BED tool) go.

We will be needing BED and Grail in about a week (with respect to 1/21/07).
  1. Do you have a machine you can install software on, and prefer doing so? If so, please skip these initial steps (but do read them because you'll find URLs and/or instructions for download and installation in this sequel).

  2. Students taking classes in SoC are eligible for CADE machine accounts. For further info on getting accounts, contact opers@eng.utah.edu or visit them in EMCB 210.
  3. Once you get an account, make sure you can log on to a CADE Linux machine. An example would be lab4-5.eng.utah.edu. Often, the following command finds for you the ``best'' Linux machine:
    ssh -Y best-linux.eng.utah.edu
  4. Once you login to such a machine, type /home/ganesh/BED
  5. If you get a prompt, try this sequence of commands:
             > var a b c
             > let d = a and b and c
             > upall d
             > view d
             > (Here, you may get an error message. Fear not.)
             > quit
           
    Then come out and look at your home directory using, say, `ls -lt | more'.

    It will show at the top of the listing a pdf file. The name of the pdf file will be number_number.pdf. Anyway, copy that PDF file and view it. You should see a BDD for a 3-input AND-gate at this point! A BDD compactly represents a Boolean function (see Chapter 11).

  6. The `view' command calls `gv' or `ggv' (ghostview), and if found, displays the BDD direcly

  7. opers@eng tell me that `gv' is installed at
    /usr/X11R6/bin/gv. So you should be able to see the BDD directly if your path setting is right. I've tried it just now and it works.

  8. Note: The Binary for BED I've kept runs only on ``x86'' machines (otherwise known as Linux machines). However, BED is available for download and installation from

    www.itu.dk/research/bed

  9. I used BED in CS 3700 to avoid lengthy circuit simulations. If you are interested, see
    www.cs.utah.edu/classes/cs3700/handouts/11:2-14
    The BDD tutorial there can be quite useful.

  10. Now install and/or try out the grail tools discussed from Chapter 8 onwards. Read on.

  11. Connect to (change directory to) /home/ganesh/grail (again on a CADE Linux machine such as lab4-5.eng.utah.edu). Try these commands.

  12. Please do not run ``grail''. That is not the executable. It is the commands in the pipeline below (plus more) that comprise the grail suite of tools.

  13.   echo "a*" | retofm | fmdeterm | fmmin | perl grail2ps.perl - | ps2pdf - > /tmp/test1.pdf
      
      xpdf /tmp/test1.pdf
     
    You should see a DFA for the regular language a*. Again, should `gv' or `ggv' become available, you can type instead
      echo "a*" | retofm | fmdeterm | fmmin | perl grail2ps.perl - | ggv -
     
    as the commands on Pages 177 and 180 illustrate.

  14. The Grail binaries are available from my book's website
    http://www.cs.utah.edu/ganesh-comp-engg-book
    Again, if this version experiences a crash, it is perhaps because `dot' could not be found in your current directory (./dot).

    In the version of grail2ps.perl provided in /home/ganesh/grail, I've typed `dot' instead of `./dot' and so you may try making this change in the grail you download from my book's website.

  15. JFLAP may be downloaded from http://www.jflap.org. It is extremely useful for understanding DFA, NFA, PDA, and most importantly non-deterministic Turing machines. JFLAP is thoroughly documented on its website. There is even a textbook describing JFLAP.

  16. If the above commands work fine, you are good to go as far as Grail, BDDs (using the BED tool), and JFLAP go. If not, plz send teach-cs6100 a message describing the part you are having trouble with.

0.5  Tools to be used later

Right now, I have included TLC in the list of ``tools to be used later.'' You can take 3-4 weeks (with respect to 1/21/07) to set this tool up (and the TA will help you with the tool installation as well). There is no real hurry here.

TLC is described (and available) at http://research.microsoft.com/users/lamport/tla/book.html


This document was translated from LATEX by HEVEA.