Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * This file is part of the cvc5 project. 3 : : * 4 : : * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS 5 : : * in the top-level source directory and their institutional affiliations. 6 : : * All rights reserved. See the file COPYING in the top-level source 7 : : * directory for licensing information. 8 : : * **************************************************************************** 9 : : * 10 : : * Encapsulation of the result of a query. 11 : : */ 12 : : 13 : : #include "cvc5_public.h" 14 : : 15 : : #ifndef CVC5__UTIL__RESULT_H 16 : : #define CVC5__UTIL__RESULT_H 17 : : 18 : : #include <cvc5/cvc5_types.h> 19 : : 20 : : #include <iosfwd> 21 : : #include <string> 22 : : 23 : : #include "options/language.h" 24 : : 25 : : namespace cvc5::internal { 26 : : 27 : : class Result; 28 : : 29 : : std::ostream& operator<<(std::ostream& out, const Result& r); 30 : : 31 : : /** 32 : : * Three-valued SMT result, with optional explanation. 33 : : */ 34 : : class Result 35 : : { 36 : : public: 37 : : enum Status 38 : : { 39 : : // the status has not been set 40 : : NONE, 41 : : // the status is "unsat" 42 : : UNSAT, 43 : : // the status is "sat" 44 : : SAT, 45 : : // the status is "unknown" 46 : : UNKNOWN 47 : : }; 48 : : 49 : : public: 50 : : Result(); 51 : : 52 : : Result(Status s, std::string inputName = ""); 53 : : 54 : : Result(Status s, 55 : : enum UnknownExplanation unknownExplanation, 56 : : std::string inputName = ""); 57 : : 58 : : Result(const std::string& s, std::string inputName = ""); 59 : : 60 : 49297 : Result(const Result& r, std::string inputName) 61 : 49297 : { 62 : 49297 : *this = r; 63 : 49297 : d_inputName = inputName; 64 : 49297 : } 65 : : 66 : 315636 : Status getStatus() const { return d_status; } 67 : : 68 : 14 : bool isNull() const { return d_status == NONE; } 69 : 33502 : bool isUnknown() const { return d_status == UNKNOWN; } 70 : : 71 : : UnknownExplanation getUnknownExplanation() const; 72 : : 73 : : /** 74 : : * Operator overloading for equality of two results. 75 : : * @param r The result to compare to for equality. 76 : : * @return True if the results are equal. 77 : : */ 78 : : bool operator==(const Result& r) const; 79 : : /** 80 : : * Operator overloading for disequality of two results. 81 : : * @param r The result to compare to for disequality. 82 : : * @return True if the results are disequal. 83 : : */ 84 : : bool operator!=(const Result& r) const; 85 : : 86 : : std::string toString() const; 87 : : 88 : : std::string getInputName() const { return d_inputName; } 89 : : 90 : : /** 91 : : * This is mostly the same the default 92 : : * If getType() == Result::TYPE_SAT && getStatus() == Result::UNKNOWN, 93 : : * 94 : : */ 95 : : void toStreamSmt2(std::ostream& out) const; 96 : : 97 : : /** 98 : : * Write a Result out to a stream. 99 : : * 100 : : * The default implementation writes a reasonable string in lowercase 101 : : * for sat, unsat, entailed, not entailed, or unknown results. This behavior 102 : : * is overridable by each Printer, since sometimes an output language 103 : : * has a particular preference for how results should appear. 104 : : */ 105 : : void toStreamDefault(std::ostream& out) const; 106 : : 107 : : private: 108 : : /** The result */ 109 : : Status d_status; 110 : : /** The unknown explanation */ 111 : : UnknownExplanation d_unknownExplanation; 112 : : /** The input name */ 113 : : std::string d_inputName; 114 : : }; /* class Result */ 115 : : 116 : : std::ostream& operator<<(std::ostream& out, enum Result::Status s); 117 : : 118 : : } // namespace cvc5::internal 119 : : 120 : : #endif /* CVC5__RESULT_H */