GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/model.h Lines: 1 3 33.3 %
Date: 2021-08-01 Branches: 0 0 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Morgan Deters, Mathias Preiner
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
 * Model class.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__MODEL_H
19
#define CVC5__MODEL_H
20
21
#include <iosfwd>
22
#include <vector>
23
24
#include "expr/node.h"
25
26
namespace cvc5 {
27
28
class SmtEngine;
29
30
namespace theory {
31
class TheoryModel;
32
}
33
34
namespace smt {
35
36
class Model;
37
38
std::ostream& operator<<(std::ostream&, const Model&);
39
40
/**
41
 * This is the SMT-level model object, that is responsible for maintaining
42
 * the necessary information for how to print the model, as well as
43
 * holding a pointer to the underlying implementation of the theory model.
44
 *
45
 * The model declarations maintained by this class are context-independent
46
 * and should be updated when this model is printed.
47
 */
48
class Model {
49
  friend std::ostream& operator<<(std::ostream&, const Model&);
50
  friend class ::cvc5::SmtEngine;
51
52
 public:
53
  /** construct */
54
  Model(theory::TheoryModel* tm);
55
  /** virtual destructor */
56
9838
  ~Model() {}
57
  /** get the input name (file name, etc.) this model is associated to */
58
  std::string getInputName() const { return d_inputName; }
59
  /**
60
   * Returns true if this model is guaranteed to be a model of the input
61
   * formula. Notice that when cvc5 answers "unknown", it may have a model
62
   * available for which this method returns false. In this case, this model is
63
   * only a candidate solution.
64
   */
65
  bool isKnownSat() const { return d_isKnownSat; }
66
  /** Get the underlying theory model */
67
  theory::TheoryModel* getTheoryModel();
68
  /** Get the underlying theory model (const version) */
69
  const theory::TheoryModel* getTheoryModel() const;
70
  //----------------------- helper methods in the underlying theory model
71
  /** Is the node n a model core symbol? */
72
  bool isModelCoreSymbol(TNode sym) const;
73
  /** Get value */
74
  Node getValue(TNode n) const;
75
  /** Does this model have approximations? */
76
  bool hasApproximations() const;
77
  //----------------------- end helper methods
78
  //----------------------- model declarations
79
  /** Clear the current model declarations. */
80
  void clearModelDeclarations();
81
  /**
82
   * Set that tn is a sort that should be printed in the model, when applicable,
83
   * based on the output language.
84
   */
85
  void addDeclarationSort(TypeNode tn);
86
  /**
87
   * Set that n is a variable that should be printed in the model, when
88
   * applicable, based on the output language.
89
   */
90
  void addDeclarationTerm(Node n);
91
  /** get declared sorts */
92
  const std::vector<TypeNode>& getDeclaredSorts() const;
93
  /** get declared terms */
94
  const std::vector<Node>& getDeclaredTerms() const;
95
  //----------------------- end model declarations
96
 protected:
97
  /** the input name (file name, etc.) this model is associated to */
98
  std::string d_inputName;
99
  /**
100
   * Flag set to false if the model is associated with an "unknown" response
101
   * from the solver.
102
   */
103
  bool d_isKnownSat;
104
  /**
105
   * Pointer to the underlying theory model, which maintains all data regarding
106
   * the values of sorts and terms.
107
   */
108
  theory::TheoryModel* d_tmodel;
109
  /**
110
   * The list of types to print, generally corresponding to declare-sort
111
   * commands.
112
   */
113
  std::vector<TypeNode> d_declareSorts;
114
  /**
115
   * The list of terms to print, is typically one-to-one with declare-fun
116
   * commands.
117
   */
118
  std::vector<Node> d_declareTerms;
119
};
120
121
}  // namespace smt
122
}  // namespace cvc5
123
124
#endif /* CVC5__MODEL_H */