Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * Top contributors (to current version): 3 : : * Andrew Reynolds, Morgan Deters, Gereon Kremer 4 : : * 5 : : * This file is part of the cvc5 project. 6 : : * 7 : : * Copyright (c) 2009-2024 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 "options/base_options.h" 19 : : #include "options/io_utils.h" 20 : : #include "printer/printer.h" 21 : : 22 : : namespace cvc5::internal { 23 : : namespace smt { 24 : : 25 : 210 : Model::Model(bool isKnownSat, const std::string& inputName) 26 : 210 : : d_inputName(inputName), d_isKnownSat(isKnownSat) 27 : : { 28 : 210 : } 29 : : 30 : 210 : std::ostream& operator<<(std::ostream& out, const Model& m) { 31 : 210 : options::ioutils::Scope scope(out); 32 : 210 : options::ioutils::applyDagThresh(out, 0); 33 : 210 : Printer::getPrinter(out)->toStream(out, m); 34 : 420 : return out; 35 : : } 36 : : 37 : 171 : const std::vector<Node>& Model::getDomainElements(TypeNode tn) const 38 : : { 39 : : std::map<TypeNode, std::vector<Node>>::const_iterator it = 40 : 171 : d_domainElements.find(tn); 41 [ - + ][ - + ]: 171 : Assert(it != d_domainElements.end()); [ - - ] 42 : 171 : return it->second; 43 : : } 44 : : 45 : 389 : Node Model::getValue(TNode n) const 46 : : { 47 : 389 : std::map<Node, Node>::const_iterator it = d_declareTermValues.find(n); 48 [ - + ][ - + ]: 389 : Assert(it != d_declareTermValues.end()); [ - - ] 49 : 778 : return it->second; 50 : : } 51 : : 52 : 210 : bool Model::getHeapModel(Node& h, Node& nilEq) const 53 : : { 54 [ + + ][ - + ]: 210 : if (d_sepHeap.isNull() || d_sepNilEq.isNull()) [ + + ] 55 : : { 56 : 209 : return false; 57 : : } 58 : 1 : h = d_sepHeap; 59 : 1 : nilEq = d_sepNilEq; 60 : 1 : return true; 61 : : } 62 : : 63 : 171 : void Model::addDeclarationSort(TypeNode tn, const std::vector<Node>& elements) 64 : : { 65 : 171 : d_declareSorts.push_back(tn); 66 : 171 : d_domainElements[tn] = elements; 67 : 171 : } 68 : : 69 : 389 : void Model::addDeclarationTerm(Node n, Node value) 70 : : { 71 : 389 : d_declareTerms.push_back(n); 72 : 389 : d_declareTermValues[n] = value; 73 : 389 : } 74 : : 75 : 1 : void Model::setHeapModel(Node h, Node nilEq) 76 : : { 77 : 1 : d_sepHeap = h; 78 : 1 : d_sepNilEq = nilEq; 79 : 1 : } 80 : : 81 : 210 : const std::vector<TypeNode>& Model::getDeclaredSorts() const 82 : : { 83 : 210 : return d_declareSorts; 84 : : } 85 : : 86 : 210 : const std::vector<Node>& Model::getDeclaredTerms() const 87 : : { 88 : 210 : return d_declareTerms; 89 : : } 90 : : 91 : : } // namespace smt 92 : : } // namespace cvc5::internal