|
| 1 | +/*******************************************************************\ |
| 2 | +
|
| 3 | +Module: EBMC Property Checker |
| 4 | +
|
| 5 | +Author: Daniel Kroening, [email protected] |
| 6 | +
|
| 7 | +\*******************************************************************/ |
| 8 | + |
| 9 | +#include "property_checker.h" |
| 10 | + |
| 11 | +#include <util/string2int.h> |
| 12 | + |
| 13 | +#include "bmc.h" |
| 14 | +#include "ebmc_error.h" |
| 15 | +#include "ebmc_solver_factory.h" |
| 16 | +#include "report_results.h" |
| 17 | + |
| 18 | +int word_level_bmc( |
| 19 | + const cmdlinet &cmdline, |
| 20 | + const transition_systemt &transition_system, |
| 21 | + ebmc_propertiest &properties, |
| 22 | + message_handlert &message_handler) |
| 23 | +{ |
| 24 | + auto solver_factory = ebmc_solver_factory(cmdline); |
| 25 | + |
| 26 | + bool convert_only = cmdline.isset("smt2") || cmdline.isset("outfile") || |
| 27 | + cmdline.isset("show-formula"); |
| 28 | + |
| 29 | + int result = 0; |
| 30 | + |
| 31 | + try |
| 32 | + { |
| 33 | + if(cmdline.isset("max-bound")) |
| 34 | + { |
| 35 | + if(convert_only) |
| 36 | + throw ebmc_errort() << "please set a specific bound"; |
| 37 | + |
| 38 | + const std::size_t max_bound = |
| 39 | + unsafe_string2size_t(cmdline.get_value("max-bound")); |
| 40 | + |
| 41 | + for(std::size_t bound = 1; bound <= max_bound; bound++) |
| 42 | + { |
| 43 | + messaget message{message_handler}; |
| 44 | + message.status() << "Doing BMC with bound " << bound << messaget::eom; |
| 45 | + |
| 46 | +#if 0 |
| 47 | + const namespacet ns(transition_system.symbol_table); |
| 48 | + CHECK_RETURN(trans_expr.has_value()); |
| 49 | + ::unwind(*trans_expr, *message_handler, solver, bound+1, ns, true); |
| 50 | + result=finish_word_level_bmc(solver); |
| 51 | +#endif |
| 52 | + } |
| 53 | + |
| 54 | + const namespacet ns(transition_system.symbol_table); |
| 55 | + report_results(cmdline, properties, ns, message_handler); |
| 56 | + } |
| 57 | + else |
| 58 | + { |
| 59 | + std::size_t bound; |
| 60 | + |
| 61 | + if(cmdline.isset("bound")) |
| 62 | + { |
| 63 | + bound = unsafe_string2unsigned(cmdline.get_value("bound")); |
| 64 | + } |
| 65 | + else |
| 66 | + { |
| 67 | + messaget message{message_handler}; |
| 68 | + message.warning() << "using default bound 1" << messaget::eom; |
| 69 | + bound = 1; |
| 70 | + } |
| 71 | + |
| 72 | + if(!convert_only) |
| 73 | + if(properties.properties.empty()) |
| 74 | + throw "no properties"; |
| 75 | + |
| 76 | + bmc( |
| 77 | + bound, |
| 78 | + convert_only, |
| 79 | + transition_system, |
| 80 | + properties, |
| 81 | + solver_factory, |
| 82 | + message_handler); |
| 83 | + |
| 84 | + if(!convert_only) |
| 85 | + { |
| 86 | + const namespacet ns(transition_system.symbol_table); |
| 87 | + report_results(cmdline, properties, ns, message_handler); |
| 88 | + result = properties.exit_code(); |
| 89 | + } |
| 90 | + } |
| 91 | + } |
| 92 | + |
| 93 | + catch(const char *e) |
| 94 | + { |
| 95 | + messaget message{message_handler}; |
| 96 | + message.error() << e << messaget::eom; |
| 97 | + return 10; |
| 98 | + } |
| 99 | + |
| 100 | + catch(const std::string &e) |
| 101 | + { |
| 102 | + messaget message{message_handler}; |
| 103 | + message.error() << e << messaget::eom; |
| 104 | + return 10; |
| 105 | + } |
| 106 | + |
| 107 | + catch(int) |
| 108 | + { |
| 109 | + return 10; |
| 110 | + } |
| 111 | + |
| 112 | + return result; |
| 113 | +} |
| 114 | + |
| 115 | +int property_checker( |
| 116 | + const cmdlinet &cmdline, |
| 117 | + const transition_systemt &transition_system, |
| 118 | + ebmc_propertiest &properties, |
| 119 | + message_handlert &message_handler) |
| 120 | +{ |
| 121 | + // default engine is word-level BMC |
| 122 | + return word_level_bmc( |
| 123 | + cmdline, transition_system, properties, message_handler); |
| 124 | +} |
0 commit comments