mCRL2
Loading...
Searching...
No Matches
smt_lib_solver.h
Go to the documentation of this file.
1// Author(s): Luc Engelen
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
9/// \file mcrl2/data/detail/prover/smt_lib_solver.h
10/// \brief Abstract interface for SMT solvers based on the SMT-LIB format
11
12#ifndef MCRL2_DATA_DETAIL_PROVER_SMT_LIB_SOLVER_H
13#define MCRL2_DATA_DETAIL_PROVER_SMT_LIB_SOLVER_H
14
15#include "mcrl2/core/print.h"
16#include "mcrl2/data/data_expression.h"
17#include "mcrl2/data/data_specification.h" // Added to make this header compile standalone
18#include "mcrl2/data/detail/prover/smt_solver.h"
19
20#ifndef WIN32
21#include <unistd.h>
22#endif
23
24namespace mcrl2::data::detail
25{
26/// The class SMT_LIB_Solver is a base class for SMT solvers that read the SMT-LIB format
27/// [Silvio Ranise and Cesare Tinelli. The SMT-LIB Standard: Version 1.1. Technical Report, Department of Computer
28/// Science, The University of Iowa, 2005. (Available at http://goedel.cs.uiowa.edu/smtlib)]. It inherits from the class
29/// SMT_Solver.
30///
31/// The method SMT_LIB_Solver::translate receives an expression of sort Bool in conjunctive normal form as parameter
32/// a_formula and translates it to a benchmark in SMT-LIB format. The result is saved as field std::string f_benchmark.
33
35{
36 private:
50 bool f_bool2pred = false;
51
52 const data_expression& left(const data_expression& x) const
53 {
54 const application& a = atermpp::down_cast<mcrl2::data::application>(x);
55 return binary_left(a);
56 }
57
58 const data_expression& right(const data_expression& x) const
59 {
60 const application& a = atermpp::down_cast<mcrl2::data::application>(x);
61 return binary_right(a);
62 }
63
64 const data_expression& arg(const data_expression& x) const
65 {
66 const application& a = atermpp::down_cast<mcrl2::data::application>(x);
67 return unary_operand(a);
68 }
69
71 {
72 f_extrasorts = "";
73 if (!f_sorts.empty())
74 {
75 f_extrasorts = " :extrasorts (";
76 sort_expression v_sort;
77 for(std::map < sort_expression, std::size_t >::const_iterator i=f_sorts.begin(); i!=f_sorts.end(); ++i)
78 {
79 if (v_sort != sort_expression())
80 {
81 f_extrasorts = f_extrasorts + " ";
82 }
83 v_sort = i->first;
84 std::stringstream v_sort_string;
85 v_sort_string << "sort" << i->second;
86 f_extrasorts = f_extrasorts + v_sort_string.str();
87 }
88 f_extrasorts = f_extrasorts + ")\n";
89 }
90 }
91
93 {
94 f_operators_extrafuns = "";
95 if (!f_operators.empty())
96 {
97 f_operators_extrafuns = " :extrafuns (";
98 for(std::map < function_symbol, std::size_t >::const_iterator i=f_operators.begin(); i!=f_operators.end(); ++i)
99 {
100 std::stringstream v_operator_string;
101 v_operator_string << "op" << i->second;
102 f_operators_extrafuns = f_operators_extrafuns + "(" + v_operator_string.str();
103 sort_expression v_sort = data_expression(i->first).sort();
104 do
105 {
106 sort_expression_list v_sort_domain_list;
107 if (is_function_sort(v_sort))
108 {
109 v_sort_domain_list = function_sort(v_sort).domain();
110 v_sort = function_sort(v_sort).codomain();
111 }
112 else
113 {
114 v_sort_domain_list = sort_expression_list({v_sort});
115 v_sort = sort_expression();
116 }
117 for (const sort_expression& v_sort_domain_elt : v_sort_domain_list)
118 {
119 if (is_function_sort(v_sort_domain_elt))
120 {
121 throw mcrl2::runtime_error("Function " + data::pp(i->first) +
122 " cannot be translated to the SMT-LIB format.");
123 }
124 if (sort_int::is_int(v_sort_domain_elt))
125 {
126 f_operators_extrafuns = f_operators_extrafuns + " Int";
127 }
128 else if (sort_nat::is_nat(v_sort_domain_elt))
129 {
130 f_operators_extrafuns = f_operators_extrafuns + " Int";
131 }
132 else if (sort_pos::is_pos(v_sort_domain_elt))
133 {
134 f_operators_extrafuns = f_operators_extrafuns + " Int";
135 }
136 else if (sort_real::is_real(v_sort_domain_elt))
137 {
138 f_operators_extrafuns = f_operators_extrafuns + " Real";
139 }
140 else
141 {
142 std::map < sort_expression, std::size_t >::const_iterator j=f_sorts.find(v_sort_domain_elt);
143 std::size_t v_sort_number=f_sorts.size();
144 if (j==f_sorts.end()) // not found
145 {
146 f_sorts[v_sort_domain_elt]=v_sort_number; // Assign a new number to v_sort_domain_elt.
147 }
148 else
149 {
150 v_sort_number=j->second; // get the previously assigned number.
151 }
152 std::stringstream v_sort_string;
153 v_sort_string << "sort" << v_sort_number;
154 f_operators_extrafuns = f_operators_extrafuns + " " + v_sort_string.str();
155 }
156 }
157 }
158 while (v_sort != sort_expression());
159 f_operators_extrafuns = f_operators_extrafuns + ")";
160 }
161 f_operators_extrafuns = f_operators_extrafuns + ")\n";
162 }
163 }
164
166 {
167 f_variables_extrafuns = "";
168 if (!f_variables.empty())
169 {
170 f_variables_extrafuns = " :extrafuns (";
171 }
172
173 for(const variable& v_variable : f_variables)
174 {
175 std::string v_variable_string = v_variable.name();
176 sort_expression v_sort = data_expression(v_variable).sort();
177 if (sort_real::is_real(v_sort))
178 {
179 f_variables_extrafuns = f_variables_extrafuns + "(" + v_variable_string + " Real)";
180 }
181 else if (sort_int::is_int(v_sort))
182 {
183 f_variables_extrafuns = f_variables_extrafuns + "(" + v_variable_string + " Int)";
184 }
185 else if (sort_nat::is_nat(v_sort))
186 {
187 f_variables_extrafuns = f_variables_extrafuns + "(" + v_variable_string + " Int)";
188 }
189 else if (sort_pos::is_pos(v_sort))
190 {
191 f_variables_extrafuns = f_variables_extrafuns + "(" + v_variable_string + " Int)";
192 }
193 else
194 {
195 std::map < sort_expression, std::size_t >::const_iterator j=f_sorts.find(v_sort);
196 std::size_t v_sort_number=f_sorts.size();
197 if (j==f_sorts.end()) // not found
198 {
199 f_sorts[v_sort]=v_sort_number; // Assign a new number to v_sort.
200 }
201 else
202 {
203 v_sort_number=j->second; // get the previously assigned number.
204 }
205
206 std::stringstream v_sort_string;
207 v_sort_string << "sort" << v_sort_number;
208 f_variables_extrafuns = f_variables_extrafuns + "(" + v_variable_string + " " + v_sort_string.str() +")";
209 }
210 }
211 if (!f_variables.empty())
212 {
213 f_variables_extrafuns = f_variables_extrafuns + ")\n";
214 }
215 }
216
218 {
219 f_extrapreds = "";
220 if (f_bool2pred)
221 {
222 assert(f_sorts.count(sort_bool::bool_())>0);
223 std::size_t v_sort_number = f_sorts[sort_bool::bool_()];
224 std::stringstream v_sort_string;
225 v_sort_string << "sort" << v_sort_number;
226 f_extrapreds = " :extrapreds ((bool2pred ";
227 f_extrapreds = f_extrapreds + v_sort_string.str() + ")";
228 f_extrapreds = f_extrapreds + ")\n";
229 }
230 }
231
233 {
234 f_sorts_notes = "";
235 if (!f_sorts.empty())
236 {
237 f_sorts_notes = " :notes \"";
238 for(std::map < sort_expression, std::size_t >::const_iterator i=f_sorts.begin(); i!=f_sorts.end(); ++i)
239 {
240 std::stringstream v_sort_string;
241 v_sort_string << "sort" << i->second;
242 std::string v_sort_original_id = pp(i->first);
243 f_sorts_notes = f_sorts_notes + "(" + v_sort_string.str() + " = " + v_sort_original_id + ")";
244 }
245 f_sorts_notes = f_sorts_notes + "\"\n";
246 }
247 }
248
250 {
251 f_operators_notes = "";
252 if (!f_operators.empty())
253 {
254 f_operators_notes = " :notes \"";
255 for(std::map < function_symbol, std::size_t >::const_iterator i=f_operators.begin(); i!=f_operators.end(); ++i)
256 {
257 std::stringstream v_operator_string;
258 v_operator_string << "op" << i->second;
259 std::string v_operator_original_id = i->first.name();
260 f_operators_notes = f_operators_notes + "(" + v_operator_string.str() + " = " + v_operator_original_id + ")";
261 }
262 f_operators_notes = f_operators_notes + "\"\n";
263 }
264 }
265
267 {
268 f_predicates_notes = "";
269 if (f_bool2pred)
270 {
271 f_predicates_notes =
272 " :notes \"bool2pred was introduced, because the smt-lib format cannot deal\"\n"
273 " :notes \"with boolean variables or functions returning boolean values.\"\n";
274 }
275 }
276
277 void translate_clause(const data_expression& a_clause, const bool a_expecting_predicate)
278 {
280 {
281 translate_not(a_clause);
282 }
283 else if (is_equal_to_application(a_clause))
284 {
285 translate_equality(a_clause);
286 }
287 else if (is_not_equal_to_application(a_clause))
288 {
290 }
291 else if (is_greater_application(a_clause))
292 {
294 }
295 else if (is_greater_equal_application(a_clause))
296 {
298 }
299 else if (is_less_application(a_clause))
300 {
301 translate_less_than(a_clause);
302 }
303 else if (is_less_equal_application(a_clause))
304 {
306 }
307 else if (sort_real::is_plus_application(a_clause))
308 {
309 translate_plus(a_clause);
310 }
311 else if (sort_real::is_negate_application(a_clause))
312 {
314 }
315 else if (sort_real::is_minus_application(a_clause))
316 {
318 }
319 else if (sort_real::is_times_application(a_clause))
320 {
322 }
324 {
325 translate_max(a_clause);
326 }
328 {
329 translate_min(a_clause);
330 }
331 else if (sort_real::is_abs_application(a_clause))
332 {
333 translate_abs(a_clause);
334 }
335 else if (sort_real::is_succ_application(a_clause))
336 {
337 translate_succ(a_clause);
338 }
339 else if (sort_real::is_pred_application(a_clause))
340 {
341 translate_pred(a_clause);
342 }
344 {
345 translate_add_c(a_clause);
346 }
347#ifndef MCRL2_ENABLE_MACHINENUMBERS
348 else if (sort_nat::is_cnat_application(a_clause))
349 {
350 translate_c_nat(a_clause);
351 }
352 else if (sort_int::is_cint_application(a_clause))
353 {
354 translate_c_int(a_clause);
355 }
356#endif
357 else if (sort_int::is_integer_constant(a_clause))
358 {
360 }
361 else if (sort_nat::is_natural_constant(a_clause))
362 {
364 }
365 else if (sort_pos::is_positive_constant(a_clause))
366 {
368 }
369 else if (sort_bool::is_true_function_symbol(a_clause) && a_expecting_predicate)
370 {
372 }
373 else if (sort_bool::is_false_function_symbol(a_clause) && a_expecting_predicate)
374 {
376 }
377 else if (is_variable(a_clause))
378 {
379 if (a_expecting_predicate)
380 {
382 }
383 else if (sort_nat::is_nat(a_clause.sort()))
384 {
385 translate_nat_variable(atermpp::down_cast<variable>(a_clause));
386 }
387 else if (sort_pos::is_pos(a_clause.sort()))
388 {
389 translate_pos_variable(atermpp::down_cast<variable>(a_clause));
390 }
391 else
392 {
393 translate_variable(atermpp::down_cast<variable>(a_clause));
394 }
395 }
396 else if (is_application(a_clause))
397 {
398 if (a_expecting_predicate)
399 {
401 }
402 else
403 {
405 }
406 }
407 else if (data::is_function_symbol(a_clause))
408 {
410 }
411 else
412 {
413 throw mcrl2::runtime_error("Unable to handle the current clause (" +
414 data::pp(a_clause) + ").");
415 }
416 }
417
419 {
420 f_bool2pred = true;
421 f_formula = f_formula + "(bool2pred ";
422 translate_clause(a_clause, false);
423 f_formula = f_formula + ")";
424 }
425
426 void translate_not(const data_expression& a_clause)
427 {
428 const data_expression v_clause=arg(a_clause);
429 f_formula = f_formula + "(not ";
430 translate_clause(v_clause, true);
431 f_formula = f_formula + ")";
432 }
433
435 {
436 const data_expression v_clause_1 = left(a_clause);
437 const data_expression v_clause_2 = right(a_clause);
438 f_formula = f_formula + "(= ";
439 translate_clause(v_clause_1, false);
440 f_formula = f_formula + " ";
441 translate_clause(v_clause_2, false);
442 f_formula = f_formula + ")";
443 }
444
446 {
447 const data_expression v_clause_1 = left(a_clause);
448 const data_expression v_clause_2 = right(a_clause);
449 f_formula = f_formula + "(distinct ";
450 translate_clause(v_clause_1, false);
451 f_formula = f_formula + " ";
452 translate_clause(v_clause_2, false);
453 f_formula = f_formula + ")";
454 }
455
457 {
458 const data_expression v_clause_1 = left(a_clause);
459 const data_expression v_clause_2 = right(a_clause);
460 f_formula = f_formula + "(> ";
461 translate_clause(v_clause_1, false);
462 f_formula = f_formula + " ";
463 translate_clause(v_clause_2, false);
464 f_formula = f_formula + ")";
465 }
466
468 {
469 const data_expression v_clause_1 = left(a_clause);
470 const data_expression v_clause_2 = right(a_clause);
471 f_formula = f_formula + "(>= ";
472 translate_clause(v_clause_1, false);
473 f_formula = f_formula + " ";
474 translate_clause(v_clause_2, false);
475 f_formula = f_formula + ")";
476 }
477
479 {
480 const data_expression v_clause_1 = left(a_clause);
481 const data_expression v_clause_2 = right(a_clause);
482 f_formula = f_formula + "(< ";
483 translate_clause(v_clause_1, false);
484 f_formula = f_formula + " ";
485 translate_clause(v_clause_2, false);
486 f_formula = f_formula + ")";
487 }
488
490 {
491 const data_expression v_clause_1 = left(a_clause);
492 const data_expression v_clause_2 = right(a_clause);
493 f_formula = f_formula + "(<= ";
494 translate_clause(v_clause_1, false);
495 f_formula = f_formula + " ";
496 translate_clause(v_clause_2, false);
497 f_formula = f_formula + ")";
498 }
499
500 void translate_plus(const data_expression& a_clause)
501 {
502 const data_expression v_clause_1 = left(a_clause);
503 const data_expression v_clause_2 = right(a_clause);
504 f_formula = f_formula + "(+ ";
505 translate_clause(v_clause_1, false);
506 f_formula = f_formula + " ";
507 translate_clause(v_clause_2, false);
508 f_formula = f_formula + ")";
509 }
510
512 {
513 const data_expression v_clause = arg(a_clause);
514 f_formula = f_formula + "(~";
515 translate_clause(v_clause, false);
516 f_formula = f_formula + ")";
517 }
518
520 {
521 const data_expression v_clause_1 = left(a_clause);
522 const data_expression v_clause_2 = right(a_clause);
523 f_formula = f_formula + "(- ";
524 translate_clause(v_clause_1, false);
525 f_formula = f_formula + " ";
526 translate_clause(v_clause_2, false);
527 f_formula = f_formula + ")";
528 }
529
531 {
532 const data_expression v_clause_1 = left(a_clause);
533 const data_expression v_clause_2 = right(a_clause);
534 f_formula = f_formula + "(* ";
535 translate_clause(v_clause_1, false);
536 f_formula = f_formula + " ";
537 translate_clause(v_clause_2, false);
538 f_formula = f_formula + ")";
539 }
540
541 void translate_max(const data_expression& a_clause)
542 {
543 const data_expression v_clause_1 = left(a_clause);
544 const data_expression v_clause_2 = right(a_clause);
545 f_formula = f_formula + "(ite (>= ";
546 translate_clause(v_clause_1, false);
547 f_formula = f_formula + " ";
548 translate_clause(v_clause_2, false);
549 f_formula = f_formula + ") ";
550 translate_clause(v_clause_1, false);
551 f_formula = f_formula + " ";
552 translate_clause(v_clause_2, false);
553 f_formula = f_formula + ")";
554 }
555
556 void translate_min(const data_expression& a_clause)
557 {
558 const data_expression v_clause_1 = left(a_clause);
559 const data_expression v_clause_2 = right(a_clause);
560 f_formula = f_formula + "(ite (<= ";
561 translate_clause(v_clause_1, false);
562 f_formula = f_formula + " ";
563 translate_clause(v_clause_2, false);
564 f_formula = f_formula + ") ";
565 translate_clause(v_clause_1, false);
566 f_formula = f_formula + " ";
567 translate_clause(v_clause_2, false);
568 f_formula = f_formula + ")";
569 }
570
571 void translate_abs(const data_expression& a_clause)
572 {
573 const data_expression v_clause = arg(a_clause);
574 f_formula = f_formula + "(ite (< 0 ";
575 translate_clause(v_clause, false);
576 f_formula = f_formula + ") ~";
577 translate_clause(v_clause, false);
578 f_formula = f_formula + " ";
579 translate_clause(v_clause, false);
580 f_formula = f_formula + ")";
581 }
582
583 void translate_succ(const data_expression& a_clause)
584 {
585 const data_expression v_clause = arg(a_clause);
586 f_formula = f_formula + "(+ ";
587 translate_clause(v_clause, false);
588 f_formula = f_formula + " 1)";
589 }
590
591 void translate_pred(const data_expression& a_clause)
592 {
593 const data_expression v_clause = arg(a_clause);
594 f_formula = f_formula + "(- ";
595 translate_clause(v_clause, false);
596 f_formula = f_formula + " 1)";
597 }
598
599 void translate_add_c(const data_expression& a_clause)
600 {
601 const application& v_clause = atermpp::down_cast<application>(a_clause);
602 application::const_iterator arg = v_clause.begin();
603 const data_expression v_clause_1 = *arg++;
604 const data_expression v_clause_2 = *arg++;
605 const data_expression v_clause_3 = *arg++;
606 f_formula = f_formula + "(ite ";
607 translate_clause(v_clause_1, true);
608 f_formula = f_formula + " (+ ";
609 translate_clause(v_clause_2, false);
610 f_formula = f_formula + " ";
611 translate_clause(v_clause_3, false);
612 f_formula = f_formula + " 1) (+ ";
613 translate_clause(v_clause_2, false);
614 f_formula = f_formula + " ";
615 translate_clause(v_clause_3, false);
616 f_formula = f_formula + "))";
617 }
618
619#ifndef MCRL2_ENABLE_MACHINENUMBERS
620 void translate_c_nat(const data_expression& a_clause)
621 {
622 const data_expression v_clause = arg(a_clause);
623 translate_clause(v_clause, false);
624 }
625
626 void translate_c_int(const data_expression& a_clause)
627 {
628 const data_expression v_clause = arg(a_clause);
629 translate_clause(v_clause, false);
630 }
631#endif
632
634 {
635 data_expression h = atermpp::down_cast<application>(a_clause).head();
636 const function_symbol& v_operator = atermpp::down_cast<function_symbol>(h);
637 std::map < function_symbol, std::size_t >::const_iterator i=f_operators.find(v_operator);
638
639 std::size_t v_operator_number=f_operators.size(); // This is the value if v_operator does not occur in f_operators.
640 if (i==f_operators.end()) // not found.
641 {
642 f_operators[v_operator]=v_operator_number;
643 }
644 else
645 {
646 v_operator_number=i->second; // this is the number already assigned to v_operator.
647 }
648 std::stringstream v_operator_string;
649 v_operator_string << "op" << v_operator_number;
650 f_formula = f_formula + "(" + v_operator_string.str();
651
652 if (data::is_application(a_clause))
653 {
654 const data::application& a = atermpp::down_cast<data::application>(a_clause);
655 for (const data_expression& i : a)
656 {
657 f_formula = f_formula + " ";
658 translate_clause(i, false);
659 }
660 }
661 f_formula = f_formula + ")";
662 }
663
664 void translate_variable(const variable& a_clause)
665 {
666 std::string v_string = a_clause.name();
667 f_formula = f_formula + v_string;
668
669 f_variables.insert(a_clause);
670 }
671
672 void translate_nat_variable(const variable& a_clause)
673 {
674 std::string v_string = a_clause.name();
675 f_formula = f_formula + v_string;
676
677 f_variables.insert(a_clause);
678 f_nat_variables.insert(a_clause);
679 }
680
681 void translate_pos_variable(const variable& a_clause)
682 {
683 std::string v_string = a_clause.name();
684 f_formula = f_formula + v_string;
685
686 f_variables.insert(a_clause);
687 f_pos_variables.insert(a_clause);
688 }
689
691 {
692 std::string v_value(data::sort_int::integer_constant_as_string(data::data_expression(a_clause)));
693 if (v_value[0] == '-')
694 {
695 v_value[0] = '~';
696 f_formula = f_formula + "(" + v_value + ")";
697 }
698 else
699 {
700 f_formula = f_formula + v_value;
701 }
702 }
703
705 {
706 std::string v_value(data::sort_nat::natural_constant_as_string(data::data_expression(a_clause)));
707 f_formula = f_formula + v_value;
708 }
709
711 {
712 std::string v_value(data::sort_pos::positive_constant_as_string(data::data_expression(a_clause)));
713 f_formula = f_formula + v_value;
714 }
715
717 {
718 f_formula = f_formula + "true";
719 }
720
722 {
723 f_formula = f_formula + "false";
724 }
725
727 {
728 const function_symbol& v_operator = atermpp::down_cast<function_symbol>(a_clause);
729 std::map < function_symbol, std::size_t >::const_iterator i=f_operators.find(v_operator);
730
731 std::size_t v_operator_number=f_operators.size(); // This is the value if v_operator does not occur in f_operators.
732 if (i==f_operators.end()) // not found.
733 {
734 f_operators[v_operator]=v_operator_number;
735 }
736 else
737 {
738 v_operator_number=i->second; // this is the number already assigned to v_operator.
739 }
740
741 std::stringstream v_operator_string;
742 v_operator_string << "op" << v_operator_number;
743 f_formula = f_formula + v_operator_string.str();
744 }
745
747 {
748 for(const variable& f_nat_variable : f_nat_variables)
749 {
750 std::string v_variable_string = f_nat_variable.name();
751 f_formula = f_formula + " (>= " + v_variable_string + " 0)";
752 }
753 }
754
756 {
757 for(const variable& f_pos_variable : f_pos_variables)
758 {
759 std::string v_variable_string = f_pos_variable.name();
760 f_formula = f_formula + " (>= " + v_variable_string + " 1)";
761 }
762 }
763
764 protected:
766
767 /// precondition: The argument passed as parameter a_formula is a list of expressions of sort Bool in internal mCRL2
768 /// format. The argument represents a formula in conjunctive normal form, where the elements of the list represent the
769 /// clauses
770 void translate(data_expression_list a_formula)
771 {
772 data_expression v_clause;
773
774 f_variables.clear();
775 f_nat_variables.clear();
776 f_pos_variables.clear();
777 f_bool2pred = false;
778
779 f_formula = " :formula (and";
780 mCRL2log(log::log_level_t::verbose) << "Formula to be solved: " << data::pp(a_formula) << std::endl;
781 while (!a_formula.empty())
782 {
783 v_clause = a_formula.front();
784 a_formula.pop_front();
785 f_formula = f_formula + " ";
786 translate_clause(v_clause, true);
787 }
790 f_formula = f_formula + ")\n";
798 f_benchmark =
799 "(benchmark nameless\n" + f_sorts_notes + f_operators_notes + f_predicates_notes +
800 f_extrasorts + f_operators_extrafuns + f_variables_extrafuns + f_extrapreds + f_formula +
801 ")\n";
802 mCRL2log(log::log_level_t::verbose) << "Corresponding benchmark:" << std::endl << f_benchmark;;
803 }
804
805
806 public:
807 SMT_LIB_Solver() = default;
808
809 ~SMT_LIB_Solver() override = default;
810};
811
812namespace prover
813{
814
815/**
816 * Template class for SMT provers that come as an external binary and use the
817 * SMT-lib format. Input to the tool is specified on standard input,
818 * output is read from standard output and matches one of the strings:
819 * "sat", "unsat", "unknown".
820 *
821 * Parameter T follows the curiously recurring template pattern (CRTP). Type T
822 * is required to have the name and exec methods as in the example below.
823 *
824 * \code
825 * class cvc_smt_solver : public binary_smt_solver< cvc_smt_solver > {
826 * inline static char* name() {
827 * return "CVC3";
828 * }
829 *
830 * inline static void exec() {
831 * ::execlp("cvc", "cvc3", "-lang smt-lib", 0);
832 * }
833 * };
834 * \endcode
835 **/
836template < typename T >
838{
839
840 protected:
841
842 // \brief Calls one of the exec functions
843 static bool execute(std::string const& benchmark);
844
845 public:
846
847 // \brief Checks the availability/usability of the prover
848 static bool usable();
849};
850#if !(defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__))
851/// The class inherits from the class SMT_LIB_Solver. It uses the SMT solver
852/// CVC / (http://www.cs.nyu.edu/acsys/cvcl/) to determine the satisfiability
853/// of propositional formulas. To use the solver CVC / the directory containing
854/// the corresponding executable must be in the path.
855///
856/// The static method usable can be used to check checks if CVC's executable is indeed available.
857///
858/// The method SMT_Solver_CVC::is_satisfiable receives a formula in conjunctive normal form as parameter a_formula and
859/// indicates whether or not this formula is satisfiable.
860class cvc_smt_solver : public SMT_LIB_Solver, public binary_smt_solver< cvc_smt_solver >
861{
862 friend class binary_smt_solver< cvc_smt_solver >;
863
864 private:
865
866 inline static char const* name()
867 {
868 return "CVC3";
869 }
870
871 inline static void exec()
872 {
873 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) execlp is an inherently variadic POSIX API.
874 ::execlp("cvc3", "cvc3", "-lang", "smt", (char*)nullptr);
875 }
876
877 public:
878
879 /// precondition: The argument passed as parameter a_formula is a list of expressions of sort Bool in internal mCRL2
880 /// format. The argument represents a formula in conjunctive normal form, where the elements of the list represent the
881 /// clauses
882 bool is_satisfiable(const data_expression_list& a_formula) override
883 {
884 translate(a_formula);
885
886 return execute(f_benchmark);
887 }
888};
889
890/// The class inherits from the class SMT_LIB_Solver. It uses the SMT solver
891/// Z3 / (https://github.com/Z3Prover/z3) to determine the satisfiability
892/// of propositional formulas. To use the solver Z3 / the directory containing
893/// the corresponding executable must be in the path.
894///
895/// The static method usable can be used to check checks if Z3's executable is indeed available.
896///
897/// The method z3_smt_solver::is_satisfiable receives a formula in conjunctive normal form as parameter a_formula and
898/// indicates whether or not this formula is satisfiable.
899class z3_smt_solver : public SMT_LIB_Solver, public binary_smt_solver< z3_smt_solver >
900{
901 friend class binary_smt_solver< z3_smt_solver >;
902
903 private:
904
905 inline static char const* name()
906 {
907 return "Z3";
908 }
909
910 inline static void exec()
911 {
912 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) execlp is an inherently variadic POSIX API.
913 ::execlp("z3", "z3", "-smt", "-in", (char*)nullptr);
914 }
915
916 public:
917
918 /// precondition: The argument passed as parameter a_formula is a list of expressions of sort Bool in internal mCRL2
919 /// format. The argument represents a formula in conjunctive normal form, where the elements of the list represent the
920 /// clauses
921 bool is_satisfiable(const data_expression_list& a_formula) override
922 {
923 translate(a_formula);
924
925 return execute(f_benchmark);
926 }
927};
928
929/// The class inherits from the class SMT_LIB_Solver. It uses the SMT solver Ario 1.1
930/// (http://www.eecs.umich.edu/~ario/) to determine the satisfiability of propositional formulas. To use the solver Ario
931/// 1.1, the directory containing the corresponding executable must be in the path.
932///
933/// The static method usable can be used to check checks if CVC's executable is indeed available.
934///
935/// The method is_satisfiable receives a formula in conjunctive normal form as parameter a_formula and
936/// indicates whether or not this formula is satisfiable.
937class ario_smt_solver : public SMT_LIB_Solver, public binary_smt_solver< ario_smt_solver >
938{
939 friend class binary_smt_solver< ario_smt_solver >;
940
941 private:
942
943 inline static char const* name()
944 {
945 return "Ario";
946 }
947
948 inline static void exec()
949 {
950 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) execlp is an inherently variadic POSIX API.
951 ::execlp("ario", "ario", (char*)nullptr);
952 }
953
954 public:
955
956 /// precondition: The argument passed as parameter a_formula is a list of expressions of sort Bool in internal mCRL2
957 /// format. The argument represents a formula in conjunctive normal form, where the elements of the list represent the
958 /// clauses
959 bool is_satisfiable(const data_expression_list& a_formula) override
960 {
961 translate(a_formula);
962
963 return execute(f_benchmark);
964 }
965};
966#endif
967} // namespace prover
968
969} // namespace mcrl2::data::detail
970
971#endif
aterm()
Default constructor.
Definition aterm.h:51
A unordered_map class in which aterms can be stored.
An abstraction expression.
Definition abstraction.h:23
const variable_list & variables() const
Definition abstraction.h:60
abstraction(const binder_type &binding_operator, const variable_list &variables, const data_expression &body)
Constructor.
Definition abstraction.h:39
const data_expression & body() const
Definition abstraction.h:65
const binder_type & binding_operator() const
Definition abstraction.h:55
Rewriter class for the mCRL2 Library. It only works for terms of type data_expression and data_expres...
Definition rewriter.h:26
const data::enumerator_identifier_generator & identifier_generator() const
Expose the identifier generator present in m_rewriter.
Definition rewriter.h:44
basic_rewriter(const data_specification &d, const used_data_equation_selector &equation_selector, const strategy s=rewrite_strategy::jitty)
Constructor.
Definition rewriter.h:71
basic_rewriter(const std::shared_ptr< detail::Rewriter > &r)
Constructor.
Definition rewriter.h:53
basic_rewriter(const basic_rewriter &other)=default
Copy Constructor.
basic_rewriter & operator=(const basic_rewriter &other)=default
Assignment operator.
std::shared_ptr< detail::Rewriter > m_rewriter
The wrapped Rewriter.
Definition rewriter.h:33
basic_rewriter(const data_specification &d, const strategy s=rewrite_strategy::jitty)
Constructor.
Definition rewriter.h:66
\brief A data equation
const data_expression & lhs() const
const variable_list & variables() const
data_expression & operator=(const data_expression &) noexcept=default
data_expression & operator=(data_expression &&) noexcept=default
sort_expression sort() const
Returns the sort of the data expression.
Definition data.cpp:107
The class BDD_Info provides information about the structure of binary decision diagrams.
Definition bdd_info.h:22
static const mcrl2::data::data_expression & get_true_branch(const mcrl2::data::data_expression &a_bdd)
Method that returns the true-branch of a BDD.
Definition bdd_info.h:43
static bool is_if_then_else(const data_expression &a_bdd)
Method that indicates wether or not the root of a BDD is a guard node.
Definition bdd_info.h:78
static bool is_false(const data_expression &a_bdd)
Method that indicates whether or not a BDD equals false.
Definition bdd_info.h:69
static const mcrl2::data::data_expression & get_guard(const mcrl2::data::data_expression &a_bdd)
Method that returns the guard of a BDD.
Definition bdd_info.h:35
static const mcrl2::data::data_expression & argument(const mcrl2::data::data_expression &x, std::size_t n)
Definition bdd_info.h:24
static const mcrl2::data::data_expression & get_false_branch(const mcrl2::data::data_expression &a_bdd)
Method that returns the false-branch of a BDD.
Definition bdd_info.h:51
static bool is_true(const data_expression &a_bdd)
Method that indicates whether or not a BDD equals true.
Definition bdd_info.h:60
Base class for eliminating inconsistent paths from BDDs.
data_expression simplify(const data_expression &a_bdd) override
Returns a BDD without inconsistent paths, equivalent to a_bdd. precondition: The argument passed as p...
data_expression aux_simplify(const data_expression &a_bdd, const data_expression_list &a_path)
Simplifies the BDD a_bdd using path a_path. Paths whose guards in conjunction with the guards in.
BDD_Info f_bdd_info
Class that provides information about the structure of BDDs.
SMT_Solver * f_smt_solver
Pointer to an SMT solver used to determine whether or not a path is inconsistent.
bool variables_overlap(const data_expression &a_expression_1, const data_expression &a_expression_2)
Returns true if the expression a_expression_1 has variables in common with expression a_expression_2.
BDD_Path_Eliminator(smt_solver_type a_solver_type)
Constructor that initializes the field BDD_Path_Eliminator::f_smt_solver.
data_expression_list create_condition(data_expression_list a_path, const data_expression &a_guard, bool a_minimal)
Returns a list representing the conjunction of all guards in a_path and the guard a_guard.
bool get_branch(const data_expression &a_bdd, const bool a_polarity, data_expression &result)
Returns branch of the BDD a_bdd, depending on the polarity a_polarity.
Definition bdd_prover.h:423
Induction f_induction
Class that creates all statements needed to prove a given property using induction.
Definition bdd_prover.h:144
strategy rewriter_strategy() const
Returns the strategy of the rewriter used inside this proving rewriter.
Definition bdd_prover.h:618
std::vector< variable > f_variables
The variables in the expression in order.
Definition bdd_prover.h:130
std::shared_ptr< BDD_Simplifier > f_bdd_simplifier
Class that simplifies a BDD.
Definition bdd_prover.h:141
static constexpr bool f_reverse
Flag indicating whether or not the result of the comparison between the first two arguments.
Definition bdd_prover.h:94
void set_substitution(substitution_type &sigma)
Set the substitution to be used to construct the BDD.
Definition bdd_prover.h:523
void set_formula(const data_expression &formula)
Sets Prover::f_formula to formula. precondition: the argument passed as parameter formula is an expre...
Definition bdd_prover.h:625
std::string indent(size_t n)
Definition bdd_prover.h:178
bool smallest(const data_expression &formula, data_expression &result)
Returns the smallest guard in the formula formula.
Definition bdd_prover.h:338
data_expression f_bdd
A binary decision diagram in the internal representation of mCRL2.
Definition bdd_prover.h:467
const Info f_info
A class that provides information about expressions.
Definition bdd_prover.h:105
data_expression bdd_down(const data_expression &formula, const size_t a_indent=0)
Creates the EQ-BDD corresponding to the formula formula.
Definition bdd_prover.h:184
static constexpr bool f_full
Flag indicating whether or not the arguments of equality functions are taken into account.
Definition bdd_prover.h:98
void eliminate_paths()
Removes all inconsistent paths from the BDD BDD_Prover::f_bdd.
Definition bdd_prover.h:248
BDD_Prover(const rewriter &r, double time_limit=0, bool apply_induction=false)
Definition bdd_prover.h:513
data_expression get_counter_example()
Returns all the guards on a path in the BDD that leads to a leaf labelled "false",...
Definition bdd_prover.h:584
substitution_type bdd_sigma
A binary decision diagram in the internal representation of the rewriter.
Definition bdd_prover.h:464
Answer f_tautology
A flag that indicates whether or not the formala Prover::f_formula is a tautology.
Definition bdd_prover.h:114
Answer is_contradiction()
Indicates whether or not the formula Prover::f_formula is a contradiction.
Definition bdd_prover.h:542
data_expression f_formula
An expression of sort Bool.
Definition bdd_prover.h:102
std::chrono::milliseconds f_deadline
A timestamp representing the moment when the maximal amount of milliseconds has been spent on process...
Definition bdd_prover.h:123
bool f_processed
A flag that indicates whether or not the formala Prover::f_formula has been processed.
Definition bdd_prover.h:111
void update_answers()
Updates the values of Prover::f_tautology and Prover::f_contradiction.
Definition bdd_prover.h:266
std::shared_ptr< detail::Rewriter > get_rewriter()
Returns the rewriter used by this prover (i.e. it returns Prover::f_rewriter).
Definition bdd_prover.h:612
const double f_time_limit
An integer representing the maximal amount of seconds to be spent on processing a formula.
Definition bdd_prover.h:120
Manipulator f_manipulator
A class that can be used to manipulate expressions.
Definition bdd_prover.h:108
bool f_apply_induction
A flag indicating whether or not induction on lists is applied.
Definition bdd_prover.h:127
void build_bdd()
Constructs the EQ-BDD corresponding to the formula Prover::f_formula.
Definition bdd_prover.h:147
std::unordered_map< data_expression, data_expression > f_smallest
A hashtable that maps formulas to the smallest guard occuring in those formulas.
Definition bdd_prover.h:138
Answer f_contradiction
A flag that indicates whether or not the formala Prover::f_formula is a contradiction.
Definition bdd_prover.h:117
std::unordered_map< data_expression, data_expression > f_formula_to_bdd
A hashtable that maps formulas to BDDs.
Definition bdd_prover.h:134
data_expression get_bdd()
Returns the BDD BDD_Prover::f_bdd.
Definition bdd_prover.h:549
data_expression get_witness()
Returns all the guards on a path in the BDD that leads to a leaf labelled "true", if such a leaf exis...
Definition bdd_prover.h:556
void set_substitution_internal(substitution_type &sigma)
Set the substitution in internal format to be used to construct the BDD.
Definition bdd_prover.h:529
Answer is_tautology()
Indicates whether or not the formula Prover::f_formula is a tautology.
Definition bdd_prover.h:535
BDD_Prover(const data_specification &data_spec, const used_data_equation_selector &equations_selector, mcrl2::data::rewriter::strategy a_rewrite_strategy=mcrl2::data::rewrite_strategy::jitty, double a_time_limit=0, bool a_path_eliminator=false, smt_solver_type a_solver_type=smt_solver_type::solver_type_cvc, bool a_apply_induction=false)
Definition bdd_prover.h:470
A base class for simplifying binary decision diagrams.
void set_time_limit(time_t a_time_limit)
Sets the attribute BDD_Simplifier::f_deadline.
virtual data_expression simplify(const data_expression &a_bdd)
Returns a simplified BDD, equivalent to the bdd a_bdd. precondition: The argument passed as parameter...
virtual ~BDD_Simplifier()=default
Destructor without any additional functionality.
time_t f_deadline
An integer representing the moment in time when the maximal amount of seconds has been spent on simpl...
The class Induction generates statements corresponding to.
Definition induction.h:25
Base class for classes that provide information about the structure of.
Definition info.h:32
data_expression get_operator(const data_expression &term) const
Returns the main operator of the term term;.
Definition info.h:236
constexpr Info(bool a_full, bool a_reverse)
Constructor that initializes the rewriter.
Definition info.h:181
Compare_Result compare_term_free_variables(const data_expression &term1, const data_expression &term2) const
Definition info.h:136
Compare_Result compare_guard_equality(const data_expression &guard1, const data_expression &guard2) const
Compares two guards by their arguments.
Definition info.h:114
Compare_Result compare_address(const atermpp::aterm &term1, const atermpp::aterm &term2) const
Definition info.h:51
static bool occurs(const data_expression &t1, const data_expression &t2)
Definition info.h:187
Compare_Result lexico(const Compare_Result &a_result1, const Compare_Result &a_result2) const
Definition info.h:44
Compare_Result compare_term_type(const data_expression &term1, const data_expression &term2) const
Compares terms by their type.
Definition info.h:152
std::size_t get_number_of_arguments(const data_expression &a_term) const
Returns the number of arguments of the main operator of a term.
Definition info.h:223
double get_guard_structure(const data_expression &guard, const std::vector< variable > &f_variables) const
Returns an integer corresponding to the structure of the guard passed as argument guard.
Definition info.h:68
Compare_Result compare_term_occurs(const data_expression &term1, const data_expression &term2) const
Compares terms by checking whether one is a part of the other.
Definition info.h:166
const bool f_full
Flag indicating whether or not the arguments of equality functions are taken into account.
Definition info.h:37
Compare_Result compare_guard_structure(const data_expression &guard1, const data_expression &guard2, const std::vector< variable > &f_variables) const
Compares the structure of two guards.
Definition info.h:100
Compare_Result compare_term(const data_expression &term1, const data_expression &term2) const
Compares two terms.
Definition info.h:205
Compare_Result compare_guard(const data_expression &guard1, const data_expression &guard2, const std::vector< variable > &f_variables) const
Compares two guards.
Definition info.h:193
const bool f_reverse
Flag indicating whether or not the result of the comparison between the first two arguments.
Definition info.h:42
Base class for classes that provide functionality to modify or create terms.
Definition manipulator.h:23
data_expression orient(const data_expression &a_term)
Orients the term a_term such that all equations of the form t1 == t2 are.
Manipulator(const Info &a_info)
Constructor initializing the rewriter and the field f_info.
data_expression set_true(const data_expression &a_formula, const data_expression &a_guard) const
Initializes the table Manipulator::f_set_true and calls.
std::unordered_map< data_expression, data_expression > f_orient
A table used by the method Manipulator::orient. The method Manipulator::orient stores resulting terms...
Definition manipulator.h:33
data_expression set_false(const data_expression &a_formula, const data_expression &a_guard) const
Initializes the table Manipulator::f_set_false and calls the method.
const Info & f_info
A class that provides information on the structure of expressions in one of the.
Definition manipulator.h:27
static data_expression make_reduced_if_then_else(const data_expression &a_expr, const data_expression &a_high, const data_expression &a_low)
Returns an expression in the internal format of the rewriter with the jitty strategy.
data_expression set_false_auxiliary(const data_expression &a_formula, const data_expression &a_guard, std::unordered_map< data_expression, data_expression > &f_set_false) const
Replaces all occurences of a_guard in a_formula by false.
Definition manipulator.h:98
data_expression set_true_auxiliary(const data_expression &a_formula, const data_expression &a_guard, std::unordered_map< data_expression, data_expression > &f_set_true) const
Replaces all occurences of a_guard in a_formula by true. Additionally, if the variable.
Definition manipulator.h:38
RewriterProver(const data_specification &data_spec, mcrl2::data::rewriter::strategy strat, const used_data_equation_selector &equations_selector)
Definition with_prover.h:28
RewriterProver(const RewriterProver &other)=delete
data_expression rewrite(const data_expression &t, substitution_type &sigma) override
Rewrite an mCRL2 data term.
Definition with_prover.h:68
rewrite_strategy getStrategy() override
Get rewriter strategy that is used.
Definition with_prover.h:38
void rewrite(data_expression &result, const data_expression &t, substitution_type &sigma) override
Rewrite an mCRL2 data term.
Definition with_prover.h:53
RewriterProver(const RewriterProver &rewr, BDD_Prover prover_obj_)
Definition with_prover.h:88
std::shared_ptr< Rewriter > clone() override
Clone a rewriter.
Definition with_prover.h:96
Rewriter interface class.
Definition rewrite.h:39
void rewrite_where(data_expression &result, const where_clause &term, substitution_type &sigma)
Definition rewrite.cpp:61
virtual void thread_initialise()
Definition rewrite.h:164
Rewriter(const data_specification &data_spec, const used_data_equation_selector &eq_selector)
Constructor. Do not use directly; use createRewriter() function instead.
Definition rewrite.h:60
std::map< function_symbol, std::size_t > f_operators
void translate_less_than(const data_expression &a_clause)
void translate_less_than_or_equal(const data_expression &a_clause)
void translate_max(const data_expression &a_clause)
void translate_pred(const data_expression &a_clause)
void translate_unary_minus(const data_expression &a_clause)
void translate_unknown_operator(const data_expression &a_clause)
void add_bool2pred_and_translate_clause(const data_expression &a_clause)
const data_expression & arg(const data_expression &x) const
void translate(data_expression_list a_formula)
void translate_nat_variable(const variable &a_clause)
void translate_add_c(const data_expression &a_clause)
void translate_c_nat(const data_expression &a_clause)
void translate_nat_constant(const data_expression &a_clause)
void translate_int_constant(const data_expression &a_clause)
void translate_binary_minus(const data_expression &a_clause)
void translate_greater_than(const data_expression &a_clause)
void translate_equality(const data_expression &a_clause)
void translate_variable(const variable &a_clause)
void translate_c_int(const data_expression &a_clause)
void translate_inequality(const data_expression &a_clause)
std::map< sort_expression, std::size_t > f_sorts
void translate_not(const data_expression &a_clause)
const data_expression & right(const data_expression &x) const
void translate_clause(const data_expression &a_clause, const bool a_expecting_predicate)
void translate_abs(const data_expression &a_clause)
void translate_pos_constant(const data_expression &a_clause)
void translate_pos_variable(const variable &a_clause)
void translate_greater_than_or_equal(const data_expression &a_clause)
void translate_min(const data_expression &a_clause)
void translate_plus(const data_expression &a_clause)
void translate_function_symbol(const data_expression &a_clause)
void translate_succ(const data_expression &a_clause)
void translate_multiplication(const data_expression &a_clause)
const data_expression & left(const data_expression &x) const
static bool execute(std::string const &benchmark)
A strategy is a list of rules and the number of variables that occur in it.
An enumerator algorithm that generates solutions of a condition.
Definition enumerator.h:599
The default element for the todo list of the enumerator.
Definition enumerator.h:229
\brief A function symbol
Rewriter that operates on data expressions.
Definition rewriter.h:84
void operator()(data_expression &result, const data_expression &d) const
Rewrites a data expression.
Definition rewriter.h:169
rewriter(const std::shared_ptr< detail::Rewriter > &r)
Constructor for internal use.
Definition rewriter.h:108
static const data_specification & default_specification()
Default specification used if no specification is specified at construction.
Definition rewriter.h:100
void operator()(data_expression &result, const data_expression &d, substitution_type &sigma) const
Rewrites the data expression d, and on the fly applies a substitution function to data variables.
Definition rewriter.h:225
void thread_initialise()
Initialises this rewriter with thread dependent information.
Definition rewriter.h:153
data_expression operator()(const data_expression &d, substitution_type &sigma) const
Rewrites the data expression d, and on the fly applies a substitution function to data variables.
Definition rewriter.h:211
static substitution_type & empty_substitution()
Definition rewriter.h:87
rewriter clone()
Create a clone of the rewriter in which the underlying rewriter is copied, and not passed as a shared...
Definition rewriter.h:143
rewriter(const data_specification &d=rewriter::default_specification(), const strategy s=rewrite_strategy::jitty)
Constructor.
Definition rewriter.h:126
rewriter(const rewriter &r)=default
Constructor.
void operator()(data_expression &result, const data_expression &d, const SubstitutionFunction &sigma) const
Rewrites the data expression d, and on the fly applies a substitution function. to data variables.
Definition rewriter.h:193
data_expression operator()(const data_expression &d, const SubstitutionFunction &sigma) const
Rewrites the data expression d, and on the fly applies a substitution function. to data variables.
Definition rewriter.h:180
rewriter(const data_specification &d, const EquationSelector &selector, const strategy s=rewrite_strategy::jitty)
Constructor.
Definition rewriter.h:135
data_expression operator()(const data_expression &d) const
Rewrites a data expression.
Definition rewriter.h:161
\brief A sort expression
Component for selecting a subset of equations that are actually used in an encompassing specification...
Definition selection.h:36
\brief A data variable
Definition variable.h:25
variable(const variable &) noexcept=default
Move semantics.
\brief A where expression
const assignment_list & assignments() const
const data_expression & body() const
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
Definition logger.h:435
void CheckRewriteRule(const data_equation &data_eqn)
Check that an mCRL2 data equation is a valid rewrite rule. If not, an runtime_error is thrown indicat...
Definition rewrite.cpp:582
static void checkPattern(const data_expression &p)
Definition rewrite.cpp:567
static void check_vars(application::const_iterator begin, const application::const_iterator &end, const std::set< variable > &vars, std::set< variable > &used_vars)
Definition rewrite.cpp:524
void set_enumerator_iteration_limit(std::size_t size)
bool isValidRewriteRule(const data_equation &data_eqn)
Check whether or not an mCRL2 data equation is a valid rewrite rule.
Definition rewrite.cpp:640
static bool occur_check(const variable &v, const atermpp::aterm &e)
Definition rewrite.cpp:44
static void checkPattern(application::const_iterator begin, const application::const_iterator &end)
Definition rewrite.cpp:558
Answer
A prover that uses EQ-BDDs.
Definition bdd_prover.h:77
variable_list set_intersection(const variable_list &x, const std::set< variable > &y)
Returns the intersection of a list and a set of variables.
static void check_vars(const data_expression &expr, const std::set< variable > &vars, std::set< variable > &used_vars)
Definition rewrite.cpp:535
variable_list set_difference(const variable_list &x, const std::set< variable > &y)
Returns a list of variables equal to the first list, not containing the elements in the second.
A collection of utilities for lazy expression construction.
data_expression and_(data_expression const &p, data_expression const &q)
Returns an expression equivalent to p or q.
Namespace for system defined sort bool_.
Definition bool.h:29
void make_not(data_expression &result, const data_expression &arg0)
Make an application of function symbol !.
Definition bool.h:204
bool is_false_function_symbol(const atermpp::aterm &e)
Recogniser for function false.
Definition bool.h:116
void make_and(data_expression &result, const data_expression &arg0, const data_expression &arg1)
Make an application of function symbol &&.
Definition bool.h:268
bool is_or_application(const atermpp::aterm &e)
Recogniser for application of ||.
Definition bool.h:342
const basic_sort & bool_()
Constructor for sort expression Bool.
Definition bool.h:41
bool is_implies_application(const atermpp::aterm &e)
Recogniser for application of =>.
Definition bool.h:406
application not_(const data_expression &arg0)
Application of function symbol !.
Definition bool.h:194
application and_(const data_expression &arg0, const data_expression &arg1)
Application of function symbol &&.
Definition bool.h:257
application implies(const data_expression &arg0, const data_expression &arg1)
Application of function symbol =>.
Definition bool.h:385
application or_(const data_expression &arg0, const data_expression &arg1)
Application of function symbol ||.
Definition bool.h:321
const function_symbol & false_()
Constructor for function symbol false.
Definition bool.h:106
bool is_and_application(const atermpp::aterm &e)
Recogniser for application of &&.
Definition bool.h:278
void make_or(data_expression &result, const data_expression &arg0, const data_expression &arg1)
Make an application of function symbol ||.
Definition bool.h:332
bool is_true_function_symbol(const atermpp::aterm &e)
Recogniser for function true.
Definition bool.h:84
bool is_not_application(const atermpp::aterm &e)
Recogniser for application of !.
Definition bool.h:214
const function_symbol & true_()
Constructor for function symbol true.
Definition bool.h:74
void make_implies(data_expression &result, const data_expression &arg0, const data_expression &arg1)
Make an application of function symbol =>.
Definition bool.h:396
Namespace for system defined sort int_.
bool is_cint_application(const atermpp::aterm &e)
Recogniser for application of @cInt.
Definition int1.h:121
bool is_integer_constant(const data_expression &n)
Determines whether n is an integer constant.
Namespace for system defined sort nat.
bool is_cnat_application(const atermpp::aterm &e)
Recogniser for application of @cNat.
Definition nat1.h:181
bool is_nat(const sort_expression &e)
Recogniser for sort expression Nat.
Definition nat1.h:53
bool is_natural_constant(const data_expression &n)
Determines whether n is a natural constant.
Namespace for system defined sort pos.
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:52
bool is_add_with_carry_application(const atermpp::aterm &e)
Recogniser for application of @addc.
Definition pos1.h:567
Namespace for system defined sort real_.
bool is_abs_application(const atermpp::aterm &e)
Recogniser for application of abs.
Definition real1.h:791
bool is_plus_application(const atermpp::aterm &e)
Recogniser for application of +.
Definition real1.h:1133
bool is_maximum_application(const atermpp::aterm &e)
Recogniser for application of max.
Definition real1.h:631
bool is_pred_application(const atermpp::aterm &e)
Recogniser for application of pred.
Definition real1.h:1040
bool is_succ_application(const atermpp::aterm &e)
Recogniser for application of succ.
Definition real1.h:957
bool is_times_application(const atermpp::aterm &e)
Recogniser for application of *.
Definition real1.h:1303
bool is_negate_application(const atermpp::aterm &e)
Recogniser for application of -.
Definition real1.h:874
bool is_minimum_application(const atermpp::aterm &e)
Recogniser for application of min.
Definition real1.h:716
bool is_minus_application(const atermpp::aterm &e)
Recogniser for application of -.
Definition real1.h:1218
bool is_application(const data_expression &t)
Returns true if the term t is an application.
bool is_where_clause(const atermpp::aterm &x)
Returns true if the term t is a where clause.
bool is_abstraction(const atermpp::aterm &x)
Returns true if the term t is an abstraction.
application if_(const data_expression &arg0, const data_expression &arg1, const data_expression &arg2)
Application of function symbol if.
Definition standard.h:224
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.
std::set< data::variable > find_free_variables(const data::data_expression &x)
Definition data.cpp:98
bool is_exists(const atermpp::aterm &x)
Returns true if the term t is an existential quantification.
bool is_machine_number(const atermpp::aterm &x)
Returns true if the term t is a machine_number.
bool is_lambda(const atermpp::aterm &x)
Returns true if the term t is a lambda abstraction.
bool is_variable(const atermpp::aterm &x)
Returns true if the term t is a variable.
bool operator()(const atermpp::aterm &t) const
Definition rewrite.cpp:37