1 /********************* */
2 /*! \file simple_vc_compat_c.c
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 C compatibility interface
15 ** (quite similar to the old CVC3 C interface)
17 ** A simple demonstration of the C compatibility interface
18 ** (quite similar to the old CVC3 C interface).
24 /* #include <cvc4/compat/c_interface.h> /* use this after CVC4 is properly installed */
25 #include "bindings/compat/c/c_interface.h"
28 VC vc
= vc_createValidityChecker(NULL
);
30 /* Prove that for integers x and y:
31 * x > 0 AND y > 0 => 2x + y >= 3 */
33 Type integer
= vc_intType(vc
);
35 Expr x
= vc_varExpr(vc
, "x", integer
);
36 Expr y
= vc_varExpr(vc
, "y", integer
);
37 Expr zero
= vc_ratExpr(vc
, 0, 1);
39 Expr x_positive
= vc_gtExpr(vc
, x
, zero
);
40 Expr y_positive
= vc_gtExpr(vc
, y
, zero
);
42 Expr two
= vc_ratExpr(vc
, 2, 1);
43 Expr twox
= vc_multExpr(vc
, two
, x
);
44 Expr twox_plus_y
= vc_plusExpr(vc
, twox
, y
);
46 Expr three
= vc_ratExpr(vc
, 3, 1);
47 Expr twox_plus_y_geq_3
= vc_geExpr(vc
, twox_plus_y
, three
);
49 Expr formula
= vc_impliesExpr(vc
, vc_andExpr(vc
, x_positive
, y_positive
),
52 char* formulaString
= vc_printExprString(vc
, formula
);
54 printf("Checking validity of formula %s with CVC4.\n", formulaString
);
55 printf("CVC4 should return 1 (meaning VALID).\n");
56 printf("Result from CVC4 is: %d\n", vc_query(vc
, formula
));