1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Mathias Preiner, Liana Hadarean, Aina Niemetz |
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 |
|
* Algebraic solver. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "cvc5_private.h" |
17 |
|
|
18 |
|
#ifndef CVC5__THEORY__BV__BV_SUBTHEORY__INEQUALITY_H |
19 |
|
#define CVC5__THEORY__BV__BV_SUBTHEORY__INEQUALITY_H |
20 |
|
|
21 |
|
#include <unordered_set> |
22 |
|
|
23 |
|
#include "context/cdhashset.h" |
24 |
|
#include "expr/attribute.h" |
25 |
|
#include "theory/bv/bv_inequality_graph.h" |
26 |
|
#include "theory/bv/bv_subtheory.h" |
27 |
|
|
28 |
|
namespace cvc5 { |
29 |
|
namespace theory { |
30 |
|
namespace bv { |
31 |
|
|
32 |
|
/** Cache for InequalitySolver::isInequalityOnly() */ |
33 |
|
struct IneqOnlyAttributeId |
34 |
|
{ |
35 |
|
}; |
36 |
|
typedef expr::Attribute<IneqOnlyAttributeId, bool> IneqOnlyAttribute; |
37 |
|
|
38 |
|
/** Whether the above has been computed yet or not for an expr */ |
39 |
|
struct IneqOnlyComputedAttributeId |
40 |
|
{ |
41 |
|
}; |
42 |
|
typedef expr::Attribute<IneqOnlyComputedAttributeId, bool> |
43 |
|
IneqOnlyComputedAttribute; |
44 |
|
|
45 |
|
class InequalitySolver : public SubtheorySolver |
46 |
|
{ |
47 |
|
struct Statistics |
48 |
|
{ |
49 |
|
IntStat d_numCallstoCheck; |
50 |
|
TimerStat d_solveTime; |
51 |
|
Statistics(); |
52 |
|
}; |
53 |
|
|
54 |
|
context::CDHashSet<Node> d_assertionSet; |
55 |
|
InequalityGraph d_inequalityGraph; |
56 |
|
context::CDHashMap<Node, TNode> d_explanations; |
57 |
|
context::CDO<bool> d_isComplete; |
58 |
|
typedef std::unordered_set<Node> NodeSet; |
59 |
|
NodeSet d_ineqTerms; |
60 |
|
bool isInequalityOnly(TNode node); |
61 |
|
bool addInequality(TNode a, TNode b, bool strict, TNode fact); |
62 |
|
Statistics d_statistics; |
63 |
|
|
64 |
|
public: |
65 |
|
InequalitySolver(context::Context* c, |
66 |
|
context::Context* u, |
67 |
|
BVSolverLayered* bv) |
68 |
|
: SubtheorySolver(c, bv), |
69 |
|
d_assertionSet(c), |
70 |
|
d_inequalityGraph(c, u), |
71 |
|
d_explanations(c), |
72 |
|
d_isComplete(c, true), |
73 |
|
d_ineqTerms(), |
74 |
|
d_statistics() |
75 |
|
{ |
76 |
|
} |
77 |
|
|
78 |
|
bool check(Theory::Effort e) override; |
79 |
|
void propagate(Theory::Effort e) override; |
80 |
|
void explain(TNode literal, std::vector<TNode>& assumptions) override; |
81 |
|
bool isComplete() override { return d_isComplete; } |
82 |
|
bool collectModelValues(TheoryModel* m, |
83 |
|
const std::set<Node>& termSet) override; |
84 |
|
Node getModelValue(TNode var) override; |
85 |
|
EqualityStatus getEqualityStatus(TNode a, TNode b) override; |
86 |
|
void assertFact(TNode fact) override; |
87 |
|
void preRegister(TNode node) override; |
88 |
|
}; |
89 |
|
|
90 |
|
} // namespace bv |
91 |
|
} // namespace theory |
92 |
|
} // namespace cvc5 |
93 |
|
|
94 |
|
#endif /* CVC5__THEORY__BV__BV_SUBTHEORY__INEQUALITY_H */ |