mCRL2
Loading...
Searching...
No Matches
expression_traits.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//
11
12#ifndef MCRL2_DATA_EXPRESSION_TRAITS_H
13#define MCRL2_DATA_EXPRESSION_TRAITS_H
14
16#include "mcrl2/data/bool.h"
17#include "mcrl2/data/exists.h"
18#include "mcrl2/data/forall.h"
19
20namespace mcrl2
21{
22
23namespace core
24{
25
27template <>
28struct term_traits<data::data_expression>
29{
32
35
38
41 static inline
43 {
45 }
46
49 static inline
51 {
53 }
54
58 static inline
60 {
61 return data::sort_bool::not_(p);
62 }
63
67 static inline
68 void make_not_(term_type& result, const term_type& p)
69 {
71 }
72
77 static inline
78 term_type and_(const term_type& p, const term_type& q)
79 {
80 return data::sort_bool::and_(p, q);
81 }
82
87 static inline
88 void make_and_(term_type& result, const term_type& p, const term_type& q)
89 {
90 data::sort_bool::make_and_(result, p, q);
91 }
92
97 static inline
98 term_type or_(const term_type& p, const term_type& q)
99 {
100 return data::sort_bool::or_(p, q);
101 }
102
107 static inline
108 void make_or_(term_type& result, const term_type& p, const term_type& q)
109 {
110 data::sort_bool::make_or_(result, p, q);
111 }
112
117 static inline
118 term_type imp(const term_type& p, const term_type& q)
119 {
120 return data::sort_bool::implies(p, q);
121 }
122
127 static inline
128 void make_imp(term_type& result, const term_type& p, const term_type& q)
129 {
130 data::sort_bool::make_implies(result, p, q);
131 }
132
137 static inline
139 {
140 return data::forall(d, p);
141 }
142
147 static inline
148 void make_forall(term_type& result, const variable_sequence_type& d, const term_type& p)
149 {
150 return data::make_forall(result, d, p);
151 }
152
157 static inline
159 {
160 return data::exists(d, p);
161 }
162
167 static inline
168 void make_exists(term_type& result, const variable_sequence_type& d, const term_type& p)
169 {
170 return data::make_exists(result, d, p);
171 }
172
176 static inline
177 bool is_true(const term_type& t)
178 {
179 return t == data::sort_bool::true_();
180 }
181
185 static inline
186 bool is_false(const term_type& t)
187 {
188 return t == data::sort_bool::false_();
189 }
190
194 static inline
195 bool is_not(const term_type& t)
196 {
198 }
199
203 static inline
204 bool is_and(const term_type& t)
205 {
207 }
208
212 static inline
213 bool is_or(const term_type& t)
214 {
216 }
217
221 static inline
222 bool is_imp(const term_type& t)
223 {
225 }
226
230 static inline
231 bool is_forall(const term_type& t)
232 {
233 return data::is_forall(t);
234 }
235
239 static inline
240 bool is_exists(const term_type& t)
241 {
242 return data::is_exists(t);
243 }
244
248 static inline
249 bool is_lambda(const term_type& t)
250 {
251 return data::is_lambda(t);
252 }
253
257 static inline
259 {
260 return v;
261 }
262
266 static inline
267 bool is_variable(const term_type& t)
268 {
269 return data::is_variable(t);
270 }
271
277 static inline
278 const term_type& argument(const term_type& t, const std::size_t n)
279 {
280 assert(data::is_application(t));
281 const data::application& a=atermpp::down_cast<data::application>(t);
282 assert(a.size()>n);
284 for(std::size_t j=0; j<n; ++j, ++i)
285 {
286 assert(i!=a.end());
287 }
288 assert(i!=a.end());
289 return *i;
290 }
291
292 static inline
293 const term_type& left(const term_type& t)
294 {
295 assert(data::is_application(t));
296 const data::application& a=atermpp::down_cast<data::application>(t);
297 assert(a.size() == 2);
298 return *(a.begin());
299 }
300
301 static inline
302 const term_type& right(const term_type& t)
303 {
304 assert(data::is_application(t));
305 const data::application& a=atermpp::down_cast<data::application>(t);
306 assert(a.size() == 2);
307 return *(++(a.begin()));
308 }
309
310 static inline
311 const term_type& not_arg(const term_type& t)
312 {
313 assert(is_not(t));
314 assert(data::is_application(t));
315 const data::application& a=atermpp::down_cast<data::application>(t);
316 assert(a.size() == 1);
317 return *(a.begin());
318 }
319
323 static inline
324 std::string pp(const term_type& t)
325 {
326 return data::pp(t);
327 }
328};
329
330} // namespace core
331
332namespace data
333{
335template < typename Expression >
336struct expression_traits : public core::term_traits< Expression >
337{
338 // Type of expression that represents variables
340
341 static bool is_true(const data_expression& e)
342 {
344 }
345
346 static bool is_false(const data_expression& e)
347 {
349 }
350
351 static bool is_application(const data_expression& e)
352 {
353 return data::is_application(e);
354 }
355
356 static bool is_abstraction(const data_expression& e)
357 {
358 return data::is_abstraction(e);
359 }
360
361 static const data_expression& head(const data_expression& e)
362 {
363 return atermpp::down_cast<mcrl2::data::application>(e).head();
364 }
365
367 {
368 return atermpp::container_cast<data_expression_list>(atermpp::down_cast<abstraction>(a).variables());
369 }
370
371 static const data_expression& body(const data_expression& a)
372 {
373 return atermpp::down_cast<const abstraction>(a).body();
374 }
375
376 static data_expression replace_body(const data_expression& variable_binder, const data_expression& new_body)
377 {
378 const abstraction& a=atermpp::down_cast<const abstraction>(variable_binder);
379 return abstraction(a.binding_operator(), a.variables(), new_body);
380 }
381
382 template < typename Container >
383 static application application(const data_expression& e, const Container& arguments)
384 {
385 return application(e, arguments);
386 }
387
388 static const data_expression& false_()
389 {
390 return sort_bool::false_();
391 }
392
393 static const data_expression& true_()
394 {
395 return sort_bool::true_();
396 }
397
399 {
400 return sort_bool::and_(e1, e2);
401 }
402
404 {
405 return sort_bool::or_(e1, e2);
406 }
407};
408
409} // namespace data
410
411} // namespace mcrl2
412
413#endif // MCRL2_DATA_EXPRESSION_TRAITS_H
The standard sort bool_.
Iterator for term_appl.
An abstraction expression.
Definition abstraction.h:26
const variable_list & variables() const
Definition abstraction.h:63
const binder_type & binding_operator() const
Definition abstraction.h:58
An application of a data expression to a number of arguments.
const_iterator end() const
Returns an iterator pointing past the last argument of the application.
const_iterator begin() const
Returns an iterator pointing to the first argument of the application.
std::size_t size() const
existential quantification.
Definition exists.h:26
universal quantification.
Definition forall.h:26
\brief A data variable
Definition variable.h:28
The class exists.
The class forall.
bool is_false_function_symbol(const atermpp::aterm &e)
Recogniser for function false.
Definition bool.h:119
bool is_or_application(const atermpp::aterm &e)
Recogniser for application of ||.
Definition bool.h:345
const function_symbol & implies()
Constructor for function symbol =>.
Definition bool.h:363
bool is_implies_application(const atermpp::aterm &e)
Recogniser for application of =>.
Definition bool.h:409
const function_symbol & and_()
Constructor for function symbol &&.
Definition bool.h:235
const function_symbol & false_()
Constructor for function symbol false.
Definition bool.h:109
bool is_and_application(const atermpp::aterm &e)
Recogniser for application of &&.
Definition bool.h:281
const function_symbol & or_()
Constructor for function symbol ||.
Definition bool.h:299
bool is_true_function_symbol(const atermpp::aterm &e)
Recogniser for function true.
Definition bool.h:87
bool is_not_application(const atermpp::aterm &e)
Recogniser for application of !.
Definition bool.h:217
const function_symbol & not_()
Constructor for function symbol !.
Definition bool.h:173
void make_not_(data_expression &result, const data_expression &arg0)
Make an application of function symbol !.
Definition bool.h:207
void make_and_(data_expression &result, const data_expression &arg0, const data_expression &arg1)
Make an application of function symbol &&.
Definition bool.h:271
const function_symbol & true_()
Constructor for function symbol true.
Definition bool.h:77
void make_or_(data_expression &result, const data_expression &arg0, const data_expression &arg1)
Make an application of function symbol ||.
Definition bool.h:335
void make_implies(data_expression &result, const data_expression &arg0, const data_expression &arg1)
Make an application of function symbol =>.
Definition bool.h:399
bool is_abstraction(const atermpp::aterm &x)
Returns true if the term t is an abstraction.
std::string pp(const abstraction &x)
Definition data.cpp:39
void make_forall(atermpp::aterm &result, ARGUMENTS... arguments)
Definition forall.h:64
bool is_forall(const atermpp::aterm &x)
Returns true if the term t is a universal quantification.
bool is_exists(const atermpp::aterm &x)
Returns true if the term t is an existential quantification.
bool is_lambda(const atermpp::aterm &x)
Returns true if the term t is a lambda abstraction.
void make_exists(atermpp::aterm &result, ARGUMENTS... arguments)
Definition exists.h:64
bool is_application(const atermpp::aterm &x)
Returns true if the term t is an application.
bool is_variable(const atermpp::aterm &x)
Returns true if the term t is a variable.
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72
static bool is_and(const term_type &t)
Test for operator and.
static void make_imp(term_type &result, const term_type &p, const term_type &q)
Operator imp.
static bool is_variable(const term_type &t)
Test if a term is a variable.
static const term_type & not_arg(const term_type &t)
static const term_type & argument(const term_type &t, const std::size_t n)
Get the n-th argument of a data expression, provided it is an application.
static term_type or_(const term_type &p, const term_type &q)
Operator or.
static term_type exists(const variable_sequence_type &d, const term_type &p)
Operator exists.
static void make_forall(term_type &result, const variable_sequence_type &d, const term_type &p)
Construct a forall.
static bool is_false(const term_type &t)
Test for value false.
static bool is_exists(const term_type &t)
Test for existential quantification.
static term_type imp(const term_type &p, const term_type &q)
Operator imp.
static term_type and_(const term_type &p, const term_type &q)
Operator and.
data::data_expression term_type
The term type.
static term_type not_(const term_type &p)
Operator not.
static bool is_lambda(const term_type &t)
Test for lambda abstraction.
static void make_exists(term_type &result, const variable_sequence_type &d, const term_type &p)
Construct an exists.
static void make_or_(term_type &result, const term_type &p, const term_type &q)
Operator or.
static const term_type & right(const term_type &t)
static bool is_true(const term_type &t)
Test for value true.
static const term_type & true_()
The value true.
static term_type forall(const variable_sequence_type &d, const term_type &p)
Operator forall.
data::variable_list variable_sequence_type
The variable sequence type.
static bool is_not(const term_type &t)
Test for operator not.
static const term_type & left(const term_type &t)
static bool is_or(const term_type &t)
Test for operator or.
static void make_and_(term_type &result, const term_type &p, const term_type &q)
Operator and.
static const term_type & variable2term(const variable_type &v)
Conversion from variable to term.
static bool is_imp(const term_type &t)
Test for implication.
static void make_not_(term_type &result, const term_type &p)
Operator not.
static bool is_forall(const term_type &t)
Test for universal quantification.
static const term_type & false_()
The value false.
static std::string pp(const term_type &t)
Pretty print function.
Contains type information for terms.
Definition term_traits.h:24
expression traits (currently nothing more than core::term_traits)
static application application(const data_expression &e, const Container &arguments)
static const data_expression_list & variables(const data_expression &a)
static const data_expression & false_()
static bool is_false(const data_expression &e)
static data_expression and_(const data_expression &e1, const data_expression &e2)
mcrl2::data::variable variable_type
static const data_expression & head(const data_expression &e)
static const data_expression & true_()
static data_expression replace_body(const data_expression &variable_binder, const data_expression &new_body)
static data_expression or_(const data_expression &e1, const data_expression &e2)
static bool is_application(const data_expression &e)
static const data_expression & body(const data_expression &a)
static bool is_true(const data_expression &e)
static bool is_abstraction(const data_expression &e)
Traits class for (boolean) terms.