LydiaSyft
ExplicitStateDfa.h
1 #ifndef EXPLICITSTATEDFA_H
2 #define EXPLICITSTATEDFA_H
3 
4 extern "C" {
5 #include <mona/bdd.h>
6 #include <mona/dfa.h>
7 #include <mona/mem.h>
8 }
9 
10 #include "lydia/logic/ltlf/base.hpp"
11 #include "lydia/dfa/mona_dfa.hpp"
12 #include "VarMgr.h"
13 
14 namespace Syft {
15 
22  class ExplicitStateDfa : public whitemech::lydia::mona_dfa {
23  public:
24 
31  ExplicitStateDfa(DFA *dfa, int nb_variables)
32  : whitemech::lydia::mona_dfa(dfa, nb_variables) {
33  }
34 
41  ExplicitStateDfa(DFA *dfa, const std::vector<std::string> &names)
42  : whitemech::lydia::mona_dfa(dfa, names) {
43  }
44 
49  : whitemech::lydia::mona_dfa(dfaCopy(other.dfa_), other.names) {
50 
51  }
52 
57  this->names = other.names;
58  this->dfa_ = dfaCopy(other.get_dfa());
59  return *this;
60  }
61 
62 
63  ~ExplicitStateDfa() {
64 
65  }
66 
71  return this->names.size();
72  }
73 
77  void dfa_print();
78 
79 
87  static ExplicitStateDfa dfa_of_formula(const whitemech::lydia::LTLfFormula &formula);
88 
95  static ExplicitStateDfa dfa_product_and(const std::vector<ExplicitStateDfa> &dfa_vector);
96 
103  static ExplicitStateDfa dfa_product_or(const std::vector<ExplicitStateDfa> &dfa_vector);
104 
112 
113 
123  static ExplicitStateDfa restrict_dfa_with_states(ExplicitStateDfa &d, std::vector<size_t> states);
124 
134  static ExplicitStateDfa
135  restrict_dfa_with_transitions(ExplicitStateDfa &d, std::unordered_map<size_t, CUDD::BDD> transitions,
136  std::shared_ptr<VarMgr> var_mgr);
137 
147 
148  private:
149  static std::vector<std::string>
150  traverse_bdd(CUDD::BDD dd, std::shared_ptr<VarMgr> var_mgr, std::vector<std::string> &names,
151  std::string guard_str);
152  };
153 
154 }
155 #endif //EXPLICITSTATEDFA_H
A DFA with explicit states and symbolic transitions.
Definition: ExplicitStateDfa.h:22
static ExplicitStateDfa dfa_minimize(const ExplicitStateDfa &d)
Minimize a given explicit-state DFA.
Definition: ExplicitStateDfa.cpp:437
void dfa_print()
Print the explicit-state DFA.
Definition: ExplicitStateDfa.cpp:23
ExplicitStateDfa & operator=(ExplicitStateDfa other)
Create an explicit-state DFA from an existing one using the opeartor =.
Definition: ExplicitStateDfa.h:56
ExplicitStateDfa(DFA *dfa, const std::vector< std::string > &names)
Create an explicit-state DFA from an Lydia DFA structure and the names of variables.
Definition: ExplicitStateDfa.h:41
static ExplicitStateDfa dfa_product_or(const std::vector< ExplicitStateDfa > &dfa_vector)
Take the product OR of a sequence of explicit-state DFAs.
Definition: ExplicitStateDfa.cpp:359
static ExplicitStateDfa restrict_dfa_with_states(ExplicitStateDfa &d, std::vector< size_t > states)
Restrict an explicit-state DFA with a given set of states.
Definition: ExplicitStateDfa.cpp:60
ExplicitStateDfa(const ExplicitStateDfa &other)
Create an explicit-state DFA from an existing one.
Definition: ExplicitStateDfa.h:48
ExplicitStateDfa(DFA *dfa, int nb_variables)
Create an explicit-state DFA from an Lydia DFA structure and the number of variables.
Definition: ExplicitStateDfa.h:31
static ExplicitStateDfa restrict_dfa_with_transitions(ExplicitStateDfa &d, std::unordered_map< size_t, CUDD::BDD > transitions, std::shared_ptr< VarMgr > var_mgr)
Restrict a DFA with a given set of transitions.
Definition: ExplicitStateDfa.cpp:173
static ExplicitStateDfa dfa_of_formula(const whitemech::lydia::LTLfFormula &formula)
Construct an explicit-state DFA from a given formula using Lydia.
Definition: ExplicitStateDfa.cpp:35
static ExplicitStateDfa dfa_complement(ExplicitStateDfa &d)
Complement a DFA.
Definition: ExplicitStateDfa.cpp:444
static ExplicitStateDfa dfa_product_and(const std::vector< ExplicitStateDfa > &dfa_vector)
Take the product AND of a sequence of explicit-state DFAs.
Definition: ExplicitStateDfa.cpp:282
int get_nb_variables()
Get the number of variables.
Definition: ExplicitStateDfa.h:70