11namespace expressions {
21 STORM_LOG_THROW(
false, storm::exceptions::InvalidTypeException,
"Predicate type not supported");
26 :
BaseExpression(manager, type), predicate(predicateType), operands(operands) {}
36 for (
auto const& operand : operands) {
37 if (operand->evaluateAsBool(valuation)) {
49 STORM_LOG_THROW(
false, storm::exceptions::InvalidTypeException,
"Predicate type not supported");
53 std::vector<std::shared_ptr<BaseExpression const>> simplifiedOperands;
54 uint64_t trueCount = 0;
55 for (
auto const& operand : operands) {
56 auto res = operand->simplify();
57 if (res->isLiteral()) {
64 simplifiedOperands.push_back(res);
67 assert(res->isFalse());
72 simplifiedOperands.push_back(res);
76 if (simplifiedOperands.size() == 0) {
87 if (simplifiedOperands.size() != operands.size()) {
90 for (uint64_t i = 0; i < simplifiedOperands.size(); ++i) {
91 if (operands[i] != simplifiedOperands[i]) {
96 return this->shared_from_this();
100 return visitor.
visit(*
this, data);
112 for (
auto const& operand : operands) {
113 if (operand->containsVariables()) {
121 return operands.size();
126 return operands[operandIndex];
130 for (
auto const& operand : operands) {
131 operand->gatherVariables(variables);
147 stream <<
"atMostOneOf(";
149 stream <<
"atLeastOneOf(";
151 stream <<
"exactlyOneOf(";
153 if (!operands.empty()) {
154 stream << *operands[0];
155 for (uint64_t i = 1; i < operands.size(); i++) {
156 stream <<
", " << *operands[i];
The base class of all expression classes.
bool hasBooleanType() const
Retrieves whether the expression has a boolean type.
ExpressionManager const & getManager() const
Retrieves the manager responsible for this expression.
Type const & getType() const
Retrieves the type of the expression.
This class is responsible for managing a set of typed variables and all expressions using these varia...
virtual boost::any visit(IfThenElseExpression const &expression, boost::any const &data)=0
The base class of all binary expressions.
virtual bool evaluateAsBool(Valuation const *valuation=nullptr) const override
Evaluates the expression under the valuation of unknowns (variables and constants) given by the valua...
PredicateExpression(ExpressionManager const &manager, Type const &type, std::vector< std::shared_ptr< BaseExpression const > > const &operands, PredicateType predicateType)
virtual std::shared_ptr< BaseExpression const > simplify() const override
Simplifies the expression according to some simple rules.
virtual boost::any accept(ExpressionVisitor &visitor, boost::any const &data) const override
Accepts the given visitor by calling its visit method.
virtual std::shared_ptr< BaseExpression const > getOperand(uint_fast64_t operandIndex) const override
Retrieves the given operand from the expression.
PredicateType getPredicateType() const
Retrieves the relation associated with the expression.
virtual uint_fast64_t getArity() const override
Returns the arity of the expression.
virtual void printToStream(std::ostream &stream) const override
Prints the expression to the given stream.
virtual void gatherVariables(std::set< storm::expressions::Variable > &variables) const override
Retrieves the set of all variables that appear in the expression.
virtual bool containsVariables() const override
Retrieves whether the expression contains a variable.
virtual bool isPredicateExpression() const override
virtual bool isFunctionApplication() const override
Checks if the expression is a function application (of any sort).
virtual storm::expressions::OperatorType getOperator() const override
Retrieves the operator of a function application.
The base class of all valuations of variables.
#define STORM_LOG_ASSERT(cond, message)
#define STORM_LOG_THROW(cond, exception, message)
OperatorType toOperatorType(PredicateExpression::PredicateType tp)