GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/bags/infer_info.cpp Lines: 14 32 43.8 %
Date: 2021-05-22 Branches: 20 122 16.4 %

Line Exec Source
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
2621
InferInfo::InferInfo(TheoryInferenceManager* im, InferenceId id)
25
2621
    : TheoryInference(id), d_im(im)
26
{
27
2621
}
28
29
2621
TrustNode InferInfo::processLemma(LemmaProperty& p)
30
{
31
2621
  NodeManager* nm = NodeManager::currentNM();
32
5242
  Node pnode = nm->mkAnd(d_premises);
33
5242
  Node lemma = nm->mkNode(kind::IMPLIES, pnode, d_conclusion);
34
35
  // send lemmas corresponding to the skolems introduced
36
3637
  for (const auto& pair : d_skolems)
37
  {
38
2032
    Node n = pair.first.eqNode(pair.second);
39
2032
    TrustNode trustedLemma = TrustNode::mkTrustLemma(n, nullptr);
40
1016
    d_im->trustedLemma(trustedLemma, getId(), p);
41
  }
42
43
2621
  Trace("bags::InferInfo::process") << (*this) << std::endl;
44
45
5242
  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
28191
}  // namespace cvc5