15-816 Linear Logic

Linear Twelf

The current version of linear Twelf is 0.2, it is available from this site: ltwelf-0.2.tar.gz. Be aware, it may still contain bugs. Nevertheless, it should run fine for the purpose of the homework. It requires Standard ML of New Jersey Version 109.27 or later. There are some precompiled heaps (for Linux 2.0, Sun Solaris, and Sun OS) available in /afs/cs/project/twelf/misc/ltwelf/bin/. They run only if you have the bin directoy of SML in your local path. To start linear Twelf type /afs/cs/project/twelf/misc/ltwelf/bin/ltwelf. If you need linear Twelf to be compiled for a different architecture just let me know.

Language notes

As a standard, a configuration is defined by a SML file config.sml which should reside in the directory where the actual code is. For the example of Mini-ML with references, it looks like

val MLR = FrontEnd.defineConfig [
The files syntax.llf, typing.llf, and eval.llf are the signatures files, as shown in class.

Loading the config file defines a configuration MLR which you can now easily load with

FrontEnd.compileConfig MLR;

To start the interpreter type

FrontEnd.top ();
and the system prompt ?- asks you for your query. If you type in
tpe (letval (ref (s (s z))) ([g] 
      letval (ref z) ([r] 
        (fix ([twice]  case (! g) noop ([y] (g is y ; r is (s (s (! r))) ; twice)))) ;
          (! r)))) X.
you should get the answer
X = nat.
%P =
      ([x:exp] [Te1:tpe x (nat tref)]
             ([x1:exp] [Te2:tpe x1 (nat tref)]
                 tpe_seq (tpe_deref Te2)
                        ([x2:exp] [Te3:tpe x2 cmd]
                               ([x3:exp] [Te4:tpe x3 nat]
                                   tpe_seq Te3
                                              (tpe_s (tpe_s (tpe_deref Te2)))
                                          (tpe_assign Te4 Te1)))
                               tpe_noop (tpe_deref Te1))))
             (tpe_ref tpe_z))
      (tpe_ref (tpe_s (tpe_s tpe_z))).
where X = nat states that the logic variable X has been instantiated by nat, and it also returns the proof term (always written as %P = ...).

Frank Pfenning, Carsten Schuermann