mCRL2
Loading...
Searching...
No Matches
consistency.h
Go to the documentation of this file.
1// Author(s): Wieger Wesselink
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
9/// \file mcrl2/data/consistency.h
10/// \brief This file contains some functions that are present in all libraries
11/// except the data library. In the data library they have different names, or
12/// are located in different namespaces. Note that this file can not be used
13/// everywhere, in particular not when people expose the sort_bool namespace.
14
15#ifndef MCRL2_DATA_CONSISTENCY_H
16#define MCRL2_DATA_CONSISTENCY_H
17
18#include "mcrl2/data/bool.h"
19#include "mcrl2/data/exists.h"
20#include "mcrl2/data/forall.h"
21
22namespace mcrl2::data
23{
24
25/// \brief Test if x is true
26/// \param x a data expression
27inline
29{
31}
32
33/// \brief Test if x is false
34/// \param x a data expression
35inline
37{
39}
40
41/// \brief Test if x is a negation
42/// \param x a data expression
43inline
44bool is_not(const data_expression& x)
45{
47}
48
49/// \brief Test if x is a disjunction
50/// \param x a data expression
51inline
52bool is_or(const data_expression& x)
53{
55}
56
57/// \brief Test if x is a conjunction
58/// \param x a data expression
59inline
60bool is_and(const data_expression& x)
61{
63}
64
65/// \brief Test if x is an implication
66/// \param x a data expression
67inline
68bool is_imp(const data_expression& x)
69{
71}
72
73/// \brief Test if x is an equality
74/// \param x a data expression
75inline
77{
78 return is_equal_to_application(x);
79}
80
81/// \brief Test if x is an inequality
82/// \param x a data expression
83inline
85{
86 return is_not_equal_to_application(x);
87}
88
89/// \return The expression true
90inline
92{
93 return sort_bool::true_();
94}
95
96/// \return The expression false
97inline
99{
100 return sort_bool::false_();
101}
102
103/// \return The negation of x
104inline
106{
107 return sort_bool::not_(x);
108}
109
110/// \return The disjunction of x and y
111inline
113{
114 return sort_bool::or_(x, y);
115}
116
117/// \return The conjunction of x and y
118inline
120{
121 return sort_bool::and_(x, y);
122}
123
124/// \return The implication of x and y
125inline
127{
128 return sort_bool::implies(x, y);
129}
130
131/// \return Test if x is the boolean sort
132inline
134{
135 return sort_bool::is_bool(x);
136}
137
138/// \return The boolean sort
139inline
141{
142 return sort_bool::bool_();
143}
144
145/// \brief Make a universal quantification. It checks for an empty variable list,
146/// which is not allowed.
147/// \param v A sequence of data variables
148/// \param x A data expression
149/// \return The value <tt>forall v.x</tt>
150inline
151data_expression make_forall_(const data::variable_list& v, const data_expression& x)
152{
153 if (v.empty())
154 {
155 return x;
156 }
157 return forall(v, x);
158}
159
160/// \brief Make an existential quantification. It checks for an empty variable list,
161/// which is not allowed.
162/// \param v A sequence of data variables
163/// \param x A data expression
164/// \return The value <tt>exists v.x</tt>
165inline
166data_expression make_exists_(const data::variable_list& v, const data_expression& x)
167{
168 if (v.empty())
169 {
170 return x;
171 }
172 return exists(v, x);
173}
174
175} // namespace mcrl2::data
176
177#endif // MCRL2_DATA_CONSISTENCY_H
aterm_string()=default
Default constructor.
\brief A basic sort
Definition basic_sort.h:25
basic_sort & operator=(basic_sort &&) noexcept=default
\brief A data equation
data_expression()
\brief Default constructor X3.
data_expression & operator=(data_expression &&) noexcept=default
sort_expression sort() const
Returns the sort of the data expression.
Definition data.cpp:107
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.
\brief A function symbol
function_symbol & operator=(function_symbol &&) noexcept=default
function_symbol()
Default constructor.
const sort_expression & sort() const
Components for generating an arbitrary element of a sort.
Rewriter that operates on data expressions.
Definition rewriter.h:84
Identifier generator that stores the identifiers of the context in a set. Using the operator()() and ...
\brief A sort expression
const sort_expression & target_sort() const
Returns the target sort of this expression.
sort_expression()
\brief Default constructor X3.
void add_sort(const basic_sort &s)
Adds a sort to this specification.
\brief A data variable
Definition variable.h:25
const sort_expression & sort() const
Definition variable.h:40
Fresh variable generator for the arguments of a function symbol.
data::set_identifier_generator & m_identifier_generator
std::map< data::sort_expression, data::variable_vector > m_variables
data::variable_vector arguments(const data::function_symbol &f)
Generate argument variables for f.
data_equation_argument_generator(data::set_identifier_generator &identifier_generator)
Algorithm class for algorithms on linear process specifications. It can be instantiated with lps::spe...
Class for unfolding expressions f(a1,...,an) based on the pattern-matching rewrite rules that define ...
std::map< data::function_symbol, bool > m_is_pattern_matching
bool matches_only_known_sorts(const data::function_symbol &f)
Determines whether f pattern matches on argument arg.
bool is_det_or_pi(const data::application &expr) const
Checks whether expr is of the shape Det(h(a1,...,an)) or pi(h(a1,...,an)), where h is defined by patt...
data::data_equation_vector find_equations(const data::function_symbol &f)
Finds all rewriting equations for f.
void operator()(T &result, const data::application &x)
Unfolds expr if it is of the shape h(a1,...,an) and h is defined by pattern matching.
pattern_match_unfolder(unfold_data_manager &datamgr)
data::data_expression unfolded_expr(const data::function_symbol &f, const data::data_expression_vector &args)
bool is_pattern_matching(const data::function_symbol &f)
Checks whether f is defined by pattern matching.
bool is_constructor(const data::function_symbol &f)
data::representative_generator m_repgen
std::vector< std::size_t > pattern_matching_args(const data::function_symbol &f)
std::map< data::function_symbol, data::data_equation > m_new_eqns
bool can_unfold(const data::data_expression &x)
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)
bool is_constructor(const data::function_symbol &f) const
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.
const data::data_specification & dataspec() const
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.
const data::function_symbol_vector & get_projection_funcs(const data::function_symbol &f)
void create_distribution_law_over_case(const data::sort_expression &sort, const data::function_symbol &function_for_distribution, data::function_symbol case_function)
Create distribution rules for distribution_functions over case_functions.
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,...
data::data_expression create_cases(const data::data_expression &target, const data::data_expression_vector &rhss)
unfold_data_manager(std::map< mcrl2::data::sort_expression, unfold_cache_element > &cache, data::data_specification &dataspec, bool possibly_inconsistent)
detail::data_equation_argument_generator m_data_equation_argument_generator
generator for arguments in left hand side of data equations
bool is_cached(const data::sort_expression &sort) const
const std::vector< data::function_symbol > & get_constructors(const data::sort_expression &sort)
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.
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
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
bool m_alt_case_placement
Boolean to indicate if alternative placement of case functions should be used.
mcrl2::data::variable process_parameter_at(std::size_t index)
Get the process parameter at given index.
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.
void algorithm(std::size_t parameter_at_index)
Applies lpsparunfold algorithm on a process parameter of an mCRL2 process specification .
mcrl2::data::variable_vector m_injected_parameters
The process parameters that are inserted.
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
Definition logger.h:435
function_symbol get_top_fs(const data_expression &expr)
Get the top level function symbol f if expr is of the shape f or f(t1,...,tn)
Namespace for system defined sort bool_.
Definition bool.h:29
bool is_false_function_symbol(const atermpp::aterm &e)
Recogniser for function false.
Definition bool.h:116
bool is_or_application(const atermpp::aterm &e)
Recogniser for application of ||.
Definition bool.h:342
bool is_bool(const sort_expression &e)
Recogniser for sort expression Bool.
Definition bool.h:51
const basic_sort & bool_()
Constructor for sort expression Bool.
Definition bool.h:41
bool is_implies_application(const atermpp::aterm &e)
Recogniser for application of =>.
Definition bool.h:406
application not_(const data_expression &arg0)
Application of function symbol !.
Definition bool.h:194
application and_(const data_expression &arg0, const data_expression &arg1)
Application of function symbol &&.
Definition bool.h:257
application implies(const data_expression &arg0, const data_expression &arg1)
Application of function symbol =>.
Definition bool.h:385
application or_(const data_expression &arg0, const data_expression &arg1)
Application of function symbol ||.
Definition bool.h:321
const function_symbol & false_()
Constructor for function symbol false.
Definition bool.h:106
bool is_and_application(const atermpp::aterm &e)
Recogniser for application of &&.
Definition bool.h:278
bool is_true_function_symbol(const atermpp::aterm &e)
Recogniser for function true.
Definition bool.h:84
bool is_not_application(const atermpp::aterm &e)
Recogniser for application of !.
Definition bool.h:214
const function_symbol & true_()
Constructor for function symbol true.
Definition bool.h:74
data_expression not_(const data_expression &x)
bool is_application(const data_expression &t)
Returns true if the term t is an application.
bool is_or(const data_expression &x)
Test if x is a disjunction.
Definition consistency.h:52
bool is_false(const data_expression &x)
Test if x is false.
Definition consistency.h:36
data_expression make_exists_(const data::variable_list &v, const data_expression &x)
Make an existential quantification. It checks for an empty variable list, which is not allowed.
data_expression make_forall_(const data::variable_list &v, const data_expression &x)
Make a universal quantification. It checks for an empty variable list, which is not allowed.
data_expression or_(const data_expression &x, const data_expression &y)
bool is_not(const data_expression &x)
Test if x is a negation.
Definition consistency.h:44
data_expression and_(const data_expression &x, const data_expression &y)
const data_expression & false_()
Definition consistency.h:98
bool is_true(const data_expression &x)
Test if x is true.
Definition consistency.h:28
bool is_not_equal_to(const data_expression &x)
Test if x is an inequality.
Definition consistency.h:84
const data_expression & true_()
Definition consistency.h:91
bool is_imp(const data_expression &x)
Test if x is an implication.
Definition consistency.h:68
sort_expression bool_()
bool is_container_sort(const atermpp::aterm &x)
Returns true if the term t is a container sort.
bool is_equal_to(const data_expression &x)
Test if x is an equality.
Definition consistency.h:76
bool is_basic_sort(const atermpp::aterm &x)
Returns true if the term t is a basic sort.
data_expression imp(const data_expression &x, const data_expression &y)
bool is_function_sort(const atermpp::aterm &x)
Returns true if the term t is a function sort.
bool is_bool(const sort_expression &x)
function_symbol if_(const sort_expression &s)
Constructor for function symbol if.
Definition standard.h:205
bool is_and(const data_expression &x)
Test if x is a conjunction.
Definition consistency.h:60
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
data::data_expression unfold_pattern_matching(const data::data_expression &x, pattern_match_unfolder &unfolder)
The main namespace for the LPS library.
Definition constelm.h:18
parunfold_replacement< Builder, Binder > apply_parunfold_replacement_builder(const lpsparunfold::case_func_replacement &case_funcs, data::set_identifier_generator &id_generator)
static constexpr std::size_t max_unfold_depth
Maximum number of times an expression is unfolded before recursion stops; unfolding this often is eno...
void apply(T &result, const data::application &x)
bool is_applied_to_constructor(const data::application &x)
replace_pattern_match_builder(pattern_match_unfolder &unfolder)
data::data_expression current_replacement
data::detail::capture_avoiding_substitution_updater< parunfold_replacement< Builder, Binder > > sigma1
data::data_expression operator()(const data::variable &x)
parunfold_replacement(const lpsparunfold::case_func_replacement &case_funcs, data::set_identifier_generator &id_generator)
void apply(T &result, const data::application &x)
void apply_case_function(data::data_expression &result, const data::application &expr)
lpsparunfold::case_func_replacement case_funcs
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