Use shared_ptr for the emptiness check interfaces.
At the same time, this adds a is_empty() method to the tgba class, simplifying many places that ran emptiness checks. * iface/dve2/dve2check.cc, src/bin/ltlcross.cc, src/dstarparse/dra2ba.cc, src/ltlvisit/contain.cc, src/tgba/tgba.cc, src/tgba/tgba.hh, src/tgbaalgos/emptiness.cc, src/tgbaalgos/emptiness.hh, src/tgbaalgos/gtec/ce.cc, src/tgbaalgos/gtec/ce.hh, src/tgbaalgos/gtec/gtec.cc, src/tgbaalgos/gtec/gtec.hh, src/tgbaalgos/gv04.cc, src/tgbaalgos/gv04.hh, src/tgbaalgos/magic.cc, src/tgbaalgos/magic.hh, src/tgbaalgos/minimize.cc, src/tgbaalgos/ndfs_result.hxx, src/tgbaalgos/powerset.cc, src/tgbaalgos/projrun.cc, src/tgbaalgos/projrun.hh, src/tgbaalgos/reducerun.cc, src/tgbaalgos/reducerun.hh, src/tgbaalgos/replayrun.cc, src/tgbaalgos/replayrun.hh, src/tgbaalgos/rundotdec.cc, src/tgbaalgos/rundotdec.hh, src/tgbaalgos/se05.cc, src/tgbaalgos/se05.hh, src/tgbaalgos/tau03.cc, src/tgbaalgos/tau03.hh, src/tgbaalgos/tau03opt.cc, src/tgbaalgos/tau03opt.hh, src/tgbaalgos/word.cc, src/tgbaalgos/word.hh, src/tgbatest/checkpsl.cc, src/tgbatest/complementation.cc, src/tgbatest/emptchk.cc, src/tgbatest/ltl2tgba.cc, src/tgbatest/randtgba.cc, wrap/python/ajax/spot.in, wrap/python/spot.i: Use shared_ptr.
This commit is contained in:
parent
803e17bb8d
commit
6d7c258fd7
42 changed files with 335 additions and 402 deletions
|
|
@ -29,7 +29,6 @@
|
|||
#include "tgbaalgos/ltl2taa.hh"
|
||||
#include "tgbaalgos/sccfilter.hh"
|
||||
#include "tgba/tgbaproduct.hh"
|
||||
#include "tgbaalgos/gtec/gtec.hh"
|
||||
#include "tgbaalgos/dotty.hh"
|
||||
#include "tgbaalgos/dupexp.hh"
|
||||
|
||||
|
|
@ -76,14 +75,11 @@ main(int argc, char** argv)
|
|||
{
|
||||
auto apos = scc_filter(ltl_to_tgba_fm(fpos, d));
|
||||
auto aneg = scc_filter(ltl_to_tgba_fm(fneg, d));
|
||||
auto ec = spot::couvreur99(spot::product(apos, aneg));
|
||||
auto res = ec->check();
|
||||
if (res)
|
||||
if (!spot::product(apos, aneg)->is_empty())
|
||||
{
|
||||
std::cerr << "non-empty intersection between pos and neg (FM)\n";
|
||||
exit(2);
|
||||
std::cerr << "non-empty intersection between pos and neg (FM)\n";
|
||||
exit(2);
|
||||
}
|
||||
delete ec;
|
||||
|
||||
// Run make_future_conditions_collector, without testing the output.
|
||||
auto fc = spot::make_future_conditions_collector(apos, true);
|
||||
|
|
@ -93,28 +89,22 @@ main(int argc, char** argv)
|
|||
{
|
||||
auto apos = scc_filter(ltl_to_tgba_fm(fpos, d, true));
|
||||
auto aneg = scc_filter(ltl_to_tgba_fm(fneg, d, true));
|
||||
auto ec = spot::couvreur99(spot::product(apos, aneg));
|
||||
auto res = ec->check();
|
||||
if (res)
|
||||
if (!spot::product(apos, aneg)->is_empty())
|
||||
{
|
||||
std::cerr << "non-empty intersection between pos and neg (FM -x)\n";
|
||||
exit(2);
|
||||
}
|
||||
delete ec;
|
||||
}
|
||||
|
||||
if (fpos->is_ltl_formula())
|
||||
{
|
||||
auto apos = scc_filter(spot::tgba_dupexp_dfs(ltl_to_taa(fpos, d)));
|
||||
auto aneg = scc_filter(spot::tgba_dupexp_dfs(ltl_to_taa(fneg, d)));
|
||||
auto ec = spot::couvreur99(spot::product(apos, aneg));
|
||||
auto res = ec->check();
|
||||
if (res)
|
||||
if (!spot::product(apos, aneg)->is_empty())
|
||||
{
|
||||
std::cerr << "non-empty intersection between pos and neg (TAA)\n";
|
||||
exit(2);
|
||||
}
|
||||
delete ec;
|
||||
}
|
||||
}
|
||||
fpos->destroy();
|
||||
fneg->destroy();
|
||||
|
|
|
|||
|
|
@ -274,8 +274,8 @@ int main(int argc, char* argv[])
|
|||
nAf = spot::make_kv_complement(Af);
|
||||
nAnf = spot::make_kv_complement(Anf);
|
||||
}
|
||||
spot::emptiness_check* ec = spot::couvreur99(spot::product(nAf, nAnf));
|
||||
spot::emptiness_check_result* res = ec->check();
|
||||
auto ec = spot::couvreur99(spot::product(nAf, nAnf));
|
||||
auto res = ec->check();
|
||||
spot::tgba_statistics a_size = spot::stats_reachable(ec->automaton());
|
||||
std::cout << "States: "
|
||||
<< a_size.states << std::endl
|
||||
|
|
@ -292,12 +292,8 @@ int main(int argc, char* argv[])
|
|||
else
|
||||
std::cout << "OK";
|
||||
std::cout << std::endl;
|
||||
|
||||
delete res;
|
||||
delete ec;
|
||||
nf1->destroy();
|
||||
f1->destroy();
|
||||
|
||||
}
|
||||
|
||||
return return_value;
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ main(int argc, char** argv)
|
|||
for (auto& algo: algos)
|
||||
{
|
||||
const char* err;
|
||||
auto i = spot::emptiness_check_instantiator::construct(algo, &err);
|
||||
auto i = spot::make_emptiness_check_instantiator(algo, &err);
|
||||
if (!i)
|
||||
{
|
||||
std::cerr << "Failed to parse `" << err << '\'' << std::endl;
|
||||
|
|
@ -157,17 +157,14 @@ main(int argc, char** argv)
|
|||
int ce_found = 0;
|
||||
do
|
||||
{
|
||||
auto res = ec->check();
|
||||
if (res)
|
||||
if (auto res = ec->check())
|
||||
{
|
||||
++ce_found;
|
||||
std::cout << ce_found << " counterexample found\n";
|
||||
auto run = res->accepting_run();
|
||||
if (run)
|
||||
if (auto run = res->accepting_run())
|
||||
{
|
||||
auto ar = spot::tgba_run_to_tgba(a, run);
|
||||
spot::dotty_reachable(std::cout, ar, false);
|
||||
delete run;
|
||||
}
|
||||
std::cout << '\n';
|
||||
if (runs == 0)
|
||||
|
|
@ -175,7 +172,6 @@ main(int argc, char** argv)
|
|||
std::cerr << "ERROR: Expected no counterexample.\n";
|
||||
exit(1);
|
||||
}
|
||||
delete res;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -201,10 +197,7 @@ main(int argc, char** argv)
|
|||
std::cerr << "ERROR: expected a counterexample.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
delete ec;
|
||||
}
|
||||
delete i;
|
||||
}
|
||||
f->destroy();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -354,7 +354,7 @@ checked_main(int argc, char** argv)
|
|||
int output = 0;
|
||||
int formula_index = 0;
|
||||
const char* echeck_algo = 0;
|
||||
spot::emptiness_check_instantiator* echeck_inst = 0;
|
||||
spot::emptiness_check_instantiator_ptr echeck_inst = 0;
|
||||
enum { NoneDup, BFS, DFS } dupexp = NoneDup;
|
||||
bool expect_counter_example = false;
|
||||
bool accepting_run = false;
|
||||
|
|
@ -500,7 +500,7 @@ checked_main(int argc, char** argv)
|
|||
|
||||
const char* err;
|
||||
echeck_inst =
|
||||
spot::emptiness_check_instantiator::construct(echeck_algo, &err);
|
||||
spot::make_emptiness_check_instantiator(echeck_algo, &err);
|
||||
if (!echeck_inst)
|
||||
{
|
||||
std::cerr << "Failed to parse argument of -e near `"
|
||||
|
|
@ -518,7 +518,7 @@ checked_main(int argc, char** argv)
|
|||
|
||||
const char* err;
|
||||
echeck_inst =
|
||||
spot::emptiness_check_instantiator::construct(echeck_algo, &err);
|
||||
spot::make_emptiness_check_instantiator(echeck_algo, &err);
|
||||
if (!echeck_inst)
|
||||
{
|
||||
std::cerr << "Failed to parse argument of -e near `"
|
||||
|
|
@ -1713,13 +1713,13 @@ checked_main(int argc, char** argv)
|
|||
|
||||
if (echeck_inst)
|
||||
{
|
||||
spot::emptiness_check* ec = echeck_inst->instantiate(a);
|
||||
auto ec = echeck_inst->instantiate(a);
|
||||
bool search_many = echeck_inst->options().get("repeated");
|
||||
assert(ec);
|
||||
do
|
||||
{
|
||||
tm.start("running emptiness check");
|
||||
spot::emptiness_check_result* res = ec->check();
|
||||
auto res = ec->check();
|
||||
tm.stop("running emptiness check");
|
||||
|
||||
if (paper_opt)
|
||||
|
|
@ -1736,8 +1736,7 @@ checked_main(int argc, char** argv)
|
|||
std::cout <<
|
||||
ec->automaton()->number_of_acceptance_conditions()
|
||||
<< ", ";
|
||||
const spot::ec_statistics* ecs =
|
||||
dynamic_cast<const spot::ec_statistics*>(ec);
|
||||
auto ecs = ec->emptiness_check_statistics();
|
||||
if (ecs)
|
||||
std::cout << std::right << std::setw(10)
|
||||
<< ecs->states() << ", "
|
||||
|
|
@ -1781,7 +1780,7 @@ checked_main(int argc, char** argv)
|
|||
{
|
||||
|
||||
tm.start("computing accepting run");
|
||||
spot::tgba_run* run = res->accepting_run();
|
||||
auto run = res->accepting_run();
|
||||
tm.stop("computing accepting run");
|
||||
|
||||
if (!run)
|
||||
|
|
@ -1793,11 +1792,8 @@ checked_main(int argc, char** argv)
|
|||
if (opt_reduce)
|
||||
{
|
||||
tm.start("reducing accepting run");
|
||||
spot::tgba_run* redrun =
|
||||
spot::reduce_run(res->automaton(), run);
|
||||
run = spot::reduce_run(res->automaton(), run);
|
||||
tm.stop("reducing accepting run");
|
||||
delete run;
|
||||
run = redrun;
|
||||
}
|
||||
if (accepting_run_replay)
|
||||
{
|
||||
|
|
@ -1827,7 +1823,6 @@ checked_main(int argc, char** argv)
|
|||
}
|
||||
tm.stop("printing accepting run");
|
||||
}
|
||||
delete run;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -1836,14 +1831,11 @@ checked_main(int argc, char** argv)
|
|||
<< "(use -C to print it)" << std::endl;
|
||||
}
|
||||
}
|
||||
delete res;
|
||||
}
|
||||
while (search_many);
|
||||
delete ec;
|
||||
}
|
||||
if (f)
|
||||
f->destroy();
|
||||
delete echeck_inst;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@
|
|||
struct ec_algo
|
||||
{
|
||||
std::string name;
|
||||
spot::emptiness_check_instantiator* inst;
|
||||
spot::emptiness_check_instantiator_ptr inst;
|
||||
};
|
||||
|
||||
const char* default_algos[] = {
|
||||
|
|
@ -84,12 +84,12 @@ const char* default_algos[] = {
|
|||
|
||||
std::vector<ec_algo> ec_algos;
|
||||
|
||||
spot::emptiness_check*
|
||||
spot::emptiness_check_ptr
|
||||
cons_emptiness_check(int num, spot::const_tgba_ptr a,
|
||||
const spot::const_tgba_ptr& degen,
|
||||
unsigned int n_acc)
|
||||
{
|
||||
spot::emptiness_check_instantiator* inst = ec_algos[num].inst;
|
||||
auto inst = ec_algos[num].inst;
|
||||
if (n_acc < inst->min_acceptance_conditions()
|
||||
|| n_acc > inst->max_acceptance_conditions())
|
||||
a = degen;
|
||||
|
|
@ -380,7 +380,7 @@ struct ar_stat
|
|||
}
|
||||
|
||||
void
|
||||
count(const spot::tgba_run* run)
|
||||
count(const spot::const_tgba_run_ptr& run)
|
||||
{
|
||||
int p = run->prefix.size();
|
||||
int c = run->cycle.size();
|
||||
|
|
@ -837,9 +837,8 @@ main(int argc, char** argv)
|
|||
{
|
||||
const char* err;
|
||||
ec_algos[i].inst =
|
||||
spot::emptiness_check_instantiator::construct(ec_algos[i]
|
||||
.name.c_str(),
|
||||
&err);
|
||||
spot::make_emptiness_check_instantiator(ec_algos[i].name.c_str(),
|
||||
&err);
|
||||
if (ec_algos[i].inst == 0)
|
||||
{
|
||||
std::cerr << "Parse error after `" << err << '\'' << std::endl;
|
||||
|
|
@ -939,9 +938,7 @@ main(int argc, char** argv)
|
|||
|
||||
for (int i = 0; i < n_alg; ++i)
|
||||
{
|
||||
spot::emptiness_check* ec;
|
||||
spot::emptiness_check_result* res;
|
||||
ec = cons_emptiness_check(i, a, degen, real_n_acc);
|
||||
auto ec = cons_emptiness_check(i, a, degen, real_n_acc);
|
||||
if (!ec)
|
||||
continue;
|
||||
++n_ec;
|
||||
|
|
@ -952,17 +949,16 @@ main(int argc, char** argv)
|
|||
std::cout << algo << ": ";
|
||||
}
|
||||
tm_ec.start(algo);
|
||||
spot::emptiness_check_result_ptr res;
|
||||
for (int count = opt_R;;)
|
||||
{
|
||||
res = ec->check();
|
||||
if (count-- <= 0)
|
||||
break;
|
||||
delete res;
|
||||
delete ec;
|
||||
ec = cons_emptiness_check(i, a, degen, real_n_acc);
|
||||
}
|
||||
tm_ec.stop(algo);
|
||||
const spot::unsigned_statistics* ecs = ec->statistics();
|
||||
auto ecs = ec->statistics();
|
||||
if (opt_z && res)
|
||||
{
|
||||
// Notice that ratios are computed w.r.t. the
|
||||
|
|
@ -1001,7 +997,7 @@ main(int argc, char** argv)
|
|||
++n_non_empty;
|
||||
if (opt_replay)
|
||||
{
|
||||
spot::tgba_run* run;
|
||||
spot::tgba_run_ptr run;
|
||||
bool done = false;
|
||||
tm_ar.start(algo);
|
||||
for (int count = opt_R;;)
|
||||
|
|
@ -1030,7 +1026,6 @@ main(int argc, char** argv)
|
|||
|
||||
if (count-- <= 0 || !run)
|
||||
break;
|
||||
delete run;
|
||||
}
|
||||
if (!run)
|
||||
{
|
||||
|
|
@ -1065,7 +1060,7 @@ main(int argc, char** argv)
|
|||
|
||||
if (opt_reduce)
|
||||
{
|
||||
spot::tgba_run* redrun =
|
||||
auto redrun =
|
||||
spot::reduce_run(res->automaton(), run);
|
||||
if (!spot::replay_tgba_run(s,
|
||||
res
|
||||
|
|
@ -1093,14 +1088,11 @@ main(int argc, char** argv)
|
|||
<< redrun->cycle.size()
|
||||
<< ']';
|
||||
}
|
||||
delete redrun;
|
||||
}
|
||||
delete run;
|
||||
}
|
||||
}
|
||||
if (!opt_paper)
|
||||
std::cout << std::endl;
|
||||
delete res;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1122,7 +1114,6 @@ main(int argc, char** argv)
|
|||
|
||||
if (opt_Z && !opt_paper)
|
||||
ec->print_stats(std::cout);
|
||||
delete ec;
|
||||
}
|
||||
|
||||
assert(n_empty + n_non_empty + n_maybe_empty == n_ec);
|
||||
|
|
@ -1310,10 +1301,6 @@ main(int argc, char** argv)
|
|||
delete formula_file;
|
||||
}
|
||||
|
||||
if (opt_ec)
|
||||
for (unsigned i = 0; i < ec_algos.size(); ++i)
|
||||
delete ec_algos[i].inst;
|
||||
|
||||
delete ap;
|
||||
delete apf;
|
||||
return exit_code;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue