13#ifdef MCRL2_ENABLE_JITTYC
79 bool rewrite_stack_too_big_exception_thrown=
false;
86 variable_renaming[v]=v_fresh;
93 rewrite_stack_too_big_exception_thrown=
true;
98 it!=variable_renaming.
end(); ++it)
100 sigma[atermpp::down_cast<variable>(it->second)]=it->second;
102 if (rewrite_stack_too_big_exception_thrown)
113 const bool body_in_normal_form,
122 std::size_t number_of_renamed_variables=0;
124 std::vector<variable> new_variables(vl.
size());
130 if (
sigma(v)!=v ||
sigma.variable_occurs_in_a_rhs(v))
132 number_of_renamed_variables++;
138 new_variables[count]=v;
144 if (number_of_renamed_variables==0)
152 if (body_in_normal_form)
157 for(v = vl.
begin(), count = 0; v != vl.
end(); ++v, ++count)
159 if (*v != new_variables[count])
161 variable_renaming[*v] = new_variables[count];
170 std::vector<data_expression> saved_substitutions;
171 for(v = vl.
begin(), count = 0; v != vl.
end(); ++v, ++count)
173 if (*v != new_variables[count])
175 saved_substitutions.push_back(
sigma(*v));
176 sigma[*v] = new_variables[count];
180 bool rewrite_stack_too_big_exception_thrown=
false;
187 rewrite_stack_too_big_exception_thrown=
true;
190 std::size_t new_variable_count = 0;
191 for(v = vl.
begin(), count = 0; v != vl.
end(); ++v, ++count)
193 if (*v != new_variables[count])
195 sigma[*v] = saved_substitutions[new_variable_count++];
198 if (rewrite_stack_too_big_exception_thrown)
203 variable_list new_variable_list(new_variables.begin(), new_variables.end());
221 const abstraction& ta=atermpp::down_cast<abstraction>(t);
256 std::size_t arity=t.
size();
262 assert(vl.
size()<=arity);
270 for(std::size_t count=0; count<vl.
size(); count++)
280 sigma[v]=vl_backup[count];
281 vl_backup[count]=temp;
285 bool rewrite_stack_too_big_exception_thrown=
false;
292 rewrite_stack_too_big_exception_thrown=
true;
299 sigma[v]=vl_backup[count];
300 vl_backup[count].~data_expression();
303 if (rewrite_stack_too_big_exception_thrown)
308 if (vl.
size()==arity)
345 const bool t1_is_normal_form,
370 const bool t1_is_normal_form,
381 const bool t1_is_normal_form,
396 if (
sigma(v)!=v ||
sigma.variable_occurs_in_a_rhs(v))
399 variable_renaming[v]=v_fresh;
400 vl_new_v.push_back(v_fresh);
404 vl_new_v.push_back(v);
416 bool sorts_are_finite=
true;
417 for(variable_vector::const_reverse_iterator i=vl_new_v.rbegin(); i!=vl_new_v.rend(); ++i)
434 if (vl_new_l_enum.
empty())
436 if (vl_new_l_other.
empty())
455 std::numeric_limits<std::size_t>::max() :
465 std::size_t count=enumerator.enumerate(enumerator_element(vl_new_l_enum, t3),
467 [&](
const enumerator_element& p)
469 partial_result = lazy_op(partial_result, p.expression());
470 return partial_result==absorbing_element;
472 [&identity_element](
const data_expression& d)->
bool {
return d==identity_element; },
473 [&absorbing_element](
const data_expression& d)->
bool {
return d==absorbing_element; }
476 if (count<=max_count)
478 if (vl_new_l_other.
empty())
480 result=partial_result;
512 return std::shared_ptr<Rewriter>(
new RewriterJitty(data_spec,equations_selector));
513#ifdef MCRL2_ENABLE_JITTYC
514 case jitty_compiling:
515 return std::shared_ptr<Rewriter>(
new RewriterCompilingJitty(data_spec,equations_selector));
519#ifdef MCRL2_ENABLE_JITTYC
520 case jitty_compiling_prover:
521 return std::shared_ptr<Rewriter>(
new RewriterProver(data_spec,jitty_compiling,equations_selector));
532 const std::set <variable>& vars,
533 std::set <variable>& used_vars)
545 const application& a=atermpp::down_cast<application>(expr);
551 const variable& v=atermpp::down_cast<variable>(expr);
554 if (vars.count(v)==0)
577 if (
is_variable(atermpp::down_cast<application>(p).head()))
580 " is used as head symbol in an application, which is not supported");
582 const application& a=atermpp::down_cast<application>(p);
591 const std::set <variable> rule_vars(rule_var_list.
begin(),rule_var_list.
end());
594 std::set <variable> lhs_vars;
604 throw runtime_error(
"variable " +
pp(var) +
" occurs in left-hand side of equation but is not defined (in equation: " +
pp(data_eqn) +
")");
610 std::set <variable> dummy;
615 throw runtime_error(
"variable " +
pp(var) +
" occurs in condition of equation but not in left-hand side (in equation: " +
616 pp(data_eqn) +
"); equation cannot be used as rewrite rule");
622 std::set <variable> dummy;
627 throw runtime_error(
"variable " +
pp(var) +
" occurs in right-hand side of equation but not in left-hand side (in equation: " +
628 pp(data_eqn) +
"); equation cannot be used as rewrite rule");
634 throw runtime_error(
"left-hand side of equation is a variable; this is not allowed for rewriting");
642 throw runtime_error(std::string(s.what()) +
" (in equation: " +
pp(data_eqn) +
"); equation cannot be used as rewrite rule");
size_type size() const
Returns the size of the term_list.
const_iterator end() const
Returns a const_iterator pointing to the end of the term_list.
const_iterator begin() const
Returns a const_iterator pointing to the beginning of the term_list.
bool empty() const
Returns true if the list's size is 0.
void push_front(const Term &el)
Inserts a new element at the beginning of the current list.
An abstraction expression.
const variable_list & variables() const
const data_expression & body() const
An application of a data expression to a number of arguments.
const_iterator end() const
Returns an iterator pointing past the last argument of the application.
const_iterator begin() const
Returns an iterator pointing to the first argument of the application.
const data_expression & head() const
Get the function at the head of this expression.
\brief Assignment of a data expression to a variable
const data_expression & lhs() const
const data_expression & condition() const
const data_expression & rhs() const
const variable_list & variables() const
bool is_certainly_finite(const sort_expression &s) const
Checks whether a sort is certainly finite.
mcrl2::data::data_specification m_data_specification_for_enumeration
void rewrite_lambda_application(data_expression &result, const data_expression &t, substitution_type &sigma)
Rewrite t, assuming that the headsymbol of t, which can be nested, is a lambda term.
void rewrite_where(data_expression &result, const where_clause &term, substitution_type &sigma)
void existential_quantifier_enumeration(data_expression &result, const abstraction &t, substitution_type &sigma)
void universal_quantifier_enumeration(data_expression &result, const abstraction &t, substitution_type &sigma)
virtual data_expression rewrite(const data_expression &term, substitution_type &sigma)=0
Rewrite an mCRL2 data term.
void rewrite_single_lambda(data_expression &result, const variable_list &vl, const data_expression &body, const bool body_in_normal_form, substitution_type &sigma)
enumerator_identifier_generator m_generator
void quantifier_enumeration(data_expression &result, const variable_list &vl, const data_expression &t1, const bool t1_is_normal_form, substitution_type &sigma, const binder_type &binder, data_expression(*lazy_op)(const data_expression &, const data_expression &), const data_expression &identity_element, const data_expression &absorbing_element)
A strategy is a list of rules and the number of variables that occur in it.
An enumerator algorithm that generates solutions of a condition.
The default element for the todo list of the enumerator.
\brief Binder for existential quantification
\brief Binder for universal quantification
\brief Binder for lambda abstraction
Generic substitution function.
Generic substitution function. The substitution is stored as a mapping of variables to expressions....
const_iterator begin() const
Returns an iterator pointing to the beginning of the sequence of assignments TODO: should become prot...
const_iterator end() const
Returns an iterator pointing past the end of the sequence of assignments TODO: should become protecte...
Component for selecting a subset of equations that are actually used in an encompassing specification...
const sort_expression & sort() const
\brief A where expression
const assignment_list & assignments() const
const data_expression & body() const
Standard exception class for reporting runtime errors.
Stores a static variable that indicates the number of iterations allowed during enumeration.
static RewriterCompilingJitty::substitution_type & sigma(RewriterCompilingJitty *this_rewriter)
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
void CheckRewriteRule(const data_equation &data_eqn)
Check that an mCRL2 data equation is a valid rewrite rule. If not, an runtime_error is thrown indicat...
static void checkPattern(const data_expression &p)
bool isValidRewriteRule(const data_equation &data_eqn)
Check whether or not an mCRL2 data equation is a valid rewrite rule.
static bool occur_check(const variable &v, const atermpp::aterm &e)
bool is_enumerable(const data_specification &dataspec, const Rewriter &rewr, const sort_expression &sort, std::list< sort_expression > &parents)
static void check_vars(const data_expression &expr, const std::set< variable > &vars, std::set< variable > &used_vars)
std::string pp(const detail::lhs_t &lhs)
std::shared_ptr< detail::Rewriter > createRewriter(const data_specification &DataSpec, const used_data_equation_selector &equations_selector, const rewrite_strategy Strategy=jitty)
Create a rewriter.
std::size_t get_enumerator_iteration_limit()
data_expression and_(data_expression const &p, data_expression const &q)
Returns an expression equivalent to p or q.
data_expression or_(data_expression const &p, data_expression const &q)
Returns an expression equivalent to p and q.
const function_symbol & false_()
Constructor for function symbol false.
const function_symbol & true_()
Constructor for function symbol true.
variable_list free_variables(const data_expression &x)
std::vector< variable > variable_vector
\brief vector of variables
rewrite_strategy
The strategy of the rewriter.
std::string pp(const abstraction &x)
bool is_forall(const atermpp::aterm &x)
Returns true if the term t is a universal quantification.
std::set< data::variable > find_free_variables(const data::data_expression &x)
void make_abstraction(atermpp::aterm &result, ARGUMENTS... arguments)
bool is_exists(const atermpp::aterm &x)
Returns true if the term t is an existential quantification.
bool is_lambda(const atermpp::aterm &x)
Returns true if the term t is a lambda abstraction.
bool is_application(const atermpp::aterm &x)
Returns true if the term t is an application.
void replace_variables(T &x, const Substitution &sigma, typename std::enable_if<!std::is_base_of< atermpp::aterm, T >::value >::type *=nullptr)
bool is_variable(const atermpp::aterm &x)
Returns true if the term t is a variable.
void make_application(atermpp::aterm &result)
Make function for an application.
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
bool operator()(const atermpp::aterm &t) const
Rewriting combined with semantic simplification using a prover.