mCRL2
Loading...
Searching...
No Matches
print.h
Go to the documentation of this file.
1// Author(s): Jeroen van der Wulp, 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_PRINT_H
13#define MCRL2_DATA_PRINT_H
14
19
20namespace mcrl2
21{
22
23namespace data
24{
25
26namespace detail {
27
28// Check that the argument, which must be of sort Pos, represents 1.
29inline
30bool is_one(const data_expression& x)
31{
32 assert(x.sort() == sort_pos::pos());
33#ifdef MCRL2_ENABLE_MACHINENUMBERS
35 (( is_machine_number(sort_pos::arg(x)) && atermpp::down_cast<machine_number>(sort_pos::arg(x)).value() == 1) ||
37 ) ||
39#else
41#endif
42}
43
44inline
46{
53#ifndef MCRL2_ENABLE_MACHINENUMBERS
56#endif
58 ;
59}
60
61inline bool look_through_numeric_casts(const data_expression& x, std::function<bool(const data_expression&)> f)
62{
63 if (is_numeric_cast(x))
64 {
65 return look_through_numeric_casts(atermpp::down_cast<application>(x)[0], f);
66 }
67 return f(x);
68}
69
70// Check whether this term is an applicatino with a head of the shape "UntypedIdentifier(s)" for
71// the given string s.
73{
74 if (is_application(x))
75 {
76 const data_expression& h=atermpp::down_cast<application>(x).head();
78 {
79 const untyped_identifier& u=atermpp::down_cast<untyped_identifier>(h);
80 return u.name()==s;
81 }
82 }
83 return false;
84}
85
86/* inline
87data_expression remove_numeric_casts(data_expression x)
88{
89 while (is_numeric_cast(x))
90 {
91 x = *atermpp::down_cast<application>(x).begin();
92 }
93 return x;
94} */
95
96inline
97bool is_plus(const application& x)
98{
100 x,
101 [](const data_expression& x)
102 {
103 return // sort_int::is_plus_application(x) ||
104 // sort_nat::is_plus_application(x) ||
105 // sort_pos::is_plus_application(x) ||
108}
109
110inline
111bool is_minus(const application& x)
112{
114 x,
115 [](const data_expression& x)
116 { return // sort_int::is_minus_application(x) ||
119}
120
121inline
122bool is_mod(const application& x)
123{
125 x,
126 [](const data_expression& x)
127 { return sort_int::is_mod_application(x) ||
129}
130
131inline
132bool is_div(const application& x)
133{
135 x,
136 [](const data_expression& x)
137 { return sort_int::is_div_application(x) ||
139}
140
141#ifndef MCRL2_ENABLE_MACHINENUMBERS
142inline
143bool is_divmod(const application& x)
144{
146 x,
147 [](const data_expression& x)
148 { return sort_nat::is_divmod_application(x); });
149}
150#endif
151
152inline
154{
156 x,
157 [](const data_expression& x)
160}
161
162inline
164{
166}
167
168inline
170{
172}
173
174inline
176{
178}
179
180inline
182{
184}
185
186inline
188{
190}
191
192inline
193bool is_and(const application& x)
194{
196}
197
198inline
199bool is_or(const application& x)
200{
202}
203
204inline
206{
208}
209
210inline
212{
214}
215
216inline
217bool is_less(const application& x)
218{
220}
221
222inline
224{
226}
227
228inline
230{
232}
233
234inline
236{
238}
239
240inline
241bool is_in(const application& x)
242{
244}
245
246inline
247bool is_times(const application& x)
248{
250 x,
251 [](const data_expression& x)
252 { return sort_int::is_times_application(x) ||
254}
255
256inline
258{
260}
261
262inline
264{
266}
267
268inline
270{
272}
273
274inline
275bool is_concat(const application& x)
276{
278}
279
280inline
282{
284 {
285 x = sort_list::right(x);
286 }
288}
289
290inline
292{
294 {
295 x = sort_list::left(x);
296 }
298}
299
300inline
301bool is_cons(const application& x)
302{
304}
305
306inline
307bool is_snoc(const application& x)
308{
310}
311
312} // namespace detail
313
314int precedence(const data_expression& x);
315
316inline
318{
319 // N.B. this code should match printing of a creal
321 {
322 const data_expression& numerator = sort_real::left(x);
323 const data_expression& denominator = sort_real::right(x);
324 // if (sort_pos::is_c1_function_symbol(denominator))
325 if (detail::is_one(denominator))
326 {
327 return precedence(numerator);
328 }
329 else
330 {
331 return precedence(sort_real::divides(numerator, sort_int::pos2int(denominator)));
332 }
333 }
334 else if (detail::is_implies(x))
335 {
336 return 2;
337 }
338 else if (detail::is_or(x))
339 {
340 return 3;
341 }
342 else if (detail::is_and(x))
343 {
344 return 4;
345 }
346 else if (detail::is_equal_to(x) ||
348 )
349 {
350 return 5;
351 }
352 else if ( detail::is_less(x)
356 || detail::is_in(x)
357 )
358 {
359 return 6;
360 }
361 else if (detail::is_cons(x))
362 {
363 return 7;
364 }
365 else if (detail::is_snoc(x))
366 {
367 return 8;
368 }
369 else if (detail::is_concat(x))
370 {
371 return 9;
372 }
373 else if ( detail::is_plus(x)
374 || detail::is_minus(x)
379 )
380 {
381 return 10;
382 }
383 else if ( detail::is_div(x)
384 || detail::is_mod(x)
385#ifndef MCRL2_ENABLE_MACHINENUMBERS
387#endif
389 )
390 {
391 return 11;
392 }
393 else if ( detail::is_times(x)
397 )
398 {
399 return 12;
400 }
402 {
403 return 13;
404 }
405 // TODO: add function application (there seems to be no recognizer for it)
406 return core::detail::max_precedence;
407}
408
409constexpr int precedence(const forall&) { return 1; }
410constexpr int precedence(const exists&) { return 1; }
411constexpr int precedence(const lambda&) { return 1; }
412constexpr int precedence(const set_comprehension&) { return core::detail::max_precedence; }
413constexpr int precedence(const bag_comprehension&) { return core::detail::max_precedence; }
414constexpr int precedence(const where_clause&) { return 0; }
415inline int precedence(const data_expression& x)
416{
417 if (data::is_application(x)) { return precedence(atermpp::down_cast<application>(x)); }
418 else if (data::is_forall(x)) { return precedence(atermpp::down_cast<forall>(x)); }
419 else if (data::is_exists(x)) { return precedence(atermpp::down_cast<exists>(x)); }
420 else if (data::is_lambda(x)) { return precedence(atermpp::down_cast<lambda>(x)); }
421 else if (data::is_set_comprehension(x)) { return precedence(atermpp::down_cast<set_comprehension>(x)); }
422 else if (data::is_bag_comprehension(x)) { return precedence(atermpp::down_cast<bag_comprehension>(x)); }
423 else if (data::is_where_clause(x)) { return precedence(atermpp::down_cast<where_clause>(x)); }
424 return core::detail::max_precedence;
425}
426
427inline
429{
431}
432
433inline
435{
436 if (!is_application(x))
437 {
438 return false;
439 }
440 const auto& x_ = atermpp::down_cast<application>(x);
441 return !detail::is_minus(x_) && !is_equal_to_application(x);
442}
443
444namespace detail
445{
446
447template <typename Derived>
448struct printer: public data::add_traverser_sort_expressions<core::detail::printer, Derived>
449{
451
452 using super::enter;
453 using super::leave;
454 using super::apply;
455 using super::derived;
456 using super::print_expression;
457 using super::print_unary_operand;
458 using super::print_list;
459
460 void print_unary_data_operation(const application& x, const std::string& op)
461 {
462 derived().print(op);
463 print_expression(x[0], precedence(x[0]) < precedence(x));
464 }
465
466 void print_binary_data_operation(const application& x, const data_expression& x1, const data_expression& x2, const std::string& op)
467 {
468 const int p = precedence(x);
469 const int p1 = precedence(x1);
470 const int p2 = precedence(x2);
471 print_expression(x1, (p1 < p) || (p1 == p && !is_left_associative(x)));
472 derived().print(op);
473 print_expression(x2, (p2 < p) || (p2 == p && !is_right_associative(x)));
474 }
475
476 void print_binary_data_operation(const application& x, const std::string& op)
477 {
478 const data_expression& x1 = x[0];
479 const data_expression& x2 = x[1];
480 print_binary_data_operation(x, x1, x2, op);
481 }
482
483 bool is_infix_operation(const application& x) const
484 {
485 if (x.size() != 2)
486 {
487 return false;
488 }
490 if (is_function_symbol(x.head()))
491 {
492 name = function_symbol(x.head()).name();
493 }
494 else if (is_untyped_identifier(x.head()))
495 {
496 name = untyped_identifier(x.head()).name();
497 }
498 else
499 {
500 return false;
501 }
502 return
503 (name == data::sort_bool::implies_name()) ||
504 (name == data::sort_bool::and_name()) ||
505 (name == data::sort_bool::or_name()) ||
506 data::detail::equal_symbol::is_symbol(name) ||
507 data::detail::not_equal_symbol::is_symbol(name) ||
508 data::detail::less_symbol::is_symbol(name) ||
509 data::detail::less_equal_symbol::is_symbol(name) ||
510 data::detail::greater_symbol::is_symbol(name) ||
511 data::detail::greater_equal_symbol::is_symbol(name) ||
512 (name == data::sort_list::in_name()) ||
513 (name == data::sort_list::cons_name()) ||
514 (name == data::sort_list::snoc_name()) ||
515 (name == data::sort_list::concat_name()) ||
516 (name == data::sort_real::plus_name()) ||
517 (name == data::sort_real::minus_name()) ||
518 (name == data::sort_set::union_name()) ||
519 (name == data::sort_fset::union_name()) ||
522 (name == data::sort_bag::union_name()) ||
523 (name == data::sort_fbag::union_name()) ||
526 (name == data::sort_int::div_name()) ||
527 (name == data::sort_int::mod_name()) ||
528 (name == data::sort_real::divides_name()) ||
529 (name == data::sort_int::times_name()) ||
533 }
534
535 core::identifier_string generate_identifier(const std::string& prefix, const data_expression& context) const
536 {
538 std::set<variable> variables = data::find_all_variables(context);
539 for (const variable& v: variables)
540 {
541 generator.add_identifier(v.name());
542 }
543 return generator(prefix);
544 }
545
546 template <typename Container>
547 void print_container(const Container& container,
548 int container_precedence = -1,
549 const std::string& separator = ", ",
550 const std::string& open_bracket = "(",
551 const std::string& close_bracket = ")"
552 )
553 {
554 for (auto i = container.begin(); i != container.end(); ++i)
555 {
556 if (i != container.begin())
557 {
558 derived().print(separator);
559 }
560 bool print_brackets = (container.size() > 1) && (precedence(*i) < container_precedence);
561 if (print_brackets)
562 {
563 derived().print(open_bracket);
564 }
565 derived().apply(*i);
566 if (print_brackets)
567 {
568 derived().print(close_bracket);
569 }
570 }
571 }
572
573 template <typename Variable>
574 void print_variable(const Variable& x, bool print_sort = false)
575 {
576 derived().apply(x);
577 if (print_sort)
578 {
579 derived().print(": ");
580 derived().apply(x.sort());
581 }
582 }
583
585 {
586 template <typename T>
587 sort_expression operator()(const T& t) const
588 {
589 return t.sort();
590 }
591 };
592
593 template <typename Container, typename SortAccessor>
594 void print_sorted_declarations(const Container& container,
595 bool print_sorts = true,
596 bool join_sorts = true,
597 bool maximally_shared = false,
598 const std::string& opener = "(",
599 const std::string& closer = ")",
600 const std::string& separator = ", ",
601 SortAccessor get_sort = get_sort_default()
602 )
603 {
604 auto first = container.begin();
605 auto last = container.end();
606 if (first == last)
607 {
608 return;
609 }
610
611 derived().print(opener);
612
613 if (maximally_shared)
614 {
615 typedef typename Container::value_type T;
616
617 // sort_map[s] will contain all elements t of container with t.sort() == s.
618 std::map<sort_expression, std::vector<T> > sort_map;
619
620 // sorts will contain all sort expressions s that appear as a key in sort_map,
621 // in the order they are encountered in container
622 std::vector<sort_expression> sorts;
623
624 for (auto i = container.begin(); i != container.end(); ++i)
625 {
626 if (sort_map.find(i->sort()) == sort_map.end())
627 {
628 sorts.push_back(i->sort());
629 }
630 sort_map[i->sort()].push_back(*i);
631 }
632
633 // do the actual printing
634 for (auto i = sorts.begin(); i != sorts.end(); ++i)
635 {
636 if (i != sorts.begin())
637 {
638 derived().print(separator);
639 }
640 const std::vector<T>& v = sort_map[*i];
641 print_list(v, "", "", ",");
642 derived().print(": ");
643 derived().apply(*i);
644 }
645 }
646 else
647 {
648 while (first != last)
649 {
650 if (first != container.begin())
651 {
652 derived().print(separator);
653 }
654
655 if (print_sorts && join_sorts)
656 {
657 // determine a consecutive interval [first, i) with elements of the same sorts
658 auto i = first;
659 do
660 {
661 ++i;
662 }
663
664 // print the elements of the interval [first, i)
665 while (i != last && i->sort() == first->sort());
666
667 for (auto j = first; j != i; ++j)
668 {
669 if (j != first)
670 {
671 derived().print(",");
672 }
673 derived().apply(*j);
674 }
675
676 // print the sort
677 if (print_sorts)
678 {
679 derived().print(": ");
680 derived().apply(get_sort(*first));
681 }
682
683 // update first
684 first = i;
685 }
686 else
687 {
688 derived().apply(*first);
689
690 // print the sort
691 if (print_sorts)
692 {
693 derived().print(": ");
694 derived().apply(get_sort(*first));
695 }
696
697 // update first
698 ++first;
699 }
700 }
701 }
702 derived().print(closer);
703 }
704
705 template <typename Container>
706 void print_variables(const Container& container,
707 bool print_sorts = true,
708 bool join_sorts = true,
709 bool maximally_shared = false,
710 const std::string& opener = "(",
711 const std::string& closer = ")",
712 const std::string& separator = ", "
713 )
714 {
715 print_sorted_declarations(container, print_sorts, join_sorts, maximally_shared, opener, closer, separator, get_sort_default());
716 }
717
718 template <typename Container>
719 void print_assignments(const Container& container,
720 bool print_lhs = true,
721 const std::string& opener = "",
722 const std::string& closer = "",
723 const std::string& separator = ", ",
724 const std::string& assignment_symbol = " = "
725 )
726 {
727 if (container.empty())
728 {
729 return;
730 }
731 derived().print(opener);
732 for (typename Container::iterator i = container.begin(); i != container.end(); ++i)
733 {
734 if (i != container.begin())
735 {
736 derived().print(separator);
737 }
738 if (print_lhs)
739 {
740 derived().apply(i->lhs());
741 derived().print(assignment_symbol);
742 }
743 derived().apply(i->rhs());
744 }
745 derived().print(closer);
746 }
747
748 template <typename T>
749 void print_condition(const T& x, const std::string& arrow = " -> ")
750 {
752 {
753 print_expression(x, true);
754 derived().print(arrow);
755 }
756 }
757
758 template <typename Container>
759 void print_sort_list(const Container& container,
760 const std::string& opener = "(",
761 const std::string& closer = ")",
762 const std::string& separator = ", "
763 )
764 {
765 if (container.empty())
766 {
767 return;
768 }
769 derived().print(opener);
770 for (auto i = container.begin(); i != container.end(); ++i)
771 {
772 if (i != container.begin())
773 {
774 derived().print(separator);
775 }
776 bool print_brackets = is_function_sort(*i);
777 if (print_brackets)
778 {
779 derived().print("(");
780 }
781 derived().apply(*i);
782 if (print_brackets)
783 {
784 derived().print(")");
785 }
786 }
787 derived().print(closer);
788 }
789
791 {
792 derived().print("[");
794 derived().print("]");
795 }
796
798 {
799 derived().print("{ ");
801 derived().print(" }");
802 }
803
805 {
806 derived().print("{ ");
808 while (i != x.end())
809 {
810 if (i != x.begin())
811 {
812 derived().print(", ");
813 }
814 derived().apply(*i++);
815 derived().print(": ");
816 derived().apply(*i++);
817 }
818 derived().print(" }");
819 }
820
822 {
823 derived().print("{ ");
824 print_variables(x.variables(), true, true, false, "", "", ", ");
825 derived().print(" | ");
826 derived().apply(x.body());
827 derived().print(" }");
828 }
829
831 {
832 return is_abstraction(x.head());
833 }
834
836 {
838 {
839 x = sort_list::right(x);
840 }
842 }
843
845 {
847 {
848 x = sort_list::left(x);
849 }
851 }
852
854 {
856 {
857 x = sort_fset::right(x);
858 }
860 }
861
864 {
866 {
867 x = sort_fbag::arg3(x);
868 }
870 }
871
873 {
874 return sort_pos::is_pos(x.sort())
875 || sort_nat::is_nat(x.sort())
876 || sort_int::is_int(x.sort())
877 || sort_real::is_real(x.sort());
878 }
879
881 {
882 return sort_pos::is_pos(x)
884 || sort_nat::is_nat(x)
885 || sort_int::is_int(x)
886 || sort_real::is_real(x);
887 }
888
890 {
892 }
893
895 {
897 }
898
900 {
902 }
903
905 {
907 }
908
910 {
912 }
913
915 {
917 }
918
920 {
921 data_expression_vector arguments;
923 {
924 arguments.push_back(sort_list::left(x));
925 x = sort_list::right(x);
926 }
927 derived().print("[");
928 print_container(arguments, 6);
929 derived().print("]");
930 }
931
933 {
934 data_expression_vector arguments;
936 {
937 arguments.insert(arguments.begin(), sort_list::right(x));
938 x = sort_list::left(x);
939 }
940 derived().print("[");
941 print_container(arguments, 7);
942 derived().print("]");
943 }
944
946 {
947 data_expression_vector arguments;
949 {
950 arguments.push_back(sort_fset::left(x));
951 x = sort_fset::right(x);
952 }
953 derived().print("{");
954 print_container(arguments, 6);
955 derived().print("}");
956 }
957
959 {
960 // TODO: check if this is the correct way to handle this case
963 {
964 derived().print("{:}");
965 }
966 else if (data::is_variable(y))
967 {
968 derived().print("@bagfbag(");
969 derived().apply(variable(y).name());
970 derived().print(")");
971 }
972 else
973 {
974 derived().apply(y);
975 }
976 }
977
979 {
980 sort_expression s = function_sort(sort_bag::left(x).sort()).domain().front(); // the sort of the bag elements
982 variable var(name, s);
983 data_expression body = number(sort_nat::nat(), "1");
985 {
987 }
988 derived().print("{ ");
989 print_variable(var, true);
990 derived().print(" | ");
991 derived().apply(body);
992 derived().print(" }");
993 }
994
996 {
997 sort_expression s = function_sort(sort_bag::left(x).sort()).domain().front(); // the sort of the bag elements
999 variable var(name, s);
1001 data_expression body = left.body();
1003 {
1005 }
1006 derived().print("{ ");
1007 print_variables(left.variables(), true, true, false, "", "", ", ");
1008 derived().print(" | ");
1009 derived().apply(body);
1010 derived().print(" }");
1011 }
1012
1014 {
1017 variable var(name, s);
1018 data_expression body = sort_bag::left(x)(var);
1020 {
1022 }
1023 derived().print("{ ");
1024 print_variable(var, true);
1025 derived().print(" | ");
1026 derived().apply(body);
1027 derived().print(" }");
1028 }
1029
1031 {
1032 std::vector<std::pair<data_expression, data_expression> > arguments;
1034 {
1036 {
1037 arguments.emplace_back(sort_fbag::arg1(x), sort_fbag::arg2(x));
1038 x = sort_fbag::arg3(x);
1039 }
1041 {
1042#ifdef MCRL2_ENABLE_MACHINENUMBERS
1043 arguments.emplace_back(sort_fbag::arg1(x), sort_nat::pos2nat(sort_fbag::arg2(x)));
1044#else
1045 arguments.emplace_back(sort_fbag::arg1(x), sort_nat::cnat(sort_fbag::arg2(x)));
1046#endif
1047 x = sort_fbag::arg3(x);
1048 }
1049 else // if (sort_fbag::is_fbagcinsert_application(x))
1050 {
1051 arguments.emplace_back(sort_fbag::arg1(x), sort_fbag::arg2(x));
1052 x = sort_fbag::arg3(x);
1053 }
1054 }
1055 print_list(arguments, "{", "}");
1056 }
1057
1059 {
1060 derived().print("!");
1061 derived().apply(sort_set::right(x));
1062 }
1063
1065 {
1067 {
1068 derived().print("{}");
1069 }
1070 else
1071 {
1072 derived().apply(sort_set::right(x));
1073 }
1074 }
1075
1077 {
1079 derived().print("{ ");
1080 print_variables(left.variables(), true, true, false, "", "", ", ");
1081 derived().print(" | ");
1082 derived().apply(left.body());
1083 derived().print(" }");
1084 }
1085
1086 void print_fset_set_operation(const data_expression& x, const std::string& op)
1087 {
1090
1091 // print lhs
1093 {
1094 derived().apply(sort_set::arg3(x));
1095 }
1097 {
1098 derived().print("!");
1099 derived().apply(sort_set::arg3(x));
1100 }
1101 else if (is_function_sort(sort_set::arg1(x).sort()))
1102 {
1103 const sort_expression sort = sort_set::arg1(x).sort();
1104 const sort_expression& s = atermpp::down_cast<function_sort>(sort).domain().front();
1106 variable var(name, s);
1108 derived().print("{ ");
1109 print_variable(var, true);
1110 derived().print(" | ");
1111 derived().apply(body);
1112 derived().print(" }");
1113 }
1114 else
1115 {
1116 // In this case the term is not well formed, for instance because it contains a "Rewritten@@term" function.
1117 // We print the residue as an aterm.
1118 derived().print(pp(atermpp::aterm(x)));
1119 return;
1120 }
1121
1122 // print operator
1123 derived().print(op);
1124
1125 // print rhs
1127 {
1128 derived().apply(sort_set::arg4(x));
1129 }
1131 {
1132 derived().print("!");
1133 derived().apply(sort_set::arg4(x));
1134 }
1135 else
1136 {
1139 variable var(name, s);
1141 derived().print("{ ");
1142 print_variable(var, true);
1143 derived().print(" | ");
1144 derived().apply(body);
1145 derived().print(" }");
1146 }
1147 }
1148
1150 {
1152 // TODO: check if this is the correct way to handle this case
1154 {
1157 variable var(name, s);
1158 data_expression body(sort_set::left(x)(var));
1159 derived().print("{ ");
1160 print_variable(var, true);
1161 derived().print(" | ");
1162 derived().apply(body);
1163 derived().print(" }");
1164 }
1165 else
1166 {
1169 variable var(name, s);
1170 data_expression lhs(sort_set::left(x)(var));
1171 data_expression rhs(sort_set::in(s, var, sort_set::set_fset(s, right)));
1172 data_expression body = not_equal_to(lhs, rhs);
1173 derived().print("{ ");
1174 print_variable(var, true);
1175 derived().print(" | ");
1176 derived().apply(body);
1177 derived().print(" }");
1178 }
1179 }
1180
1181 template <typename Abstraction>
1182 void print_abstraction(const Abstraction& x, const std::string& op)
1183 {
1184 derived().enter(x);
1185 derived().print(op + " ");
1186 print_variables(x.variables(), true, true, false, "", "", ", ");
1187 derived().print(". ");
1188 derived().apply(x.body());
1189 derived().leave(x);
1190 }
1191
1193 {
1194 // Add special handling of list/set/bag enumeration types. This case applies to printing
1195 // terms after parsing and before type checking.
1197 {
1199 return;
1200 }
1202 {
1204 return;
1205 }
1207 {
1209 return;
1210 }
1211
1212 if (is_infix_operation(x))
1213 {
1214 assert(detail::is_untyped(x));
1215 auto i = x.begin();
1216 data_expression left = *i++;
1217 data_expression right = *i;
1218
1219
1220 print_expression(left, precedence(left)<precedence(x));
1221 derived().print(" ");
1222 derived().apply(x.head());
1223 derived().print(" ");
1224 print_expression(right, precedence(right)<precedence(x));
1225 return;
1226 }
1227
1228 // print the head
1229 bool print_parentheses = is_abstraction(x.head());
1230 if (print_parentheses)
1231 {
1232 derived().print("(");
1233 }
1234 derived().apply(x.head());
1235 if (print_parentheses)
1236 {
1237 derived().print(")");
1238 }
1239
1240 // print the arguments
1241 print_parentheses = !x.empty();
1242 if (is_function_symbol(x.head()) && x.size() == 1)
1243 {
1244 std::string name(function_symbol(x.head()).name());
1245 if (name == "!" || name == "#")
1246 {
1247 print_parentheses = precedence(*x.begin()) < core::detail::max_precedence;
1248 }
1249 }
1250 if (print_parentheses)
1251 {
1252 derived().print("(");
1253 }
1254 print_container(x);
1255 if (print_parentheses)
1256 {
1257 derived().print(")");
1258 }
1259 }
1260
1261 // N.B. This is interpreted as the bag element 'x.first: x.second'
1262 void apply(const std::pair<data_expression, data_expression>& x)
1263 {
1264 derived().apply(x.first);
1265 derived().print(": ");
1266 derived().apply(x.second);
1267 }
1268
1269 // TODO: this code should be generated!
1271 {
1272 derived().enter(x);
1274 {
1275 derived().apply(data::list_container(atermpp::aterm(x)));
1276 }
1277 else if (data::is_set_container(x))
1278 {
1279 derived().apply(data::set_container(atermpp::aterm(x)));
1280 }
1281 else if (data::is_bag_container(x))
1282 {
1283 derived().apply(data::bag_container(atermpp::aterm(x)));
1284 }
1285 else if (data::is_fset_container(x))
1286 {
1287 derived().apply(data::fset_container(atermpp::aterm(x)));
1288 }
1289 else if (data::is_fbag_container(x))
1290 {
1291 derived().apply(data::fbag_container(atermpp::aterm(x)));
1292 }
1293 derived().leave(x);
1294 }
1295
1297 {
1298 derived().enter(x);
1299 derived().apply(x.lhs());
1300 derived().print(" = ");
1301 derived().apply(x.rhs());
1302 derived().leave(x);
1303 }
1304
1305 // variable lists have their own notation
1307 {
1308 derived().enter(x);
1309 print_list(x, "", "", ", ", false);
1310 derived().leave(x);
1311 }
1312
1314 {
1315 derived().enter(x);
1316 derived().apply(x.name());
1317 print_list(x.arguments(), "(", ")", ", ");
1318 derived().leave(x);
1319 }
1320
1322 {
1323 derived().enter(x);
1324 derived().apply(x.lhs());
1325 derived().print("=");
1326 derived().apply(x.rhs());
1327 derived().leave(x);
1328 }
1329
1331 {
1332 derived().enter(x);
1333 derived().leave(x);
1334 }
1335
1337 {
1338 derived().enter(x);
1339 derived().leave(x);
1340 }
1341
1343 {
1344 derived().enter(x);
1345 derived().leave(x);
1346 }
1347
1349 {
1350 derived().enter(x);
1351 derived().leave(x);
1352 }
1353
1355 {
1356 derived().enter(x);
1357 derived().leave(x);
1358 }
1359
1361 {
1362 derived().enter(x);
1363 derived().leave(x);
1364 }
1365
1367 {
1368 derived().enter(x);
1370 {
1371 derived().apply(x.name());
1372 derived().print(": ");
1373 }
1374 derived().apply(x.sort());
1375 derived().leave(x);
1376 }
1377
1379 {
1380 derived().enter(x);
1381 derived().apply(x.name());
1382 print_list(x.arguments(), "(", ")", ", ");
1384 {
1385 derived().print("?");
1386 derived().apply(x.recogniser());
1387 }
1388 derived().leave(x);
1389 }
1390
1391 void apply(const data::alias& x)
1392 {
1393 derived().enter(x);
1394 derived().apply(x.name());
1395 derived().print(" = ");
1396 derived().apply(x.reference());
1397 derived().leave(x);
1398 }
1399
1401 {
1402 derived().enter(x);
1403 derived().print("List");
1404 derived().leave(x);
1405 }
1406
1408 {
1409 derived().enter(x);
1410 derived().print("Set");
1411 derived().leave(x);
1412 }
1413
1415 {
1416 derived().enter(x);
1417 derived().print("Bag");
1418 derived().leave(x);
1419 }
1420
1422 {
1423 derived().enter(x);
1424 derived().print("FSet");
1425 derived().leave(x);
1426 }
1427
1429 {
1430 derived().enter(x);
1431 derived().print("FBag");
1432 derived().leave(x);
1433 }
1434
1436 {
1437 derived().enter(x);
1438 derived().apply(x.name());
1439 derived().leave(x);
1440 }
1441
1443 {
1444 derived().enter(x);
1445 derived().apply(x.container_name());
1446 derived().print("(");
1447 derived().apply(x.element_sort());
1448 derived().print(")");
1449 derived().leave(x);
1450 }
1451
1453 {
1454 derived().enter(x);
1455 print_list(x.constructors(), "struct ", "", " | ");
1456 derived().leave(x);
1457 }
1458
1460 {
1461 derived().enter(x);
1462 print_sort_list(x.domain(), "", " -> ", " # ");
1463 derived().apply(x.codomain());
1464 derived().leave(x);
1465 }
1466
1468 {
1469 derived().enter(x);
1470 derived().print("untyped_sort");
1471 derived().leave(x);
1472 }
1473
1475 {
1476 derived().enter(x);
1477 derived().print("@untyped_possible_sorts[");
1478 derived().apply(x.sorts());
1479 derived().print("]");
1480 derived().leave(x);
1481 }
1482
1484 {
1485 derived().enter(x);
1486 derived().print("@s");
1487 derived().apply(x.value());
1488 derived().leave(x);
1489 }
1490
1492 {
1493 derived().enter(x);
1494 derived().apply(x.name());
1495 derived().leave(x);
1496 }
1497
1498 void apply(const data::variable& x)
1499 {
1500 derived().enter(x);
1501 derived().apply(x.name());
1502 derived().leave(x);
1503 }
1504
1506 {
1507 derived().enter(x);
1509 {
1510 derived().print("0");
1511 }
1513 {
1514 derived().print("1");
1515 }
1517 {
1518 derived().print("{:}");
1519 }
1521 {
1522 derived().print("{}");
1523 }
1524 else
1525 {
1526 derived().print(x.name());
1527 }
1528 derived().leave(x);
1529 }
1530
1532 {
1533 derived().enter(x);
1534
1535 //-------------------------------------------------------------------//
1536 // bool
1537 //-------------------------------------------------------------------//
1538
1540 {
1542 }
1544 {
1545 print_binary_data_operation(x, " && ");
1546 }
1547 else if (sort_bool::is_or_application(x))
1548 {
1549 print_binary_data_operation(x, " || ");
1550 }
1552 {
1553 print_binary_data_operation(x, " => ");
1554 }
1555
1556 //-------------------------------------------------------------------//
1557 // data
1558 //-------------------------------------------------------------------//
1559
1561 {
1562 print_binary_data_operation(x, " == ");
1563 }
1565 {
1566 print_binary_data_operation(x, " != ");
1567 }
1568 else if (data::is_if_application(x))
1569 {
1570 // TODO: is this correct?
1572 }
1573 else if (data::is_less_application(x))
1574 {
1576 }
1578 {
1579 print_binary_data_operation(x, " <= ");
1580 }
1581 else if (data::is_greater_application(x))
1582 {
1584 }
1586 {
1587 print_binary_data_operation(x, " >= ");
1588 }
1589
1590#ifdef MCRL2_ENABLE_MACHINENUMBERS
1591 //-------------------------------------------------------------------//
1592 // machine_word
1593 //-------------------------------------------------------------------//
1594
1596 {
1597 derived().print(std::to_string(sort_machine_word::detail::zero_word().value()));
1598 }
1600 {
1601 derived().print(std::to_string(sort_machine_word::detail::one_word().value()));
1602 }
1604 {
1605 derived().print(std::to_string(sort_machine_word::detail::max_word().value()));
1606 }
1608 {
1609 derived().print("((");
1610 derived().apply(sort_machine_word::arg(x));
1611 derived().print(" + 1) mod ");
1612 derived().print(max_machine_number_string());
1613 derived().print(" )");
1614 }
1616 {
1617 derived().print("((");
1618 derived().apply(sort_machine_word::left(x));
1619 derived().print(" + ");
1620 derived().apply(sort_machine_word::right(x));
1621 derived().print(") mod ");
1622 derived().print(max_machine_number_string());
1623 derived().print(" )");
1624 }
1626 {
1627 derived().print("((");
1628 derived().apply(sort_machine_word::left(x));
1629 derived().print(" + ");
1630 derived().apply(sort_machine_word::right(x));
1631 derived().print(") div ");
1632 derived().print(max_machine_number_string());
1633 derived().print(" )");
1634 }
1636 {
1637 derived().print("((");
1638 derived().apply(sort_machine_word::left(x));
1639 derived().print(" * ");
1640 derived().apply(sort_machine_word::right(x));
1641 derived().print(") mod ");
1642 derived().print(max_machine_number_string());
1643 derived().print(" )");
1644 }
1646 {
1647 derived().print("((");
1648 derived().apply(sort_machine_word::left(x));
1649 derived().print(" * ");
1650 derived().apply(sort_machine_word::right(x));
1651 derived().print(") div ");
1652 derived().print(max_machine_number_string());
1653 derived().print(" )");
1654 }
1655 /* else if (sort_machine_word::is_minus_word_application(x))
1656 {
1657 derived().print("(if(");
1658 derived().print_binary_operation(x, " >= ");
1659 derived().print(", ");
1660 derived().print_binary_operation(x, " - ");
1661 derived().print(", ");
1662 derived().print(max_machine_number_string());
1663 derived().print(" + ");
1664 derived().print_binary_operation(x, " - ");
1665 derived().print(")");
1666 }
1667 else if (sort_machine_word::is_div_word_application(x))
1668 {
1669 derived().print_binary_operation(x, " div ");
1670 }
1671 else if (sort_machine_word::is_mod_word_application(x))
1672 {
1673 derived().print_binary_operation(x, " mod ");
1674 } */
1675
1676/* TODO: Handle the following cases.
1677
1678 @div_doubleword <"div_doubleword">: @word <"arg1"> # @word <"arg2"> # @word <"arg3"> -> @word
1679 @div_double_doubleword <"div_double_doubleword">: @word <"arg1"> # @word <"arg2"> # @word <"arg3"> # @word <"arg4"> -> @word
1680 @div_triple_doubleword <"div_triple_doubleword">: @word <"arg1"> # @word <"arg2"> # @word <"arg3"> # @word <"arg4"> # @word <"arg5"> -> @word
1681 @mod_doubleword <"mod_doubleword">: @word <"arg1"> # @word <"arg2"> # @word <"arg3"> -> @word
1682 @sqrt_doubleword <"sqrt_doubleword">: @word <"arg1"> # @word <"arg2"> -> @word
1683 @sqrt_tripleword <"sqrt_tripleword">: @word <"arg1"> # @word <"arg2"> # @word <"arg3"> -> @word
1684 @sqrt_tripleword_overflow <"sqrt_tripleword_overflow">: @word <"arg1"> # @word <"arg2"> # @word <"arg3"> -> @word
1685 @sqrt_quadrupleword <"sqrt_quadrupleword">: @word <"arg1"> # @word <"arg2"> # @word <"arg3"> # @word <"arg4"> -> @word
1686 @sqrt_quadrupleword_overflow <"sqrt_quadrupleword_overflow">: @word <"arg1"> # @word <"arg2"> # @word <"arg3"> # @word <"arg4"> -> @word
1687 @pred_word <"pred_word">: @word <"arg"> ->@word
1688*/
1689
1690
1691#endif
1692
1693 //-------------------------------------------------------------------//
1694 // pos
1695 //-------------------------------------------------------------------//
1696
1697#ifdef MCRL2_ENABLE_MACHINENUMBERS
1699 {
1701 }
1703 {
1704 derived().apply(sort_pos::arg(x));
1705 }
1707 {
1708 derived().print(max_machine_number_string() + "* (");
1709 derived().apply(sort_pos::arg1(x));
1710 derived().print(") + ");
1711 derived().apply(sort_pos::arg2(x));
1712 }
1713#else
1715 {
1717 {
1719 }
1720 else
1721 {
1722 std::vector<char> number = data::detail::string_to_vector_number("1");
1723 derived().apply(detail::reconstruct_pos_mult(x, number));
1724 }
1725 }
1726#endif
1727 // TODO: handle @pospred
1729 {
1731 }
1733 {
1734#ifdef MCRL2_ENABLE_MACHINENUMBERS
1735 const data_expression& x1 = sort_pos::left(x);
1736 const data_expression& x2 = sort_pos::right(x);
1737 derived().apply(sort_pos::plus(x1, x2));
1738#else
1739 const data_expression& b = sort_pos::arg1(x);
1740 const data_expression& x1 = sort_pos::arg2(x);
1741 const data_expression& x2 = sort_pos::arg3(x);
1742 if (b == data::sort_bool::true_())
1743 {
1744 derived().apply(sort_pos::succ(sort_pos::plus(x1, x2)));
1745 }
1746 else if (b == sort_bool::false_())
1747 {
1748 derived().apply(sort_pos::plus(x1, x2));
1749 }
1750 else
1751 {
1752 derived().apply(if_(b, x1, x2));
1753 }
1754#endif
1755 }
1757 {
1759 }
1760 // TODO: handle @powerlog2
1761
1762 //-------------------------------------------------------------------//
1763 // natpair
1764 //-------------------------------------------------------------------//
1765
1766#ifdef MCRL2_ENABLE_MACHINENUMBERS
1768 {
1769 // TODO: verify if this is the correct way of dealing with first/divmod
1772 {
1774 }
1775 else
1776 {
1777 print_expression(sort_nat::left(y), true); // Removed left_precedence(y) and replaced it with true, which may be undesireable. Happens 3x more below.
1778 derived().print(" div ");
1779 print_expression(sort_nat::right(y), true);
1780 }
1781 }
1783 {
1784 // TODO: verify if this is the correct way of dealing with last/divmod
1787 {
1789 }
1790 else
1791 {
1792 print_expression(sort_nat::left(y), true);
1793 derived().print(" mod ");
1794 print_expression(sort_nat::right(y), true);
1795 }
1796 }
1797#else
1799 {
1800 // TODO: verify if this is the correct way of dealing with first/divmod
1801 const auto& y = atermpp::down_cast<application>(sort_nat::arg(x));
1803 {
1805 }
1806 else
1807 {
1808 print_binary_data_operation(y, " div ");
1809 }
1810 }
1812 {
1813 // TODO: verify if this is the correct way of dealing with last/divmod
1814 const auto& y = atermpp::down_cast<application>(sort_nat::arg(x));
1816 {
1818 }
1819 else
1820 {
1821 print_binary_data_operation(y, " mod ");
1822 }
1823 }
1824#endif
1825
1826 //-------------------------------------------------------------------//
1827 // nat
1828 //-------------------------------------------------------------------//
1829
1830#ifdef MCRL2_ENABLE_MACHINENUMBERS
1832 {
1834 }
1836 {
1837 derived().apply(sort_nat::arg(x));
1838 }
1840 {
1841 derived().print("(" + max_machine_number_string() + "*");
1842 derived().apply(sort_nat::arg1(x));
1843 derived().print(") + ");
1844 derived().apply(sort_nat::arg2(x));
1845 }
1846#else
1848 {
1849 derived().apply(sort_nat::arg(x));
1850 }
1851#endif
1853 {
1854 derived().apply(*x.begin());
1855 }
1856 // TODO: handle @dub
1857 // TODO: handle @dubsucc
1859 {
1861 }
1862 // TODO: handle @gtesubtb
1864 {
1866 }
1867 else if (sort_nat::is_div_application(x))
1868 {
1870 }
1871 else if (sort_nat::is_mod_application(x))
1872 {
1874 }
1875 // TODO: handle @monus
1876 // TODO: handle @swap_zero*
1877 // TODO: handle @sqrt_nat
1878
1879 //-------------------------------------------------------------------//
1880 // int
1881 //-------------------------------------------------------------------//
1882
1884 {
1885 derived().apply(sort_int::arg(x));
1886 }
1888 {
1889 derived().apply(sort_int::negate(sort_int::arg(x)));
1890 }
1892 {
1893 derived().apply(*x.begin());
1894 }
1896 {
1897 derived().apply(sort_int::arg(x));
1898 }
1900 {
1902 }
1904 {
1906 }
1908 {
1910 }
1912 {
1914 }
1915 else if (sort_int::is_div_application(x))
1916 {
1918 }
1919 else if (sort_int::is_mod_application(x))
1920 {
1922 }
1923
1924 //-------------------------------------------------------------------//
1925 // real
1926 //-------------------------------------------------------------------//
1927
1929 {
1930 data_expression numerator = sort_real::left(x);
1931 const data_expression& denominator = sort_real::right(x);
1932 if (detail::is_one(denominator))
1933 {
1934 derived().apply(numerator);
1935 }
1936 else
1937 {
1939 }
1940 }
1942 {
1943 derived().apply(*x.begin());
1944 }
1946 {
1947 derived().apply(*x.begin());
1948 }
1950 {
1951 derived().apply(*x.begin());
1952 }
1954 {
1956 }
1958 {
1960 }
1962 {
1964 }
1966 {
1968 }
1970 {
1972 }
1974 {
1975 derived().apply(sort_real::divides(sort_real::left(x),sort_real::right(x)));
1976 }
1978 {
1980 }
1981 // TODO: handle @redfrachlp
1982
1983 //-------------------------------------------------------------------//
1984 // list
1985 //-------------------------------------------------------------------//
1986
1988 {
1990 }
1992 {
1993 if (is_cons_list(x))
1994 {
1995 print_cons_list(x);
1996 }
1997 else
1998 {
1999 print_binary_data_operation(x, " |> ");
2000 }
2001 }
2002 else if (sort_list::is_in_application(x))
2003 {
2004 print_binary_data_operation(x, " in ");
2005 }
2007 {
2008 derived().print("#");
2009 print_unary_operand(x, sort_list::arg(x));
2010 }
2012 {
2013 if (is_snoc_list(x))
2014 {
2015 print_snoc_list(x);
2016 }
2017 else
2018 {
2019 print_binary_data_operation(x, " <| ");
2020 }
2021 }
2023 {
2024 print_binary_data_operation(x, " ++ ");
2025 }
2027 {
2029 }
2030
2031 //-------------------------------------------------------------------//
2032 // set
2033 //-------------------------------------------------------------------//
2034
2036 {
2037 if (is_fset_true(x))
2038 {
2039 print_fset_true(x);
2040 }
2041 else if (is_fset_false(x))
2042 {
2044 }
2045 else if (is_fset_lambda(x))
2046 {
2048 }
2049 else
2050 {
2052 }
2053 }
2055 {
2058 {
2059 derived().print("{}");
2060 }
2061 else if (data::is_variable(y))
2062 {
2063 derived().print("@setfset(");
2064 derived().apply(variable(y).name());
2065 derived().print(")");
2066 }
2067 else
2068 {
2069 derived().apply(y);
2070 }
2071 }
2073 {
2076 variable var(name, s);
2077 data_expression body(sort_set::arg(x)(var));
2078 derived().print("{ ");
2079 print_variable(var, true);
2080 derived().print(" | ");
2081 derived().apply(body);
2082 derived().print(" }");
2083 }
2084 else if (sort_set::is_in_application(x))
2085 {
2086 print_binary_data_operation(x, " in ");
2087 }
2089 {
2091 }
2093 {
2095 }
2097 {
2099 }
2101 {
2103 }
2105 {
2106 print_fset_set_operation(x, " + ");
2107 }
2109 {
2110 print_fset_set_operation(x, " * ");
2111 }
2112
2113 //-------------------------------------------------------------------//
2114 // fset
2115 //-------------------------------------------------------------------//
2116
2117 else if (is_fset_cons_list(x))
2118 {
2120 }
2121 else if (sort_fset::is_in_application(x))
2122 {
2123 print_binary_data_operation(x, " in ");
2124 }
2126 {
2127 derived().apply(sort_fset::left(x));
2128 derived().print(" - ");
2129 derived().apply(sort_fset::right(x));
2130 }
2132 {
2133 derived().apply(sort_fset::left(x));
2134 derived().print(" + ");
2135 derived().apply(sort_fset::right(x));
2136 }
2138 {
2139 derived().apply(sort_fset::left(x));
2140 derived().print(" * ");
2141 derived().apply(sort_fset::right(x));
2142 }
2144 {
2145 derived().print("#");
2146 derived().apply(sort_fset::arg(x));
2147 }
2148
2149 //-------------------------------------------------------------------//
2150 // bag
2151 //-------------------------------------------------------------------//
2152
2154 {
2155 if (is_fbag_zero(x))
2156 {
2157 print_fbag_zero(x);
2158 }
2159 else if (is_fbag_one(x))
2160 {
2161 print_fbag_one(x);
2162 }
2163 else if (is_fbag_lambda(x))
2164 {
2166 }
2167 else
2168 {
2170 }
2171 }
2173 {
2176 {
2177 derived().print("{:}");
2178 }
2179 else if (data::is_variable(y))
2180 {
2181 derived().print("@bagfbag(");
2182 derived().apply(variable(y).name());
2183 derived().print(")");
2184 }
2185 else
2186 {
2187 derived().apply(y);
2188 }
2189 }
2191 {
2194 variable var(name, s);
2195 data_expression body(sort_bag::arg(x)(var));
2196 derived().print("{ ");
2197 print_variable(var, true);
2198 derived().print(" | ");
2199 derived().apply(body);
2200 derived().print(" }");
2201 }
2202 else if (sort_bag::is_in_application(x))
2203 {
2204 print_binary_data_operation(x, " in ");
2205 }
2207 {
2209 }
2211 {
2213 }
2215 {
2217 }
2218
2219 //-------------------------------------------------------------------//
2220 // fbag
2221 //-------------------------------------------------------------------//
2222
2223 // cons / insert / cinsert
2224 else if (is_fbag_cons_list(x))
2225 {
2227 }
2228 else if (sort_fbag::is_in_application(x))
2229 {
2230 print_binary_data_operation(x, " in ");
2231 }
2233 {
2235 }
2237 {
2239 }
2240
2242 {
2244 }
2246 {
2247 derived().print("#");
2248 derived().apply(sort_fbag::arg(x));
2249 }
2250
2251 //-------------------------------------------------------------------//
2252 // function update
2253 //-------------------------------------------------------------------//
2255 {
2259 bool print_parentheses = is_abstraction(x1);
2260 if (print_parentheses)
2261 {
2262 derived().print("(");
2263 }
2264 derived().apply(x1);
2265 if (print_parentheses)
2266 {
2267 derived().print(")");
2268 }
2269 derived().print("[");
2270 derived().apply(x2);
2271 derived().print(" -> ");
2272 derived().apply(x3);
2273 derived().print("]");
2274 }
2275
2276 //-------------------------------------------------------------------//
2277 // abstraction
2278 //-------------------------------------------------------------------//
2279 else if (is_abstraction_application(x))
2280 {
2281 if (!x.empty()) {
2282 derived().print("(");
2283 }
2284 derived().apply(x.head());
2285 if (!x.empty())
2286 {
2287 derived().print(")(");
2288 }
2289 print_container(x);
2290 if (!x.empty())
2291 {
2292 derived().print(")");
2293 }
2294 }
2295
2296 //-------------------------------------------------------------------//
2297 // function application
2298 //-------------------------------------------------------------------//
2299 else
2300 {
2302 }
2303 derived().leave(x);
2304 }
2305
2306 void apply(const machine_number& x)
2307 {
2308 derived().print(std::to_string(x.value()));
2309 }
2310
2312 {
2313 derived().enter(x);
2314 derived().apply(x.body());
2315 derived().print(" whr ");
2316 const assignment_expression_list& declarations = x.declarations();
2317 for (assignment_expression_list::const_iterator i = declarations.begin(); i != declarations.end(); ++i)
2318 {
2319 if (i != declarations.begin())
2320 {
2321 derived().print(", ");
2322 }
2323 derived().apply(*i);
2324 }
2325 derived().print(" end");
2326 derived().leave(x);
2327 }
2328
2329 void apply(const data::forall& x)
2330 {
2331 print_abstraction(x, "forall");
2332 }
2333
2334 void apply(const data::exists& x)
2335 {
2336 print_abstraction(x, "exists");
2337 }
2338
2339 void apply(const data::lambda& x)
2340 {
2341 print_abstraction(x, "lambda");
2342 }
2343
2345 {
2346 derived().enter(x);
2348 derived().apply(x.lhs());
2349 derived().print(" = ");
2350 derived().apply(x.rhs());
2351 derived().leave(x);
2352 }
2353
2354 // Adds variables v and function symbols f to variable_map and function_symbol_names respectively.
2356 std::vector<variable>& variables,
2357 std::map<core::identifier_string, variable>& variable_map,
2358 std::set<core::identifier_string>& function_symbol_names
2359 )
2360 {
2361 for (const function_symbol& f: data::find_function_symbols(eqn))
2362 {
2363 function_symbol_names.insert(f.name());
2364 }
2365 for (const variable& v: eqn.variables())
2366 {
2367 std::pair<std::map<core::identifier_string, variable>::iterator, bool> k = variable_map.insert(std::make_pair(v.name(), v));
2368 if (k.second) // new variable encountered
2369 {
2370 variables.push_back(v);
2371 }
2372 }
2373 }
2374
2376 const std::map<core::identifier_string, variable>& variable_map
2377 )
2378 {
2379 for (const variable& v: eqn.variables())
2380 {
2381 auto j = variable_map.find(v.name());
2382 if (j != variable_map.end() && v != j->second)
2383 {
2384 return true;
2385 }
2386 }
2387 return false;
2388 }
2389
2395 template <typename Iter>
2396 Iter find_conflicting_equation(Iter first, Iter last, std::vector<variable>& variables)
2397 {
2398 std::map<core::identifier_string, variable> variable_map;
2399 std::set<core::identifier_string> function_symbol_names;
2400 for (Iter i = first; i != last; ++i)
2401 {
2402 if (has_conflict(*i, variable_map))
2403 {
2404 return i;
2405 }
2406 else
2407 {
2408 update_mappings(*i, variables, variable_map, function_symbol_names);
2409 }
2410 }
2411 return last; // no conflict found
2412 }
2413
2414 template <typename AliasContainer, typename SortContainer>
2415 void print_sort_declarations(const AliasContainer& aliases,
2416 const SortContainer& sorts,
2417 const std::string& opener = "(",
2418 const std::string& closer = ")",
2419 const std::string& separator = ", "
2420 )
2421 {
2422 if (aliases.empty() && sorts.empty())
2423 {
2424 return;
2425 }
2426 bool first_element = true;
2427 derived().print(opener);
2428
2429 // print sorts
2430 for (auto i = sorts.begin(); i != sorts.end(); ++i)
2431 {
2432 if (!first_element)
2433 {
2434 derived().print(separator);
2435 }
2436 derived().apply(*i);
2437 first_element = false;
2438 }
2439
2440 // print aliases
2441 for (auto i = aliases.begin(); i != aliases.end(); ++i)
2442 {
2443 if (!first_element)
2444 {
2445 derived().print(separator);
2446 }
2447 derived().apply(*i);
2448 first_element = false;
2449 }
2450
2451 derived().print(closer);
2452 }
2453
2454 template <typename Container>
2455 void print_equations(const Container& equations,
2456 const data_specification& data_spec,
2457 const std::string& opener = "(",
2458 const std::string& closer = ")",
2459 const std::string& separator = ", "
2460 )
2461 {
2462 auto first = equations.begin();
2463 auto last = equations.end();
2464
2465 Container normalized_equations = equations;
2466 data::normalize_sorts(normalized_equations, data_spec);
2467
2468 while (first != last)
2469 {
2470 std::vector<variable> variables;
2471 auto i = find_conflicting_equation(first, last, variables);
2472 print_variables(variables, true, true, true, "var ", ";\n", ";\n ");
2473
2474 // N.B. We print normalized equations instead of user defined equations.
2475 // print_list(std::vector<data_equation>(first, i), opener, closer, separator);
2476 auto first1 = normalized_equations.begin() + (first - equations.begin());
2477 auto i1 = normalized_equations.begin() + (i - equations.begin());
2478 print_list(std::vector<data_equation>(first1, i1), opener, closer, separator);
2479
2480 first = i;
2481 }
2482 }
2483
2485 {
2486 derived().enter(x);
2487 print_sort_declarations(x.user_defined_aliases(), x.user_defined_sorts(), "sort ", ";\n\n", ";\n ");
2488 print_sorted_declarations(x.user_defined_constructors(), true, true, false, "cons ",";\n\n", ";\n ", get_sort_default());
2489 print_sorted_declarations(x.user_defined_mappings(), true, true, false, "map ",";\n\n", ";\n ", get_sort_default());
2490 print_equations(x.user_defined_equations(), x, "eqn ", ";\n\n", ";\n ");
2491 derived().leave(x);
2492 }
2493
2494 // Override, because there are set/bag/setbag comprehension classes that exist after parsing and before type checking.
2496 {
2497 derived().enter(x);
2498 if (data::is_forall(x))
2499 {
2500 derived().apply(atermpp::down_cast<data::forall>(x));
2501 }
2502 else if (data::is_exists(x))
2503 {
2504 derived().apply(atermpp::down_cast<data::exists>(x));
2505 }
2506 else if (data::is_lambda(x))
2507 {
2508 derived().apply(atermpp::down_cast<data::lambda>(x));
2509 }
2510 else if (data::is_set_comprehension(x))
2511 {
2513 }
2514 else if (data::is_bag_comprehension(x))
2515 {
2517 }
2519 {
2521 }
2522 derived().leave(x);
2523 }
2524};
2525
2526} // namespace detail
2527
2530{
2531 template <typename T>
2532 void operator()(const T& x, std::ostream& out)
2533 {
2534 core::detail::apply_printer<data::detail::printer> printer(out);
2535 printer.apply(x);
2536 }
2537};
2538
2540template <typename T>
2541std::string pp(const T& x)
2542{
2543 std::ostringstream out;
2544 stream_printer()(x, out);
2545 return out.str();
2546}
2547
2548} // namespace data
2549
2550} // namespace mcrl2
2551
2552#endif
Term containing a string.
bool empty() const
Returns true if the term has no arguments.
Definition aterm.h:158
Iterator for term_appl.
Iterator for term_list.
const_iterator end() const
Returns a const_iterator pointing to the end of the term_list.
Definition aterm_list.h:282
const Term & front() const
Returns the first element of the list.
Definition aterm_list.h:239
const_iterator begin() const
Returns a const_iterator pointing to the beginning of the term_list.
Definition aterm_list.h:275
An abstraction expression.
Definition abstraction.h:26
const variable_list & variables() const
Definition abstraction.h:63
const data_expression & body() const
Definition abstraction.h:68
\brief A sort alias
Definition alias.h:26
const basic_sort & name() const
Definition alias.h:52
const sort_expression & reference() const
Definition alias.h:57
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.
const data_expression & head() const
Get the function at the head of this expression.
std::size_t size() const
\brief Assignment of a data expression to a variable
Definition assignment.h:91
const data_expression & rhs() const
Definition assignment.h:122
const variable & lhs() const
Definition assignment.h:117
\brief Binder for bag comprehension
universal quantification.
\brief Container type for bags
\brief A basic sort
Definition basic_sort.h:26
const core::identifier_string & name() const
Definition basic_sort.h:57
\brief A container sort
const container_type & container_name() const
const sort_expression & element_sort() const
\brief Container type
\brief A data equation
const data_expression & lhs() const
const data_expression & condition() const
const data_expression & rhs() const
const variable_list & variables() const
sort_expression sort() const
Returns the sort of the data expression.
Definition data.cpp:108
const_iterator end() const
const_iterator begin() const
const function_symbol_vector & user_defined_constructors() const
Gets the constructors defined by the user, excluding those that are system defined.
const function_symbol_vector & user_defined_mappings() const
Gets all user defined mappings in this specification.
const data_equation_vector & user_defined_equations() const
Gets all user defined equations.
\brief Binder for existential quantification
existential quantification.
Definition exists.h:26
\brief Container type for finite bags
\brief Binder for universal quantification
universal quantification.
Definition forall.h:26
\brief Container type for finite sets
\brief A function sort
const sort_expression & codomain() const
const sort_expression_list & domain() const
\brief A function symbol
const core::identifier_string & name() const
const sort_expression & sort() const
\brief Binder for lambda abstraction
function symbol.
Definition lambda.h:27
\brief Container type for lists
\brief A machine number
std::size_t value() const
\brief Binder for set comprehension
universal quantification.
\brief Container type for sets
Identifier generator that stores the identifiers of the context in a set. Using the operator()() and ...
void add_identifier(const core::identifier_string &s) override
Adds the identifier s to the context.
\brief A sort expression
const basic_sort_vector & user_defined_sorts() const
Gets all sorts defined by a user (excluding the system defined sorts).
const alias_vector & user_defined_aliases() const
Gets the user defined aliases.
\brief An argument of a constructor of a structured sort
\brief A constructor for a structured sort
const core::identifier_string & name() const
const core::identifier_string & recogniser() const
const structured_sort_constructor_argument_list & arguments() const
const structured_sort_constructor_list & constructors() const
const core::identifier_string & name() const
const data_expression_list & arguments() const
\brief Assignment of a data expression to a string
Definition assignment.h:182
const core::identifier_string & lhs() const
Definition assignment.h:213
const data_expression & rhs() const
Definition assignment.h:218
\brief An untyped identifier
const core::identifier_string & name() const
const sort_expression_list & sorts() const
\brief Binder for untyped set or bag comprehension
Definition binder_type.h:77
const atermpp::aterm_int & value() const
\brief Unknown sort expression
\brief A data variable
Definition variable.h:28
const core::identifier_string & name() const
Definition variable.h:38
\brief A where expression
const data_expression & body() const
const assignment_expression_list & declarations() const
add your file description here.
The class data_specification.
add your file description here.
identifier_string empty_identifier_string()
Provides the empty identifier string.
bool is_greater(const application &x)
Definition print.h:229
bool is_minus(const application &x)
Definition print.h:111
bool is_equal_to(const application &x)
Definition print.h:205
bool is_snoc_list(data_expression x)
Definition print.h:291
bool is_in(const application &x)
Definition print.h:241
bool head_matches_undefined_symbol(const data_expression &x, const core::identifier_string &s)
Definition print.h:72
bool is_bag_intersection(const application &x)
Definition print.h:269
bool is_set_difference(const application &x)
Definition print.h:175
bool is_not_equal_to(const application &x)
Definition print.h:211
bool is_numeric_cast(const data_expression &x)
Definition print.h:45
bool is_divides(const application &x)
Definition print.h:153
bool is_set_union(const application &x)
Definition print.h:169
bool is_bag_difference(const application &x)
Definition print.h:187
bool is_less_equal(const application &x)
Definition print.h:223
bool is_set_intersection(const application &x)
Definition print.h:263
bool is_plus(const application &x)
Definition print.h:97
bool is_or(const application &x)
Definition print.h:199
bool is_greater_equal(const application &x)
Definition print.h:235
data_expression reconstruct_pos_mult(const data_expression &x, const std::vector< char > &result)
bool is_untyped(const data_expression &x)
Definition is_untyped.h:73
bool is_one(const data_expression &x)
Definition print.h:30
std::string pp(const detail::lhs_t &lhs)
bool is_element_at(const application &x)
Definition print.h:257
bool is_bag_join(const application &x)
Definition print.h:181
bool is_concat(const application &x)
Definition print.h:275
bool is_and(const application &x)
Definition print.h:193
bool look_through_numeric_casts(const data_expression &x, std::function< bool(const data_expression &)> f)
Definition print.h:61
bool is_snoc(const application &x)
Definition print.h:307
bool is_implies(const application &x)
Definition print.h:163
bool is_cons_list(data_expression x)
Definition print.h:281
bool is_mod(const application &x)
Definition print.h:122
bool is_divmod(const application &x)
Definition print.h:143
bool is_div(const application &x)
Definition print.h:132
bool is_times(const application &x)
Definition print.h:247
bool is_cons(const application &x)
Definition print.h:301
bool is_less(const application &x)
Definition print.h:217
const data_expression & right(const data_expression &e)
Function for projecting out argument. right from an application.
Definition bag1.h:1636
function_symbol bag_fbag(const sort_expression &s)
Constructor for function symbol @bagfbag.
Definition bag1.h:176
bool is_difference_application(const atermpp::aterm &e)
Recogniser for application of -.
Definition bag1.h:689
bool is_bag_fbag_application(const atermpp::aterm &e)
Recogniser for application of @bagfbag.
Definition bag1.h:220
bool is_union_application(const atermpp::aterm &e)
Recogniser for application of +.
Definition bag1.h:495
function_symbol count(const sort_expression &, const sort_expression &s0, const sort_expression &s1)
Definition bag1.h:298
bool is_in_application(const atermpp::aterm &e)
Recogniser for application of in.
Definition bag1.h:410
const data_expression & left(const data_expression &e)
Function for projecting out argument. left from an application.
Definition bag1.h:1624
const core::identifier_string & intersection_name()
Generate identifier *.
Definition bag1.h:503
bool is_bag_enumeration_application(const atermpp::aterm &e)
Recogniser for application of bag_enumeration.
bool is_constructor_application(const atermpp::aterm &e)
Recogniser for application of @bag.
Definition bag1.h:124
bool is_zero_function_function_symbol(const atermpp::aterm &e)
Recogniser for function @zero_.
Definition bag1.h:841
bool is_bag_comprehension_application(const atermpp::aterm &e)
Recogniser for application of @bagcomp.
Definition bag1.h:282
const core::identifier_string & union_name()
Generate identifier +.
Definition bag1.h:418
bool is_intersection_application(const atermpp::aterm &e)
Recogniser for application of *.
Definition bag1.h:596
const data_expression & arg(const data_expression &e)
Function for projecting out argument. arg from an application.
Definition bag1.h:1648
const core::identifier_string & difference_name()
Generate identifier -.
Definition bag1.h:604
bool is_one_function_function_symbol(const atermpp::aterm &e)
Recogniser for function @one_.
Definition bag1.h:903
bool is_or_application(const atermpp::aterm &e)
Recogniser for application of ||.
Definition bool.h:345
bool is_bool(const sort_expression &e)
Recogniser for sort expression Bool.
Definition bool.h:54
const core::identifier_string & implies_name()
Generate identifier =>.
Definition bool.h:353
const core::identifier_string & or_name()
Generate identifier ||.
Definition bool.h:289
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
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
const function_symbol & true_()
Constructor for function symbol true.
Definition bool.h:77
const core::identifier_string & and_name()
Generate identifier &&.
Definition bool.h:225
bool is_empty_function_symbol(const atermpp::aterm &e)
Recogniser for function {:}.
Definition fbag1.h:87
bool is_union_application(const atermpp::aterm &e)
Recogniser for application of +.
Definition fbag1.h:579
const data_expression & arg3(const data_expression &e)
Function for projecting out argument. arg3 from an application.
Definition fbag1.h:868
const data_expression & arg(const data_expression &e)
Function for projecting out argument. arg from an application.
Definition fbag1.h:904
bool is_intersection_application(const atermpp::aterm &e)
Recogniser for application of *.
Definition fbag1.h:643
bool is_in_application(const atermpp::aterm &e)
Recogniser for application of in.
Definition fbag1.h:453
const core::identifier_string & difference_name()
Generate identifier -.
Definition fbag1.h:651
bool is_difference_application(const atermpp::aterm &e)
Recogniser for application of -.
Definition fbag1.h:707
bool is_cons_application(const atermpp::aterm &e)
Recogniser for application of @fbag_cons.
Definition fbag1.h:259
const data_expression & arg2(const data_expression &e)
Function for projecting out argument. arg2 from an application.
Definition fbag1.h:856
bool is_count_all_application(const atermpp::aterm &e)
Recogniser for application of #.
Definition fbag1.h:769
bool is_cinsert_application(const atermpp::aterm &e)
Recogniser for application of @fbag_cinsert.
Definition fbag1.h:325
const core::identifier_string & union_name()
Generate identifier +.
Definition fbag1.h:523
bool is_insert_application(const atermpp::aterm &e)
Recogniser for application of @fbag_insert.
Definition fbag1.h:157
const data_expression & arg1(const data_expression &e)
Function for projecting out argument. arg1 from an application.
Definition fbag1.h:844
bool is_empty_function_symbol(const atermpp::aterm &e)
Recogniser for function {}.
Definition fset1.h:85
bool is_in_application(const atermpp::aterm &e)
Recogniser for application of in.
Definition fset1.h:383
const core::identifier_string & difference_name()
Generate identifier -.
Definition fset1.h:391
const data_expression & right(const data_expression &e)
Function for projecting out argument. right from an application.
Definition fset1.h:720
const data_expression & left(const data_expression &e)
Function for projecting out argument. left from an application.
Definition fset1.h:708
bool is_difference_application(const atermpp::aterm &e)
Recogniser for application of -.
Definition fset1.h:447
const core::identifier_string & union_name()
Generate identifier +.
Definition fset1.h:455
bool is_count_application(const atermpp::aterm &e)
Recogniser for application of #.
Definition fset1.h:637
bool is_cons_application(const atermpp::aterm &e)
Recogniser for application of @fset_cons.
Definition fset1.h:253
bool is_intersection_application(const atermpp::aterm &e)
Recogniser for application of *.
Definition fset1.h:575
const data_expression & arg(const data_expression &e)
Function for projecting out argument. arg from an application.
Definition fset1.h:768
bool is_union_application(const atermpp::aterm &e)
Recogniser for application of +.
Definition fset1.h:511
bool is_insert_application(const atermpp::aterm &e)
Recogniser for application of @fset_insert.
Definition fset1.h:153
const data_expression & right(const data_expression &e)
Function for projecting out argument. right from an application.
Definition int1.h:1516
const function_symbol & pos2int()
Constructor for function symbol Pos2Int.
Definition int1.h:360
const data_expression & arg(const data_expression &e)
Function for projecting out argument. arg from an application.
Definition int1.h:1492
bool is_mod_application(const atermpp::aterm &e)
Recogniser for application of mod.
Definition int1.h:1309
bool is_int(const sort_expression &e)
Recogniser for sort expression Int.
Definition int1.h:57
bool is_times_application(const atermpp::aterm &e)
Recogniser for application of *.
Definition int1.h:1168
bool is_cneg_application(const atermpp::aterm &e)
Recogniser for application of @cNeg.
Definition int1.h:186
bool is_cint_application(const atermpp::aterm &e)
Recogniser for application of @cInt.
Definition int1.h:124
bool is_plus_application(const atermpp::aterm &e)
Recogniser for application of +.
Definition int1.h:1023
const core::identifier_string & mod_name()
Generate identifier mod.
Definition int1.h:1253
bool is_negate_application(const atermpp::aterm &e)
Recogniser for application of -.
Definition int1.h:776
function_symbol negate(const sort_expression &s0)
Definition int1.h:730
bool is_div_application(const atermpp::aterm &e)
Recogniser for application of div.
Definition int1.h:1245
const core::identifier_string & minus_name()
Generate identifier -.
Definition int1.h:1031
const core::identifier_string & div_name()
Generate identifier div.
Definition int1.h:1176
bool is_nat2int_application(const atermpp::aterm &e)
Recogniser for application of Nat2Int.
Definition int1.h:280
bool is_minus_application(const atermpp::aterm &e)
Recogniser for application of -.
Definition int1.h:1087
bool is_pos2int_application(const atermpp::aterm &e)
Recogniser for application of Pos2Int.
Definition int1.h:404
const core::identifier_string & times_name()
Generate identifier *.
Definition int1.h:1095
const data_expression & left(const data_expression &e)
Function for projecting out argument. left from an application.
Definition int1.h:1504
const core::identifier_string & snoc_name()
Generate identifier <|.
Definition list1.h:324
bool is_list_enumeration_application(const atermpp::aterm &e)
Recogniser for application of list_enumeration.
const core::identifier_string & in_name()
Generate identifier in.
Definition list1.h:198
bool is_concat_application(const atermpp::aterm &e)
Recogniser for application of ++.
Definition list1.h:444
const core::identifier_string & cons_name()
Generate identifier |>.
Definition list1.h:98
const core::identifier_string & concat_name()
Generate identifier ++.
Definition list1.h:388
bool is_in_application(const atermpp::aterm &e)
Recogniser for application of in.
Definition list1.h:254
const core::identifier_string & element_at_name()
Generate identifier ..
Definition list1.h:452
bool is_cons_application(const atermpp::aterm &e)
Recogniser for application of |>.
Definition list1.h:154
bool is_snoc_application(const atermpp::aterm &e)
Recogniser for application of <|.
Definition list1.h:380
bool is_element_at_application(const atermpp::aterm &e)
Recogniser for application of ..
Definition list1.h:508
const data_expression & left(const data_expression &e)
Function for projecting out argument. left from an application.
Definition list1.h:831
bool is_count_application(const atermpp::aterm &e)
Recogniser for application of #.
Definition list1.h:316
const data_expression & arg(const data_expression &e)
Function for projecting out argument. arg from an application.
Definition list1.h:855
const data_expression & right(const data_expression &e)
Function for projecting out argument. right from an application.
Definition list1.h:843
bool is_empty_function_symbol(const atermpp::aterm &e)
Recogniser for function [].
Definition list1.h:86
const machine_number & one_word()
const machine_number & max_word()
const machine_number & zero_word()
bool is_zero_word_function_symbol(const atermpp::aterm &e)
Recogniser for function @zero_word.
bool is_add_word_application(const atermpp::aterm &e)
Recogniser for application of @add_word.
bool is_max_word_function_symbol(const atermpp::aterm &e)
Recogniser for function @max_word.
bool is_succ_word_application(const atermpp::aterm &e)
Recogniser for application of @succ_word.
bool is_one_word_function_symbol(const atermpp::aterm &e)
Recogniser for function @one_word.
const data_expression & right(const data_expression &e)
Function for projecting out argument. right from an application.
bool is_times_overflow_word_application(const atermpp::aterm &e)
Recogniser for application of @times_overflow_word.
bool is_times_word_application(const atermpp::aterm &e)
Recogniser for application of @times_word.
const data_expression & arg(const data_expression &e)
Function for projecting out argument. arg from an application.
const data_expression & left(const data_expression &e)
Function for projecting out argument. left from an application.
bool is_add_overflow_word_application(const atermpp::aterm &e)
Recogniser for application of @add_overflow_word.
const data_expression & right(const data_expression &e)
Function for projecting out argument. right from an application.
Definition nat1.h:2257
bool is_cnat_application(const atermpp::aterm &e)
Recogniser for application of @cNat.
Definition nat1.h:184
bool is_div_application(const atermpp::aterm &e)
Recogniser for application of div.
Definition nat1.h:1110
bool is_pos2nat_application(const atermpp::aterm &e)
Recogniser for application of Pos2Nat.
Definition nat1.h:344
const function_symbol & cnat()
Constructor for function symbol @cNat.
Definition nat1.h:140
const basic_sort & nat()
Constructor for sort expression Nat.
Definition nat1.h:46
const function_symbol & swap_zero()
Constructor for function symbol @swap_zero.
Definition nat1.h:1395
bool is_nat(const sort_expression &e)
Recogniser for sort expression Nat.
Definition nat1.h:56
std::string natural_constant_as_string(const data_expression &n_in)
Return the string representation of a natural number.
const data_expression & left(const data_expression &e)
Function for projecting out argument. left from an application.
Definition nat1.h:2245
bool is_mod_application(const atermpp::aterm &e)
Recogniser for application of mod.
Definition nat1.h:1174
bool is_last_application(const atermpp::aterm &e)
Recogniser for application of @last.
Definition nat1.h:1897
bool is_first_application(const atermpp::aterm &e)
Recogniser for application of @first.
Definition nat1.h:1835
bool is_c0_function_symbol(const atermpp::aterm &e)
Recogniser for function @c0.
Definition nat1.h:118
const data_expression & arg2(const data_expression &e)
Function for projecting out argument. arg2 from an application.
Definition nat1.h:2233
const data_expression & arg1(const data_expression &e)
Function for projecting out argument. arg1 from an application.
Definition nat1.h:2221
bool is_concat_digit_application(const atermpp::aterm &e)
Recogniser for application of @concat_digit.
Definition nat64.h:422
const data_expression & arg(const data_expression &e)
Function for projecting out argument. arg from an application.
Definition nat1.h:2209
bool is_plus_application(const atermpp::aterm &e)
Recogniser for application of +.
Definition nat1.h:903
bool is_divmod_aux_application(const atermpp::aterm &e)
Recogniser for application of @divmod_aux.
Definition nat64.h:3064
bool is_times_application(const atermpp::aterm &e)
Recogniser for application of *.
Definition nat1.h:1046
const function_symbol & pos2nat()
Constructor for function symbol Pos2Nat.
Definition nat1.h:300
bool is_natural_constant(const data_expression &n)
Determines whether n is a natural constant.
bool is_most_significant_digit_nat_application(const atermpp::aterm &e)
Recogniser for application of @most_significant_digitNat.
Definition nat64.h:345
bool is_divmod_application(const atermpp::aterm &e)
Recogniser for application of @divmod.
Definition nat1.h:1961
std::string positive_constant_as_string(const data_expression &n_in)
Return the string representation of a positive number.
const data_expression & arg(const data_expression &e)
Function for projecting out argument. arg from an application.
Definition pos1.h:788
bool is_positive_constant(const data_expression &n)
Determines whether n is a positive constant.
bool is_pos(const sort_expression &e)
Recogniser for sort expression Pos.
Definition pos1.h:55
const data_expression & arg3(const data_expression &e)
Function for projecting out argument. arg3 from an application.
Definition pos1.h:824
const data_expression & arg1(const data_expression &e)
Function for projecting out argument. arg1 from an application.
Definition pos1.h:800
bool is_cdub_application(const atermpp::aterm &e)
Recogniser for application of @cDub.
Definition pos1.h:156
const function_symbol & plus()
Constructor for function symbol +.
Definition pos1.h:458
bool is_add_with_carry_application(const atermpp::aterm &e)
Recogniser for application of @addc.
Definition pos1.h:570
const core::identifier_string & times_name()
Generate identifier *.
Definition pos1.h:578
bool is_c1_function_symbol(const atermpp::aterm &e)
Recogniser for function @c1.
Definition pos1.h:88
const data_expression & arg2(const data_expression &e)
Function for projecting out argument. arg2 from an application.
Definition pos1.h:812
const core::identifier_string & plus_name()
Generate identifier +.
Definition pos1.h:448
const data_expression & right(const data_expression &e)
Function for projecting out argument. right from an application.
Definition pos1.h:776
bool is_times_application(const atermpp::aterm &e)
Recogniser for application of *.
Definition pos1.h:634
bool is_most_significant_digit_application(const atermpp::aterm &e)
Recogniser for application of @most_significant_digit.
Definition pos64.h:249
bool is_concat_digit_application(const atermpp::aterm &e)
Recogniser for application of @concat_digit.
Definition pos64.h:313
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
bool is_plus_application(const atermpp::aterm &e)
Recogniser for application of +.
Definition pos1.h:504
const function_symbol & succ()
Constructor for function symbol succ.
Definition pos1.h:334
function_symbol plus(const sort_expression &s0, const sort_expression &s1)
Definition real1.h:1059
const core::identifier_string & minus_name()
Generate identifier -.
Definition real1.h:1144
function_symbol divides(const sort_expression &s0, const sort_expression &s1)
Definition real1.h:1407
bool is_int2real_application(const atermpp::aterm &e)
Recogniser for application of Int2Real.
Definition real1.h:339
const data_expression & arg2(const data_expression &e)
Function for projecting out argument. arg2 from an application.
Definition real1.h:1989
bool is_plus_application(const atermpp::aterm &e)
Recogniser for application of +.
Definition real1.h:1136
bool is_divides_application(const atermpp::aterm &e)
Recogniser for application of /.
Definition real1.h:1455
const core::identifier_string & divides_name()
Generate identifier /.
Definition real1.h:1399
bool is_reduce_fraction_where_application(const atermpp::aterm &e)
Recogniser for application of @redfracwhr.
Definition real1.h:1771
bool is_creal_application(const atermpp::aterm &e)
Recogniser for application of @cReal.
Definition real1.h:153
bool is_real(const sort_expression &e)
Recogniser for sort expression Real.
Definition real1.h:58
const data_expression & right(const data_expression &e)
Function for projecting out argument. right from an application.
Definition real1.h:1953
const data_expression & arg1(const data_expression &e)
Function for projecting out argument. arg1 from an application.
Definition real1.h:1977
const core::identifier_string & plus_name()
Generate identifier +.
Definition real1.h:1051
const data_expression & left(const data_expression &e)
Function for projecting out argument. left from an application.
Definition real1.h:1941
bool is_times_application(const atermpp::aterm &e)
Recogniser for application of *.
Definition real1.h:1306
bool is_reduce_fraction_application(const atermpp::aterm &e)
Recogniser for application of @redfrac.
Definition real1.h:1705
bool is_negate_application(const atermpp::aterm &e)
Recogniser for application of -.
Definition real1.h:877
bool is_minus_application(const atermpp::aterm &e)
Recogniser for application of -.
Definition real1.h:1221
const data_expression & arg3(const data_expression &e)
Function for projecting out argument. arg3 from an application.
Definition real1.h:2001
const function_symbol & int2real()
Constructor for function symbol Int2Real.
Definition real1.h:295
bool is_pos2real_application(const atermpp::aterm &e)
Recogniser for application of Pos2Real.
Definition real1.h:215
bool is_nat2real_application(const atermpp::aterm &e)
Recogniser for application of Nat2Real.
Definition real1.h:277
bool is_set_comprehension_application(const atermpp::aterm &e)
Recogniser for application of @setcomp.
Definition set1.h:280
bool is_false_function_function_symbol(const atermpp::aterm &e)
Recogniser for function @false_.
Definition set1.h:677
bool is_union_application(const atermpp::aterm &e)
Recogniser for application of +.
Definition set1.h:483
const data_expression & arg4(const data_expression &e)
Function for projecting out argument. arg4 from an application.
Definition set1.h:1262
bool is_true_function_function_symbol(const atermpp::aterm &e)
Recogniser for function @true_.
Definition set1.h:739
bool is_complement_application(const atermpp::aterm &e)
Recogniser for application of !.
Definition set1.h:406
bool is_fset_union_application(const atermpp::aterm &e)
Recogniser for application of @fset_union.
Definition set1.h:1031
const data_expression & left(const data_expression &e)
Function for projecting out argument. left from an application.
Definition set1.h:1190
bool is_in_application(const atermpp::aterm &e)
Recogniser for application of in.
Definition set1.h:344
bool is_fset_intersection_application(const atermpp::aterm &e)
Recogniser for application of @fset_inter.
Definition set1.h:1099
bool is_difference_application(const atermpp::aterm &e)
Recogniser for application of -.
Definition set1.h:649
const data_expression & arg(const data_expression &e)
Function for projecting out argument. arg from an application.
Definition set1.h:1214
bool is_constructor_application(const atermpp::aterm &e)
Recogniser for application of @set.
Definition set1.h:122
bool is_set_fset_application(const atermpp::aterm &e)
Recogniser for application of @setfset.
Definition set1.h:218
const data_expression & arg2(const data_expression &e)
Function for projecting out argument. arg2 from an application.
Definition set1.h:1238
const core::identifier_string & intersection_name()
Generate identifier *.
Definition set1.h:491
bool is_set_enumeration_application(const atermpp::aterm &e)
Recogniser for application of set_enumeration.
const data_expression & arg3(const data_expression &e)
Function for projecting out argument. arg3 from an application.
Definition set1.h:1250
const data_expression & right(const data_expression &e)
Function for projecting out argument. right from an application.
Definition set1.h:1202
const core::identifier_string & union_name()
Generate identifier +.
Definition set1.h:414
function_symbol in(const sort_expression &, const sort_expression &s0, const sort_expression &s1)
Definition set1.h:296
const core::identifier_string & difference_name()
Generate identifier -.
Definition set1.h:576
function_symbol set_fset(const sort_expression &s)
Constructor for function symbol @setfset.
Definition set1.h:174
bool is_intersection_application(const atermpp::aterm &e)
Recogniser for application of *.
Definition set1.h:568
const data_expression & arg1(const data_expression &e)
Function for projecting out argument. arg1 from an application.
Definition set1.h:1226
bool is_greater_application(const DataExpression &e)
Recogniser for application of >
Definition standard.h:343
bool is_set_container(const atermpp::aterm &x)
int precedence(const data_expression &x)
Definition print.h:415
data_expression number(const sort_expression &s, const std::string &n)
Construct numeric expression from a string representing a number in decimal notation.
function_symbol not_equal_to(const sort_expression &s)
Constructor for function symbol !=.
Definition standard.h:163
const data_expression & arg1(const data_expression &e)
Function for projecting out argument. arg1 from an application.
bool is_list_container(const atermpp::aterm &x)
bool is_if_application(const DataExpression &e)
Recogniser for application of if.
Definition standard.h:232
bool is_not_equal_to_application(const DataExpression &e)
Recogniser for application of !=.
Definition standard.h:192
std::set< data::variable > find_all_variables(const data::data_expression &x)
Definition data.cpp:94
bool is_where_clause(const atermpp::aterm &x)
Returns true if the term t is a where clause.
bool is_greater_equal_application(const DataExpression &e)
Recogniser for application of >=.
Definition standard.h:380
bool is_abstraction(const atermpp::aterm &x)
Returns true if the term t is an abstraction.
bool is_untyped_identifier(const atermpp::aterm &x)
Returns true if the term t is an identifier.
bool is_left_associative(const data_expression &x)
Definition print.h:428
std::vector< data_expression > data_expression_vector
\brief vector of data_expressions
std::string pp(const abstraction &x)
Definition data.cpp:39
bool is_right_associative(const data_expression &x)
Definition print.h:434
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.
bool is_fset_container(const atermpp::aterm &x)
bool is_function_update_stable_application(const atermpp::aterm &e)
Recogniser for application of @func_update_stable.
std::set< data::function_symbol > find_function_symbols(const data::data_equation &x)
Definition data.cpp:101
bool is_untyped_set_or_bag_comprehension(const atermpp::aterm &x)
Returns true if the term t is a set/bag comprehension.
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.
data_expression normalize_sorts(const data_expression &x, const data::sort_specification &sortspec)
Definition data.cpp:86
bool is_bag_comprehension(const atermpp::aterm &x)
Returns true if the term t is a bag comprehension.
bool is_set_comprehension(const atermpp::aterm &x)
Returns true if the term t is a set comprehension.
std::string max_machine_number_string()
A string representation indicating the maximal machine number + 1.
bool is_bag_container(const atermpp::aterm &x)
bool is_machine_number(const atermpp::aterm &x)
Returns true if the term t is a machine_number.
bool is_function_update_application(const atermpp::aterm &e)
Recogniser for application of @func_update.
bool is_fbag_container(const atermpp::aterm &x)
bool is_lambda(const atermpp::aterm &x)
Returns true if the term t is a lambda abstraction.
bool is_less_application(const DataExpression &e)
Recogniser for application of <.
Definition standard.h:269
const data_expression & arg3(const data_expression &e)
Function for projecting out argument. arg3 from an application.
bool is_application(const atermpp::aterm &x)
Returns true if the term t is an application.
bool is_less_equal_application(const DataExpression &e)
Recogniser for application of <=.
Definition standard.h:306
const data_expression & arg2(const data_expression &e)
Function for projecting out argument. arg2 from an application.
function_symbol if_(const sort_expression &s)
Constructor for function symbol if.
Definition standard.h:200
bool is_equal_to_application(const DataExpression &e)
Recogniser for application of ==.
Definition standard.h:155
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
Provides utilities for working with data expressions of standard container sorts.
sort_expression operator()(const T &t) const
Definition print.h:587
void print_condition(const T &x, const std::string &arrow=" -> ")
Definition print.h:749
void apply(const data::untyped_set_or_bag_comprehension_binder &x)
Definition print.h:1330
void apply(const data::untyped_sort_variable &x)
Definition print.h:1483
void apply(const data::application &x)
Definition print.h:1531
bool is_cons_list(data_expression x) const
Definition print.h:835
void apply(const machine_number &x)
Definition print.h:2306
void print_container(const Container &container, int container_precedence=-1, const std::string &separator=", ", const std::string &open_bracket="(", const std::string &close_bracket=")")
Definition print.h:547
void apply(const data::untyped_identifier &x)
Definition print.h:1491
void print_sort_list(const Container &container, const std::string &opener="(", const std::string &closer=")", const std::string &separator=", ")
Definition print.h:759
void print_fset_default(const data_expression &x)
Definition print.h:1149
void apply(const data::bag_comprehension_binder &x)
Definition print.h:1342
void apply(const data::set_container &x)
Definition print.h:1407
void apply(const data::set_comprehension_binder &x)
Definition print.h:1336
void print_set_enumeration(const application &x)
Definition print.h:797
void print_binary_data_operation(const application &x, const std::string &op)
Definition print.h:476
void print_cons_list(data_expression x)
Definition print.h:919
void print_sort_declarations(const AliasContainer &aliases, const SortContainer &sorts, const std::string &opener="(", const std::string &closer=")", const std::string &separator=", ")
Definition print.h:2415
void update_mappings(const data_equation &eqn, std::vector< variable > &variables, std::map< core::identifier_string, variable > &variable_map, std::set< core::identifier_string > &function_symbol_names)
Definition print.h:2355
bool is_fbag_cons_list(data_expression x)
Returns true if x is a list composed of cons, insert and cinsert applications.
Definition print.h:863
void print_assignments(const Container &container, bool print_lhs=true, const std::string &opener="", const std::string &closer="", const std::string &separator=", ", const std::string &assignment_symbol=" = ")
Definition print.h:719
void apply(const data::list_container &x)
Definition print.h:1400
void apply(const data::exists &x)
Definition print.h:2334
void apply(const data::fbag_container &x)
Definition print.h:1428
void apply(const data::function_sort &x)
Definition print.h:1459
void print_fset_lambda(const data_expression &x)
Definition print.h:1076
core::identifier_string generate_identifier(const std::string &prefix, const data_expression &context) const
Definition print.h:535
void apply(const data::data_equation &x)
Definition print.h:2344
void apply(const data::alias &x)
Definition print.h:1391
void print_sorted_declarations(const Container &container, bool print_sorts=true, bool join_sorts=true, bool maximally_shared=false, const std::string &opener="(", const std::string &closer=")", const std::string &separator=", ", SortAccessor get_sort=get_sort_default())
Definition print.h:594
void apply(const data::where_clause &x)
Definition print.h:2311
void apply(const data::data_specification &x)
Definition print.h:2484
bool is_fbag_zero(const data_expression &x)
Definition print.h:904
void apply(const data::structured_sort &x)
Definition print.h:1452
void apply(const data::untyped_identifier_assignment &x)
Definition print.h:1321
void print_equations(const Container &equations, const data_specification &data_spec, const std::string &opener="(", const std::string &closer=")", const std::string &separator=", ")
Definition print.h:2455
bool is_fset_false(const data_expression &x)
Definition print.h:894
bool is_abstraction_application(const application &x) const
Definition print.h:830
void apply(const data::lambda_binder &x)
Definition print.h:1360
void apply(const data::structured_sort_constructor_argument &x)
Definition print.h:1366
void apply(const data::variable &x)
Definition print.h:1498
void apply(const data::container_type &x)
Definition print.h:1270
bool is_fbag_one(const data_expression &x)
Definition print.h:909
void apply(const data::basic_sort &x)
Definition print.h:1435
bool is_snoc_list(data_expression x) const
Definition print.h:844
void print_fbag_one(const data_expression &x)
Definition print.h:978
bool is_fbag_lambda(const data_expression &x)
Definition print.h:914
void print_abstraction(const Abstraction &x, const std::string &op)
Definition print.h:1182
void apply(const data::function_symbol &x)
Definition print.h:1505
void apply(const data::exists_binder &x)
Definition print.h:1354
void apply(const data::fset_container &x)
Definition print.h:1421
bool has_conflict(const data_equation &eqn, const std::map< core::identifier_string, variable > &variable_map)
Definition print.h:2375
bool is_numeric_expression(const application &x)
Definition print.h:872
bool is_infix_operation(const application &x) const
Definition print.h:483
void print_fbag_lambda(const data_expression &x)
Definition print.h:995
void apply(const data::untyped_data_parameter &x)
Definition print.h:1313
void apply(const data::abstraction &x)
Definition print.h:2495
void apply(const data::untyped_sort &x)
Definition print.h:1467
void apply(const data::container_sort &x)
Definition print.h:1442
void apply(const data::assignment &x)
Definition print.h:1296
void print_fbag_zero(const data_expression &x)
Definition print.h:958
data::add_traverser_sort_expressions< core::detail::printer, Derived > super
Definition print.h:450
bool is_fset_lambda(const data_expression &x)
Definition print.h:899
void print_snoc_list(data_expression x)
Definition print.h:932
void print_fset_false(const data_expression &x)
Definition print.h:1064
void print_fbag_cons_list(data_expression x)
Definition print.h:1030
bool is_standard_sort(const sort_expression &x)
Definition print.h:880
void apply(const data::untyped_possible_sorts &x)
Definition print.h:1474
void print_unary_data_operation(const application &x, const std::string &op)
Definition print.h:460
bool is_fset_cons_list(data_expression x)
Definition print.h:853
void print_setbag_comprehension(const abstraction &x)
Definition print.h:821
void print_fset_cons_list(data_expression x)
Definition print.h:945
void print_bag_enumeration(const application &x)
Definition print.h:804
void print_variables(const Container &container, bool print_sorts=true, bool join_sorts=true, bool maximally_shared=false, const std::string &opener="(", const std::string &closer=")", const std::string &separator=", ")
Definition print.h:706
void apply(const data::bag_container &x)
Definition print.h:1414
void print_function_application(const application &x)
Definition print.h:1192
void print_fbag_default(const data_expression &x)
Definition print.h:1013
Iter find_conflicting_equation(Iter first, Iter last, std::vector< variable > &variables)
Searches in the range of equations [first, last) for the first equation that conflicts with one of th...
Definition print.h:2396
void print_variable(const Variable &x, bool print_sort=false)
Definition print.h:574
void apply(const data::variable_list &x)
Definition print.h:1306
void apply(const std::pair< data_expression, data_expression > &x)
Definition print.h:1262
void print_binary_data_operation(const application &x, const data_expression &x1, const data_expression &x2, const std::string &op)
Definition print.h:466
void print_list_enumeration(const application &x)
Definition print.h:790
void apply(const data::structured_sort_constructor &x)
Definition print.h:1378
void apply(const data::forall &x)
Definition print.h:2329
void apply(const data::forall_binder &x)
Definition print.h:1348
void apply(const data::lambda &x)
Definition print.h:2339
void print_fset_set_operation(const data_expression &x, const std::string &op)
Definition print.h:1086
void print_fset_true(const data_expression &x)
Definition print.h:1058
bool is_fset_true(const data_expression &x)
Definition print.h:889
Prints the object x to a stream.
Definition print.h:2530
void operator()(const T &x, std::ostream &out)
Definition print.h:2532