spot  2.16
lasso.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 <spot/twa/twagraph.hh>
22 #include <spot/twaalgos/emptiness.hh>
23 #include <spot/twaalgos/sccinfo.hh>
24 #include <spot/twaalgos/word.hh>
25 #include <climits>
26 #include <vector>
27 
28 namespace spot
29 {
42  class SPOT_API lasso_enumerator final
43  {
44  public:
55  unsigned min_stem, unsigned max_stem,
56  unsigned min_cycle, unsigned max_cycle);
57 
58  ~lasso_enumerator() = default;
59  lasso_enumerator(const lasso_enumerator&) = delete;
60  lasso_enumerator& operator=(const lasso_enumerator&) = delete;
61 
64 
67 
68  private:
70  scc_info si_;
71  unsigned min_stem_, max_stem_;
72  unsigned min_cycle_, max_cycle_;
73  unsigned init_state_;
74  bool done_;
75 
76  // Current (stem_len, cycle_len) pair being enumerated.
77  unsigned cur_stem_;
78  unsigned cur_cycle_;
79  unsigned cur_total_;
80 
81  // DFS stacks: each element is an edge number in the automaton graph.
82  std::vector<unsigned> stem_;
83  std::vector<unsigned> cycle_;
84 
85  unsigned stem_end_;
86  bool stem_ready_;
87  bool cycle_ready_;
88  bool cycle_exhausted_;
89 
90  // Graph access helpers.
91  unsigned first_edge_(unsigned state) const;
92  unsigned next_edge_(unsigned edge) const;
93  unsigned edge_dst_(unsigned edge) const;
94  bdd edge_cond_(unsigned edge) const;
95  acc_cond::mark_t edge_acc_(unsigned edge) const;
96 
97  // DFS helpers.
98  bool backtrack_(std::vector<unsigned>& path) const;
99  bool extend_(std::vector<unsigned>& path,
100  unsigned from_state, unsigned target_len);
101  bool is_valid_cycle_() const;
102 
103  // Advancement functions.
104  bool advance_pair_();
105  bool advance_stem_();
106  bool advance_cycle_();
107 
108  // Build a twa_run from the current stem_ and cycle_.
109  twa_run_ptr build_run_() const;
110  };
111 }
Lazily enumerate lasso-shaped accepted runs/words of bounded size.
Definition: lasso.hh:43
twa_word_ptr next_word()
Return the next accepted word, or nullptr when exhausted.
lasso_enumerator(const const_twa_graph_ptr &aut, unsigned min_stem, unsigned max_stem, unsigned min_cycle, unsigned max_cycle)
Construct a lasso enumerator.
twa_run_ptr next_run()
Return the next accepted run, or nullptr when exhausted.
Compute an SCC map and gather assorted information.
Definition: sccinfo.hh:465
Abstract class for states.
Definition: twa.hh:49
std::shared_ptr< twa_run > twa_run_ptr
Shared pointer to a twa_run.
Definition: twa.hh:38
std::shared_ptr< twa_word > twa_word_ptr
Shared pointer to a mutable twa_word.
Definition: fwd.hh:60
std::shared_ptr< const twa_graph > const_twa_graph_ptr
Shared pointer to a const twa_graph.
Definition: fwd.hh:38
Definition: automata.hh:26
An acceptance mark.
Definition: acc.hh:76

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