fix constness of twa::get_init_state() and twa_succ_iterator::dst()

Fixes #125.

* src/kripke/kripkegraph.hh, src/ta/ta.cc, src/ta/ta.hh,
src/ta/taexplicit.cc, src/ta/taexplicit.hh, src/ta/taproduct.cc,
src/ta/taproduct.hh, src/ta/tgtaproduct.cc, src/ta/tgtaproduct.hh,
src/taalgos/dot.cc, src/taalgos/emptinessta.cc,
src/taalgos/emptinessta.hh, src/taalgos/minimize.cc,
src/taalgos/reachiter.cc, src/taalgos/tgba2ta.cc, src/twa/twa.hh,
src/twa/twagraph.hh, src/twa/twaproduct.cc, src/twa/twaproduct.hh,
src/twaalgos/compsusp.cc, src/twaalgos/gtec/gtec.cc,
src/twaalgos/ltl2tgba_fm.cc, src/twaalgos/reachiter.cc,
src/twaalgos/stutter.cc: Adjust.
This commit is contained in:
Alexandre Duret-Lutz 2015-11-28 21:47:04 +01:00
parent afbaa54d92
commit 06b176991e
24 changed files with 144 additions and 178 deletions

View file

@ -180,12 +180,11 @@ namespace spot
return init_number_; return init_number_;
} }
// FIXME: The return type ought to be const. virtual const kripke_graph_state* get_init_state() const
virtual kripke_graph_state* get_init_state() const
{ {
if (num_states() == 0) if (num_states() == 0)
const_cast<graph_t&>(g_).new_state(); const_cast<graph_t&>(g_).new_state();
return const_cast<kripke_graph_state*>(state_from_number(init_number_)); return state_from_number(init_number_);
} }
/// \brief Allow to get an iterator on the state we passed in /// \brief Allow to get an iterator on the state we passed in

View file

@ -56,7 +56,7 @@ namespace spot
s.emplace_front(index); s.emplace_front(index);
} }
std::list<state*>& std::list<const state*>&
scc_stack_ta::rem() scc_stack_ta::rem()
{ {
return top().rem; return top().rem;

View file

@ -90,9 +90,10 @@ namespace spot
} }
typedef std::set<state*, state_ptr_less_than> states_set_t; typedef std::set<state*, state_ptr_less_than> states_set_t;
typedef std::set<const state*, state_ptr_less_than> const_states_set_t;
/// \brief Get the initial states set of the automaton. /// \brief Get the initial states set of the automaton.
virtual const states_set_t virtual const_states_set_t
get_initial_states_set() const = 0; get_initial_states_set() const = 0;
/// \brief Get the artificial initial state set of the automaton. /// \brief Get the artificial initial state set of the automaton.
@ -102,7 +103,7 @@ namespace spot
/// artificial initial state have one transition to each real initial state, /// artificial initial state have one transition to each real initial state,
/// and this transition is labeled by the corresponding initial condition. /// and this transition is labeled by the corresponding initial condition.
/// (For more details, see the paper cited above) /// (For more details, see the paper cited above)
virtual spot::state* virtual const spot::state*
get_artificial_initial_state() const get_artificial_initial_state() const
{ {
return nullptr; return nullptr;
@ -205,17 +206,14 @@ namespace spot
virtual bool next() = 0; virtual bool next() = 0;
virtual bool done() const = 0; virtual bool done() const = 0;
virtual state* virtual const state* dst() const = 0;
dst() const = 0;
/// \brief Get the changeset on the transition leading to current successor. /// \brief Get the changeset on the transition leading to current successor.
/// ///
/// This is a boolean function of atomic propositions. /// This is a boolean function of atomic propositions.
virtual bdd virtual bdd cond() const = 0;
cond() const = 0;
acc_cond::mark_t acc_cond::mark_t acc() const = 0;
acc() const = 0;
}; };
@ -238,7 +236,7 @@ namespace spot
/// transitions which connect the states of the connected component. /// transitions which connect the states of the connected component.
acc_cond::mark_t condition; acc_cond::mark_t condition;
std::list<state*> rem; std::list<const state*> rem;
}; };
/// Stack a new SCC with index \a index. /// Stack a new SCC with index \a index.
@ -262,7 +260,7 @@ namespace spot
size() const; size() const;
/// The \c rem member of the top SCC. /// The \c rem member of the top SCC.
std::list<state*>& std::list<const state*>&
rem(); rem();
/// Is the stack empty? /// Is the stack empty?

View file

