rename tgba files as twa
Automatic mass renaming. * src/graphtest/tgbagraph.cc, src/tgba/acc.cc, src/tgba/acc.hh, src/tgba/bdddict.cc, src/tgba/bdddict.hh, src/tgba/bddprint.cc, src/tgba/bddprint.hh, src/tgba/formula2bdd.cc, src/tgba/formula2bdd.hh, src/tgba/fwd.hh, src/tgba/Makefile.am, src/tgba/taatgba.cc, src/tgba/taatgba.hh, src/tgba/tgba.cc, src/tgba/tgbagraph.cc, src/tgba/tgbagraph.hh, src/tgba/tgba.hh, src/tgba/tgbamask.cc, src/tgba/tgbamask.hh, src/tgba/tgbaproduct.cc, src/tgba/tgbaproduct.hh, src/tgba/tgbaproxy.cc, src/tgba/tgbaproxy.hh, src/tgba/tgbasafracomplement.cc, src/tgba/tgbasafracomplement.hh, src/tgba/.cvsignore: Rename as... * src/graphtest/twagraph.cc, src/twa/acc.cc, src/twa/acc.hh, src/twa/bdddict.cc, src/twa/bdddict.hh, src/twa/bddprint.cc, src/twa/bddprint.hh, src/twa/formula2bdd.cc, src/twa/formula2bdd.hh, src/twa/fwd.hh, src/twa/Makefile.am, src/twa/taatgba.cc, src/twa/taatgba.hh, src/twa/twa.cc, src/twa/twagraph.cc, src/twa/twagraph.hh, src/twa/twa.hh, src/twa/twamask.cc, src/twa/twamask.hh, src/twa/twaproduct.cc, src/twa/twaproduct.hh, src/twa/twaproxy.cc, src/twa/twaproxy.hh, src/twa/twasafracomplement.cc, src/twa/twasafracomplement.hh, src/twa/.cvsignore: ... these. * README, bench/stutter/stutter_invariance_randomgraph.cc, configure.ac, iface/ltsmin/modelcheck.cc, src/Makefile.am, src/bin/common_aoutput.cc, src/bin/common_conv.hh, src/bin/common_trans.hh, src/bin/dstar2tgba.cc, src/bin/ltl2tgta.cc, src/bin/randaut.cc, src/dstarparse/dra2ba.cc, src/dstarparse/public.hh, src/graphtest/Makefile.am, src/graphtest/ngraph.cc, src/hoaparse/hoaparse.yy, src/hoaparse/public.hh, src/kripke/fairkripke.hh, src/kripke/kripkeexplicit.cc, src/kripke/kripkeprint.cc, src/kripkeparse/kripkeparse.yy, src/ltlvisit/apcollect.cc, src/ltlvisit/apcollect.hh, src/ltlvisit/exclusive.hh, src/ltlvisit/simplify.cc, src/ltlvisit/simplify.hh, src/priv/accmap.hh, src/ta/ta.hh, src/ta/taexplicit.cc, src/ta/taexplicit.hh, src/ta/tgta.hh, src/ta/tgtaexplicit.cc, src/ta/tgtaexplicit.hh, src/ta/tgtaproduct.hh, src/taalgos/dotty.cc, src/taalgos/emptinessta.cc, src/taalgos/minimize.cc, src/taalgos/tgba2ta.cc, src/taalgos/tgba2ta.hh, src/tgbaalgos/are_isomorphic.cc, src/tgbaalgos/are_isomorphic.hh, src/tgbaalgos/bfssteps.cc, src/tgbaalgos/canonicalize.cc, src/tgbaalgos/canonicalize.hh, src/tgbaalgos/cleanacc.hh, src/tgbaalgos/complete.hh, src/tgbaalgos/compsusp.cc, src/tgbaalgos/compsusp.hh, src/tgbaalgos/degen.cc, src/tgbaalgos/degen.hh, src/tgbaalgos/dotty.cc, src/tgbaalgos/dotty.hh, src/tgbaalgos/dtbasat.cc, src/tgbaalgos/dtbasat.hh, src/tgbaalgos/dtgbacomp.hh, src/tgbaalgos/dtgbasat.cc, src/tgbaalgos/dtgbasat.hh, src/tgbaalgos/dupexp.cc, src/tgbaalgos/dupexp.hh, src/tgbaalgos/emptiness.cc, src/tgbaalgos/emptiness.hh, src/tgbaalgos/gtec/sccstack.hh, src/tgbaalgos/gtec/status.hh, src/tgbaalgos/gv04.cc, src/tgbaalgos/gv04.hh, src/tgbaalgos/hoa.cc, src/tgbaalgos/hoa.hh, src/tgbaalgos/isdet.hh, src/tgbaalgos/lbtt.cc, src/tgbaalgos/lbtt.hh, src/tgbaalgos/ltl2taa.hh, src/tgbaalgos/ltl2tgba_fm.cc, src/tgbaalgos/ltl2tgba_fm.hh, src/tgbaalgos/magic.cc, src/tgbaalgos/magic.hh, src/tgbaalgos/mask.hh, src/tgbaalgos/minimize.hh, src/tgbaalgos/ndfs_result.hxx, src/tgbaalgos/neverclaim.cc, src/tgbaalgos/neverclaim.hh, src/tgbaalgos/postproc.hh, src/tgbaalgos/powerset.cc, src/tgbaalgos/powerset.hh, src/tgbaalgos/product.cc, src/tgbaalgos/product.hh, src/tgbaalgos/projrun.cc, src/tgbaalgos/projrun.hh, src/tgbaalgos/randomgraph.cc, src/tgbaalgos/randomgraph.hh, src/tgbaalgos/randomize.hh, src/tgbaalgos/reachiter.hh, src/tgbaalgos/reducerun.cc, src/tgbaalgos/reducerun.hh, src/tgbaalgos/relabel.hh, src/tgbaalgos/remfin.hh, src/tgbaalgos/remprop.hh, src/tgbaalgos/replayrun.cc, src/tgbaalgos/replayrun.hh, src/tgbaalgos/sbacc.hh, src/tgbaalgos/scc.cc, src/tgbaalgos/scc.hh, src/tgbaalgos/sccfilter.hh, src/tgbaalgos/sccinfo.cc, src/tgbaalgos/sccinfo.hh, src/tgbaalgos/se05.cc, src/tgbaalgos/se05.hh, src/tgbaalgos/simulation.cc, src/tgbaalgos/simulation.hh, src/tgbaalgos/stats.cc, src/tgbaalgos/stats.hh, src/tgbaalgos/stripacc.hh, src/tgbaalgos/stutter.cc, src/tgbaalgos/stutter.hh, src/tgbaalgos/tau03.cc, src/tgbaalgos/tau03.hh, src/tgbaalgos/tau03opt.cc, src/tgbaalgos/tau03opt.hh, src/tgbaalgos/totgba.cc, src/tgbaalgos/totgba.hh, src/tgbaalgos/weight.hh, src/tgbaalgos/word.cc, src/tgbatest/acc.cc, src/tgbatest/complementation.cc, src/tgbatest/emptchk.cc, src/tgbatest/ltl2tgba.cc, src/tgbatest/taatgba.cc, wrap/python/spot_impl.i: Adjust.
This commit is contained in:
parent
8839f50a0f
commit
703fbd0e99
154 changed files with 232 additions and 231 deletions
482
src/twa/twagraph.hh
Normal file
482
src/twa/twagraph.hh
Normal file
|
|
@ -0,0 +1,482 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2014, 2015 Laboratoire de Recherche et Développement
|
||||
// de l'Epita.
|
||||
//
|
||||
// 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/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "fwd.hh"
|
||||
#include "graph/graph.hh"
|
||||
#include "graph/ngraph.hh"
|
||||
#include "twa/bdddict.hh"
|
||||
#include "twa/twa.hh"
|
||||
#include "tgbaalgos/dupexp.hh"
|
||||
#include <sstream>
|
||||
|
||||
namespace spot
|
||||
{
|
||||
|
||||
struct SPOT_API twa_graph_state: public spot::state
|
||||
{
|
||||
public:
|
||||
twa_graph_state():
|
||||
spot::state()
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~twa_graph_state() noexcept
|
||||
{
|
||||
}
|
||||
|
||||
virtual int compare(const spot::state* other) const
|
||||
{
|
||||
auto o = down_cast<const twa_graph_state*>(other);
|
||||
assert(o);
|
||||
|
||||
// Do not simply return "other - this", it might not fit in an int.
|
||||
if (o < this)
|
||||
return -1;
|
||||
if (o > this)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual size_t hash() const
|
||||
{
|
||||
return
|
||||
reinterpret_cast<const char*>(this) - static_cast<const char*>(nullptr);
|
||||
}
|
||||
|
||||
virtual twa_graph_state*
|
||||
clone() const
|
||||
{
|
||||
return const_cast<twa_graph_state*>(this);
|
||||
}
|
||||
|
||||
virtual void destroy() const
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct SPOT_API twa_graph_trans_data
|
||||
{
|
||||
bdd cond;
|
||||
acc_cond::mark_t acc;
|
||||
|
||||
explicit twa_graph_trans_data()
|
||||
: cond(bddfalse), acc(0)
|
||||
{
|
||||
}
|
||||
|
||||
twa_graph_trans_data(bdd cond, acc_cond::mark_t acc = 0U)
|
||||
: cond(cond), acc(acc)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator<(const twa_graph_trans_data& other) const
|
||||
{
|
||||
if (cond.id() < other.cond.id())
|
||||
return true;
|
||||
if (cond.id() > other.cond.id())
|
||||
return false;
|
||||
return acc < other.acc;
|
||||
}
|
||||
|
||||
bool operator==(const twa_graph_trans_data& other) const
|
||||
{
|
||||
return cond.id() == other.cond.id() &&
|
||||
acc == other.acc;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<class Graph>
|
||||
class SPOT_API twa_graph_succ_iterator final:
|
||||
public twa_succ_iterator
|
||||
{
|
||||
private:
|
||||
typedef typename Graph::transition transition;
|
||||
typedef typename Graph::state_data_t state;
|
||||
const Graph* g_;
|
||||
transition t_;
|
||||
transition p_;
|
||||
|
||||
public:
|
||||
twa_graph_succ_iterator(const Graph* g, transition t)
|
||||
: g_(g), t_(t)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void recycle(transition t)
|
||||
{
|
||||
t_ = t;
|
||||
}
|
||||
|
||||
virtual bool first()
|
||||
{
|
||||
p_ = t_;
|
||||
return p_;
|
||||
}
|
||||
|
||||
virtual bool next()
|
||||
{
|
||||
p_ = g_->trans_storage(p_).next_succ;
|
||||
return p_;
|
||||
}
|
||||
|
||||
virtual bool done() const
|
||||
{
|
||||
return !p_;
|
||||
}
|
||||
|
||||
virtual twa_graph_state* current_state() const
|
||||
{
|
||||
assert(!done());
|
||||
return const_cast<twa_graph_state*>
|
||||
(&g_->state_data(g_->trans_storage(p_).dst));
|
||||
}
|
||||
|
||||
virtual bdd current_condition() const
|
||||
{
|
||||
assert(!done());
|
||||
return g_->trans_data(p_).cond;
|
||||
}
|
||||
|
||||
virtual acc_cond::mark_t current_acceptance_conditions() const
|
||||
{
|
||||
assert(!done());
|
||||
return g_->trans_data(p_).acc;
|
||||
}
|
||||
|
||||
transition pos() const
|
||||
{
|
||||
return p_;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class SPOT_API twa_graph final: public twa
|
||||
{
|
||||
public:
|
||||
typedef digraph<twa_graph_state, twa_graph_trans_data> graph_t;
|
||||
typedef graph_t::trans_storage_t trans_storage_t;
|
||||
|
||||
protected:
|
||||
graph_t g_;
|
||||
mutable unsigned init_number_;
|
||||
|
||||
public:
|
||||
twa_graph(const bdd_dict_ptr& dict)
|
||||
: twa(dict),
|
||||
init_number_(0)
|
||||
{
|
||||
}
|
||||
|
||||
explicit twa_graph(const const_twa_graph_ptr& other, prop_set p)
|
||||
: twa(other->get_dict()),
|
||||
g_(other->g_), init_number_(other->init_number_)
|
||||
{
|
||||
copy_acceptance_of(other);
|
||||
copy_ap_of(other);
|
||||
prop_copy(other, p);
|
||||
}
|
||||
|
||||
virtual ~twa_graph()
|
||||
{
|
||||
get_dict()->unregister_all_my_variables(this);
|
||||
// Prevent this state from being destroyed by ~twa(),
|
||||
// as the state will be destroyed when g_ is destroyed.
|
||||
last_support_conditions_input_ = 0;
|
||||
}
|
||||
|
||||
// FIXME: Once we ditch GCC 4.6, we can using a template aliases
|
||||
// (supported from GCC 4.7 onward) instead of this.
|
||||
template <typename State_Name,
|
||||
typename Name_Hash = std::hash<State_Name>,
|
||||
typename Name_Equal = std::equal_to<State_Name>>
|
||||
struct namer
|
||||
{
|
||||
typedef named_graph<graph_t, State_Name, Name_Hash, Name_Equal> type;
|
||||
};
|
||||
|
||||
template <typename State_Name,
|
||||
typename Name_Hash = std::hash<State_Name>,
|
||||
typename Name_Equal = std::equal_to<State_Name>>
|
||||
typename namer<State_Name, Name_Hash, Name_Equal>::type*
|
||||
create_namer()
|
||||
{
|
||||
return new named_graph<graph_t, State_Name, Name_Hash, Name_Equal>(g_);
|
||||
}
|
||||
|
||||
graph_t& get_graph()
|
||||
{
|
||||
return g_;
|
||||
}
|
||||
|
||||
const graph_t& get_graph() const
|
||||
{
|
||||
return g_;
|
||||
}
|
||||
|
||||
unsigned num_states() const
|
||||
{
|
||||
return g_.num_states();
|
||||
}
|
||||
|
||||
unsigned num_transitions() const
|
||||
{
|
||||
return g_.num_transitions();
|
||||
}
|
||||
|
||||
void set_init_state(graph_t::state s)
|
||||
{
|
||||
assert(s < num_states());
|
||||
init_number_ = s;
|
||||
}
|
||||
|
||||
void set_init_state(const state* s)
|
||||
{
|
||||
set_init_state(state_number(s));
|
||||
}
|
||||
|
||||
graph_t::state get_init_state_number() const
|
||||
{
|
||||
if (num_states() == 0)
|
||||
const_cast<graph_t&>(g_).new_state();
|
||||
return init_number_;
|
||||
}
|
||||
|
||||
// FIXME: The return type ought to be const.
|
||||
virtual twa_graph_state* get_init_state() const
|
||||
{
|
||||
if (num_states() == 0)
|
||||
const_cast<graph_t&>(g_).new_state();
|
||||
return const_cast<twa_graph_state*>(state_from_number(init_number_));
|
||||
}
|
||||
|
||||
virtual twa_succ_iterator*
|
||||
succ_iter(const state* st) const
|
||||
{
|
||||
auto s = down_cast<const typename graph_t::state_storage_t*>(st);
|
||||
assert(s);
|
||||
assert(!s->succ || g_.valid_trans(s->succ));
|
||||
|
||||
if (this->iter_cache_)
|
||||
{
|
||||
auto it =
|
||||
down_cast<twa_graph_succ_iterator<graph_t>*>(this->iter_cache_);
|
||||
it->recycle(s->succ);
|
||||
this->iter_cache_ = nullptr;
|
||||
return it;
|
||||
}
|
||||
return new twa_graph_succ_iterator<graph_t>(&g_, s->succ);
|
||||
}
|
||||
|
||||
graph_t::state
|
||||
state_number(const state* st) const
|
||||
{
|
||||
auto s = down_cast<const typename graph_t::state_storage_t*>(st);
|
||||
assert(s);
|
||||
return s - &g_.state_storage(0);
|
||||
}
|
||||
|
||||
const twa_graph_state*
|
||||
state_from_number(graph_t::state n) const
|
||||
{
|
||||
return &g_.state_data(n);
|
||||
}
|
||||
|
||||
std::string format_state(unsigned n) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << n;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
virtual std::string format_state(const state* st) const
|
||||
{
|
||||
return format_state(state_number(st));
|
||||
}
|
||||
|
||||
twa_graph_trans_data& trans_data(const twa_succ_iterator* it)
|
||||
{
|
||||
auto* i = down_cast<const twa_graph_succ_iterator<graph_t>*>(it);
|
||||
return g_.trans_data(i->pos());
|
||||
}
|
||||
|
||||
twa_graph_trans_data& trans_data(unsigned t)
|
||||
{
|
||||
return g_.trans_data(t);
|
||||
}
|
||||
|
||||
const twa_graph_trans_data& trans_data(const twa_succ_iterator* it) const
|
||||
{
|
||||
auto* i = down_cast<const twa_graph_succ_iterator<graph_t>*>(it);
|
||||
return g_.trans_data(i->pos());
|
||||
}
|
||||
|
||||
const twa_graph_trans_data& trans_data(unsigned t) const
|
||||
{
|
||||
return g_.trans_data(t);
|
||||
}
|
||||
|
||||
trans_storage_t& trans_storage(const twa_succ_iterator* it)
|
||||
{
|
||||
auto* i = down_cast<const twa_graph_succ_iterator<graph_t>*>(it);
|
||||
return g_.trans_storage(i->pos());
|
||||
}
|
||||
|
||||
trans_storage_t& trans_storage(unsigned t)
|
||||
{
|
||||
return g_.trans_storage(t);
|
||||
}
|
||||
|
||||
const trans_storage_t
|
||||
trans_storage(const twa_succ_iterator* it) const
|
||||
{
|
||||
auto* i = down_cast<const twa_graph_succ_iterator<graph_t>*>(it);
|
||||
return g_.trans_storage(i->pos());
|
||||
}
|
||||
|
||||
const trans_storage_t trans_storage(unsigned t) const
|
||||
{
|
||||
return g_.trans_storage(t);
|
||||
}
|
||||
|
||||
unsigned new_state()
|
||||
{
|
||||
return g_.new_state();
|
||||
}
|
||||
|
||||
unsigned new_states(unsigned n)
|
||||
{
|
||||
return g_.new_states(n);
|
||||
}
|
||||
|
||||
unsigned new_transition(unsigned src, unsigned dst,
|
||||
bdd cond, acc_cond::mark_t acc = 0U)
|
||||
{
|
||||
return g_.new_transition(src, dst, cond, acc);
|
||||
}
|
||||
|
||||
unsigned new_acc_transition(unsigned src, unsigned dst,
|
||||
bdd cond, bool acc = true)
|
||||
{
|
||||
if (acc)
|
||||
return g_.new_transition(src, dst, cond, acc_.all_sets());
|
||||
else
|
||||
return g_.new_transition(src, dst, cond);
|
||||
}
|
||||
|
||||
#ifndef SWIG
|
||||
auto out(unsigned src) const
|
||||
SPOT_RETURN(g_.out(src));
|
||||
auto out(unsigned src)
|
||||
SPOT_RETURN(g_.out(src));
|
||||
|
||||
auto states() const
|
||||
SPOT_RETURN(g_.states());
|
||||
auto states()
|
||||
SPOT_RETURN(g_.states());
|
||||
|
||||
auto transitions() const
|
||||
SPOT_RETURN(g_.transitions());
|
||||
auto transitions()
|
||||
SPOT_RETURN(g_.transitions());
|
||||
|
||||
auto transition_vector() const
|
||||
SPOT_RETURN(g_.transition_vector());
|
||||
auto transition_vector()
|
||||
SPOT_RETURN(g_.transition_vector());
|
||||
|
||||
auto is_dead_transition(const graph_t::trans_storage_t& t) const
|
||||
SPOT_RETURN(g_.is_dead_transition(t));
|
||||
#endif
|
||||
|
||||
virtual bdd compute_support_conditions(const state* s) const
|
||||
{
|
||||
bdd sum = bddfalse;
|
||||
for (auto& t: out(state_number(s)))
|
||||
sum |= t.cond;
|
||||
return sum;
|
||||
}
|
||||
|
||||
/// Iterate over all transitions, and merge those with compatible
|
||||
/// extremities and acceptance.
|
||||
void merge_transitions();
|
||||
|
||||
/// Remove all states without successors.
|
||||
void purge_dead_states();
|
||||
|
||||
/// Remove all unreachable states.
|
||||
void purge_unreachable_states();
|
||||
|
||||
bool state_is_accepting(unsigned s) const
|
||||
{
|
||||
assert(has_state_based_acc() || acc_.num_sets() == 0);
|
||||
for (auto& t: g_.out(s))
|
||||
// Stop at the first transition, since the remaining should be
|
||||
// labeled identically.
|
||||
return acc_.accepting(t.acc);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool state_is_accepting(const state* s) const
|
||||
{
|
||||
return state_is_accepting(state_number(s));
|
||||
}
|
||||
|
||||
bool operator==(const twa_graph& aut) const
|
||||
{
|
||||
if (num_states() != aut.num_states() ||
|
||||
num_transitions() != aut.num_transitions() ||
|
||||
acc().num_sets() != aut.acc().num_sets())
|
||||
return false;
|
||||
auto& trans1 = transition_vector();
|
||||
auto& trans2 = aut.transition_vector();
|
||||
return std::equal(trans1.begin() + 1, trans1.end(),
|
||||
trans2.begin() + 1);
|
||||
}
|
||||
};
|
||||
|
||||
inline twa_graph_ptr make_twa_graph(const bdd_dict_ptr& dict)
|
||||
{
|
||||
return std::make_shared<twa_graph>(dict);
|
||||
}
|
||||
|
||||
inline twa_graph_ptr make_twa_graph(const twa_graph_ptr& aut,
|
||||
twa::prop_set p)
|
||||
{
|
||||
return std::make_shared<twa_graph>(aut, p);
|
||||
}
|
||||
|
||||
inline twa_graph_ptr make_twa_graph(const const_twa_graph_ptr& aut,
|
||||
twa::prop_set p)
|
||||
{
|
||||
return std::make_shared<twa_graph>(aut, p);
|
||||
}
|
||||
|
||||
inline twa_graph_ptr make_twa_graph(const const_twa_ptr& aut,
|
||||
twa::prop_set p)
|
||||
{
|
||||
auto a = std::dynamic_pointer_cast<const twa_graph>(aut);
|
||||
if (a)
|
||||
return std::make_shared<twa_graph>(a, p);
|
||||
else
|
||||
return tgba_dupexp_dfs(aut, p);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue