21 #include <spot/twa/twagraph.hh>
22 #include <spot/misc/bddlt.hh>
23 #include <unordered_map>
35 struct SPOT_API
mtdswa:
public std::enable_shared_from_this<mtdswa>
46 dict_->unregister_all_my_variables(
this);
58 std::vector<formula>
aps;
62 std::vector<acc_cond::mark_t>
colors;
94 return states.size() + bdd_has_true(states);
100 std::ostream&
print_dot(std::ostream& os,
const char* opts =
nullptr)
const;
146 bool ignore_non_registered_ap =
false);
153 return controllable_variables_;
158 bdd controllable_variables_ = bddtrue;
193 std::vector<bool>*
transient =
nullptr,
194 std::vector<std::vector<int>>*
253 const std::vector<unsigned>& initial_partition);
344 bool simplify_terms =
true);
350 const std::vector<std::string>& outvars,
351 bool realizability,
int debug = -1);
400 struct formula_level_pair
405 bool operator==(
const formula_level_pair& other)
const
407 return f == other.f && level == other.level;
411 struct formula_level_pair_hash
413 std::size_t operator()(
const formula_level_pair& p)
const
415 return p.f.id() ^ (p.level * 0x9e3779b9);
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];
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_;
429 bool simplify_terms_;
444 bool fuse_same_bdds =
true,
445 bool simplify_terms =
true);
469 const std::vector<std::string>& outvars,
470 bool realizability =
false,
471 bool simplify_terms =
true,
501 bool trim_useless_sccs_too =
false);
An acceptance condition.
Definition: acc.hh:54
"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.
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.
bddExtCache * get_cache()
Return a pointer to the internal BDD cache.
Definition: mtdswa.hh:392
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.
std::vector< unsigned > loding_weak_ranking(const mtdswa_ptr &aut, bool fix=false)
Preprocess a weak MTDSwA before minimization.
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.
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.
mtdswa_ptr minimize_mtdswa(const mtdswa_ptr &dfa)
Minimization of MTDSwA.
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.
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
twa_graph_ptr complement(const const_twa_graph_ptr &aut, const output_aborter *aborter=nullptr)
Complement a TωA.
twa_graph_ptr complete(const const_twa_ptr &aut)
Clone a twa and complete it.
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.
std::ostream & print_dot(std::ostream &os, const char *opts=nullptr) const
Print the MTBDD.
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::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.