SMT-RAT
24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
ExpressionContent.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <cassert>
4
#include <vector>
5
6
#include <boost/functional/hash.hpp>
7
#include <boost/variant.hpp>
8
9
#include "../../Common.h"
10
#include "
ExpressionTypes.h
"
11
#include "
Expression.h
"
12
13
namespace
smtrat
{
14
namespace
expression {
15
16
struct
ITEExpression
{
17
ITEType
type
;
18
Expression
condition
;
19
Expression
thencase
;
20
Expression
elsecase
;
21
22
ITEExpression
(
ITEType
,
Expression
&& _condition,
Expression
&& _then,
Expression
&& _else):
23
condition
(std::move(_condition)),
thencase
(std::move(_then)),
elsecase
(std::move(_else))
24
{}
25
};
26
inline
std::ostream&
operator<<
(std::ostream& os,
const
ITEExpression
& expr) {
27
return
os <<
"("
<< expr.
type
<<
" "
<< expr.
condition
<<
" "
<< expr.
thencase
<<
" "
<< expr.
elsecase
<<
")"
;
28
}
29
30
struct
QuantifierExpression
{
31
QuantifierType
type
;
32
std::vector<carl::Variable>
variables
;
33
Expression
expression
;
34
35
QuantifierExpression
(
QuantifierType
_type, std::vector<carl::Variable>&& _variables,
Expression
&& _expression):
36
type
(_type),
variables
(std::move(_variables)),
expression
(std::move(_expression))
37
{}
38
};
39
inline
std::ostream&
operator<<
(std::ostream& os,
const
QuantifierExpression
& expr) {
40
return
os <<
"("
<< expr.
type
<<
" "
<< expr.
expression
<<
")"
;
41
}
42
43
struct
UnaryExpression
{
44
UnaryType
type
;
45
Expression
expression
;
46
47
UnaryExpression
(
UnaryType
_type,
Expression
&& _expression):
48
type
(_type),
expression
(std::move(_expression))
49
{}
50
};
51
inline
std::ostream&
operator<<
(std::ostream& os,
const
UnaryExpression
& expr) {
52
return
os <<
"("
<< expr.
type
<<
" "
<< expr.
expression
<<
")"
;
53
}
54
55
struct
BinaryExpression
{
56
BinaryType
type
;
57
Expression
lhs
;
58
Expression
rhs
;
59
60
BinaryExpression
(
BinaryType
_type,
Expression
&& _lhs,
Expression
&& _rhs):
61
type
(_type),
lhs
(std::move(_lhs)),
rhs
(std::move(_rhs))
62
{
63
//if (rhs < lhs) std::swap(lhs, rhs);
64
}
65
};
66
inline
std::ostream&
operator<<
(std::ostream& os,
const
BinaryExpression
& expr) {
67
return
os <<
"("
<< expr.
type
<<
" "
<< expr.
lhs
<<
" "
<< expr.
rhs
<<
")"
;
68
}
69
70
struct
NaryExpression
{
71
NaryType
type
;
72
Expressions
expressions
;
73
74
NaryExpression
(
NaryType
_type,
Expressions
&& _expressions):
75
type
(_type),
expressions
(std::move(_expressions))
76
{
77
normalize
();
78
}
79
NaryExpression
(
NaryType
_type,
const
std::initializer_list<Expression>& _expressions):
80
type
(_type),
expressions
(_expressions)
81
{
82
normalize
();
83
}
84
void
normalize
() {
85
if
(
type
==
AND
||
type
==
OR
||
type
==
XOR
||
type
==
IFF
) {
86
std::sort
(
expressions
.begin(),
expressions
.end());
87
}
88
}
89
};
90
inline
std::ostream&
operator<<
(std::ostream& os,
const
NaryExpression
& expr) {
91
os <<
"("
<< expr.
type
;
92
for
(
const
auto
& e: expr.
expressions
) os <<
" "
<< e;
93
return
os <<
")"
;
94
}
95
96
struct
ExpressionContent
{
97
typedef
boost::variant<
98
carl::Variable,
99
ITEExpression
,
100
QuantifierExpression
,
101
UnaryExpression
,
102
BinaryExpression
,
103
NaryExpression
104
>
Content
;
105
friend
struct
std::hash
<
Content
>;
106
107
Content
content
;
108
std::size_t
id
;
109
std::size_t
hash
;
110
const
ExpressionContent
*
negation
;
111
112
template
<
typename
... T>
113
ExpressionContent
(T&&... t):
content
(std::forward<T>(t)...),
id
(0),
hash
(0) {
114
updateHash
();
115
}
116
private
:
117
void
updateHash
();
118
};
119
inline
std::ostream&
operator<<
(std::ostream& os,
const
ExpressionContent
& expr) {
120
return
os << expr.
content
;
121
}
122
inline
std::ostream&
operator<<
(std::ostream& os,
const
ExpressionContent
* expr) {
123
return
os << expr->
content
;
124
}
125
126
template
<
typename
T>
127
struct
ExpressionTypeChecker
:
public
boost::static_visitor<bool> {
128
bool
operator()
(
const
T&)
const
{
129
return
true
;
130
}
131
template
<
typename
T2>
132
bool
operator()
(
const
T2&)
const
{
133
return
false
;
134
}
135
};
136
}
137
}
138
139
#include "
ExpressionHash.h
"
ExpressionHash.h
ExpressionTypes.h
Expression.h
smtrat::expression::Expression
Definition:
Expression.h:12
Minisat::sort
void sort(T *array, int size, LessThan lt)
Definition:
Sort.h:67
Minisat::hash
static uint32_t hash(uint32_t x)
Definition:
Map.h:32
smtrat::expression::BinaryType
BinaryType
Definition:
ExpressionTypes.h:27
smtrat::expression::operator<<
std::ostream & operator<<(std::ostream &os, const Expression &expr)
smtrat::expression::ITEType
ITEType
Definition:
ExpressionTypes.h:24
smtrat::expression::QuantifierType
QuantifierType
Definition:
ExpressionTypes.h:25
smtrat::expression::Expressions
std::vector< Expression > Expressions
Definition:
ExpressionTypes.h:21
smtrat::expression::NaryType
NaryType
Definition:
ExpressionTypes.h:28
smtrat::expression::OR
@ OR
Definition:
ExpressionTypes.h:28
smtrat::expression::AND
@ AND
Definition:
ExpressionTypes.h:28
smtrat::expression::XOR
@ XOR
Definition:
ExpressionTypes.h:28
smtrat::expression::IFF
@ IFF
Definition:
ExpressionTypes.h:28
smtrat::expression::UnaryType
UnaryType
Definition:
ExpressionTypes.h:26
smtrat
Class to create the formulas for axioms.
Definition:
handle_options.h:10
smtrat::expression::BinaryExpression
Definition:
ExpressionContent.h:55
smtrat::expression::BinaryExpression::lhs
Expression lhs
Definition:
ExpressionContent.h:57
smtrat::expression::BinaryExpression::BinaryExpression
BinaryExpression(BinaryType _type, Expression &&_lhs, Expression &&_rhs)
Definition:
ExpressionContent.h:60
smtrat::expression::BinaryExpression::rhs
Expression rhs
Definition:
ExpressionContent.h:58
smtrat::expression::BinaryExpression::type
BinaryType type
Definition:
ExpressionContent.h:56
smtrat::expression::ExpressionContent
Definition:
ExpressionContent.h:96
smtrat::expression::ExpressionContent::updateHash
void updateHash()
smtrat::expression::ExpressionContent::hash
std::size_t hash
Definition:
ExpressionContent.h:109
smtrat::expression::ExpressionContent::ExpressionContent
ExpressionContent(T &&... t)
Definition:
ExpressionContent.h:113
smtrat::expression::ExpressionContent::negation
const ExpressionContent * negation
Definition:
ExpressionContent.h:110
smtrat::expression::ExpressionContent::Content
boost::variant< carl::Variable, ITEExpression, QuantifierExpression, UnaryExpression, BinaryExpression, NaryExpression > Content
Definition:
ExpressionContent.h:104
smtrat::expression::ExpressionContent::id
std::size_t id
Definition:
ExpressionContent.h:108
smtrat::expression::ExpressionContent::content
Content content
Definition:
ExpressionContent.h:107
smtrat::expression::ExpressionTypeChecker
Definition:
ExpressionContent.h:127
smtrat::expression::ExpressionTypeChecker::operator()
bool operator()(const T &) const
Definition:
ExpressionContent.h:128
smtrat::expression::ExpressionTypeChecker::operator()
bool operator()(const T2 &) const
Definition:
ExpressionContent.h:132
smtrat::expression::ITEExpression
Definition:
ExpressionContent.h:16
smtrat::expression::ITEExpression::condition
Expression condition
Definition:
ExpressionContent.h:18
smtrat::expression::ITEExpression::type
ITEType type
Definition:
ExpressionContent.h:17
smtrat::expression::ITEExpression::thencase
Expression thencase
Definition:
ExpressionContent.h:19
smtrat::expression::ITEExpression::elsecase
Expression elsecase
Definition:
ExpressionContent.h:20
smtrat::expression::ITEExpression::ITEExpression
ITEExpression(ITEType, Expression &&_condition, Expression &&_then, Expression &&_else)
Definition:
ExpressionContent.h:22
smtrat::expression::NaryExpression
Definition:
ExpressionContent.h:70
smtrat::expression::NaryExpression::expressions
Expressions expressions
Definition:
ExpressionContent.h:72
smtrat::expression::NaryExpression::normalize
void normalize()
Definition:
ExpressionContent.h:84
smtrat::expression::NaryExpression::NaryExpression
NaryExpression(NaryType _type, Expressions &&_expressions)
Definition:
ExpressionContent.h:74
smtrat::expression::NaryExpression::type
NaryType type
Definition:
ExpressionContent.h:71
smtrat::expression::NaryExpression::NaryExpression
NaryExpression(NaryType _type, const std::initializer_list< Expression > &_expressions)
Definition:
ExpressionContent.h:79
smtrat::expression::QuantifierExpression
Definition:
ExpressionContent.h:30
smtrat::expression::QuantifierExpression::QuantifierExpression
QuantifierExpression(QuantifierType _type, std::vector< carl::Variable > &&_variables, Expression &&_expression)
Definition:
ExpressionContent.h:35
smtrat::expression::QuantifierExpression::variables
std::vector< carl::Variable > variables
Definition:
ExpressionContent.h:32
smtrat::expression::QuantifierExpression::expression
Expression expression
Definition:
ExpressionContent.h:33
smtrat::expression::QuantifierExpression::type
QuantifierType type
Definition:
ExpressionContent.h:31
smtrat::expression::UnaryExpression
Definition:
ExpressionContent.h:43
smtrat::expression::UnaryExpression::type
UnaryType type
Definition:
ExpressionContent.h:44
smtrat::expression::UnaryExpression::UnaryExpression
UnaryExpression(UnaryType _type, Expression &&_expression)
Definition:
ExpressionContent.h:47
smtrat::expression::UnaryExpression::expression
Expression expression
Definition:
ExpressionContent.h:45
smtrat-expressions
ExpressionContent.h
Generated by
1.9.1