spot 2.15
Loading...
Searching...
No Matches
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{
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:
54 outedge_combiner(const twa_graph_ptr& aut);
56 bdd operator()(unsigned st);
57 void new_dests(unsigned st, bdd out) const;
58 };
59
70 template<class I>
71 SPOT_API
72 unsigned states_and(const twa_graph_ptr& aut, I begin, I end)
73 {
74 if (begin == end)
75 throw std::runtime_error
76 ("state_and() expects an non-empty list of states");
77 outedge_combiner combiner(aut);
78 bdd combination = bddtrue;
79 while (begin != end)
80 combination &= combiner(*begin++);
81 unsigned new_s = aut->new_state();
82 combiner.new_dests(new_s, combination);
83 return new_s;
84 }
85
86 template<class T>
87 SPOT_API
88 unsigned states_and(const twa_graph_ptr& aut,
89 const std::initializer_list<T>& il)
90 {
91 return states_and(aut, il.begin(), il.end());
92 }
94
110 SPOT_API
111 twa_graph_ptr remove_alternation(const const_twa_graph_ptr& aut,
112 bool named_states = false,
113 const output_aborter* aborter = nullptr,
114 bool raise_if_too_many_sets = true);
115
116
117 // Remove universal edges on the fly.
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);
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
163 SPOT_API
164 twa_univ_remover_ptr remove_univ_otf(const const_twa_graph_ptr& aut);
165}
Helper class combine outgoing edges in alternating automata.
Definition alternation.hh:47
Helper object to specify when an algorithm should abort its construction.
Definition powerset.hh:44
Abstract class for states.
Definition twa.hh:47
Iterate over the successors of a state.
Definition twa.hh:394
Definition alternation.hh:138
const state * get_init_state() const override
Get the initial state of the automaton.
std::string format_state(const state *s) const override
Format the state as a string for printing.
twa_succ_iterator * succ_iter(const state *s) const override
Get an iterator over the successors of local_state.
A Transition-based ω-Automaton.
Definition twa.hh:619
Definition alternation.hh:119
size_t hash() const override
Hash a state.
int compare(const state *other) const override
Compares two states (that come from the same automaton).
state * clone() const override
Duplicate a state.
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:72
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.8