@ -71,7 +71,7 @@ namespace spot
return !transitions_ || i_ == transitions_->end(); return !transitions_ || i_ == transitions_->end();
} }
state* const state*
ta_explicit_succ_iterator::dst() const ta_explicit_succ_iterator::dst() const
{ {
trace trace
@ -81,8 +81,7 @@ namespace spot
trace trace
<< "***ta_explicit_succ_iterator::dst() (*i_)->condition =***" << "***ta_explicit_succ_iterator::dst() (*i_)->condition =***"
<< (*i_)->condition << std::endl; << (*i_)->condition << std::endl;
state_ta_explicit* s = (*i_)->dest; return (*i_)->dest;
return s;
} }
bdd bdd
@ -273,7 +272,7 @@ namespace spot
if (trans) if (trans)
for (it_trans = trans->begin(); it_trans != trans->end();) for (it_trans = trans->begin(); it_trans != trans->end();)
{ {
state_ta_explicit* dest = (*it_trans)->dest; auto dest = (*it_trans)->dest;
bool is_stuttering_transition = (get_tgba_condition() bool is_stuttering_transition = (get_tgba_condition()
== (dest)->get_tgba_condition()); == (dest)->get_tgba_condition());
bool dest_is_livelock_accepting = bool dest_is_livelock_accepting =
@ -316,14 +315,11 @@ namespace spot
state_ta_explicit::free_transitions() state_ta_explicit::free_transitions()
{ {
state_ta_explicit::transitions* trans = transitions_; state_ta_explicit::transitions* trans = transitions_;
state_ta_explicit::transitions::iterator it_trans;
// We don't destroy the transitions in the state's destructor because // We don't destroy the transitions in the state's destructor because
// they are not cloned. // they are not cloned.
if (trans) if (trans)
for (it_trans = trans->begin(); it_trans != trans->end(); ++it_trans) for (auto& t: *trans)
{ delete t;
delete *it_trans;
}
delete trans; delete trans;
std::unordered_map<int, transitions*, std::hash<int> >::iterator i = std::unordered_map<int, transitions*, std::hash<int> >::iterator i =
@ -353,7 +349,7 @@ namespace spot
acc().set_generalized_buchi(); acc().set_generalized_buchi();
if (artificial_initial_state) if (artificial_initial_state)
{ {
state_ta_explicit* is = add_state(artificial_initial_state); auto is = add_state(artificial_initial_state);
assert(is == artificial_initial_state); assert(is == artificial_initial_state);
(void)is; (void)is;
} }
@ -364,7 +360,8 @@ namespace spot
ta::states_set_t::iterator it; ta::states_set_t::iterator it;
for (it = states_set_.begin(); it != states_set_.end(); ++it) for (it = states_set_.begin(); it != states_set_.end(); ++it)
{ {
state_ta_explicit* s = down_cast<state_ta_explicit*>(*it); auto* s = const_cast<state_ta_explicit*>
(down_cast<const state_ta_explicit*>(*it));
s->free_transitions(); s->free_transitions();
s->get_tgba_state()->destroy(); s->get_tgba_state()->destroy();
@ -379,7 +376,7 @@ namespace spot
std::pair<ta::states_set_t::iterator, bool> add_state_to_ta = std::pair<ta::states_set_t::iterator, bool> add_state_to_ta =
states_set_.insert(s); states_set_.insert(s);
return static_cast<state_ta_explicit*>(*add_state_to_ta.first); return down_cast<state_ta_explicit*>(*add_state_to_ta.first);
} }
void void
@ -389,21 +386,21 @@ namespace spot
s->set_initial_state(true); s->set_initial_state(true);
if (condition == bddfalse) if (condition == bddfalse)
condition = get_state_condition(s); condition = get_state_condition(s);
std::pair<ta::states_set_t::iterator, bool> add_state = auto add_state = initial_states_set_.insert(s);
initial_states_set_.insert(s);
if (get_artificial_initial_state()) if (get_artificial_initial_state())
if (add_state.second) if (add_state.second)
{ {
state_ta_explicit* i = auto i =
down_cast<state_ta_explicit*>(get_artificial_initial_state()); down_cast<state_ta_explicit*>(get_artificial_initial_state());
create_transition(i, condition, 0U, s); create_transition(i, condition, 0U, s);
} }
} }
void void
ta_explicit::delete_stuttering_and_hole_successors(spot::state* s) ta_explicit::delete_stuttering_and_hole_successors(const spot::state* s)
{ {
state_ta_explicit * state = down_cast<state_ta_explicit*>(s); auto state =
const_cast<state_ta_explicit*>(down_cast<const state_ta_explicit*>(s));
assert(state); assert(state);
state->delete_stuttering_and_hole_successors(); state->delete_stuttering_and_hole_successors();
if (state->is_initial_state()) if (state->is_initial_state())
@ -414,7 +411,8 @@ namespace spot
void void
ta_explicit::create_transition(state_ta_explicit* source, bdd condition, ta_explicit::create_transition(state_ta_explicit* source, bdd condition,
acc_cond::mark_t acceptance_conditions, acc_cond::mark_t acceptance_conditions,
state_ta_explicit* dest, bool add_at_beginning) const state_ta_explicit* dest,
bool add_at_beginning)
{ {
state_ta_explicit::transition* t = new state_ta_explicit::transition; state_ta_explicit::transition* t = new state_ta_explicit::transition;
t->dest = dest; t->dest = dest;
@ -424,7 +422,7 @@ namespace spot
} }
const ta::states_set_t ta::const_states_set_t
ta_explicit::get_initial_states_set() const ta_explicit::get_initial_states_set() const
{ {
return initial_states_set_; return initial_states_set_;

View file

@ -56,7 +56,7 @@ namespace spot
void void
create_transition(state_ta_explicit* source, bdd condition, create_transition(state_ta_explicit* source, bdd condition,
acc_cond::mark_t acceptance_conditions, acc_cond::mark_t acceptance_conditions,
state_ta_explicit* dest, const state_ta_explicit* dest,
bool add_at_beginning = false); bool add_at_beginning = false);
void void
@ -64,7 +64,7 @@ namespace spot
// ta interface // ta interface
virtual virtual
~ta_explicit(); ~ta_explicit();
virtual const states_set_t virtual const_states_set_t
get_initial_states_set() const; get_initial_states_set() const;
virtual ta_succ_iterator* virtual ta_succ_iterator*
@ -108,7 +108,7 @@ namespace spot
} }
virtual void virtual void
delete_stuttering_and_hole_successors(spot::state* s); delete_stuttering_and_hole_successors(const spot::state* s);
ta::states_set_t ta::states_set_t
get_states_set() get_states_set()
@ -124,7 +124,7 @@ namespace spot
const_twa_ptr tgba_; const_twa_ptr tgba_;
state_ta_explicit* artificial_initial_state_; state_ta_explicit* artificial_initial_state_;
ta::states_set_t states_set_; ta::states_set_t states_set_;
ta::states_set_t initial_states_set_; ta::const_states_set_t initial_states_set_;
}; };
/// states used by spot::ta_explicit. /// states used by spot::ta_explicit.
@ -139,7 +139,7 @@ namespace spot
{ {
bdd condition; bdd condition;
acc_cond::mark_t acceptance_conditions; acc_cond::mark_t acceptance_conditions;
state_ta_explicit* dest; const state_ta_explicit* dest;
}; };
typedef std::list<transition*> transitions; typedef std::list<transition*> transitions;
@ -238,13 +238,10 @@ namespace spot
virtual bool next(); virtual bool next();
virtual bool done() const; virtual bool done() const;
virtual state* virtual const state* dst() const;
dst() const; virtual bdd cond() const;
virtual bdd
cond() const;
virtual acc_cond::mark_t virtual acc_cond::mark_t acc() const;
acc() const;
private: private:
state_ta_explicit::transitions* transitions_; state_ta_explicit::transitions* transitions_;

View file

@ -259,26 +259,25 @@ namespace spot
dict_->unregister_all_my_variables(this); dict_->unregister_all_my_variables(this);
} }
const ta::states_set_t ta::const_states_set_t
ta_product::get_initial_states_set() const ta_product::get_initial_states_set() const
{ {
//build initial states set //build initial states set
ta::states_set_t ta_init_states_set; ta::const_states_set_t ta_init_states_set;
ta::states_set_t::const_iterator it; ta::const_states_set_t::const_iterator it;
ta::states_set_t initial_states_set; ta::const_states_set_t initial_states_set;
state* kripke_init_state = kripke_->get_init_state(); const state* kripke_init = kripke_->get_init_state();
bdd kripke_init_state_condition = kripke_->state_condition( bdd kripke_init_condition = kripke_->state_condition(kripke_init);
kripke_init_state);
spot::state* artificial_initial_state = const spot::state* artificial_initial_state =
ta_->get_artificial_initial_state(); ta_->get_artificial_initial_state();
if (artificial_initial_state) if (artificial_initial_state)
{ {
ta_succ_iterator* ta_init_it_ = ta_->succ_iter( ta_succ_iterator* ta_init_it_ = ta_->succ_iter(
artificial_initial_state, kripke_init_state_condition); artificial_initial_state, kripke_init_condition);
for (ta_init_it_->first(); !ta_init_it_->done(); ta_init_it_->next()) for (ta_init_it_->first(); !ta_init_it_->done(); ta_init_it_->next())
{ {
ta_init_states_set.insert(ta_init_it_->dst()); ta_init_states_set.insert(ta_init_it_->dst());
@ -291,21 +290,13 @@ namespace spot
ta_init_states_set = ta_->get_initial_states_set(); ta_init_states_set = ta_->get_initial_states_set();
} }
for (it = ta_init_states_set.begin(); it != ta_init_states_set.end(); ++it) for (auto s: ta_init_states_set)
{ if (artificial_initial_state ||
(kripke_init_condition == ta_->get_state_condition(s)))
initial_states_set.insert(new state_ta_product(s,
kripke_init->clone()));
if (artificial_initial_state || kripke_init->destroy();
(kripke_init_state_condition == ta_->get_state_condition(*it)))
{
state_ta_product* stp = new state_ta_product((*it),
kripke_init_state->clone());
initial_states_set.insert(stp);
}
}
kripke_init_state->destroy();
return initial_states_set; return initial_states_set;
} }
@ -369,8 +360,8 @@ namespace spot
const state_ta_product* stp = down_cast<const state_ta_product*> (s); const state_ta_product* stp = down_cast<const state_ta_product*> (s);
assert(stp); assert(stp);
state* ta_s = stp->get_ta_state(); const state* ta_s = stp->get_ta_state();
state* kr_s = stp->get_kripke_state(); const state* kr_s = stp->get_kripke_state();
return (ta_->is_initial_state(ta_s)) return (ta_->is_initial_state(ta_s))
&& ((kripke_->get_init_state())->compare(kr_s) == 0) && ((kripke_->get_init_state())->compare(kr_s) == 0)
@ -393,7 +384,7 @@ namespace spot
{ {
const state_ta_product* stp = down_cast<const state_ta_product*> (s); const state_ta_product* stp = down_cast<const state_ta_product*> (s);
assert(stp); assert(stp);
state* ta_s = stp->get_ta_state(); const state* ta_s = stp->get_ta_state();
return ta_->get_state_condition(ta_s); return ta_->get_state_condition(ta_s);
} }

View file

@ -36,7 +36,7 @@ namespace spot
/// \brief Constructor /// \brief Constructor
/// \param ta_state The state from the ta automaton. /// \param ta_state The state from the ta automaton.
/// \param kripke_state The state from Kripke structure. /// \param kripke_state The state from Kripke structure.
state_ta_product(state* ta_state, state* kripke_state) : state_ta_product(const state* ta_state, const state* kripke_state) :
ta_state_(ta_state), kripke_state_(kripke_state) ta_state_(ta_state), kripke_state_(kripke_state)
{ {
} }
@ -47,13 +47,13 @@ namespace spot
virtual virtual
~state_ta_product(); ~state_ta_product();
state* const state*
get_ta_state() const get_ta_state() const
{ {
return ta_state_; return ta_state_;
} }
state* const state*
get_kripke_state() const get_kripke_state() const
{ {
return kripke_state_; return kripke_state_;
@ -67,8 +67,8 @@ namespace spot
clone() const; clone() const;
private: private:
state* ta_state_; ///< State from the ta automaton. const state* ta_state_; ///< State from the ta automaton.
state* kripke_state_; ///< State from the kripke structure. const state* kripke_state_; ///< State from the kripke structure.
}; };
/// \brief Iterate over the successors of a product computed on the fly. /// \brief Iterate over the successors of a product computed on the fly.
@ -117,12 +117,12 @@ namespace spot
const kripke* kripke_; const kripke* kripke_;
ta_succ_iterator* ta_succ_it_; ta_succ_iterator* ta_succ_it_;
twa_succ_iterator* kripke_succ_it_; twa_succ_iterator* kripke_succ_it_;
state_ta_product* current_state_; const state_ta_product* current_state_;
bdd current_condition_; bdd current_condition_;
acc_cond::mark_t current_acceptance_conditions_; acc_cond::mark_t current_acceptance_conditions_;
bool is_stuttering_transition_; bool is_stuttering_transition_;
bdd kripke_source_condition; bdd kripke_source_condition;
state * kripke_current_dest_state; const state* kripke_current_dest_state;
}; };
@ -141,7 +141,7 @@ namespace spot
virtual virtual
~ta_product(); ~ta_product();
virtual const std::set<state*, state_ptr_less_than> virtual ta::const_states_set_t
get_initial_states_set() const; get_initial_states_set() const;
virtual ta_succ_iterator_product* virtual ta_succ_iterator_product*

