dlinear  0.0.1
Delta-complete SMT solver for linear programming
Loading...
Searching...
No Matches
Term.h
1
14#pragma once
15
16#include <iosfwd>
17#include <variant>
18
19#include "dlinear/parser/vnnlib/Sort.h"
20#include "dlinear/symbolic/literal.h"
21#include "dlinear/symbolic/symbolic.h"
22
23namespace dlinear::vnnlib {
24
34class Term {
35 public:
36 enum class Type { EXPRESSION, FORMULA };
37
39 Term();
40 ~Term() = default;
45 explicit Term(Expression e);
50 explicit Term(Formula f);
51 Term(const Term &) = default;
52 Term(Term &&) = default;
53 Term &operator=(const Term &) = default;
54 Term &operator=(const Formula &);
55 Term &operator=(const Expression &);
56 Term &operator=(Term &&) = default;
57 Term &operator=(Formula &&);
58 Term &operator=(Expression &&);
59
61 [[nodiscard]] Type type() const;
63 [[nodiscard]] const Expression &expression() const;
67 [[nodiscard]] const Formula &formula() const;
70
77 Term Substitute(const Variable &v, const Term &t);
78
84 void Check(Sort s) const;
85
91 void Check(Variable::Type t) const;
92
93 private:
94 std::variant<Expression, Formula> term_;
95};
96
97std::ostream &operator<<(std::ostream &os, const Term &t);
98
99} // namespace dlinear::vnnlib
100
101#ifdef DLINEAR_INCLUDE_FMT
102
103#include "dlinear/util/logging.h"
104
105OSTREAM_FORMATTER(dlinear::vnnlib::Term)
106
107#endif
Represents a symbolic form of an expression.
Represents a symbolic form of a first-order logic formula.
Represents a symbolic variable.
Type
Supported types of symbolic variables.
Generic term that can be either an expression or a formula.
Definition Term.h:34
std::variant< Expression, Formula > term_
Expression or formula stored by the term.
Definition Term.h:94
Expression & m_expression()
Get read-write access to the expression of the term.
Definition Term.cpp:37
const Formula & formula() const
Get read-only access to the formula of the term.
Definition Term.cpp:38
Term()
Construct a new term object.
Definition Term.cpp:15
Formula & m_formula()
Get read-write access to the formula of the term.
Definition Term.cpp:39
Type type() const
Get read-only access to the type of the term.
Definition Term.cpp:35
void Check(Sort s) const
Check if this term can be matched with s.
Definition Term.cpp:72
Term Substitute(const Variable &v, const Term &t)
Create a new Term with substitutes the variable v in this term with t.
Definition Term.cpp:41
const Expression & expression() const
Get read-only access to the expression of the term.
Definition Term.cpp:36
Namespace for the VNNLIB parser of the dlinear library.
Definition Driver.cpp:17
Sort
Sort of a term.
Definition Sort.h:18