mCRL2
Loading...
Searching...
No Matches
print_utility.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_DETAIL_PRINT_UTILITY_H
13#define MCRL2_DATA_DETAIL_PRINT_UTILITY_H
14
17
18#include "mcrl2/data/bag.h"
19#include "mcrl2/data/list.h"
21#include "mcrl2/data/lambda.h"
23
24namespace mcrl2 {
25
26namespace data {
27
28namespace detail {
29
31// Real.
33inline
35{
36 // TODO Maybe enforce that SortExpr is a PNIR sort
37 return data::if_(e, data::function_symbol("1", s), data::function_symbol("0", s));
38}
39
40inline
41data_expression reconstruct_pos_mult(const data_expression& x, const std::vector<char>& result)
42{
43#ifdef MCRL2_ENABLE_MACHINENUMBERS
44 utilities::mcrl2_unused(result); // Maybe this part of this printing utility may have to be written.
45 return x;
46#else
47 data_expression reconstruction_result;
49 {
50 //x is 1; return result
51 reconstruction_result = data::function_symbol(data::detail::vector_number_to_string(result), data::sort_pos::pos());
52 }
54 {
55 //x is of the form cDub(b,p); return (result*2)*v(p) + result*v(b)
56 data_expression bool_arg = sort_pos::left(x);
58 std::vector<char> double_result = result;
59 data::detail::decimal_number_multiply_by_two(double_result);
60 pos_arg = reconstruct_pos_mult(pos_arg, double_result);
62 {
63 //result*v(b) = 0
64 reconstruction_result = pos_arg;
65 }
67 {
68 //result*v(b) = result
69 reconstruction_result = data::sort_real::plus(pos_arg,
70 data::function_symbol(data::detail::vector_number_to_string(result), data::sort_pos::pos()));
71 }
72 else if (data::detail::vector_number_to_string(result) == "1")
73 {
74 //result*v(b) = v(b)
75 reconstruction_result = data::sort_real::plus(pos_arg, bool_to_numeric(bool_arg, data::sort_nat::nat()));
76 }
77 else
78 {
79 //result*v(b)
80 reconstruction_result = data::sort_real::plus(pos_arg,
81 data::sort_real::times(data::function_symbol(data::detail::vector_number_to_string(result), data::sort_nat::nat()),
83 }
84 }
85 else
86 {
87 //x is not a Pos constructor
88 if (data::detail::vector_number_to_string(result) == "1")
89 {
90 reconstruction_result = x;
91 }
92 else
93 {
94 reconstruction_result = data::sort_real::times(data::function_symbol(data::detail::vector_number_to_string(result), data::sort_pos::pos()), x);
95 }
96 }
97 return reconstruction_result;
98#endif
99}
100
101} // namespace detail
102
103} // namespace data
104
105} // namespace mcrl2
106
107#endif // MCRL2_DATA_DETAIL_PRINT_UTILITY_H
The standard sort bag.
\brief A function symbol
\brief A sort expression
add your file description here.
The standard sort function_update.
The class lambda.
The standard sort list.
data_expression reconstruct_pos_mult(const data_expression &x, const std::vector< char > &result)
data::data_expression bool_to_numeric(const data::data_expression &e, const data::sort_expression &s)
bool is_false_function_symbol(const atermpp::aterm &e)
Recogniser for function false.
Definition bool.h:119
bool is_true_function_symbol(const atermpp::aterm &e)
Recogniser for function true.
Definition bool.h:87
const basic_sort & nat()
Constructor for sort expression Nat.
Definition nat1.h:46
bool is_cdub_application(const atermpp::aterm &e)
Recogniser for application of @cDub.
Definition pos1.h:156
bool is_c1_function_symbol(const atermpp::aterm &e)
Recogniser for function @c1.
Definition pos1.h:88
const data_expression & right(const data_expression &e)
Function for projecting out argument. right from an application.
Definition pos1.h:776
const basic_sort & pos()
Constructor for sort expression Pos.
Definition pos1.h:45
const data_expression & left(const data_expression &e)
Function for projecting out argument. left from an application.
Definition pos1.h:764
function_symbol plus(const sort_expression &s0, const sort_expression &s1)
Definition real1.h:1059
function_symbol times(const sort_expression &s0, const sort_expression &s1)
Definition real1.h:1237
function_symbol if_(const sort_expression &s)
Constructor for function symbol if.
Definition standard.h:200
void mcrl2_unused(T &&...)
Function that can be used to silence unused parameter warnings.
Definition unused.h:20
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72
Provides utilities for working with data expressions of standard sorts.
add your file description here.