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 |
|
|
21 |
|
namespace cvc5 { |
22 |
|
namespace theory { |
23 |
|
namespace strings { |
24 |
|
|
25 |
76953 |
InferInfo::InferInfo(InferenceId id): TheoryInference(id), d_sim(nullptr), d_idRev(false) |
26 |
|
{ |
27 |
76953 |
} |
28 |
|
|
29 |
21422 |
TrustNode InferInfo::processLemma(LemmaProperty& p) |
30 |
|
{ |
31 |
21422 |
return d_sim->processLemma(*this, p); |
32 |
|
} |
33 |
|
|
34 |
29540 |
Node InferInfo::processFact(std::vector<Node>& exp, ProofGenerator*& pg) |
35 |
|
{ |
36 |
97006 |
for (const Node& ec : d_premises) |
37 |
|
{ |
38 |
67466 |
utils::flattenOp(kind::AND, ec, exp); |
39 |
|
} |
40 |
29540 |
d_sim->processFact(*this, pg); |
41 |
29540 |
return d_conc; |
42 |
|
} |
43 |
|
|
44 |
73899 |
bool InferInfo::isTrivial() const |
45 |
|
{ |
46 |
73899 |
Assert(!d_conc.isNull()); |
47 |
73899 |
return d_conc.isConst() && d_conc.getConst<bool>(); |
48 |
|
} |
49 |
|
|
50 |
73899 |
bool InferInfo::isConflict() const |
51 |
|
{ |
52 |
73899 |
Assert(!d_conc.isNull()); |
53 |
73899 |
return d_conc.isConst() && !d_conc.getConst<bool>() && d_noExplain.empty(); |
54 |
|
} |
55 |
|
|
56 |
32429 |
bool InferInfo::isFact() const |
57 |
|
{ |
58 |
32429 |
Assert(!d_conc.isNull()); |
59 |
64858 |
TNode atom = d_conc.getKind() == kind::NOT ? d_conc[0] : d_conc; |
60 |
|
// we could process inferences with conjunctive conclusions as facts, where |
61 |
|
// the explanation is copied. However, for simplicity, we always send these |
62 |
|
// as lemmas. This case happens very infrequently. |
63 |
64776 |
return !atom.isConst() && atom.getKind() != kind::OR |
64 |
95925 |
&& atom.getKind() != kind::AND && d_noExplain.empty(); |
65 |
|
} |
66 |
|
|
67 |
59080 |
Node InferInfo::getPremises() const |
68 |
|
{ |
69 |
|
// d_noExplain is a subset of d_ant |
70 |
59080 |
return utils::mkAnd(d_premises); |
71 |
|
} |
72 |
|
|
73 |
|
std::ostream& operator<<(std::ostream& out, const InferInfo& ii) |
74 |
|
{ |
75 |
|
out << "(infer " << ii.getId() << " " << ii.d_conc; |
76 |
|
if (ii.d_idRev) |
77 |
|
{ |
78 |
|
out << " :rev"; |
79 |
|
} |
80 |
|
if (!ii.d_premises.empty()) |
81 |
|
{ |
82 |
|
out << " :ant (" << ii.d_premises << ")"; |
83 |
|
} |
84 |
|
if (!ii.d_noExplain.empty()) |
85 |
|
{ |
86 |
|
out << " :no-explain (" << ii.d_noExplain << ")"; |
87 |
|
} |
88 |
|
out << ")"; |
89 |
|
return out; |
90 |
|
} |
91 |
|
|
92 |
|
} // namespace strings |
93 |
|
} // namespace theory |
94 |
29340 |
} // namespace cvc5 |