spot  2.6
alternation.hh
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2016 Laboratoire de Recherche et Développement de
3 // l'Epita (LRDE).
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 <spot/twa/twagraph.hh>
23 #include <utility>
24 
25 namespace spot
26 {
45  class SPOT_API outedge_combiner
46  {
47  private:
48  const twa_graph_ptr& aut_;
49  std::map<unsigned, int> state_to_var;
50  std::map<int, unsigned> var_to_state;
51  bdd vars_;
52  public:
53  outedge_combiner(const twa_graph_ptr& aut);
54  ~outedge_combiner();
55  bdd operator()(unsigned st);
56  void new_dests(unsigned st, bdd out) const;
57  };
58 
69  template<class I>
70  SPOT_API
71  unsigned states_and(const twa_graph_ptr& aut, I begin, I end)
72  {
73  if (begin == end)
74  throw std::runtime_error
75  ("state_and() expects an non-empty list of states");
76  outedge_combiner combiner(aut);
77  bdd combination = bddtrue;
78  while (begin != end)
79  combination &= combiner(*begin++);
80  unsigned new_s = aut->new_state();
81  combiner.new_dests(new_s, combination);
82  return new_s;
83  }
84 
85  template<class T>
86  SPOT_API
87  unsigned states_and(const twa_graph_ptr& aut,
88  const std::initializer_list<T>& il)
89  {
90  return states_and(aut, il.begin(), il.end());
91  }
93 
102  SPOT_API
103  twa_graph_ptr remove_alternation(const const_twa_graph_ptr& aut,
104  bool named_states = false);
105 
106 
107  // Remove universal edges on the fly.
108 
109  class SPOT_API univ_remover_state: public state
110  {
111  protected:
112  std::set<unsigned> states_;
113  bool is_reset_;
114 
115  public:
116  univ_remover_state(const std::set<unsigned>& states);
117  int compare(const state* other) const override;
118  size_t hash() const override;
119  state* clone() const override;
120  const std::set<unsigned>& states() const;
121  bool is_reset() const;
122  };
123 
124  class SPOT_API twa_univ_remover: public twa
125  {
126 
127  private:
128  const_twa_graph_ptr aut_;
129  std::vector<int> state_to_var_;
130  std::map<int, unsigned> var_to_state_;
131  bdd all_states_;
132 
133  public:
134  twa_univ_remover(const const_twa_graph_ptr& aut);
135  void allocate_state_vars();
136  const state* get_init_state() const override;
137  twa_succ_iterator* succ_iter(const state* s) const override;
138  std::string format_state(const state* s) const override;
139  };
140 
141  typedef std::shared_ptr<twa_univ_remover> twa_univ_remover_ptr;
142 
159  SPOT_API
160  twa_univ_remover_ptr remove_univ_otf(const const_twa_graph_ptr& aut);
161 }
Definition: automata.hh:26

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.8.13