summaryrefslogtreecommitdiff
path: root/src/smt/model.cpp
blob: 5c427fa46aabf35e0aca2edc1992e809ceaf568c (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
83
84
85
86
87
88
89
90
91
92
/******************************************************************************
 * Top contributors (to current version):
 *   Andrew Reynolds, Morgan Deters, Tim King
 *
 * This file is part of the cvc5 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.
 * ****************************************************************************
 *
 * Implementation of Model class.
 */

#include "smt/model.h"

#include "options/base_options.h"
#include "options/io_utils.h"
#include "printer/printer.h"

namespace cvc5 {
namespace smt {

Model::Model(bool isKnownSat, const std::string& inputName)
    : d_inputName(inputName), d_isKnownSat(isKnownSat)
{
}

std::ostream& operator<<(std::ostream& out, const Model& m) {
  options::ioutils::Scope scope(out);
  options::ioutils::applyDagThresh(out, 0);
  Printer::getPrinter(options::outputLanguage())->toStream(out, m);
  return out;
}

const std::vector<Node>& Model::getDomainElements(TypeNode tn) const
{
  std::map<TypeNode, std::vector<Node>>::const_iterator it =
      d_domainElements.find(tn);
  Assert(it != d_domainElements.end());
  return it->second;
}

Node Model::getValue(TNode n) const
{
  std::map<Node, Node>::const_iterator it = d_declareTermValues.find(n);
  Assert(it != d_declareTermValues.end());
  return it->second;
}

bool Model::getHeapModel(Node& h, Node& nilEq) const
{
  if (d_sepHeap.isNull() || d_sepNilEq.isNull())
  {
    return false;
  }
  h = d_sepHeap;
  nilEq = d_sepNilEq;
  return true;
}

void Model::addDeclarationSort(TypeNode tn, const std::vector<Node>& elements)
{
  d_declareSorts.push_back(tn);
  d_domainElements[tn] = elements;
}

void Model::addDeclarationTerm(Node n, Node value)
{
  d_declareTerms.push_back(n);
  d_declareTermValues[n] = value;
}

void Model::setHeapModel(Node h, Node nilEq)
{
  d_sepHeap = h;
  d_sepNilEq = nilEq;
}

const std::vector<TypeNode>& Model::getDeclaredSorts() const
{
  return d_declareSorts;
}

const std::vector<Node>& Model::getDeclaredTerms() const
{
  return d_declareTerms;
}

}  // namespace smt
}  // namespace cvc5
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback