12#ifndef MCRL2_MODAL_FORMULA_RESOLVE_NAME_CLASHES_H
13#define MCRL2_MODAL_FORMULA_RESOLVE_NAME_CLASHES_H
15#include "mcrl2/modal_formula/builder.h"
16#include "mcrl2/utilities/detail/container_utility.h"
23template <
typename Derived>
44 m_names[name].pop_back();
50 std::vector<core::identifier_string>& names = m_names[name];
53 names.push_back(name);
57 names.push_back(m_generator(std::string(name) +
"_"));
115 result = variable(m_names[x.name()].back(), x.arguments());
138 if (utilities::detail::contains(bound_variables, v))
140 substitutions[v].push_back(data::variable(generator(v.name()), v.sort()));
142 bound_variables.insert(v);
148 std::multiset<data::variable>::const_iterator var_iter=bound_variables.find(v);
149 assert(var_iter!=bound_variables.end());
150 bound_variables.erase(var_iter);
152 auto i = substitutions.find(v);
153 if (i != substitutions.end())
155 i->second.pop_back();
156 if (i->second.empty())
158 substitutions.erase(i);
167 auto i = substitutions.find(v);
168 if (i == substitutions.end())
172 return i->second.back();
175 return data::assignment_list(x.begin(), x.end(), [&](
const data::assignment& a)
177 return data::assignment(atermpp::down_cast<data::variable>(sigma(a.lhs())), data::replace_free_variables(a.rhs(), sigma));
186 auto i = substitutions.find(v);
187 if (i == substitutions.end())
191 return i->second.back();
194 return data::variable_list(x.begin(), x.end(), [&](
const data::variable& v)
196 return atermpp::down_cast<data::variable>(sigma(v));
204 for (
const data::assignment& a: x.assignments())
209 result = mu(x.name(), apply_assignments(x.assignments()), result);
210 for (
const data::assignment& a: x.assignments())
219 for (
const data::assignment& a: x.assignments())
224 result = nu(x.name(), apply_assignments(x.assignments()), result);
225 for (
const data::assignment& a: x.assignments())
234 for (
const data::variable& v: x.variables())
239 result = forall(apply_variables(x.variables()), result);
240 for (
const data::variable& v: x.variables())
249 for (
const data::variable& v: x.variables())
254 result = exists(apply_variables(x.variables()), result);
255 for (
const data::variable& v: x.variables())
264 for (
const data::variable& v: x.variables())
270 result = action_formulas::forall(apply_variables(x.variables()), body);
271 for (
const data::variable& v: x.variables())
280 for (
const data::variable& v: x.variables())
286 result = action_formulas::exists(apply_variables(x.variables()), body);
287 for (
const data::variable& v: x.variables())
298 auto i = substitutions.find(v);
299 if (i == substitutions.end())
303 return i->second.back();
306 result=
data::replace_free_variables(x, sigma);
326 generator.add_identifiers(state_formulas::find_identifiers(x));
327 generator.add_identifiers(context_ids);
aterm_string(const aterm_string &t) noexcept=default
bool operator==(const unprotected_aterm_core &t) const
Comparison operator.
sort_expression sort() const
Returns the sort of the data expression.
data_equation_vector & user_defined_equations()
data_specification()
Default constructor. Generate a data specification that contains only booleans and positive numbers.
const data_specification operator()() const
Yields a type checked data specification, provided typechecking was successful. If not successful an ...
void operator()(data_equation_vector &eqns)
Yields a type checked equation list, and sets the types in the equations right. If not successful an ...
data_type_checker(const data_specification &data_spec)
make a data type checker. Throws a mcrl2::runtime_error exception if the data_specification is not we...
Identifier generator that stores the identifiers of the context in a set. Using the operator()() and ...
\brief An untyped parameter
logger(const log_level_t l)
Default constructor.
Linear process specification.
Linear process specification.
stochastic_specification(const specification &other)
Constructor. This constructor is explicit as implicit conversions of this kind is a source of bugs.
\brief An untyped multi action or data application
Standard exception class for reporting runtime errors.
Identifier generator that generates names consisting of a prefix followed by a number....
D_ParserTables parser_tables_mcrl2
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
The main namespace for the aterm++ library.
void syntax_error_fn(struct D_Parser *ap)
Custom syntax error function that prints both the line number and the column.
D_ParseNode * ambiguity_fn(struct D_Parser *, int n, struct D_ParseNode **v)
Function for resolving parser ambiguities.
void warn_left_merge_merge(const parse_node &)
Prints a warning for each occurrence of 'x ||_ y || z' in the parse tree.
atermpp::aterm_string identifier_string
String type of the LPS library. Identifier strings are represented internally as ATerms.
void warn_and_or(const parse_node &)
Prints a warning for each occurrence of 'x && y || z' in the parse tree.
Namespace for system defined sort bool_.
const basic_sort & bool_()
Constructor for sort expression Bool.
application not_(const data_expression &arg0)
Application of function symbol !.
Namespace for system defined sort real_.
application negate(const data_expression &arg0)
Application of function symbol -.
Namespace for all data library functionality.
bool is_data_expression(const atermpp::aterm &x)
Test for a data_expression expression.
data_specification merge_data_specifications(const data_specification &dataspec1, const data_specification &dataspec2)
Merges two data specifications. Throws an exception if conflicts are detected.
atermpp::term_list< data_expression > data_expression_list
\brief list of data_expressions
bool is_untyped_data_parameter(const atermpp::aterm &x)
atermpp::term_list< variable > variable_list
\brief list of variables
atermpp::term_list< assignment > assignment_list
\brief list of assignments
The main namespace for the LPS library.
specification remove_stochastic_operators(const stochastic_specification &spec)
Converts a stochastic specification to a specification. Throws an exception if non-empty distribution...
The main namespace for the Process library.
atermpp::term_list< action_label > action_label_list
\brief list of action_labels
atermpp::term_list< action > action_list
\brief list of actions
bool is_untyped_multi_action(const atermpp::aterm &x)
std::string read_text(std::istream &in)
Read text from a stream.
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
expression builder that visits all sub expressions
Wrapper for D_Parser and its corresponding D_ParserTables.
parse_node parse(const std::string &text, unsigned int start_symbol_index=0, bool partial_parses=false)
Parses a string. N.B. The user is responsible for destruction of the returned value by calling destro...
parser(D_ParserTables &tables, D_AmbiguityFn ambiguity_fn=nullptr, D_SyntaxErrorFn syntax_error_fn=nullptr, std::size_t max_error_message_count=1)
unsigned int start_symbol_index(const std::string &name) const
expression traverser that visits all sub expressions
std::size_t operator()(const atermpp::detail::reference_aterm< T > &t) const