safra: Fix nesting comparision
* src/tests/safra.cc: Output error message for wrong ltl formula. * src/twaalgos/safra.cc: Default comparision of vector does not correspond to the desired comparision.
This commit is contained in:
parent
8362bf3a5f
commit
ebe03cf3d0
2 changed files with 25 additions and 5 deletions
|
|
@ -27,6 +27,7 @@
|
|||
#include "ltlparse/public.hh"
|
||||
#include "twaalgos/dotty.hh"
|
||||
#include "twaalgos/hoa.hh"
|
||||
#include "twaalgos/degen.hh"
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
|
|
@ -42,6 +43,8 @@ int main(int argc, char* argv[])
|
|||
const spot::ltl::formula* f =
|
||||
spot::ltl::parse(input, pel, spot::ltl::default_environment::instance(),
|
||||
false);
|
||||
if (spot::ltl::format_parse_errors(std::cerr, input, pel))
|
||||
return 2;
|
||||
spot::translator trans(dict);
|
||||
trans.set_pref(spot::postprocessor::Deterministic);
|
||||
auto tmp = trans.run(f);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,21 @@ namespace spot
|
|||
{
|
||||
namespace
|
||||
{
|
||||
// Returns true if lhs has a smaller nesting pattern than rhs
|
||||
// If lhs and rhs are the same, return false.
|
||||
bool nesting_cmp(const std::vector<node_helper::brace_t>& lhs,
|
||||
const std::vector<node_helper::brace_t>& rhs)
|
||||
{
|
||||
size_t m = std::min(lhs.size(), rhs.size());
|
||||
size_t i = 0;
|
||||
for (; i < m; ++i)
|
||||
{
|
||||
if (lhs[i] < rhs[i])
|
||||
return true;
|
||||
}
|
||||
return lhs.size() > rhs.size();
|
||||
}
|
||||
|
||||
// Used to remove all acceptance whos value is above max_acc
|
||||
void remove_dead_acc(twa_graph_ptr& aut, unsigned max_acc)
|
||||
{
|
||||
|
|
@ -91,7 +106,10 @@ namespace spot
|
|||
{
|
||||
if (nb_braces_[i] == 0)
|
||||
{
|
||||
red = std::min(red, 2 * i + 1);
|
||||
// It is impossible to emit red == -1 as those transitions would
|
||||
// lead us in a sink states which are not created here.
|
||||
assert(i >= 1);
|
||||
red = std::min(red, 2 * i - 1);
|
||||
// Step A3: Brackets that do not contain any nodes emit red
|
||||
is_green_[i] = false;
|
||||
}
|
||||
|
|
@ -187,9 +205,9 @@ namespace spot
|
|||
auto i = nodes_.emplace(dst, copy);
|
||||
if (!i.second)
|
||||
{
|
||||
// Step A2: Remove all occurrences whos nesting pattern (i-e braces_)
|
||||
// is smaller
|
||||
if (copy > i.first->second)
|
||||
// Step A2: Only keep the smallest nesting pattern (i-e braces_) for
|
||||
// identical nodes. Nesting_cmp returnes true if copy is smaller
|
||||
if (nesting_cmp(copy, i.first->second))
|
||||
{
|
||||
// Remove brace count of replaced node
|
||||
for (auto b: i.first->second)
|
||||
|
|
@ -301,7 +319,6 @@ namespace spot
|
|||
deltas[t.cond] = std::make_pair(prev, bddnums.size());
|
||||
}
|
||||
}
|
||||
unsigned nc = bdd2num.size();
|
||||
|
||||
auto res = make_twa_graph(aut->get_dict());
|
||||
res->copy_ap_of(aut);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue