Mungojerrie  1.0
Mungojerrie
LTS.hh
Go to the documentation of this file.
1 #ifndef LTS_HH_
2 #define LTS_HH_
3 
46 #include <string>
47 #include "cuddObj.hh"
48 #include "State.hh"
49 
54  template<typename T> friend class LTS;
55 public:
56  BaseTransition() {}
57  BaseTransition(State d, BDD l) : destination(d), label(l) {}
60  bool operator==(BaseTransition const &) const = delete;
64  bool operator<(BaseTransition const &) const = delete;
65  /* @brief Returns the destination of a transition. */
66  State getDestination(void) const { return destination; }
67  /* @brief Returns a copy of the label of a transition. */
68  BDD getLabel(void) const { return label; }
69 protected:
70  State destination;
71  BDD label;
72 };
73 
75 std::ostream & operator<<(std::ostream & os, BaseTransition const & p);
76 
83 template<typename Tran>
84 class LTS {
85 public:
86  using Transition = Tran;
87  using Edge = std::pair<State,Transition>;
88  using EdgeSet = std::set<Edge>;
89  using Delta = std::vector<Transition>;
91  using PairsStateBdd = std::set< std::pair<State,BDD>, Util::PairWithBddCompare<State>>;
93  using const_iterator = std::vector<State>::const_iterator;
95  const_iterator cbegin() { return states.cbegin(); }
97  const_iterator cend() { return states.cend(); }
98 
100  LTS(Cudd mgr);
102  size_t numStates(void) const { return states.size(); }
104  Cudd getManager(void) const { return mgr; }
106  void addState(State s, Delta delta = Delta{});
108  void addTransition(State source, State destination, BDD const & label);
110  void makeInitial(State s);
112  State getInitial(void) const { return initialState; }
114  void addAtomicProposition(BDD proposition, std::string name);
116  std::string getPropositionName(BDD proposition) const;
118  std::set<BDD, Util::BddCompare> getAtomicPropositions(void) const {
119  return varSet;
120  }
122  State getSuccessor(State source, BDD letter) const;
124  StateSet getSuccessors(State source, BDD letter) const;
126  StateSet getEpsilonSuccessors(State source) const;
128  bool checkTransitions(void) const;
130  void print(std::ostream & os = std::cout) const;
132  void letters(StateSet const & stateset, std::vector<BDD> & lv) const;
134  std::vector<BDD> getLetters(std::vector<State> const & statevec) const;
136  int readVerbosity(void) const { return verbosity; }
138  void setVerbosity(int v) { verbosity = v; }
140  bool isDeterministic(bool complete = true) const;
142  bool isComplete(void) const;
144  using SCCs = std::vector<StateSet>;
146  SCCs getSCCs(StateSet const & init, StateSet const & restriction,
147  EdgeSet const & forbiddenEdges) const;
149  SCCs getSCCs(StateSet const & init,
150  StateSet const & restriction) const;
152  SCCs getSCCs(StateSet const & restriction) const;
154  SCCs getSCCs(void) const;
156  void findTransient(std::vector<State> & transient, StateSet const & init,
157  StateSet const & restriction) const;
159  void findTransient(std::vector<State> & transient, StateSet const & restriction) const;
161  void findTransient(std::vector<State> & transient) const;
163  std::map<State,State> stateEquivalence(std::map<State,unsigned> const & outputClass) const;
165  void trim(StateSet const & targets);
168  void trim(StateSet const & targets, SCCs const & sccs);
170  void printDot(std::string graphname = std::string("LTS")) const;
172  LTS subsetsLTS(std::map<State,StateSet> & subsets) const;
174  void setEpsilonBDD(BDD const & e) { epsilon = e; }
176  BDD const & getEpsilonBDD(void) const { return epsilon; }
178  bool hasEpsilonTransitions(void) const { return !epsilon.IsZero(); }
180  LTS product(LTS const & second);
181 protected:
183  void mergeTransitions(void);
185  bool isTrivial(StateSet const & scc,
186  EdgeSet const & forbidden = EdgeSet{}) const;
188  void pruneVarSet(void);
189  using TransitionMap = std::map<State,Delta>;
190 
191  Cudd mgr;
192  int verbosity;
193  std::vector<State> states;
194  State initialState;
195  TransitionMap transitions;
196  std::set<BDD, Util::BddCompare> varSet;
197  BDD epsilon;
198 private:
199  class SccAnalyzer;
200  class PartitionRefinement;
201  class SubsetConstruction;
202 };
203 
205 template<typename T>
206 std::ostream & operator<<(std::ostream & os, LTS<T> const & l);
207 
209 template<typename Tran>
210 LTS<Tran> product(LTS<Tran> const & first, LTS<Tran> const & second);
211 
212 #endif
LTS::isDeterministic
bool isDeterministic(bool complete=true) const
Checks whether the LTS is deterministic.
Definition: LTS.cc:280
LTS::stateEquivalence
std::map< State, State > stateEquivalence(std::map< State, unsigned > const &outputClass) const
Returns state equivalence relation.
Definition: LTS.cc:936
LTS::getSCCs
SCCs getSCCs(void) const
Computes the SCCs of the LTS.
Definition: LTS.cc:579
LTS::getEpsilonBDD
const BDD & getEpsilonBDD(void) const
Gets the epsilon proposition for LDBWs.
Definition: LTS.hh:176
LTS::getAtomicPropositions
std::set< BDD, Util::BddCompare > getAtomicPropositions(void) const
Returns the set of atomic propositions.
Definition: LTS.hh:118
product
LTS< Tran > product(LTS< Tran > const &first, LTS< Tran > const &second)
Return product of two LTS's.
LTS< ParityTransition >::SCCs
std::vector< StateSet > SCCs
Type of the collection of SCCs.
Definition: LTS.hh:144
Util::PairWithBddCompare
Class that defines a comparison operator for pairs with BDDs.
Definition: Util.hh:101
LTS::makeInitial
void makeInitial(State s)
Makes a state initial.
Definition: LTS.cc:84
LTS::cend
const_iterator cend()
Returns a const_iterator pointing "just past the last" state.
Definition: LTS.hh:97
LTS::trim
void trim(StateSet const &targets)
Removes states with no path to target states.
Definition: LTS.cc:998
LTS::isComplete
bool isComplete(void) const
Checks whether the LTS is complete.
Definition: LTS.cc:316
LTS::hasEpsilonTransitions
bool hasEpsilonTransitions(void) const
Checks whether there exist epsilon transitions.
Definition: LTS.hh:178
LTS::setVerbosity
void setVerbosity(int v)
Sets the verbosity level of the LTS.
Definition: LTS.hh:138
LTS::setEpsilonBDD
void setEpsilonBDD(BDD const &e)
Sets the epsilon proposition for LDBWs.
Definition: LTS.hh:174
State.hh
Basic type definitions.
LTS::printDot
void printDot(std::string graphname=std::string("LTS")) const
Writes LTS in dot format.
Definition: LTS.cc:1006
LTS::checkTransitions
bool checkTransitions(void) const
Checks sanity of transitions.
Definition: LTS.cc:172
LTS::getPropositionName
std::string getPropositionName(BDD proposition) const
Returns name of an atomic proposition.
Definition: LTS.cc:104
LTS::getInitial
State getInitial(void) const
Returns the initial state of the LTS.
Definition: LTS.hh:112
LTS< ParityTransition >::const_iterator
std::vector< State >::const_iterator const_iterator
Constant iterator type.
Definition: LTS.hh:93
LTS::getLetters
std::vector< BDD > getLetters(std::vector< State > const &statevec) const
Alternate interface to letters.
Definition: LTS.cc:271
LTS::getEpsilonSuccessors
StateSet getEpsilonSuccessors(State source) const
Returns states reachable from source via epsilon transitions.
Definition: LTS.cc:155
operator<<
std::ostream & operator<<(std::ostream &os, BaseTransition const &p)
Overloads stream insertion operator.
LTS::mergeTransitions
void mergeTransitions(void)
Merge transitions that differ at most in their labels.
Definition: LTS.cc:190
LTS::print
void print(std::ostream &os=std::cout) const
Stream insertion operator helper function.
Definition: LTS.cc:350
LTS
Class of labeled transition systems.
Definition: LTS.hh:84
LTS::subsetsLTS
LTS subsetsLTS(std::map< State, StateSet > &subsets) const
Returns the result of the Rabin-Scott subset construction.
Definition: LTS.cc:1172
LTS::getSuccessor
State getSuccessor(State source, BDD letter) const
Returns successor of source state for input letter in deterministic LTS.
Definition: LTS.cc:119
BaseTransition
Base class for the labeled edges of the transition graph.
Definition: LTS.hh:53
LTS::numStates
size_t numStates(void) const
Returns the number of states in the LTS.
Definition: LTS.hh:102
LTS::LTS
LTS(Cudd mgr)
Constructor.
Definition: LTS.cc:56
BaseTransition::operator==
bool operator==(BaseTransition const &) const =delete
Checks whether two transitions have the same endpoints and label.
LTS::getManager
Cudd getManager(void) const
Returns the BDD manager of the LTS.
Definition: LTS.hh:104
LTS::addAtomicProposition
void addAtomicProposition(BDD proposition, std::string name)
Adds atomic proposition to model.
Definition: LTS.cc:91
LTS::isTrivial
bool isTrivial(StateSet const &scc, EdgeSet const &forbidden=EdgeSet{}) const
Check whether an SCC is trivial.
Definition: LTS.cc:1035
BaseTransition::operator<
bool operator<(BaseTransition const &) const =delete
Comparison function used to store transitions in ordered containers.
LTS::readVerbosity
int readVerbosity(void) const
Returns the verbosity level of the LTS.
Definition: LTS.hh:136
LTS::getSuccessors
StateSet getSuccessors(State source, BDD letter) const
Returns states reachable from source for input letter.
Definition: LTS.cc:138
LTS::findTransient
void findTransient(std::vector< State > &transient, StateSet const &init, StateSet const &restriction) const
Finds transient states of LTS reachable from init and contained in restriction.
LTS::addTransition
void addTransition(State source, State destination, BDD const &label)
Adds a transition to a state of the LTS.
Definition: LTS.cc:71
LTS< ParityTransition >::PairsStateBdd
std::set< std::pair< State, BDD >, Util::PairWithBddCompare< State > > PairsStateBdd
Type of sets of pairs of state and BDD.
Definition: LTS.hh:91
LTS::cbegin
const_iterator cbegin()
Returns a const_iterator pointing to the first state.
Definition: LTS.hh:95
LTS::pruneVarSet
void pruneVarSet(void)
Prune the variable set of unused atomic propositions.
Definition: LTS.cc:1057
second
State second
Model state.
Definition: Gym.hh:56
LTS::letters
void letters(StateSet const &stateset, std::vector< BDD > &lv) const
Returns the letters in the labels of a set of states.
Definition: LTS.cc:228
LTS::addState
void addState(State s, Delta delta=Delta{})
Adds a state to the LTS.
Definition: LTS.cc:60
LTS::product
LTS product(LTS const &second)
Returns the synchronous product of two LTSs.
Definition: LTS.cc:1227