Skip to content
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

introduce property_checker_resultt #651

Merged
merged 1 commit into from
Aug 30, 2024
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
21 changes: 9 additions & 12 deletions src/ebmc/bdd_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ Author: Daniel Kroening, [email protected]
#include <trans-netlist/unwind_netlist.h>
#include <verilog/sva_expr.h>

#include "report_results.h"

#include <algorithm>
#include <iostream>

Expand Down Expand Up @@ -51,7 +49,7 @@ class bdd_enginet
{
}

int operator()();
property_checker_resultt operator()();

protected:
using propertiest = ebmc_propertiest;
Expand Down Expand Up @@ -173,7 +171,7 @@ Function: bdd_enginet::operator()

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

int bdd_enginet::operator()()
property_checker_resultt bdd_enginet::operator()()
{
try
{
Expand Down Expand Up @@ -216,30 +214,29 @@ int bdd_enginet::operator()()
}

std::cout << '\n';
return 0;

return property_checker_resultt::SUCCESS;
}

if(properties.properties.empty())
{
message.error() << "no properties" << messaget::eom;
return 1;
return property_checker_resultt::ERROR;
}

for(propertyt &p : properties.properties)
check_property(p);

report_results(cmdline, properties, ns, message.get_message_handler());
return properties.exit_code();
return property_checker_resultt::VERIFICATION_RESULT;
}
catch(const char *error_msg)
{
message.error() << error_msg << messaget::eom;
return 1;
return property_checker_resultt::ERROR;
}
catch(int)
{
return 1;
return property_checker_resultt::ERROR;
}
}

Expand Down Expand Up @@ -1002,7 +999,7 @@ Function: bdd_engine

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

