|
| 1 | +/*******************************************************************\ |
| 2 | +
|
| 3 | +Module: Completeness Threshold |
| 4 | +
|
| 5 | +Author: Daniel Kroening, [email protected] |
| 6 | +
|
| 7 | +\*******************************************************************/ |
| 8 | + |
| 9 | +#include "completeness_threshold.h" |
| 10 | + |
| 11 | +#include <temporal-logic/ltl.h> |
| 12 | +#include <temporal-logic/temporal_logic.h> |
| 13 | +#include <verilog/sva_expr.h> |
| 14 | + |
| 15 | +#include "bmc.h" |
| 16 | + |
| 17 | +bool has_low_completeness_threshold(const exprt &expr) |
| 18 | +{ |
| 19 | + if(!has_temporal_operator(expr)) |
| 20 | + { |
| 21 | + return true; // state predicate only |
| 22 | + } |
| 23 | + else if(expr.id() == ID_X) |
| 24 | + { |
| 25 | + // X p |
| 26 | + return !has_temporal_operator(to_X_expr(expr).op()); |
| 27 | + } |
| 28 | + else if(expr.id() == ID_sva_nexttime) |
| 29 | + { |
| 30 | + // nexttime p |
| 31 | + return !has_temporal_operator(to_sva_nexttime_expr(expr).op()); |
| 32 | + } |
| 33 | + else |
| 34 | + return false; |
| 35 | +} |
| 36 | + |
| 37 | +bool has_low_completeness_threshold(const ebmc_propertiest::propertyt &property) |
| 38 | +{ |
| 39 | + return has_low_completeness_threshold(property.normalized_expr); |
| 40 | +} |
| 41 | + |
| 42 | +bool have_low_completeness_threshold(const ebmc_propertiest &properties) |
| 43 | +{ |
| 44 | + for(auto &property : properties.properties) |
| 45 | + if(has_low_completeness_threshold(property)) |
| 46 | + return true; |
| 47 | + return false; |
| 48 | +} |
| 49 | + |
| 50 | +property_checker_resultt completeness_threshold( |
| 51 | + const cmdlinet &cmdline, |
| 52 | + const transition_systemt &transition_system, |
| 53 | + const ebmc_propertiest &properties, |
| 54 | + const ebmc_solver_factoryt &solver_factory, |
| 55 | + message_handlert &message_handler) |
| 56 | +{ |
| 57 | + // Do we have an eligibile property? |
| 58 | + if(!have_low_completeness_threshold(properties)) |
| 59 | + return property_checker_resultt{properties}; // give up |
| 60 | + |
| 61 | + // Do BMC with two timeframes |
| 62 | + auto result = bmc( |
| 63 | + 1, // bound |
| 64 | + false, // convert_only |
| 65 | + cmdline.isset("bmc-with-assumptions"), |
| 66 | + transition_system, |
| 67 | + properties, |
| 68 | + solver_factory, |
| 69 | + message_handler); |
| 70 | + |
| 71 | + for(auto &property : result.properties) |
| 72 | + { |
| 73 | + if(property.is_proved_with_bound()) |
| 74 | + { |
| 75 | + // Turn "PROVED up to bound k" into "PROVED" if k>=CT |
| 76 | + if(has_low_completeness_threshold(property) && property.bound >= 1) |
| 77 | + property.proved(); |
| 78 | + else |
| 79 | + property.unknown(); |
| 80 | + } |
| 81 | + } |
| 82 | + |
| 83 | + return result; |
| 84 | +} |
0 commit comments