summaryrefslogtreecommitdiff
path: root/examples/SimpleVCCompat.java
diff options
context:
space:
mode:
Diffstat (limited to 'examples/SimpleVCCompat.java')
-rw-r--r--examples/SimpleVCCompat.java70
1 files changed, 70 insertions, 0 deletions
diff --git a/examples/SimpleVCCompat.java b/examples/SimpleVCCompat.java
new file mode 100644
index 000000000..107b5504e
--- /dev/null
+++ b/examples/SimpleVCCompat.java
@@ -0,0 +1,70 @@
+/********************* */
+/*! \file SimpleVCCompat.java
+ ** \verbatim
+ ** Original author: mdeters
+ ** Major contributors: none
+ ** Minor contributors (to current version): none
+ ** This file is part of the CVC4 prototype.
+ ** Copyright (c) 2009, 2010, 2011 The Analysis of Computer Systems Group (ACSys)
+ ** Courant Institute of Mathematical Sciences
+ ** New York University
+ ** See the file COPYING in the top-level source directory for licensing
+ ** information.\endverbatim
+ **
+ ** \brief A simple demonstration of the Java compatibility interface
+ ** (quite similar to the old CVC3 Java interface)
+ **
+ ** A simple demonstration of the Java compatibility interface
+ ** (quite similar to the old CVC3 Java interface).
+ **
+ ** To run the resulting class file, you need to do something like the
+ ** following:
+ **
+ ** java \
+ ** -classpath path/to/cvc4compat.jar \
+ ** -Djava.library.path=/dir/containing/libcvc4bindings_java_compat.so \
+ ** SimpleVCCompat
+ **
+ ** For example, if you are building CVC4 without specifying your own
+ ** build directory, the build process puts everything in builds/, and
+ ** you can run this example (after building it with "make") like this:
+ **
+ ** java \
+ ** -classpath builds/examples:builds/src/bindings/compat/java/cvc4compat.jar \
+ ** -Djava.library.path=builds/src/bindings/compat/java/.libs \
+ ** SimpleVCCompat
+ **/
+
+import cvc3.*;
+
+public class SimpleVCCompat {
+ public static void main(String[] args) {
+ ValidityChecker vc = ValidityChecker.create();
+
+ // Prove that for integers x and y:
+ // x > 0 AND y > 0 => 2x + y >= 3
+
+ Type integer = vc.intType();
+
+ Expr x = vc.varExpr("x", integer);
+ Expr y = vc.varExpr("y", integer);
+ Expr zero = vc.ratExpr(0);
+
+ Expr x_positive = vc.gtExpr(x, zero);
+ Expr y_positive = vc.gtExpr(y, zero);
+
+ Expr two = vc.ratExpr(2);
+ Expr twox = vc.multExpr(two, x);
+ Expr twox_plus_y = vc.plusExpr(twox, y);
+
+ Expr three = vc.ratExpr(3);
+ Expr twox_plus_y_geq_3 = vc.geExpr(twox_plus_y, three);
+
+ Expr formula = vc.impliesExpr(vc.andExpr(x_positive, y_positive),
+ twox_plus_y_geq_3);
+
+ System.out.println("Checking validity of formula " + formula + " with CVC4.");
+ System.out.println("CVC4 should report VALID.");
+ System.out.println("Result from CVC4 is: " + vc.query(formula));
+ }
+}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback