spot 2.15
Loading...
Searching...
No Matches
ltlf2dfa.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 <spot/misc/trival.hh>
24#include <spot/twaalgos/backprop.hh>
25
26namespace spot
27{
44
49 struct SPOT_API mtdfa_stats
50 {
55 unsigned states;
56
62 unsigned aps;
63
67 unsigned nodes;
68
74 unsigned terminals;
75
83
88 unsigned long long paths;
89
93 unsigned long long edges;
94 };
95
116 struct SPOT_API mtdfa: public std::enable_shared_from_this<mtdfa>
117 {
118 public:
123 mtdfa(const bdd_dict_ptr& dict) noexcept
124 : dict_(dict)
125 {
126 }
127
128 ~mtdfa()
129 {
130 dict_->unregister_all_my_variables(this);
131 }
132
133 std::vector<bdd> states;
134 std::vector<formula> names;
144 std::vector<formula> aps;
145
150 unsigned num_roots() const
151 {
152 return states.size();
153 }
154
160 unsigned num_states() const
161 {
162 return states.size() + bdd_has_true(states);
163 }
164
165 // This assumes that all states are reachable, so we just have to
166 // check if one terminal is accepting.
167 bool is_empty() const;
168
178 std::ostream& print_dot(std::ostream& os,
179 int index = -1,
180 bool labels = true) const;
181
199 twa_graph_ptr as_twa(bool state_based = false, bool labels = true) const;
200
214 mtdfa_stats get_stats(bool nodes, bool paths) const;
215
217 bdd_dict_ptr get_dict() const
218 {
219 return dict_;
220 }
221
234 void set_controllable_variables(const std::vector<std::string>& vars,
235 bool ignore_non_registered_ap = false);
238
241 {
242 return controllable_variables_;
243 }
244
245 private:
246 bdd_dict_ptr dict_;
247 bdd controllable_variables_ = bddtrue;
248 };
249
250 typedef std::shared_ptr<mtdfa> mtdfa_ptr;
251 typedef std::shared_ptr<const mtdfa> const_mtdfa_ptr;
252
290 SPOT_API mtdfa_ptr
291 ltlf_to_mtdfa(formula f, const bdd_dict_ptr& dict,
292 bool fuse_same_bdds = true,
293 bool simplify_terms = true,
294 bool detect_empty_univ = true,
295 bool preserve_quantifiers_in_names = false);
296
297
303
310 {
315 bool one_step_preprocess = true;
316
323 bool terminating_semantics = true;
324
326 bool fuse_same_bdds = true;
327
329 bool simplify_terms = true;
330
336 bool detect_empty_univ = true;
337 };
338
372 SPOT_API mtdfa_ptr
373 ltlf_to_mtdfa_for_synthesis(formula f, const bdd_dict_ptr& dict,
374 const std::vector<std::string>& outvars,
377 bool realizability = false,
378 ltlf_synthesis_options options = {});
379
411 SPOT_API mtdfa_ptr
412 ltlf_to_mtdfa_compose(formula f, const bdd_dict_ptr& dict,
413 bool minimize = true, bool order_for_aps = true,
414 bool want_names = true,
415 bool fuse_same_bdds = true,
416 bool simplify_terms = true);
417
436 SPOT_API mtdfa_ptr minimize_mtdfa(const mtdfa_ptr& dfa);
437
440 SPOT_API mtdfa_ptr product(const mtdfa_ptr& dfa1, const mtdfa_ptr& dfa2);
441
444 SPOT_API mtdfa_ptr product_or(const mtdfa_ptr& dfa1, const mtdfa_ptr& dfa2);
445
452 SPOT_API mtdfa_ptr product_xor(const mtdfa_ptr& dfa1, const mtdfa_ptr& dfa2);
453
460 SPOT_API mtdfa_ptr product_xnor(const mtdfa_ptr& dfa1, const mtdfa_ptr& dfa2);
461
467 SPOT_API mtdfa_ptr product_implies(const mtdfa_ptr& dfa1,
468 const mtdfa_ptr& dfa2);
469
472 SPOT_API mtdfa_ptr complement(const mtdfa_ptr& dfa);
473
476 SPOT_API mtdfa_ptr twadfa_to_mtdfa(const twa_graph_ptr& twa);
477
478
485 class SPOT_API ltlf_translator
486 {
487 public:
488 ltlf_translator(const bdd_dict_ptr& dict,
489 bool simplify_terms = true);
490
491 mtdfa_ptr ltlf_to_mtdfa(formula f, bool fuse_same_bdds,
492 bool detect_empty_univ = true,
493 const std::vector<std::string>* outvars = nullptr,
494 bool do_backprop = false,
495 bool realizability = false,
496 bool one_step_preprocess = false,
497 bool bfs = true,
498 bool terminating_semantics = true,
499 bool preserve_quantifiers_in_names = false);
500
501 bdd ltlf_to_mtbdd(formula f);
502 std::pair<formula, bool> leaf_to_formula(int b, int term) const;
503
504 formula terminal_to_formula(int t) const;
505 int formula_to_int(formula f);
506 int formula_to_terminal(formula f, bool may_stop = false);
507 bdd formula_to_terminal_bdd(formula f, bool may_stop = false);
508 int formula_to_terminal_bdd_as_int(formula f, bool may_stop = false);
509
510 bdd combine_and(bdd left, bdd right);
511 bdd combine_or(bdd left, bdd right);
512 bdd combine_implies(bdd left, bdd right);
513 bdd combine_equiv(bdd left, bdd right);
514 bdd combine_xor(bdd left, bdd right);
515 bdd combine_not(bdd b);
516
517
518 bdd propeq_encode(formula f);
519 formula propeq_representative(formula f);
520 int formula_propeq_to_int(formula f);
521 int formula_propeq_to_terminal_bdd_as_int(formula f, bool may_stop);
522 int formula_propeq_to_terminal(formula f, bool may_stop = false);
523
524
525 bddExtCache* get_cache()
526 {
527 return &cache_;
528 }
529
531 private:
532 std::unordered_map<formula, int> formula_to_var_;
533 std::unordered_map<formula, bdd> propositional_equiv_bdd_;
534 std::unordered_map<bdd, formula, bdd_hash> propositional_equiv_;
535 std::unordered_map<formula, int> propeq_to_int_;
536
537 std::unordered_map<formula, bdd> formula_to_bdd_;
538 std::unordered_map<formula, int> formula_to_int_;
539 std::vector<formula> int_to_formula_;
540 bdd_dict_ptr dict_;
541 bddExtCache cache_;
542 bool simplify_terms_;
543 };
544
558 SPOT_API std::vector<bool>
559 mtdfa_winning_region(mtdfa_ptr dfa);
560
573 SPOT_API std::vector<bool>
575
576 SPOT_API std::vector<trival>
579
588 SPOT_API mtdfa_ptr mtdfa_restrict_as_game(mtdfa_ptr dfa);
589 SPOT_API mtdfa_ptr
591 const std::vector<bool>& winning_states);
592 SPOT_API mtdfa_ptr
594 const std::vector<trival>& winning_states);
596
597
614 SPOT_API backprop_graph
615 mtdfa_to_backprop(mtdfa_ptr dfa, bool early_stop = true,
616 bool preserve_names = false);
617
633 SPOT_API mtdfa_ptr
634 mtdfa_winning_strategy(mtdfa_ptr dfa, bool backprop_nodes);
635
650 SPOT_API twa_graph_ptr
651 mtdfa_strategy_to_mealy(mtdfa_ptr strategy, bool labels = true,
652 bool loop = false);
653}
Definition backprop.hh:31
Main class for temporal logic formula.
Definition formula.hh:850
"Semi-internal" class used to implement spot::ltlf_to_mtdfa()
Definition ltlf2dfa.hh:486
A Transition-based ω-Automaton.
Definition twa.hh:619
mtdfa_ptr product_or(const mtdfa_ptr &dfa1, const mtdfa_ptr &dfa2)
Combine two MTDFAs to sum their languages.
mtdfa_ptr twadfa_to_mtdfa(const twa_graph_ptr &twa)
Convert a TWA (representing a DFA) into an MTDFA.
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 ltlf_to_mtdfa_for_synthesis(formula f, const bdd_dict_ptr &dict, const std::vector< std::string > &outvars, ltlf_synthesis_backprop backprop=dfs_node_backprop, bool realizability=false, ltlf_synthesis_options options={})
Solve (or start solving) LTLf synthesis.
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 ltlf_to_mtdfa_compose(formula f, const bdd_dict_ptr &dict, bool minimize=true, bool order_for_aps=true, bool want_names=true, bool fuse_same_bdds=true, bool simplify_terms=true)
Convert an LTLf formula into a MTDFA, with a compositional approach.
mtdfa_ptr ltlf_to_mtdfa(formula f, const bdd_dict_ptr &dict, bool fuse_same_bdds=true, bool simplify_terms=true, bool detect_empty_univ=true, bool preserve_quantifiers_in_names=false)
Convert an LTLf formula into an MTDFA.
twa_graph_ptr mtdfa_strategy_to_mealy(mtdfa_ptr strategy, bool labels=true, bool loop=false)
Convert an MTDFA representing a strategy to a TwA with the "synthesis-output" property.
std::vector< bool > mtdfa_winning_region(mtdfa_ptr dfa)
Compute the winning region of the MTDFA interpreted as a game.
mtdfa_ptr product(const mtdfa_ptr &dfa1, const mtdfa_ptr &dfa2)
Combine two MTDFAs to intersect their languages.
mtdfa_ptr minimize_mtdfa(const mtdfa_ptr &dfa)
Minimize a MTDFA.
mtdfa_ptr mtdfa_winning_strategy(mtdfa_ptr dfa, bool backprop_nodes)
Compute a strategy for an MTDFA interpreted as a game.
mtdfa_ptr mtdfa_restrict_as_game(mtdfa_ptr dfa)
Build a generalized strategy from a set of winning states.
backprop_graph mtdfa_to_backprop(mtdfa_ptr dfa, bool early_stop=true, bool preserve_names=false)
Build a backprop_graph from dfa.
mtdfa_ptr product_implies(const mtdfa_ptr &dfa1, const mtdfa_ptr &dfa2)
Combine two MTDFAs to build an implication.
twa_graph_ptr complement(const const_twa_graph_ptr &aut, const output_aborter *aborter=nullptr)
Complement a TωA.
Definition automata.hh:26
std::vector< bool > mtdfa_winning_region_lazy(mtdfa_ptr dfa)
Compute the winning region of the MTDFA interpreted as a game. Lazy version.
ltlf_synthesis_backprop
Definition ltlf2dfa.hh:298
@ state_refine
no backpropagation, just local refinement
Definition ltlf2dfa.hh:299
@ dfs_node_backprop
on-the-fly, DFS
Definition ltlf2dfa.hh:301
@ bfs_node_backprop
on-the-fly, BFS
Definition ltlf2dfa.hh:300
std::vector< trival > mtdfa_winning_region_lazy3(mtdfa_ptr dfa)
Compute the winning region of the MTDFA interpreted as a game. Lazy version.
Fine-tuning options for LTLf synthesis.
Definition ltlf2dfa.hh:310
statistics about an mtdfa instance
Definition ltlf2dfa.hh:50
unsigned nodes
Number of internal nodes (or decision nodes)
Definition ltlf2dfa.hh:67
unsigned long long paths
Number of paths between a root and a leaf (terminal or constant)
Definition ltlf2dfa.hh:88
unsigned terminals
Number of terminal nodes.
Definition ltlf2dfa.hh:74
unsigned aps
number of atomic propositions
Definition ltlf2dfa.hh:62
bool has_false
Whether the true and false constants are used.
Definition ltlf2dfa.hh:81
bool has_true
Whether the true and false constants are used.
Definition ltlf2dfa.hh:80
unsigned states
number of roots
Definition ltlf2dfa.hh:55
unsigned long long edges
Number of pairs (root, leaf) for which a path exists.
Definition ltlf2dfa.hh:93
a DFA represented using shared multi-terminal BDDs
Definition ltlf2dfa.hh:117
unsigned num_states() const
The number of states in the automaton.
Definition ltlf2dfa.hh:160
twa_graph_ptr as_twa(bool state_based=false, bool labels=true) const
Convert this automaton to a spot::twa_graph.
void set_controllable_variables(const std::vector< std::string > &vars, bool ignore_non_registered_ap=false)
declare a list of controllable variables
bdd_dict_ptr get_dict() const
get the bdd_dict associated to this automaton
Definition ltlf2dfa.hh:217
std::vector< formula > aps
The list of atomic propositions possibly used by the automaton.
Definition ltlf2dfa.hh:144
void set_controllable_variables(bdd vars)
declare a list of controllable variables
mtdfa_stats get_stats(bool nodes, bool paths) const
compute some statistics about the automaton
bdd get_controllable_variables() const
Returns the conjunction of controllable variables.
Definition ltlf2dfa.hh:240
unsigned num_roots() const
the number of MTBDDs roots
Definition ltlf2dfa.hh:150
std::ostream & print_dot(std::ostream &os, int index=-1, bool labels=true) const
Print the states array of MTBDD in graphviz format.
mtdfa(const bdd_dict_ptr &dict) noexcept
create an empty mtdfa
Definition ltlf2dfa.hh:123

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