spot/src/tgbaalgos/mask.cc
Alexandre Duret-Lutz 1f0bb428b0 add a stutter-invariant property to automata
... and show it in the HOA output.  Fixes #60.

* src/tgba/tgba.hh: Add is_stutter_invariant().
* src/tgbaalgos/hoa.cc: Print stutter-invariant
and inherently-weak.
* src/tgbaalgos/ltl2tgba_fm.cc: Set both.
* src/tgbaalgos/are_isomorphic.cc, src/tgbaalgos/complete.cc,
src/tgbaalgos/degen.cc, src/tgbaalgos/dtgbacomp.cc,
src/tgbaalgos/mask.cc, src/tgbaalgos/minimize.cc,
src/tgbaalgos/remfin.cc, src/tgbaalgos/sccfilter.cc,
src/tgbaalgos/simulation.cc, src/tgbaalgos/stutter.cc,
src/tgbatest/hoaparse.test, src/tgbatest/ltldo.test,
src/tgbatest/monitor.test, src/tgbatest/randomize.test,
src/tgbatest/remfin.test, src/tgbatest/sbacc.test: Adjust.
2015-02-28 16:44:06 +01:00

70 lines
2.4 KiB
C++

// -*- coding: utf-8 -*-
// Copyright (C) 2015 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "mask.hh"
namespace spot
{
tgba_digraph_ptr mask_acc_sets(const const_tgba_digraph_ptr& in,
acc_cond::mark_t to_remove)
{
auto res = make_tgba_digraph(in->get_dict());
res->copy_ap_of(in);
res->prop_copy(in, { true, false, true, true, false });
unsigned na = in->acc().num_sets();
unsigned tr = to_remove.count();
assert(tr <= na);
res->set_acceptance(na - tr,
in->get_acceptance().strip(to_remove, false));
transform_accessible(in, res, [&](unsigned,
bdd& cond,
acc_cond::mark_t& acc,
unsigned)
{
if (acc & to_remove)
cond = bddfalse;
else
acc = acc.strip(to_remove);
});
return res;
}
tgba_digraph_ptr mask_keep_states(const const_tgba_digraph_ptr& in,
std::vector<bool>& to_keep,
unsigned int init)
{
if (to_keep.size() < in->num_states())
to_keep.resize(in->num_states(), false);
auto res = make_tgba_digraph(in->get_dict());
res->copy_ap_of(in);
res->prop_copy(in, { true, true, true, true, false });
res->copy_acceptance_conditions_of(in);
transform_copy(in, res, [&](unsigned src,
bdd& cond,
acc_cond::mark_t&,
unsigned dst)
{
if (!to_keep[src] || !to_keep[dst])
cond = bddfalse;
}, init);
return res;
}
}