blob: baa901540930e3b1193563afb414d3c8b24272e6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/********************* */
/*! \file statistics.cpp
** \verbatim
** Original author: Morgan Deters
** Major contributors: none
** Minor contributors (to current version): none
** This file is part of the CVC4 project.
** Copyright (c) 2009-2014 New York University and The University of Iowa
** See the file COPYING in the top-level source directory for licensing
** information.\endverbatim
**
** \brief A simple statistics test for CVC4.
**
** This simple test just makes sure that the statistics interface is
** minimally functional.
**/
#include <iostream>
#include <sstream>
#include "expr/expr.h"
#include "expr/sexpr.h"
#include "expr/statistics.h"
#include "smt/smt_engine.h"
using namespace CVC4;
using namespace std;
int main() {
ExprManager em;
Options opts;
SmtEngine smt(&em);
smt.setOption("incremental", SExpr("true"));
Expr x = em.mkVar("x", em.integerType());
Expr y = em.mkVar("y", em.integerType());
smt.assertFormula(em.mkExpr(kind::GT, em.mkExpr(kind::PLUS, x, y), em.mkConst(Rational(5))));
Expr q = em.mkExpr(kind::GT, x, em.mkConst(Rational(0)));
Result r = smt.query(q);
if(r != Result::INVALID) {
exit(1);
}
Statistics stats = smt.getStatistics();
for(Statistics::iterator i = stats.begin(); i != stats.end(); ++i) {
cout << "stat " << (*i).first << " is " << (*i).second << endl;
}
smt.assertFormula(em.mkExpr(kind::LT, y, em.mkConst(Rational(5))));
r = smt.query(q);
Statistics stats2 = smt.getStatistics();
bool different = false;
for(Statistics::iterator i = stats2.begin(); i != stats2.end(); ++i) {
cout << "stat1 " << (*i).first << " is " << stats.getStatistic((*i).first) << endl;
cout << "stat2 " << (*i).first << " is " << (*i).second << endl;
if(smt.getStatistic((*i).first) != (*i).second) {
cout << "SMT engine reports different value for statistic "
<< (*i).first << ": " << smt.getStatistic((*i).first) << endl;
exit(1);
}
different = different || stats.getStatistic((*i).first) != (*i).second;
}
#ifdef CVC4_STATISTICS_ON
if(!different) {
cout << "stats are the same! bailing.." << endl;
exit(1);
}
#endif /* CVC4_STATISTICS_ON */
return r == Result::VALID ? 0 : 1;
}
|