View file

@ -49,7 +49,7 @@ namespace spot
{ {
} }
state* const state*
tgta_product::get_init_state() const tgta_product::get_init_state() const
{ {
fixed_size_pool* p = const_cast<fixed_size_pool*> (&pool_); fixed_size_pool* p = const_cast<fixed_size_pool*> (&pool_);
@ -79,7 +79,7 @@ namespace spot
: source_(s), tgta_(t), kripke_(k), pool_(pool) : source_(s), tgta_(t), kripke_(k), pool_(pool)
{ {
state * tgta_init_state = tgta_->get_init_state(); const state* tgta_init_state = tgta_->get_init_state();
if ((s->right())->compare(tgta_init_state) == 0) if ((s->right())->compare(tgta_init_state) == 0)
source_ = nullptr; source_ = nullptr;

View file

@ -35,8 +35,7 @@ namespace spot
tgta_product(const const_kripke_ptr& left, tgta_product(const const_kripke_ptr& left,
const const_tgta_ptr& right); const const_tgta_ptr& right);
virtual state* virtual const state* get_init_state() const;
get_init_state() const;
virtual twa_succ_iterator* virtual twa_succ_iterator*
succ_iter(const state* local_state) const; succ_iter(const state* local_state) const;
@ -97,6 +96,6 @@ namespace spot
bdd current_condition_; bdd current_condition_;
acc_cond::mark_t current_acceptance_conditions_; acc_cond::mark_t current_acceptance_conditions_;
bdd kripke_source_condition; bdd kripke_source_condition;
state* kripke_current_dest_state; const state* kripke_current_dest_state;
}; };
} }

