GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/model.cpp Lines: 31 38 81.6 %
Date: 2021-09-15 Branches: 18 62 29.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Morgan Deters, Tim King
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 Model class.
14
 */
15
16
#include "smt/model.h"
17
18
#include "expr/expr_iomanip.h"
19
#include "options/base_options.h"
20
#include "printer/printer.h"
21
22
namespace cvc5 {
23
namespace smt {
24
25
29
Model::Model(bool isKnownSat, const std::string& inputName)
26
29
    : d_inputName(inputName), d_isKnownSat(isKnownSat)
27
{
28
29
}
29
30
29
std::ostream& operator<<(std::ostream& out, const Model& m) {
31
58
  expr::ExprDag::Scope scope(out, false);
32
29
  Printer::getPrinter(options::outputLanguage())->toStream(out, m);
33
58
  return out;
34
}
35
36
6
const std::vector<Node>& Model::getDomainElements(TypeNode tn) const
37
{
38
  std::map<TypeNode, std::vector<Node>>::const_iterator it =
39
6
      d_domainElements.find(tn);
40
6
  Assert(it != d_domainElements.end());
41
6
  return it->second;
42
}
43
44
34
Node Model::getValue(TNode n) const
45
{
46
34
  std::map<Node, Node>::const_iterator it = d_declareTermValues.find(n);
47
34
  Assert(it != d_declareTermValues.end());
48
34
  return it->second;
49
}
50
51
25
bool Model::getHeapModel(Node& h, Node& nilEq) const
52
{
53
25
  if (d_sepHeap.isNull() || d_sepNilEq.isNull())
54
  {
55
25
    return false;
56
  }
57
  h = d_sepHeap;
58
  nilEq = d_sepNilEq;
59
  return true;
60
}
61
62
6
void Model::addDeclarationSort(TypeNode tn, const std::vector<Node>& elements)
63
{
64
6
  d_declareSorts.push_back(tn);
65
6
  d_domainElements[tn] = elements;
66
6
}
67
68
34
void Model::addDeclarationTerm(Node n, Node value)
69
{
70
34
  d_declareTerms.push_back(n);
71
34
  d_declareTermValues[n] = value;
72
34
}
73
74
void Model::setHeapModel(Node h, Node nilEq)
75
{
76
  d_sepHeap = h;
77
  d_sepNilEq = nilEq;
78
}
79
80
29
const std::vector<TypeNode>& Model::getDeclaredSorts() const
81
{
82
29
  return d_declareSorts;
83
}
84
85
29
const std::vector<Node>& Model::getDeclaredTerms() const
86
{
87
29
  return d_declareTerms;
88
}
89
90
}  // namespace smt
91
29577
}  // namespace cvc5