2afdc5ac6547f333627ee00f43bb83460fac4534
1 /********************* */
2 /*! \file cvc3_main.cpp
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-2012 New York University and The University of Iowa
9 ** See the file COPYING in the top-level source directory for licensing
10 ** information.\endverbatim
12 ** \brief Test of CVC3 compatibility interface
14 ** This is part of a test of the CVC3 compatibility interface present in
15 ** CVC4. It is a test copied from CVC3's "test" directory. Only #includes
16 ** were changed to support this test in CVC4.
18 ** The original file comment is preserved in the source.
21 ///////////////////////////////////////////////////////////////////////////////
24 // Author: Clark Barrett //
25 // Created: Sat Apr 19 01:47:47 2003 //
27 ///////////////////////////////////////////////////////////////////////////////
30 #include "compat/cvc3_compat.h"
32 //#include "theory_arith.h" // for arith kinds and expressions
33 //#include "theory_array.h"
38 //#include "exception.h"
39 //#include "typecheck_exception.h"
40 //#include "command_line_flags.h"
42 #include "cvc3_george.h"
50 inline void __expect__(const std::string
& file
,
53 const std::string
& cond_s
,
54 const std::string
& msg
) {
56 std::cerr
<< file
<< ":" << line
57 << ": Expected: (" << cond_s
<< "). "
63 #define EXPECT(cond, msg) __expect__(__FILE__, __LINE__, (cond), #cond, (msg))
65 // Check whether e is valid
66 bool check(ValidityChecker
* vc
, Expr e
, bool verbose
=true)
72 bool res
= vc
->query(e
);
75 if(verbose
) cout
<< "Invalid" << endl
<< endl
;
78 if(verbose
) cout
<< "Valid" << endl
<< endl
;
85 // Make a new assertion
86 void newAssertion(ValidityChecker
* vc
, Expr e
)
93 int eqExprVecs(const vector
<Expr
>& v1
,
94 const vector
<Expr
>& v2
) {
95 if( v1
.size() != v2
.size() ) {
99 for( unsigned int i
=0; i
< v1
.size(); ++i
) {
100 if( v1
[i
] != v2
[i
] ) {
108 int eqExprVecVecs(const vector
<vector
<Expr
> > vv1
,
109 const vector
<vector
<Expr
> > vv2
) {
110 if( vv1
.size() != vv2
.size() ) {
114 for( unsigned int i
=0; i
< vv1
.size(); ++i
) {
115 if( !eqExprVecs(vv1
[i
],vv2
[i
]) ) {
126 CLFlags flags
= ValidityChecker::createFlags();
127 ValidityChecker
* vc
= ValidityChecker::create(flags
);
130 Type
it (vc
->intType ()); //int
131 Op f
= vc
->createOp("f",vc
->funType(it
,it
));
132 Expr z
= vc
->varExpr("z",it
);
133 Expr e
= vc
->funExpr(f
, vc
->funExpr(f
, z
));
135 Expr f2
= vc
->funExpr(f
, e
);
136 Expr f3
= vc
->funExpr(f
, f2
);
138 EXPECT(e
!= f2
&& e
!= f3
, "Refcount problems");
140 Expr
x (vc
->boundVarExpr ("x", "0", it
));//x0:int
142 xs
.push_back (x
); //<x0:int>
143 Op
lxsx (vc
->lambdaExpr (xs
,x
)); //\<x0:int>. x0:int
144 Expr
y (vc
->ratExpr (1,1)); //1
146 ys
.push_back (y
); //<1>
147 Expr lxsxy
= vc
->funExpr (lxsx
, y
); //(\<x0:int>. x0:int)1
148 Expr lxsxys
= vc
->funExpr (lxsx
, ys
); //(\<x0:int>. x0:int)<1>
149 cout
<< "Lambda application: " << lxsxy
<< endl
;
150 cout
<< "Simplified: " << vc
->simplify(lxsxy
) << endl
;
151 } catch(const Exception
& e
) {
153 cout
<< "*** Exception caught in test (): \n" << e
<< endl
;
160 CLFlags flags
= ValidityChecker::createFlags();
161 flags
.setFlag("dagify-exprs",false);
162 flags
.setFlag("dump-log", ".test1.cvc");
163 ValidityChecker
* vc
= ValidityChecker::create(flags
);
165 // It is important that all Expr objects are deleted before vc is
166 // deleted. Therefore, we enclose them in a scope of try{ }catch
169 // Also, vc methods may throw an Exception, and we want to delete vc
170 // even in those exceptional cases.
173 bool b
= check(vc
, vc
->trueExpr());
174 EXPECT(b
, "Should be valid");
177 b
= check(vc
, vc
->falseExpr());
178 EXPECT(!b
, "Should be invalid");
183 Expr p
= vc
->varExpr("p", vc
->boolType());
184 Expr e
= vc
->orExpr(p
, vc
->notExpr(p
));
187 EXPECT(b
, "Should be valid");
189 // Check x = y -> f(x) = f(y)
191 Expr x
= vc
->varExpr("x", vc
->realType());
192 Expr y
= vc
->varExpr("y", vc
->realType());
194 Type real2real
= vc
->funType(vc
->realType(), vc
->realType());
195 Op f
= vc
->createOp("f", real2real
);
196 Expr fx
= vc
->funExpr(f
, x
);
197 Expr fy
= vc
->funExpr(f
, y
);
199 e
= vc
->impliesExpr(vc
->eqExpr(x
,y
),vc
->eqExpr(fx
, fy
));
201 EXPECT(b
, "Should be valid");
203 // Check f(x) = f(y) -> x = y
205 e
= vc
->impliesExpr(vc
->eqExpr(fx
,fy
),vc
->eqExpr(x
, y
));
206 int scopeLevel
= vc
->scopeLevel();
209 EXPECT(!b
, "Should be invalid");
211 // Get counter-example
213 vector
<Expr
> assertions
;
214 cout
<< "Scope level: " << vc
->scopeLevel() << endl
;
215 cout
<< "Counter-example:" << endl
;
216 //vc->getCounterExample(assertions);
217 for (unsigned i
= 0; i
< assertions
.size(); ++i
) {
218 vc
->printExpr(assertions
[i
]);
220 cout
<< "End of counter-example" << endl
<< endl
;
222 // Reset to initial scope
223 cout
<< "Resetting" << endl
;
225 EXPECT(scopeLevel
== vc
->scopeLevel(), "scope error");
226 cout
<< "Scope level: " << vc
->scopeLevel() << endl
<< endl
;
228 // Check w = x & x = y & y = z & f(x) = f(y) & x = 1 & z = 2
230 Expr w
= vc
->varExpr("w", vc
->realType());
231 Expr z
= vc
->varExpr("z", vc
->realType());
233 cout
<< "Push Scope" << endl
<< endl
;
236 newAssertion(vc
, vc
->eqExpr(w
, x
));
237 newAssertion(vc
, vc
->eqExpr(x
, y
));
238 newAssertion(vc
, vc
->eqExpr(y
, z
));
239 newAssertion(vc
, vc
->eqExpr(fx
, fy
));
240 newAssertion(vc
, vc
->eqExpr(x
, vc
->ratExpr(1)));
242 cout
<< endl
<< "simplify(w) = ";
243 vc
->printExpr(vc
->simplify(w
));
245 EXPECT(vc
->simplify(w
)==vc
->ratExpr(1), "Expected simplify(w) = 1");
247 newAssertion(vc
, vc
->eqExpr(z
, vc
->ratExpr(2)));
249 cout
<< "Inconsistent?: " << vc
->inconsistent(assertions
) << endl
;
251 cout
<< "Assumptions Used:" << endl
;
252 for (unsigned i
= 0; i
< assertions
.size(); ++i
) {
253 vc
->printExpr(assertions
[i
]);
256 cout
<< endl
<< "Pop Scope" << endl
<< endl
;
259 cout
<< "simplify(w) = ";
260 vc
->printExpr(vc
->simplify(w
));
261 EXPECT(vc
->simplify(w
)==w
, "Expected simplify(w) = w");
265 cout
<< "Inconsistent?: " << vc
->inconsistent(assertions
) << endl
;
266 } catch(const Exception
& e
) {
268 cout
<< "*** Exception caught in test1(): \n" << e
<< endl
;
276 CLFlags flags
= ValidityChecker::createFlags();
277 flags
.setFlag("dagify-exprs",false);
278 ValidityChecker
* vc
= ValidityChecker::create(flags
);
282 Expr bexpr
= vc
->varExpr("b", vc
->intType());
283 vc
->assertFormula(vc
->ltExpr(bexpr
, vc
->ratExpr(10)));
285 Expr c
= vc
->varExpr("c", vc
->intType());
286 vc
->assertFormula(c
.eqExpr(vc
->ratExpr(0)) || c
.eqExpr(vc
->ratExpr(1)));
288 bool b
= check(vc
, vc
->leExpr(bexpr
, vc
->ratExpr(10)));
289 EXPECT(b
, "Should be valid");
291 b
= check(vc
, vc
->falseExpr());
292 EXPECT(!b
, "Should be invalid");
293 vc
->returnFromCheck();
295 // Check x = y -> g(x,y) = g(y,x)
297 Expr x
= vc
->varExpr("x", vc
->realType());
298 Expr y
= vc
->varExpr("y", vc
->realType());
300 Type real
= vc
->realType();
305 Type realxreal2real
= vc
->funType(RxR
, real
);
306 Op g
= vc
->createOp("g", realxreal2real
);
308 Expr gxy
= vc
->funExpr(g
, x
, y
);
309 Expr gyx
= vc
->funExpr(g
, y
, x
);
311 Expr e
= vc
->impliesExpr(vc
->eqExpr(x
,y
),vc
->eqExpr(gxy
, gyx
));
313 EXPECT(b
, "Should be valid");
315 Op h
= vc
->createOp("h", realxreal2real
);
317 Expr hxy
= vc
->funExpr(h
, x
, y
);
318 Expr hyx
= vc
->funExpr(h
, y
, x
);
320 e
= vc
->impliesExpr(vc
->eqExpr(x
,y
),vc
->eqExpr(hxy
, hyx
));
322 EXPECT(b
, "Should be valid");
324 } catch(const Exception
& e
) {
326 cout
<< "*** Exception caught in test2(): \n" << e
<< endl
;
333 Expr
ltLex(ValidityChecker
* vc
, Expr i1
, Expr i2
, Expr j1
, Expr j2
)
335 Expr res
= vc
->ltExpr(i1
, j1
);
336 return vc
->orExpr(res
, vc
->andExpr(vc
->eqExpr(i1
, j1
), vc
->ltExpr(i2
, j2
)));
340 Expr
createTestFormula(ValidityChecker
* vc
, Expr i1
, Expr i2
, Expr r1
, Expr r2
)
342 Expr lt1
= ltLex(vc
, r1
, r2
, i1
, i2
);
343 Expr lt2
= ltLex(vc
, i2
, i1
, r2
, r1
);
344 return vc
->andExpr(lt1
, lt2
);
350 CLFlags flags
= ValidityChecker::createFlags();
351 flags
.setFlag("dagify-exprs",false);
352 ValidityChecker
* vc
= ValidityChecker::create(flags
);
355 Expr i
= vc
->varExpr("i", vc
->realType());
356 Expr j
= vc
->varExpr("j", vc
->realType());
357 Expr k
= vc
->varExpr("k", vc
->realType());
359 Expr one
= vc
->ratExpr(1);
361 cout
<< "i: " << i
.getIndex() << endl
;
363 Expr test
= createTestFormula(vc
, i
, j
,
364 vc
->minusExpr(i
, one
), vc
->minusExpr(j
, k
));
366 cout
<< "Trying test: ";
371 bool result
= vc
->query(test
);
373 cout
<< "Test Valid" << endl
;
378 vector
<Expr
> assertions
;
381 //vc->getCounterExample(assertions);
383 cout
<< "Test Invalid Under Conditions:" << endl
;
384 for (index
= 0; index
< assertions
.size(); ++index
) {
385 vc
->printExpr(assertions
[index
]);
388 // Try assertions one by one
389 for (index
= 0; index
< assertions
.size(); ++index
) {
390 condition
= vc
->notExpr(assertions
[index
]);
391 cout
<< "Trying test under condition: ";
392 vc
->printExpr(condition
);
396 result
= vc
->query(vc
->impliesExpr(condition
, test
));
398 cout
<< "Result Valid" << endl
;
402 cout
<< "Result Invalid" << endl
;
406 } catch(const Exception
& e
) {
408 cout
<< "*** Exception caught in test3(): \n" << e
<< endl
;
416 CLFlags flags
= ValidityChecker::createFlags();
417 flags
.setFlag("dagify-exprs",false);
418 ValidityChecker
* vc
= ValidityChecker::create(flags
);
421 Expr i
= vc
->varExpr("i", vc
->realType());
422 Expr j
= vc
->varExpr("j", vc
->realType());
423 Expr k
= vc
->varExpr("k", vc
->realType());
425 Expr one
= vc
->ratExpr(1);
427 cout
<< "i: " << i
.getIndex() << endl
;
429 Expr test
= createTestFormula(vc
, i
, j
,
430 vc
->minusExpr(i
, one
), vc
->minusExpr(j
, k
));
432 cout
<< "Trying test: ";
437 bool result
= vc
->query(test
);
439 cout
<< "Test Valid" << endl
;
443 vector
<Expr
> assertions
;
446 //vc->getCounterExample(assertions);
448 cout
<< "Test Invalid Under Conditions:" << endl
;
449 for (index
= 0; index
< assertions
.size(); ++index
) {
450 vc
->printExpr(assertions
[index
]);
453 // Try assertions one by one
454 for (index
= 0; index
< assertions
.size(); ++index
) {
455 condition
= vc
->notExpr(assertions
[index
]);
456 cout
<< "Trying test under condition: ";
457 vc
->printExpr(condition
);
461 result
= vc
->query(vc
->impliesExpr(condition
, test
));
463 cout
<< "Result Valid" << endl
;
467 cout
<< "Result Invalid" << endl
;
471 } catch(const Exception
& e
) {
473 cout
<< "*** Exception caught in test4(): \n" << e
<< endl
;
479 void findLeaves(Expr e
, vector
<Expr
>& l
)
483 for (int i
= 0; i
< ar
; ++i
)
491 bool hasij(Expr e
, Expr i
, Expr j
)
495 for (int k
= 0; k
< ar
; ++k
)
496 if (hasij(e
[k
], i
, j
)) return true;
499 if (e
== i
|| e
== j
) return true;
504 Expr
plusExpr(ValidityChecker
* vc
, vector
<Expr
>& kids
)
506 if (kids
.size() == 0) return vc
->ratExpr(0);
507 else if (kids
.size() == 1) return kids
[0];
508 else if (kids
.size() == 2) return vc
->plusExpr(kids
[0], kids
[1]);
510 Expr r
= kids
.back();
512 return vc
->plusExpr(plusExpr(vc
, kids
), r
);
519 CLFlags flags
= ValidityChecker::createFlags();
520 flags
.setFlag("dagify-exprs",false);
521 flags
.setFlag("dump-log", ".test5.cvc");
522 ValidityChecker
* vc
= ValidityChecker::create(flags
);
525 Expr i
= vc
->varExpr("i1", vc
->realType());
526 Expr j
= vc
->varExpr("i2", vc
->realType());
527 Expr p
= vc
->varExpr("p", vc
->realType());
528 Expr q
= vc
->varExpr("q", vc
->realType());
529 Expr r
= vc
->varExpr("r", vc
->realType());
530 Expr a
= vc
->varExpr("arb_addr", vc
->realType());
531 Expr N
= vc
->varExpr("N", vc
->realType());
533 Expr M
= vc
->varExpr("M", vc
->arrayType(vc
->realType(), vc
->realType()));
535 Expr M2
= vc
->writeExpr(M
, vc
->plusExpr(q
, i
), vc
->readExpr(M
, vc
->plusExpr(r
, i
)));
537 Expr M1
= vc
->writeExpr(M
, vc
->plusExpr(p
, j
), vc
->readExpr(M
, vc
->plusExpr(r
, j
)));
539 Expr e
= vc
->eqExpr(vc
->readExpr(vc
->writeExpr(M2
, vc
->plusExpr(p
, j
), vc
->readExpr(M2
, vc
->plusExpr(r
, j
))), a
),
540 vc
->readExpr(vc
->writeExpr(M1
, vc
->plusExpr(q
, i
), vc
->readExpr(M1
, vc
->plusExpr(r
, i
))), a
));
542 Expr one
= vc
->ratExpr(1);
543 Expr zero
= vc
->ratExpr(0);
545 Expr qmp
= vc
->minusExpr(q
, p
);
546 Expr qmr
= vc
->minusExpr(q
, r
);
549 hyp
.push_back(vc
->ltExpr(i
, j
));
550 // hyp.push_back(vc->orExpr(vc->geExpr(qmp, N), vc->leExpr(qmp, zero)));
551 // hyp.push_back(vc->orExpr(vc->geExpr(qmr, N), vc->leExpr(qmr, zero)));
553 Expr test
= vc
->impliesExpr(vc
->andExpr(hyp
), e
);
556 cout
<< "Checking verification condition:" << endl
;
561 bool result
= vc
->query(test
);
563 cout
<< "Valid" << endl
;
566 vector
<Expr
> conditions
;
567 vector
<Expr
> assertions
;
568 unsigned index
, index2
;
572 //vc->getCounterExample(assertions);
574 cout
<< "Invalid Under Conditions:" << endl
;
575 for (index
= 0; index
< assertions
.size(); ++index
) {
576 if (assertions
[index
] == (!test
)) {
577 for (; index
< assertions
.size()-1; ++index
) {
578 assertions
[index
] = assertions
[index
+1];
580 assertions
.pop_back();
584 for (index
= 0; index
< assertions
.size(); ++index
) {
585 vc
->printExpr(assertions
[index
]);
590 // Try assertions one by one
591 for (index
= 0; index
< assertions
.size(); ++index
) {
592 e
= assertions
[index
];
594 // Check condition for eligibility
596 cout
<< "Condition ineligible: negation" << endl
;
607 findLeaves(e
, leaves
);
608 for (index2
= 0; index2
< leaves
.size(); ++index2
) {
609 if (!leaves
[index2
].isVar() ||
610 leaves
[index2
] == i
||
611 leaves
[index2
] == j
||
617 cout
<< "Condition ineligible: not enough non-loop variables" << endl
;
623 cout
<< "Condition selected:" << endl
;
625 cout
<< endl
<< endl
;
627 conditions
.push_back(vc
->notExpr(e
));
628 cout
<< "Trying verification condition with hypothesis:" << endl
;
629 vc
->printExpr(vc
->andExpr(conditions
));
633 query
= vc
->impliesExpr(vc
->andExpr(conditions
), test
);
634 result
= vc
->query(query
);
636 cout
<< "Result Valid" << endl
;
641 vc
->getCounterExample(assertions
);
643 cout
<< "Invalid Under Conditions:" << endl
;
644 for (index2
= 0; index2
< assertions
.size(); ++index2
) {
645 if (assertions
[index2
] == (!query
)) {
646 for (; index2
< assertions
.size()-1; ++index2
) {
647 assertions
[index2
] = assertions
[index2
+1];
649 assertions
.pop_back();
654 for (index2
= 0; index2
< assertions
.size(); ++index2
) {
655 vc
->printExpr(assertions
[index2
]);
658 index
= (unsigned)-1;
662 cout
<< endl
<< "Attempting to remove loop variables" << endl
;
663 // replace loop variables in conditions
664 vector
<Expr
> newConditions
;
665 vector
<Expr
> newPlus
;
666 bool foundi
, foundj
, negi
, negj
;
667 Expr minusone
= vc
->ratExpr(-1);
668 for (index
= 0; index
< conditions
.size(); ++index
) {
669 if (conditions
[index
][0].isEq()) {
670 e
= vc
->simplify(vc
->minusExpr(conditions
[index
][0][0], conditions
[index
][0][1]));
671 if (hasij(e
, i
, j
)) {
672 if (e
.getKind() == CVC3::PLUS
) {
674 newPlus
.push_back(e
[0]);
675 foundi
= foundj
= negi
= negj
= false;
676 for (index2
= 1; index2
< (unsigned)e
.arity(); index2
++) {
677 Expr term
= e
[index2
];
678 if (term
== i
&& !foundi
) foundi
= true;
679 else if (term
== j
&& !foundj
) {
683 else if (term
.getKind() == CVC3::MULT
&& term
[0] == minusone
&& term
[1] == i
&& !foundi
) {
687 else if (term
.getKind() == CVC3::MULT
&& term
[0] == minusone
&& term
[1] == j
&& !foundj
) foundj
= true;
688 else newPlus
.push_back(term
);
690 if (foundi
&& foundj
&& ((negi
&& negj
) || (!negi
&& !negj
))) {
691 e
= plusExpr(vc
, newPlus
);
692 if (negi
&& negj
) e
= vc
->uminusExpr(e
);
694 if (!hasij(e
, i
, j
)) {
695 newConditions
.push_back(vc
->orExpr(vc
->geExpr(e
, N
), vc
->leExpr(e
, zero
)));
700 cout
<< "Unable to remove loop variables:" << endl
;
705 newConditions
.push_back(conditions
[index
]);
707 if (index
== conditions
.size()) {
708 cout
<< "Loop variables successfully removed:" << endl
;
709 Expr cond
= (newConditions
.size()>0)?
710 vc
->andExpr(newConditions
) : vc
->trueExpr();
714 vector
<Expr
> loopConditions
;
715 loopConditions
.push_back(cond
);
716 loopConditions
.push_back(vc
->geExpr(i
, one
));
717 loopConditions
.push_back(vc
->geExpr(j
, one
));
718 loopConditions
.push_back(vc
->leExpr(i
, N
));
719 loopConditions
.push_back(vc
->leExpr(j
, N
));
722 cout
<< "Final query" << endl
;
723 result
= vc
->query(vc
->impliesExpr(vc
->andExpr(loopConditions
), test
));
725 cout
<< "Result Valid" << endl
;
728 cout
<< "Result Invalid" << endl
;
732 } catch(const Exception
& e
) {
734 cout
<< "*** Exception caught in test5(): \n" << e
<< endl
;
741 // Test importing of Exprs from a different validity checker
743 ValidityChecker
* vc1
= ValidityChecker::create();
744 ValidityChecker
* vc2
= ValidityChecker::create();
747 Type real1
= vc1
->realType();
749 Expr x1
= vc1
->varExpr("x", real1
);
750 Expr y1
= vc1
->boundVarExpr("y", "0", real1
);
752 cout
<< "vc1 variables: " << x1
<< ", " << y1
<< endl
;
754 Expr x2
= vc2
->varExpr("x", vc2
->importType(real1
));
755 Expr y2
= vc2
->boundVarExpr("y", "0", vc2
->realType());
757 cout
<< "vc2 variables: " << x2
<< ", " << y2
<< endl
;
758 cout
<< "vars imported to vc2 from vc1: "
759 << vc2
->importExpr(x1
) << ", " << vc2
->importExpr(y1
) << endl
;
760 Expr t1
= vc1
->trueExpr();
761 Expr and1
= vc1
->andExpr(t1
, vc1
->falseExpr());
762 Op f1
= vc1
->createOp("f", vc1
->funType(real1
, real1
));
763 Expr fx1
= vc1
->funExpr(f1
, x1
);
764 Expr f5_1
= vc1
->funExpr(f1
, vc1
->ratExpr(5,1));
765 Type rt1
= vc1
->recordType("foo", real1
, "bar", real1
);
766 Expr r1
= vc1
->recordExpr("foo", fx1
, "bar", f5_1
);
767 Expr r1_eq
= vc1
->eqExpr(r1
, vc1
->recUpdateExpr(r1
, "foo", f5_1
));
768 Type art1
= vc1
->arrayType(real1
, rt1
);
769 Expr ar1
= vc1
->varExpr("ar", art1
);
770 Expr ar_eq1
= vc1
->eqExpr(vc1
->writeExpr(ar1
, x1
, r1
), ar1
);
771 Expr query1
= vc1
->eqExpr(vc1
->recSelectExpr(vc1
->readExpr(ar1
, x1
), "foo"),
772 vc1
->recSelectExpr(r1
, "bar"));
774 cout
<< "*** VC #1:" << endl
;
775 newAssertion(vc1
, r1_eq
);
776 newAssertion(vc1
, ar_eq1
);
779 cout
<< "*** VC #2:" << endl
;
780 newAssertion(vc2
, vc2
->importExpr(r1_eq
));
781 newAssertion(vc2
, vc2
->importExpr(ar_eq1
));
782 check(vc2
, vc2
->importExpr(query1
));
783 } catch(const Exception
& e
) {
785 cout
<< "*** Exception caught in test6(): \n" << e
<< endl
;
793 ValidityChecker
* vc1
= ValidityChecker::create();
794 ValidityChecker
* vc2
= ValidityChecker::create();
796 Expr e1
= vc1
->varExpr("e1", vc1
->realType());
797 Expr e2
= vc2
->varExpr("e2", vc2
->realType());
798 newAssertion(vc2
, vc2
->eqExpr(vc2
->importExpr(e1
), e2
));
799 } catch(const Exception
& e
) {
801 cout
<< "*** Exception caught in test7(): \n" << e
<< endl
;
809 ValidityChecker
* vc
= ValidityChecker::create();
812 vec
.push_back(vc
->boundVarExpr("x", "x", vc
->realType()));
813 Expr lambda
= vc
->lambdaExpr(vec
, vc
->falseExpr()).getExpr();
816 Type t
= vc
->subtypeType(lambda
, witness
);
817 EXPECT(false, "Typechecking exception expected");
818 } catch(const TypecheckException
&) {
821 } catch(const Exception
& e
) {
823 cout
<< "*** Exception caught in test8(): \n" << e
<< endl
;
829 Expr
adder(ValidityChecker
* vc
, const Expr
& a
, const Expr
& b
, const Expr
& c
)
831 return vc
->notExpr(vc
->iffExpr(vc
->notExpr(vc
->iffExpr(a
,b
)),c
));
835 Expr
carry(ValidityChecker
* vc
, const Expr
& a
, const Expr
& b
, const Expr
& c
)
837 return vc
->orExpr(vc
->andExpr(a
,b
), vc
->orExpr(vc
->andExpr(b
,c
),vc
->andExpr(a
,c
)));
841 void add(ValidityChecker
* vc
, vector
<Expr
> a
, vector
<Expr
> b
, vector
<Expr
>& sum
)
844 Expr c
= vc
->falseExpr();
846 for (i
=0; i
< N
; i
++)
848 sum
.push_back(adder(vc
,a
[i
],b
[i
],c
));
849 c
= carry(vc
,a
[i
],b
[i
],c
);
854 Expr
vectorEq(ValidityChecker
* vc
, vector
<Expr
> a
, vector
<Expr
> b
)
857 Expr result
= vc
->trueExpr();
859 for (i
=0; i
< N
; i
++) {
860 result
= result
&& a
[i
].iffExpr(b
[i
]);
867 CLFlags flags
= ValidityChecker::createFlags();
868 // flags.setFlag("proofs",true);
869 ValidityChecker
* vc
= ValidityChecker::create(flags
);
873 vector
<Expr
> a
,b
,sum1
,sum2
;
875 for (i
=0; i
< N
; i
++) {
876 a
.push_back(vc
->varExpr("a" + int2string(i
), vc
->boolType()));
877 b
.push_back(vc
->varExpr("b" + int2string(i
), vc
->boolType()));
883 Expr q
= vectorEq(vc
,sum1
,sum2
);
887 // Proof p = vc->getProof();
889 } catch(const Exception
& e
) {
891 cout
<< "*** Exception caught in test9(): \n" << e
<< endl
;
897 Expr
bvadder(ValidityChecker
* vc
, const Expr
& a
, const Expr
& b
, const Expr
& c
)
899 return vc
->newBVXorExpr(a
, vc
->newBVXorExpr(b
, c
));
903 Expr
bvcarry(ValidityChecker
* vc
, const Expr
& a
, const Expr
& b
, const Expr
& c
)
905 return vc
->newBVOrExpr(vc
->newBVAndExpr(a
,b
), vc
->newBVOrExpr(vc
->newBVAndExpr(b
,c
),vc
->newBVAndExpr(a
,c
)));
909 void bvadd(ValidityChecker
* vc
, vector
<Expr
> a
, vector
<Expr
> b
, vector
<Expr
>& sum
)
912 Expr c
= vc
->newBVConstExpr(Rational(0), 1);
914 for (i
=0; i
< N
; i
++)
916 sum
.push_back(bvadder(vc
,a
[i
],b
[i
],c
));
917 c
= bvcarry(vc
,a
[i
],b
[i
],c
);
922 Expr
bvvectorEq(ValidityChecker
* vc
, vector
<Expr
> a
, vector
<Expr
> b
)
925 Expr result
= vc
->newBVConstExpr(string("1"));
927 for (i
=0; i
< N
; i
++) {
928 result
= vc
->newBVAndExpr(result
, vc
->newBVXnorExpr(a
[i
], b
[i
]));
934 void bvtest9(int N
) {
935 CLFlags flags
= ValidityChecker::createFlags();
936 ValidityChecker
* vc
= ValidityChecker::create(flags
);
940 vector
<Expr
> avec
,bvec
,sum1vec
,sum2
;
943 a
= vc
->varExpr("a", vc
->bitvecType(N
));
944 b
= vc
->varExpr("b", vc
->bitvecType(N
));
948 sum1
= vc
->newBVPlusExpr(N
, kids
);
950 for (i
=0; i
< N
; i
++) {
951 avec
.push_back(vc
->newBVExtractExpr(a
, i
, i
));
952 bvec
.push_back(vc
->newBVExtractExpr(b
, i
, i
));
953 sum1vec
.push_back(vc
->newBVExtractExpr(sum1
, i
, i
));
956 bvadd(vc
,avec
,bvec
,sum2
);
958 Expr q
= bvvectorEq(vc
,sum1vec
,sum2
);
960 check(vc
, vc
->eqExpr(q
,vc
->newBVConstExpr(string("1"))));
962 } catch(const Exception
& e
) {
964 cout
<< "*** Exception caught in bvtest9(): \n" << e
<< endl
;
970 // Test for memory leaks (run silently)
973 CLFlags flags
= ValidityChecker::createFlags();
974 ValidityChecker
* vc
= ValidityChecker::create(flags
);
976 // Create all expressions in a separate scope, so that they are
977 // destroyed before vc is deleted.
980 // Check x = y -> g(x,y) = g(y,x)
982 Expr x
= vc
->varExpr("x", vc
->realType());
983 Expr y
= vc
->varExpr("y", vc
->realType());
985 Type real
= vc
->realType();
990 Type realxreal2real
= vc
->funType(RxR
, real
);
991 Op g
= vc
->createOp("g", realxreal2real
);
993 Expr gxy
= vc
->funExpr(g
, x
, y
);
994 Expr gyx
= vc
->funExpr(g
, y
, x
);
996 Expr e
= vc
->impliesExpr(vc
->eqExpr(x
,y
),vc
->eqExpr(gxy
, gyx
));
999 Op h
= vc
->createOp("h", realxreal2real
);
1001 Expr hxy
= vc
->funExpr(h
, x
, y
);
1002 Expr hyx
= vc
->funExpr(h
, y
, x
);
1004 e
= vc
->impliesExpr(vc
->eqExpr(x
,y
),vc
->eqExpr(hxy
, hyx
));
1005 check(vc
, e
, false);
1007 } catch(const Exception
& e
) {
1009 cout
<< "*** Exception caught in test10(): \n" << e
<< endl
;
1011 // Make sure all Expr's are deleted first
1015 unsigned int printImpliedLiterals(ValidityChecker
* vc
)
1017 unsigned int count
= 0;
1018 cout
<< "Implied Literals:" << endl
;
1019 Expr impLit
= vc
->getImpliedLiteral();
1020 while (!impLit
.isNull()) {
1022 vc
->printExpr(impLit
);
1023 impLit
= vc
->getImpliedLiteral();
1031 CLFlags flags
= ValidityChecker::createFlags();
1032 ValidityChecker
* vc
= ValidityChecker::create(flags
);
1035 Expr x
= vc
->varExpr("x", vc
->realType());
1036 Expr y
= vc
->varExpr("y", vc
->realType());
1037 Expr z
= vc
->varExpr("z", vc
->realType());
1039 Type real
= vc
->realType();
1040 Type real2real
= vc
->funType(real
, real
);
1041 Type real2bool
= vc
->funType(real
, vc
->boolType());
1042 Op f
= vc
->createOp("f", real2real
);
1043 Op p
= vc
->createOp("p", real2bool
);
1045 Expr fx
= vc
->funExpr(f
, x
);
1046 Expr fy
= vc
->funExpr(f
, y
);
1048 Expr px
= vc
->funExpr(p
, x
);
1049 Expr py
= vc
->funExpr(p
, y
);
1051 Expr xeqy
= vc
->eqExpr(x
, y
);
1052 Expr yeqx
= vc
->eqExpr(y
, x
);
1053 Expr xeqz
= vc
->eqExpr(x
, z
);
1054 Expr zeqx
= vc
->eqExpr(z
, x
);
1055 Expr yeqz
= vc
->eqExpr(y
, z
);
1056 Expr zeqy
= vc
->eqExpr(z
, y
);
1060 vc
->registerAtom(vc
->eqExpr(x
,vc
->ratExpr(0,1)));
1061 vc
->registerAtom(xeqy
);
1062 vc
->registerAtom(yeqx
);
1063 vc
->registerAtom(xeqz
);
1064 vc
->registerAtom(zeqx
);
1065 vc
->registerAtom(yeqz
);
1066 vc
->registerAtom(zeqy
);
1067 vc
->registerAtom(px
);
1068 vc
->registerAtom(py
);
1069 vc
->registerAtom(vc
->eqExpr(fx
, fy
));
1071 cout
<< "Push" << endl
;
1074 cout
<< "Assert x = y" << endl
;
1075 vc
->assertFormula(xeqy
);
1076 c
= printImpliedLiterals(vc
);
1077 EXPECT(c
==3,"Implied literal error 0");
1079 cout
<< "Push" << endl
;
1081 cout
<< "Assert x /= z" << endl
;
1082 vc
->assertFormula(!xeqz
);
1083 c
= printImpliedLiterals(vc
);
1084 EXPECT(c
==4,"Implied literal error 1");
1085 cout
<< "Pop" << endl
;
1088 cout
<< "Push" << endl
;
1090 cout
<< "Assert y /= z" << endl
;
1091 vc
->assertFormula(!yeqz
);
1092 c
= printImpliedLiterals(vc
);
1093 EXPECT(c
==4,"Implied literal error 2");
1094 cout
<< "Pop" << endl
;
1097 cout
<< "Push" << endl
;
1099 cout
<< "Assert p(x)" << endl
;
1100 vc
->assertFormula(px
);
1101 c
= printImpliedLiterals(vc
);
1102 EXPECT(c
==2,"Implied literal error 3");
1103 cout
<< "Pop" << endl
;
1106 cout
<< "Push" << endl
;
1108 cout
<< "Assert p(y)" << endl
;
1109 vc
->assertFormula(py
);
1110 c
= printImpliedLiterals(vc
);
1111 EXPECT(c
==2,"Implied literal error 4");
1112 cout
<< "Pop" << endl
;
1115 cout
<< "Pop" << endl
;
1118 cout
<< "Push" << endl
;
1120 cout
<< "Assert y = x" << endl
;
1121 vc
->assertFormula(yeqx
);
1122 c
= printImpliedLiterals(vc
);
1123 EXPECT(c
==3,"Implied literal error 5");
1124 cout
<< "Pop" << endl
;
1127 cout
<< "Push" << endl
;
1129 cout
<< "Assert p(x)" << endl
;
1130 vc
->assertFormula(px
);
1131 c
= printImpliedLiterals(vc
);
1132 EXPECT(c
==1,"Implied literal error 6");
1133 cout
<< "Assert x = y" << endl
;
1134 vc
->assertFormula(xeqy
);
1135 c
= printImpliedLiterals(vc
);
1136 EXPECT(c
==4,"Implied literal error 7");
1137 cout
<< "Pop" << endl
;
1140 cout
<< "Push" << endl
;
1142 cout
<< "Assert NOT p(x)" << endl
;
1143 vc
->assertFormula(!px
);
1144 c
= printImpliedLiterals(vc
);
1145 EXPECT(c
==1,"Implied literal error 8");
1146 cout
<< "Assert x = y" << endl
;
1147 vc
->assertFormula(xeqy
);
1148 c
= printImpliedLiterals(vc
);
1149 EXPECT(c
==4,"Implied literal error 9");
1150 cout
<< "Pop" << endl
;
1153 } catch(const Exception
& e
) {
1155 cout
<< "*** Exception caught in test11(): \n" << e
<< endl
;
1163 ValidityChecker
* vc
= ValidityChecker::create( );
1165 Type realType
= vc
->realType();
1166 Type intType
= vc
->intType();
1167 Type boolType
= vc
->boolType();
1169 int initial_layer
= vc
->stackLevel();
1170 int initial_scope
= vc
->scopeLevel();
1171 Expr exprObj_trueID
= vc
->trueExpr();
1172 Expr exprObj_falseID
= vc
->notExpr(vc
->trueExpr());
1173 vc
->popto(initial_layer
);
1174 EXPECT(vc
->scopeLevel() == initial_scope
, "Expected no change");
1175 EXPECT(vc
->stackLevel() == initial_layer
, "Expected no change");
1176 // TODO: what happens if we push and then popscope?
1177 } catch(const Exception
& e
) {
1179 cout
<< "*** Exception caught in test12(): \n" << e
<< endl
;
1187 CLFlags flags
= ValidityChecker::createFlags();
1188 flags
.setFlag("dagify-exprs", false);
1189 flags
.setFlag("dump-log", ".test13.cvc");
1190 ValidityChecker
* vc
= ValidityChecker::create(flags
);
1192 Expr rat_one
= vc
->ratExpr(1);
1193 Expr rat_two
= vc
->ratExpr(2);
1194 Expr rat_minus_one
= vc
->ratExpr(-1);
1197 query_result
= vc
->query(vc
->eqExpr(rat_two
,rat_one
));
1198 cout
<< "2=1 " << query_result
<< endl
;
1199 query_result
= vc
->query(vc
->eqExpr(rat_two
,rat_minus_one
));
1200 cout
<< "2=-1 " << query_result
<< endl
;
1201 } catch(const Exception
& e
) {
1203 cout
<< "*** Exception caught in test13(): \n" << e
<< endl
;
1209 Expr
func1(ValidityChecker
*vc
) {
1211 Expr tmp
= vc
->varExpr("tmp", vc
->boolType());
1212 return vc
->trueExpr();
1217 ValidityChecker
*vc
= ValidityChecker::create();
1220 Expr test1
= func1(vc
);
1223 Expr test2
= func1(vc
);
1224 } catch(const Exception
& e
) {
1226 cout
<< "*** Exception caught in test14(): \n" << e
<< endl
;
1233 CLFlags flags
= ValidityChecker::createFlags();
1234 flags
.setFlag("dagify-exprs", false);
1235 ValidityChecker
*vc
= ValidityChecker::create(flags
);
1238 /*****************************************************
1239 * array declaration *
1240 *****************************************************/
1242 // array: index type
1243 Type index_type
= vc
->subrangeType(vc
->ratExpr(0),
1246 Type data_type
= vc
->subrangeType(vc
->ratExpr(0),
1248 // array type: [0 .. 3] of 0 .. 3
1249 Type array_type
= vc
->arrayType(index_type
, data_type
);
1250 Expr arr
= vc
->varExpr("array", array_type
);
1253 arr
= vc
->writeExpr(arr
, vc
->ratExpr(0), vc
->ratExpr(1));
1254 arr
= vc
->writeExpr(arr
, vc
->ratExpr(1), vc
->ratExpr(1));
1255 arr
= vc
->writeExpr(arr
, vc
->ratExpr(2), vc
->ratExpr(0));
1256 arr
= vc
->writeExpr(arr
, vc
->ratExpr(3), vc
->ratExpr(0));
1260 /*****************************************************
1262 *****************************************************/
1265 Expr id
= vc
->boundVarExpr("id", "0", vc
->subrangeType(vc
->ratExpr(0),
1271 Expr for_body
= vc
->leExpr(vc
->readExpr(arr
, id
),
1272 vc
->readExpr(arr
, vc
->plusExpr(id
, vc
->ratExpr(1))));
1274 Expr forall_expr
= vc
->forallExpr(vars
, for_body
);
1277 check(vc
, forall_expr
);
1279 vector
<Expr
> assertions
;
1280 cout
<< "Scope level: " << vc
->scopeLevel() << endl
;
1281 cout
<< "Counter-example:" << endl
;
1282 //vc->getCounterExample(assertions);
1283 for (unsigned i
= 0; i
< assertions
.size(); ++i
) {
1284 vc
->printExpr(assertions
[i
]);
1286 cout
<< "End of counter-example" << endl
<< endl
;
1289 /*****************************************************
1290 * manual expansion *
1291 *****************************************************/
1293 Expr e1
= vc
->leExpr(vc
->readExpr(arr
, vc
->ratExpr(0)),
1294 vc
->readExpr(arr
, vc
->ratExpr(1)));
1295 Expr e2
= vc
->leExpr(vc
->readExpr(arr
, vc
->ratExpr(1)),
1296 vc
->readExpr(arr
, vc
->ratExpr(2)));
1297 Expr e3
= vc
->leExpr(vc
->readExpr(arr
, vc
->ratExpr(2)),
1298 vc
->readExpr(arr
, vc
->ratExpr(3)));
1299 Expr manual_expr
= vc
->andExpr(e1
, vc
->andExpr(e2
, e3
));
1303 /*****************************************************
1305 *****************************************************/
1308 Expr id_ex
= vc
->varExpr("id_ex", vc
->subrangeType(vc
->ratExpr(0),
1310 vector
<Expr
> vars_ex
;
1311 vars_ex
.push_back(id_ex
);
1314 Expr ex_body
= vc
->gtExpr(vc
->readExpr(arr
, id_ex
),
1315 vc
->readExpr(arr
, vc
->plusExpr(id_ex
, vc
->ratExpr(1))));
1317 Expr ex_expr
= vc
->existsExpr(vars_ex
, ex_body
);
1322 /*****************************************************
1323 * ??? forall <==> manual expansion *
1324 *****************************************************/
1326 cout
<< endl
<< "Checking forallExpr <==> manual expansion ..." << endl
;
1327 if (vc
->query(vc
->iffExpr(forall_expr
, manual_expr
)))
1328 cout
<< " -- yes." << endl
;
1330 cout
<< " -- no, with counter examples as " << endl
;
1332 vector
<Expr
> assert1
;
1333 vc
->getCounterExample(assert1
);
1334 for (unsigned int i
= 0; i
< assert1
.size(); i
++)
1335 vc
->printExpr(assert1
[i
]);
1342 /*****************************************************
1343 * ??? !forall <==> existsExpr *
1344 *****************************************************/
1345 cout
<< endl
<< "Checking !forallExpr <==> existsExpr ..." << endl
;
1346 if (vc
->query(vc
->iffExpr(vc
->notExpr(forall_expr
), ex_expr
)))
1347 cout
<< " -- yes." << endl
;
1348 else if (vc
->incomplete()) {
1349 cout
<< " -- incomplete:" << endl
;
1350 vector
<string
> reasons
;
1351 vc
->incomplete(reasons
);
1352 for (unsigned int i
= 0; i
< reasons
.size(); ++i
)
1353 cout
<< reasons
[i
] << endl
;
1356 cout
<< " -- no, with counter examples as " << endl
;
1358 vector
<Expr
> assert2
;
1359 //vc->getCounterExample(assert2);
1360 for (unsigned int i
= 0; i
< assert2
.size(); i
++)
1361 vc
->printExpr(assert2
[i
]);
1364 cout
<< endl
<< "End of testcases." << endl
<< endl
;
1367 } catch(const Exception
& e
) {
1369 cout
<< "*** Exception caught in test15(): \n" << e
<< endl
;
1376 ValidityChecker
*vc
= ValidityChecker::create();
1378 Type zto100
= vc
->subrangeType(vc
->ratExpr(0), vc
->ratExpr(100));
1379 Expr mem
= vc
->varExpr("mem", vc
->arrayType(zto100
, vc
->intType()));
1380 Expr a
= vc
->varExpr("a", zto100
);
1381 Expr b
= vc
->varExpr("b", zto100
);
1383 Expr lhs
= vc
->readExpr(vc
->writeExpr(mem
, a
, vc
->ratExpr(30)), b
);
1384 Expr rhs
= vc
->readExpr(vc
->writeExpr(mem
, b
, vc
->ratExpr(40)), a
);
1386 Expr q
= vc
->impliesExpr(vc
->notExpr(vc
->eqExpr(a
, b
)), vc
->eqExpr(lhs
, rhs
));
1390 vector
<Expr
> assertions
;
1391 cout
<< "Scope level: " << vc
->scopeLevel() << endl
;
1392 cout
<< "Counter-example:" << endl
;
1393 vc
->getCounterExample(assertions
);
1394 EXPECT(assertions
.size() > 0, "Expected non-empty counter-example");
1395 for (unsigned i
= 0; i
< assertions
.size(); ++i
) {
1396 vc
->printExpr(assertions
[i
]);
1398 cout
<< "End of counter-example" << endl
<< endl
;
1401 vc
->getConcreteModel(m
);
1402 ExprMap
<Expr
>::iterator it
= m
.begin(), end
= m
.end();
1404 cout
<< " Did not find concrete model for any vars" << endl
;
1406 cout
<< "%Satisfiable Variable Assignment: % \n";
1407 for(; it
!= end
; it
++) {
1409 if(it
->first
.getType().isBool()) {
1410 EXPECT((it
->second
).isBoolConst(),
1411 "Bad variable assignement: e = "+(it
->first
).toString()
1412 +"\n\n val = "+(it
->second
).toString());
1413 if((it
->second
).isTrue())
1419 eq
= (it
->first
).eqExpr(it
->second
);
1420 //cout << Expr(ASSERT, eq) << "\n";
1424 } catch(const Exception
& e
) {
1426 cout
<< "*** Exception caught in test16(): \n" << e
<< endl
;
1433 ValidityChecker
*vc
= ValidityChecker::create();
1436 vector
<string
> selectors
;
1439 selectors
.push_back("car");
1440 types
.push_back(vc
->intType().getExpr());
1441 selectors
.push_back("cdr");
1442 types
.push_back(vc
->stringExpr("list"));
1444 Type badList
= vc
->dataType("list", "cons", selectors
, types
);
1445 EXPECT(false, "Typechecking exception expected");
1446 } catch(const TypecheckException
&) {
1450 vc
= ValidityChecker::create();
1452 vector
<string
> constructors
;
1453 vector
<vector
<string
> > selectors(2);
1454 vector
<vector
<Expr
> > types(2);
1456 constructors
.push_back("cons");
1457 selectors
[0].push_back("car");
1458 types
[0].push_back(vc
->intType().getExpr());
1459 selectors
[0].push_back("cdr");
1460 types
[0].push_back(vc
->stringExpr("list"));
1461 constructors
.push_back("null");
1463 Type list
= vc
->dataType("list", constructors
, selectors
, types
);
1465 Expr x
= vc
->varExpr("x", vc
->intType());
1466 Expr y
= vc
->varExpr("y", list
);
1471 Expr cons
= vc
->datatypeConsExpr("cons", args
);
1473 Expr sel
= vc
->datatypeSelExpr("car", cons
);
1474 bool b
= check(vc
, vc
->eqExpr(sel
, x
));
1475 EXPECT(b
, "Should be valid");
1479 vc
= ValidityChecker::create();
1481 vector
<string
> names
;
1482 vector
<vector
<string
> > constructors(2);
1483 vector
<vector
<vector
<string
> > > selectors(2);
1484 vector
<vector
<vector
<Expr
> > > types(2);
1485 vector
<Type
> returnTypes
;
1487 names
.push_back("list1");
1489 selectors
[0].resize(1);
1491 constructors
[0].push_back("cons1");
1492 selectors
[0][0].push_back("car1");
1493 types
[0][0].push_back(vc
->intType().getExpr());
1494 selectors
[0][0].push_back("cdr1");
1495 types
[0][0].push_back(vc
->stringExpr("list2"));
1497 names
.push_back("list2");
1499 selectors
[1].resize(1);
1501 constructors
[1].push_back("cons2");
1502 selectors
[0][0].push_back("car2");
1503 types
[0][0].push_back(vc
->intType().getExpr());
1504 selectors
[0][0].push_back("cdr2");
1505 types
[0][0].push_back(vc
->stringExpr("list1"));
1507 vc
->dataType(names
, constructors
, selectors
, types
, returnTypes
);
1508 EXPECT(false, "Typechecking exception expected");
1509 } catch(const TypecheckException
&) {
1513 vc
= ValidityChecker::create();
1515 vector
<string
> names
;
1516 vector
<vector
<string
> > constructors(2);
1517 vector
<vector
<vector
<string
> > > selectors(2);
1518 vector
<vector
<vector
<Expr
> > > types(2);
1519 vector
<Type
> returnTypes
;
1521 names
.push_back("list1");
1523 selectors
[0].resize(1);
1525 constructors
[0].push_back("cons1");
1526 selectors
[0][0].push_back("car1");
1527 types
[0][0].push_back(vc
->intType().getExpr());
1528 selectors
[0][0].push_back("cdr1");
1529 types
[0][0].push_back(vc
->stringExpr("list2"));
1531 names
.push_back("list2");
1533 selectors
[1].resize(2);
1535 constructors
[1].push_back("cons2");
1536 selectors
[1][0].push_back("car2");
1537 types
[1][0].push_back(vc
->intType().getExpr());
1538 selectors
[1][0].push_back("cdr2");
1539 types
[1][0].push_back(vc
->stringExpr("list1"));
1540 constructors
[1].push_back("null");
1542 vc
->dataType(names
, constructors
, selectors
, types
, returnTypes
);
1544 Type list1
= returnTypes
[0];
1545 Type list2
= returnTypes
[1];
1547 Expr x
= vc
->varExpr("x", vc
->intType());
1548 Expr y
= vc
->varExpr("y", list2
);
1549 Expr z
= vc
->varExpr("z", list1
);
1554 Expr cons1
= vc
->datatypeConsExpr("cons1", args
);
1556 Expr isnull
= vc
->datatypeTestExpr("null", y
);
1557 Expr hyp
= vc
->andExpr(vc
->eqExpr(z
, cons1
), isnull
);
1560 Expr null
= vc
->datatypeConsExpr("null", args
);
1563 args
.push_back(null
);
1564 Expr cons1_2
= vc
->datatypeConsExpr("cons1", args
);
1566 bool b
= check(vc
, vc
->impliesExpr(hyp
, vc
->eqExpr(z
, cons1_2
)));
1567 EXPECT(b
, "Should be valid");
1571 vc
= ValidityChecker::create();
1573 vector
<string
> constructors
;
1574 vector
<vector
<string
> > selectors(2);
1575 vector
<vector
<Expr
> > types(2);
1577 constructors
.push_back("A");
1578 constructors
.push_back("B");
1580 Type two
= vc
->dataType("two", constructors
, selectors
, types
);
1582 Expr x
= vc
->varExpr("x", two
);
1583 Expr y
= vc
->varExpr("y", two
);
1584 Expr z
= vc
->varExpr("z", two
);
1587 args
.push_back(!vc
->eqExpr(x
,y
));
1588 args
.push_back(!vc
->eqExpr(y
,z
));
1589 args
.push_back(!vc
->eqExpr(x
,z
));
1591 bool b
= check(vc
, !vc
->andExpr(args
));
1592 EXPECT(b
, "Should be valid");
1595 } catch(const Exception
& e
) {
1597 cout
<< "*** Exception caught in test17(): \n" << e
<< endl
;
1605 CLFlags flags
= ValidityChecker::createFlags();
1606 flags
.setFlag("tcc", true);
1607 ValidityChecker
*vc
= ValidityChecker::create(flags
);
1609 vector
<string
> names
;
1610 vector
<vector
<string
> > constructors(3);
1611 vector
<vector
<vector
<string
> > > selectors(3);
1612 vector
<vector
<vector
<Expr
> > > types(3);
1613 vector
<Type
> returnTypes
;
1615 names
.push_back("nat");
1617 selectors
[0].resize(2);
1619 constructors
[0].push_back("zero");
1620 constructors
[0].push_back("succ");
1621 selectors
[0][1].push_back("pred");
1622 types
[0][1].push_back(vc
->stringExpr("nat"));
1624 names
.push_back("list");
1626 selectors
[1].resize(2);
1628 constructors
[1].push_back("cons");
1629 selectors
[1][0].push_back("car");
1630 types
[1][0].push_back(vc
->stringExpr("tree"));
1631 selectors
[1][0].push_back("cdr");
1632 types
[1][0].push_back(vc
->stringExpr("list"));
1633 constructors
[1].push_back("null");
1635 names
.push_back("tree");
1637 selectors
[2].resize(2);
1639 constructors
[2].push_back("leaf");
1640 constructors
[2].push_back("node");
1641 selectors
[2][1].push_back("data");
1642 types
[2][1].push_back(vc
->stringExpr("nat"));
1643 selectors
[2][1].push_back("children");
1644 types
[2][1].push_back(vc
->stringExpr("list"));
1646 vc
->dataType(names
, constructors
, selectors
, types
, returnTypes
);
1648 Type nat
= returnTypes
[0];
1649 Type listType
= returnTypes
[1];
1650 Type tree
= returnTypes
[2];
1652 Expr x
= vc
->varExpr("x", nat
);
1655 Expr zero
= vc
->datatypeConsExpr("zero", args
);
1656 Expr null
= vc
->datatypeConsExpr("null", args
);
1657 Expr leaf
= vc
->datatypeConsExpr("leaf", args
);
1661 check(vc
, vc
->notExpr(vc
->eqExpr(zero
, null
)));
1662 // TCCs not supported by CVC4 yet
1663 //EXPECT(false, "Should have caught tcc exception");
1664 } catch(const TypecheckException
&) { }
1667 args
.push_back(vc
->datatypeSelExpr("pred",x
));
1668 Expr spx
= vc
->datatypeConsExpr("succ", args
);
1669 Expr spxeqx
= vc
->eqExpr(spx
, x
);
1673 // TCCs not supported by CVC4 yet
1674 //EXPECT(false, "Should have caught tcc exception");
1675 } catch(const TypecheckException
&) { }
1678 bool b
= check(vc
, vc
->impliesExpr(vc
->datatypeTestExpr("succ", x
), spxeqx
));
1679 EXPECT(b
, "Should be valid");
1681 b
= check(vc
, vc
->orExpr(vc
->datatypeTestExpr("zero", x
),
1682 vc
->datatypeTestExpr("succ", x
)));
1683 EXPECT(b
, "Should be valid");
1685 Expr y
= vc
->varExpr("y", nat
);
1686 Expr xeqy
= vc
->eqExpr(x
, y
);
1689 Expr sx
= vc
->datatypeConsExpr("succ", args
);
1692 Expr sy
= vc
->datatypeConsExpr("succ", args
);
1693 Expr sxeqsy
= vc
->eqExpr(sx
,sy
);
1694 b
= check(vc
, vc
->impliesExpr(xeqy
, sxeqsy
));
1695 EXPECT(b
, "Should be valid");
1697 b
= check(vc
, vc
->notExpr(vc
->eqExpr(sx
, zero
)));
1698 EXPECT(b
, "Should be valid");
1700 b
= check(vc
, vc
->impliesExpr(sxeqsy
, xeqy
));
1701 EXPECT(b
, "Should be valid");
1703 b
= check(vc
, vc
->notExpr(vc
->eqExpr(sx
, x
)));
1704 EXPECT(b
, "Should be valid");
1706 } catch(const Exception
& e
) {
1708 cout
<< "*** Exception caught in test18(): \n" << e
<< endl
;
1715 CVC3::CLFlags flags
= CVC3::ValidityChecker::createFlags();
1716 flags
.setFlag("dagify-exprs", false);
1717 CVC3::ValidityChecker
* vc
= CVC3::ValidityChecker::create(flags
);
1719 CVC3::Type RealType
=(vc
->realType());
1720 CVC3::Type IntType
=(vc
->intType());
1721 CVC3::Type BoolType
=(vc
->boolType());
1722 CVC3::Type PtrType
=(RealType
);
1723 CVC3::Type HeapType
=(vc
->arrayType(PtrType
, RealType
));
1725 // -----------------
1726 //ASSERT(FORALL (CVCi: REAL): (Hs[CVCi] = Ht[CVCi]));
1727 //QUERY(Hs[(t6 + (3 * 1))] = Ht[(t6 + (3 * 1))]);
1728 CVC3::Expr Ad
= vc
->boundVarExpr("CVCi", "CVCi", RealType
);
1729 CVC3::Expr Hs
= vc
->varExpr("Hs", HeapType
);
1730 CVC3::Expr Ht
= vc
->varExpr("Ht", HeapType
);
1731 CVC3::Expr t6
= vc
->varExpr("t6", RealType
);
1733 vector
<CVC3::Expr
> Vars
;
1735 // Body= (Hs[Ad] = Ht[Ad])
1736 CVC3::Expr Body
= vc
->eqExpr(vc
->readExpr(Hs
, Ad
), vc
->readExpr(Ht
, Ad
));
1738 //A = forall (~i:REAL): Body
1739 CVC3::Expr A
= vc
->forallExpr(Vars
, Body
);
1741 // Q = (Hs[t6] = Ht[t6])
1742 CVC3::Expr Q
= vc
->eqExpr(vc
->readExpr(Hs
, t6
), vc
->readExpr(Ht
, t6
));
1744 // ----------- CHECK A -> Q
1747 vc
->assertFormula(A
);
1749 cout
<<"Checking formula "<<Q
<<"\n in context "<<A
<<"\n";
1751 bool Succ
= vc
->query(Q
);
1753 EXPECT(Succ
, "Expected valid formula");
1755 } catch(const Exception
& e
) {
1757 cout
<< "*** Exception caught in test19(): \n" << e
<< endl
;
1764 ValidityChecker
*vc
= ValidityChecker::create();
1766 vector
<string
> names
;
1767 vector
<vector
<string
> > constructors(3);
1768 vector
<vector
<vector
<string
> > > selectors(3);
1769 vector
<vector
<vector
<Expr
> > > types(3);
1770 vector
<Type
> returnTypes
;
1772 names
.push_back("pair");
1774 selectors
[0].resize(1);
1776 constructors
[0].push_back("p");
1777 selectors
[0][0].push_back("p1");
1778 types
[0][0].push_back(vc
->stringExpr("t1"));
1779 selectors
[0][0].push_back("p2");
1780 types
[0][0].push_back(vc
->stringExpr("t2"));
1782 names
.push_back("t1");
1784 selectors
[1].resize(5);
1786 constructors
[1].push_back("a");
1787 constructors
[1].push_back("b");
1788 constructors
[1].push_back("c");
1789 constructors
[1].push_back("d");
1790 constructors
[1].push_back("e");
1792 names
.push_back("t2");
1794 selectors
[2].resize(1);
1796 constructors
[2].push_back("cons");
1797 selectors
[2][0].push_back("s0");
1798 types
[2][0].push_back(vc
->bitvecType(2).getExpr());
1799 selectors
[2][0].push_back("s1");
1800 types
[2][0].push_back(vc
->arrayType(vc
->intType(), vc
->subrangeType(vc
->ratExpr(0), vc
->ratExpr(0))).getExpr());
1802 vc
->dataType(names
, constructors
, selectors
, types
, returnTypes
);
1804 EXPECT(returnTypes
[0].card() == CARD_FINITE
, "Expected finite");
1805 Unsigned size
= returnTypes
[0].sizeFinite();
1807 for (; i
< size
; ++i
) {
1809 vc
->printExpr(returnTypes
[0].enumerateFinite(i
));
1812 } catch(const Exception
& e
) {
1814 cout
<< "*** Exception caught in test20(): \n" << e
<< endl
;
1820 ValidityChecker
*vc
= ValidityChecker::create();
1823 Type t
= vc
->realType();
1825 Expr x1
= vc
->varExpr("x",t
);
1827 Expr x2
= vc
->exprFromString("x");
1828 cout
<< "x1: " << x1
;
1829 cout
<< "\nx2: " << x2
;
1830 EXPECT(x1
== x2
, "Expected x1 == x2");
1832 Expr x3
= vc
->exprFromString("x", SMTLIB_V2_LANG
);
1833 cout
<< "\nx3: " << x3
;
1834 EXPECT(x1
== x3
, "Expected x1 == x3");
1836 Expr y1
= vc
->varExpr("y",t
);
1837 Expr y2
= vc
->exprFromString("y");
1838 cout
<< "\ny1: " << y1
;
1839 cout
<< "\ny2: " << y2
;
1840 EXPECT(y1
== y2
, "Expected y1 == y2");
1842 Expr y3
= vc
->exprFromString("y", SMTLIB_V2_LANG
);
1843 cout
<< "\ny3: " << y3
;
1844 EXPECT(y1
== y3
, "Expected y1 == y3");
1846 Expr a1
= vc
->gtExpr(x1
,vc
->ratExpr(0,1));
1847 Expr a2
= vc
->exprFromString("x > 0");
1848 cout
<< "\na1: " << a1
;
1849 cout
<< "\na2: " << a2
;
1850 EXPECT(a1
== a2
, "Expected a1 == a2");
1852 Expr a3
= vc
->exprFromString("(> x 0)", SMTLIB_V2_LANG
);
1853 cout
<< "\na3: " << a3
;
1854 EXPECT(a1
== a3
, "Expected a1 == a3");
1856 Expr b1
= vc
->ltExpr(x1
,y1
);
1857 Expr b2
= vc
->exprFromString ("x < y");
1858 cout
<< "\nb1: " << b1
;
1859 cout
<< "\nb2: " << b2
;
1860 EXPECT(b1
== b2
, "Expected b1 == b2");
1862 Expr b3
= vc
->exprFromString ("(< x y)", SMTLIB_V2_LANG
);
1863 cout
<< "\nb3: " << b3
;
1864 EXPECT(b1
== b3
, "Expected b1 == b3");
1867 Expr e2
= vc
->exprFromString("x > 0 AND x < y");
1868 cout
<< "\ne1: " << e1
;
1869 cout
<< "\ne2: " << e2
;
1870 EXPECT(e1
== e2
, "Expected e1 == e2");
1872 Expr e3
= vc
->exprFromString("(and (> x 0) (< x y))", SMTLIB_V2_LANG
);
1873 cout
<< "\ne3: " << e3
;
1874 EXPECT(e1
== e3
, "Expected e1 == e3");
1875 } catch(const Exception
& e
) {
1877 cout
<< "*** Exception caught in test21(): \n" << e
<< endl
;
1883 CLFlags flags
= ValidityChecker::createFlags();
1884 ValidityChecker
* vc
= ValidityChecker::create(flags
);
1887 Type
intType(vc
->intType());
1888 Type
fType(vc
->funType(intType
,intType
));
1890 Op
f(vc
->createOp("f",fType
));
1891 Expr
x(vc
->varExpr("x",intType
));
1892 Expr
fx(vc
->exprFromString("f(x)"));
1894 Expr
p(vc
->exprFromString("FORALL (x:INT) : x < f(x)"));
1896 vector
<vector
<Expr
> > patternvv
;
1897 vector
<Expr
> patternv
;
1898 patternv
.push_back(fx
);
1899 patternvv
.push_back(patternv
);
1901 vc
->setTriggers(p
,patternv
);
1902 EXPECT( eqExprVecVecs(p
.getTriggers(), patternvv
),
1903 "Expected p.getTriggers() == patternvv: " + p
.toString() );
1905 vc
->setTriggers(p
,patternvv
);
1907 EXPECT( eqExprVecVecs(p
.getTriggers(), patternvv
),
1908 "Expected p.getTriggers() == patternvv: " + p
.toString() );
1910 // [chris 10/4/2009] Not sure why, but this fails
1912 // Expr q(vc->exprFromString("FORALL (x:INT) : PATTERN (f(x)) : x < f(x)"));
1914 // EXPECT( eqExprVecVecs(q.getTriggers(), patternvv),
1915 // "Expected q.getTriggers() == patternvv" + q.toString());
1919 Expr
r(vc
->forallExpr( vars
, vc
->ltExpr(x
,fx
), patternvv
));
1921 EXPECT( eqExprVecVecs(r
.getTriggers(), patternvv
),
1922 "Expected r.getTriggers() == patternvv: " + r
.toString() );
1924 Expr
s(vc
->exprFromString("FORALL (x:INT) : x > f(x)"));
1925 vc
->setTrigger(s
,fx
);
1927 std::vector
<std::vector
<Expr
> > trigsvv
= s
.getTriggers();
1928 EXPECT( trigsvv
.size() == 1,
1929 "Expected s.getTriggers().size() == 1: " + trigsvv
.size() );
1931 std::vector
<Expr
> trigsv
= trigsvv
[0];
1932 EXPECT( trigsv
.size() == 1,
1933 "Expected s.getTriggers()[0].size() == 1: "
1936 EXPECT( trigsv
[0] == fx
,
1937 "Expected s.getTriggers()[0][0] == fx: "
1938 + (trigsv
[0].toString()) );
1940 Expr
t(vc
->exprFromString("FORALL (x:INT) : x > f(x)"));
1941 vc
->setMultiTrigger(t
,patternv
);
1942 trigsvv
= t
.getTriggers();
1943 EXPECT( trigsvv
.size() == 1,
1944 "Expected t.getTriggers().size() == 1: " + trigsvv
.size() );
1946 trigsv
= trigsvv
[0];
1947 EXPECT( trigsv
.size() == 1,
1948 "Expected t.getTriggers()[0].size() == 1: "
1951 EXPECT( trigsv
[0] == fx
,
1952 "Expected t.getTriggers()[0][0] == fx: "
1953 + (trigsv
[0].toString()) );
1954 } catch(const Exception
& e
) {
1956 cout
<< "*** Exception caught in test22(): \n" << e
<< endl
;
1962 CLFlags flags
= ValidityChecker::createFlags();
1963 ValidityChecker
* vc
= ValidityChecker::create(flags
);
1966 Type
intType(vc
->intType());
1967 Type
fType(vc
->funType(intType
,intType
));
1969 Expr
x(vc
->varExpr("x",intType
));
1970 Expr
y(vc
->varExpr("y",intType
));
1971 Expr
a(vc
->varExpr("a",intType
));
1972 Expr
b(vc
->varExpr("b",intType
));
1974 Expr
s(vc
->exprFromString("x < y"));
1975 Expr
t(vc
->exprFromString("a < b"));
1977 cout
<< "s=" << s
<< "\nt=" << t
<< "\n";
1979 std::vector
<Expr
> oldExprs
, newExprs
;
1980 oldExprs
.push_back(x
);
1981 oldExprs
.push_back(y
);
1982 newExprs
.push_back(a
);
1983 newExprs
.push_back(b
);
1985 Expr
u(s
.substExpr(oldExprs
,newExprs
));
1986 cout
<< "u=" << u
<< "\n";
1988 EXPECT( t
== u
, "Expected t==u" );
1989 } catch(const Exception
& e
) {
1991 cout
<< "*** Exception caught in test23(): \n" << e
<< endl
;
1997 CLFlags flags
= ValidityChecker::createFlags();
1998 ValidityChecker
* vc
= ValidityChecker::create(flags
);
2001 Type
intType(vc
->intType());
2002 Type
aType(vc
->arrayType(intType
,intType
));
2004 Expr
a(vc
->varExpr("a",aType
));
2005 Expr
x(vc
->varExpr("x",intType
));
2006 Expr
ax(vc
->exprFromString("a[x]"));
2008 Expr
p(vc
->exprFromString("FORALL (x:INT) : PATTERN (a[x]) : x < a[x]"));
2012 vector
<vector
<Expr
> > pTriggers(p
.getTriggers());
2013 EXPECT( pTriggers
.size() == 1,
2014 "Actual: " + int2string(pTriggers
.size()));
2015 EXPECT( pTriggers
[0].size() == 1,
2016 "Actual: " + int2string( pTriggers
[0].size()));
2017 /* We can't check that the trigger == ax, because x will have
2018 * been replaced with a bvar
2020 EXPECT( pTriggers
[0][0].getKind() == READ
,
2021 "Actual: " + int2string(pTriggers
[0][0].getKind()));
2022 EXPECT( pTriggers
[0][0][0] == a
,
2023 "Actual: " + pTriggers
[0][0][0].toString() );
2025 Expr
aPrime(vc
->varExpr("a'",aType
));
2026 Expr
axPrime(vc
->exprFromString("a'[x]"));
2028 ExprHashMap
<Expr
> substMap
;
2029 substMap
.insert(a
,aPrime
);
2031 Expr
q(p
.substExpr(substMap
));
2035 vector
<vector
<Expr
> > qTriggers(q
.getTriggers());
2036 EXPECT( qTriggers
.size() == 1,
2038 int2string(qTriggers
.size()));
2039 EXPECT( qTriggers
[0].size() == 1,
2041 int2string(qTriggers
[0].size()));
2042 EXPECT( qTriggers
[0][0].getKind() == READ
,
2044 int2string(qTriggers
[0][0].getKind()));
2045 EXPECT( qTriggers
[0][0][0] == aPrime
,
2046 "Actual: " + qTriggers
[0][0][0].toString() );
2047 } catch(const Exception
& e
) {
2049 cout
<< "*** Exception caught in test24(): \n" << e
<< endl
;
2056 CLFlags flags
= ValidityChecker::createFlags();
2057 ValidityChecker
* vc
= ValidityChecker::create(flags
);
2060 Type
realType(vc
->realType());
2062 Expr x
= vc
->ratExpr("-0.1");
2063 cout
<< "-0.1: " << x
<< endl
;
2064 Expr y
= vc
->ratExpr("-1/10");
2065 cout
<< "-1/10: " << y
<< endl
;
2066 Expr z
= vc
->ratExpr("-1","10",10);
2067 cout
<< "-1 over 10: " << z
<< endl
;
2068 Expr w
= vc
->ratExpr(-1,10);
2069 cout
<< "-1 over 10 (ints): " << w
<< endl
;
2071 EXPECT(x
== y
&& y
== z
&& z
== w
, "Error in rational constants");
2073 } catch(const Exception
& e
) {
2075 cout
<< "*** Exception caught in test25(): \n" << e
<< endl
;
2082 CLFlags flags
= ValidityChecker::createFlags();
2083 ValidityChecker
* vc
= ValidityChecker::create(flags
);
2086 Type
bvType(vc
->bitvecType(32));
2088 Expr x
= vc
->varExpr("x", bvType
);
2089 Expr e1
= vc
->newFixedConstWidthLeftShiftExpr(x
, 16);
2090 Expr e2
= vc
->newBVSHL(x
, vc
->newBVConstExpr(16, 32));
2092 bool b
= check(vc
, vc
->eqExpr(e1
, e2
));
2093 EXPECT(b
, "Should be valid");
2095 e1
= vc
->newFixedRightShiftExpr(x
, 16);
2096 e2
= vc
->newBVLSHR(x
, vc
->newBVConstExpr(16, 32));
2098 b
= check(vc
, vc
->eqExpr(e1
, e2
));
2099 EXPECT(b
, "Should be valid");
2101 e2
= vc
->newBVASHR(x
, vc
->newBVConstExpr(16, 32));
2102 b
= check(vc
, vc
->eqExpr(e1
, e2
));
2103 EXPECT(!b
, "Should be invalid");
2105 } catch(const Exception
& e
) {
2107 cout
<< "*** Exception caught in test26(): \n" << e
<< endl
;
2113 int main(int argc
, char** argv
)
2115 int regressLevel
= 3;
2116 if (argc
> 1) regressLevel
= atoi(argv
[1]);
2117 cout
<< "Running API test, regress level = " << regressLevel
<< endl
;
2121 // [MGD for CVC4] This is a CVC3 test, and many tests had to be commented
2122 // out for CVC4 since the functionality is either unsupported or
2123 // as-yet-unimplemented in CVC4's compatibility layer. For example,
2124 // subranges, predicate subtyping, quantifiers, and string expressions
2125 // are unavailable. Also, Exprs and Types are distinct in CVC4 and it's
2126 // not clear how to implement Type::getExpr(), and Exprs and Ops are
2127 // indistinguishable, so getOp() and getOpExpr() have the same result.
2129 cout
<< "\n}\ntest26(): {" << endl
;
2131 //cout << "\ntest(): {" << endl;
2133 cout
<< "\n}\ntest1(): {" << endl
;
2135 cout
<< "\n}\n\ntest2(): {" << endl
;
2137 cout
<< "\n}\n\ntest3(): {" << endl
;
2139 cout
<< "\n}\n\ntest4(): {" << endl
;
2141 if (regressLevel
> 0) {
2142 cout
<< "\n}\n\ntest5(): {" << endl
;
2145 //cout << "\n}\n\ntest6(): {" << endl;
2147 cout
<< "\n}\n\ntest7(): {" << endl
;
2149 //cout << "\n}\n\ntest8(): {" << endl;
2151 cout
<< "\n}\n\ntest9(" << 10*regressLevel
+10 << "): {" << endl
;
2152 test9(10*regressLevel
+10);
2153 cout
<< "\nbvtest9(): {" << endl
;
2154 bvtest9(regressLevel
*3+2);
2155 cout
<< "\n}" << endl
;
2157 // Test for obvious memory leaks
2158 int limit
= 100 * regressLevel
+10;
2159 for(int i
=0; i
<limit
; ++i
) {
2160 if(i
% 100 == 0) cout
<< "test10[" << i
<< "]" << endl
;
2164 //cout << "\ntest11(): {" << endl;
2166 cout
<< "\n}\ntest12(): {" << endl
;
2168 cout
<< "\n}\ntest13(): {" << endl
;
2170 cout
<< "\n}\ntest14(): {" << endl
;
2172 //cout << "\n}\ntest15(): {" << endl;
2174 //cout << "\n}\ntest16(): {" << endl;
2176 cout
<< "\n}\ntest17(): {" << endl
;
2178 cout
<< "\n}\ntest18(): {" << endl
;
2180 cout
<< "\n}\ntest19(): {" << endl
;
2182 cout
<< "\ntest20(): {" << endl
;
2184 cout
<< "\n}\ntest21(): {" << endl
;
2186 //cout << "\n}\ntest22(): {" << endl;
2188 cout
<< "\n}\ntest23(): {" << endl
;
2190 cout
<< "\n}\ntest24(): {" << endl
;
2192 cout
<< "\n}\ntest25(): {" << endl
;
2196 if (regressLevel > 1) {
2197 cout << "\n}\ntestgeorge1(): {" << endl;
2199 cout << "\n}\ntestgeorge2(): {" << endl;
2201 cout << "\n}\ntestgeorge3(): {" << endl;
2203 cout << "\n}\ntestgeorge4(): {" << endl;
2205 cout << "\n}\ntestgeorge5(): {" << endl;
2209 cout
<< "\n}" << endl
;
2211 } catch(const Exception
& e
) {
2212 cout
<< "*** Exception caught: \n" << e
<< endl
;
2216 cout
<< "Program exits successfully." << endl
;
2218 cout
<< "Program exits with error status = " << exitStatus
<< "." << endl
;