1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Gereon Kremer, Tim King |
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 |
|
* Common data shared by multiple checks. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "theory/arith/nl/ext/ext_state.h" |
17 |
|
|
18 |
|
#include <vector> |
19 |
|
|
20 |
|
#include "expr/node.h" |
21 |
|
#include "proof/proof.h" |
22 |
|
#include "theory/arith/inference_manager.h" |
23 |
|
#include "theory/arith/nl/ext/monomial.h" |
24 |
|
#include "theory/arith/nl/nl_lemma_utils.h" |
25 |
|
#include "theory/arith/nl/nl_model.h" |
26 |
|
#include "util/rational.h" |
27 |
|
|
28 |
|
namespace cvc5 { |
29 |
|
namespace theory { |
30 |
|
namespace arith { |
31 |
|
namespace nl { |
32 |
|
|
33 |
9700 |
ExtState::ExtState(InferenceManager& im, NlModel& model, Env& env) |
34 |
9700 |
: d_im(im), d_model(model), d_env(env) |
35 |
|
{ |
36 |
9700 |
d_false = NodeManager::currentNM()->mkConst(false); |
37 |
9700 |
d_true = NodeManager::currentNM()->mkConst(true); |
38 |
9700 |
d_zero = NodeManager::currentNM()->mkConst(Rational(0)); |
39 |
9700 |
d_one = NodeManager::currentNM()->mkConst(Rational(1)); |
40 |
9700 |
d_neg_one = NodeManager::currentNM()->mkConst(Rational(-1)); |
41 |
9700 |
if (d_env.isTheoryProofProducing()) |
42 |
|
{ |
43 |
14046 |
d_proof.reset(new CDProofSet<CDProof>( |
44 |
9364 |
d_env.getProofNodeManager(), d_env.getUserContext(), "nl-ext")); |
45 |
|
} |
46 |
9700 |
} |
47 |
|
|
48 |
4188 |
void ExtState::init(const std::vector<Node>& xts) |
49 |
|
{ |
50 |
4188 |
d_ms_vars.clear(); |
51 |
4188 |
d_ms.clear(); |
52 |
4188 |
d_mterms.clear(); |
53 |
4188 |
d_tplane_refine.clear(); |
54 |
|
|
55 |
4188 |
Trace("nl-ext-mv") << "Extended terms : " << std::endl; |
56 |
|
// for computing congruence |
57 |
8376 |
std::map<Kind, ArgTrie> argTrie; |
58 |
35716 |
for (unsigned i = 0, xsize = xts.size(); i < xsize; i++) |
59 |
|
{ |
60 |
63056 |
Node a = xts[i]; |
61 |
31528 |
d_model.computeConcreteModelValue(a); |
62 |
31528 |
d_model.computeAbstractModelValue(a); |
63 |
31528 |
d_model.printModelValue("nl-ext-mv", a); |
64 |
31528 |
Kind ak = a.getKind(); |
65 |
31528 |
if (ak == Kind::NONLINEAR_MULT) |
66 |
|
{ |
67 |
22930 |
d_ms.push_back(a); |
68 |
|
|
69 |
|
// context-independent registration |
70 |
22930 |
d_mdb.registerMonomial(a); |
71 |
|
|
72 |
22930 |
const std::vector<Node>& varList = d_mdb.getVariableList(a); |
73 |
67286 |
for (const Node& v : varList) |
74 |
|
{ |
75 |
44356 |
if (std::find(d_ms_vars.begin(), d_ms_vars.end(), v) == d_ms_vars.end()) |
76 |
|
{ |
77 |
24877 |
d_ms_vars.push_back(v); |
78 |
|
} |
79 |
|
} |
80 |
|
// mark processed if has a "one" factor (will look at reduced monomial)? |
81 |
|
} |
82 |
|
} |
83 |
|
|
84 |
|
// register constants |
85 |
4188 |
d_mdb.registerMonomial(d_one); |
86 |
|
|
87 |
|
// register variables |
88 |
4188 |
Trace("nl-ext-mv") << "Variables in monomials : " << std::endl; |
89 |
29065 |
for (unsigned i = 0; i < d_ms_vars.size(); i++) |
90 |
|
{ |
91 |
49754 |
Node v = d_ms_vars[i]; |
92 |
24877 |
d_mdb.registerMonomial(v); |
93 |
24877 |
d_model.computeConcreteModelValue(v); |
94 |
24877 |
d_model.computeAbstractModelValue(v); |
95 |
24877 |
d_model.printModelValue("nl-ext-mv", v); |
96 |
|
} |
97 |
|
|
98 |
4188 |
Trace("nl-ext") << "We have " << d_ms.size() << " monomials." << std::endl; |
99 |
4188 |
} |
100 |
|
|
101 |
7843 |
bool ExtState::isProofEnabled() const { return d_proof.get() != nullptr; } |
102 |
|
|
103 |
1039 |
CDProof* ExtState::getProof() |
104 |
|
{ |
105 |
1039 |
Assert(isProofEnabled()); |
106 |
1039 |
return d_proof->allocateProof(d_env.getUserContext()); |
107 |
|
} |
108 |
|
|
109 |
|
} // namespace nl |
110 |
|
} // namespace arith |
111 |
|
} // namespace theory |
112 |
31125 |
} // namespace cvc5 |