spot  2.16
alternation.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/powerset.hh>
23 #include <utility>
24 
25 namespace spot
26 {
46  class SPOT_API outedge_combiner
47  {
48  private:
49  const twa_graph_ptr& aut_;
50  std::map<unsigned, int> state_to_var;
51  std::map<int, unsigned> var_to_state;
52  bdd vars_;
53  public:
58  bdd operator()(unsigned st);
60  void new_dests(unsigned st, bdd out) const;
61  };
62 
73  template<class I>
74  SPOT_API
75  unsigned states_and(const twa_graph_ptr& aut, I begin, I end)
76  {
77  if (begin == end)
78  throw std::runtime_error
79  ("state_and() expects a non-empty list of states");
80  outedge_combiner combiner(aut);
81  bdd combination = bddtrue;
82  while (begin != end)
83  combination &= combiner(*begin++);
84  unsigned new_s = aut->new_state();
85  combiner.new_dests(new_s, combination);
86  return new_s;
87  }
88 
89  template<class T>
90  SPOT_API
91  unsigned states_and(const twa_graph_ptr& aut,
92  const std::initializer_list<T>& il)
93  {
94  return states_and(aut, il.begin(), il.end());
95  }
97 
115  SPOT_API
117  bool named_states = false,
118  const output_aborter* aborter = nullptr,
119  bool raise_if_too_many_sets = true);
120 
121 
125  class SPOT_API univ_remover_state: public state
126  {
127  protected:
128  std::set<unsigned> states_;
129  bool is_reset_;
130 
131  public:
133  univ_remover_state(const std::set<unsigned>& states);
136  : states_(other.states_), is_reset_(other.is_reset_)
137  {
138  }
139  int compare(const state* other) const override;
140  size_t hash() const override;
141  state* clone() const override;
143  const std::set<unsigned>& states() const;
145  bool is_reset() const;
146  };
147 
151  class SPOT_API twa_univ_remover: public twa
152  {
153 
154  private:
155  const_twa_graph_ptr aut_;
156  std::vector<int> state_to_var_;
157  std::map<int, unsigned> var_to_state_;
158  bdd all_states_;
159 
160  public:
165  const state* get_init_state() const override;
166  twa_succ_iterator* succ_iter(const state* s) const override;
167  std::string format_state(const state* s) const override;
168  };
169 
172  typedef std::shared_ptr<twa_univ_remover> twa_univ_remover_ptr;
173 
181  SPOT_API
183 }
Helper class to combine outgoing edges in alternating automata.
Definition: alternation.hh:47
bdd operator()(unsigned st)
Combine outgoing edges of state st.
void new_dests(unsigned st, bdd out) const
Compute new destinations for state st under condition out.
outedge_combiner(const twa_graph_ptr &aut)
Construct from an alternating automaton.
Helper object to specify when an algorithm should abort its construction.
Definition: powerset.hh:50
Abstract class for states.
Definition: twa.hh:49
Iterate over the successors of a state.
Definition: twa.hh:425
On-the-fly TωA that removes universal edges from an alternating automaton.
Definition: alternation.hh:152
twa_univ_remover(const const_twa_graph_ptr &aut)
Construct from an alternating automaton.
twa_succ_iterator * succ_iter(const state *s) const override
Get an iterator over the successors of local_state.
std::string format_state(const state *s) const override
Format the state as a string for printing.
const state * get_init_state() const override
Get the initial state of the automaton.
void allocate_state_vars()
Allocate BDD variables for the states.
A Transition-based ω-Automaton.
Definition: twa.hh:648
State used during on-the-fly removal of universal edges from an alternating automaton.
Definition: alternation.hh:126
size_t hash() const override
Hash a state.
const std::set< unsigned > & states() const
Return the set of original states.
int compare(const state *other) const override
Compares two states (that come from the same automaton).
std::set< unsigned > states_
The set of original states represented.
Definition: alternation.hh:128
bool is_reset() const
Check if this is a reset state.
bool is_reset_
Whether this state represents a reset.
Definition: alternation.hh:129
univ_remover_state(const std::set< unsigned > &states)
Construct a state from a set of original states.
univ_remover_state(const univ_remover_state &other)
Copy constructor.
Definition: alternation.hh:135
state * clone() const override
Duplicate a state.
std::shared_ptr< twa_univ_remover > twa_univ_remover_ptr
Shared pointer to a twa_univ_remover.
Definition: alternation.hh:172
twa_univ_remover_ptr remove_univ_otf(const const_twa_graph_ptr &aut)
Remove universal edges on the fly from an alternating Büchi automaton.
twa_graph_ptr remove_alternation(const const_twa_graph_ptr &aut, bool named_states=false, const output_aborter *aborter=nullptr, bool raise_if_too_many_sets=true)
Remove universal edges from a weak alternating automaton.
unsigned states_and(const twa_graph_ptr &aut, I begin, I end)
Combine two states in a conjunction.
Definition: alternation.hh:75
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

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