spot  2.16
gtec.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 <stack>
22 #include <spot/twaalgos/gtec/status.hh>
23 #include <spot/twaalgos/emptiness.hh>
24 #include <spot/twaalgos/emptiness_stats.hh>
25 
26 namespace spot
27 {
30 
42 
117  SPOT_API emptiness_check_ptr
119 
120 #ifndef SWIG
124  class SPOT_API couvreur99_check:
125  // We inherit from ec_statistics first to work around GCC bug #90309.
126  // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90309#c6
127  public ec_statistics, public emptiness_check
128  {
129  public:
132 
133  virtual ~couvreur99_check();
134 
136  virtual emptiness_check_result_ptr check() override;
137 
138  virtual std::ostream& print_stats(std::ostream& os) const override;
139 
148  std::shared_ptr<const couvreur99_check_status> result() const;
149 
150  protected:
152  std::shared_ptr<couvreur99_check_status> ecs_;
158  void remove_component(const state* start_delete);
159 
161  bool poprem_;
164 
166  unsigned get_removed_components() const;
168  unsigned get_vmsize() const;
169  };
170 
175  class SPOT_API couvreur99_check_shy final: public couvreur99_check
176  {
177  public:
180  virtual ~couvreur99_check_shy();
181 
182  virtual emptiness_check_result_ptr check() override;
183 
184  protected:
187  struct successor {
189  const spot::state* s;
191  successor(acc_cond::mark_t acc, const spot::state* s) noexcept
192  : acc(acc), s(s) {}
193  };
194 
195  // We use five main data in this algorithm:
196  // * couvreur99_check::root, a stack of strongly connected components (SCC),
197  // * couvreur99_check::h, a hash of all visited nodes, with their order,
198  // (it is called "Hash" in Couvreur's paper)
199  // * arc, a stack of acceptance conditions between each of these SCC,
200  std::stack<acc_cond::mark_t> arc;
201  // * num, the number of visited nodes. Used to set the order of each
202  // visited node,
203  int num;
204  // * todo, the depth-first search stack. This holds pairs of the
205  // form (STATE, SUCCESSORS) where SUCCESSORS is a list of
206  // (ACCEPTANCE_CONDITIONS, STATE) pairs.
208  typedef std::list<successor> succ_queue;
209 
210  // Position in the loop seeking known successors.
211  succ_queue::iterator pos;
212 
215  struct todo_item
216  {
217  const state* s;
218  int n;
221  todo_item(const state* s, int n, couvreur99_check_shy* shy);
222  };
223 
225  typedef std::list<todo_item> todo_list;
227 
229  void clear_todo();
230 
232  bool group_;
233  // If the "group2" option is set (it implies "group"), we
234  // reprocess the successor states of SCC that have been merged.
236  bool group2_;
237  };
238 #endif
239 
241 }
A version of spot::couvreur99_check that tries to visit known states first.
Definition: gtec.hh:176
bool group_
Whether successors should be grouped for states in the same SCC.
Definition: gtec.hh:232
std::list< successor > succ_queue
Queue type for unprocessed successors of a state.
Definition: gtec.hh:208
std::list< todo_item > todo_list
List type for the DFS stack.
Definition: gtec.hh:225
succ_queue::iterator pos
Iterator into current successor queue.
Definition: gtec.hh:211
void clear_todo()
Clear the DFS stack.
todo_list todo
The DFS stack.
Definition: gtec.hh:226
couvreur99_check_shy(const const_twa_ptr &a, option_map o=option_map())
Construct the shy variant for the given automaton and options.
virtual emptiness_check_result_ptr check() override
Check whether the automaton's language is empty.
std::stack< acc_cond::mark_t > arc
Stack of inter-SCC acceptance marks.
Definition: gtec.hh:200
int num
Counter of visited nodes (DFS order).
Definition: gtec.hh:203
bool group2_
If set, reprocess successors of merged SCCs (implies group_).
Definition: gtec.hh:236
An implementation of the Couvreur99 emptiness-check algorithm.
Definition: gtec.hh:128
std::shared_ptr< couvreur99_check_status > ecs_
Shared status object holding the DFS data structures.
Definition: gtec.hh:152
bool poprem_
Whether to store the state to be removed.
Definition: gtec.hh:161
couvreur99_check(const const_twa_ptr &a, option_map o=option_map())
Construct an emptiness check for the given automaton and options.
void remove_component(const state *start_delete)
Remove a strongly component from the hash.
unsigned get_vmsize() const
Return the virtual memory size used by the process (in kB).
std::shared_ptr< const couvreur99_check_status > result() const
Return the status of the emptiness-check.
virtual std::ostream & print_stats(std::ostream &os) const override
Print statistics, if any.
virtual emptiness_check_result_ptr check() override
Check whether the automaton's language is empty.
unsigned get_removed_components() const
Return the number of dead SCCs removed by the algorithm.
unsigned removed_components
Number of dead SCC removed by the algorithm.
Definition: gtec.hh:163
Emptiness-check statistics.
Definition: emptiness_stats.hh:62
Common interface to emptiness check algorithms.
Definition: emptiness.hh:144
Manage a map of options.
Definition: optionmap.hh:34
Abstract class for states.
Definition: twa.hh:49
emptiness_check_ptr couvreur99(const const_twa_ptr &a, option_map options=option_map())
Check whether the language of an automaton is empty.
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
std::shared_ptr< const twa > const_twa_ptr
Shared pointer to a const twa.
Definition: fwd.hh:36
Definition: automata.hh:26
An acceptance mark.
Definition: acc.hh:76
A successor state with its associated acceptance marks, used in the shy Couvreur check.
Definition: gtec.hh:187
const spot::state * s
Definition: gtec.hh:189
successor(acc_cond::mark_t acc, const spot::state *s) noexcept
Construct a successor from acceptance marks and a state.
Definition: gtec.hh:191
acc_cond::mark_t acc
Acceptance marks on the edge to this successor.
Definition: gtec.hh:188
DFS stack item holding a state and its queue of unprocessed successors.
Definition: gtec.hh:216
succ_queue q
Definition: gtec.hh:219
todo_item(const state *s, int n, couvreur99_check_shy *shy)
Construct a DFS stack item for the given state.
int n
The DFS order number of this state.
Definition: gtec.hh:218
const state * s
The state at this DFS stack entry.
Definition: gtec.hh:217

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