Next: , Previous: Outputs, Up: Top


10 PrincipleWriter

The principle compiler PrincipleWriter is thoroughly described in Jochen Setz' BSc. Thesis (References). Also be sure to check out the example principles in PrincipleWriter/Examples, and the grammars suffixed PW (Grammars) which use them.

Basically, PW makes writing principles much easier. You can write down your principles in a simple first-order logic, and PW compiles them into efficient principle implementations for the XDK.

This is how it works, in a nutshell. An example is the climbing principle:

     defprinciple "principle.climbingPW" {
       dims {D1 D2}
       constraints {
     
     forall V: forall V1:
       dom(V V1 D1) => dom(V V1 D2)
       }
     }

What you do is to define the name of the principle (principle.climbingPW), the dimensions over which it should abstract (D1 and D2), and then a set of constraints.

Then you go into the directory PrincipleWriter, and call the compiler as follows:1

     pw.exe -p Examples/climbingPW.ul

This compiles the principle, and puts the principle definition functor ClimbingPW.oz into Solver/Principles and the constraint functor also called ClimbingPW.oz into Solver/Principles/Lib.

To use the principle, it has to be integrated into the XDK. You can do this using the perl script addprinciple:

     addprinciple ClimbingPW ClimbingPW

or by adding it manually as follows:

  1. add the principle definition functor to the ozmake makefile
    Solver/Principles/makefile.oz
  2. add the principle definition functor to the imported functors of the functor
    Solver/Principles/Principles.oz, and also to the list Principles on top of
    Solver/Principles/Principles.oz.
  3. add the identifier of the new principle to the XML file
    Solver/Principles/principles.xml. Here, for each new principle, you add a line like the following for the graph principle:
  4. add the constraint functor to the ozmake makefile
    Solver/Principles/Lib/makefile.oz
  5. add the constraint functor to the top level ozmake makefile makefile.oz in order to include it in the ozmake package created for the XDK.

To finalize the integration of the new principle, call ozmake from the XDK main directory (where e.g. xdk.exe resides in).

...and off you go :)


Footnotes

[1] Use pw.exe --help to get a full summary of the commandline options.