1 /******************************************************************************
2 * Top contributors (to current version):
3 * Andrew Reynolds, Mudathir Mohamed, Gereon Kremer
5 * This file is part of the cvc5 project.
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 * ****************************************************************************
13 * Implementation of inference information utility.
16 #include "theory/strings/infer_info.h"
18 #include "theory/strings/inference_manager.h"
19 #include "theory/strings/theory_strings_utils.h"
20 #include "theory/theory.h"
26 InferInfo::InferInfo(InferenceId id
): TheoryInference(id
), d_sim(nullptr), d_idRev(false)
30 TrustNode
InferInfo::processLemma(LemmaProperty
& p
)
32 return d_sim
->processLemma(*this, p
);
35 Node
InferInfo::processFact(std::vector
<Node
>& exp
, ProofGenerator
*& pg
)
37 for (const Node
& ec
: d_premises
)
39 utils::flattenOp(kind::AND
, ec
, exp
);
41 d_sim
->processFact(*this, pg
);
45 bool InferInfo::isTrivial() const
47 Assert(!d_conc
.isNull());
48 return d_conc
.isConst() && d_conc
.getConst
<bool>();
51 bool InferInfo::isConflict() const
53 Assert(!d_conc
.isNull());
54 return d_conc
.isConst() && !d_conc
.getConst
<bool>() && d_noExplain
.empty();
57 bool InferInfo::isFact() const
59 Assert(!d_conc
.isNull());
60 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 return !atom
.isConst() && Theory::theoryOf(atom
) == THEORY_STRINGS
65 && d_noExplain
.empty();
68 Node
InferInfo::getPremises() const
70 // d_noExplain is a subset of d_ant
71 return utils::mkAnd(d_premises
);
74 std::ostream
& operator<<(std::ostream
& out
, const InferInfo
& ii
)
76 out
<< "(infer " << ii
.getId() << " " << ii
.d_conc
;
81 if (!ii
.d_premises
.empty())
83 out
<< " :ant (" << ii
.d_premises
<< ")";
85 if (!ii
.d_noExplain
.empty())
87 out
<< " :no-explain (" << ii
.d_noExplain
<< ")";
93 } // namespace strings