10#include "dlinear/util/exception.h"
11#include "dlinear/util/logging.h"
26Term &Term::operator=(Formula &&f) {
27 term_.emplace<Formula>(f);
30Term &Term::operator=(Expression &&e) {
31 term_.emplace<Expression>(e);
35Term::Type
Term::type()
const {
return std::holds_alternative<Expression>(
term_) ? Type::EXPRESSION : Type::FORMULA; }
44 switch (v.get_type()) {
52 DLINEAR_UNREACHABLE();
55 case Type::EXPRESSION: {
56 switch (v.get_type()) {
64 DLINEAR_UNREACHABLE();
68 DLINEAR_UNREACHABLE();
74 case Term::Type::EXPRESSION:
77 case Term::Type::FORMULA:
81 DLINEAR_RUNTIME_ERROR_FMT(
"Term {} does not match against sort {}", *
this, s);
90 case Type::EXPRESSION:
94 DLINEAR_RUNTIME_ERROR_FMT(
"Term {} does not match against type {}", *
this, t);
98std::ostream &operator<<(std::ostream &os,
const Term &t) {
100 case Term::Type::EXPRESSION:
102 case Term::Type::FORMULA:
105 DLINEAR_UNREACHABLE();
Represents a symbolic form of an expression.
Expression Substitute(const Variable &var, const Expression &e) const
Returns a copy of this expression replacing all occurrences of var with e.
Represents a symbolic variable.
Type
Supported types of symbolic variables.
@ INTEGER
An INTEGER variable takes an int value.
@ BINARY
A BINARY variable takes an integer value from {0, 1}.
@ CONTINUOUS
A CONTINUOUS variable takes a mpq_class value.
@ BOOLEAN
A BOOLEAN variable takes a bool value.
Generic term that can be either an expression or a formula.
void Check(Sort s) const
Check if this term can be matched with s.
Expression & m_expression()
Get read-write access to the expression of the term.
Formula & m_formula()
Get read-write access to the formula of the term.
Type type() const
Get read-only access to the type of the term.
Term()
Construct a new term object.
Term Substitute(const Variable &v, const Term &t)
Create a new Term with substitutes the variable v in this term with t.
std::variant< Expression, Formula > term_
Expression or formula stored by the term.
const Formula & formula() const
Get read-only access to the formula of the term.
const Expression & expression() const
Get read-only access to the expression of the term.
Namespace for the SMT2 parser of the dlinear library.