spot  2.16
split.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 <vector>
23 
24 namespace spot
25 {
41 
42 #ifndef SWIG
46  template<bool subsumed>
47  struct SPOT_API edge_separator_filter
48  {
50  edge_separator_filter(const std::vector<bdd>& labels, bdd cond)
51  : labels_(labels), cond_(cond)
52  {
53  }
54 
57  class iterator
58  {
59  std::vector<bdd>::const_iterator pos_;
60  std::vector<bdd> const& labels_;
61  bdd cond_;
62 
63  public:
65  iterator(const std::vector<bdd>& labels, bdd cond)
66  : labels_(labels), cond_(cond)
67  {
68  pos_ = labels_.begin();
69  next();
70  }
71 
74  {
75  ++pos_;
76  next();
77  return *this;
78  }
79 
81  void next()
82  {
83  // If subsumed is true, we want to match the labels
84  // that imply the current condition. Otherwise we
85  // want to match the labels that are compatible.
86  while (pos_ != labels_.end() &&
87  ((subsumed && !bdd_implies(*pos_, cond_))
88  || (!subsumed && (*pos_ & cond_) == bddfalse)))
89  ++pos_;
90  }
91 
93  bdd operator*() const
94  {
95  if (subsumed)
96  return *pos_;
97  else
98  return *pos_ & cond_;
99  }
100 
102  bool operator==(const iterator& other) const
103  {
104  return pos_ == other.pos_;
105  }
106 
108  bool operator!=(const iterator& other) const
109  {
110  return pos_ != other.pos_;
111  }
112 
114  bool operator==(std::vector<bdd>::const_iterator pos) const
115  {
116  return pos_ == pos;
117  }
118 
120  bool operator!=(std::vector<bdd>::const_iterator pos) const
121  {
122  return pos_ != pos;
123  }
124  };
125 
127  iterator begin() const
128  {
129  return iterator(labels_, cond_);
130  }
131 
133  std::vector<bdd>::const_iterator end() const
134  {
135  return labels_.end();
136  }
137 
138  private:
139  const std::vector<bdd>& labels_;
140  bdd cond_;
141  };
142 #endif
143 
144 
159  class SPOT_API edge_separator
160  {
161  public:
178  void add_to_basis(bdd label);
181  unsigned long max_label);
197 #ifndef SWIG
207  {
208  return {basis_, label};
209  }
220  {
221  return {basis_, label};
222  }
223 #endif
224 
226  unsigned basis_size() const
227  {
228  return basis_.size();
229  }
230 
232  const std::vector<bdd>& basis() const
233  {
234  return basis_;
235  }
236 
237  private:
238  std::vector<bdd> basis_{bddtrue};
239  std::set<formula> aps_;
240  };
241 
255 }
Iterator over edge labels compatible with the filter's BDD condition.
Definition: split.hh:58
iterator(const std::vector< bdd > &labels, bdd cond)
Construct an iterator over matching labels.
Definition: split.hh:65
bool operator!=(std::vector< bdd >::const_iterator pos) const
Check inequality with a vector iterator.
Definition: split.hh:120
bool operator!=(const iterator &other) const
Check inequality with another iterator.
Definition: split.hh:108
bdd operator*() const
Dereference to get the current label.
Definition: split.hh:93
iterator & operator++()
Advance to the next matching label.
Definition: split.hh:73
bool operator==(const iterator &other) const
Check equality with another iterator.
Definition: split.hh:102
void next()
Advance to the next matching label (implementation).
Definition: split.hh:81
bool operator==(std::vector< bdd >::const_iterator pos) const
Check equality with a vector iterator.
Definition: split.hh:114
separate edges so that their labels are disjoint
Definition: split.hh:160
const std::vector< bdd > & basis() const
Return the basis vector.
Definition: split.hh:232
edge_separator_filter< true > separate_implying(bdd label)
Separate a label.
Definition: split.hh:206
bool add_to_basis(const const_twa_graph_ptr &aut, unsigned long max_label)
add label(s) to a basis
twa_graph_ptr separate_implying(const const_twa_graph_ptr &aut)
Separate an automaton.
edge_separator_filter< false > separate_compat(bdd label)
Separate a label.
Definition: split.hh:219
void add_to_basis(bdd label)
add label(s) to a basis
void add_to_basis(const const_twa_graph_ptr &aut)
add label(s) to a basis
unsigned basis_size() const
Return the number of basis elements.
Definition: split.hh:226
twa_graph_ptr separate_compat(const const_twa_graph_ptr &aut)
Separate an automaton.
twa_graph_ptr split_edges(const const_twa_graph_ptr &aut)
Transform edges into transitions.
twa_graph_ptr separate_edges(const const_twa_graph_ptr &aut)
Make edge labels disjoint.
std::shared_ptr< twa_graph > twa_graph_ptr
Shared pointer to a mutable twa_graph.
Definition: fwd.hh:44
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
A filter for iterating over edge labels compatible with a given BDD condition.
Definition: split.hh:48
edge_separator_filter(const std::vector< bdd > &labels, bdd cond)
Construct a filter from the given label basis and condition.
Definition: split.hh:50
std::vector< bdd >::const_iterator end() const
Return an iterator past the last label.
Definition: split.hh:133
iterator begin() const
Return an iterator to the first matching label.
Definition: split.hh:127

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