Commit 8068cfad authored by Alexandre Lewkowicz's avatar Alexandre Lewkowicz Committed by Alexandre Duret-Lutz

safra: Add complete option and rename files

* src/tests/safra.cc, src/twaalgos/safra.cc,
src/twaalgos/safra.hh, src/tests/safra.test: Rename as...
* spot/twaalgos/safra.cc, spot/twaalgos/safra.hh, tests/core/safra.cc
tests/core/safra.test: ... these.
* tests/Makefile.am: Update.
parent f88154e5
......@@ -24,9 +24,10 @@
#include <unordered_map>
#include "safra.hh"
#include "twaalgos/degen.hh"
#include "twaalgos/sccfilter.hh"
#include "twaalgos/simulation.hh"
#include "spot/twaalgos/degen.hh"
#include "spot/twaalgos/sccfilter.hh"
#include "spot/twaalgos/simulation.hh"
#include "spot/twaalgos/complete.hh"
namespace spot
{
......@@ -168,6 +169,8 @@ namespace spot
}
std::vector<bool> find_scc_paths(const scc_info& scc);
unsigned
safra_state::find_scc_brace_id(unsigned scc_id, const scc_info& scc)
{
......@@ -459,23 +462,6 @@ safra_state::compute_succs(const const_twa_graph_ptr& aut,
return nodes_ < other.nodes_;
}
// All edge going into an accepting SCC are marked as accepting
// This helps safra make fewer trees as we immediately see the accepting
// edge and don't create useless states
void
emit_accepting_scc(twa_graph_ptr& aut, scc_info& scc)
{
for (auto& e: aut->edges())
{
unsigned src_scc = scc.scc_of(e.src);
unsigned dst_scc = scc.scc_of(e.dst);
if (src_scc == dst_scc)
continue;
if (scc.is_accepting_scc(dst_scc))
e.acc |= 1;
}
}
std::vector<bool>
find_scc_paths(const scc_info& scc)
{
......@@ -504,12 +490,17 @@ safra_state::compute_succs(const const_twa_graph_ptr& aut,
twa_graph_ptr
tgba_determinisation(const const_twa_graph_ptr& a, bool bisimulation,
bool pretty_print, bool scc_opt, bool use_bisimulation)
bool pretty_print, bool scc_opt, bool use_bisimulation,
bool complete)
{
// Degeneralize
twa_graph_ptr aut = spot::scc_filter(spot::degeneralize_tba(a));
twa_graph_ptr aut = spot::degeneralize_tba(a);
std::map<int, bdd> implications;
aut = simulation(aut, &implications);
if (use_bisimulation)
{
aut = spot::scc_filter(aut);
aut = simulation(aut, &implications);
}
scc_info scc = scc_info(aut);
std::vector<bool> is_connected = find_scc_paths(scc);
......@@ -620,6 +611,8 @@ safra_state::compute_succs(const const_twa_graph_ptr& aut,
res = simulation(res);
if (pretty_print)
res->set_named_prop("state-names", print_debug(seen));
if (complete)
spot::complete_here(res);
return res;
}
}
......@@ -22,9 +22,9 @@
#include <set>
#include <map>
#include "misc/bddlt.hh"
#include "twa/twagraph.hh"
#include "twaalgos/sccinfo.hh"
#include <spot/misc/bddlt.hh>
#include <spot/twa/twagraph.hh>
#include <spot/twaalgos/sccinfo.hh>
namespace spot
{
......@@ -98,5 +98,6 @@ namespace spot
bool bisimulation = false,
bool pretty_print = false,
bool scc_opt = false,
bool use_bisimulation = false);
bool use_bisimulation = false,
bool complete = false);
}
......@@ -87,6 +87,7 @@ check_PROGRAMS = \
core/reduccmp \
core/reduceu \
core/reductaustr \
core/safra \
core/syntimpl \
core/taatgba \
core/trival \
......@@ -134,6 +135,7 @@ core_reduceu_SOURCES = core/equalsf.cc
core_reduceu_CPPFLAGS = $(AM_CPPFLAGS) -DREDUC -DEVENT_UNIV
core_reductaustr_SOURCES = core/equalsf.cc
core_reductaustr_CPPFLAGS = $(AM_CPPFLAGS) -DREDUC_TAUSTR
core_safra_SOURCES = core/safra.cc
core_syntimpl_SOURCES = core/syntimpl.cc
core_tostring_SOURCES = core/tostring.cc
core_trival_SOURCES = core/trival.cc
......@@ -256,6 +258,7 @@ TESTS_twa = \
core/randtgba.test \
core/isomorph.test \
core/uniq.test \
core/safra.test \
core/sbacc.test \
core/stutter-tgba.test \
core/strength.test \
......
......@@ -20,17 +20,18 @@
#include <iostream>
#include <cstring>
#include "tl/parse.hh" // spot::parse_infix_psl
#include "tl/formula.hh" // spot::formula
#include "parseaut/public.hh"
#include "twa/twagraph.hh"
#include "twaalgos/degen.hh"
#include "twaalgos/dot.hh" // print_dot
#include "twaalgos/hoa.hh" // print_hoa
#include "twaalgos/safra.hh"
#include "twaalgos/translate.hh"
#include "spot/tl/parse.hh" // spot::parse_infix_psl
#include "spot/tl/formula.hh" // spot::formula
#include "spot/parseaut/public.hh"
#include "spot/twa/twagraph.hh"
#include "spot/twaalgos/degen.hh"
#include "spot/twaalgos/dot.hh" // print_dot
#include "spot/twaalgos/hoa.hh" // print_hoa
#include "spot/twaalgos/safra.hh"
#include "spot/twaalgos/translate.hh"
int help();
int help()
{
std::cerr << "safra [OPTIONS]\n";
......@@ -53,6 +54,7 @@ int main(int argc, char* argv[])
bool out_dot = true;
bool out_hoa = false;
bool pretty_print = false;
bool complete = false;
char* input = nullptr;
if (argc <= 2)
......@@ -82,6 +84,8 @@ int main(int argc, char* argv[])
pretty_print = true;
else if (!strncmp(argv[i], "-b", 2))
sim = true;
else if (!strncmp(argv[i], "-c", 2))
complete = true;
else if (!strncmp(argv[i], "--scc_opt", 9))
scc_opt = true;
else if (!strncmp(argv[i], "--bisim_opt", 10))
......@@ -108,7 +112,7 @@ int main(int argc, char* argv[])
trans.set_pref(spot::postprocessor::Deterministic);
auto tmp = trans.run(f);
res = spot::tgba_determinisation(tmp, sim, pretty_print, scc_opt,
use_bisim);
use_bisim, complete);
}
else if (in_hoa)
{
......@@ -116,7 +120,7 @@ int main(int argc, char* argv[])
if (aut->format_errors(std::cerr))
return 2;
res = tgba_determinisation(aut->aut, sim, pretty_print, scc_opt,
use_bisim);
use_bisim, complete);
}
res->merge_edges();
......
......@@ -173,7 +173,7 @@ a M G(F!b | X!a)
G!a R XFb
EOF
run 0 ../safra --hoa double_b.hoa -H > out.hoa
ltl2tgba=../../bin/ltl2tgba
../../bin/ltlcross -F formulae \
ltl2tgba=ltl2tgba
ltlcross -F formulae \
"../safra -f %f -H > %O" \
"$ltl2tgba -f %f -H > %O"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment