carl  24.04
Computer ARithmetic Library
SMTLIBStream.h
Go to the documentation of this file.
1 #pragma once
2 
14 #include <carl-formula/sort/Sort.h>
18 
19 #include <iostream>
20 #include <sstream>
21 #include <type_traits>
22 
23 namespace carl::io {
24 
25 /**
26  * Allows to print carl data structures in SMTLIB syntax.
27  */
28 class SMTLIBStream {
29 private:
30  std::stringstream mStream;
31 
32  void write(const mpz_class& n) { *this << carl::toString(n, false); }
33  void write(const mpq_class& n) { *this << carl::toString(n, false); }
34 #ifdef USE_CLN_NUMBERS
35  void write(const cln::cl_I& n) { *this << carl::toString(n, false); }
36  void write(const cln::cl_RA& n) { *this << carl::toString(n, false); }
37 #endif
38 
39  template<typename Pol>
40  void write(const Constraint<Pol>& c) {
41  if (c.relation() == Relation::NEQ) {
42  *this << "(not (= " << c.lhs() << " 0))";
43  } else {
44  *this << "(" << c.relation() << " " << c.lhs() << " 0)";
45  }
46  }
47 
48  template<typename Pol>
49  void write(const VariableComparison<Pol>& c) {
50  auto constraint = carl::as_constraint(c);
51  if (constraint) {
52  *this << *constraint;
53  } else {
54  auto iroot = [&]() {
55  if (std::holds_alternative<MultivariateRoot<Pol>>(c.value())) {
56  return std::get<MultivariateRoot<Pol>>(c.value());
57  } else {
58  return convert_to_mvroot<Pol>(std::get<typename MultivariateRoot<Pol>::RAN>(c.value()), c.var());
59  }
60  }();
61  *this << "(" << c.relation() << " " << (c.negated() ? "true" : "false") << " " << c.var() << " (root " << iroot.poly() << " " << iroot.k() << " " << iroot.var() << "))";
62  }
63  }
64 
65  template<typename Pol>
66  void write(const Formula<Pol>& f) {
67  switch (f.type()) {
68  case FormulaType::AND:
69  case FormulaType::OR:
70  case FormulaType::IFF:
71  case FormulaType::XOR:
73  case FormulaType::ITE:
74  // *this << "(" << f.type() << " " << stream_joined(" ", f.subformulas()) << ")";
75  *this << "(" << f.type();
76  for (const auto& f : f.subformulas()) {
77  *this << " " << f;
78  }
79  *this << ")";
80  break;
81  case FormulaType::NOT:
82  *this << "(" << f.type() << " " << f.subformula() << ")";
83  break;
84  case FormulaType::BOOL:
85  *this << f.boolean();
86  break;
88  *this << f.constraint();
89  break;
91  *this << f.variable_comparison();
92  break;
94  *this << f.variable_assignment();
95  break;
97  *this << f.bv_constraint();
98  break;
99  case FormulaType::TRUE:
100  case FormulaType::FALSE:
101  *this << f.type();
102  break;
103  case FormulaType::UEQ:
104  *this << f.u_equality();
105  break;
106  case FormulaType::EXISTS:
107  case FormulaType::FORALL:
108  CARL_LOG_ERROR("carl.smtlibstream", "Printing exists or forall is not implemented yet.");
109  break;
110  default:
111  CARL_LOG_ERROR("carl.smtlibstream", "Not supported formula type: " << f.type());
112  }
113  }
114 
115  template<typename Rational, typename Poly>
116  void write(const Model<Rational,Poly>& model) {
117  *this << "(model " << std::endl;
118  for (const auto& m: model) {
119  auto value = m.second;
120  value = model.evaluated(m.first);
121  *this << "\t(define-fun " << m.first << " () ";
122  if (m.first.is_variable()) {
123  *this << m.first.asVariable().type() << std::endl;
124  } else if (m.first.isBVVariable()) {
125  *this << m.first.asBVVariable().sort() << std::endl;
126  } else if (m.first.isUVariable()) {
127  *this << m.first.asUVariable().domain() << std::endl;
128  } else if (m.first.isFunction()) {
129  *this << value;
130  } else {
131  CARL_LOG_ERROR("carl.smtlibstream", "Encountered an unknown type of ModelVariable: " << m.first);
132  assert(false);
133  }
134  *this << "\t\t";
135  value.visit([this](const auto& v){ this->write(v); });
136  *this << std::endl << "\t)" << std::endl;
137  }
138  *this << ")" << std::endl;
139  }
140 
141  template<typename Rational>
143  if (ran.is_numeric()) {
144  *this << ran.value();
145  return;
146  }
147 
148  auto p = ran.polynomial();
149  auto denominator = p.coprime_factor();
150  if ((denominator < 0) == (p.lcoeff() > 0)) denominator *= -1;
151  p *= denominator;
152 
153  *this << "(root-of-with-interval ";
154  const auto& coeffs = p.coefficients();
155  auto it = coeffs.begin();
156  *this << "(coeffs " << *it;
157  it++;
158  for (; it != coeffs.end(); it++) {
159  assert(carl::is_integer(*it));
160  *this << " " << *it;
161  }
162  *this << ") ";
163  *this << ran.interval().lower() << " " << ran.interval().upper();
164  *this << ")";
165  }
166 
167  template<typename Rational, typename Poly>
169  if (mv.isBool()) {
170  *this << mv.asBool();
171  } else if (mv.isRational()) {
172  *this << mv.asRational();
173  } else if (mv.isRAN()) {
174  write(mv.asRAN());
175  }
176  }
177 
178  void write(const Monomial::Arg& m) {
179  if (m) *this << *m;
180  else *this << "1";
181  }
182  void write(const Monomial::Content::value_type& m) {
183  if (m.second == 0) *this << "1";
184  else if (m.second == 1) *this << m.first;
185  else {
186  *this << "(*";
187  for (std::size_t i = 0; i < m.second; ++i) *this << " " << m.first;
188  *this << ")";
189  }
190  }
191  void write(const Monomial& m) {
192  if (m.exponents().empty()) *this << "1";
193  else if (m.exponents().size() == 1) *this << m.exponents().front();
194  else {
195  // *this << "(* " << stream_joined(" ", m.exponents()) << ")";
196  *this << "(* ";
197  for (const auto& e : m.exponents()) {
198  *this << " " << e;
199  }
200  *this << ")";
201  }
202  }
203 
204  template<typename Coeff>
206  if (is_zero(mp)) *this << "0";
207  else if (mp.nr_terms() == 1) *this << mp.lterm();
208  else {
209  *this << "(+";
210  for (auto it = mp.rbegin(); it != mp.rend(); ++it) {
211  *this << " " << *it;
212  }
213  *this << ")";
214  }
215  }
216 
217  void write(Relation r) {
218  switch (r) {
219  case Relation::EQ: *this << "="; break;
220  case Relation::NEQ: *this << "<>"; break;
221  case Relation::LESS: *this << "<"; break;
222  case Relation::LEQ: *this << "<="; break;
223  case Relation::GREATER: *this << ">"; break;
224  case Relation::GEQ: *this << ">="; break;
225  }
226  }
227 
228  template<typename Coeff>
229  void write(const Term<Coeff>& t) {
230  if (!t.monomial()) *this << t.coeff();
231  else {
232  if (carl::is_one(t.coeff())) {
233  *this << t.monomial();
234  } else {
235  *this << "(* " << t.coeff() << " " << t.monomial() << ")";
236  }
237  }
238  }
239 
240  void write(const UEquality& ueq) {
241  if (ueq.negated()) {
242  *this << "(not (= " << ueq.lhs() << " " << ueq.rhs() << "))";
243  } else {
244  *this << "(= " << ueq.lhs() << " " << ueq.rhs() << ")";
245  }
246  }
247 
248  void write(const UFInstance& ufi) {
249  // *this << "(" << ufi.uninterpretedFunction().name() << " " << stream_joined(" ", ufi.args()) << ")";
250  *this << "(" << ufi.uninterpretedFunction().name();
251  for (const auto& a : ufi.args()) {
252  *this << " " << a;
253  }
254  *this << ")";
255  }
256 
257  template<typename Coeff>
259  if (up.is_constant()) *this << up.constant_part();
260  else {
261  *this << "(+";
262  for (std::size_t i = 0; i < up.coefficients().size(); ++i) {
263  std::size_t exp = up.coefficients().size() - i - 1;
264  const auto& coeff = up.coefficients()[exp];
265  if (exp == 0) *this << " " << coeff;
266  else *this << " (* " << coeff << " " << Monomial(up.main_var(), exp) << ")";
267  }
268  *this << ")";
269  }
270  }
271 
272  void write(const UTerm& t) {
274  [this](UVariable v) { *this << v; },
275  [this](UFInstance ufi) { *this << ufi; },
276  }, t.asVariant());
277  }
278 
279  void write(const Variable& v) {
280  *this << v.name();
281  }
282  void write(const VariableType& vt) {
283  switch (vt) {
284  case VariableType::VT_BOOL: *this << "Bool"; break;
285  case VariableType::VT_REAL: *this << "Real"; break;
286  case VariableType::VT_INT: *this << "Int"; break;
287  case VariableType::VT_UNINTERPRETED: *this << "?_Uninterpreted"; break;
288  case VariableType::VT_BITVECTOR: *this << "?_Bitvector"; break;
289  default: *this << "?"; break;
290  }
291  }
292 
293  void write(const bool b) {
294  if (b) *this << "true";
295  else *this << "false";
296  }
297 
298  template<typename T>
299  void write(T&& t) {
300  mStream << t;
301  }
302 
303 public:
304  /// Writes a comment
305  void comment(const std::string& c) {
306  *this << "; " << c << std::endl;
307  }
308  /// Declare a logic via `set-logic`.
309  void declare(Logic l) {
310  *this << "(set-logic " << l << ")" << std::endl;
311  }
312  /// Declare a sort via `declare-sort`.
313  void declare(Sort s) {
314  *this << "(declare-sort " << s << " " << s.arity() << ")" << std::endl;
315  }
316  /// Declare a fresh function via `declare-fun`.
318  // *this << "(declare-fun " << uf.name() << " (" << stream_joined(" ", uf.domain()) << ") ";
319  *this << "(declare-fun " << uf.name() << " (";
320  for (const auto& d : uf.domain()) {
321  *this << " " << d;
322  }
323  *this << ") ";
324  *this << uf.codomain() << ")" << std::endl;
325  }
326  /// Declare a fresh variable via `declare-fun`.
327  void declare(Variable v) {
328  *this << "(declare-fun " << v << " () " << v.type() << ")" << std::endl;
329  }
330  /// Declare a bitvector variable via `declare-fun`.
331  void declare(BVVariable v) {
332  *this << "(declare-fun " << v.variable() << " () " << v.variable().type() << ")" << std::endl;
333  }
334  /// Declare an uninterpreted variable via `declare-fun`.
335  void declare(UVariable v) {
336  *this << "(declare-fun " << v << " () " << v.domain() << ")" << std::endl;
337  }
338  /// Declare a set of functions.
339  void declare(const std::set<UninterpretedFunction>& ufs) {
340  for (const auto& uf: ufs) {
341  declare(uf);
342  }
343  }
344  /// Declare a set of variables.
345  void declare(const carlVariables& vars) {
346  for (const auto& v: vars) {
347  declare(v);
348  }
349  }
350  /// Declare a set of bitvector variables.
351  void declare(const std::set<BVVariable>& bvvs) {
352  for (const auto& bv: bvvs) {
353  declare(bv);
354  }
355  }
356  /// Declare a set of uninterpreted variables.
357  void declare(const std::set<UVariable>& uvs) {
358  for (const auto& uv: uvs) {
359  declare(uv);
360  }
361  }
362  /// Generic initializer including the logic, a set of variables and a set of functions.
363  void initialize(Logic l, const carlVariables& vars, const std::set<UninterpretedFunction>& ufs = {}, const std::set<BVVariable>& bvvs = {}, const std::set<UVariable>& uvs = {}) {
364  declare(l);
365  std::set<Sort> sorts;
366  for (const auto& v: bvvs) {
367  sorts.insert(v.sort());
368  }
369  for (const auto& v: uvs) {
370  sorts.insert(v.domain());
371  }
372  for (const auto& s: sorts) {
373  declare(s);
374  }
375  declare(ufs);
376  declare(vars.filter(carl::variable_type_filter::excluding({VariableType::VT_BITVECTOR, VariableType::VT_UNINTERPRETED})));
377  declare(bvvs);
378  declare(uvs);
379  }
380 
381  /// Generic initializer including the logic and variables and functions from a set of formulas.
382  template<typename Pol>
383  void initialize(Logic l, std::initializer_list<Formula<Pol>> formulas) {
384  carlVariables vars;
385  std::set<UninterpretedFunction> ufs;
386  std::set<BVVariable> bvvs;
387  std::set<UVariable> uvs;
388  for (const auto& f: formulas) {
389  carl::variables(f,vars);
393  }
394  initialize(l, vars, ufs, bvvs, uvs);
395  }
396 
397  /// Set information via `set-info`.
398  void setInfo(const std::string& name, const std::string& value) {
399  *this << "(set-info :" << name << " " << value << ")" << std::endl;
400  }
401 
402  /// Set option via `set-option`.
403  void setOption(const std::string& name, const std::string& value) {
404  *this << "(set-option :" << name << " " << value << ")" << std::endl;
405  }
406 
407  /// Assert a formula via `assert`.
408  template<typename Pol>
409  void assertFormula(const Formula<Pol>& formula) {
410  *this << "(assert " << formula << ")" << std::endl;
411  }
412 
413  /// Minimize an objective via custom `minimize`.
414  template<typename Pol>
415  void minimize(const Pol& objective) {
416  *this << "(minimize " << objective << ")" << std::endl;
417  }
418 
419  /// Check satisfiability via `check-sat`.
420  void checkSat() {
421  *this << "(check-sat)" << std::endl;
422  }
423 
424  /// Print assertions via `get-assertions`.
425  void getAssertions() {
426  *this << "(get-assertions)" << std::endl;
427  }
428 
429  /// Print model via `get-model`.
430  void getModel() {
431  *this << "(get-model)" << std::endl;
432  }
433 
434  /// Echo via `echo`.
435  void echo(const std::string& str) {
436  *this << "(echo \"" << str << "\")" << std::endl;
437  }
438 
439  /// Reset via `reset`.
440  void reset() {
441  *this << "(reset)" << std::endl;
442  }
443 
444  /// Exit via `exit`.
445  void exit() {
446  *this << "(exit)" << std::endl;
447  }
448 
449  /// Write some data to this stream.
450  template<typename T>
452  write(static_cast<const std::decay_t<T>&>(t));
453  return *this;
454  }
455 
456  /// Write io operators (like `std::endl`) directly to the underlying stream.
457  SMTLIBStream& operator<<(std::ostream& (*os)(std::ostream&)) {
458  write(os);
459  return *this;
460  }
461 
462  /// Return the written data as a string.
463  auto str() const {
464  return mStream.str();
465  }
466 
467  /// Return the underlying stream buffer.
468  auto content() const {
469  return mStream.rdbuf();
470  }
471 };
472 
473 /// Write the written data to some `std::ostream`.
474 inline std::ostream& operator<<(std::ostream& os, const SMTLIBStream& ss) {
475  return os << ss.content();
476 }
477 
478 namespace detail {
479 
480 /// Shorthand to allow writing SMTLIB scripts in one line.
481 template<typename Pol>
484  std::initializer_list<Formula<Pol>> mFormulas;
485  bool mGetModel;
487  SMTLIBScriptContainer(Logic l, std::initializer_list<Formula<Pol>> f, bool getModel = false): mLogic(l), mFormulas(f), mGetModel(getModel) {}
488  SMTLIBScriptContainer(Logic l, std::initializer_list<Formula<Pol>> f, const Pol& objective, bool getModel = false): mLogic(l), mFormulas(f), mGetModel(getModel), mObjective(objective) {}
489 };
490 /// Actually write an SMTLIBScriptContainer to an std::ostream.
491 template<typename Pol>
492 std::ostream& operator<<(std::ostream& os, const SMTLIBScriptContainer<Pol>& sc) {
493  SMTLIBStream sls;
494  sls.initialize(sc.mLogic, sc.mFormulas);
495  for (const auto& f: sc.mFormulas) sls.assertFormula(f);
496  if (!is_zero(sc.mObjective)) sls.minimize(sc.mObjective);
497  sls.checkSat();
498  if (sc.mGetModel) sls.getModel();
499  return os << sls;
500 }
501 
502 }
503 
504 /// Shorthand to allow writing SMTLIB scripts in one line.
505 template<typename Pol, typename... Args>
506 detail::SMTLIBScriptContainer<Pol> outputSMTLIB(Logic l, std::initializer_list<Formula<Pol>> formulas, Args&&... args) {
507  return detail::SMTLIBScriptContainer<Pol>(l, formulas, std::forward<Args>(args)...);
508 }
509 
510 namespace detail {
511  template<typename... Args>
513  std::tuple<Args...> mData;
514  explicit SMTLIBOutputContainer(Args&&... args): mData(std::forward<Args>(args)...) {}
515  };
516  template<typename... Args>
517  std::ostream& operator<<(std::ostream& os, const SMTLIBOutputContainer<Args...>& soc) {
518  SMTLIBStream sls;
519  carl::tuple_accumulate(soc.mData, sls, [](auto& sls, const auto& t) -> auto& { return sls << t; });
520  return os << sls;
521  }
522 }
523 
524 /// Generic shorthand to write arbitrary data to an SMTLIBStream and return the result.
525 template<typename... Args>
526 detail::SMTLIBOutputContainer<Args...> asSMTLIB(Args&&... args) {
527  return detail::SMTLIBOutputContainer<Args...>(std::forward<Args>(args)...);
528 }
529 
530 }
#define CARL_LOG_ERROR(channel, msg)
Definition: carl-logging.h:40
MultivariatePolynomial< Rational > Pol
Definition: HornerTest.cpp:17
@ CONSTRAINT
@ BITVECTOR
@ VARCOMPARE
@ VARASSIGN
std::string toString(Relation r)
Definition: Relation.h:73
carlVariables uninterpreted_variables(const T &t)
Definition: Variables.h:261
T tuple_accumulate(Tuple &&t, T &&init, F &&f)
Implements a functional fold (similar to std::accumulate) for std::tuple.
Definition: tuple_util.h:139
std::optional< BasicConstraint< Poly > > as_constraint(const VariableComparison< Poly > &f)
Convert this variable comparison "v < root(..)" into a simpler polynomial (in)equality against zero "...
Interval< Number > exp(const Interval< Number > &i)
Definition: Exponential.h:10
void uninterpreted_functions(const Formula< Pol > &f, std::set< UninterpretedFunction > &ufs)
Definition: Variables.h:42
carlVariables bitvector_variables(const T &t)
Definition: Variables.h:254
bool is_zero(const Interval< Number > &i)
Check if this interval is a point-interval containing 0.
Definition: Interval.h:1453
VariableType
Several types of variables are supported.
Definition: Variable.h:28
void visit(const Formula< Pol > &formula, Visitor func)
Recursively calls func on every subformula.
Definition: Visit.h:12
Logic
Definition: Logic.h:7
bool is_integer(const Interval< Number > &n)
Definition: Interval.h:1445
@ GREATER
Definition: SignCondition.h:15
Relation
Definition: Relation.h:20
void variables(const BasicConstraint< Pol > &c, carlVariables &vars)
bool is_one(const Interval< Number > &i)
Check if this interval is a point-interval containing 1.
Definition: Interval.h:1462
detail::SMTLIBOutputContainer< Args... > asSMTLIB(Args &&... args)
Generic shorthand to write arbitrary data to an SMTLIBStream and return the result.
Definition: SMTLIBStream.h:526
std::ostream & operator<<(std::ostream &os, const MapleStream &ms)
Definition: MapleStream.h:197
detail::SMTLIBScriptContainer< Pol > outputSMTLIB(Logic l, std::initializer_list< Formula< Pol >> formulas, Args &&... args)
Shorthand to allow writing SMTLIB scripts in one line.
Definition: SMTLIBStream.h:506
std::ostream & operator<<(std::ostream &os, const SMTLIBScriptContainer< Pol > &sc)
Actually write an SMTLIBScriptContainer to an std::ostream.
Definition: SMTLIBStream.h:492
auto & get(const std::string &name)
A Variable represents an algebraic variable that can be used throughout carl.
Definition: Variable.h:85
std::string name() const
Retrieves the name of the variable.
Definition: Variable.cpp:8
constexpr VariableType type() const noexcept
Retrieves the type of the variable.
Definition: Variable.h:131
static variable_type_filter excluding(std::initializer_list< VariableType > i)
Definition: Variables.h:24
carlVariables filter(variable_type_filter &&f) const
Definition: Variables.h:178
typename Poly::RootType RAN
Represent a sum type/variant of an (in)equality between a variable on the left-hand side and multivar...
const std::variant< MR, RAN > & value() const
This class represents a univariate polynomial with coefficients of an arbitrary type.
bool is_constant() const
Checks whether the polynomial is constant with respect to the main variable.
const std::vector< Coefficient > & coefficients() const &
Retrieves the coefficients defining this polynomial.
Variable main_var() const
Retrieves the main variable of this polynomial.
NumberType constant_part() const
Returns the constant part of this polynomial.
The general-purpose multivariate polynomial class.
const Term< Coeff > & lterm() const
The leading term.
std::size_t nr_terms() const
Calculate the number of terms.
The general-purpose monomials.
Definition: Monomial.h:59
std::shared_ptr< const Monomial > Arg
Definition: Monomial.h:62
const Content & exponents() const
Definition: Monomial.h:189
Coefficient & coeff()
Get the coefficient.
Definition: Term.h:80
Monomial::Arg & monomial()
Get the monomial.
Definition: Term.h:91
const auto & value() const
Definition: Ran.h:227
const auto & interval() const
Definition: Ran.h:222
const auto & polynomial() const
Definition: Ran.h:218
bool is_numeric() const
Definition: Ran.h:214
Represent a polynomial (in)equality against zero.
Definition: Constraint.h:62
Relation relation() const
Definition: Constraint.h:116
const Pol & lhs() const
Definition: Constraint.h:109
Represent a BitVector-Variable.
Definition: BVVariable.h:13
Variable variable() const
Definition: BVVariable.h:34
Represent an SMT formula, which can be an atom for some background theory or a boolean combination of...
Definition: Formula.h:47
const VariableAssignment< Pol > & variable_assignment() const
Definition: Formula.h:421
const Formula & subformula() const
Definition: Formula.h:327
const VariableComparison< Pol > & variable_comparison() const
Definition: Formula.h:416
carl::Variable::Arg boolean() const
Definition: Formula.h:436
const Constraint< Pol > & constraint() const
Definition: Formula.h:410
const Formulas< Pol > & subformulas() const
Definition: Formula.h:400
const BVConstraint & bv_constraint() const
Definition: Formula.h:426
const UEquality & u_equality() const
Definition: Formula.h:446
FormulaType type() const
Definition: Formula.h:254
Represent a collection of assignments/mappings from variables to values.
Definition: Model.h:19
const ModelValue< Rational, Poly > & evaluated(const typename Map::key_type &key) const
Return the ModelValue for the given key, evaluated if it's a ModelSubstitution and evaluatable,...
Definition: Model.h:146
Represent a sum type/variant over the different kinds of values that can be assigned to the different...
Definition: ModelValue.h:56
const Poly::RootType & asRAN() const
Definition: ModelValue.h:233
bool isBool() const
Definition: ModelValue.h:143
const Rational & asRational() const
Definition: ModelValue.h:217
bool isRational() const
Definition: ModelValue.h:150
bool asBool() const
Definition: ModelValue.h:209
bool isRAN() const
Definition: ModelValue.h:164
Implements a sort (for defining types of variables and functions).
Definition: Sort.h:20
std::size_t arity() const
Definition: Sort.cpp:14
Implements an uninterpreted equality, that is an equality of either two uninterpreted function instan...
Definition: UEquality.h:23
const UTerm & rhs() const
Definition: UEquality.h:79
bool negated() const
Definition: UEquality.h:65
const UTerm & lhs() const
Definition: UEquality.h:72
Implements an uninterpreted function instance.
Definition: UFInstance.h:25
const UninterpretedFunction & uninterpretedFunction() const
Definition: UFInstance.cpp:21
const std::vector< UTerm > & args() const
Definition: UFInstance.cpp:25
Implements an uninterpreted function.
const std::string & name() const
const std::vector< Sort > & domain() const
Implements an uninterpreted term, that is either an uninterpreted variable or an uninterpreted functi...
Definition: UTerm.h:22
const auto & asVariant() const
Definition: UTerm.h:41
Implements an uninterpreted variable.
Definition: UVariable.h:19
Sort domain() const
Definition: UVariable.h:61
Allows to print carl data structures in SMTLIB syntax.
Definition: SMTLIBStream.h:28
void declare(const std::set< UVariable > &uvs)
Declare a set of uninterpreted variables.
Definition: SMTLIBStream.h:357
void write(const Constraint< Pol > &c)
Definition: SMTLIBStream.h:40
void exit()
Exit via exit.
Definition: SMTLIBStream.h:445
std::stringstream mStream
Definition: SMTLIBStream.h:30
void comment(const std::string &c)
Writes a comment.
Definition: SMTLIBStream.h:305
void declare(UVariable v)
Declare an uninterpreted variable via declare-fun.
Definition: SMTLIBStream.h:335
void declare(const carlVariables &vars)
Declare a set of variables.
Definition: SMTLIBStream.h:345
void reset()
Reset via reset.
Definition: SMTLIBStream.h:440
void write(const UnivariatePolynomial< Coeff > &up)
Definition: SMTLIBStream.h:258
void assertFormula(const Formula< Pol > &formula)
Assert a formula via assert.
Definition: SMTLIBStream.h:409
void write(const ModelValue< Rational, Poly > &mv)
Definition: SMTLIBStream.h:168
void initialize(Logic l, std::initializer_list< Formula< Pol >> formulas)
Generic initializer including the logic and variables and functions from a set of formulas.
Definition: SMTLIBStream.h:383
auto content() const
Return the underlying stream buffer.
Definition: SMTLIBStream.h:468
void declare(Variable v)
Declare a fresh variable via declare-fun.
Definition: SMTLIBStream.h:327
void write(const UEquality &ueq)
Definition: SMTLIBStream.h:240
void write(const VariableComparison< Pol > &c)
Definition: SMTLIBStream.h:49
void declare(const std::set< UninterpretedFunction > &ufs)
Declare a set of functions.
Definition: SMTLIBStream.h:339
void write(const Monomial::Content::value_type &m)
Definition: SMTLIBStream.h:182
void write(const UTerm &t)
Definition: SMTLIBStream.h:272
void declare(BVVariable v)
Declare a bitvector variable via declare-fun.
Definition: SMTLIBStream.h:331
void write(const Model< Rational, Poly > &model)
Definition: SMTLIBStream.h:116
SMTLIBStream & operator<<(T &&t)
Write some data to this stream.
Definition: SMTLIBStream.h:451
void checkSat()
Check satisfiability via check-sat.
Definition: SMTLIBStream.h:420
SMTLIBStream & operator<<(std::ostream &(*os)(std::ostream &))
Write io operators (like std::endl) directly to the underlying stream.
Definition: SMTLIBStream.h:457
void echo(const std::string &str)
Echo via echo.
Definition: SMTLIBStream.h:435
void write(const Variable &v)
Definition: SMTLIBStream.h:279
void declare(Sort s)
Declare a sort via declare-sort.
Definition: SMTLIBStream.h:313
void write(const MultivariatePolynomial< Coeff > &mp)
Definition: SMTLIBStream.h:205
void write(const Formula< Pol > &f)
Definition: SMTLIBStream.h:66
void write(const UFInstance &ufi)
Definition: SMTLIBStream.h:248
void getModel()
Print model via get-model.
Definition: SMTLIBStream.h:430
void write(Relation r)
Definition: SMTLIBStream.h:217
void getAssertions()
Print assertions via get-assertions.
Definition: SMTLIBStream.h:425
void write(const mpz_class &n)
Definition: SMTLIBStream.h:32
void setInfo(const std::string &name, const std::string &value)
Set information via set-info.
Definition: SMTLIBStream.h:398
void minimize(const Pol &objective)
Minimize an objective via custom minimize.
Definition: SMTLIBStream.h:415
void write(const mpq_class &n)
Definition: SMTLIBStream.h:33
void write(const IntRepRealAlgebraicNumber< Rational > &ran)
Definition: SMTLIBStream.h:142
void declare(UninterpretedFunction uf)
Declare a fresh function via declare-fun.
Definition: SMTLIBStream.h:317
void write(const Monomial::Arg &m)
Definition: SMTLIBStream.h:178
auto str() const
Return the written data as a string.
Definition: SMTLIBStream.h:463
void write(const Monomial &m)
Definition: SMTLIBStream.h:191
void write(const Term< Coeff > &t)
Definition: SMTLIBStream.h:229
void initialize(Logic l, const carlVariables &vars, const std::set< UninterpretedFunction > &ufs={}, const std::set< BVVariable > &bvvs={}, const std::set< UVariable > &uvs={})
Generic initializer including the logic, a set of variables and a set of functions.
Definition: SMTLIBStream.h:363
void setOption(const std::string &name, const std::string &value)
Set option via set-option.
Definition: SMTLIBStream.h:403
void declare(Logic l)
Declare a logic via set-logic.
Definition: SMTLIBStream.h:309
void declare(const std::set< BVVariable > &bvvs)
Declare a set of bitvector variables.
Definition: SMTLIBStream.h:351
void write(const VariableType &vt)
Definition: SMTLIBStream.h:282
void write(const bool b)
Definition: SMTLIBStream.h:293
Shorthand to allow writing SMTLIB scripts in one line.
Definition: SMTLIBStream.h:482
SMTLIBScriptContainer(Logic l, std::initializer_list< Formula< Pol >> f, const Pol &objective, bool getModel=false)
Definition: SMTLIBStream.h:488
std::initializer_list< Formula< Pol > > mFormulas
Definition: SMTLIBStream.h:484
SMTLIBScriptContainer(Logic l, std::initializer_list< Formula< Pol >> f, bool getModel=false)
Definition: SMTLIBStream.h:487