1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Mudathir Mohamed, 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 inference information utility. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "theory/bags/infer_info.h" |
17 |
|
|
18 |
|
#include "theory/bags/inference_manager.h" |
19 |
|
|
20 |
|
namespace cvc5 { |
21 |
|
namespace theory { |
22 |
|
namespace bags { |
23 |
|
|
24 |
1857 |
InferInfo::InferInfo(TheoryInferenceManager* im, InferenceId id) |
25 |
1857 |
: TheoryInference(id), d_im(im) |
26 |
|
{ |
27 |
1857 |
} |
28 |
|
|
29 |
1857 |
TrustNode InferInfo::processLemma(LemmaProperty& p) |
30 |
|
{ |
31 |
1857 |
NodeManager* nm = NodeManager::currentNM(); |
32 |
3714 |
Node pnode = nm->mkAnd(d_premises); |
33 |
3714 |
Node lemma = nm->mkNode(kind::IMPLIES, pnode, d_conclusion); |
34 |
|
|
35 |
|
// send lemmas corresponding to the skolems introduced |
36 |
2495 |
for (const auto& pair : d_skolems) |
37 |
|
{ |
38 |
1276 |
Node n = pair.first.eqNode(pair.second); |
39 |
1276 |
TrustNode trustedLemma = TrustNode::mkTrustLemma(n, nullptr); |
40 |
638 |
d_im->trustedLemma(trustedLemma, getId(), p); |
41 |
|
} |
42 |
|
|
43 |
1857 |
Trace("bags::InferInfo::process") << (*this) << std::endl; |
44 |
|
|
45 |
3714 |
return TrustNode::mkTrustLemma(lemma, nullptr); |
46 |
|
} |
47 |
|
|
48 |
|
bool InferInfo::isTrivial() const |
49 |
|
{ |
50 |
|
Assert(!d_conclusion.isNull()); |
51 |
|
return d_conclusion.isConst() && d_conclusion.getConst<bool>(); |
52 |
|
} |
53 |
|
|
54 |
|
bool InferInfo::isConflict() const |
55 |
|
{ |
56 |
|
Assert(!d_conclusion.isNull()); |
57 |
|
return d_conclusion.isConst() && !d_conclusion.getConst<bool>(); |
58 |
|
} |
59 |
|
|
60 |
|
bool InferInfo::isFact() const |
61 |
|
{ |
62 |
|
Assert(!d_conclusion.isNull()); |
63 |
|
TNode atom = |
64 |
|
d_conclusion.getKind() == kind::NOT ? d_conclusion[0] : d_conclusion; |
65 |
|
return !atom.isConst() && atom.getKind() != kind::OR; |
66 |
|
} |
67 |
|
|
68 |
|
std::ostream& operator<<(std::ostream& out, const InferInfo& ii) |
69 |
|
{ |
70 |
|
out << "(infer :id " << ii.getId() << std::endl; |
71 |
|
out << ":conclusion " << ii.d_conclusion << std::endl; |
72 |
|
if (!ii.d_premises.empty()) |
73 |
|
{ |
74 |
|
out << " :premise (" << ii.d_premises << ")" << std::endl; |
75 |
|
} |
76 |
|
out << ":skolems " << ii.d_skolems << std::endl; |
77 |
|
out << ")"; |
78 |
|
return out; |
79 |
|
} |
80 |
|
|
81 |
|
} // namespace bags |
82 |
|
} // namespace theory |
83 |
22755 |
} // namespace cvc5 |