spot  1.99.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
sccinfo.hh
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2014, 2015 Laboratoire de Recherche et Développement
3 // de l'Epita.
4 //
5 // This file is part of Spot, a model checking library.
6 //
7 // Spot is free software; you can redistribute it and/or modify it
8 // under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // Spot is distributed in the hope that it will be useful, but WITHOUT
13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 // License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 
20 #pragma once
21 
22 #include <vector>
23 #include "twa/twagraph.hh"
24 
25 namespace spot
26 {
27  class SPOT_API scc_info
28  {
29  public:
30  struct scc_trans
31  {
32  scc_trans(bdd cond, unsigned dst)
33  : cond(cond), dst(dst)
34  {
35  }
36  bdd cond;
37  unsigned dst;
38  };
39 
40  typedef std::vector<scc_trans> scc_succs;
41 
42  class scc_node
43  {
44  friend class scc_info;
45  protected:
46  scc_succs succ_;
47  acc_cond::mark_t acc_;
48  std::list<unsigned> states_; // States of the component
49  bool trivial_:1;
50  bool accepting_:1; // Necessarily accepting
51  bool rejecting_:1; // Necessarily rejecting
52  bool useful_:1;
53  public:
54  scc_node():
55  acc_(0U), trivial_(true), accepting_(false),
56  rejecting_(false), useful_(false)
57  {
58  }
59 
60  scc_node(acc_cond::mark_t acc, bool trivial):
61  acc_(acc), trivial_(trivial), accepting_(false),
62  rejecting_(false), useful_(false)
63  {
64  }
65 
66  bool is_trivial() const
67  {
68  return trivial_;
69  }
70 
75  bool is_accepting() const
76  {
77  return accepting_;
78  }
79 
80  // True if we are sure that the SCC is rejecting
84  bool is_rejecting() const
85  {
86  return rejecting_;
87  }
88 
89  bool is_useful() const
90  {
91  return useful_;
92  }
93 
94  acc_cond::mark_t acc_marks() const
95  {
96  return acc_;
97  }
98 
99  const std::list<unsigned>& states() const
100  {
101  return states_;
102  }
103 
104  const scc_succs& succ() const
105  {
106  return succ_;
107  }
108  };
109 
110  protected:
111 
112  std::vector<unsigned> sccof_;
113  std::vector<scc_node> node_;
114  const_twa_graph_ptr aut_;
115 
116  // Update the useful_ bits. Called automatically.
117  void determine_usefulness();
118 
119  const scc_node& node(unsigned scc) const
120  {
121  assert(scc < node_.size());
122  return node_[scc];
123  }
124 
125  public:
126  scc_info(const_twa_graph_ptr aut);
127 
128  const_twa_graph_ptr get_aut() const
129  {
130  return aut_;
131  }
132 
133  unsigned scc_count() const
134  {
135  return node_.size();
136  }
137 
138  bool reachable_state(unsigned st) const
139  {
140  return scc_of(st) != -1U;
141  }
142 
143  unsigned scc_of(unsigned st) const
144  {
145  assert(st < sccof_.size());
146  return sccof_[st];
147  }
148 
149  auto begin() const
150  SPOT_RETURN(node_.begin());
151  auto end() const
152  SPOT_RETURN(node_.end());
153  auto cbegin() const
154  SPOT_RETURN(node_.cbegin());
155  auto cend() const
156  SPOT_RETURN(node_.cend());
157  auto rbegin() const
158  SPOT_RETURN(node_.rbegin());
159  auto rend() const
160  SPOT_RETURN(node_.rend());
161 
162  const std::list<unsigned>& states_of(unsigned scc) const
163  {
164  return node(scc).states();
165  }
166 
167  unsigned one_state_of(unsigned scc) const
168  {
169  return states_of(scc).front();
170  }
171 
173  unsigned initial() const
174  {
175  assert(scc_count() - 1 == scc_of(aut_->get_init_state_number()));
176  return scc_count() - 1;
177  }
178 
179  const scc_succs& succ(unsigned scc) const
180  {
181  return node(scc).succ();
182  }
183 
184  bool is_trivial(unsigned scc) const
185  {
186  return node(scc).is_trivial();
187  }
188 
189  acc_cond::mark_t acc(unsigned scc) const
190  {
191  return node(scc).acc_marks();
192  }
193 
194  bool is_accepting_scc(unsigned scc) const
195  {
196  return node(scc).is_accepting();
197  }
198 
199  bool is_rejecting_scc(unsigned scc) const
200  {
201  return node(scc).is_rejecting();
202  }
203 
204  // Study the SCC that are currently reported neither as accepting
205  // nor rejecting because of the presence of Fin sets
206  void determine_unknown_acceptance();
207 
208  bool is_useful_scc(unsigned scc) const
209  {
210  return node(scc).is_useful();
211  }
212 
213  bool is_useful_state(unsigned st) const
214  {
215  return reachable_state(st) && node(scc_of(st)).is_useful();
216  }
217 
220  std::vector<std::set<acc_cond::mark_t>> used_acc() const;
221 
222  std::set<acc_cond::mark_t> used_acc_of(unsigned scc) const;
223 
224 
225  std::vector<bool> weak_sccs() const;
226 
227  bdd scc_ap_support(unsigned scc) const;
228  };
229 
230 
234  SPOT_API std::ostream&
235  dump_scc_info_dot(std::ostream& out,
236  const_twa_graph_ptr aut, scc_info* sccinfo = nullptr);
237 
238 }
Definition: sccinfo.hh:42
bool is_rejecting() const
Definition: sccinfo.hh:84
Definition: public.hh:31
Definition: sccinfo.hh:27
Definition: formula.hh:515
Definition: sccinfo.hh:30
unsigned initial() const
Get number of the SCC containing the initial state.
Definition: sccinfo.hh:173
bool is_accepting() const
True if we are sure that the SCC is accepting.
Definition: sccinfo.hh:75
Definition: acc.hh:34

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Tue Jun 23 2015 06:55:46 for spot by doxygen 1.8.8