22 #include <spot/kripke/kripke.hh>
23 #include <spot/graph/graph.hh>
58 auto o = down_cast<const kripke_graph_state*>(other);
68 virtual size_t hash()
const override
70 return reinterpret_cast<size_t>(
this);
101 template<
class Graph>
105 typedef typename Graph::edge edge;
106 typedef typename Graph::state_data_t state;
113 const typename Graph::state_storage_t* s):
125 void recycle(
const typename Graph::state_storage_t* s)
139 p_ = g_->edge_storage(p_).next_succ;
143 virtual bool done()
const override
150 SPOT_ASSERT(!done());
152 (&g_->state_data(g_->edge_storage(p_).dst));
169 typedef internal::edge_storage<unsigned, unsigned, unsigned,
170 internal::boxed_label
177 typedef internal::distate_storage<unsigned,
178 internal::boxed_label<kripke_graph_state, false>>
186 static_assert(std::is_same<typename graph_t::state, state_num>::value,
195 :
kripke(d), init_number_(0)
201 get_dict()->unregister_all_my_variables(
this);
219 if (SPOT_UNLIKELY(s >= num_states()))
220 throw std::invalid_argument
221 (
"set_init_state() called with nonexistent state");
229 if (num_states() == 0)
230 throw std::runtime_error(
"kripke has no state at all");
236 return state_from_number(get_init_state_number());
243 auto s = down_cast<const typename graph_t::state_storage_t*>(st);
246 if (this->iter_cache_)
249 down_cast<kripke_graph_succ_iterator<graph_t>*>(this->iter_cache_);
251 this->iter_cache_ =
nullptr;
262 auto s = down_cast<const typename graph_t::state_storage_t*>(st);
283 auto named = get_named_prop<std::vector<std::string>>(
"state-names");
284 if (named && n < named->size())
287 return std::to_string(n);
292 return format_state(state_number(st));
298 auto gs = down_cast<const kripke_graph_state*>(s);
349 internal::all_trans<const graph_t>
357 internal::all_trans<graph_t>
365 internal::state_out<const graph_t>
373 internal::state_out<graph_t>
388 return std::make_shared<kripke_graph>(d);
unsigned num_states() const
The number of states in the automaton.
Definition: graph.hh:670
internal::distate_storage< edge, internal::boxed_label< kripke_graph_state > > state_storage_t
State storage type.
Definition: graph.hh:628
const state_vector & states() const
Return the vector of states.
Definition: graph.hh:960
state new_states(unsigned n, Args &&... args)
Create n new states.
Definition: graph.hh:709
state new_state(Args &&... args)
Create a new state.
Definition: graph.hh:695
bool is_valid_edge(edge t) const
Test whether the given edge is valid.
Definition: graph.hh:1011
edge_storage_t & edge_storage(edge s)
Return a reference to the storage of an edge.
Definition: graph.hh:760
internal::state_out< digraph > out(state src)
Return a fake container with all edges leaving src.
Definition: graph.hh:916
state_storage_t & state_storage(state s)
Return a reference to the storage of a state.
Definition: graph.hh:724
unsigned num_edges() const
The number of edges in the automaton.
Definition: graph.hh:678
state_storage_t::data_t & state_data(state s)
Return the State_Data associated to a state.
Definition: graph.hh:742
internal::edge_storage< state, state, edge, internal::boxed_label< void > > edge_storage_t
Edge storage type.
Definition: graph.hh:632
edge new_edge(state src, state dst, Args &&... args)
Create a new edge.
Definition: graph.hh:797
internal::all_trans< const digraph > edges() const
Return a fake container with all edges (excluding erased edges)
Definition: graph.hh:975
Successor iterator for a graph-based Kripke structure state.
Definition: kripkegraph.hh:103
void recycle(const typename Graph::state_storage_t *s)
Reset the iterator for a new state.
Definition: kripkegraph.hh:125
virtual bool first() override
Position the iterator on the first successor (if any).
Definition: kripkegraph.hh:131
virtual bool done() const override
Check whether the iteration is finished.
Definition: kripkegraph.hh:143
kripke_graph_succ_iterator(const Graph *g, const typename Graph::state_storage_t *s)
Construct iterator over successors of state s in graph g.
Definition: kripkegraph.hh:112
virtual bool next() override
Jump to the next successor (if any).
Definition: kripkegraph.hh:137
virtual kripke_graph_state * dst() const override
Get the destination state of the current edge.
Definition: kripkegraph.hh:148
Kripke Structure.
Definition: kripkegraph.hh:161
unsigned num_states() const
Return the number of states.
Definition: kripkegraph.hh:205
state_vector & states()
Return all states.
Definition: kripkegraph.hh:342
state_num get_init_state_number() const
Return the initial state number.
Definition: kripkegraph.hh:226
internal::edge_storage< unsigned, unsigned, unsigned, internal::boxed_label< void, true > > edge_storage_t
Edge storage type.
Definition: kripkegraph.hh:172
std::string format_state(unsigned n) const
Return string representation of state n.
Definition: kripkegraph.hh:281
unsigned init_number_
Initial state number.
Definition: kripkegraph.hh:191
virtual kripke_graph_succ_iterator< graph_t > * succ_iter(const spot::state *st) const override
Return an iterator on the state passed as a parameter.
Definition: kripkegraph.hh:241
unsigned new_states(unsigned n, bdd cond)
Create n new states with the given condition.
Definition: kripkegraph.hh:321
internal::distate_storage< unsigned, internal::boxed_label< kripke_graph_state, false > > state_storage_t
State storage type.
Definition: kripkegraph.hh:174
digraph< kripke_graph_state, void > graph_t
The underlying graph type.
Definition: kripkegraph.hh:164
unsigned state_num
State number type.
Definition: kripkegraph.hh:185
unsigned new_edge(unsigned src, unsigned dst)
Add a new edge from src to dst.
Definition: kripkegraph.hh:327
internal::state_out< const graph_t > out(unsigned src) const
Return successor range for src.
Definition: kripkegraph.hh:366
state_num state_number(const state *st) const
Return the number of state st.
Definition: kripkegraph.hh:260
internal::state_out< graph_t > out(unsigned src)
Return successor range for src.
Definition: kripkegraph.hh:374
internal::all_trans< graph_t > edges() noexcept
Return all edges.
Definition: kripkegraph.hh:358
const kripke_graph_state * state_from_number(state_num n) const
Return the state with the given number.
Definition: kripkegraph.hh:268
edge_storage_t & edge_storage(unsigned t)
Return edge storage at index t.
Definition: kripkegraph.hh:303
graph_t g_
The underlying graph.
Definition: kripkegraph.hh:187
internal::all_trans< const graph_t > edges() const noexcept
Return all edges.
Definition: kripkegraph.hh:350
kripke_graph(const bdd_dict_ptr &d)
Construct with BDD dictionary d.
Definition: kripkegraph.hh:194
virtual std::string format_state(const state *st) const override
Format the state as a string for printing.
Definition: kripkegraph.hh:290
const edge_storage_t edge_storage(unsigned t) const
Return edge storage at index t.
Definition: kripkegraph.hh:309
unsigned new_state(bdd cond)
Create a new state with the given condition.
Definition: kripkegraph.hh:315
virtual const kripke_graph_state * get_init_state() const override
Get the initial state of the automaton.
Definition: kripkegraph.hh:234
void set_init_state(state_num s)
Set the initial state.
Definition: kripkegraph.hh:217
std::vector< state_storage_t > state_vector
Vector of states.
Definition: kripkegraph.hh:181
unsigned num_edges() const
Return the number of edges.
Definition: kripkegraph.hh:211
kripke_graph_state * state_from_number(state_num n)
Return the state with the given number.
Definition: kripkegraph.hh:275
const state_vector & states() const
Return all states.
Definition: kripkegraph.hh:335
virtual bdd state_condition(const state *s) const override
Get the condition on the state.
Definition: kripkegraph.hh:296
Iterator code for Kripke structure.
Definition: kripke.hh:130
Interface for a Kripke structure.
Definition: kripke.hh:178
Abstract class for states.
Definition: twa.hh:49
std::shared_ptr< bdd_dict > bdd_dict_ptr
Shared pointer to a bdd_dict.
Definition: bdddict.hh:304
Definition: automata.hh:26
std::shared_ptr< kripke_graph > kripke_graph_ptr
Shared pointer to a kripke_graph.
Definition: kripkegraph.hh:382
kripke_graph_ptr make_kripke_graph(const bdd_dict_ptr &d)
Create a new kripke_graph.
Definition: kripkegraph.hh:386
Concrete class for kripke_graph states.
Definition: kripkegraph.hh:31
bdd cond() const
Return the BDD condition of this state.
Definition: kripkegraph.hh:84
virtual size_t hash() const override
Hash a state.
Definition: kripkegraph.hh:68
kripke_graph_state & operator=(const kripke_graph_state &other) noexcept
Copy assignment operator.
Definition: kripkegraph.hh:46
virtual kripke_graph_state * clone() const override
Duplicate a state.
Definition: kripkegraph.hh:74
kripke_graph_state(const kripke_graph_state &other) noexcept
Copy constructor.
Definition: kripkegraph.hh:40
virtual void destroy() const override
Release a state.
Definition: kripkegraph.hh:79
virtual int compare(const spot::state *other) const override
Compares two states (that come from the same automaton).
Definition: kripkegraph.hh:56
kripke_graph_state(bdd cond=bddfalse) noexcept
Construct with BDD condition cond.
Definition: kripkegraph.hh:34
void cond(bdd c)
Set the BDD condition to c.
Definition: kripkegraph.hh:90