1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Aina Niemetz, Yoni Zohar |
4 |
|
* |
5 |
|
* This file is part of the cvc5 project. |
6 |
|
* |
7 |
|
* Copyright (c) 2009-2021 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. |
11 |
|
* **************************************************************************** |
12 |
|
* |
13 |
|
* Unit tests for Foreign Theory Rerwrite prepricessing pass. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "expr/node_manager.h" |
17 |
|
#include "preprocessing/passes/foreign_theory_rewrite.h" |
18 |
|
#include "smt/smt_engine.h" |
19 |
|
#include "test_smt.h" |
20 |
|
#include "util/rational.h" |
21 |
|
|
22 |
|
namespace cvc5 { |
23 |
|
|
24 |
|
using namespace preprocessing::passes; |
25 |
|
|
26 |
|
namespace test { |
27 |
|
|
28 |
4 |
class TestPPWhiteForeignTheoryRewrite : public TestSmt |
29 |
|
{ |
30 |
|
}; |
31 |
|
|
32 |
10 |
TEST_F(TestPPWhiteForeignTheoryRewrite, simplify) |
33 |
|
{ |
34 |
2 |
std::cout << "len(x) >= 0 is simplified to true" << std::endl; |
35 |
4 |
Node x = d_nodeManager->mkVar("x", d_nodeManager->stringType()); |
36 |
4 |
Node len_x = d_nodeManager->mkNode(kind::STRING_LENGTH, x); |
37 |
4 |
Node zero = d_nodeManager->mkConst<Rational>(0); |
38 |
4 |
Node geq1 = d_nodeManager->mkNode(kind::GEQ, len_x, zero); |
39 |
4 |
Node tt = d_nodeManager->mkConst<bool>(true); |
40 |
4 |
Node simplified1 = ForeignTheoryRewrite::foreignRewrite(geq1); |
41 |
2 |
ASSERT_EQ(simplified1, tt); |
42 |
|
|
43 |
2 |
std::cout << "len(x) >= n is not simplified to true" << std::endl; |
44 |
4 |
Node n = d_nodeManager->mkVar("n", d_nodeManager->integerType()); |
45 |
4 |
Node geq2 = d_nodeManager->mkNode(kind::GEQ, len_x, n); |
46 |
4 |
Node simplified2 = ForeignTheoryRewrite::foreignRewrite(geq2); |
47 |
2 |
ASSERT_NE(simplified2, tt); |
48 |
|
} |
49 |
|
|
50 |
|
} // namespace test |
51 |
24274 |
} // namespace cvc5 |