How to Use ACL2S

Follow these instructions in labs in the basement of ENS (ENS 1 or ENS 2).

  1. Start Eclipse: Start | Programs | Programming | Eclipse

  2. Create a project: Select File | New | Project... | General | Project. Then click on Next >;. Enter a new project name that will contain your ACL2 developments for this class, e.g., cs313k, and click Finish.

  3. Open the ACL2 Development perspective: Select Window | Open Perspective | Other | ACL2 Development. Then click OK. This may change the layout of your workbench.

  4. Create a new Lisp file: Select File | New | ACL2s/Lisp file. The “Directory” should already indicate the project you just created, cs313k, but if it doesn't, Browse to your new project, cs313k. Finally, pick a file name, like defuns.lisp. Select the ACL2 mode Programming (no proofs or soundness requirements/guarantees). Click Finish.

  5. Note: You may now have several panes or windows on your screen, each with a tab. One of them will read defuns.lisp. You may wish to kill the other panes, by clicking on the X beside the tab name, e.g., Navigator, Proof Tree, etc. This is just a matter of how you like to manage your screen real-estate.

    You should not have to do any of the above again. You could do all your future programming in defuns.lisp if you wish, or you could create different files for different assignments, etc. Good practice is to separate your code into modules (called “books” in ACL2). But that requires you to include the appropriate supporting books when you start developing a new one.

  6. Enter a sample definition: Click on the defuns.lisp tab. We will call this the editor window because it is here you will enter new forms and edit them until you're satisfied they say what you mean. Type this definition in the editor window, to get a feel for the auto-indenting, parenthesis-matching, and syntax-based coloring.
    (defun fact (n)
      (if (zp n)
        1
        (* n (fact (- n 1)))))
    

  7. Learn a little about the buttons: If you click on ACL2s it will display the icons that also appear on the toolbar and will give you the descriptive name of each icon. We refer to the icons by these names below. But once you learn the icons you won't have to click on ACL2s.

  8. Start a session so you can run your definitions: Click on ACL2s | (Re)start Session. A new tab will appear with a session named defuns.lisp.a2s. Note that you can click on the name of either tab and the contents of that window will be displayed. You will only need these two tabs: defuns.lisp, the editor window and defuns.lisp.a2s, the session window.

    Note: If you've never run ACL2s before, the attempt to start a new session will pop up a series of windows asking if you want to certify the ACL2s books. Answer affirmatively to get through this one-time-only certification. It takes a minute or so. Then, hit ACL2s | (Re)start Session again and it should start without error.

  9. Optional - split your Eclipse window so both windows are displayed: You may not have to do this if you've been using Eclipse. But to split the windows, select the defuns.lisp.a2s tab and then click and drag it to the far right-hand edge of the Eclipse frame. A vertical line will appear in the middle of the Eclipse frame. Then unclick. Now both the edit and session windows should appear side-by-side. You may click-and-drag the vertical bar separating them to narrow or widen one of the windows.

  10. Define fact: Click on ACL2s | Advance Todo. If you typed the definition of fact exactly as shown, then the edit window now has the definition of fact shaded gray and the session window will now have this at the bottom:
    ACL2 p>EVENT
    (defun fact (n)
      (if (zp n)
        1
        (* n (fact (- n 1)))))
    
    Summary
    Form:  ( DEFUN FACT ...)
    Rules: NIL
    Warnings:  None
    Time:  0.00 seconds (prove: 0.00, print: 0.00, proof tree: 0.00, other: 0.00)
     FACT
    ACL2 p>
    
    Your colors may vary. If your session window looks like this, then the definition of fact has been accepted. Otherwise, there is an error message in the session window and you should use it to tell you how to fix your definition of fact in the edit window. When you've fixed your typo, try Advance Todo again.

  11. Run a test: In the edit window type (fact 6) below the (defun fact ...). When you're satisfied that you've typed it correctly, Advance Todo again. This should cause the gray area to grow to cover the (fact 6) and it will add
    ACL2 p>VALUE (fact 6)
    720
    ACL2 p>
    
    to the bottom of the session window. Congratulations! You've just computed factorial of 6! The answer is 720.

  12. Run another test: In the edit window type
    (cons "Hi" (cons "from" (cons α nil)))
    
    where α is your name enclosed in double quotation marks. For example, I would type:
    (cons "Hi" (cons "from" (cons "J Moore" nil)))
    

  13. Now let's pretend you are finished with this ACL2s session and practice saving the session and quitting.

  14. Whenever you finish with an ACL2s session, quit Eclipse — Click on File | Exit, or (on my Mac) Eclipse | Quit Eclipse. Save all the files it asks about. When you start ACL2s up the next time, it will look ALMOST like it does right now. Try it. Note that the gray area is green and the session isn't running (the defuns.lisp.a2s tab says “(not running)”). You need to (re)start the session with ACL2s | (Re)start Session. Then it will look like it did!

    Warning: If you save the defuns.lisp.a2s window using the Eclipse File | Save options, you will have a file of that name in your Eclipse workspace cs313k/defuns.lisp.a2s. But this file is not easily human readable. It contains a lot of stuff that ACL2s uses to recover the state upon start-up. Do not send that to me. Find a way to send me plain text containing just your session transcript, as by copying the relevant text into a message.

  15. From here on out, I'll assume you can fire up ACL2s, define functions, run expressions, save the transcript, and save your work.