22#include <spot/kripke/kripke.hh>
23#include <spot/graph/graph.hh>
54 auto o = down_cast<const kripke_graph_state*>(other);
64 virtual size_t hash()
const override
66 return reinterpret_cast<size_t>(
this);
97 typedef typename Graph::edge edge;
98 typedef typename Graph::state_data_t state;
104 const typename Graph::state_storage_t* s):
115 void recycle(
const typename Graph::state_storage_t* s)
129 p_ = g_->edge_storage(p_).next_succ;
133 virtual bool done()
const override
140 SPOT_ASSERT(!done());
142 (&g_->state_data(g_->edge_storage(p_).dst));
168 typedef std::vector<state_storage_t> state_vector;
171 typedef unsigned state_num;
172 static_assert(std::is_same<typename graph_t::state, state_num>::value,
177 mutable unsigned init_number_;
180 :
kripke(d), init_number_(0)
186 get_dict()->unregister_all_my_variables(
this);
189 unsigned num_states()
const
194 unsigned num_edges()
const
199 void set_init_state(state_num s)
201 if (SPOT_UNLIKELY(s >= num_states()))
202 throw std::invalid_argument
203 (
"set_init_state() called with nonexisiting state");
207 state_num get_init_state_number()
const
210 if (num_states() == 0)
211 throw std::runtime_error(
"kripke has no state at all");
217 return state_from_number(get_init_state_number());
225 auto s = down_cast<const typename graph_t::state_storage_t*>(st);
228 if (this->iter_cache_)
231 down_cast<kripke_graph_succ_iterator<graph_t>*>(this->iter_cache_);
233 this->iter_cache_ =
nullptr;
241 state_number(
const state* st)
const
243 auto s = down_cast<const typename graph_t::state_storage_t*>(st);
247 const kripke_graph_state*
248 state_from_number(state_num n)
const
254 state_from_number(state_num n)
259 std::string format_state(
unsigned n)
const
261 auto named = get_named_prop<std::vector<std::string>>(
"state-names");
262 if (named && n < named->size())
265 return std::to_string(n);
270 return format_state(state_number(st));
276 auto gs = down_cast<const kripke_graph_state*>(s);
280 edge_storage_t& edge_storage(
unsigned t)
285 const edge_storage_t edge_storage(
unsigned t)
const
290 unsigned new_state(bdd cond)
295 unsigned new_states(
unsigned n, bdd cond)
300 unsigned new_edge(
unsigned src,
unsigned dst)
307 const state_vector& states()
const
313 state_vector& states()
319 internal::all_trans<const graph_t>
320 edges() const noexcept
326 internal::all_trans<graph_t>
333 internal::state_out<const graph_t>
334 out(
unsigned src)
const
340 internal::state_out<graph_t>
348 typedef std::shared_ptr<kripke_graph> kripke_graph_ptr;
350 inline kripke_graph_ptr
351 make_kripke_graph(
const bdd_dict_ptr& d)
353 return std::make_shared<kripke_graph>(d);
unsigned num_states() const
The number of states in the automaton.
Definition: graph.hh:657
state new_states(unsigned n, Args &&... args)
Create n new states.
Definition: graph.hh:696
state new_state(Args &&... args)
Create a new states.
Definition: graph.hh:682
bool is_valid_edge(edge t) const
Test whether the given edge is valid.
Definition: graph.hh:996
internal::state_out< digraph > out(state src)
Return a fake container with all edges leaving src.
Definition: graph.hh:901
state_storage_t::data_t & state_data(state s)
return the State_Data associated to a state
Definition: graph.hh:729
edge_storage_t & edge_storage(edge s)
return a reference to the storage of an edge
Definition: graph.hh:747
const state_vector & states() const
Return the vector of states.
Definition: graph.hh:945
internal::all_trans< const digraph > edges() const
Return a fake container with all edges (excluding erased edges)
Definition: graph.hh:960
unsigned num_edges() const
The number of edges in the automaton.
Definition: graph.hh:665
state_storage_t & state_storage(state s)
return a reference to the storage of a state
Definition: graph.hh:711
edge new_edge(state src, state dst, Args &&... args)
Create a new edge.
Definition: graph.hh:784
Definition: kripkegraph.hh:95
virtual bool first() override
Position the iterator on the first successor (if any).
Definition: kripkegraph.hh:121
virtual bool done() const override
Check whether the iteration is finished.
Definition: kripkegraph.hh:133
virtual bool next() override
Jump to the next successor (if any).
Definition: kripkegraph.hh:127
virtual kripke_graph_state * dst() const override
Get the destination state of the current edge.
Definition: kripkegraph.hh:138
Kripke Structure.
Definition: kripkegraph.hh:150
virtual std::string format_state(const state *st) const override
Format the state as a string for printing.
Definition: kripkegraph.hh:268
virtual kripke_graph_succ_iterator< graph_t > * succ_iter(const spot::state *st) const override
Allow to get an iterator on the state we passed in parameter.
Definition: kripkegraph.hh:223
virtual bdd state_condition(const state *s) const override
Get the condition on the state.
Definition: kripkegraph.hh:274
virtual const kripke_graph_state * get_init_state() const override
Get the initial state of the automaton.
Definition: kripkegraph.hh:215
Iterator code for Kripke structure.
Definition: kripke.hh:130
virtual bdd cond() const override
Get the condition on the edge leading to this successor.
Interface for a Kripke structure.
Definition: kripke.hh:177
Abstract class for states.
Definition: twa.hh:47
Definition: automata.hh:26
Concrete class for kripke_graph states.
Definition: kripkegraph.hh:30
virtual size_t hash() const override
Hash a state.
Definition: kripkegraph.hh:64
virtual kripke_graph_state * clone() const override
Duplicate a state.
Definition: kripkegraph.hh:70
virtual void destroy() const override
Release a state.
Definition: kripkegraph.hh:75
virtual int compare(const spot::state *other) const override
Compares two states (that come from the same automaton).
Definition: kripkegraph.hh:52