GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/datatypes/inference.cpp Lines: 18 24 75.0 %
Date: 2021-09-18 Branches: 38 104 36.5 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Gereon Kremer, Aina Niemetz
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
 * Datatypes inference.
14
 */
15
16
#include "theory/datatypes/inference.h"
17
18
#include "expr/dtype.h"
19
#include "options/datatypes_options.h"
20
#include "theory/datatypes/inference_manager.h"
21
#include "theory/theory.h"
22
23
using namespace cvc5::kind;
24
25
namespace cvc5 {
26
namespace theory {
27
namespace datatypes {
28
29
360081
DatatypesInference::DatatypesInference(InferenceManager* im,
30
                                       Node conc,
31
                                       Node exp,
32
360081
                                       InferenceId i)
33
360081
    : SimpleTheoryInternalFact(i, conc, exp, nullptr), d_im(im)
34
{
35
  // false is not a valid explanation
36
360081
  Assert(d_exp.isNull() || !d_exp.isConst() || d_exp.getConst<bool>());
37
360081
}
38
39
329439
bool DatatypesInference::mustCommunicateFact(Node n, Node exp)
40
{
41
329439
  Trace("dt-lemma-debug") << "Compute for " << exp << " => " << n << std::endl;
42
  // Force lemmas if option is set
43
329439
  if (options::dtInferAsLemmas())
44
  {
45
    Trace("dt-lemma-debug")
46
        << "Communicate " << n << " due to option" << std::endl;
47
    return true;
48
  }
49
  // Note that equalities due to instantiate are forced as lemmas if
50
  // necessary as they are created. This ensures that terms are shared with
51
  // external theories when necessary. We send the lemma here only if the
52
  // conclusion has kind LEQ (for datatypes size) or OR. Notice that
53
  // all equalities are kept internal, apart from those forced as lemmas
54
  // via instantiate.
55
329439
  else if (n.getKind() == LEQ || n.getKind() == OR)
56
  {
57
    Trace("dt-lemma-debug")
58
        << "Communicate " << n << " due to kind" << std::endl;
59
    return true;
60
  }
61
329439
  Trace("dt-lemma-debug") << "Do not communicate " << n << std::endl;
62
329439
  return false;
63
}
64
65
18648
TrustNode DatatypesInference::processLemma(LemmaProperty& p)
66
{
67
  // we don't pass lemma property p currently, as it is always default
68
18648
  return d_im->processDtLemma(d_conc, d_exp, getId());
69
}
70
71
325586
Node DatatypesInference::processFact(std::vector<Node>& exp,
72
                                     ProofGenerator*& pg)
73
{
74
  // add to the explanation vector if applicable (when non-trivial)
75
325586
  if (!d_exp.isNull() && !d_exp.isConst())
76
  {
77
300400
    exp.push_back(d_exp);
78
  }
79
325586
  return d_im->processDtFact(d_conc, d_exp, getId(), pg);
80
}
81
82
}  // namespace datatypes
83
}  // namespace theory
84
29574
}  // namespace cvc5