spot 2.16
Loading...
Searching...
No Matches
mtdswa.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/misc/bddlt.hh>
23#include <unordered_map>
24
25namespace spot
26{
29
32
35 struct SPOT_API mtdswa: public std::enable_shared_from_this<mtdswa>
36 {
37 public:
39 mtdswa(const bdd_dict_ptr& dict) noexcept
40 : dict_(dict)
41 {
42 }
43
44 ~mtdswa()
45 {
46 dict_->unregister_all_my_variables(this);
47 }
48
58 std::vector<formula> aps;
59
60 std::vector<bdd> states;
61 std::vector<formula> names;
62 std::vector<acc_cond::mark_t> colors;
64
66 std::unordered_map<int, int> terminal_to_state_map;
68 std::unordered_map<int, unsigned> highlight_nodes;
70 std::unordered_map<int, int> highlight_groups;
71
74 {
75 return dict_;
76 }
77
82 unsigned num_roots() const
83 {
84 return states.size();
85 }
86
92 unsigned num_states() const
93 {
94 return states.size() + bdd_has_true(states);
95 }
96
100 std::ostream& print_dot(std::ostream& os, const char* opts = nullptr) const;
101
103 twa_graph_ptr as_twa(bool state_based = false,
104 bool labels = true,
105 bool complete = false) const;
106
122
130 void sinks_as_constants(bool keep_all_states = false);
131
145 void set_controllable_variables(const std::vector<std::string>& vars,
146 bool ignore_non_registered_ap = false);
149
152 {
153 return controllable_variables_;
154 }
155
156 private:
157 bdd_dict_ptr dict_;
158 bdd controllable_variables_ = bddtrue;
159 };
160
161
164 typedef std::shared_ptr<mtdswa> mtdswa_ptr;
167 typedef std::shared_ptr<const mtdswa> const_mtdswa_ptr;
168
172
192 SPOT_API std::vector<int> scc_vector(const mtdswa_ptr& aut,
193 std::vector<bool>* transient = nullptr,
194 std::vector<std::vector<int>>*
195 succs = nullptr);
196
220 SPOT_API std::vector<unsigned> loding_weak_ranking(const mtdswa_ptr& aut,
221 bool fix = false);
222
249 SPOT_API
251 SPOT_API
253 const std::vector<unsigned>& initial_partition);
255
256
259 SPOT_API
260 mtdswa_ptr product(const mtdswa_ptr& swa1, const mtdswa_ptr& swa2);
261
264 SPOT_API
265 mtdswa_ptr product_or(const mtdswa_ptr& swa1, const mtdswa_ptr& swa2);
266
273 SPOT_API
274 mtdswa_ptr product_xor(const mtdswa_ptr& swa1, const mtdswa_ptr& swa2);
275
282 SPOT_API
283 mtdswa_ptr product_xnor(const mtdswa_ptr& swa1, const mtdswa_ptr& swa2);
284
290 SPOT_API
292
295 SPOT_API mtdswa_ptr complement(const mtdswa_ptr& swa);
296
306 SPOT_API mtdswa_ptr
307 quantify_exists(const mtdswa_ptr& swa, bdd vars, bool trim = true);
308 SPOT_API mtdswa_ptr
309 quantify_exists(const mtdswa_ptr& swa, const formula& ap, bool trim = true);
310 SPOT_API mtdswa_ptr
311 quantify_exists(const mtdswa_ptr& swa, const std::vector<formula>& aps,
312 bool trim = true);
314
324 SPOT_API mtdswa_ptr
325 quantify_forall(const mtdswa_ptr& swa, bdd vars, bool trim = true);
326 SPOT_API mtdswa_ptr
327 quantify_forall(const mtdswa_ptr& swa, const formula& ap, bool trim = true);
328 SPOT_API mtdswa_ptr
329 quantify_forall(const mtdswa_ptr& swa, const std::vector<formula>& aps,
330 bool trim = true);
332
340 {
341 public:
344 bool simplify_terms = true);
345
347 mtdswa_ptr ltl_to_mtdswa(formula f, bool fuse_same_bdds);
350 const std::vector<std::string>& outvars,
351 bool realizability, int debug = -1);
352
356 formula leaf_to_formula(int b, int term) const;
357
372
374 bdd combine_and(bdd left, bdd right);
376 bdd combine_or(bdd left, bdd right);
378 bdd combine_implies(bdd left, bdd right);
380 bdd combine_equiv(bdd left, bdd right);
382 bdd combine_xor(bdd left, bdd right);
384 bdd combine_not(bdd b);
385
387 bdd propeq_encode(formula f, int level = 0);
390
392 bddExtCache* get_cache()
393 {
394 return &cache_;
395 }
396
398 private:
399 // Pair representing a formula at a given X-nesting level
400 struct formula_level_pair
401 {
402 formula f;
403 int level;
404
405 bool operator==(const formula_level_pair& other) const
406 {
407 return f == other.f && level == other.level;
408 }
409 };
410
411 struct formula_level_pair_hash
412 {
413 std::size_t operator()(const formula_level_pair& p) const
414 {
415 return p.f.id() ^ (p.level * 0x9e3779b9);
416 }
417 };
418
419 std::unordered_map<formula_level_pair, bdd,
420 formula_level_pair_hash> propositional_equiv_bdd_;
421 std::unordered_map<bdd, formula, bdd_hash> propositional_equiv_[2];
422
423 std::unordered_map<formula, bdd> formula_to_bdd_;
424 std::unordered_map<formula, int> formula_to_int_;
425 std::unordered_map<formula, int> propeq_to_int_;
426 std::vector<formula> int_to_formula_;
427 bdd_dict_ptr dict_;
428 bddExtCache cache_;
429 bool simplify_terms_;
430 };
431
442 SPOT_API
444 bool fuse_same_bdds = true,
445 bool simplify_terms = true);
446
467 SPOT_API
469 const std::vector<std::string>& outvars,
470 bool realizability = false,
471 bool simplify_terms = true,
472 int debug = -1);
473
479 SPOT_API twa_graph_ptr
480 mtdswa_strategy_to_mealy(mtdswa_ptr strategy, bool labels = true,
481 bool loop = false);
482
483
500 SPOT_API void trim(mtdswa_ptr swa,
501 bool trim_useless_sccs_too = false);
502
503}
An acceptance condition.
Definition acc.hh:54
Main class for temporal logic formula.
Definition formula.hh:847
"Semi-internal" for translating LTL using MTBDDs
Definition mtdswa.hh:340
bdd ltl_to_mtbdd(formula f)
Convert an LTL formula to an MTBDD.
mtdswa_ptr ltl_to_mtdswa_synthesis(formula f, const std::vector< std::string > &outvars, bool realizability, int debug=-1)
Translate an LTL formula for synthesis to MTDSwA.
int formula_to_terminal_bdd_as_int(formula f)
Convert a formula to a terminal BDD integer.
formula leaf_to_formula(int b, int term) const
Convert a leaf value to a formula.
bdd combine_and(bdd left, bdd right)
Combine two BDDs with logical AND.
int formula_to_int(formula f)
Convert a formula to an integer key.
bdd combine_implies(bdd left, bdd right)
Combine two BDDs with logical implication.
formula terminal_to_formula(int t) const
Convert a terminal integer to a formula.
mtdswa_ptr ltl_to_mtdswa(formula f, bool fuse_same_bdds)
Translate an LTL formula to an MTDSwA.
bdd combine_or(bdd left, bdd right)
Combine two BDDs with logical OR.
int formula_propeq_to_int(formula f)
Convert a propositional equivalence formula to int.
bdd combine_not(bdd b)
Negate a BDD.
formula propeq_representative(formula f, bool isacc)
Get the representative formula for a propositional equiv.
bdd propeq_encode(formula f, int level=0)
Encode a formula using propositional equivalences.
bdd formula_to_terminal_bdd(formula f)
Convert a formula to a terminal BDD.
bddExtCache * get_cache()
Return a pointer to the internal BDD cache.
Definition mtdswa.hh:392
bdd combine_equiv(bdd left, bdd right)
Combine two BDDs with logical equivalence.
bdd combine_xor(bdd left, bdd right)
Combine two BDDs with exclusive OR.
int formula_to_terminal(formula f)
Convert a formula to a terminal index.
simple_ltl_translator(const bdd_dict_ptr &dict, bool simplify_terms=true)
Construct the translator with the given BDD dictionary.
int formula_propeq_to_terminal_bdd_as_int(formula f)
Convert propositional equiv formula to terminal BDD int.
mtdfa_ptr product_or(const mtdfa_ptr &dfa1, const mtdfa_ptr &dfa2)
Combine two MTDFAs to sum their languages.
mtdfa_ptr product_xor(const mtdfa_ptr &dfa1, const mtdfa_ptr &dfa2)
Combine two MTDFAs to build the exclusive sum of their languages.
mtdfa_ptr product_xnor(const mtdfa_ptr &dfa1, const mtdfa_ptr &dfa2)
Combine two MTDFAs to keep words that are handled similarly in both operands.
mtdfa_ptr product(const mtdfa_ptr &dfa1, const mtdfa_ptr &dfa2)
Combine two MTDFAs to intersect their languages.
mtdfa_ptr trim(const mtdfa_ptr &dfa)
Trim an MTDFA.
mtdfa_ptr quantify_forall(const mtdfa_ptr &dfa, bdd vars, bool trim=true)
Universally quantify variables in an MTDFA.
mtdfa_ptr quantify_exists(const mtdfa_ptr &dfa, bdd vars, bool trim=true)
Existentially quantify variables in an MTDFA.
mtdfa_ptr product_implies(const mtdfa_ptr &dfa1, const mtdfa_ptr &dfa2)
Combine two MTDFAs to build an implication.
twa_graph_ptr mtdswa_strategy_to_mealy(mtdswa_ptr strategy, bool labels=true, bool loop=false)
Convert a strategy represented as MTDSwA into a Mealy machine.
mtdswa_ptr obligation_to_mtdswa(formula f, const bdd_dict_ptr &dict, bool fuse_same_bdds=true, bool simplify_terms=true)
Convert a syntactic-obligation to an MTDSwA.
mtdswa_ptr minimize_mtdswa(const mtdswa_ptr &dfa)
Minimization of MTDSwA.
std::vector< int > scc_vector(const mtdswa_ptr &aut, std::vector< bool > *transient=nullptr, std::vector< std::vector< int > > *succs=nullptr)
Find the SCC of each state.
std::shared_ptr< mtdswa > mtdswa_ptr
Shared pointer to an mtdswa.
Definition mtdswa.hh:164
mtdswa_ptr obligation_synthesis(formula f, const bdd_dict_ptr &dict, const std::vector< std::string > &outvars, bool realizability=false, bool simplify_terms=true, int debug=-1)
Reactive synthesis of syntactic-obligations.
std::vector< unsigned > loding_weak_ranking(const mtdswa_ptr &aut, bool fix=false)
Preprocess a weak MTDSwA before minimization.
mtdswa_ptr dtwa_to_mtdswa(const twa_graph_ptr &aut)
Convert deterministic TwA to MTDSwA.
std::shared_ptr< const mtdswa > const_mtdswa_ptr
Shared pointer to a const mtdswa.
Definition mtdswa.hh:167
@ ap
Atomic proposition.
twa_graph_ptr complement(const const_twa_graph_ptr &aut, const output_aborter *aborter=nullptr)
Complement a TωA.
std::shared_ptr< bdd_dict > bdd_dict_ptr
Shared pointer to a bdd_dict.
Definition bdddict.hh:304
std::shared_ptr< twa_graph > twa_graph_ptr
Shared pointer to a mutable twa_graph.
Definition fwd.hh:44
Definition automata.hh:26
constexpr bool operator==(trival a, trival b)
Equality comparison of two trival values.
Definition trival.hh:134
MTBDD-based representation of a state-based ω-automaton.
Definition mtdswa.hh:36
mtdswa(const bdd_dict_ptr &dict) noexcept
Construct an MTDSwA with the given BDD dictionary.
Definition mtdswa.hh:39
std::unordered_map< int, unsigned > highlight_nodes
Highlighted BDD nodes (for visualization).
Definition mtdswa.hh:68
std::unordered_map< int, int > terminal_to_state_map
Map terminal BDD values to state indices (debug only).
Definition mtdswa.hh:66
void set_controllable_variables(bdd vars)
Declare a list of controllable variables.
void set_controllable_variables(const std::vector< std::string > &vars, bool ignore_non_registered_ap=false)
Declare a list of controllable variables.
acc_cond acc
Acceptance condition of the automaton.
Definition mtdswa.hh:63
std::vector< formula > names
Name formula for each root state.
Definition mtdswa.hh:61
std::vector< formula > aps
The list of atomic propositions possibly used by the automaton.
Definition mtdswa.hh:58
unsigned num_states() const
The number of states in the automaton.
Definition mtdswa.hh:92
std::vector< acc_cond::mark_t > colors
Acceptance marks per root state.
Definition mtdswa.hh:62
void sinks_as_constants(bool keep_all_states=false)
Convert sink states to bddtrue/bddfalse constants.
bdd get_controllable_variables() const
Returns the conjunction of controllable variables.
Definition mtdswa.hh:151
void sinks_as_states()
Convert bddtrue/bddfalse nodes to actual states.
std::unordered_map< int, int > highlight_groups
Cluster grouping for BDD nodes (for visualization).
Definition mtdswa.hh:70
std::ostream & print_dot(std::ostream &os, const char *opts=nullptr) const
Print the MTBDD.
std::vector< bdd > states
BDD transitions for each root state.
Definition mtdswa.hh:60
bdd_dict_ptr get_dict() const
Get the bdd_dict associated to this automaton.
Definition mtdswa.hh:73
unsigned num_roots() const
Return the number of root states.
Definition mtdswa.hh:82
twa_graph_ptr as_twa(bool state_based=false, bool labels=true, bool complete=false) const
Convert to twa.

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