4 ### Original author: mdeters
5 ### Major contributors: none
6 ### Minor contributors (to current version): none
7 ### This file is part of the CVC4 prototype.
8 ### Copyright (c) 2009, 2010, 2011 The Analysis of Computer Systems Group (ACSys)
9 ### Courant Institute of Mathematical Sciences
10 ### New York University
11 ### See the file COPYING in the top-level source directory for licensing
12 ### information.\endverbatim
14 ### \brief A simple demonstration of the Python interface
16 ### A simple demonstration of the Python interface. Compare to the
17 ### C++ interface in simple_vc_cxx.cpp; they are quite similar.
19 ### To run, use something like:
21 ### ln -s ../builds/src/bindings/python/CVC4.py CVC4.py
22 ### ln -s ../builds/src/bindings/python/.libs/CVC4.so _CVC4.so
27 from CVC4
import ExprManager
, SmtEngine
, Rational
, Expr
35 # Prove that for integers x and y:
36 # x > 0 AND y > 0 => 2x + y >= 3
38 integer
= em
.integerType()
40 x
= em
.mkVar("x", integer
)
41 y
= em
.mkVar("y", integer
)
42 zero
= em
.mkConst(Rational(0))
44 x_positive
= em
.mkExpr(CVC4
.GT
, x
, zero
)
45 y_positive
= em
.mkExpr(CVC4
.GT
, y
, zero
)
47 two
= em
.mkConst(Rational(2))
48 twox
= em
.mkExpr(CVC4
.MULT
, two
, x
)
49 twox_plus_y
= em
.mkExpr(CVC4
.PLUS
, twox
, y
)
51 three
= em
.mkConst(Rational(3))
52 twox_plus_y_geq_3
= em
.mkExpr(CVC4
.GEQ
, twox_plus_y
, three
)
54 formula
= Expr(em
.mkExpr(CVC4
.AND
, x_positive
, y_positive
)).impExpr(Expr(twox_plus_y_geq_3
))
56 print("Checking entailment of formula " + formula
.toString() + " with CVC4.")
57 print("CVC4 should report ENTAILED .")
58 print("Result from CVC4 is: " + smt
.checkEntailed(formula
).toString())
62 if __name__
== '__main__':