View file

@ -146,9 +146,7 @@ namespace spot
artificial_initial_state_ = t_automata_->get_artificial_initial_state(); artificial_initial_state_ = t_automata_->get_artificial_initial_state();
ta::states_set_t init_states_set; ta::const_states_set_t init_states_set;
ta::states_set_t::const_iterator it;
if (artificial_initial_state_) if (artificial_initial_state_)
{ {
@ -159,10 +157,9 @@ namespace spot
{ {
int n = 0; int n = 0;
init_states_set = t_automata_->get_initial_states_set(); init_states_set = t_automata_->get_initial_states_set();
for (it = init_states_set.begin(); for (auto s: init_states_set)
it != init_states_set.end(); ++it)
{ {
bdd init_condition = t_automata_->get_state_condition(*it); bdd init_condition = t_automata_->get_state_condition(s);
std::string label = bdd_format_formula(t_automata_->get_dict(), std::string label = bdd_format_formula(t_automata_->get_dict(),
init_condition); init_condition);
++n; ++n;
@ -223,7 +220,7 @@ namespace spot
private: private:
std::ostream& os_; std::ostream& os_;
spot::state* artificial_initial_state_; const spot::state* artificial_initial_state_;
bool opt_horizontal_ = true; bool opt_horizontal_ = true;
bool opt_circles_ = false; bool opt_circles_ = false;

View file

@ -88,11 +88,11 @@ namespace spot
// Setup depth-first search from initial states. // Setup depth-first search from initial states.
auto& ta_ = a_->get_ta(); auto& ta_ = a_->get_ta();
auto& kripke_ = a_->get_kripke(); auto& kripke_ = a_->get_kripke();
state* kripke_init_state = kripke_->get_init_state(); auto kripke_init_state = kripke_->get_init_state();
bdd kripke_init_state_condition = kripke_->state_condition( bdd kripke_init_state_condition = kripke_->state_condition(
kripke_init_state); kripke_init_state);
spot::state* artificial_initial_state = ta_->get_artificial_initial_state(); auto artificial_initial_state = ta_->get_artificial_initial_state();
ta_succ_iterator* ta_init_it_ = ta_->succ_iter(artificial_initial_state, ta_succ_iterator* ta_init_it_ = ta_->succ_iter(artificial_initial_state,
kripke_init_state_condition); kripke_init_state_condition);
@ -124,8 +124,7 @@ namespace spot
while (!todo.empty()) while (!todo.empty())
{ {
auto curr = todo.top().first;
state* curr = todo.top().first;
// We are looking at the next successor in SUCC. // We are looking at the next successor in SUCC.
ta_succ_iterator_product* succ = todo.top().second; ta_succ_iterator_product* succ = todo.top().second;
@ -249,7 +248,7 @@ namespace spot
// top of ROOT that have an index greater to the one of // top of ROOT that have an index greater to the one of
// the SSCC of S2 (called the "threshold"). // the SSCC of S2 (called the "threshold").
int threshold = std::abs(p.first->second); int threshold = std::abs(p.first->second);
std::list<state*> rem; std::list<const state*> rem;
bool acc = false; bool acc = false;
trace << "***PASS 1: CYCLE***\n"; trace << "***PASS 1: CYCLE***\n";
@ -393,21 +392,17 @@ namespace spot
std::stack<pair_state_iter> todo; std::stack<pair_state_iter> todo;
// * init: the set of the depth-first search initial states // * init: the set of the depth-first search initial states
std::queue<spot::state*> ta_init_it_; std::queue<const spot::state*> ta_init_it_;
const ta::states_set_t init_states_set = a_->get_initial_states_set(); auto init_states_set = a_->get_initial_states_set();
ta::states_set_t::const_iterator it; for (auto init_state: init_states_set)
for (it = init_states_set.begin(); it != init_states_set.end(); ++it) ta_init_it_.push(init_state);
{
state* init_state = (*it);
ta_init_it_.push(init_state);
}
while (!ta_init_it_.empty()) while (!ta_init_it_.empty())
{ {
// Setup depth-first search from initial states. // Setup depth-first search from initial states.
{ {
state* init = ta_init_it_.front(); auto init = ta_init_it_.front();
ta_init_it_.pop(); ta_init_it_.pop();
if (!h.emplace(init, num + 1).second) if (!h.emplace(init, num + 1).second)
@ -426,8 +421,7 @@ namespace spot
while (!todo.empty()) while (!todo.empty())
{ {
auto curr = todo.top().first;
state* curr = todo.top().first;
// We are looking at the next successor in SUCC. // We are looking at the next successor in SUCC.
ta_succ_iterator_product* succ = todo.top().second; ta_succ_iterator_product* succ = todo.top().second;
@ -517,16 +511,12 @@ namespace spot
//self loop state //self loop state
if (!curr->compare(i->first)) if (!curr->compare(i->first))
{ if (t->is_livelock_accepting_state(curr))
state* self_loop_state = curr; {
clear(h, todo, ta_init_it_);
if (t->is_livelock_accepting_state(self_loop_state)) trace << "PASS 2: SUCCESS\n";
{ return true;
clear(h, todo, ta_init_it_); }
trace << "PASS 2: SUCCESS\n";
return true;
}
}
// Now this is the most interesting case. We have reached a // Now this is the most interesting case. We have reached a
// state S1 which is already part of a non-dead SSCC. Any such // state S1 which is already part of a non-dead SSCC. Any such
@ -540,7 +530,7 @@ namespace spot
// top of ROOT that have an index greater to the one of // top of ROOT that have an index greater to the one of
// the SSCC of S2 (called the "threshold"). // the SSCC of S2 (called the "threshold").
int threshold = i->second; int threshold = i->second;
std::list<state*> rem; std::list<const state*> rem;
bool acc = false; bool acc = false;
while (threshold < sscc.top().index) while (threshold < sscc.top().index)
@ -578,7 +568,7 @@ namespace spot
void void
ta_check::clear(hash_type& h, std::stack<pair_state_iter> todo, ta_check::clear(hash_type& h, std::stack<pair_state_iter> todo,
std::queue<spot::state*> init_states) std::queue<const spot::state*> init_states)
{ {
set_states(states() + h.size()); set_states(states() + h.size());

View file

@ -33,7 +33,8 @@ namespace spot
namespace namespace
{ {
typedef std::pair<spot::state*, ta_succ_iterator_product*> pair_state_iter; typedef std::pair<const spot::state*,
ta_succ_iterator_product*> pair_state_iter;
} }
/// \addtogroup ta_emptiness_check Emptiness-checks /// \addtogroup ta_emptiness_check Emptiness-checks
@ -127,7 +128,7 @@ namespace spot
protected: protected:
void void
clear(hash_type& h, std::stack<pair_state_iter> todo, std::queue< clear(hash_type& h, std::stack<pair_state_iter> todo, std::queue<
spot::state*> init_set); const spot::state*> init_set);
void void
clear(hash_type& h, std::stack<pair_state_iter> todo, clear(hash_type& h, std::stack<pair_state_iter> todo,

View file

@ -230,8 +230,7 @@ namespace spot
std::set<const state*>::iterator it; std::set<const state*>::iterator it;
spot::state* artificial_initial_state = auto artificial_initial_state = ta_->get_artificial_initial_state();
ta_->get_artificial_initial_state();
for (it = states_set.begin(); it != states_set.end(); ++it) for (it = states_set.begin(); it != states_set.end(); ++it)
{ {

View file

@ -50,12 +50,10 @@ namespace spot
int n = 0; int n = 0;
start(); start();
spot::state* artificial_initial_state = const spot::state* artificial_initial_state =
t_automata_->get_artificial_initial_state(); t_automata_->get_artificial_initial_state();
ta::states_set_t init_states_set; ta::const_states_set_t init_states_set;
ta::states_set_t::const_iterator it;
if (artificial_initial_state) if (artificial_initial_state)
{ {
@ -66,13 +64,11 @@ namespace spot
init_states_set = t_automata_->get_initial_states_set(); init_states_set = t_automata_->get_initial_states_set();
} }
for (it = init_states_set.begin(); it != init_states_set.end(); ++it) for (auto init_state: init_states_set)
{ {
state* init_state = (*it);
if (want_state(init_state)) if (want_state(init_state))
add_state(init_state); add_state(init_state);
seen[init_state] = ++n; seen[init_state] = ++n;
} }
const state* t; const state* t;

View file

@ -42,7 +42,7 @@ namespace spot
namespace namespace
{ {
typedef std::pair<spot::state*, twa_succ_iterator*> pair_state_iter; typedef std::pair<const spot::state*, twa_succ_iterator*> pair_state_iter;
static void static void
transform_to_single_pass_automaton transform_to_single_pass_automaton
@ -52,7 +52,7 @@ namespace spot
if (artificial_livelock_acc_state) if (artificial_livelock_acc_state)
{ {
state_ta_explicit* artificial_livelock_acc_state_added = auto artificial_livelock_acc_state_added =
testing_automata->add_state(artificial_livelock_acc_state); testing_automata->add_state(artificial_livelock_acc_state);
// unique artificial_livelock_acc_state // unique artificial_livelock_acc_state
@ -71,7 +71,8 @@ namespace spot
for (it = states_set.begin(); it != states_set.end(); ++it) for (it = states_set.begin(); it != states_set.end(); ++it)
{ {
state_ta_explicit* source = static_cast<state_ta_explicit*> (*it); auto source = const_cast<state_ta_explicit*>
(static_cast<const state_ta_explicit*>(*it));
transitions_to_livelock_states->clear(); transitions_to_livelock_states->clear();
@ -81,10 +82,10 @@ namespace spot
if (trans) if (trans)
for (it_trans = trans->begin(); it_trans != trans->end();) for (it_trans = trans->begin(); it_trans != trans->end();)
{ {
state_ta_explicit* dest = (*it_trans)->dest; auto dest = const_cast<state_ta_explicit*>((*it_trans)->dest);
state_ta_explicit::transitions* dest_trans = state_ta_explicit::transitions* dest_trans =
(dest)->get_transitions(); dest->get_transitions();
bool dest_trans_empty = !dest_trans || dest_trans->empty(); bool dest_trans_empty = !dest_trans || dest_trans->empty();
//select transitions where a destination is a livelock state //select transitions where a destination is a livelock state
@ -175,9 +176,9 @@ namespace spot
std::stack<pair_state_iter> todo; std::stack<pair_state_iter> todo;
// * init: the set of the depth-first search initial states // * init: the set of the depth-first search initial states
std::stack<state*> init_set; std::stack<const state*> init_set;
for (state* s: testing_aut->get_initial_states_set()) for (auto s: testing_aut->get_initial_states_set())
init_set.push(s); init_set.push(s);
while (!init_set.empty()) while (!init_set.empty())
@ -185,8 +186,7 @@ namespace spot
// Setup depth-first search from initial states. // Setup depth-first search from initial states.
{ {
state_ta_explicit* init = auto init = down_cast<const state_ta_explicit*> (init_set.top());
down_cast<state_ta_explicit*> (init_set.top());
init_set.pop(); init_set.pop();
if (!h.emplace(init, num + 1).second) if (!h.emplace(init, num + 1).second)
@ -206,7 +206,7 @@ namespace spot
while (!todo.empty()) while (!todo.empty())
{ {
state* curr = todo.top().first; auto curr = todo.top().first;
auto i = h.find(curr); auto i = h.find(curr);
// If we have reached a dead component, ignore it. // If we have reached a dead component, ignore it.
@ -254,8 +254,9 @@ namespace spot
trace << "*** sscc.size() > 1: states: ***" trace << "*** sscc.size() > 1: states: ***"
<< testing_aut->format_state(j) << testing_aut->format_state(j)
<< '\n'; << '\n';
state_ta_explicit* livelock_accepting_state = auto livelock_accepting_state =
down_cast<state_ta_explicit*>(j); const_cast<state_ta_explicit*>
(down_cast<const state_ta_explicit*>(j));
livelock_accepting_state-> livelock_accepting_state->
set_livelock_accepting_state(true); set_livelock_accepting_state(true);
@ -285,7 +286,7 @@ namespace spot
} }
// Fetch the values destination state we are interested in... // Fetch the values destination state we are interested in...
state* dest = succ->dst(); auto dest = succ->dst();
auto acc_cond = succ->acc(); auto acc_cond = succ->acc();
// ... and point the iterator to the next successor, for // ... and point the iterator to the next successor, for
@ -332,8 +333,8 @@ namespace spot
if (!curr->compare(id->first)) if (!curr->compare(id->first))
{ {
state_ta_explicit * self_loop_state = auto self_loop_state = const_cast<state_ta_explicit*>
down_cast<state_ta_explicit*> (curr); (down_cast<const state_ta_explicit*>(curr));
assert(self_loop_state); assert(self_loop_state);
if (testing_aut->is_accepting_state(self_loop_state) if (testing_aut->is_accepting_state(self_loop_state)
@ -365,7 +366,7 @@ namespace spot
// top of ROOT that have an index greater to the one of // top of ROOT that have an index greater to the one of
// the SSCC of S2 (called the "threshold"). // the SSCC of S2 (called the "threshold").
int threshold = id->second; int threshold = id->second;
std::list<state*> rem; std::list<const state*> rem;
bool acc = false; bool acc = false;
while (threshold < sscc.top().index) while (threshold < sscc.top().index)
@ -412,7 +413,7 @@ namespace spot
const_twa_ptr tgba_ = ta->get_tgba(); const_twa_ptr tgba_ = ta->get_tgba();
// build Initial states set: // build Initial states set:
state* tgba_init_state = tgba_->get_init_state(); auto tgba_init_state = tgba_->get_init_state();
bdd tgba_condition = tgba_->support_conditions(tgba_init_state); bdd tgba_condition = tgba_->support_conditions(tgba_init_state);
@ -546,7 +547,7 @@ namespace spot
{ {
ta_explicit_ptr ta; ta_explicit_ptr ta;
state* tgba_init_state = tgba_->get_init_state(); auto tgba_init_state = tgba_->get_init_state();
if (artificial_initial_state_mode) if (artificial_initial_state_mode)
{ {
state_ta_explicit* artificial_init_state = state_ta_explicit* artificial_init_state =
@ -597,7 +598,7 @@ namespace spot
tgta_explicit_ptr tgta_explicit_ptr
tgba_to_tgta(const const_twa_ptr& tgba_, bdd atomic_propositions_set_) tgba_to_tgta(const const_twa_ptr& tgba_, bdd atomic_propositions_set_)
{ {
state* tgba_init_state = tgba_->get_init_state(); auto tgba_init_state = tgba_->get_init_state();
auto artificial_init_state = new state_ta_explicit(tgba_init_state->clone(), auto artificial_init_state = new state_ta_explicit(tgba_init_state->clone(),
bddfalse, true); bddfalse, true);
tgba_init_state->destroy(); tgba_init_state->destroy();

View file

@ -385,7 +385,7 @@ namespace spot
/// ///
/// The returned state should be destroyed (see state::destroy) /// The returned state should be destroyed (see state::destroy)
/// by the caller after it is no longer used. /// by the caller after it is no longer used.
virtual state* dst() const = 0; virtual const state* dst() const = 0;
/// \brief Get the condition on the transition leading to this successor. /// \brief Get the condition on the transition leading to this successor.
/// ///
/// This is a boolean function of atomic propositions. /// This is a boolean function of atomic propositions.
@ -531,7 +531,7 @@ namespace spot
/// The state has been allocated with \c new. It is the /// The state has been allocated with \c new. It is the
/// responsability of the caller to \c destroy it when no /// responsability of the caller to \c destroy it when no
/// longer needed. /// longer needed.
virtual state* get_init_state() const = 0; virtual const state* get_init_state() const = 0;
/// \brief Get an iterator over the successors of \a local_state. /// \brief Get an iterator over the successors of \a local_state.
/// ///

View file

@ -143,11 +143,10 @@ namespace spot
return !p_; return !p_;
} }
virtual twa_graph_state* dst() const virtual const twa_graph_state* dst() const
{ {
assert(!done()); assert(!done());
return const_cast<twa_graph_state*> return &g_->state_data(g_->edge_storage(p_).dst);
(&g_->state_data(g_->edge_storage(p_).dst));
} }
virtual bdd cond() const virtual bdd cond() const
@ -266,12 +265,11 @@ namespace spot
return init_number_; return init_number_;
} }
// FIXME: The return type ought to be const. virtual const twa_graph_state* get_init_state() const
virtual twa_graph_state* get_init_state() const
{ {
if (num_states() == 0) if (num_states() == 0)
const_cast<graph_t&>(g_).new_state(); const_cast<graph_t&>(g_).new_state();
return const_cast<twa_graph_state*>(state_from_number(init_number_)); return state_from_number(init_number_);
} }
virtual twa_succ_iterator* virtual twa_succ_iterator*

View file

@ -130,7 +130,7 @@ namespace spot
return !right_ || right_->done(); return !right_ || right_->done();
} }
state_product* dst() const const state_product* dst() const
{ {
return new(pool_->allocate()) state_product(left_->dst(), return new(pool_->allocate()) state_product(left_->dst(),
right_->dst(), right_->dst(),
@ -330,7 +330,7 @@ namespace spot
} }
} }
state* const state*
twa_product::get_init_state() const twa_product::get_init_state() const
{ {
fixed_size_pool* p = const_cast<fixed_size_pool*>(&pool_); fixed_size_pool* p = const_cast<fixed_size_pool*>(&pool_);
@ -434,7 +434,7 @@ namespace spot
std::swap(left_init_, right_init_); std::swap(left_init_, right_init_);
} }
state* const state*
twa_product_init::get_init_state() const twa_product_init::get_init_state() const
{ {
fixed_size_pool* p = const_cast<fixed_size_pool*>(&pool_); fixed_size_pool* p = const_cast<fixed_size_pool*>(&pool_);

View file

@ -42,20 +42,22 @@ namespace spot
/// \param pool The pool from which the state was allocated. /// \param pool The pool from which the state was allocated.
/// These states are acquired by spot::state_product, and will /// These states are acquired by spot::state_product, and will
/// be destroyed on destruction. /// be destroyed on destruction.
state_product(state* left, state* right, fixed_size_pool* pool) state_product(const state* left,
const state* right,
fixed_size_pool* pool)
: left_(left), right_(right), count_(1), pool_(pool) : left_(left), right_(right), count_(1), pool_(pool)
{ {
} }
virtual void destroy() const; virtual void destroy() const;
state* const state*
left() const left() const
{ {
return left_; return left_;
} }
state* const state*
right() const right() const
{ {
return right_; return right_;
@ -66,8 +68,8 @@ namespace spot
virtual state_product* clone() const; virtual state_product* clone() const;
private: private:
state* left_; ///< State from the left automaton. const state* left_; ///< State from the left automaton.
state* right_; ///< State from the right automaton. const state* right_; ///< State from the right automaton.
mutable unsigned count_; mutable unsigned count_;
fixed_size_pool* pool_; fixed_size_pool* pool_;
@ -88,7 +90,7 @@ namespace spot
virtual ~twa_product(); virtual ~twa_product();
virtual state* get_init_state() const; virtual const state* get_init_state() const;
virtual twa_succ_iterator* virtual twa_succ_iterator*
succ_iter(const state* state) const; succ_iter(const state* state) const;
@ -124,7 +126,7 @@ namespace spot
public: public:
twa_product_init(const const_twa_ptr& left, const const_twa_ptr& right, twa_product_init(const const_twa_ptr& left, const const_twa_ptr& right,
const state* left_init, const state* right_init); const state* left_init, const state* right_init);
virtual state* get_init_state() const; virtual const state* get_init_state() const;
protected: protected:
const state* left_init_; const state* left_init_;
const state* right_init_; const state* right_init_;

View file

@ -178,7 +178,7 @@ namespace spot
pair_queue todo; pair_queue todo;
state_pair p(left->get_init_state(), nullptr); state_pair p(left->get_init_state(), nullptr);
state* ris = right->get_init_state(); const state* ris = right->get_init_state();
p.second = ris; p.second = ris;
unsigned i = res->new_state(); unsigned i = res->new_state();
seen[p] = i; seen[p] = i;

View file

@ -108,7 +108,7 @@ namespace spot
{ {
inc_transitions(); inc_transitions();
state* s = i->dst(); const state* s = i->dst();
auto j = ecs_->h.find(s); auto j = ecs_->h.find(s);
assert(j != ecs_->h.end()); assert(j != ecs_->h.end());
s->destroy(); s->destroy();
@ -158,7 +158,7 @@ namespace spot
// Setup depth-first search from the initial state. // Setup depth-first search from the initial state.
{ {
state* init = ecs_->aut->get_init_state(); const state* init = ecs_->aut->get_init_state();
ecs_->h[init] = 1; ecs_->h[init] = 1;
ecs_->root.push(1); ecs_->root.push(1);
arc.push(0U); arc.push(0U);

View file

@ -1235,7 +1235,7 @@ namespace spot
for (auto i: aut->succ(st)) for (auto i: aut->succ(st))
{ {
bdd label = i->cond(); bdd label = i->cond();
state* s = i->dst(); const state* s = i->dst();
formula dest = formula dest =
namer->get_name(aut->state_number(s)); namer->get_name(aut->state_number(s));
@ -1280,7 +1280,7 @@ namespace spot
for (auto i: aut->succ(st)) for (auto i: aut->succ(st))
{ {
bdd label = i->cond(); bdd label = i->cond();
state* s = i->dst(); const state* s = i->dst();
formula dest = namer->get_name(aut->state_number(s)); formula dest = namer->get_name(aut->state_number(s));
missing -= label; missing -= label;

View file

@ -50,7 +50,7 @@ namespace spot
{ {
int n = 0; int n = 0;
start(); start();
state* i = aut_->get_init_state(); const state* i = aut_->get_init_state();
if (want_state(i)) if (want_state(i))
add_state(i); add_state(i);
seen[i] = ++n; seen[i] = ++n;
@ -188,7 +188,7 @@ namespace spot
{ {
int n = 1; int n = 1;
start(); start();
state* i = aut_->get_init_state(); const state* i = aut_->get_init_state();
if (want_state(i)) if (want_state(i))
push(i, n); push(i, n);
seen[i] = n++; seen[i] = n++;

View file

@ -43,7 +43,7 @@ namespace spot
class state_tgbasl: public state class state_tgbasl: public state
{ {
public: public:
state_tgbasl(state* s, bdd cond) : s_(s), cond_(cond) state_tgbasl(const state* s, bdd cond) : s_(s), cond_(cond)
{ {
} }
@ -77,7 +77,7 @@ namespace spot
return new state_tgbasl(*this); return new state_tgbasl(*this);
} }
state* const state*
real_state() const real_state() const
{ {
return s_; return s_;
@ -90,7 +90,7 @@ namespace spot
} }
private: private:
state* s_; const state* s_;
bdd cond_; bdd cond_;
}; };
@ -220,7 +220,7 @@ namespace spot
get_dict()->unregister_all_my_variables(this); get_dict()->unregister_all_my_variables(this);
} }
virtual state* get_init_state() const override virtual const state* get_init_state() const override
{ {
return new state_tgbasl(a_->get_init_state(), bddfalse); return new state_tgbasl(a_->get_init_state(), bddfalse);
} }