1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Mudathir Mohamed, 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/strings/infer_info.h" |
17 |
|
|
18 |
|
#include "theory/strings/inference_manager.h" |
19 |
|
#include "theory/strings/theory_strings_utils.h" |
20 |
|
#include "theory/theory.h" |
21 |
|
|
22 |
|
namespace cvc5 { |
23 |
|
namespace theory { |
24 |
|
namespace strings { |
25 |
|
|
26 |
97322 |
InferInfo::InferInfo(InferenceId id): TheoryInference(id), d_sim(nullptr), d_idRev(false) |
27 |
|
{ |
28 |
97322 |
} |
29 |
|
|
30 |
25507 |
TrustNode InferInfo::processLemma(LemmaProperty& p) |
31 |
|
{ |
32 |
25507 |
return d_sim->processLemma(*this, p); |
33 |
|
} |
34 |
|
|
35 |
37303 |
Node InferInfo::processFact(std::vector<Node>& exp, ProofGenerator*& pg) |
36 |
|
{ |
37 |
122612 |
for (const Node& ec : d_premises) |
38 |
|
{ |
39 |
85309 |
utils::flattenOp(kind::AND, ec, exp); |
40 |
|
} |
41 |
37303 |
d_sim->processFact(*this, pg); |
42 |
37303 |
return d_conc; |
43 |
|
} |
44 |
|
|
45 |
90241 |
bool InferInfo::isTrivial() const |
46 |
|
{ |
47 |
90241 |
Assert(!d_conc.isNull()); |
48 |
90241 |
return d_conc.isConst() && d_conc.getConst<bool>(); |
49 |
|
} |
50 |
|
|
51 |
90241 |
bool InferInfo::isConflict() const |
52 |
|
{ |
53 |
90241 |
Assert(!d_conc.isNull()); |
54 |
90241 |
return d_conc.isConst() && !d_conc.getConst<bool>() && d_noExplain.empty(); |
55 |
|
} |
56 |
|
|
57 |
40775 |
bool InferInfo::isFact() const |
58 |
|
{ |
59 |
40775 |
Assert(!d_conc.isNull()); |
60 |
81550 |
TNode atom = d_conc.getKind() == kind::NOT ? d_conc[0] : d_conc; |
61 |
|
// we could process inferences with conjunctive conclusions as facts, where |
62 |
|
// the explanation is copied. However, for simplicity, we always send these |
63 |
|
// as lemmas. This case happens very infrequently. |
64 |
122245 |
return !atom.isConst() && Theory::theoryOf(atom) == THEORY_STRINGS |
65 |
160524 |
&& d_noExplain.empty(); |
66 |
|
} |
67 |
|
|
68 |
74606 |
Node InferInfo::getPremises() const |
69 |
|
{ |
70 |
|
// d_noExplain is a subset of d_ant |
71 |
74606 |
return utils::mkAnd(d_premises); |
72 |
|
} |
73 |
|
|
74 |
|
std::ostream& operator<<(std::ostream& out, const InferInfo& ii) |
75 |
|
{ |
76 |
|
out << "(infer " << ii.getId() << " " << ii.d_conc; |
77 |
|
if (ii.d_idRev) |
78 |
|
{ |
79 |
|
out << " :rev"; |
80 |
|
} |
81 |
|
if (!ii.d_premises.empty()) |
82 |
|
{ |
83 |
|
out << " :ant (" << ii.d_premises << ")"; |
84 |
|
} |
85 |
|
if (!ii.d_noExplain.empty()) |
86 |
|
{ |
87 |
|
out << " :no-explain (" << ii.d_noExplain << ")"; |
88 |
|
} |
89 |
|
out << ")"; |
90 |
|
return out; |
91 |
|
} |
92 |
|
|
93 |
|
} // namespace strings |
94 |
|
} // namespace theory |
95 |
31137 |
} // namespace cvc5 |