mCRL2
Loading...
Searching...
No Matches
bdd_prover.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/bdd_prover.h
10/// \brief EQ-BDD based prover for mCRL2 boolean data expressions
11
12#ifndef MCRL2_DATA_DETAIL_BDD_PROVER_H
13#define MCRL2_DATA_DETAIL_BDD_PROVER_H
14
15#include "mcrl2/data/detail/prover/bdd_path_eliminator.h"
16#include "mcrl2/data/detail/prover/induction.h"
17#include "mcrl2/data/find.h"
18#include <chrono>
19#include <memory>
20
21namespace mcrl2::data::detail
22{
23
24/** \brief A prover that uses EQ-BDDs.
25 *
26 * \detail
27 * A class based on the Prover class that takes an expression of sort
28 * Bool in internal mCRL2 format and creates the corresponding EQ-BDD.
29 * Using this EQ-BDD, the class can determine if the original
30 * formula is a tautology or a contradiction. The term "formula" in
31 * the following text denotes arbitrary expressions of sort Bool in
32 * the mCRL2 format.
33 *
34 * A prover uses a rewriter to rewrite parts of the formulas it
35 * manipulates. The constructor BDD_Prover::BDD_Prover initializes the
36 * prover's rewriter with the data equations in internal mCRL2 format
37 * contained in the LPS passed as parameter a_lps and the rewrite
38 * strategy passed as parameter a_rewrite_strategy. The parameter
39 * a_rewrite_strategy can be set to either
40 * GS_REWR_data::jitty or GS_REWR_data::jittyC. To limit the
41 * number of seconds spent on proving a single formula, a time limit
42 * can be set. If the time limit is set to 0, no time limit will be
43 * enforced. The parameter a_apply_induction indicates whether or
44 * induction on lists is applied. The constructor
45 * BDD_Prover::BDD_Prover has two additional parameters,
46 * a_path_eliminator and a_solver_type. The parameter
47 * a_path_eliminator can be used to enable the use of an instance of
48 * the class BDD_Path_Eliminator. Instances of this class use an SMT
49 * solver to eliminate inconsistent paths from BDDs. The parameter
50 * a_solver_type can be used to indicate which SMT solver should be
51 * used for this task. Either the SMT solver ario
52 * (http://www.eecs.umich.edu/~ario/) or cvc-lite
53 * (http://www.cs.nyu.edu/acsys/cvcl/) can be used. To use one of
54 * these solvers, the directory containing the corresponding
55 * executable must be in the path. If the parameter a_path_eliminator
56 * is set to false, the parameter a_solver_type is ignored and no
57 * instance of the class BDD_Path_Eliminator is initialized.
58 *
59 * The formula to be handled is set using the method
60 * Prover::set_formula inherited from the class Prover. An entity of
61 * the class BDD_Prover uses binary decision diagrams to determine if
62 * a given formula is a tautology or a contradiction. The resulting
63 * BDD can be retreived using the method BDD_Prover::get_bdd.
64 *
65 * The methods BDD_Prover::is_tautology and
66 * BDD_Prover::is_contradiction indicate whether or not a formula is a
67 * tautology or a contradiction. These methods will return answer_yes,
68 * answer_no or answer_undefined. If a formula is neither a tautology
69 * nor a contradiction according to the prover, a so called witness or
70 * counter example can be returned by the methods
71 * BDD_Prover::get_witness and BDD_Prover::get_counter_example. A
72 * witness is a valuation for which the formula holds, a counter
73 * example is a valuation for which it does not hold.
74*/
75
77{
81};
82
83
84class BDD_Prover: protected rewriter
85{
86 public:
88
89 private:
90
91 /// \brief Flag indicating whether or not the result of the comparison between the first two arguments
92 /// \brief weighs stronger than the result of the comparison between the second pair of arguments of an
93 /// \brief equation, when determining the order of expressions.
94 static constexpr bool f_reverse = true;
95
96 /// \brief Flag indicating whether or not the arguments of equality functions are taken into account
97 /// \brief when determining the order of expressions.
98 static constexpr bool f_full = true;
99
100 protected:
101 /// \brief An expression of sort Bool.
103
104 /// \brief A class that provides information about expressions.
106
107 /// \brief A class that can be used to manipulate expressions.
109
110 /// \brief A flag that indicates whether or not the formala Prover::f_formula has been processed.
111 bool f_processed = false;
112
113 /// \brief A flag that indicates whether or not the formala Prover::f_formula is a tautology.
115
116 /// \brief A flag that indicates whether or not the formala Prover::f_formula is a contradiction.
118
119 /// \brief An integer representing the maximal amount of seconds to be spent on processing a formula.
120 const double f_time_limit;
121
122 /// \brief A timestamp representing the moment when the maximal amount of milliseconds has been spent on processing the current formula.
124
125 private:
126 /// \brief A flag indicating whether or not induction on lists is applied.
128
129 /// \brief The variables in the expression in order.
131
132 /// \brief A hashtable that maps formulas to BDDs.
133 /// \brief If the BDD of a formula is unknown, it maps this formula to 0.
135
136 /// \brief A hashtable that maps formulas to the smallest guard occuring in those formulas.
137 /// \brief If the smallest guard of a formula is unknown, it maps this formula to 0.
139
140 /// \brief Class that simplifies a BDD.
142
143 /// \brief Class that creates all statements needed to prove a given property using induction.
145
146 /// \brief Constructs the EQ-BDD corresponding to the formula Prover::f_formula.
148 {
149 f_deadline = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch() + std::chrono::milliseconds(int(f_time_limit * 1000)));
150
151 data_expression v_previous_1;
152 data_expression v_previous_2;
153
154 mCRL2log(log::debug) << "Formula: " << f_formula << std::endl;
155
156 data_expression intermediate_bdd = f_formula;
157
158 intermediate_bdd = m_rewriter->rewrite(intermediate_bdd,bdd_sigma);
159 intermediate_bdd = f_manipulator.orient(intermediate_bdd);
160
161 mCRL2log(log::trace) << "Formula rewritten and oriented: " << intermediate_bdd << std::endl;
162
163 while (v_previous_1 != intermediate_bdd && v_previous_2 != intermediate_bdd)
164 {
165 v_previous_2 = v_previous_1;
166 v_previous_1 = intermediate_bdd;
167 intermediate_bdd = bdd_down(intermediate_bdd);
168 mCRL2log(log::trace) << "End of iteration." << std::endl;
169 mCRL2log(log::trace) << "Intermediate BDD: " << intermediate_bdd << std::endl;
170 }
171
172 f_bdd = intermediate_bdd;
173 mCRL2log(log::debug) << "Resulting BDD: " << f_bdd << std::endl;
174
175 }
176
177 // Auxiliary function to deliver an indent of length n.
179 {
180 return std::string(n, ' ');
181 }
182
183 /// \brief Creates the EQ-BDD corresponding to the formula formula.
184 data_expression bdd_down(const data_expression& formula, const size_t a_indent=0)
185 {
186
187 if (f_time_limit != 0 && (f_deadline <= std::chrono::system_clock::now().time_since_epoch()))
188 {
189 mCRL2log(log::debug) << "The time limit has passed." << std::endl;
190 return formula;
191 }
192
193 if (formula==sort_bool::true_())
194 {
195 return formula;
196 }
197 if (formula==sort_bool::false_())
198 {
199 return formula;
200 }
201
202 if (is_abstraction(formula))
203 {
204 const abstraction& a = atermpp::down_cast<abstraction>(formula);
206 }
207
208 const std::unordered_map < data_expression, data_expression >::const_iterator i = f_formula_to_bdd.find(formula);
209 if (i!=f_formula_to_bdd.end()) // found
210 {
211 return i->second;
212 }
213
214 data_expression v_guard;
215 bool success = smallest(formula, v_guard);
216 if (!success)
217 {
218 return formula;
219 }
220 else
221 {
222 mCRL2log(log::trace) << indent(a_indent) << "Smallest guard: " << v_guard << std::endl;
223 }
224
225 const size_t extra_indent = a_indent + 2;
226
227 data_expression v_term1 = f_manipulator.set_true(formula, v_guard);
228 v_term1 = m_rewriter->rewrite(v_term1,bdd_sigma);
229 v_term1 = f_manipulator.orient(v_term1);
230 mCRL2log(log::trace) << indent(extra_indent) << "True-branch after rewriting and orienting: " << v_term1 << std::endl;
231 v_term1 = bdd_down(v_term1, extra_indent);
232 mCRL2log(log::trace) << indent(extra_indent) << "BDD of the true-branch: " << v_term1 << std::endl;
233
234 data_expression v_term2 = f_manipulator.set_false(formula, v_guard);
235 v_term2 = m_rewriter->rewrite(v_term2,bdd_sigma);
236 v_term2 = f_manipulator.orient(v_term2);
237 mCRL2log(log::trace) << indent(extra_indent) << "False-branch after rewriting and orienting: " << v_term2 << std::endl;
238 v_term2 = bdd_down(v_term2, extra_indent);
239 mCRL2log(log::trace) << indent(extra_indent) << "BDD of the false-branch: " << v_term2 << std::endl;
240
241 data_expression v_bdd = Manipulator::make_reduced_if_then_else(v_guard, v_term1, v_term2);
242 f_formula_to_bdd[formula]=v_bdd;
243
244 return v_bdd;
245 }
246
247 /// \brief Removes all inconsistent paths from the BDD BDD_Prover::f_bdd.
249 {
250 time_t v_new_time_limit;
251
252 v_new_time_limit = (f_deadline
253 - std::chrono::duration_cast<std::chrono::milliseconds>(
254 std::chrono::system_clock::now().time_since_epoch()))
255 .count();
256 if (v_new_time_limit > 0 || f_time_limit == 0)
257 {
258 mCRL2log(log::debug) << "Simplifying the BDD:" << std::endl;
259 f_bdd_simplifier->set_time_limit((std::max)(v_new_time_limit, time(nullptr)));
260 f_bdd = f_bdd_simplifier->simplify(f_bdd);
261 mCRL2log(log::debug) << "Resulting BDD: " << f_bdd << std::endl;
262 }
263 }
264
265 /// \brief Updates the values of Prover::f_tautology and Prover::f_contradiction.
267 {
268 if (!f_processed)
269 {
272 data_expression v_original_formula = f_formula;
273 data_expression v_original_bdd = f_bdd;
275 {
276 f_induction.initialize(v_original_formula);
277 while (f_induction.can_apply_induction() && !BDD_Info::is_true(f_bdd))
278 {
279 mCRL2log(log::debug) << "Applying induction." << std::endl;
280 f_formula = f_induction.apply_induction();
281 build_bdd();
282 eliminate_paths();
283 }
285 {
288 }
289 else
290 {
291 v_original_formula = sort_bool::not_(v_original_formula);
292 f_bdd = v_original_bdd;
293 f_induction.initialize(v_original_formula);
294 while (f_induction.can_apply_induction() && !BDD_Info::is_true(f_bdd))
295 {
296 mCRL2log(log::debug) << "Applying induction on the negated formula." << std::endl;
297 f_formula = f_induction.apply_induction();
298 build_bdd();
299 eliminate_paths();
300 }
302 {
306 }
307 else
308 {
309 f_bdd = v_original_bdd;
312 }
313 }
314 }
315 else
316 {
318 {
321 }
323 {
326 }
327 else
328 {
331 }
332 }
333 f_processed = true;
334 }
335 };
336
337 /// \brief Returns the smallest guard in the formula formula.
338 bool smallest(const data_expression& formula, data_expression& result)
339 {
340 if (is_machine_number(formula))
341 {
342 return false;
343 }
344 if (is_variable(formula))
345 {
346 if (formula.sort()==sort_bool::bool_())
347 {
348 result=formula;
349 return true;
350 }
351 else
352 {
353 return false;
354 }
355 }
356 if (is_function_symbol(formula))
357 {
358 if (formula.sort()==sort_bool::bool_() && !(formula==sort_bool::true_() || formula==sort_bool::false_()))
359 {
360 result=formula;
361 return true;
362 }
363 else
364 {
365 return false;
366 }
367 }
368 if (is_abstraction(formula))
369 {
370 // Guards from within an abstraction may contain
371 // variables that are not bound outside that abstraction.
372 // Therefore, we never return a smallest guard from
373 // within an abstraction.
374 return false;
375 }
376
377 const std::unordered_map < data_expression, data_expression >::const_iterator i = f_smallest.find(formula);
378 if (i!=f_smallest.end()) //found
379 {
380 result=i->second;
381 return true;
382 }
383
384 bool result_is_defined=false;
385 data_expression v_small;
386 for (const data_expression& arg: atermpp::down_cast<application>(formula))
387 {
388 bool success = smallest(arg,v_small);
389 if (success)
390 {
391 if (result_is_defined)
392 {
393 // By default, the ordering of selecting the guard to pivot changes based on how
394 // the brackets of the expression are placed. Choose the ordering of the variables
395 // based on the order in which they appear in the formula.
396 if (f_info.compare_guard(v_small, result, f_variables) == compare_result_smaller)
397 {
398 result = v_small;
399 }
400 }
401 else
402 {
403 result = v_small;
404 result_is_defined=true;
405 }
406 }
407 }
408 if (!result_is_defined && formula.sort()==sort_bool::bool_())
409 {
410 result = formula;
411 return true;
412 }
413 if (result_is_defined)
414 {
415 f_smallest[formula]=result; // Save the result in the cache
416 return true;
417 }
418
419 return false;
420 }
421
422 /// \brief Returns branch of the BDD a_bdd, depending on the polarity a_polarity.
423 bool get_branch(const data_expression& a_bdd, const bool a_polarity, data_expression& result)
424 {
426 {
427 const data_expression& v_guard = BDD_Info::get_guard(a_bdd);
428 const data_expression& v_true_branch = BDD_Info::get_true_branch(a_bdd);
429 const data_expression& v_false_branch = BDD_Info::get_false_branch(a_bdd);
430 bool success = get_branch(v_true_branch, a_polarity, result);
431 if (success)
432 {
433 result = lazy::and_(result, v_guard);
434 return true;
435 }
436 else
437 {
438 success = get_branch(v_false_branch, a_polarity, result);
439 if (success)
440 {
441 result = lazy::and_(result, sort_bool::not_(v_guard));
442 return true;
443 }
444 else
445 {
446 return false;
447 }
448 }
449 }
450 else
451 {
452 if ((BDD_Info::is_true(a_bdd) && a_polarity) || (BDD_Info::is_false(a_bdd) && !a_polarity))
453 {
454 result = sort_bool::true_();
455 return true;
456 }
457 return false;
458 }
459 }
460
461 protected:
462
463 /// \brief A binary decision diagram in the internal representation of the rewriter.
465
466 /// \brief A binary decision diagram in the internal representation of mCRL2.
468 public:
469
471 const used_data_equation_selector& equations_selector,
472 mcrl2::data::rewriter::strategy a_rewrite_strategy = mcrl2::data::jitty,
473 double a_time_limit = 0,
474 bool a_path_eliminator = false,
475 smt_solver_type a_solver_type = solver_type_cvc,
476 bool a_apply_induction = false)
478 f_time_limit(a_time_limit),
479 f_apply_induction(a_apply_induction),
482 {
484 switch (a_rewrite_strategy)
485 {
486 case(jitty):
487#ifdef MCRL2_ENABLE_JITTYC
488 case(jitty_compiling):
489#endif
490 {
491 /* These provers are ok */
492 break;
493 }
494 case(jitty_prover):
495#ifdef MCRL2_ENABLE_JITTYC
496 case(jitty_compiling_prover):
497#endif
498 {
499 throw mcrl2::runtime_error("The proving rewriters are not supported by the prover (only jitty and jittyc are supported).");
500 }
501 default:
502 {
503 throw mcrl2::runtime_error("Unknown type of rewriter.");
504 break;
505 }
506 }
507
508 mCRL2log(log::debug) << "Flags:" << std::endl
509 << " Reverse: " << std::boolalpha << f_reverse << "," << std::endl
510 << " Full: " << f_full << "," << std::endl;
511 }
512
513 BDD_Prover(const rewriter& r, double time_limit = 0, bool apply_induction = false)
514 : rewriter(r),
515 f_time_limit(time_limit),
516 f_apply_induction(apply_induction),
518 {
520 }
521
522 /// \brief Set the substitution to be used to construct the BDD
523 void set_substitution(substitution_type& sigma)
524 {
525 bdd_sigma = sigma;
526 }
527
528 /// \brief Set the substitution in internal format to be used to construct the BDD
529 void set_substitution_internal(substitution_type& sigma)
530 {
531 bdd_sigma = sigma;
532 }
533
534 /// \brief Indicates whether or not the formula Prover::f_formula is a tautology.
536 {
538 return f_tautology;
539 }
540
541 /// \brief Indicates whether or not the formula Prover::f_formula is a contradiction.
543 {
545 return f_contradiction;
546 }
547
548 /// \brief Returns the BDD BDD_Prover::f_bdd.
550 {
552 return f_bdd;
553 }
554
555 /// \brief Returns all the guards on a path in the BDD that leads to a leaf labelled "true", if such a leaf exists.
557 {
560 {
561 mCRL2log(log::debug) << "The formula is a contradiction." << std::endl;
562 return sort_bool::true_();
563 }
564 else if (is_tautology() == answer_yes)
565 {
566 mCRL2log(log::debug) << "The formula is a tautology." << std::endl;
567 return sort_bool::false_();
568 }
569 else
570 {
571 mCRL2log(log::debug) << "The formula is satisfiable, but not a tautology." << std::endl;
572 data_expression result;
573 bool success = get_branch(f_bdd, true, result);
574 if (!success)
575 { throw mcrl2::runtime_error(
576 "Cannot provide witness. This is probably caused by an abrupt stop of the\n"
577 "conversion from expression to EQ-BDD. This typically occurs when a time limit is set.");
578 }
579 return result;
580 }
581 }
582
583 /// \brief Returns all the guards on a path in the BDD that leads to a leaf labelled "false", if such a leaf exists.
585 {
588 {
589 mCRL2log(log::debug) << "The formula is a contradiction." << std::endl;
590 return sort_bool::false_();
591 }
592 else if (is_tautology() == answer_yes)
593 {
594 mCRL2log(log::debug) << "The formula is a tautology." << std::endl;
595 return sort_bool::true_();
596 }
597 else
598 {
599 mCRL2log(log::debug) << "The formula is satisfiable, but not a tautology." << std::endl;
600 data_expression result;
601 bool success=get_branch(f_bdd, false,result);
602 if (!success)
603 { throw mcrl2::runtime_error(
604 "Cannot provide counter example. This is probably caused by an abrupt stop of the\n"
605 "conversion from expression to EQ-BDD. This typically occurs when a time limit is set.");
606 }
607 return result;
608 }
609 }
610
611 /// \brief Returns the rewriter used by this prover (i.e. it returns Prover::f_rewriter).
612 std::shared_ptr<detail::Rewriter> get_rewriter()
613 {
614 return m_rewriter;
615 }
616
617 /// \brief Returns the strategy of the rewriter used inside this proving rewriter.
619 {
620 return m_rewriter->getStrategy();
621 }
622
623 /// \brief Sets Prover::f_formula to formula.
624 /// precondition: the argument passed as parameter formula is an expression of sort Bool
625 void set_formula(const data_expression& formula)
626 {
627 f_formula = formula;
628 f_processed = false;
629 f_variables = find_free_variables_in_order(f_formula);
630 mCRL2log(log::debug) << "The formula has been set." << std::endl;
631 }
632
634 {
635 return BDD_Prover(rewriter::clone());
636 }
637
639 {
641 }
642
643
644};
645} // namespace mcrl2::data::detail
646
647#endif
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
\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 & 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
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
BDD_Prover(const data_specification &data_spec, const used_data_equation_selector &equations_selector, mcrl2::data::rewriter::strategy a_rewrite_strategy=mcrl2::data::jitty, double a_time_limit=0, bool a_path_eliminator=false, smt_solver_type a_solver_type=solver_type_cvc, bool a_apply_induction=false)
Definition bdd_prover.h:470
Answer is_tautology()
Indicates whether or not the formula Prover::f_formula is a tautology.
Definition bdd_prover.h:535
A base class for simplifying binary decision diagrams.
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
constexpr Info(bool a_full, bool a_reverse)
Constructor that initializes the rewriter.
Definition info.h:181
Base class for classes that provide functionality to modify or create terms.
Definition manipulator.h:23
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.
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:163
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
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
Rewriter that operates on data expressions.
Definition rewriter.h:84
void thread_initialise()
Initialises this rewriter with thread dependent information.
Definition rewriter.h:153
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 rewriter &r)=default
Constructor.
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:393
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
static void check_vars(const data_expression &expr, const std::set< variable > &vars, std::set< variable > &used_vars)
Definition rewrite.cpp:535
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
const basic_sort & bool_()
Constructor for sort expression Bool.
Definition bool.h:41
application not_(const data_expression &arg0)
Application of function symbol !.
Definition bool.h:194
const function_symbol & false_()
Constructor for function symbol false.
Definition bool.h:106
const function_symbol & true_()
Constructor for function symbol true.
Definition bool.h:74
bool is_application(const data_expression &t)
Returns true if the term t is an application.
bool is_abstraction(const atermpp::aterm &x)
Returns true if the term t is an abstraction.
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_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