18#ifndef MCRL2_ATERMPP_STANDARD_CONTAINER_VECTOR_H
19#define MCRL2_ATERMPP_STANDARD_CONTAINER_VECTOR_H
23#include "mcrl2/atermpp/detail/aterm_container.h"
24#include "mcrl2/atermpp/detail/thread_aterm_pool.h"
25#include "mcrl2/utilities/shared_mutex.h"
73 template <
class InputIterator>
120 if constexpr (ThreadSafe) {
122 super::shrink_to_fit();
125 super::shrink_to_fit();
131 if constexpr (ThreadSafe) {
142 if constexpr (ThreadSafe) {
146 return super::insert(pos, value);
150 return super::insert(pos, value);
155 if constexpr (ThreadSafe) {
157 return super::insert(pos, value);
161 return super::insert(pos, value);
166 if constexpr (ThreadSafe) {
168 return super::insert(pos, count, value);
172 return super::insert(pos, count, value);
175 template<
class InputIt >
177 InputIt first, InputIt last )
179 if constexpr (ThreadSafe) {
181 return super::insert(pos, first, last);
185 return super::insert(pos, first, last);
190 if constexpr (ThreadSafe) {
192 return super::insert(pos, ilist);
196 return super::insert(pos, ilist);
199 template<
class... Args >
202 if constexpr (ThreadSafe) {
204 return super::emplace(pos, args...);
208 return super::emplace(pos, args...);
213 if constexpr (ThreadSafe) {
215 return super::erase(pos);
219 return super::erase(pos);
224 if constexpr (ThreadSafe) {
226 return super::erase(first, last);
230 return super::erase(first, last);
235 if constexpr (ThreadSafe)
238 super::push_back(value);
243 super::push_back(value);
249 if constexpr (ThreadSafe)
252 super::push_back(value);
257 super::push_back(value);
261 template<
class... Args >
264 if constexpr (ThreadSafe) {
266 return super::emplace_back(args...);
270 return super::emplace_back(args...);
275 if constexpr (ThreadSafe)
289 if constexpr (ThreadSafe)
292 super::resize(count);
297 super::resize(count);
303 if constexpr (ThreadSafe)
306 super::resize(count, value);
311 super::resize(count, value);
317 if constexpr (ThreadSafe)
333 return super::size();
aterm_core & assign(const aterm_core &other, detail::thread_aterm_pool &pool) noexcept
Assignment operator, to be used if busy and forbidden flags are explicitly available.
size_type size() const
Returns the number of arguments of this term.
function_symbol_pool & get_symbol_pool()
mcrl2::utilities::lock_guard lock()
Acquire an exclusive lock.
mcrl2::utilities::shared_guard lock_shared()
Acquire a shared lock on this thread aterm pool.
Generates unique function symbols with a given prefix.
std::size_t m_initial_index
Cache the value that is set in the constructor.
void clear()
Restores the index back to the value that was initially assigned in the constructor.
std::size_t m_index
A reference to the index as present in the function symbol generator.
std::string m_string_buffer
A local string cache to prevent allocating new strings for every function symbol generated.
function_symbol operator()(std::size_t arity=0)
Generates a unique function symbol with the given prefix followed by a number.
function_symbol_generator(const std::string &prefix)
Constructor.
~function_symbol_generator()
std::shared_ptr< std::size_t > m_central_index
The address of the central index for this prefix.
An unprotected term does not change the reference count of the shared term when it is copied or moved...
bool operator==(const unprotected_aterm_core &t) const
Comparison operator.
bool operator!=(const unprotected_aterm_core &t) const
Inequality operator on two unprotected aterms.
A vector class in which aterms can be stored.
iterator insert(const_iterator pos, InputIt first, InputIt last)
vector & operator=(const vector &x)=default
Assignment operator.
iterator insert(const_iterator pos, std::initializer_list< T > ilist)
vector & operator=(vector &&x)=default
Move assignment operator.
iterator insert(const_iterator pos, T &&value)
~vector()
Standard destructor.
void swap(vector &other) noexcept
super::allocator_type allocator_type
Standard typedefs.
iterator emplace(const_iterator pos, Args &&... args)
void push_back(const T &value)
iterator insert(const_iterator pos, size_type count, const T &value)
super::reference reference
vector(const vector &x, const allocator_type &alloc)
Constructor.
void push_back(T &&value)
super::value_type value_type
vector(vector &&x)
Constructor.
iterator erase(const_iterator first, const_iterator last)
vector(const allocator_type &alloc)
Constructor.
void resize(size_type count, const value_type &value)
vector(InputIterator first, InputIterator last, const allocator_type &alloc=allocator_type())
Constructor.
super::const_iterator const_iterator
super::size_type size_type
vector(vector &&x, const allocator_type &alloc)
Constructor.
vector(size_type n, const allocator_type &alloc=allocator_type())
Constructor.
iterator erase(const_iterator pos)
iterator insert(const_iterator pos, const T &value)
vector(const vector &x)
Constructor.
void resize(size_type count)
detail::generic_aterm_container< std::vector< detail::reference_aterm< T >, Alloc > > container_wrapper
reference emplace_back(Args &&... args)
vector(std::initializer_list< value_type > il, const allocator_type &alloc=allocator_type())
Constructor. To be done later....
vector()
Default constructor.
std::vector< detail::reference_aterm< T >, Alloc > super
vector(size_type n, const value_type &val, const allocator_type &alloc=allocator_type())
An abstraction expression.
const variable_list & variables() const
abstraction(const binder_type &binding_operator, const variable_list &variables, const data_expression &body)
Constructor.
const data_expression & body() const
const binder_type & binding_operator() const
data_equation(const data_equation &) noexcept=default
Move semantics.
data_expression & operator=(const data_expression &) noexcept=default
data_expression & operator=(data_expression &&) noexcept=default
bool is_default_data_expression() const
A function to efficiently determine whether a data expression is made by the default constructor.
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.
std::shared_ptr< detail::Rewriter > clone()
Clone a rewriter.
strategy create_a_rewriting_based_strategy(const function_symbol &f, const data_equation_list &rules1)
void rewrite(data_expression &result, const data_expression &term, substitution_type &sigma)
Rewrite an mCRL2 data term.
rewrite_strategy getStrategy()
Get rewriter strategy that is used.
strategy create_a_cpp_function_based_strategy(const function_symbol &f, const data_specification &data_spec)
class rewrite_stack m_rewrite_stack
void rewrite_aux_const_function_symbol(data_expression &result, const function_symbol &op, substitution_type &sigma)
data_expression rewrite(const data_expression &term, substitution_type &sigma)
Rewrite an mCRL2 data term.
RewriterJitty(const data_specification &data_spec, const used_data_equation_selector &)
void rewrite_aux(data_expression &result, const data_expression &term, substitution_type &sigma)
Rewrite a term with a given substitution and put the rewritten term in result.
RewriterJitty(const RewriterJitty &other)=default
strategy create_strategy(const function_symbol &f, const data_equation_list &rules1, const data_specification &data_spec)
void apply_cpp_code_to_higher_order_term(data_expression &result, const application &t, const std::function< void(data_expression &, const data_expression &)> rewrite_cpp_code, ITERATOR begin, ITERATOR end, substitution_type &sigma)
const function_symbol & this_term_is_in_normal_form()
void subst_values(data_expression &result, const jitty_assignments_for_a_rewrite_rule &assignments, const data_expression &t, data::enumerator_identifier_generator &generator)
RewriterJitty & operator=(const RewriterJitty &other)=delete
void rewrite_aux_function_symbol(data_expression &result, const function_symbol &op, const application &term, substitution_type &sigma)
data_expression remove_normal_form_function(const data_expression &t)
atermpp::detail::thread_aterm_pool * m_thread_aterm_pool
void rebuild_strategy(const data_specification &data_spec, const mcrl2::data::used_data_equation_selector &equation_selector)
std::vector< strategy > jitty_strat
std::map< function_symbol, data_equation_list > jitty_eqns
bool rewriting_in_progress
function_symbol this_term_is_in_normal_form_symbol
void make_jitty_strat_sufficiently_larger(const std::size_t i)
Auxiliary function to take care that the array jitty_strat is sufficiently large to access element i.
std::vector< data_expression > rhs_for_constants_cache
Rewriter interface class.
used_data_equation_selector data_equation_selector
mcrl2::data::data_specification m_data_specification_for_enumeration
virtual std::shared_ptr< detail::Rewriter > clone()=0
Clone a rewriter.
data_expression universal_quantifier_enumeration(const abstraction &t, substitution_type &sigma)
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_lambda_application(data_expression &result, const abstraction &lambda_term, const application &t, substitution_type &sigma)
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)
virtual void rewrite(data_expression &result, const data_expression &term, substitution_type &sigma)=0
Rewrite an mCRL2 data term.
data_expression operator()(const data_expression &term, substitution_type &sigma)
Provide the rewriter with a () operator, such that it can also rewrite terms using this operator.
void existential_quantifier_enumeration(data_expression &result, const variable_list &vl, const data_expression &t1, const bool t1_is_normal_form, substitution_type &sigma)
data_expression existential_quantifier_enumeration(const abstraction &t, substitution_type &sigma)
void universal_quantifier_enumeration(data_expression &result, const abstraction &t, substitution_type &sigma)
data_expression universal_quantifier_enumeration(const variable_list &vl, const data_expression &t1, const bool t1_is_normal_form, substitution_type &sigma)
Rewriter(const Rewriter &other)=default
The copy constructor operator is protected. Public copying is not allowed.
virtual rewrite_strategy getStrategy()=0
Get rewriter strategy that is used.
mutable_indexed_substitution substitution_type
virtual data_expression rewrite(const data_expression &term, substitution_type &sigma)=0
Rewrite an mCRL2 data term.
data_expression existential_quantifier_enumeration(const variable_list &vl, const data_expression &t1, const bool t1_is_normal_form, substitution_type &sigma)
data_expression rewrite_single_lambda(const variable_list &vl, const data_expression &body, const bool body_in_normal_form, substitution_type &sigma)
data_expression rewrite_where(const where_clause &term, substitution_type &sigma)
data_expression rewrite_lambda_application(const data_expression &t, substitution_type &sigma)
virtual ~Rewriter()
Destructor.
data::enumerator_identifier_generator & identifier_generator()
The fresh name generator of the rewriter.
void rewrite_single_lambda(data_expression &result, const variable_list &vl, const data_expression &body, const bool body_in_normal_form, substitution_type &sigma)
virtual void thread_initialise()
Rewriter(const data_specification &data_spec, const used_data_equation_selector &eq_selector)
Constructor. Do not use directly; use createRewriter() function instead.
Rewriter & operator=(const Rewriter &other)=default
The copy assignment operator is protected. Public copying is not allowed.
void universal_quantifier_enumeration(data_expression &result, const variable_list &vl, const data_expression &t1, const bool t1_is_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)
std::set< std::size_t > m_dependencies
const std::set< std::size_t > & dependencies() const
const data_equation equation() const
dependencies_rewrite_rule_pair(std::set< std::size_t > &dependencies, const data_equation &eq)
mutable_indexed_substitution & m_sigma
jitty_argument_rewriter(mutable_indexed_substitution<> &sigma, RewriterJitty &r)
void operator()(data_expression &result, const data_expression &t)
rewrite_stack()
Constructor.
void reserve_more_space()
void increase(std::size_t distance)
void set_element(std::size_t pos, std::size_t frame_size, const data_expression &d)
data_expression & element(std::size_t pos, std::size_t frame_size)
void reset_stack_size(std::size_t n)
std::size_t stack_size() const
void decrease(std::size_t distance)
atermpp::vector< data_expression >::const_iterator stack_iterator(std::size_t pos, std::size_t frame_size) const
std::size_t m_reserved_stack_size
A strategy is a list of rules and the number of variables that occur in it.
std::size_t number_of_variables() const
Provides the maximal number of variables used in the rewrite rules making up this strategy.
core::identifier_string operator()()
Generates a unique function symbol with the given prefix followed by a number.
atermpp::function_symbol_generator f
enumerator_identifier_generator(const std::string &prefix="x_")
Constructor.
const sort_expression & codomain() const
function_sort(const atermpp::aterm &term)
const sort_expression_list & domain() const
const sort_expression & sort() const
function_symbol(const std::string &name, const sort_expression &sort)
Constructor.
Generic substitution function.
mutable_indexed_substitution()
Default constructor.
std::multiset< variable > m_variables_in_rhs
const expression_type & operator()(const variable_type &v) const
Application operator; applies substitution to v.
bool m_variables_in_rhs_set_is_defined
ExpressionType expression_type
Type of expressions.
atermpp::utilities::unordered_map< VariableType, ExpressionType > substitution_type
mutable_indexed_substitution< VariableType, ExpressionType > clone()
Create a clone of the rewriter in which the underlying rewriter is copied, and not passed as a shared...
void apply(const variable_type &v, expression_type &target, atermpp::detail::thread_aterm_pool &thread_aterm_pool)
Application operator; applies substitution to v.
bool size()
Returns the number of assigned variables in the substitution.
bool operator==(const Substitution &) const
Compare substitutions.
void apply(const variable_type &v, ResultType &target)
Application operator; applies substitution to v.
const std::multiset< variable_type > & variables_occurring_in_right_hand_sides() const
Provides a multiset containing the variables in the rhs.
void clear()
Clear substitutions.
bool empty()
Returns true if the substitution is empty.
assignment operator[](variable_type const &v)
Index operator.
substitution_type m_substitution
Internal storage for substitutions. Required to be a container with random access through [] operator...
std::string to_string() const
string representation of the substitution. N.B. This is an expensive operation!
VariableType variable_type
Type of variables.
bool variable_occurs_in_a_rhs(const variable &v)
Checks whether a variable v occurs in one of the rhs's of the current substitution.
mutable_indexed_substitution(const substitution_type &substitution, const bool variables_in_rhs_set_is_defined, const std::multiset< variable_type > &variables_in_rhs)
sort_expression & operator=(const sort_expression &) noexcept=default
\brief Unknown sort expression
untyped_sort()
\brief Default constructor X3.
Component for selecting a subset of equations that are actually used in an encompassing specification...
used_data_equation_selector(const data_specification &specification, const std::set< function_symbol > &function_symbols, const std::set< data::variable > &global_variables, const bool do_not_remove_function_symbols)
void add_symbols(Range const &r)
void add_data_specification_symbols(const data_specification &specification)
used_data_equation_selector()
default constructor
used_data_equation_selector(const data_specification &)
select all equations
void add_function_symbols(const data_expression &t)
used_data_equation_selector(data_specification const &data_spec, Range const &context)
context is a range of function symbols
void add_symbol(const function_symbol &f)
bool operator()(const data_equation &e) const
Check whether data equation relates to used symbols, and therefore is important.
bool operator()(const data::function_symbol &f) const
Check whether the symbol is used.
std::set< function_symbol > m_used_symbols
\brief A where expression
const data_expression & body() const
const assignment_expression_list & declarations() const
Standard exception class for reporting runtime errors.
An exclusive lock guard for the shared_mutex.
A shared lock guard for the shared_mutex.
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
thread_aterm_pool & g_thread_term_pool()
A reference to the thread local term pool storage.
The main namespace for the aterm++ library.
static std::size_t & generator_sequence_number()
static std::mutex & function_symbol_generator_mutex()
atermpp::aterm_string identifier_string
String type of the LPS library. Identifier strings are represented internally as ATerms.
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...
data_expression remove_normal_form_function(const data_expression &t)
removes auxiliary expressions this_term_is_in_normal_form from data_expressions that are being rewrit...
bool isValidRewriteRule(const data_equation &data_eqn)
Check whether or not an mCRL2 data equation is a valid rewrite rule.
std::size_t recursive_number_of_args(const data_expression &t)
const data_expression & get_argument_of_higher_order_term(const application &t, std::size_t i)
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.
static bool match_jitty(const data_expression &t, const data_expression &p, jitty_assignments_for_a_rewrite_rule &assignments, const bool term_context_guarantees_normal_form)
std::size_t getArity(const data::function_symbol &op)
std::size_t get_direct_arity(const data::function_symbol &op)
std::set< variable > bound_variables_in_substitution(const jitty_assignments_for_a_rewrite_rule &assignments)
const data_expression & get_nested_head(const data_expression &t)
Namespace for system defined sort bool_.
const basic_sort & bool_()
Constructor for sort expression Bool.
const function_symbol & and_()
Constructor for function symbol &&.
const function_symbol & or_()
Constructor for function symbol ||.
const function_symbol & not_()
Constructor for function symbol !.
Namespace for all data library functionality.
atermpp::term_list< assignment_expression > assignment_expression_list
\brief list of assignment_expressions
std::vector< assignment > assignment_vector
\brief vector of assignments
std::multiset< variable > substitution_variables(const mutable_indexed_substitution< VariableType, ExpressionType > &sigma)
bool is_application(const data_expression &t)
Returns true if the term t is an application.
bool is_where_clause(const atermpp::aterm &x)
Returns true if the term t is a where clause.
std::istream & operator>>(std::istream &is, rewrite_strategy &s)
standard conversion from stream to rewrite strategy
std::string pp(const rewrite_strategy s)
Pretty prints a rewrite strategy.
std::string description(const rewrite_strategy s)
standard descriptions for rewrite strategies
bool is_abstraction(const atermpp::aterm &x)
Returns true if the term t is an abstraction.
std::vector< variable > variable_vector
\brief vector of variables
atermpp::term_list< sort_expression > sort_expression_list
\brief list of sort_expressions
rewrite_strategy
The strategy of the rewriter.
bool is_exists_binder(const atermpp::aterm &x)
bool is_lambda_binder(const atermpp::aterm &x)
bool is_forall(const atermpp::aterm &x)
Returns true if the term t is a universal quantification.
bool is_function_symbol(const atermpp::aterm &x)
Returns true if the term t is a function symbol.
atermpp::term_list< data_equation > data_equation_list
\brief list of data_equations
atermpp::term_list< variable > variable_list
\brief list of variables
bool is_exists(const atermpp::aterm &x)
Returns true if the term t is an existential quantification.
bool is_function_sort(const atermpp::aterm &x)
Returns true if the term t is a function sort.
atermpp::term_list< assignment > assignment_list
\brief list of assignments
bool is_machine_number(const atermpp::aterm &x)
Returns true if the term t is a machine_number.
bool is_lambda(const atermpp::aterm &x)
Returns true if the term t is a lambda abstraction.
bool is_forall_binder(const atermpp::aterm &x)
std::vector< function_symbol > function_symbol_vector
\brief vector of function_symbols
function_symbol if_(const sort_expression &s)
Constructor for function symbol if.
bool is_variable(const atermpp::aterm &x)
Returns true if the term t is a variable.
static constexpr bool GlobalThreadSafe
Enables thread safety for the whole toolset.
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
jitty_variable_assignment_for_a_rewrite_rule * assignment
jitty_assignments_for_a_rewrite_rule(jitty_variable_assignment_for_a_rewrite_rule *a)
jitty_variable_assignment_for_a_rewrite_rule(const variable &m_var, const data_expression &m_term, bool m_nf)
bool variable_is_a_normal_form
const data_expression & term
Wrapper class for internal storage and substitution updates using operator()
const variable_type & m_variable
mutable_indexed_substitution< VariableType, ExpressionType > & m_super
assignment(const variable_type &v, mutable_indexed_substitution< VariableType, ExpressionType > &super)
Constructor.
void operator=(const expression_type &e)
Actual assignment.
std::size_t operator()(const atermpp::detail::reference_aterm< T > &t) const