spot 2.13.2.dev
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{
39
44 struct SPOT_API mtdfa_stats
45 {
50 unsigned states;
51
57 unsigned aps;
58
62 unsigned nodes;
63
69 unsigned terminals;
70
78
83 unsigned long long paths;
84
88 unsigned long long edges;
89 };
90
106 struct SPOT_API mtdfa: public std::enable_shared_from_this<mtdfa>
107
108 {
109 public:
114 mtdfa(const bdd_dict_ptr& dict) noexcept
115 : dict_(dict)
116 {
117 }
118
119 ~mtdfa()
120 {
121 dict_->unregister_all_my_variables(this);
122 }
123
124 std::vector<bdd> states;
125 std::vector<formula> names;
135 std::vector<formula> aps;
136
141 unsigned num_roots() const
142 {
143 return states.size();
144 }
145
151 unsigned num_states() const
152 {
153 return states.size() + bdd_has_true(states);
154 }
155
156 // This assumes that all states are reachable, so we just have to
157 // check if one terminal is accepting.
158 bool is_empty() const;
159
168 std::ostream& print_dot(std::ostream& os,
169 int index = -1,
170 bool labels = true) const;
171
189 twa_graph_ptr as_twa(bool state_based = false, bool labels = true) const;
190
204 mtdfa_stats get_stats(bool nodes, bool paths) const;
205
207 bdd_dict_ptr get_dict() const
208 {
209 return dict_;
210 }
211
224 void set_controllable_variables(const std::vector<std::string>& vars,
225 bool ignore_non_registered_ap = false);
228
231 {
232 return controllable_variables_;
233 }
234
235 private:
236 bdd_dict_ptr dict_;
237 bdd controllable_variables_ = bddtrue;
238 };
239
240 typedef std::shared_ptr<mtdfa> mtdfa_ptr;
241 typedef std::shared_ptr<const mtdfa> const_mtdfa_ptr;
242
267 SPOT_API mtdfa_ptr
268 ltlf_to_mtdfa(formula f, const bdd_dict_ptr& dict,
269 bool fuse_same_bdds = true,
270 bool simplify_terms = true,
271 bool detect_empty_univ = true);
272
273
274 enum ltlf_synthesis_backprop {
275 state_refine, // no backpropagation, just local refinement
276 bfs_node_backprop, // on-the-fly
277 dfs_node_backprop, // on-the-fly, DFS that stops on visited nodes
278 dfs_strict_node_backprop, // on-the-fly, DFS that stops on visited states
279 };
280
313 SPOT_API mtdfa_ptr
314 ltlf_to_mtdfa_for_synthesis(formula f, const bdd_dict_ptr& dict,
315 const std::vector<std::string>& outvars,
316 ltlf_synthesis_backprop backprop
317 = dfs_node_backprop,
318 bool one_step_preprocess = false,
319 bool realizability = false,
320 bool fuse_same_bdds = true,
321 bool simplify_terms = true,
322 bool detect_empty_univ = true);
323
355 SPOT_API mtdfa_ptr
356 ltlf_to_mtdfa_compose(formula f, const bdd_dict_ptr& dict,
357 bool minimize = true, bool order_for_aps = true,
358 bool want_names = true,
359 bool fuse_same_bdds = true,
360 bool simplify_terms = true);
361
382 SPOT_API mtdfa_ptr minimize_mtdfa(const mtdfa_ptr& dfa);
383
386 SPOT_API mtdfa_ptr product(const mtdfa_ptr& dfa1, const mtdfa_ptr& dfa2);
387
390 SPOT_API mtdfa_ptr product_or(const mtdfa_ptr& dfa1, const mtdfa_ptr& dfa2);
391
397 SPOT_API mtdfa_ptr product_xor(const mtdfa_ptr& dfa1, const mtdfa_ptr& dfa2);
398
405 SPOT_API mtdfa_ptr product_xnor(const mtdfa_ptr& dfa1, const mtdfa_ptr& dfa2);
406
412 SPOT_API mtdfa_ptr product_implies(const mtdfa_ptr& dfa1,
413 const mtdfa_ptr& dfa2);
414
417 SPOT_API mtdfa_ptr complement(const mtdfa_ptr& dfa);
418
421 SPOT_API mtdfa_ptr twadfa_to_mtdfa(const twa_graph_ptr& twa);
422
423
430 class SPOT_API ltlf_translator
431 {
432 public:
433 ltlf_translator(const bdd_dict_ptr& dict,
434 bool simplify_terms = true);
435
436 mtdfa_ptr ltlf_to_mtdfa(formula f, bool fuse_same_bdds,
437 bool detect_empty_univ = true,
438 const std::vector<std::string>* outvars = nullptr,
439 bool do_backprop = false,
440 bool realizability = false,
441 bool one_step_preprocess = false,
442 bool bfs = true);
443
444 mtdfa_ptr ltlf_synthesis_with_dfs(formula f,
445 const std::vector<std::string>*
446 outvars = nullptr,
447 bool realizability = false,
448 bool ont_step_preprocess = false);
449
450 bdd ltlf_to_mtbdd(formula f);
451 std::pair<formula, bool> leaf_to_formula(int b, int term) const;
452
453 formula terminal_to_formula(int t) const;
454 int formula_to_int(formula f);
455 int formula_to_terminal(formula f, bool may_stop = false);
456 bdd formula_to_terminal_bdd(formula f, bool may_stop = false);
457 int formula_to_terminal_bdd_as_int(formula f, bool may_stop = false);
458
459 bdd combine_and(bdd left, bdd right);
460 bdd combine_or(bdd left, bdd right);
461 bdd combine_implies(bdd left, bdd right);
462 bdd combine_equiv(bdd left, bdd right);
463 bdd combine_xor(bdd left, bdd right);
464 bdd combine_not(bdd b);
465
466 formula propeq_representative(formula f);
467
468 bddExtCache* get_cache()
469 {
470 return &cache_;
471 }
472
474 private:
475 std::unordered_map<formula, int> formula_to_var_;
476 std::unordered_map<bdd, formula, bdd_hash> propositional_equiv_;
477
478 std::unordered_map<formula, bdd> formula_to_bdd_;
479 std::unordered_map<formula, int> formula_to_int_;
480 std::vector<formula> int_to_formula_;
481 bdd_dict_ptr dict_;
482 bddExtCache cache_;
483 bool simplify_terms_;
484 };
485
499 SPOT_API std::vector<bool>
500 mtdfa_winning_region(mtdfa_ptr dfa);
501
514 SPOT_API std::vector<bool>
516
517 SPOT_API std::vector<trival>
520
521 #include <spot/graph/adjlist.hh>
522
523
532 SPOT_API mtdfa_ptr mtdfa_restrict_as_game(mtdfa_ptr dfa);
533 SPOT_API mtdfa_ptr
535 const std::vector<bool>& winning_states);
536 SPOT_API mtdfa_ptr
538 const std::vector<trival>& winning_states);
540
541
556 SPOT_API backprop_graph
557 mtdfa_to_backprop(mtdfa_ptr dfa, bool early_stop = true,
558 bool preserve_names = false);
559
575 SPOT_API mtdfa_ptr
576 mtdfa_winning_strategy(mtdfa_ptr dfa, bool backprop_nodes);
577
585 SPOT_API twa_graph_ptr
586 mtdfa_strategy_to_mealy(mtdfa_ptr strategy, bool labels = true);
587}
Definition backprop.hh:31
Main class for temporal logic formula.
Definition formula.hh:786
"Semi-internal" class used to implement spot::ltlf_to_mtdfa()
Definition ltlf2dfa.hh:431
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.
twa_graph_ptr mtdfa_strategy_to_mealy(mtdfa_ptr strategy, bool labels=true)
Convert an MTDFA representing a strategy to a TwA with the "synthesis-output" property.
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)
Convert an LTLf formula into a MTDFA.
std::vector< bool > mtdfa_winning_region(mtdfa_ptr dfa)
Compute the winning region of the MTDFA interpreted as a game.
mtdfa_ptr minimize_mtdfa(const mtdfa_ptr &dfa)
Minimize a MTDFA.
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 one_step_preprocess=false, bool realizability=false, bool fuse_same_bdds=true, bool simplify_terms=true, bool detect_empty_univ=true)
Solve (or start solving) LTLf synthesis.
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.
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.
std::vector< trival > mtdfa_winning_region_lazy3(mtdfa_ptr dfa)
Compute the winning region of the MTDFA interpreted as a game. Lazy version.
twa_graph_ptr complement(const const_twa_graph_ptr &aut, const output_aborter *aborter=nullptr)
Complement a TωA.
statistics about an mtdfa instance
Definition ltlf2dfa.hh:45
unsigned nodes
Number of internal nodes (or decision nodes)
Definition ltlf2dfa.hh:62
unsigned long long paths
Number of paths between a root and a leaf (terminal or constant)
Definition ltlf2dfa.hh:83
unsigned terminals
Number of terminal nodes.
Definition ltlf2dfa.hh:69
unsigned aps
number of atomic propositions
Definition ltlf2dfa.hh:57
bool has_false
Whether the true and false constants are used.
Definition ltlf2dfa.hh:76
bool has_true
Whether the true and false constants are used.
Definition ltlf2dfa.hh:75
unsigned states
number of roots
Definition ltlf2dfa.hh:50
unsigned long long edges
Number of pairs (root, leaf) for which a path exists.
Definition ltlf2dfa.hh:88
a DFA represented using shared multi-terminal BDDs
Definition ltlf2dfa.hh:108
unsigned num_states() const
The number of states in the automaton.
Definition ltlf2dfa.hh:151
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:207
std::vector< formula > aps
The list of atomic propositions possibly used by the automaton.
Definition ltlf2dfa.hh:135
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:230
unsigned num_roots() const
the number of MTBDDs roots
Definition ltlf2dfa.hh:141
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:114

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