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 "expr/proof.h" |
22 |
|
#include "theory/arith/inference_manager.h" |
23 |
|
#include "theory/arith/nl/ext/monomial.h" |
24 |
|
#include "theory/arith/nl/nl_model.h" |
25 |
|
#include "theory/arith/nl/nl_lemma_utils.h" |
26 |
|
|
27 |
|
namespace cvc5 { |
28 |
|
namespace theory { |
29 |
|
namespace arith { |
30 |
|
namespace nl { |
31 |
|
|
32 |
4781 |
ExtState::ExtState(InferenceManager& im, |
33 |
|
NlModel& model, |
34 |
|
ProofNodeManager* pnm, |
35 |
4781 |
context::UserContext* c) |
36 |
4781 |
: d_im(im), d_model(model), d_pnm(pnm), d_ctx(c) |
37 |
|
{ |
38 |
4781 |
d_false = NodeManager::currentNM()->mkConst(false); |
39 |
4781 |
d_true = NodeManager::currentNM()->mkConst(true); |
40 |
4781 |
d_zero = NodeManager::currentNM()->mkConst(Rational(0)); |
41 |
4781 |
d_one = NodeManager::currentNM()->mkConst(Rational(1)); |
42 |
4781 |
d_neg_one = NodeManager::currentNM()->mkConst(Rational(-1)); |
43 |
4781 |
if (d_pnm != nullptr) |
44 |
|
{ |
45 |
567 |
d_proof.reset(new CDProofSet<CDProof>(d_pnm, d_ctx, "nl-ext")); |
46 |
|
} |
47 |
4781 |
} |
48 |
|
|
49 |
2763 |
void ExtState::init(const std::vector<Node>& xts) |
50 |
|
{ |
51 |
2763 |
d_ms_vars.clear(); |
52 |
2763 |
d_ms.clear(); |
53 |
2763 |
d_mterms.clear(); |
54 |
2763 |
d_tplane_refine.clear(); |
55 |
|
|
56 |
2763 |
Trace("nl-ext-mv") << "Extended terms : " << std::endl; |
57 |
|
// for computing congruence |
58 |
5526 |
std::map<Kind, ArgTrie> argTrie; |
59 |
24104 |
for (unsigned i = 0, xsize = xts.size(); i < xsize; i++) |
60 |
|
{ |
61 |
42682 |
Node a = xts[i]; |
62 |
21341 |
d_model.computeConcreteModelValue(a); |
63 |
21341 |
d_model.computeAbstractModelValue(a); |
64 |
21341 |
d_model.printModelValue("nl-ext-mv", a); |
65 |
21341 |
Kind ak = a.getKind(); |
66 |
21341 |
if (ak == Kind::NONLINEAR_MULT) |
67 |
|
{ |
68 |
14709 |
d_ms.push_back(a); |
69 |
|
|
70 |
|
// context-independent registration |
71 |
14709 |
d_mdb.registerMonomial(a); |
72 |
|
|
73 |
14709 |
const std::vector<Node>& varList = d_mdb.getVariableList(a); |
74 |
43108 |
for (const Node& v : varList) |
75 |
|
{ |
76 |
28399 |
if (std::find(d_ms_vars.begin(), d_ms_vars.end(), v) == d_ms_vars.end()) |
77 |
|
{ |
78 |
13138 |
d_ms_vars.push_back(v); |
79 |
|
} |
80 |
|
} |
81 |
|
// mark processed if has a "one" factor (will look at reduced monomial)? |
82 |
|
} |
83 |
|
} |
84 |
|
|
85 |
|
// register constants |
86 |
2763 |
d_mdb.registerMonomial(d_one); |
87 |
|
|
88 |
|
// register variables |
89 |
2763 |
Trace("nl-ext-mv") << "Variables in monomials : " << std::endl; |
90 |
15901 |
for (unsigned i = 0; i < d_ms_vars.size(); i++) |
91 |
|
{ |
92 |
26276 |
Node v = d_ms_vars[i]; |
93 |
13138 |
d_mdb.registerMonomial(v); |
94 |
13138 |
d_model.computeConcreteModelValue(v); |
95 |
13138 |
d_model.computeAbstractModelValue(v); |
96 |
13138 |
d_model.printModelValue("nl-ext-mv", v); |
97 |
|
} |
98 |
|
|
99 |
2763 |
Trace("nl-ext") << "We have " << d_ms.size() << " monomials." << std::endl; |
100 |
2763 |
} |
101 |
|
|
102 |
4815 |
bool ExtState::isProofEnabled() const { return d_proof.get() != nullptr; } |
103 |
|
|
104 |
836 |
CDProof* ExtState::getProof() |
105 |
|
{ |
106 |
836 |
Assert(isProofEnabled()); |
107 |
836 |
return d_proof->allocateProof(d_ctx); |
108 |
|
} |
109 |
|
|
110 |
|
} // namespace nl |
111 |
|
} // namespace arith |
112 |
|
} // namespace theory |
113 |
27735 |
} // namespace cvc5 |