Skip to content

Commit 58e07ea

Browse files
Add stop-on-fail verifier
Stops verification when the first property violation is found.
1 parent 17ebf64 commit 58e07ea

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*******************************************************************\
2+
3+
Module: Goto Verifier for stopping at the first failing property
4+
5+
Author: Daniel Kroening, Peter Schrammel
6+
7+
\*******************************************************************/
8+
9+
/// \file
10+
/// Goto Verifier for stopping at the first failing property
11+
12+
#ifndef CPROVER_GOTO_CHECKER_STOP_ON_FAIL_VERIFIER_H
13+
#define CPROVER_GOTO_CHECKER_STOP_ON_FAIL_VERIFIER_H
14+
15+
#include "bmc_util.h"
16+
#include "goto_verifier.h"
17+
18+
/// Stops when the first failing property is found.
19+
/// Requires an incremental goto checker that is a
20+
/// `goto_trace_providert` and `witness_providert`.
21+
template <class incremental_goto_checkerT>
22+
class stop_on_fail_verifiert : public goto_verifiert
23+
{
24+
public:
25+
stop_on_fail_verifiert(
26+
const optionst &options,
27+
ui_message_handlert &ui_message_handler,
28+
abstract_goto_modelt &goto_model)
29+
: goto_verifiert(options, ui_message_handler),
30+
goto_model(goto_model),
31+
incremental_goto_checker(options, ui_message_handler, goto_model)
32+
{
33+
properties = std::move(initialize_properties(goto_model));
34+
}
35+
36+
resultt operator()() override
37+
{
38+
(void)incremental_goto_checker(properties);
39+
return determine_result(properties);
40+
}
41+
42+
void report() override
43+
{
44+
switch(determine_result(properties))
45+
{
46+
case resultt::PASS:
47+
report_success(ui_message_handler);
48+
incremental_goto_checker.output_proof();
49+
break;
50+
51+
case resultt::FAIL:
52+
{
53+
namespacet ns(goto_model.get_symbol_table());
54+
goto_tracet goto_trace = incremental_goto_checker.build_trace();
55+
output_error_trace(
56+
goto_trace, ns, trace_optionst(options), ui_message_handler);
57+
report_failure(ui_message_handler);
58+
incremental_goto_checker.output_error_witness(goto_trace);
59+
break;
60+
}
61+
62+
case resultt::UNKNOWN:
63+
report_inconclusive(ui_message_handler);
64+
break;
65+
66+
case resultt::ERROR:
67+
report_error(ui_message_handler);
68+
break;
69+
}
70+
}
71+
72+
protected:
73+
abstract_goto_modelt &goto_model;
74+
incremental_goto_checkerT incremental_goto_checker;
75+
};
76+
77+
#endif // CPROVER_GOTO_CHECKER_STOP_ON_FAIL_VERIFIER_H

0 commit comments

Comments
 (0)