23 #include <spot/kripke/kripke.hh>
24 #include <spot/graph/graph.hh>
55 auto o = down_cast<const kripke_graph_state*>(other);
65 virtual size_t hash()
const override
67 return reinterpret_cast<size_t>(
this);
98 typedef typename Graph::edge edge;
99 typedef typename Graph::state_data_t state;
105 const typename Graph::state_storage_t* s):
116 void recycle(
const typename Graph::state_storage_t* s)
130 p_ = g_->edge_storage(p_).next_succ;
134 virtual bool done()
const override
141 SPOT_ASSERT(!done());
143 (&g_->state_data(g_->edge_storage(p_).dst));
169 typedef std::vector<state_storage_t> state_vector;
172 typedef unsigned state_num;
173 static_assert(std::is_same<typename graph_t::state, state_num>::value,
178 mutable unsigned init_number_;
181 :
kripke(d), init_number_(0)
187 get_dict()->unregister_all_my_variables(
this);
190 unsigned num_states()
const
195 unsigned num_edges()
const
200 void set_init_state(state_num s)
202 if (SPOT_UNLIKELY(s >= num_states()))
203 throw std::invalid_argument
204 (
"set_init_state() called with nonexisiting state");
208 state_num get_init_state_number()
const
211 if (num_states() == 0)
212 throw std::runtime_error(
"kripke has no state at all");
218 return state_from_number(get_init_state_number());
226 auto s = down_cast<const typename graph_t::state_storage_t*>(st);
229 if (this->iter_cache_)
232 down_cast<kripke_graph_succ_iterator<graph_t>*>(this->iter_cache_);
234 this->iter_cache_ =
nullptr;
242 state_number(
const state* st)
const
244 auto s = down_cast<const typename graph_t::state_storage_t*>(st);
248 const kripke_graph_state*
249 state_from_number(state_num n)
const
255 state_from_number(state_num n)
260 std::string format_state(
unsigned n)
const
262 auto named = get_named_prop<std::vector<std::string>>(
"state-names");
263 if (named && n < named->size())
266 return std::to_string(n);
271 return format_state(state_number(st));
277 auto gs = down_cast<const kripke_graph_state*>(s);
281 edge_storage_t& edge_storage(
unsigned t)
286 const edge_storage_t edge_storage(
unsigned t)
const
291 unsigned new_state(bdd cond)
296 unsigned new_states(
unsigned n, bdd cond)
301 unsigned new_edge(
unsigned src,
unsigned dst)
308 const state_vector& states()
const
314 state_vector& states()
320 internal::all_trans<const graph_t>
321 edges() const noexcept
327 internal::all_trans<graph_t>
334 internal::state_out<const graph_t>
335 out(
unsigned src)
const
341 internal::state_out<graph_t>
349 typedef std::shared_ptr<kripke_graph> kripke_graph_ptr;
351 inline kripke_graph_ptr
352 make_kripke_graph(
const bdd_dict_ptr& d)
354 return std::make_shared<kripke_graph>(d);
unsigned num_states() const
The number of states in the automaton.
Definition: graph.hh:658
const state_vector & states() const
Return the vector of states.
Definition: graph.hh:946
state new_states(unsigned n, Args &&... args)
Create n new states.
Definition: graph.hh:697
state new_state(Args &&... args)
Create a new states.
Definition: graph.hh:683
bool is_valid_edge(edge t) const
Test whether the given edge is valid.
Definition: graph.hh:997
edge_storage_t & edge_storage(edge s)
return a reference to the storage of an edge
Definition: graph.hh:748
internal::state_out< digraph > out(state src)
Return a fake container with all edges leaving src.
Definition: graph.hh:902
state_storage_t & state_storage(state s)
return a reference to the storage of a state
Definition: graph.hh:712
unsigned num_edges() const
The number of edges in the automaton.
Definition: graph.hh:666
state_storage_t::data_t & state_data(state s)
return the State_Data associated to a state
Definition: graph.hh:730
edge new_edge(state src, state dst, Args &&... args)
Create a new edge.
Definition: graph.hh:785
internal::all_trans< const digraph > edges() const
Return a fake container with all edges (exluding erased edges)
Definition: graph.hh:961
Definition: kripkegraph.hh:96
virtual bool first() override
Position the iterator on the first successor (if any).
Definition: kripkegraph.hh:122
virtual bool done() const override
Check whether the iteration is finished.
Definition: kripkegraph.hh:134
virtual bool next() override
Jump to the next successor (if any).
Definition: kripkegraph.hh:128
virtual kripke_graph_state * dst() const override
Get the destination state of the current edge.
Definition: kripkegraph.hh:139
Kripke Structure.
Definition: kripkegraph.hh:151
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:224
virtual std::string format_state(const state *st) const override
Format the state as a string for printing.
Definition: kripkegraph.hh:269
virtual const kripke_graph_state * get_init_state() const override
Get the initial state of the automaton.
Definition: kripkegraph.hh:216
virtual bdd state_condition(const state *s) const override
Get the condition on the state.
Definition: kripkegraph.hh:275
Iterator code for Kripke structure.
Definition: kripke.hh:131
virtual bdd cond() const override
Get the condition on the edge leading to this successor.
Interface for a Kripke structure.
Definition: kripke.hh:178
Abstract class for states.
Definition: twa.hh:51
Definition: automata.hh:27
Concrete class for kripke_graph states.
Definition: kripkegraph.hh:31
virtual size_t hash() const override
Hash a state.
Definition: kripkegraph.hh:65
virtual kripke_graph_state * clone() const override
Duplicate a state.
Definition: kripkegraph.hh:71
virtual void destroy() const override
Release a state.
Definition: kripkegraph.hh:76
virtual int compare(const spot::state *other) const override
Compares two states (that come from the same automaton).
Definition: kripkegraph.hh:53