39 std::map< data::sort_expression, unfold_cache_element >::iterator ce =
m_cache.find(sort);
64 return new_cache_element;
77 std::string hint(
"S");
80 hint = atermpp::down_cast<basic_sort>(sort).name();
96 mCRL2log(
debug) <<
"Generated a fresh function symbol name: " << result << std::endl;
131 std::string prefix =
"c_";
132 prefix.append(
func.name());
149 std::string str =
"C_";
156 std::map<mcrl2::data::sort_expression, mcrl2::data::function_symbol>::const_iterator
157 case_function_it = new_cache_element.
case_functions.find(output_sort);
177 return case_function_it->second;
184 std::string str =
"Det_";
199 std::string str =
"pi_";
206 const function_sort fs = atermpp::down_cast<function_sort>(f.sort());
237 const variable_list f_arguments_list(f_arguments.begin(), f_arguments.end());
239 for(
const variable& arg: f_arguments)
253 const variable_list g_arguments_list(g_arguments.begin(), g_arguments.end());
255 if (g_arguments.empty())
272 <<
"= ... as no default term of sort "
299 assert(case_function.
sort().
target_sort() == atermpp::down_cast<function_sort>(f.
sort()).domain().front());
307 variable_vector::const_iterator args = lhs_args.begin();
308 for (variable_vector::const_iterator i = lhs_args.begin(); i != lhs_args.end(); ++i)
310 if(i == lhs_args.begin())
312 rhs_args.push_back(*args);
343 assert(atermpp::down_cast<function_sort>(case_function.
sort()).domain().size() == new_cache_element.
new_constructors.size() + 1);
353 variable_vector::const_iterator vars_it = vars.begin();
358 sub_args[0] = new_constructor;
368 eq_args[0] = vars.front();
379 cs_args.push_back(cs);
393 vars_it = vars.begin();
394 const variable det_var = *vars_it++;
397 if(vars_it == vars.end())
426 function_symbol_vector::const_iterator constructor_it = new_cache_element.
new_constructors.begin();
432 if(function_arguments.empty())
440 const variable_list args(function_arguments.begin(), function_arguments.end());
463 std::map< data::sort_expression , unfold_cache_element >& cache,
464 bool alt_case_placement,
465 bool possibly_inconsistent,
469 m_datamgr(cache, spec.data(), possibly_inconsistent),
470 m_pattern_unfolder(m_datamgr),
471 m_alt_case_placement(alt_case_placement),
497 new_assignments.insert(new_assignments.end(), injected_assignments.begin(), injected_assignments.end());
501 new_assignments.push_back(k);
527 if (new_pars_it->sort() != arg_sort)
529 throw runtime_error(
"Unexpected new parameter encountered, maybe they were not sorted well.");
531 arg.push_back(*new_pars_it++);
536 dev.push_back(case_func_arg);
550 process_parameters.
begin();
551 std::advance(unfold_parameter_it, parameter_at_index);
559 mCRL2log(
log::verbose) <<
" Unfolding parameter " << unfold_parameter_it->name() <<
" at index " << parameter_at_index <<
"..." << std::endl;
562 new_process_parameters.insert(new_process_parameters.end(),
563 process_parameters.
begin(),
564 unfold_parameter_it);
584 <<
"::" <<
pp(s) << std::endl;
591 mCRL2log(
debug) <<
"- No process parameters are injected for constant: "
592 << constructor << std::endl;
600 new_process_parameters.insert(new_process_parameters.end(),
605 ++unfold_parameter_it;
607 new_process_parameters.insert(new_process_parameters.end(),
608 unfold_parameter_it, process_parameters.
end());
610 mCRL2log(
debug) <<
"- New LPS process parameters: " <<
data::pp(new_process_parameters) << std::endl;
639 mCRL2log(
log::verbose) <<
"- Inserting case functions into the process using alternative case placement" << std::endl;
645 mCRL2log(
log::verbose) <<
"- Inserting case functions into the process using default case placement" << std::endl;
677 std::size_t parameter_at_index)
689 if (index == parameter_at_index)
693 new_init.insert(new_init.end(), ins.begin(), ins.end());
697 new_init.push_back(k);
712 std::map<data::variable, data::data_expression> result;
731 if (new_pars_it->sort() != arg_sort)
733 throw runtime_error(
"Unexpected new parameter encountered, maybe they were not sorted well.");
735 arg.push_back(*new_pars_it++);
740 dev.push_back(case_func_arg);
745 result.insert(std::make_pair(
754 return data::if_(atermpp::down_cast<data::application>(de)[0],
811 std::advance(parameter_it, index);
812 return *parameter_it;
Term containing a string.
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.
An application of a data expression to a number of arguments.
\brief Assignment of a data expression to a variable
const core::identifier_string & name() const
sort_expression sort() const
Returns the sort of the data expression.
void add_mapping(const function_symbol &f)
Adds a mapping to this specification.
void add_equation(const data_equation &e)
Adds an equation to this specification.
bool equal_sorts(sort_expression const &s1, sort_expression const &s2) const
Checks whether two sort expressions represent the same sort.
void add_constructor(const function_symbol &f)
Adds a constructor to this specification.
const function_symbol_vector & constructors() const
Gets all constructors including those that are system defined.
const function_symbol_vector & mappings() const
Gets all mappings in this specification including those that are system defined.
const sort_expression_list & domain() const
const sort_expression & sort() const
Generic substitution function. The substitution is stored as a mapping of variables to expressions....
Rewriter that operates on data expressions.
const sort_expression & target_sort() const
Returns the target sort of this expression.
void add_sort(const basic_sort &s)
Adds a sort to this specification.
const core::identifier_string & name() const
const sort_expression & sort() const
LPS summand containing a multi-action.
data::variable_vector arguments(const data::function_symbol &f)
Generate argument variables for f.
lps::stochastic_specification & m_spec
The specification that is processed by the algorithm.
void add_used_identifier(const core::identifier_string &id)
data::data_specification & m_dataspec
bool m_possibly_inconsistent
Boolean indicating whether rewrite rules may be added that could make the data specification inconsis...
mcrl2::data::set_identifier_generator m_identifier_generator
set of identifiers to use during fresh variable generation
void create_determine_function(const data::sort_expression &sort)
Creates the determine function.
void add_used_identifiers(const std::set< core::identifier_string > &ids)
unfold_cache_element & get_cache_element(const data::sort_expression &sort)
mcrl2::core::identifier_string generate_fresh_function_symbol_name(const std::string &str)
Generates a fresh name for a constructor or mapping.
void generate_case_function_equations(const data::sort_expression &sort, const data::function_symbol &case_function)
Create the data equations for case functions.
data::set_identifier_generator & id_gen()
void generate_determine_function_equations(const data::sort_expression &sort)
Create the data equations for the determine function.
void generate_projection_function_equations(const data::sort_expression &sort)
Create the data equations for the projection functions.
void create_new_constructors(const data::sort_expression &sort)
Creates a set of constructors for the fresh basic sort.
std::map< mcrl2::data::sort_expression, unfold_cache_element > & m_cache
cache for previously unfolded sorts. facilitates reuse of previously introduced sorts and function sy...
std::string filter_illegal_characters(std::string in) const
mcrl2::data::variable generate_fresh_variable(std::string str, const data::sort_expression &sort)
Generates variable of type sort based on a given string str.
mcrl2::data::representative_generator m_representative_generator
a generator for default data expressions of a given sort;
mcrl2::data::basic_sort generate_fresh_basic_sort(const data::sort_expression &sort)
Generates a fresh basic sort given a sort expression.
data::function_symbol create_case_function(const data::sort_expression &det_sort, const data::sort_expression &output_sort)
Creates the case function with number of arguments determined by the number of affected constructors,...
void create_distribution_law_over_case(const data::sort_expression &sort, const data::function_symbol &function_for_distribution, const data::function_symbol case_function)
Create distribution rules for distribution_functions over case_functions.
detail::data_equation_argument_generator m_data_equation_argument_generator
generator for arguments in left hand side of data equations
void create_projection_functions(const data::sort_expression &sort)
Creates projection functions for the unfolded process parameter.
void determine_affected_constructors(const data::sort_expression &sort)
Determines the constructors that are affected with the unfold process parameter.
const std::vector< ActionSummand > & action_summands() const
Returns the sequence of action summands.
const data::variable_list & process_parameters() const
Returns the sequence of process parameters.
std::map< mcrl2::data::variable, mcrl2::data::data_expression > parameter_substitution()
substitute function for replacing process parameters with unfolded process parameters functions.
void update_linear_process(std::size_t parameter_at_index)
substitute unfold process parameter in the linear process
std::tuple< data::variable, std::map< data::sort_expression, data::function_symbol >, data::variable, data::data_expression_vector > case_func_replacement
void update_linear_process_initialization(std::size_t parameter_at_index)
substitute unfold process parameter in the initialization of the linear process
detail::pattern_match_unfolder m_pattern_unfolder
mcrl2::data::variable process_parameter_at(const std::size_t index)
Get the process parameter at given index.
bool m_alt_case_placement
Boolean to indicate if alternative placement of case functions should be used.
void algorithm(const std::size_t parameter_at_index)
Applies lpsparunfold algorithm on a process parameter of an mCRL2 process specification .
lpsparunfold(lps::stochastic_specification &spec, std::map< data::sort_expression, unfold_cache_element > &cache, bool alt_case_placement=false, bool possibly_inconsistent=false, bool unfold_pattern_matching=true)
Constructor for lpsparunfold algorithm.
case_func_replacement parameter_case_function()
bool m_run_before
set to true when the algorithm has been run once; as the algorithm should run only once....
bool m_unfold_pattern_matching
Indicates whether functions defined by pattern matching that occur in the scope of a Det or pi in a s...
mcrl2::data::data_expression_vector unfold_constructor(const mcrl2::data::data_expression &de)
unfolds a data expression into a vector of process parameters
void unfold_summands(mcrl2::lps::stochastic_action_summand_vector &summands)
detail::unfold_data_manager m_datamgr
Bookkeeper for recogniser and projection functions.
data::data_expression apply_function(const data::function_symbol &f, const data::data_expression &de) const
mcrl2::data::variable m_unfold_parameter
The process parameter that needs to be unfold.
mcrl2::data::variable_vector m_injected_parameters
The process parameters that are inserted.
data::data_expression_list expressions() const
const std::set< data::variable > & global_variables() const
Returns the declared free variables of the LPS.
const process::action_label_list & action_labels() const
Returns a sequence of action labels. This sequence contains all action labels occurring in the specif...
const InitialProcessExpression & initial_process() const
Returns the initial process.
const LinearProcess & process() const
Returns the linear process of the specification.
const data::data_specification & data() const
Returns the data specification.
LPS summand containing a multi-action.
A stochastic process initializer.
const stochastic_distribution & distribution() const
Linear process specification.
Standard exception class for reporting runtime errors.
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
add your file description here.
data_expression join_or(ForwardTraversalIterator first, ForwardTraversalIterator last)
Returns or applied to the sequence of data expressions [first, last)
bool is_bool(const sort_expression &e)
Recogniser for sort expression Bool.
const basic_sort & bool_()
Constructor for sort expression Bool.
const function_symbol & and_()
Constructor for function symbol &&.
const basic_sort & real_()
Constructor for sort expression Real.
Namespace for all data library functionality.
std::vector< assignment > assignment_vector
\brief vector of assignments
bool is_structured_sort(const atermpp::aterm &x)
Returns true if the term t is a structured sort.
void find_identifiers(const T &x, OutputIterator o)
std::vector< sort_expression > sort_expression_vector
\brief vector of sort_expressions
bool is_if_application(const DataExpression &e)
Recogniser for application of if.
std::vector< variable > variable_vector
\brief vector of variables
function_sort make_function_sort_(const sort_expression &dom1, const sort_expression &codomain)
Convenience constructor for function sort with domain size 1.
const data_expression & false_()
std::vector< data_expression > data_expression_vector
\brief vector of data_expressions
std::string pp(const abstraction &x)
bool is_container_sort(const atermpp::aterm &x)
Returns true if the term t is a container sort.
atermpp::term_list< data_expression > data_expression_list
\brief list of data_expressions
bool is_basic_sort(const atermpp::aterm &x)
Returns true if the term t is a basic sort.
bool is_if_function_symbol(const DataExpression &e)
Recogniser for function if.
atermpp::term_list< variable > variable_list
\brief list of variables
bool is_function_sort(const atermpp::aterm &x)
Returns true if the term t is a function sort.
assignment_vector make_assignment_vector(VariableSequence const &variables, ExpressionSequence const &expressions)
Constructs an assignment_list by pairwise combining a variable and expression.
atermpp::term_list< assignment > assignment_list
\brief list of assignments
function_symbol equal_to(const sort_expression &s)
Constructor for function symbol ==.
function_symbol if_(const sort_expression &s)
Constructor for function symbol if.
data_equation unfold_pattern_matching(const function_symbol &mapping, const data_equation_vector &rewrite_rules, StructInfo &ssf, representative_generator &gen, set_identifier_generator &id_gen)
This converts a collection of rewrite rules for a give function symbol into a one-rule specification ...
bool is_variable(const atermpp::aterm &x)
Returns true if the term t is a variable.
bool mCRL2logEnabled(const log_level_t level)
std::vector< stochastic_action_summand > stochastic_action_summand_vector
\brief vector of stochastic_action_summands
bool check_well_typedness(const linear_process &x)
void replace_variables_capture_avoiding(T &x, Substitution &sigma, data::set_identifier_generator &id_generator, typename std::enable_if<!std::is_base_of< atermpp::aterm, T >::value >::type *=nullptr)
std::string pp(const action_summand &x)
void insert_case_functions(T &x, const lpsparunfold::case_func_replacement &cfv, data::set_identifier_generator &id_generator, typename std::enable_if<!std::is_base_of< atermpp::aterm, T >::value >::type *=nullptr)
void find_identifiers(const T &x, OutputIterator o)
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Element in the cache that keeps track of the information for a single unfolded sort,...
std::map< mcrl2::data::sort_expression, mcrl2::data::function_symbol > case_functions
mcrl2::data::basic_sort fresh_basic_sort
mcrl2::data::function_symbol_vector affected_constructors
mcrl2::data::function_symbol determine_function
mcrl2::data::function_symbol_vector projection_functions
mcrl2::data::function_symbol_vector new_constructors
mcrl2::core::identifier_string case_function_name