GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/strings/infer_info.cpp Lines: 23 33 69.7 %
Date: 2021-08-01 Branches: 39 106 36.8 %

Line Exec Source
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
67057
InferInfo::InferInfo(InferenceId id): TheoryInference(id), d_sim(nullptr), d_idRev(false)
26
{
27
67057
}
28
29
19327
TrustNode InferInfo::processLemma(LemmaProperty& p)
30
{
31
19327
  return d_sim->processLemma(*this, p);
32
}
33
34
22286
Node InferInfo::processFact(std::vector<Node>& exp, ProofGenerator*& pg)
35
{
36
80302
  for (const Node& ec : d_premises)
37
  {
38
58016
    utils::flattenOp(kind::AND, ec, exp);
39
  }
40
22286
  d_sim->processFact(*this, pg);
41
22286
  return d_conc;
42
}
43
44
62276
bool InferInfo::isTrivial() const
45
{
46
62276
  Assert(!d_conc.isNull());
47
62276
  return d_conc.isConst() && d_conc.getConst<bool>();
48
}
49
50
62276
bool InferInfo::isConflict() const
51
{
52
62276
  Assert(!d_conc.isNull());
53
62276
  return d_conc.isConst() && !d_conc.getConst<bool>() && d_noExplain.empty();
54
}
55
56
25070
bool InferInfo::isFact() const
57
{
58
25070
  Assert(!d_conc.isNull());
59
50140
  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
50058
  return !atom.isConst() && atom.getKind() != kind::OR
64
73848
         && atom.getKind() != kind::AND && d_noExplain.empty();
65
}
66
67
44572
Node InferInfo::getPremises() const
68
{
69
  // d_noExplain is a subset of d_ant
70
44572
  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
29280
}  // namespace cvc5