spot 2.12.2
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
25namespace 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
109 SPOT_API
110 twa_graph_ptr remove_alternation(const const_twa_graph_ptr& aut,
111 bool named_states = false,
112 const output_aborter* aborter = nullptr,
113 bool raise_if_too_many_sets = true);
114
115
116 // Remove universal edges on the fly.
117
118 class SPOT_API univ_remover_state: public state
119 {
120 protected:
121 std::set<unsigned> states_;
122 bool is_reset_;
123
124 public:
125 univ_remover_state(const std::set<unsigned>& states);
126 univ_remover_state(const univ_remover_state& other)
127 : states_(other.states_), is_reset_(other.is_reset_)
128 {
129 }
130 int compare(const state* other) const override;
131 size_t hash() const override;
132 state* clone() const override;
133 const std::set<unsigned>& states() const;
134 bool is_reset() const;
135 };
136
137 class SPOT_API twa_univ_remover: public twa
138 {
139
140 private:
141 const_twa_graph_ptr aut_;
142 std::vector<int> state_to_var_;
143 std::map<int, unsigned> var_to_state_;
144 bdd all_states_;
145
146 public:
147 twa_univ_remover(const const_twa_graph_ptr& aut);
148 void allocate_state_vars();
149 const state* get_init_state() const override;
150 twa_succ_iterator* succ_iter(const state* s) const override;
151 std::string format_state(const state* s) const override;
152 };
153
154 typedef std::shared_ptr<twa_univ_remover> twa_univ_remover_ptr;
155
172 SPOT_API
173 twa_univ_remover_ptr remove_univ_otf(const const_twa_graph_ptr& aut);
174}
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.4