23 #include <spot/kripke/kripke.hh>
24 #include <spot/graph/graph.hh>
55 virtual size_t hash()
const
58 reinterpret_cast<const char*
>(
this) - static_cast<const char*>(
nullptr);
89 typedef typename Graph::edge edge;
90 typedef typename Graph::state_data_t state;
96 const typename Graph::state_storage_t* s):
107 virtual void recycle(
const typename Graph::state_storage_t* s)
121 p_ = g_->edge_storage(p_).next_succ;
134 (&g_->state_data(g_->edge_storage(p_).dst));
148 mutable unsigned init_number_;
151 :
kripke(d), init_number_(0)
157 get_dict()->unregister_all_my_variables(
this);
160 unsigned num_states()
const
162 return g_.num_states();
165 unsigned num_edges()
const
167 return g_.num_edges();
170 void set_init_state(graph_t::state s)
172 assert(s < num_states());
176 graph_t::state get_init_state_number()
const
178 if (num_states() == 0)
179 const_cast<graph_t&
>(g_).new_state();
185 if (num_states() == 0)
186 const_cast<graph_t&
>(g_).new_state();
187 return state_from_number(init_number_);
197 assert(!s->succ || g_.valid_trans(s->succ));
199 if (this->iter_cache_)
204 this->iter_cache_ =
nullptr;
212 state_number(
const state* st)
const
214 auto s = down_cast<
const typename graph_t::state_storage_t*>(st);
216 return s - &g_.state_storage(0);
219 const kripke_graph_state*
220 state_from_number(graph_t::state n)
const
222 return &g_.state_data(n);
226 state_from_number(graph_t::state n)
228 return &g_.state_data(n);
231 std::string format_state(
unsigned n)
const
233 std::stringstream ss;
238 virtual std::string format_state(
const state* st)
const
240 return format_state(state_number(st));
249 edge_storage_t& edge_storage(
unsigned t)
251 return g_.edge_storage(t);
254 const edge_storage_t edge_storage(
unsigned t)
const
256 return g_.edge_storage(t);
259 unsigned new_state(bdd cond)
261 return g_.new_state(cond);
264 unsigned new_states(
unsigned n, bdd cond)
266 return g_.new_states(n, cond);
269 unsigned new_edge(
unsigned src,
unsigned dst)
271 return g_.new_edge(src, dst);
275 typedef std::shared_ptr<kripke_graph> kripke_graph_ptr;
277 inline kripke_graph_ptr
278 make_kripke_graph(
const bdd_dict_ptr& d)
280 return std::make_shared<kripke_graph>(d);
virtual void destroy() const
Release a state.
Definition: kripkegraph.hh:67
Kripke Structure.
Definition: kripkegraph.hh:141
virtual bool first()
Position the iterator on the first successor (if any).
Definition: kripkegraph.hh:113
Interface for a Kripke structure.
Definition: kripke.hh:91
virtual int compare(const spot::state *other) const
Compares two states (that come from the same automaton).
Definition: kripkegraph.hh:42
Abstract class for states.
Definition: twa.hh:43
Iterator code for Kripke structure.
Definition: kripke.hh:43
virtual kripke_graph_succ_iterator< graph_t > * succ_iter(const spot::state *st) const
Allow to get an iterator on the state we passed in parameter.
Definition: kripkegraph.hh:193
Concrete class for kripke_graph states.
Definition: kripkegraph.hh:30
virtual kripke_graph_state * clone() const
Duplicate a state.
Definition: kripkegraph.hh:62
virtual kripke_graph_state * dst() const
Get the state of the current successor.
Definition: kripkegraph.hh:130
virtual bdd state_condition(const state *s) const
Get the condition on the state.
Definition: kripkegraph.hh:244
virtual bdd cond() const
Get the condition on the transition leading to this successor.
virtual bool done() const
Check whether the iteration is finished.
Definition: kripkegraph.hh:125
virtual const kripke_graph_state * get_init_state() const
Get the initial state of the automaton.
Definition: kripkegraph.hh:183
virtual size_t hash() const
Hash a state.
Definition: kripkegraph.hh:55
Definition: kripkegraph.hh:86
virtual bool next()
Jump to the next successor (if any).
Definition: kripkegraph.hh:119