Skip to content

Stop-on-fail verifier [blocks: 3968] #3796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions jbmc/src/jbmc/jbmc_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@ Author: Daniel Kroening, [email protected]
#include <util/config.h>
#include <util/exit_codes.h>
#include <util/invariant.h>
#include <util/make_unique.h>
#include <util/unicode.h>
#include <util/xml.h>
#include <util/version.h>
#include <util/xml.h>

#include <langapi/language.h>

#include <ansi-c/ansi_c_language.h>

#include <goto-checker/all_properties_verifier.h>
#include <goto-checker/all_properties_verifier_with_trace_storage.h>
#include <goto-checker/stop_on_fail_verifier.h>

#include <goto-programs/adjust_float_expressions.h>
#include <goto-programs/lazy_goto_model.h>
Expand Down Expand Up @@ -566,11 +568,33 @@ int jbmc_parse_optionst::doit()
}
}

if(
options.get_bool_option("dimacs") ||
!options.get_option("outfile").empty())
{
if(!options.get_bool_option("paths"))
{
stop_on_fail_verifiert<multi_path_symex_checkert> verifier(
options, ui_message_handler, goto_model);
(void)verifier();
return CPROVER_EXIT_SUCCESS;
}
}

std::unique_ptr<goto_verifiert> verifier = nullptr;

if(!options.get_bool_option("paths") && !options.is_set("cover"))
if(
!options.get_bool_option("paths") && !options.is_set("cover") &&
!options.get_bool_option("dimacs") &&
options.get_option("outfile").empty())
{
if(!options.get_bool_option("stop-on-fail"))
if(options.get_bool_option("stop-on-fail"))
{
verifier = util_make_unique<
stop_on_fail_verifiert<java_multi_path_symex_checkert>>(
options, ui_message_handler, goto_model);
}
else
{
verifier = util_make_unique<all_properties_verifier_with_trace_storaget<
java_multi_path_symex_checkert>>(
Expand Down
26 changes: 24 additions & 2 deletions src/cbmc/cbmc_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Author: Daniel Kroening, [email protected]
#include <util/exception_utils.h>
#include <util/exit_codes.h>
#include <util/invariant.h>
#include <util/make_unique.h>
#include <util/unicode.h>
#include <util/version.h>

Expand All @@ -38,6 +39,7 @@ Author: Daniel Kroening, [email protected]
#include <goto-checker/multi_path_symex_checker.h>
#include <goto-checker/multi_path_symex_only_checker.h>
#include <goto-checker/properties.h>
#include <goto-checker/stop_on_fail_verifier.h>

#include <goto-programs/adjust_float_expressions.h>
#include <goto-programs/initialize_goto_model.h>
Expand Down Expand Up @@ -564,11 +566,31 @@ int cbmc_parse_optionst::doit()
}
}

if(
options.get_bool_option("dimacs") || !options.get_option("outfile").empty())
{
if(!options.get_bool_option("paths"))
{
stop_on_fail_verifiert<multi_path_symex_checkert> verifier(
options, ui_message_handler, goto_model);
(void)verifier();
return CPROVER_EXIT_SUCCESS;
}
}

std::unique_ptr<goto_verifiert> verifier = nullptr;

if(!options.get_bool_option("paths") && !options.is_set("cover"))
if(
!options.get_bool_option("paths") && !options.is_set("cover") &&
!options.get_bool_option("dimacs") && options.get_option("outfile").empty())
{
if(!options.get_bool_option("stop-on-fail"))
if(options.get_bool_option("stop-on-fail"))
{
verifier =
util_make_unique<stop_on_fail_verifiert<multi_path_symex_checkert>>(
options, ui_message_handler, goto_model);
}
else
{
verifier = util_make_unique<
all_properties_verifier_with_trace_storaget<multi_path_symex_checkert>>(
Expand Down
3 changes: 3 additions & 0 deletions src/goto-checker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ The combination of these three concepts enables:
without impacting others.

There are the following variants of goto verifiers at the moment:
* \ref stop_on_fail_verifiert : Checks all properties, but terminates
as soon as the first violated property is found and reports this violation.
A trace ends at a violated property.
* \ref all_properties_verifier_with_trace_storaget : Determines the status of
all properties and outputs results when the verification algorithm has
terminated. A trace ends at a violated property.
Expand Down
79 changes: 79 additions & 0 deletions src/goto-checker/stop_on_fail_verifier.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*******************************************************************\

Module: Goto Verifier for stopping at the first failing property

Author: Daniel Kroening, Peter Schrammel

\*******************************************************************/

/// \file
/// Goto Verifier for stopping at the first failing property

#ifndef CPROVER_GOTO_CHECKER_STOP_ON_FAIL_VERIFIER_H
#define CPROVER_GOTO_CHECKER_STOP_ON_FAIL_VERIFIER_H

#include "bmc_util.h"
#include "goto_verifier.h"

/// Stops when the first failing property is found.
/// Requires an incremental goto checker that is a
/// `goto_trace_providert` and `witness_providert`.
template <class incremental_goto_checkerT>
class stop_on_fail_verifiert : public goto_verifiert
{
public:
stop_on_fail_verifiert(
const optionst &options,
ui_message_handlert &ui_message_handler,
abstract_goto_modelt &goto_model)
: goto_verifiert(options, ui_message_handler),
goto_model(goto_model),
incremental_goto_checker(options, ui_message_handler, goto_model)
{
properties = std::move(initialize_properties(goto_model));
}

resultt operator()() override
{
(void)incremental_goto_checker(properties);
return determine_result(properties);
}

void report() override
{
switch(determine_result(properties))
{
case resultt::PASS:
report_success(ui_message_handler);
incremental_goto_checker.output_proof();
break;

case resultt::FAIL:
{
goto_tracet goto_trace = incremental_goto_checker.build_trace();
output_error_trace(
goto_trace,
incremental_goto_checker.get_namespace(),
trace_optionst(options),
ui_message_handler);
report_failure(ui_message_handler);
incremental_goto_checker.output_error_witness(goto_trace);
break;
}

case resultt::UNKNOWN:
report_inconclusive(ui_message_handler);
break;

case resultt::ERROR:
report_error(ui_message_handler);
break;
}
}

protected:
abstract_goto_modelt &goto_model;
incremental_goto_checkerT incremental_goto_checker;
};

#endif // CPROVER_GOTO_CHECKER_STOP_ON_FAIL_VERIFIER_H