spot  2.7.3
alternation.hh
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2016, 2018 Laboratoire de Recherche et Développement
3 // de 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  univ_remover_state(const univ_remover_state& other)
118  : states_(other.states_), is_reset_(other.is_reset_)
119  {
120  }
121  int compare(const state* other) const override;
122  size_t hash() const override;
123  state* clone() const override;
124  const std::set<unsigned>& states() const;
125  bool is_reset() const;
126  };
127 
128  class SPOT_API twa_univ_remover: public twa
129  {
130 
131  private:
132  const_twa_graph_ptr aut_;
133  std::vector<int> state_to_var_;
134  std::map<int, unsigned> var_to_state_;
135  bdd all_states_;
136 
137  public:
138  twa_univ_remover(const const_twa_graph_ptr& aut);
139  void allocate_state_vars();
140  const state* get_init_state() const override;
141  twa_succ_iterator* succ_iter(const state* s) const override;
142  std::string format_state(const state* s) const override;
143  };
144 
145  typedef std::shared_ptr<twa_univ_remover> twa_univ_remover_ptr;
146 
163  SPOT_API
164  twa_univ_remover_ptr remove_univ_otf(const const_twa_graph_ptr& aut);
165 }
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