int bdd_engine(
property_checker_resultt bdd_engine(
const cmdlinet &cmdline,
transition_systemt &transition_system,
ebmc_propertiest &properties,
Expand Down
7 changes: 2 additions & 5 deletions src/ebmc/bdd_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ Author: Daniel Kroening, [email protected]
#ifndef CPROVER_EBMC_BDD_ENGINE_H
#define CPROVER_EBMC_BDD_ENGINE_H

#include <util/cmdline.h>
#include <util/message.h>
#include "property_checker.h"

#include "ebmc_properties.h"

int bdd_engine(
property_checker_resultt bdd_engine(
const cmdlinet &,
transition_systemt &,
ebmc_propertiest &,
Expand Down
7 changes: 2 additions & 5 deletions src/ebmc/k_induction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Author: Daniel Kroening, [email protected]
#include "ebmc_error.h"
#include "ebmc_solver_factory.h"
#include "liveness_to_safety.h"
#include "report_results.h"

#include <fstream>

Expand Down Expand Up @@ -118,7 +117,7 @@ Function: k_induction

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

int k_induction(
property_checker_resultt k_induction(
const cmdlinet &cmdline,
transition_systemt &transition_system,
ebmc_propertiest &properties,
Expand Down Expand Up @@ -154,9 +153,7 @@ int k_induction(
k_induction(
k, transition_system, properties, solver_factory, message_handler);

const namespacet ns(transition_system.symbol_table);
report_results(cmdline, properties, ns, message_handler);
return properties.exit_code();
return property_checker_resultt::VERIFICATION_RESULT;
}

/*******************************************************************\
Expand Down
3 changes: 2 additions & 1 deletion src/ebmc/k_induction.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ Author: Daniel Kroening, [email protected]
#include <util/message.h>

#include "ebmc_solver_factory.h"
#include "property_checker.h"

class transition_systemt;
class ebmc_propertiest;

int k_induction(
property_checker_resultt k_induction(
const cmdlinet &,
transition_systemt &,
ebmc_propertiest &,
Expand Down
79 changes: 44 additions & 35 deletions src/ebmc/property_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Author: Daniel Kroening, [email protected]
#include <chrono>
#include <iostream>

int word_level_bmc(
property_checker_resultt word_level_bmc(
const cmdlinet &cmdline,
const transition_systemt &transition_system,
ebmc_propertiest &properties,
Expand All @@ -38,8 +38,6 @@ int word_level_bmc(
bool convert_only = cmdline.isset("smt2") || cmdline.isset("outfile") ||
cmdline.isset("show-formula");

int result = 0;

try
{
if(cmdline.isset("max-bound"))
Expand Down Expand Up @@ -93,38 +91,34 @@ int word_level_bmc(
solver_factory,
message_handler);

if(!convert_only)
{
const namespacet ns(transition_system.symbol_table);
report_results(cmdline, properties, ns, message_handler);
result = properties.exit_code();
}
if(convert_only)
return property_checker_resultt::SUCCESS;
}
}

catch(const char *e)
{
messaget message{message_handler};
message.error() << e << messaget::eom;
return 10;
return property_checker_resultt::ERROR;
}

catch(const std::string &e)
{
messaget message{message_handler};
message.error() << e << messaget::eom;
return 10;
return property_checker_resultt::ERROR;
}

catch(int)
{
return 10;
return property_checker_resultt::ERROR;
}

return result;
return property_checker_resultt::VERIFICATION_RESULT;
}

int finish_bit_level_bmc(
property_checker_resultt finish_bit_level_bmc(
std::size_t bound,
const bmc_mapt &bmc_map,
propt &solver,
Expand Down Expand Up @@ -179,12 +173,12 @@ int finish_bit_level_bmc(

case propt::resultt::P_ERROR:
message.error() << "Error from decision procedure" << messaget::eom;
return 2;
return property_checker_resultt::ERROR;

default:
message.error() << "Unexpected result from decision procedure"
<< messaget::eom;
return 1;
return property_checker_resultt::ERROR;
}
}

Expand All @@ -195,10 +189,10 @@ int finish_bit_level_bmc(
<< std::chrono::duration<double>(sat_stop_time - sat_start_time).count()
<< messaget::eom;

return properties.exit_code();
return property_checker_resultt::VERIFICATION_RESULT;
}

int bit_level_bmc(
property_checker_resultt bit_level_bmc(
cnft &solver,
bool convert_only,
const cmdlinet &cmdline,
Expand All @@ -220,8 +214,6 @@ int bit_level_bmc(
bound = 1;
}

int result;

try
{
bmc_mapt bmc_map;
Expand Down Expand Up @@ -288,38 +280,35 @@ int bit_level_bmc(
}

if(convert_only)
result = 0;
return property_checker_resultt::SUCCESS;
else
{
result = finish_bit_level_bmc(
return finish_bit_level_bmc(
bound, bmc_map, solver, transition_system, properties, message_handler);
report_results(cmdline, properties, ns, message_handler);
}
}

catch(const char *e)
{
messaget message{message_handler};
message.error() << e << messaget::eom;
return 10;
return property_checker_resultt::ERROR;
}

catch(const std::string &e)
{
messaget message{message_handler};
message.error() << e << messaget::eom;
return 10;
return property_checker_resultt::ERROR;
}

catch(int)
{
return 10;
return property_checker_resultt::ERROR;
}

return result;
}

int bit_level_bmc(
property_checker_resultt bit_level_bmc(
const cmdlinet &cmdline,
transition_systemt &transition_system,
ebmc_propertiest &properties,
Expand Down Expand Up @@ -380,23 +369,43 @@ int property_checker(
ebmc_propertiest &properties,
message_handlert &message_handler)
{
property_checker_resultt result;

if(cmdline.isset("bdd") || cmdline.isset("show-bdds"))
{
return bdd_engine(cmdline, transition_system, properties, message_handler);
result =
bdd_engine(cmdline, transition_system, properties, message_handler);
}
else if(cmdline.isset("aig") || cmdline.isset("dimacs"))
{
return bit_level_bmc(
cmdline, transition_system, properties, message_handler);
result =
bit_level_bmc(cmdline, transition_system, properties, message_handler);
}
else if(cmdline.isset("k-induction"))
{
return k_induction(cmdline, transition_system, properties, message_handler);
result =
k_induction(cmdline, transition_system, properties, message_handler);
}
else
{
// default engine is word-level BMC
return word_level_bmc(
cmdline, transition_system, properties, message_handler);
result =
word_level_bmc(cmdline, transition_system, properties, message_handler);
}

switch(result)
{
case property_checker_resultt::ERROR:
return 10;

case property_checker_resultt::SUCCESS:
return 0;

case property_checker_resultt::VERIFICATION_RESULT:
const namespacet ns{transition_system.symbol_table};
report_results(cmdline, properties, ns, message_handler);
return properties.exit_code();
}

UNREACHABLE;
}
7 changes: 7 additions & 0 deletions src/ebmc/property_checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ Author: Daniel Kroening, [email protected]
#include "ebmc_properties.h"
#include "transition_system.h"

enum class property_checker_resultt
{
VERIFICATION_RESULT,
SUCCESS,
ERROR
};

int property_checker(
const cmdlinet &,
transition_systemt &,
Expand Down
Loading