spot  2.16
emptiness.hh
1 // -*- coding: utf-8 -*-
2 // Copyright (C) by the Spot authors, see the AUTHORS file for details.
3 //
4 // This file is part of Spot, a model checking library.
5 //
6 // Spot is free software; you can redistribute it and/or modify it
7 // under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // Spot is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 // License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 #pragma once
20 
21 #include <map>
22 #include <list>
23 #include <iosfwd>
24 #include <bddx.h>
25 #include <spot/misc/optionmap.hh>
26 #include <spot/twa/twagraph.hh>
27 #include <spot/twaalgos/emptiness_stats.hh>
28 
29 namespace spot
30 {
31  struct twa_run;
32  typedef std::shared_ptr<twa_run> twa_run_ptr;
34  typedef std::shared_ptr<const twa_run> const_twa_run_ptr;
35 
75 
81  class SPOT_API emptiness_check_result
82  {
83  public:
86  option_map o = option_map())
87  : a_(a), o_(o)
88  {
89  }
90 
91  virtual
93  {
94  }
95 
109 
111  const const_twa_ptr&
112  automaton() const
113  {
114  return a_;
115  }
116 
118  const option_map&
119  options() const
120  {
121  return o_;
122  }
123 
125  const char* parse_options(char* options);
126 
128  virtual const unsigned_statistics* statistics() const;
129 
130  protected:
132  virtual void options_updated(const option_map& old);
133 
136  };
137 
139  typedef std::shared_ptr<emptiness_check_result> emptiness_check_result_ptr;
140 
142  class SPOT_API emptiness_check:
143  public std::enable_shared_from_this<emptiness_check>
144  {
145  public:
148  : a_(a), o_(o)
149  {
150  }
151  virtual ~emptiness_check();
152 
154  const const_twa_ptr&
155  automaton() const
156  {
157  return a_;
158  }
159 
161  const option_map&
162  options() const
163  {
164  return o_;
165  }
166 
168  const char* parse_options(char* options);
169 
171  virtual bool safe() const;
172 
188 
190  virtual const unsigned_statistics* statistics() const;
191 
194 
196  virtual std::ostream& print_stats(std::ostream& os) const;
197 
199  virtual void options_updated(const option_map& old);
200 
201  protected:
204  };
205 
207  typedef std::shared_ptr<emptiness_check> emptiness_check_ptr;
208 
211  typedef std::shared_ptr<emptiness_check_instantiator>
213 
216  {
217  public:
220 
223  const option_map&
224  options() const
225  {
226  return o_;
227  }
228 
229  option_map&
231  {
232  return o_;
233  }
235 
238  unsigned int min_sets() const;
239 
244  unsigned int max_sets() const;
245  protected:
248 
250  void *info_;
251  };
252 
367  make_emptiness_check_instantiator(const char* name, const char** err);
368 
370 
371 
374 
378 
380  struct SPOT_API twa_run final
381  {
384  struct step {
385  const state* s;
386  bdd label;
388 
390  step(const state* s, bdd label, acc_cond::mark_t acc) noexcept
391  : s(s), label(label), acc(acc)
392  {
393  }
394  step() = default;
395  };
396 
397  typedef std::list<step> steps;
398 
402 
403  ~twa_run();
405  twa_run(const const_twa_ptr& aut) noexcept
406  : aut(aut)
407  {
408  }
409  twa_run(const twa_run& run);
410  twa_run& operator=(const twa_run& run);
411 
419  void ensure_non_empty_cycle(const char* where) const;
420 
435 
444  twa_run_ptr project(const const_twa_ptr& other, bool right = false);
445 
456  bool replay(std::ostream& os, bool debug = false) const;
457 
461  void highlight(unsigned color);
462 
469  twa_graph_ptr as_twa(bool preserve_names = false) const;
470 
485  SPOT_API
486  friend std::ostream& operator<<(std::ostream& os, const twa_run& run);
487  };
489 
492 }
Emptiness-check statistics.
Definition: emptiness_stats.hh:62
Dynamically create emptiness checks. Given their name and options.
Definition: emptiness.hh:216
const option_map & options() const
Definition: emptiness.hh:224
emptiness_check_instantiator(option_map o, void *i)
Construct an instantiator from options and implementation info.
emptiness_check_ptr instantiate(const const_twa_ptr &a) const
Actually instantiate the emptiness check, for a.
void * info_
Opaque pointer to implementation-specific data.
Definition: emptiness.hh:250
option_map & options()
Definition: emptiness.hh:230
option_map o_
The options.
Definition: emptiness.hh:249
unsigned int min_sets() const
Minimum number of acceptance sets supported by the emptiness check.
unsigned int max_sets() const
Maximum number of acceptance conditions supported by the emptiness check.
The result of an emptiness check.
Definition: emptiness.hh:82
virtual void options_updated(const option_map &old)
Notify option updates.
option_map o_
The options.
Definition: emptiness.hh:135
const option_map & options() const
Return the options parameterizing how the accepting run is computed.
Definition: emptiness.hh:119
virtual twa_run_ptr accepting_run()
Return a run accepted by the automaton passed to the emptiness check.
const char * parse_options(char *options)
Modify the algorithm options.
virtual const unsigned_statistics * statistics() const
Return statistics, if available.
const const_twa_ptr & automaton() const
The automaton on which an accepting_run() was found.
Definition: emptiness.hh:112
const_twa_ptr a_
The automaton.
Definition: emptiness.hh:134
emptiness_check_result(const const_twa_ptr &a, option_map o=option_map())
Construct a result for the given automaton and options.
Definition: emptiness.hh:85
Common interface to emptiness check algorithms.
Definition: emptiness.hh:144
const_twa_ptr a_
The automaton.
Definition: emptiness.hh:202
option_map o_
The options.
Definition: emptiness.hh:203
virtual std::ostream & print_stats(std::ostream &os) const
Print statistics, if any.
emptiness_check(const const_twa_ptr &a, option_map o=option_map())
Construct an emptiness check for the given automaton and options.
Definition: emptiness.hh:147
virtual const ec_statistics * emptiness_check_statistics() const
Return emptiness check statistics, if available.
virtual bool safe() const
Return false iff accepting_run() can return 0 for non-empty automata.
virtual void options_updated(const option_map &old)
Notify option updates.
const option_map & options() const
Return the options parameterizing how the emptiness check is realized.
Definition: emptiness.hh:162
const char * parse_options(char *options)
Modify the algorithm options.
virtual const unsigned_statistics * statistics() const
Return statistics, if available.
const const_twa_ptr & automaton() const
The automaton that this emptiness-check inspects.
Definition: emptiness.hh:155
virtual emptiness_check_result_ptr check()=0
Check whether the automaton contains an accepting run.
Manage a map of options.
Definition: optionmap.hh:34
Abstract class for states.
Definition: twa.hh:49
std::shared_ptr< emptiness_check > emptiness_check_ptr
Shared pointer to emptiness_check.
Definition: emptiness.hh:207
std::shared_ptr< emptiness_check_result > emptiness_check_result_ptr
Shared pointer to emptiness_check_result.
Definition: emptiness.hh:139
emptiness_check_instantiator_ptr make_emptiness_check_instantiator(const char *name, const char **err)
Create an emptiness-check instantiator, given the name of an emptiness check.
std::shared_ptr< emptiness_check_instantiator > emptiness_check_instantiator_ptr
Shared pointer to emptiness_check_instantiator.
Definition: emptiness.hh:209
std::shared_ptr< twa_run > twa_run_ptr
Shared pointer to a twa_run.
Definition: twa.hh:38
std::shared_ptr< const twa > const_twa_ptr
Shared pointer to a const twa.
Definition: fwd.hh:36
std::shared_ptr< twa_graph > twa_graph_ptr
Shared pointer to a mutable twa_graph.
Definition: fwd.hh:44
Definition: automata.hh:26
std::shared_ptr< const twa_run > const_twa_run_ptr
Shared pointer to const twa_run.
Definition: emptiness.hh:34
An acceptance mark.
Definition: acc.hh:76
A single step in a TωA run, pairing a state with an edge label and acceptance marks.
Definition: emptiness.hh:384
const state * s
Source state.
Definition: emptiness.hh:385
acc_cond::mark_t acc
Acceptance marks on the transition.
Definition: emptiness.hh:387
bdd label
Transition label.
Definition: emptiness.hh:386
step(const state *s, bdd label, acc_cond::mark_t acc) noexcept
Construct a step from a state, label, and acceptance marks.
Definition: emptiness.hh:390
An accepted run, for a twa.
Definition: emptiness.hh:381
void highlight(unsigned color)
Highlight the accepting run on the automaton.
twa_run_ptr project(const const_twa_ptr &other, bool right=false)
Project an accepting run.
steps prefix
The prefix part of the run.
Definition: emptiness.hh:399
void ensure_non_empty_cycle(const char *where) const
Raise an exception if the cycle is empty.
steps cycle
The cycle part of the run.
Definition: emptiness.hh:400
twa_graph_ptr as_twa(bool preserve_names=false) const
Convert the run into a lasso-shaped automaton.
twa_run(const twa_run &run)
Copy constructor.
const_twa_ptr aut
The automaton this run is associated with.
Definition: emptiness.hh:401
twa_run_ptr reduce() const
Reduce an accepting run.
twa_run & operator=(const twa_run &run)
Copy-assignment operator.
std::list< step > steps
Ordered sequence of run steps.
Definition: emptiness.hh:397
friend std::ostream & operator<<(std::ostream &os, const twa_run &run)
Display a twa_run.
bool replay(std::ostream &os, bool debug=false) const
Replay a run.
twa_run(const const_twa_ptr &aut) noexcept
Construct an empty run for the given automaton.
Definition: emptiness.hh:405
Interface for retrieving unsigned integer statistics from an emptiness check.
Definition: emptiness_stats.hh:34

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Fri Feb 27 2015 10:00:07 for spot by doxygen 1.9.1