Princess — The Scala Theorem Prover

Latest release: 2024-01-12

Princess is a theorem prover (aka SMT Solver) for Presburger arithmetic with uninterpreted predicates, written entirely in Scala. Princess can reason about problems in integer arithmetic, augmented with predicates that can be axiomatised arbitrarily. Such problems can contain arbitrary quantifiers to express that some formula is supposed to hold for all or for some integers.

Main features of Princess include:

Princess runs on any platform that provides a Java runtime environment (version 1.5 or higher).

Princess won the TFA division (arithmetic problems) at CASC J6, 2012. In 2013 and 2014, Princess won in the TFI category of CASC, (integer problems), and was runner-up in the overall TFA division. We currently maintain a separate branch for full support of the TPTP format.

Princess is free software. Since version 2021-03-10, Princess is distributed under BSD 3-clause. Previous versions were distributed under LGPL v2.1 or later; under LGPL v3, and even earlier under GPL v3.

Please contact me if you are interested in any projects or thesis work related to Princess.

Download Binary Download Sources Web Interface

Examples

Sources

Benchmarks

Documentation and Publications

Installation of the binary distribution

We provide a binary distribution of the latest version of Princess. This distribution contains all required libraries, i.e., the Scala API and the Cup parser generator library; it is only necessary to have a Java runtime environment (version 1.5 or newer) installed.

To install, just download the archive and unpack it in some directory of your choice. The Princess gui can then be invoked using the script princessGui, the command line tool using the script princess. In addition, the script princessClient can be used to run Princess in client-server mode (more details).

Using Princess as a Scala Library

If you want to use the Princess API, it is easiest to start from the class ap.SimpleAPI, and use the functions in ap.parser.IExpression to construct formulae. A number of examples are included in both the source and binary distributions, in directory testcases/api.

Stable versions of Princess can be obtained from Maven Central, it is enough to add the following line to your build.sbt script:

libraryDependencies += "io.github.uuverifiers" %% "princess" % "2024-01-12"

For use in Scala3, the line has to be modified to:

libraryDependencies += ("io.github.uuverifiers" %% "princess" % "2024-01-12").cross(CrossVersion.for3Use2_13)

We also maintain a local Maven repository with stable and unstable Princess versions, with URL https://eldarica.org/maven/ and organisation id uuverifiers. If you build your software using sbt, you can simply add the following two lines in the build.sbt script to automatically download Princess during compilation:

resolvers += "uuverifiers" at "https://eldarica.org/maven/"

libraryDependencies += "uuverifiers" %% "princess" % "2024-01-12"

You can download a complete hello-world project here. The example can be compiled using sbt. If you have sbt installed, just calling sbt run in directory hw should take care of downloading Princess, and all other dependencies, compilation, and running the example.

Other examples:

Using Princess as a Java Library

The class ap.JavaWrapper can be used for processing input in textual form, for instance stored as string or a file, with exactly the same functionality as on the command line:

[...]

final ArrayList<String> options = new ArrayList<> ();

options.add("-inputFormat=pri");   // Input in the Princess format
options.add("+quiet");             // No warnings or debugging output

final String input1 =
  "\\functions { int x, y, z; } \\problem { x > y & y > z -> x > z }";

System.out.println(JavaWrapper.readFromString(input1, options));

[...]
We provide a complete example for this, including a Maven build file that will automatically download all dependencies. If you have Maven installed on your machine, you can compile and run the example by invoking
> mvn package
> mvn exec:java -Dexec.mainClass=SimpleSolving

To generate formulas programmatically within a Java application, we recommend that you have a look at the JavaSMT wrapper, which provides uniform access to Princess and many other SMT solvers. When building Java programs using Maven, it is enough to put the following lines in your pom.xml to have all required libraries downloaded automatically:

<project ...>
  ...

  <dependencies>
    <dependency>
      <groupId>org.sosy-lab</groupId>
      <artifactId>java-smt</artifactId>
      <version>4.1.0</version>
    </dependency>
    <dependency>
      <groupId>io.github.uuverifiers</groupId>
      <artifactId>princess_2.13</artifactId>
      <version>2023-06-19</version>
    </dependency>
  </dependencies>
</project>

You can again download a complete hello-world project, again including a Maven build file pre-configured to use Princess together with JavaSMT. If you have Maven installed on your machine, you can compile and run the example by invoking

> mvn package
> mvn exec:java -Dexec.mainClass=Riddle

Other Java examples:

Installation of the binary CASC/TPTP distribution

We currently maintain a separate branch for full support of the TPTP format. You can download a binary of the latest version, or the sources. This version differs from normal Princess mainly in the following points:

The Royal Family

More recently, some siblings of Princess have appeared as well:

Compilation and Installation from Sources using sbt

sbt is currently the simplest way to build Princess, you don't even have to install a Scala compiler yourself. With any recent version of sbt, simply do the following:
  1. Unpack one of the snapshots (preferably the newest one) and change to the princess-* directory
  2. Call sbt run in order to compile Princess and run it
  3. Call sbt assembly to create a standalone jar file that you can run with java -jar target/scala-2.XX/Princess-assembly-XX.jar.

After sbt assembly, you can also use the provided scripts princess, princessGui, princessClient to invoke Princess through the jar file.

Compilation and Installation from Sources using make

The compilation is so far only tested on Linux systems. For the installation, using the make tool, you need:

The actual installation consists of the following steps:

  1. Unpack one of the snapshots (preferably the newest one) and change to the princess-* directory
  2. Create a directory extlibs and copy the file java-cup-11a.jar into it
  3. In case you want to compile the parser yourself (not necessary), run make parser-jar
  4. Run make to compile Princess.

If everything went ok, it is possible to run Princess with the command ./princess <inputfile>
A list of the Princess options can be printed using ./princess -h

Applications

Here is a (probably incomplete) list of applications of Princess that I am aware of. I am interested in learning about further situations where Princess was found to be useful, so in case you have one feel free to drop me a mail!

Funding

The development of Princess has been supported by: