1 /********************* */
2 /*! \file SimpleVC.java
4 ** Top contributors (to current version):
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS
8 ** in the top-level source directory) and their institutional affiliations.
9 ** All rights reserved. See the file COPYING in the top-level source
10 ** directory for licensing information.\endverbatim
12 ** \brief A simple demonstration of the Java interface
14 ** A simple demonstration of the Java interface.
16 ** To run the resulting class file, you need to do something like the
20 ** -cp path/to/CVC4.jar:SimpleVC.jar \
21 ** -Djava.library.path=/dir/containing/libcvc4jni.so \
26 import edu
.stanford
.CVC4
.*;
28 public class SimpleVC
{
29 public static void main(String
[] args
) {
30 System
.loadLibrary("cvc4jni");
32 ExprManager em
= new ExprManager();
33 SmtEngine smt
= new SmtEngine(em
);
35 // Prove that for integers x and y:
36 // x > 0 AND y > 0 => 2x + y >= 3
38 Type integer
= em
.integerType();
40 Expr x
= em
.mkVar("x", integer
);
41 Expr y
= em
.mkVar("y", integer
);
42 Expr zero
= em
.mkConst(new Rational(0));
44 Expr x_positive
= em
.mkExpr(Kind
.GT
, x
, zero
);
45 Expr y_positive
= em
.mkExpr(Kind
.GT
, y
, zero
);
47 Expr two
= em
.mkConst(new Rational(2));
48 Expr twox
= em
.mkExpr(Kind
.MULT
, two
, x
);
49 Expr twox_plus_y
= em
.mkExpr(Kind
.PLUS
, twox
, y
);
51 Expr three
= em
.mkConst(new Rational(3));
52 Expr twox_plus_y_geq_3
= em
.mkExpr(Kind
.GEQ
, twox_plus_y
, three
);
55 new Expr(em
.mkExpr(Kind
.AND
, x_positive
, y_positive
)).
56 impExpr(new Expr(twox_plus_y_geq_3
));
59 "Checking entailment of formula " + formula
+ " with CVC4.");
60 System
.out
.println("CVC4 should report ENTAILED.");
61 System
.out
.println("Result from CVC4 is: " + smt
.checkEntailed(formula
));