1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Gereon Kremer |
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 |
|
* Implementation of utilities for the non-linear solver. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "theory/arith/nl/nl_lemma_utils.h" |
17 |
|
|
18 |
|
#include "theory/arith/nl/nl_model.h" |
19 |
|
#include "theory/arith/nl/nonlinear_extension.h" |
20 |
|
|
21 |
|
namespace cvc5 { |
22 |
|
namespace theory { |
23 |
|
namespace arith { |
24 |
|
namespace nl { |
25 |
|
|
26 |
|
TrustNode NlLemma::processLemma(LemmaProperty& p) |
27 |
|
{ |
28 |
|
if (d_nlext != nullptr) |
29 |
|
{ |
30 |
|
d_nlext->processSideEffect(*this); |
31 |
|
} |
32 |
|
return SimpleTheoryLemma::processLemma(p); |
33 |
|
} |
34 |
|
|
35 |
|
std::ostream& operator<<(std::ostream& out, NlLemma& n) |
36 |
|
{ |
37 |
|
out << n.d_node; |
38 |
|
return out; |
39 |
|
} |
40 |
|
|
41 |
61125 |
bool SortNlModel::operator()(Node i, Node j) |
42 |
|
{ |
43 |
61125 |
int cv = d_nlm->compare(i, j, d_isConcrete, d_isAbsolute); |
44 |
61125 |
if (cv == 0) |
45 |
|
{ |
46 |
13505 |
return i < j; |
47 |
|
} |
48 |
47620 |
return d_reverse_order ? cv > 0 : cv < 0; |
49 |
|
} |
50 |
|
|
51 |
20093 |
bool SortNonlinearDegree::operator()(Node i, Node j) |
52 |
|
{ |
53 |
20093 |
unsigned i_count = getDegree(i); |
54 |
20093 |
unsigned j_count = getDegree(j); |
55 |
20093 |
return i_count == j_count ? (i < j) : (i_count < j_count ? true : false); |
56 |
|
} |
57 |
|
|
58 |
40186 |
unsigned SortNonlinearDegree::getDegree(Node n) const |
59 |
|
{ |
60 |
40186 |
std::map<Node, unsigned>::const_iterator it = d_mdegree.find(n); |
61 |
40186 |
Assert(it != d_mdegree.end()); |
62 |
40186 |
return it->second; |
63 |
|
} |
64 |
|
|
65 |
4264 |
Node ArgTrie::add(Node d, const std::vector<Node>& args) |
66 |
|
{ |
67 |
4264 |
ArgTrie* at = this; |
68 |
8528 |
for (const Node& a : args) |
69 |
|
{ |
70 |
4264 |
at = &(at->d_children[a]); |
71 |
|
} |
72 |
4264 |
if (at->d_data.isNull()) |
73 |
|
{ |
74 |
3912 |
at->d_data = d; |
75 |
|
} |
76 |
4264 |
return at->d_data; |
77 |
|
} |
78 |
|
|
79 |
|
} // namespace nl |
80 |
|
} // namespace arith |
81 |
|
} // namespace theory |
82 |
31137 |
} // namespace cvc5 |