12#ifndef MCRL2_LPS_LTSMIN_H
13#define MCRL2_LPS_LTSMIN_H
31#ifdef MCRL2_ENABLE_JITTYC
32#define MCRL2_JITTYC_AVAILABLE
45 std::vector<std::string> result;
46 std::size_t max_iterations = 10000;
49 bool accept_solutions_with_variables =
false;
57 [&](
const enumerator_element& p)
59 p.add_assignments(v_list,
sigma, rewr);
61 return result.size() >= max_size;
80 class index_iterator:
public boost::iterator_facade<index_iterator, const std::size_t, boost::forward_traversal_tag>
140 virtual std::string
print(
int i)
const = 0;
146 virtual std::size_t
parse(
const std::string& s) = 0;
149 virtual const std::string&
name()
const = 0;
247 std::string
print(
int i)
const override
252 std::size_t
parse(
const std::string& s)
override
257 const std::string&
name()
const override
291 std::string
print(
int i)
const override
296 std::size_t
parse(
const std::string& s)
override
302 const std::string&
name()
const override
310 return std::vector<std::string>();
403 template <
typename Iter>
406 std::ostringstream out;
408 for (Iter i = first; i != last; ++i)
420 template <
typename Container>
428 std::set<data::variable> parameters(
process().process_parameters().begin(),
process().process_parameters().end());
441 for (
const auto & summand :
proc.action_summands())
444 std::set<data::variable> used_write_variables;
449 for (
const auto & assignment : summand.assignments())
451 if (assignment.lhs() != assignment.rhs())
459 std::set<data::variable> used_read_parameters;
460 std::set<data::variable> used_write_parameters;
466 std::inserter(used_read_parameters,
467 used_read_parameters.begin()));
468 std::set_intersection(used_write_variables.begin(),
469 used_write_variables.end(),
472 std::inserter(used_write_parameters,
473 used_write_parameters.begin()));
478 if (used_read_parameters.find(param) != used_read_parameters.end())
482 if (used_write_parameters.find(param) != used_write_parameters.end())
499 std::set<data::variable> used_update_variables;
501 data::find_free_variables(reduced_summand.condition(), std::inserter(used_update_variables, used_update_variables.end()));
502 lps::find_free_variables(reduced_summand.multi_action(), std::inserter(used_update_variables, used_update_variables.end()));
504 for (
const auto & assignment : reduced_summand.assignments())
506 if (assignment.lhs() != assignment.rhs())
513 std::set<data::variable> used_update_parameters;
515 std::set_intersection(used_update_variables.begin(),
516 used_update_variables.end(),
519 std::inserter(used_update_parameters,
520 used_update_parameters.begin()));
525 if (used_update_parameters.find(param) != used_update_parameters.end())
562 std::vector<lps::action_summand> reduced_summands;
573 std::set<data::data_expression> conjuncts =
data::split_and(summand.condition());
574 std::set<data::variable> summation_variables(summand.summation_variables().begin(), summand.summation_variables().end());
576 for (
const auto & conjunct : conjuncts)
579 std::size_t at =
m_guards.index(conjunct);
581 bool use_conjunct_as_guard =
true;
584 std::set<data::variable> conjunct_variables;
587 if (!summand.summation_variables().empty())
591 std::set<data::variable> summation_variables_in_conjunct;
592 std::set_intersection(conjunct_variables.begin(),
593 conjunct_variables.end(),
594 summation_variables.begin(),
595 summation_variables.end(),
596 std::inserter(summation_variables_in_conjunct, summation_variables_in_conjunct.begin()));
598 if (!summation_variables_in_conjunct.empty()) {
600 use_conjunct_as_guard =
false;
602 std::string printed_guard(
data::pp(conjunct).substr(0, 80));
604 <<
"Guard '" << printed_guard + (printed_guard.size() > 80?
"...":
"") <<
"' in summand "
605 << reduced_summands.size()
606 <<
" introduces local variables. To remove the guard from the condition, try instantiating the summand with 'lpssuminst'."
611 reduced_condition = conjunct;
617 if (use_conjunct_as_guard) {
620 if (!conjunct_variables.empty())
626 if (conjunct_variables.find(param) != conjunct_variables.end())
634 at =
m_guards.insert(conjunct).first;
639 if (use_conjunct_as_guard) {
649 reduced_summands.push_back(
lps::action_summand(summand.summation_variables(), reduced_condition, summand.multi_action(), summand.assignments()));
657 return specification_reduced;
663 pins(
const std::string& filename,
const std::string& rewriter_strategy)
674 for (
const auto & param : params)
681 std::map<data::sort_expression, pins_data_type*> existing_type_maps;
682 std::vector<data::variable> parameters(
process().process_parameters().begin(),
process().process_parameters().end());
683 for (std::size_t i = 0; i < params.
size(); i++)
686 std::map<data::sort_expression, pins_data_type*>::const_iterator j = existing_type_maps.find(s);
687 if (j == existing_type_maps.end())
692 existing_type_maps[s] = dt;
714 std::set<pins_data_type*> deleted;
717 if (deleted.find(data_type_ptr) == deleted.end())
719 delete data_type_ptr;
720 deleted.insert(data_type_ptr);
744 const std::vector<std::size_t>&
read_group(std::size_t index)
const
753 const std::vector<std::size_t>&
write_group(std::size_t index)
const
772 const std::vector<std::size_t>&
guard_info(std::size_t index)
const
833 std::set<std::string> result;
836 for (
const auto & i : l)
838 result.insert(std::string(i.label().name()));
856 template <
typename StateFunction>
861 for (std::size_t i = 0; i < nparams; i++)
866 state source(state_arguments.begin(),nparams);
869 for (
const generator_type::transition& t: transitions)
871 state destination = t.state;
872 for (std::size_t j = 0; j < nparams; j++)
881 template <
typename StateFunction>
887 template <
typename StateFunction>
912 template <
typename StateFunction>
922 for (std::size_t i = 0; i < nparams; i++)
926 state source(state_arguments.begin(),nparams);
928 std::list<generator_type::transition> transitions = generator->
out_edges(source, group);
930 for (
const generator_type::transition& t: transitions)
932 state destination = t.state;
933 for (std::size_t j = 0; j < nparams; j++)
945 for (std::size_t i = 0; i < nparams; i++)
968 std::ostringstream out;
970 out <<
"\n--- EDGE LABELS ---\n";
975 out <<
"edge_label_name(" << i <<
") = " <<
edge_label_name(i) << std::endl;
976 out <<
"edge_label_type(" << i <<
") = " <<
edge_label_type(i) << std::endl;
979 out <<
"\n--- PROCESS PARAMETERS ---\n";
988 out <<
"\n--- SUMMANDS ---\n";
989 out <<
"group_count() = " <<
group_count() << std::endl;
998 out <<
"\n--- GUARDS ---\n";
999 out <<
"guard_count() = " <<
guard_count() << std::endl;
1005 out <<
"\n--- INITIAL STATE ---\n";
1011 out <<
"\n--- DATA TYPE MAPS ---\n";
1017 out <<
"datatype " << i <<
"\n"
1018 <<
" name = " << type.
name() <<
"\n"
1019 <<
" size = " << type.
size() <<
"\n"
1020 <<
" bounded = " << std::boolalpha << type.
is_bounded() <<
"\n";
Read-only balanced binary tree of terms.
size_type size() const
Returns the size of the term_list.
const_iterator begin() const
Returns a const_iterator pointing to the beginning of the term_list.
bool is_certainly_finite(const sort_expression &s) const
Checks whether a sort is certainly finite.
An enumerator algorithm that generates solutions of a condition.
An element for the todo list of the enumerator that collects the substitution corresponding to the ex...
Generic substitution function.
Rewriter that operates on data expressions.
basic_rewriter< data_expression >::substitution_type substitution_type
Class for logging messages.
Models the mapping of mCRL2 action labels to integers.
const std::string & name() const override
Returns the name of the data type.
std::size_t parse(const std::string &s) override
Parses a string to a data value, and returns the corresponding index. If the value is not in the mapp...
std::string print(int i) const override
Returns a human readable representation of the value with index i. N.B. It is not guaranteed that par...
action_label_data_type(const data::data_specification &data, const process::action_label_list &action_labels)
std::string serialize(int i) const override
Serializes the i-th value of the data type to a binary string. It is guaranteed that serialize(deseri...
std::vector< std::string > generate_values(std::size_t) const override
Generates possible values of the data type (at most max_size).
std::size_t deserialize(const std::string &s) override
Deserializes a string to a data value, and returns the corresponding index. If the value is not in th...
LPS summand containing a multi-action.
const data::data_expression_list & initial_state() const
const data::rewriter & get_rewriter() const
std::list< transition > out_edges(const state &s, const SummandSequence ®ular_summands, const SummandSequence &confluent_summands, data::mutable_indexed_substitution<> &sigma, data::rewriter &rewr, data::enumerator_algorithm<> &enumerator, data::enumerator_identifier_generator &id_generator)
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.
\brief A timed multi-action
Forward iterator used for iterating over indices.
std::ptrdiff_t distance_to(const index_iterator &other) const
const std::size_t & dereference() const
bool equal(const index_iterator &other) const
index_iterator(std::size_t index=0)
friend class boost::iterator_core_access
Models a pins data type. A pins data type maintains a mapping between known values of a data type and...
utilities::indexed_set< atermpp::aterm > & indexed_set()
Returns the indexed_set holding the values.
utilities::indexed_set< atermpp::aterm > m_indexed_set
const utilities::indexed_set< atermpp::aterm > & indexed_set() const
Returns the indexed_set holding the values.
virtual std::vector< std::string > generate_values(std::size_t max_size) const =0
Generates possible values of the data type (at most max_size).
bool is_bounded() const
Returns true if the number of elements is bounded. If this property can not be computed for a data ty...
virtual const std::string & name() const =0
Returns the name of the data type.
const data::data_specification & m_data
virtual std::size_t parse(const std::string &s)=0
Parses a string to a data value, and returns the corresponding index. If the value is not in the mapp...
virtual std::string serialize(int i) const =0
Serializes the i-th value of the data type to a binary string. It is guaranteed that serialize(deseri...
std::size_t size() const
Returns the number of values that are stored in the map.
virtual std::size_t deserialize(const std::string &s)=0
Deserializes a string to a data value, and returns the corresponding index. If the value is not in th...
pins_data_type(const data::data_specification &data, const process::action_label_list &action_labels, bool is_bounded=false)
Constructor.
virtual std::string print(int i) const =0
Returns a human readable representation of the value with index i. N.B. It is not guaranteed that par...
index_iterator index_begin() const
Returns an iterator to the beginning of the indices.
virtual ~pins_data_type()=default
Destructor.
index_iterator index_end() const
Returns an iterator to the end of the indices.
atermpp::aterm get(std::size_t i)
Returns the value at index i.
std::size_t operator[](const atermpp::aterm &x)
Returns the index of the value x.
const process::action_label_list & m_action_labels
generator_type m_generator
const std::vector< std::size_t > & guard_parameters(std::size_t index) const
guard_evaluation_t
guard evaluations have ternary logic. A guard may not always rewrite to true or false
const linear_process & process() const
Returns the process of the LPS specification.
const std::vector< std::size_t > & write_group(std::size_t index) const
Indices of process parameters that influence event or next state of a summand by being written.
void get_initial_state(ltsmin_state_type &s)
Assigns the initial state to s.
datatype_index edge_label_type(std::size_t) const
Returns the datatype map index corresponding to edge label i.
std::string process_parameter_name(std::size_t i) const
Returns a human-readable, unique name for process parameter i.
std::vector< std::vector< std::size_t > > m_write_group
std::size_t m_group_count
std::size_t process_parameter_count() const
Returns the number of process parameters of the LPS.
pins(const std::string &filename, const std::string &rewriter_strategy)
Constructor.
void next_state_long(ltsmin_state_type const &src, std::size_t group, StateFunction &f, ltsmin_state_type const &dest, int *const &labels)
lps::specification m_specification_reduced
generator_type m_generator_reduced
std::vector< pins_data_type * > m_unique_data_types
The unique type mappings (is contained in m_data_types).
data::rewriter::substitution_type substitution_t
std::size_t edge_label_count() const
Returns the number of labels per edge.
std::size_t m_state_length
std::string print_vector(Iter first, Iter last) const
std::string print_vector(const Container &c) const
std::size_t datatype_count() const
Returns the number of unique datatype maps. Note that the datatype map for action labels is included,...
utilities::indexed_set< atermpp::aterm > m_guards
void update_long(ltsmin_state_type const &src, std::size_t group, StateFunction &f, ltsmin_state_type const &dest, int *const &labels)
std::set< std::string > summand_action_names(std::size_t i) const
Returns the names of the actions that appear in the summand with index i, with 0 <= i < group_count()...
lps::specification reduce_specification(const lps::specification &spec)
extracts all guards from the original specification and returns a new one with the guards removed.
std::size_t guard_count() const
void next_state_all(ltsmin_state_type const &src, StateFunction &f, ltsmin_state_type const &dest, int *const &labels)
Iterates over the 'next states' of state src, and invokes a callback function for each discovered sta...
std::vector< std::vector< std::size_t > > m_read_group
std::string info()
Prints an overview of several relevant attributes.
static lps::specification load_specification(const std::string &filename)
guard_evaluation_t eval_guard_long(ltsmin_state_type const &src, std::size_t guard)
pins_data_type & action_label_type_map()
Returns the action data type.
const linear_process & process_reduced() const
Returns the reduced process of the LPS specification, i.e. with conditions with guards removed.
std::vector< std::size_t > m_unique_data_type_index
pins_data_type & data_type(std::size_t i)
Returns a reference to the datatype map with index i.
std::vector< std::string > m_guard_names
const std::vector< std::size_t > & guard_info(std::size_t index) const
const pins_data_type & action_label_type_map() const
Returns the action data type.
std::vector< pins_data_type * > m_data_types
std::vector< data::variable > m_parameters_list
const pins_data_type & state_type_map(std::size_t i) const
Returns the data type of the i-th state parameter.
pins_data_type & state_type_map(std::size_t i)
Returns the data type of the i-th state parameter.
std::vector< std::vector< std::size_t > > m_update_group
datatype_index process_parameter_type(std::size_t i) const
Returns the datatype map index corresponding to process parameter i.
const std::vector< std::size_t > & read_group(std::size_t index) const
Indices of process parameters that influence event or next state of a summand by being read.
std::string edge_label_name(std::size_t) const
Returns the name of the i-th action label (always "action").
std::size_t datatype_index
std::vector< std::vector< std::size_t > > m_guard_info
void initialize_read_write_groups()
const std::string & guard_name(std::size_t index)
const std::vector< std::size_t > & update_group(std::size_t index) const
Indices of process parameters that influence event or next state of a summand by being read except fr...
void _long(ltsmin_state_type const &src, std::size_t group, StateFunction &f, const ltsmin_state_type &dest, int *const &labels, generator_type *generator)
Iterates over the 'next states' of a particular summand of state src that are generated by a group of...
const data::data_specification & data() const
Returns the data specification of the LPS specification.
lps::explorer< false, false, lps::specification > generator_type
std::vector< std::string > m_process_parameter_names
std::vector< std::vector< std::size_t > > guard_parameters_list
std::size_t group_count() const
Returns the number of available groups. This equals the number of action summands of the LPS.
lps::specification m_specification
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.
Linear process specification.
Models the mapping of mCRL2 state values to integers.
std::size_t expression2index(const data::data_expression &x)
data::data_expression index2expression(std::size_t i) const
std::size_t parse(const std::string &s) override
Parses a string to a data value, and returns the corresponding index. If the value is not in the mapp...
std::string print(int i) const override
Returns a human readable representation of the value with index i. N.B. It is not guaranteed that par...
data::sort_expression m_sort
std::size_t deserialize(const std::string &s) override
Deserializes a string to a data value, and returns the corresponding index. If the value is not in th...
std::string serialize(int i) const override
Serializes the i-th value of the data type to a binary string. It is guaranteed that serialize(deseri...
std::vector< std::string > generate_values(std::size_t max_size) const override
Generates possible values of the data type (at most max_size).
const std::string & name() const override
Returns the name of the data type.
state_data_type(const data::data_specification &data, const process::action_label_list &action_labels, const data::sort_expression &sort, bool sort_is_finite)
A set that assigns each element an unique index.
Join and split functions for data expressions.
add your file description here.
MCRL2_EXPORT bool init(rewriter_interface *i, RewriterCompilingJitty *this_rewriter)
static RewriterCompilingJitty::substitution_type & sigma(RewriterCompilingJitty *this_rewriter)
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
IO routines for linear process specifications.
add your file description here.
mcrl2::log::log_level_t mcrl2_log_level_t
aterm read_term_from_string(const std::string &s)
Reads an aterm from a string. The string can be in either binary or text format.
std::string print_set(const Container &v, const std::string &message="", bool print_index=false, bool boundary_spaces=true)
Creates a string representation of a container.
atermpp::aterm add_index(const atermpp::aterm &x)
atermpp::aterm remove_index(const atermpp::aterm &x)
const function_symbol & and_()
Constructor for function symbol &&.
const function_symbol & false_()
Constructor for function symbol false.
const function_symbol & true_()
Constructor for function symbol true.
data_expression parse_data_expression(std::istream &in, const VariableContainer &variables, const data_specification &dataspec=detail::default_specification(), bool type_check=true, bool translate_user_notation=true, bool normalize_sorts=true)
Parses and type checks a data expression.
std::set< data::variable > find_all_variables(const data::data_expression &x)
std::vector< data_expression > data_expression_vector
\brief vector of data_expressions
std::string pp(const abstraction &x)
std::set< data::variable > find_free_variables(const data::data_expression &x)
std::set< data_expression > split_and(const data_expression &expr)
Splits a conjunction into a sequence of operands Given a data expression of the form p1 && p2 && ....
log_level_t
Log levels that are supported.
std::string pp(const action_summand &x)
std::set< data::variable > find_free_variables(const lps::deadlock &x)
std::vector< std::string > generate_values(const data::data_specification &dataspec, const data::sort_expression &s, std::size_t max_size=1000)
Generates possible values of the data type (at most max_size).
multi_action parse_multi_action(std::stringstream &in, const process::action_label_list &action_decls, const data::data_specification &data_spec=data::detail::default_specification())
Parses a multi_action from an input stream.
void load_lps(Specification &spec, std::istream &stream, const std::string &source="")
Load LPS from file.
std::set< data::variable > used_read_variables(const action_summand &summand)
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...