Skip to content

Commit f770a8e

Browse files
committed
random_traces functions now take ebmc_solver_factoryt
The random_traces module now uses the global solver factory, as opposed to constructing a specific solver itself.
1 parent 56199ec commit f770a8e

File tree

3 files changed

+27
-15
lines changed

3 files changed

+27
-15
lines changed

src/ebmc/neural_liveness.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ void neural_livenesst::sample(std::function<void(trans_tracet)> trace_consumer)
250250
trace_consumer,
251251
number_of_traces,
252252
number_of_trace_steps,
253+
solver_factory,
253254
message.get_message_handler());
254255
}
255256

src/ebmc/random_traces.cpp

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com
1616
#include <util/string2int.h>
1717
#include <util/unicode.h>
1818

19-
#include <solvers/flattening/boolbv.h>
20-
#include <solvers/sat/satcheck.h>
2119
#include <trans-word-level/instantiate_word_level.h>
2220
#include <trans-word-level/trans_trace_word_level.h>
2321
#include <trans-word-level/unwind.h>
@@ -43,8 +41,10 @@ class random_tracest
4341
public:
4442
explicit random_tracest(
4543
const transition_systemt &_transition_system,
44+
const ebmc_solver_factoryt &_solver_factory,
4645
message_handlert &_message_handler)
4746
: transition_system(_transition_system),
47+
solver_factory(_solver_factory),
4848
ns(_transition_system.symbol_table),
4949
message(_message_handler)
5050
{
@@ -58,6 +58,7 @@ class random_tracest
5858

5959
protected:
6060
const transition_systemt &transition_system;
61+
const ebmc_solver_factoryt &solver_factory;
6162
const namespacet ns;
6263
messaget message;
6364

@@ -86,8 +87,10 @@ class random_tracest
8687

8788
symbolst remove_constrained(const symbolst &) const;
8889

89-
void
90-
freeze(const symbolst &, std::size_t number_of_timeframes, boolbvt &) const;
90+
void freeze(
91+
const symbolst &,
92+
std::size_t number_of_timeframes,
93+
decision_proceduret &) const;
9194

9295
// Random number generator. These are fully specified in
9396
// the C++ standard, and produce the same values on compliant
@@ -210,7 +213,9 @@ int random_traces(const cmdlinet &cmdline, message_handlert &message_handler)
210213
trace_nr++;
211214
};
212215

213-
random_tracest(transition_system, message_handler)(
216+
const auto solver_factory = ebmc_solver_factory(cmdline);
217+
218+
random_tracest(transition_system, solver_factory, message_handler)(
214219
consumer, random_seed, number_of_traces, number_of_trace_steps);
215220

216221
return 0;
@@ -314,7 +319,9 @@ int random_trace(const cmdlinet &cmdline, message_handlert &message_handler)
314319
}
315320
};
316321

317-
random_tracest(transition_system, message_handler)(
322+
const auto solver_factory = ebmc_solver_factory(cmdline);
323+
324+
random_tracest(transition_system, solver_factory, message_handler)(
318325
consumer, random_seed, 1, number_of_trace_steps);
319326

320327
return 0;
@@ -337,6 +344,7 @@ void random_traces(
337344
const std::string &outfile_prefix,
338345
std::size_t number_of_traces,
339346
std::size_t number_of_trace_steps,
347+
const ebmc_solver_factoryt &solver_factory,
340348
message_handlert &message_handler)
341349
{
342350
std::size_t random_seed = 0;
@@ -355,7 +363,7 @@ void random_traces(
355363
trace_nr++;
356364
};
357365

358-
random_tracest(transition_system, message_handler)(
366+
random_tracest(transition_system, solver_factory, message_handler)(
359367
consumer, random_seed, number_of_traces, number_of_trace_steps);
360368
}
361369

@@ -376,11 +384,12 @@ void random_traces(
376384
std::function<void(trans_tracet)> consumer,
377385
std::size_t number_of_traces,
378386
std::size_t number_of_trace_steps,
387+
const ebmc_solver_factoryt &solver_factory,
379388
message_handlert &message_handler)
380389
{
381390
std::size_t random_seed = 0;
382391

383-
random_tracest(transition_system, message_handler)(
392+
random_tracest(transition_system, solver_factory, message_handler)(
384393
consumer, random_seed, number_of_traces, number_of_trace_steps);
385394
}
386395

@@ -479,15 +488,15 @@ Function: random_tracest::freeze
479488
void random_tracest::freeze(
480489
const symbolst &symbols,
481490
std::size_t number_of_timeframes,
482-
boolbvt &boolbv) const
491+
decision_proceduret &solver) const
483492
{
484493
for(std::size_t i = 0; i < number_of_timeframes; i++)
485494
{
486495
for(auto &symbol : symbols)
487496
{
488497
auto symbol_in_timeframe =
489498
instantiate(symbol, i, number_of_timeframes, ns);
490-
boolbv.set_frozen(boolbv.convert_bv(symbol_in_timeframe));
499+
(void)solver.handle(symbol_in_timeframe);
491500
}
492501
}
493502
}
@@ -578,8 +587,8 @@ void random_tracest::operator()(
578587

579588
message.status() << "Passing transition system to solver" << messaget::eom;
580589

581-
satcheckt satcheck{message.get_message_handler()};
582-
boolbvt solver(ns, satcheck, message.get_message_handler());
590+
auto solver_container = solver_factory(ns, message.get_message_handler());
591+
auto &solver = solver_container.decision_procedure();
583592

584593
::unwind(
585594
transition_system.trans_expr,
@@ -619,9 +628,7 @@ void random_tracest::operator()(
619628
auto merged =
620629
merge_constraints(input_constraints, initial_state_constraints);
621630

622-
solver.push(merged);
623-
auto dec_result = solver();
624-
solver.pop();
631+
auto dec_result = solver(conjunction(merged));
625632

626633
switch(dec_result)
627634
{

src/ebmc/random_traces.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Author: Daniel Kroening, kroening@kroening.com
99
#ifndef EBMC_RANDOM_TRACES_H
1010
#define EBMC_RANDOM_TRACES_H
1111

12+
#include "ebmc_solver_factory.h"
13+
1214
#include <functional>
1315
#include <string>
1416

@@ -30,6 +32,7 @@ void random_traces(
3032
const std::string &outfile_prefix,
3133
std::size_t number_of_traces,
3234
std::size_t number_of_trace_steps,
35+
const ebmc_solver_factoryt &,
3336
message_handlert &);
3437

3538
// many traces, given to a callback
@@ -38,6 +41,7 @@ void random_traces(
3841
std::function<void(trans_tracet)> consumer,
3942
std::size_t number_of_traces,
4043
std::size_t number_of_trace_steps,
44+
const ebmc_solver_factoryt &,
4145
message_handlert &);
4246

4347
#endif

0 commit comments

Comments
 (0)