mCRL2
Loading...
Searching...
No Matches
regfrmtrans.cpp
Go to the documentation of this file.
1// Author(s): Aad Mathijssen
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 regfrmtrans.cpp
10
11#include "mcrl2/data/xyz_identifier_generator.h"
12#include "mcrl2/modal_formula/translate_regular_formulas.h"
13
14using namespace mcrl2::core;
15using namespace mcrl2::core::detail;
16using namespace mcrl2::data;
17using namespace mcrl2::state_formulas;
18using namespace mcrl2::regular_formulas;
19
20
21
23{
24
25//local declarations
26//------------------
27
29/*Pre: part represents a part of a state formula
30 * after the data implementation phase
31 *Ret: part in which all regular formulas are translated in terms of state and
32 * action formulas
33 */
34
35//implementation
36//--------------
37
39{
40 xyz_identifier_generator xyz_generator(find_identifiers(state_frm));
41 return translate_reg_frms_appl(state_frm, xyz_generator);
42}
43
45{
56 )
57 {
58 //part is a data expression, a multiaction, a state variable or a data
59 //variable declaration (with or without initialisation); return part
60 }
61 else if (state_formulas::is_must(part))
62 {
63 //part is the must operator; return equivalent non-regular formula
64 const regular_formula reg_frm = must(part).formula();
65 const state_formula phi = must(part).operand();
67 {
68 const regular_formula R1 = seq(reg_frm).left();
69 const regular_formula R2 = seq(reg_frm).right();
70 //red([R1.R2]phi) -> red([R1][R2]phi)
71 part = translate_reg_frms_appl(must(R1, must(R2, phi)),xyz_generator);
72 }
73 else if (regular_formulas::is_alt(reg_frm))
74 {
75 const regular_formula R1 = alt(reg_frm).left();
76 const regular_formula R2 = alt(reg_frm).right();
77 //red([R1+R2]phi) -> red([R1]phi) && red([R2]phi)
80 translate_reg_frms_appl(must(R2,phi),xyz_generator)
81 );
82 }
83 else if (regular_formulas::is_trans(reg_frm))
84 {
86 //red([R+]phi) -> red([R.R*]phi)
88 }
90 {
92 //red([R*]phi) -> nu X. red(phi) && red([R]X),
93 //where X does not occur free in phi and R
94 const identifier_string X = xyz_generator("X");
95 part = nu(X, assignment_list(), state_formulas::and_(
96 translate_reg_frms_appl(phi,xyz_generator),
98 ));
99 }
100 else
101 {
102 //reg_frm is an action formula; reduce phi
103 part = must(reg_frm, translate_reg_frms_appl(phi,xyz_generator));
104 }
105 }
106 else if (state_formulas::is_may(part))
107 {
108 //part is the may operator; return equivalent non-regular formula
109 regular_formula reg_frm = may(part).formula();
112 {
113 const regular_formula R1 = seq(reg_frm).left();
114 const regular_formula R2 = seq(reg_frm).right();
115 //red(<R1.R2>phi) -> red(<R1><R2>phi)
116 part = translate_reg_frms_appl(may(R1, may(R2, phi)),xyz_generator);
117 }
118 else if (regular_formulas::is_alt(reg_frm))
119 {
120 const regular_formula R1 = alt(reg_frm).left();
121 const regular_formula R2 = alt(reg_frm).right();
122 //red(<R1+R2>phi) -> red(<R1>phi) || red(<R2>phi)
124 translate_reg_frms_appl(may(R1,phi),xyz_generator),
125 translate_reg_frms_appl(may(R2,phi),xyz_generator)
126 );
127 }
128 else if (regular_formulas::is_trans(reg_frm))
129 {
131 //red(<R+>phi) -> red(<R.R*>phi)
133 }
135 {
137 //red(<R*>phi) -> mu X. red(phi) || red(<R>X),
138 //where X does not occur free in phi and R
139 const identifier_string X =xyz_generator("X");
140 part = mu(X, assignment_list(), state_formulas::or_(
141 translate_reg_frms_appl(phi,xyz_generator),
143 ));
144 }
145 else
146 {
147 //reg_frm is an action formula; reduce phi
148 part = may(reg_frm, translate_reg_frms_appl(phi,xyz_generator));
149 }
150 }
151 else if (state_formulas::is_not(part))
152 {
153 const state_formulas::not_& not_part = atermpp::down_cast<state_formulas::not_>(part);
155 }
156 else if (state_formulas::is_minus(part))
157 {
158 const state_formulas::minus& minus_part = atermpp::down_cast<state_formulas::minus>(part);
160 }
161 else if (state_formulas::is_and(part))
162 {
165 }
166 else if (state_formulas::is_or(part))
167 {
170 }
171 else if (state_formulas::is_imp(part))
172 {
175 }
176 else if (state_formulas::is_plus(part))
177 {
180 }
182 {
185 }
187 {
190 }
191 else if (state_formulas::is_forall(part))
192 {
195 }
196 else if (state_formulas::is_exists(part))
197 {
200 }
201 else if (state_formulas::is_infimum(part))
202 {
205 }
207 {
210 }
211 else if (state_formulas::is_sum(part))
212 {
215 }
216 else if (state_formulas::is_nu(part))
217 {
218 const nu nu_part(part);
219 part = nu(nu_part.name(),nu_part.assignments(),
220 translate_reg_frms_appl(nu_part.operand(),xyz_generator));
221 }
222 else if (state_formulas::is_mu(part))
223 {
224 const mu mu_part(part);
225 part = mu(mu_part.name(),mu_part.assignments(),
226 translate_reg_frms_appl(mu_part.operand(),xyz_generator));
227 }
228 else
229 {
230 assert(0); //Unexpected state_formula.
231 }
232
233 return part;
234}
235
236} // namespace mcrl2::regular_formulas::detail
aterm(const aterm &other) noexcept=default
This class has user-declared copy constructor so declare default copy and move operators.
A unordered_map class in which aterms can be stored.
Identifier generator that generates names from the range X, Y, Z, X0, Y0, Z0, X1, ....
\brief The alt operator for regular formulas
alt(const atermpp::aterm &term)
const regular_formula & right() const
const regular_formula & left() const
\brief The seq operator for regular formulas
seq(const regular_formula &left, const regular_formula &right)
\brief Constructor Z14.
const regular_formula & right() const
const regular_formula & left() const
seq(const atermpp::aterm &term)
\brief The 'trans or nil' operator for regular formulas
trans_or_nil(const regular_formula &operand)
\brief Constructor Z14.
trans_or_nil(const atermpp::aterm &term)
const regular_formula & operand() const
\brief The trans operator for regular formulas
trans(const atermpp::aterm &term)
const regular_formula & operand() const
\brief The and operator for state formulas
const state_formula & right() const
and_(const atermpp::aterm &term)
and_(const state_formula &left, const state_formula &right)
\brief Constructor Z14.
const state_formula & left() const
\brief The multiply operator for state formulas with values
const state_formula & left() const
const_multiply_alt(const state_formula &left, const data::data_expression &right)
\brief Constructor Z14.
const data::data_expression & right() const
const_multiply_alt(const atermpp::aterm &term)
\brief The multiply operator for state formulas with values
const data::data_expression & left() const
const_multiply(const data::data_expression &left, const state_formula &right)
\brief Constructor Z14.
const_multiply(const atermpp::aterm &term)
const state_formula & right() const
\brief The existential quantification operator for state formulas
exists(const data::variable_list &variables, const state_formula &body)
\brief Constructor Z14.
const state_formula & body() const
exists(const atermpp::aterm &term)
const data::variable_list & variables() const
\brief The universal quantification operator for state formulas
const state_formula & body() const
forall(const atermpp::aterm &term)
const data::variable_list & variables() const
forall(const data::variable_list &variables, const state_formula &body)
\brief Constructor Z14.
\brief The implication operator for state formulas
imp(const state_formula &left, const state_formula &right)
\brief Constructor Z14.
const state_formula & left() const
const state_formula & right() const
imp(const atermpp::aterm &term)
\brief The infimum over a data type for state formulas
infimum(const data::variable_list &variables, const state_formula &body)
\brief Constructor Z14.
const data::variable_list & variables() const
const state_formula & body() const
infimum(const atermpp::aterm &term)
\brief The may operator for state formulas
const state_formula & operand() const
const regular_formulas::regular_formula & formula() const
may(const regular_formulas::regular_formula &formula, const state_formula &operand)
\brief Constructor Z14.
may(const atermpp::aterm &term)
\brief The minus operator for state formulas
minus(const state_formula &operand)
\brief Constructor Z14.
const state_formula & operand() const
\brief The mu operator for state formulas
const core::identifier_string & name() const
const data::assignment_list & assignments() const
mu(const core::identifier_string &name, const data::assignment_list &assignments, const state_formula &operand)
\brief Constructor Z14.
mu(const atermpp::aterm &term)
const state_formula & operand() const
\brief The must operator for state formulas
must(const atermpp::aterm &term)
must(const regular_formulas::regular_formula &formula, const state_formula &operand)
\brief Constructor Z14.
const regular_formulas::regular_formula & formula() const
const state_formula & operand() const
\brief The not operator for state formulas
const state_formula & operand() const
not_(const state_formula &operand)
\brief Constructor Z14.
\brief The nu operator for state formulas
nu(const atermpp::aterm &term)
nu(const core::identifier_string &name, const data::assignment_list &assignments, const state_formula &operand)
\brief Constructor Z14.
const core::identifier_string & name() const
const state_formula & operand() const
const data::assignment_list & assignments() const
\brief The or operator for state formulas
or_(const state_formula &left, const state_formula &right)
\brief Constructor Z14.
const state_formula & right() const
or_(const atermpp::aterm &term)
const state_formula & left() const
\brief The plus operator for state formulas with values
const state_formula & left() const
plus(const atermpp::aterm &term)
const state_formula & right() const
plus(const state_formula &left, const state_formula &right)
\brief Constructor Z14.
state_formula & operator=(state_formula &&) noexcept=default
\brief The sum over a data type for state formulas
sum(const atermpp::aterm &term)
sum(const data::variable_list &variables, const state_formula &body)
\brief Constructor Z14.
const data::variable_list & variables() const
const state_formula & body() const
\brief The supremum over a data type for state formulas
supremum(const atermpp::aterm &term)
const state_formula & body() const
const data::variable_list & variables() const
supremum(const data::variable_list &variables, const state_formula &body)
\brief Constructor Z14.
\brief The state formula variable
variable(const core::identifier_string &name, const data::data_expression_list &arguments)
\brief Constructor Z14.
bool is_data_expression(const atermpp::aterm &x)
Test for a data_expression expression.
bool is_assignment(const atermpp::aterm &x)
Definition assignment.h:152
The main namespace for the LPS library.
Definition constelm.h:18
bool is_multi_action(const atermpp::aterm &x)
state_formula translate_reg_frms(const state_formula &state_frm)
Translate regular formulas in terms of state and action formulas.
state_formula translate_reg_frms_appl(state_formula part, xyz_identifier_generator &xyz_generator)
bool is_alt(const atermpp::aterm &x)
bool is_trans(const atermpp::aterm &x)
bool is_trans_or_nil(const atermpp::aterm &x)
bool is_seq(const atermpp::aterm &x)
bool is_infimum(const atermpp::aterm &x)
bool is_and(const atermpp::aterm &x)
bool is_delay_timed(const atermpp::aterm &x)
bool is_const_multiply(const atermpp::aterm &x)
bool is_minus(const atermpp::aterm &x)
bool is_exists(const atermpp::aterm &x)
bool is_not(const atermpp::aterm &x)
bool is_supremum(const atermpp::aterm &x)
bool is_must(const atermpp::aterm &x)
bool is_yaled(const atermpp::aterm &x)
bool is_true(const atermpp::aterm &x)
bool is_variable(const atermpp::aterm &x)
bool is_may(const atermpp::aterm &x)
bool is_yaled_timed(const atermpp::aterm &x)
bool is_imp(const atermpp::aterm &x)
bool is_sum(const atermpp::aterm &x)
bool is_nu(const atermpp::aterm &x)
bool is_delay(const atermpp::aterm &x)
bool is_false(const atermpp::aterm &x)
bool is_plus(const atermpp::aterm &x)
bool is_mu(const atermpp::aterm &x)
bool is_forall(const atermpp::aterm &x)
bool is_const_multiply_alt(const atermpp::aterm &x)
bool is_or(const atermpp::aterm &x)
std::set< core::identifier_string > find_identifiers(const state_formulas::state_formula &x)