summaryrefslogtreecommitdiff
path: root/src/theory/bags/infer_info.cpp
blob: 444597eb5215e5dbd293abda78a1c66e73a80add (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*********************                                                        */
/*! \file infer_info.cpp
 ** \verbatim
 ** Top contributors (to current version):
 **   Mudathir Mohamed, Andrew Reynolds, Gereon Kremer
 ** This file is part of the CVC4 project.
 ** Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
 ** in the top-level source directory and their institutional affiliations.
 ** All rights reserved.  See the file COPYING in the top-level source
 ** directory for licensing information.\endverbatim
 **
 ** \brief Implementation of inference information utility.
 **/

#include "theory/bags/infer_info.h"

#include "theory/bags/inference_manager.h"

namespace CVC5 {
namespace theory {
namespace bags {

InferInfo::InferInfo(TheoryInferenceManager* im, InferenceId id)
    : TheoryInference(id), d_im(im)
{
}

TrustNode InferInfo::processLemma(LemmaProperty& p)
{
  NodeManager* nm = NodeManager::currentNM();
  Node pnode = nm->mkAnd(d_premises);
  Node lemma = nm->mkNode(kind::IMPLIES, pnode, d_conclusion);

  // send lemmas corresponding to the skolems introduced
  for (const auto& pair : d_skolems)
  {
    Node n = pair.first.eqNode(pair.second);
    TrustNode trustedLemma = TrustNode::mkTrustLemma(n, nullptr);
    d_im->trustedLemma(trustedLemma, getId(), p);
  }

  Trace("bags::InferInfo::process") << (*this) << std::endl;

  return TrustNode::mkTrustLemma(lemma, nullptr);
}

bool InferInfo::isTrivial() const
{
  Assert(!d_conclusion.isNull());
  return d_conclusion.isConst() && d_conclusion.getConst<bool>();
}

bool InferInfo::isConflict() const
{
  Assert(!d_conclusion.isNull());
  return d_conclusion.isConst() && !d_conclusion.getConst<bool>();
}

bool InferInfo::isFact() const
{
  Assert(!d_conclusion.isNull());
  TNode atom =
      d_conclusion.getKind() == kind::NOT ? d_conclusion[0] : d_conclusion;
  return !atom.isConst() && atom.getKind() != kind::OR;
}

std::ostream& operator<<(std::ostream& out, const InferInfo& ii)
{
  out << "(infer :id " << ii.getId() << std::endl;
  out << ":conclusion " << ii.d_conclusion << std::endl;
  if (!ii.d_premises.empty())
  {
    out << " :premise (" << ii.d_premises << ")" << std::endl;
  }
  out << ":skolems " << ii.d_skolems << std::endl;
  out << ")";
  return out;
}

}  // namespace bags
}  // namespace theory
}  // namespace CVC5
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback