Nwa.hpp

Go to the documentation of this file.
00001 #ifndef wali_nwa_NWA_GUARD
00002 #define wali_nwa_NWA_GUARD 1
00003 
00004 #include "opennwa/NwaFwd.hpp"
00005 
00006 /**
00007  * @author Amanda Burton
00008  */
00009 
00010 // ::wali
00011 #include "wali/Printable.hpp"
00012 #include "wali/Countable.hpp"
00013 #include "wali/KeyContainer.hpp"
00014 
00015 #include "opennwa/details/SymbolStorage.hpp"
00016 #include "opennwa/details/StateStorage.hpp"
00017 #include "opennwa/details/TransitionStorage.hpp"
00018 
00019 #include "wali/wpds/WPDS.hpp"
00020 #include "wali/wpds/RuleFunctor.hpp"
00021 #include "wali/wpds/Rule.hpp"
00022 
00023 #include "wali/Worklist.hpp"
00024 
00025 #include "opennwa/WeightGen.hpp"
00026 
00027 //#define USE_BUDDY
00028 #ifdef USE_BUDDY
00029 #  include "opennwa/RelationOpsBuddy.hpp"
00030 #else
00031 #  include "opennwa/RelationOps.hpp"
00032 #endif
00033 
00034 // std::c++
00035 #include <iostream>
00036 #include <sstream>
00037 #include <map>
00038 #include <deque>
00039 
00040 namespace opennwa
00041 {
00042     /**
00043      *
00044      * This class models nested word automata (NWA). 
00045      * Note: StName must be a unique identifier for states.
00046      *
00047      */
00048     class Nwa : public wali::Printable, public wali::Countable
00049     {
00050     private:
00051       typedef ClientInfo Client;
00052       typedef details::StateStorage StateStorage;
00053       typedef details::SymbolStorage SymbolStorage;
00054       typedef details::TransitionStorage Trans;
00055       typedef std::pair<State,State> StatePair;
00056 
00057       static std::string const XMLTag;
00058 
00059       
00060     public:
00061       // {{{ Typedefs
00062 
00063       ///
00064       /// @brief ref_ptr to a ClientInfo object
00065       typedef StateStorage::ClientInfoRefPtr ClientInfoRefPtr;
00066 
00067       /// @brief Iterator for traversing a set of states
00068       ///
00069       /// Dereferences to a 'State'. (This is used for the set of states, set
00070       /// of initial states, and set of accepting states.)
00071       typedef StateStorage::const_iterator StateIterator;
00072       
00073       ///
00074       /// @brief Iterator for traversing the set of symbols. Dereferences to a 'Symbol'
00075       typedef SymbolStorage::const_iterator SymbolIterator;
00076 
00077 
00078       /// @brief Represents a call transition
00079       ///
00080       /// Has the following fields:
00081       ///    Call::first    The call site (a State)
00082       ///    Call::second   The symbol (a Symbol)
00083       ///    Call::third    The entry (a State)
00084       typedef Trans::Call Call;
00085       
00086       /// @brief Represents an internal transition
00087       ///
00088       /// Has the following fields:
00089       ///    Internal::first    The source state (a State)
00090       ///    Internal::second   The symbol (a Symbol)
00091       ///    Internal::third    The target state (a State)
00092       typedef Trans::Internal Internal;
00093       
00094       /// @brief Represents a return transition
00095       ///
00096       /// Has the following fields:
00097       ///    Return::first    The exit site (a State)
00098       ///    Return::second   The call predecessor (a State)
00099       ///    Return::third    The symbol (a Symbol)
00100       ///    Return::fourth   The return site (a State)
00101       typedef Trans::Return Return;          
00102       
00103       typedef Trans::Calls Calls;
00104       typedef Trans::Internals Internals;
00105       typedef Trans::Returns Returns;
00106 
00107       ///
00108       /// @brief Iterator to a set of calls. Dereferences to a 'Call'.
00109       typedef Trans::CallIterator CallIterator;
00110       ///
00111       /// @brief Iterator to a set of internals. Dereferences to an 'Internal'
00112       typedef Trans::InternalIterator InternalIterator;
00113       ///
00114       /// @brief Iterator to a set of returns. Dereferences to a 'Return'
00115       typedef Trans::ReturnIterator ReturnIterator;
00116 
00117 
00118       /// @brief Represents a binary relation on states
00119       ///
00120       /// There are a couple possibilities for a concrete type for this,
00121       /// depending on whether you are using the (very experimental) BuDDY
00122       /// support or just std::maps. See the appropriate version of
00123       /// RelationOps.hpp.
00124       typedef wali::relations::RelationTypedefs<State>::BinaryRelation BinaryRelation;
00125 
00126       // }}}
00127 
00128 
00129 
00130     public:
00131 
00132 
00133       ///
00134       /// @brief Constructs an empty NWA
00135       Nwa( );
00136 
00137       /// @brief Copies 'other'. Does not share structure.
00138       ///
00139       /// Will clone the client info objects. TODO-RELEASE
00140       Nwa( const Nwa & other );
00141 
00142       /// @brief Assigns 'other' to this NWA. Does not share structure.
00143       ///
00144       /// Will clone the client info objects. TODO-RELEASE
00145       Nwa & operator=( const Nwa & other );
00146 
00147       /**
00148        * @brief Removes all states, symbols, and transitions from this NWA
00149        */
00150       void clear( );
00151 
00152       
00153       /**
00154        * Marshalls the NWA as XML to the output stream os
00155        */
00156       virtual std::ostream& marshall( std::ostream& os ) const;
00157 
00158 
00159       //State Accessors
00160 
00161       /**
00162        * 
00163        * @brief access the client information associated with the given state
00164        *
00165        * This method provides access to the client information associated with the given 
00166        * state.
00167        *
00168        * @param - state: the state whose client information to retrieve
00169        * @return the client information associated with the given state
00170        *
00171        */
00172       ClientInfoRefPtr getClientInfo( State state ) const;
00173 
00174       /**
00175        * 
00176        * @brief set the client information associated with the given state
00177        *
00178        * This method sets the client information associated with the given state to the 
00179        * client information provided.
00180        *
00181        * @param - state: the  state whose client information to set
00182        * @param - c: the desired client information for the given state
00183        *
00184        */
00185       void setClientInfo( State state, const ClientInfoRefPtr c );  
00186      
00187 
00188       
00189       //////////////////////////////
00190       // {{{ Query & Mutate States
00191 
00192       /// @brief Returns the set of states in the NWA
00193       ///
00194       /// @return The set of all states
00195       const StateSet & getStates( ) const;
00196 
00197       /// @brief Tests if a given state is in this NWA
00198       ///
00199       /// @param - state: the state to check
00200       /// @return true if the given state is a member of this NWA
00201       bool isState( State state ) const; 
00202 
00203       /// @brief Adds the given state to this NWA
00204       ///
00205       /// If the state is already a member of this NWA. returns false.
00206       /// Otherwise, returns true.
00207       ///
00208       /// @param - state: the state to add
00209       /// @return 'false' if the state already exists in the NWA, 'true' otherwise
00210       bool addState( State state );
00211 
00212       /// @brief Returns the number of states in this NWA
00213       ///
00214       /// Foo bar
00215       ///
00216       /// @return the number of states in this NWA
00217       size_t sizeStates( ) const;
00218 
00219       /// @brief Returns the largest state ID in the automaton
00220       ///
00221       /// @return the largest state ID in the automaton
00222       State largestState() const {
00223         return states.largestState();
00224       }
00225 
00226       /// @brief Removes the given state from this NWA along with any
00227       ///        associated transitions.
00228       ///
00229       ///
00230       /// This removes 'state' from the set of initial and final states as
00231       /// well as the set of all states. It also removes any transitions (of
00232       /// any type) with 'state' as a component.
00233       ///
00234       /// If 'state' is not present, this command is a no-op (except for the
00235       /// return value). The return value indicates whether the state was
00236       /// actually removed.
00237       ///
00238       /// @param - state: the state to remove
00239       /// @return false if the state did not exist in the NWA, true otherwise
00240       virtual bool removeState( State state );
00241 
00242       
00243       /// @brief remove all states and transitions from the NWA
00244       ///
00245       /// This method removes all states and transitions from the NWA.
00246       void clearStates( );
00247 
00248       // }}}
00249       
00250 
00251       // {{{ Query & Mutate Initial States
00252 
00253       /// @brief Returns the set of initial states
00254       ///
00255       /// (Note: An NWA can have an unbounded number of inital states.)
00256       ///
00257       /// @return the set of inital states associated with the NWA
00258       const StateSet & getInitialStates( ) const; 
00259 
00260       /**
00261        * @brief test if the given state is an initial state of this NWA
00262        *
00263        * @param - state: the state to check
00264        * @return true if the given state is an initial state, false otherwise
00265        */
00266       bool isInitialState( State state ) const;
00267 
00268       /// @brief Makes the given state an initial state in this NWA (adding
00269       ///        it to the NWA if necessary).
00270       ///
00271       /// This method checks whether 'state' is in the state set of this NWA.
00272       /// If the state is not present, it is added to the automaton.  In
00273       /// either case, the given state is then added to the set of initial
00274       /// states for the NWA.
00275       ///
00276       /// Returns whether the state was added to the set of initial
00277       /// states. (The return value is 'true' if it was not already an
00278       /// initial state regardless of whether it needed to be added to the
00279       /// machine or not.)
00280       ///
00281       /// @param - state: the state to add to initial state set
00282       /// @return false if the state already exists in the initial state set of the NWA
00283       bool addInitialState( State state );
00284 
00285       /// @brief Returns the number of initial states in this NWA
00286       ///
00287       /// @return the number of initial states in this NWA
00288       size_t sizeInitialStates( ) const;
00289 
00290       /// @brief Removes the given state from the set of initial states.
00291       ///
00292       /// If 'state' is not already an initial state, this function is a
00293       /// no-op (except for the return value), even if 'state' is not in the
00294       /// NWA at all.
00295       ///
00296       /// The return value indicates whether 'state' was an initial state.
00297       ///
00298       /// (This method does not remove any transitions from the NWA, nor does
00299       /// it remove the state from the NWA entirely.)
00300       ///
00301       /// @param - state: the state to remove from the initial state set
00302       /// @return false if the state does not exist in the initial state set of this NWA
00303       bool removeInitialState( State state );
00304 
00305       /// @brief Clears the set of initial states
00306       ///
00307       /// (This function does not remove any states or transitions from the
00308       /// automaton, it just affects the set of initial states.)
00309       void clearInitialStates( );
00310 
00311       // }}}
00312 
00313       // {{{ Query and Mutate Final States
00314 
00315       /// @brief Returns the set of final states
00316       ///
00317       /// (Note: An NWA can have an unbounded number of inital states.)
00318       ///
00319       /// @return the set of inital states associated with the NWA
00320       const  StateSet & getFinalStates( ) const;
00321 
00322       /**
00323        * @brief test if a state with the given name is a final state
00324        *
00325        * This method tests whether the given state is in the final state set
00326        * of the NWA.
00327        *
00328        * @param - state: the state to check
00329        * @return true if the given state is a final state
00330        */
00331       bool isFinalState( State state ) const;
00332 
00333       /// @brief Makes the given state an final state in this NWA (adding
00334       ///        it to the NWA if necessary).
00335       ///
00336       /// This method checks whether 'state' is in the state set of this NWA.
00337       /// If the state is not present, it is added to the automaton.  In
00338       /// either case, the given state is then added to the set of final
00339       /// states for the NWA.
00340       ///
00341       /// Returns whether the state was added to the set of final
00342       /// states. (The return value is 'true' if it was not already a final
00343       /// state regardless of whether it needed to be added to the machine or
00344       /// not.)
00345       ///
00346       /// @param - state: the state to add to final state set
00347       /// @return false if the state already exists in the final state set of the NWA
00348       bool addFinalState( State state );
00349 
00350       /// @brief Returns the number of final states in this NWA
00351       ///
00352       /// @return the number of final states in this NWA
00353       size_t sizeFinalStates( ) const;
00354 
00355       /// @brief Removes the given state from the set of final states.
00356       ///
00357       /// If 'state' is not already an final state, this function is a
00358       /// no-op (except for the return value), even if 'state' is not in the
00359       /// NWA at all.
00360       ///
00361       /// The return value indicates whether 'state' was an final state.
00362       ///
00363       /// (This method does not remove any transitions from the NWA, nor does
00364       /// it remove the state from the NWA entirely.)
00365       ///
00366       /// @param - state: the state to remove from the final state set
00367       /// @return false if the state does not exist in the final state set of this NWA
00368       bool removeFinalState( State state );
00369 
00370       /// @brief Clears the set of final states
00371       ///
00372       /// (This function does not remove any states or transitions from the
00373       /// automaton, it just affects the set of final states.)
00374       void clearFinalStates( );
00375 
00376       // }}}
00377 
00378 
00379       // {{{ Query and Mutate Symbols
00380 
00381       /// @brief Returns the set of (non-epsilon, non-wild) symbols in this NWA.
00382       ///
00383       /// Note: Not all symbols need to be used on a transition. (This
00384       /// function will still return them.)
00385       ///
00386       /// @return set of all symbols in this NWA
00387       const  SymbolSet & getSymbols( ) const;
00388 
00389       /// @brief Tests whether the given symbol is a member the NWA.
00390       ///
00391       /// This returns 'false' for EPSILON and WILD, even if they
00392       /// are used on a transition.
00393       ///
00394       /// @param - sym: the symbol to check
00395       /// @return true if the given symbol is associated with the NWA
00396       bool isSymbol( Symbol sym ) const;
00397 
00398       /// @brief Adds the given symbol to the NWA.
00399       ///
00400       /// If 'sym' is already present in the NWA, this function is a
00401       /// no-op. It is also a no-op if 'sym' is either 'EPSILON' or
00402       /// 'WILD'.
00403       ///
00404       /// The return value indicates whether 'sym' was added.
00405       ///
00406       /// @param - sym: the symbol to add
00407       /// @return false if the symbol is already associated with the NWA
00408       bool addSymbol( Symbol sym );
00409 
00410       /// @brief Returns the number of symbols in this NWA (excluding epsilon
00411       ///        and wild).
00412       ///
00413       /// Symbols in the automaton are counted regardless of whether they are
00414       /// used to label any transitions. Neither 'EPSILON' nor
00415       /// 'WILD' are included in this count at all, regardless of
00416       /// whether they are used to label transitions or not.
00417       ///
00418       /// @return The number of symbols in this NWA
00419       size_t sizeSymbols( ) const;
00420 
00421       /// @brief Remove the given symbol from the NWA along with any
00422       ///        associated transitions.
00423       ///
00424       /// Removes 'sym' from the symbol set of the NWA as well as any
00425       /// transitions that have 'sym' as the symbol component.
00426       ///
00427       /// If 'sym' is not present, this command is a no-op; the return value
00428       /// indicates whether this was the case.
00429       ///
00430       /// @param - sym: the symbol to remove
00431       /// @return false if the symbols was not in the NWA
00432       bool removeSymbol( Symbol sym );
00433 
00434       /// @brief Remove all symbols and transitions from the NWA
00435       ///
00436       /// This method removes all symbols and all transitions from the
00437       /// NWA. It does not touch any states.
00438       ///
00439       /// (Note: this also removes all transitions labeled with
00440       /// 'EPSILON' and 'WILD' even though this perhaps needn't be
00441       /// the case.)
00442       void clearSymbols( );
00443 
00444       // }}}
00445 
00446       
00447 
00448       /// Please don't call this, in case that's not evident from the
00449       /// name. It's const, so you won't break the NWA, but I make no
00450       /// guarantees it'll be around in future versions.
00451       Trans const & _private_get_transition_storage_() const  {
00452         return trans;
00453       }
00454       
00455 
00456       /**
00457        *    
00458        * @brief duplicates the original state, but only duplicates outgoing transitions
00459        *
00460        * This method assigns to the duplicate state all the state properties of the 
00461        * original state and duplicates all outgoing transitions of the original state for 
00462        * the duplicate state.  Further, any self-loop outgoing transitions that the 
00463        * original state are not only duplicated as self-loop transitions for the duplicate 
00464        * state, but the duplicate state also has transitions to the original state for 
00465        * each such transition. 
00466        *
00467        * @param - orig: the name of the original state, i.e. the state to duplicate
00468        * @param - dup: the name of the duplicate state
00469        *
00470        */
00471       void duplicateStateOutgoing( State orig, State dup );
00472 
00473       /**
00474        * 
00475        * @brief duplicates the original state
00476        *
00477        * This method assigns to the duplicate state all the state properties of the 
00478        * original state and duplicates all transitions of the original state for the 
00479        * duplicate state.  Further, any self-loop transitions that the original state are 
00480        * not only duplicated as self-loop transitions for the duplicate state, but the 
00481        * duplicate state also has transitions to and from the original state for each 
00482        * such transition.
00483        *
00484        * @param - orig: the name of the original state, i.e. the state to duplicate
00485        * @param - dup: the name of the duplicate state
00486        *
00487        */
00488       void duplicateState( State orig, State dup );
00489 
00490 
00491       /**
00492        *  
00493        * @brief realizes all implicit transitions in the NWA
00494        *
00495        * This method makes explicit all transitions in the NWA by adding the
00496        * given stuckState (if necessary) then any transitions to the stuck
00497        * state for each state/symbol(excluding epsilon) pair for which no
00498        * outgoing edge(one of each kind-call,internal,return) from that state
00499        * is labeled with that symbol.
00500        *
00501        */
00502       void realizeImplicitTrans(State stuckState);
00503 
00504       
00505       /// @brief Returns the number of transitions in this NWA (regardless of
00506       ///        type).
00507       ///
00508       /// @return the number of transitions in this NWA
00509       size_t sizeTrans( ) const;
00510 
00511       /// @brief Removes all transitions from this NWA.
00512       ///
00513       /// This function does not remove any states or symbols.
00514       void clearTrans( );
00515       
00516 
00517       // {{{ Query and Mutate Internal Transitions
00518 
00519       /// @brief Adds a internal transition to the NWA.
00520       ///
00521       /// If the internal transition is already present, this function is a
00522       /// no-op (other than the return value). The return value indicates
00523       /// whether the transition was successfully added.
00524       ///
00525       /// Note: 'sym' cannot be EPSILON.
00526       ///
00527       /// @param - from: the state the edge departs from
00528       /// @param - sym: the symbol labeling the edge
00529       /// @param - to: the state the edge arrives to  
00530       /// @return false if the internal transition already exists in the NWA
00531       bool addInternalTrans( State from, Symbol sym, State to );
00532 
00533       /// @brief Adds a internal transition to the NWA.
00534       ///
00535       /// If the internal transition is already present, this function is a
00536       /// no-op (other than the return value). The return value indicates
00537       /// whether the transition was successfully added.
00538       ///
00539       /// @param - ct: the internal transition to add
00540       /// @return false if the internal transition already exists in the NWA
00541       bool addInternalTrans( Internal & ct );
00542 
00543       /// @brief Removes the given internal transition from the NWA.
00544       ///
00545       /// Removes the specified internal transition from the NWA, if
00546       /// present. If it was not present, this function is a no-op (apart
00547       /// from the return value). The return value indicates whether the
00548       /// transition was successfully removed.
00549       ///
00550       /// @param - from: the state the edge departs from
00551       /// @param - sym: the symbol labeling the edge
00552       /// @param - to: the state the edge arrives to  
00553       /// @return false if the internal transition does not exist in the NWA
00554       bool removeInternalTrans( State from, Symbol sym, State to );
00555 
00556       /// @brief Removes the given internal transition from the NWA.
00557       ///
00558       /// Removes the specified internal transition from the NWA, if
00559       /// present. If it was not present, this function is a no-op (apart
00560       /// from the return value). The return value indicates whether the
00561       /// transition was successfully removed.
00562       ///
00563       /// @param - ct: the internal transition to remove
00564       /// @return false if the internal transition does not exist in the NWA
00565       bool removeInternalTrans( const Internal & ct );
00566 
00567       /// @brief Returns the number of internal transitions in this NWA
00568       ///
00569       /// @return the number of internal transitions in this NWA
00570       size_t sizeInternalTrans( ) const;
00571 
00572       // }}}
00573 
00574 
00575       // {{{ Query and Mutate Call Transitions
00576 
00577       /// @brief Adds a call transition to the NWA.
00578       ///
00579       /// If the call transition is already present, this function is a no-op
00580       /// (other than the return value). The return value indicates whether
00581       /// the transition was successfully added.
00582       ///
00583       /// Note: 'sym' cannot be EPSILON.
00584       ///
00585       /// @param - call: the state the edge departs from
00586       /// @param - sym: the symbol labeling the edge
00587       /// @param - entry: the state the edge arrives to  
00588       /// @return false if the call transition already exists in the NWA
00589       bool addCallTrans( State call, Symbol sym, State entry );
00590 
00591       /// @brief Adds a call transition to the NWA.
00592       ///
00593       /// If the call transition is already present, this function is a no-op
00594       /// (other than the return value). The return value indicates whether
00595       /// the transition was successfully added.
00596       ///
00597       /// @param - ct: the call transition to add
00598       /// @return false if the call transition already exists in the NWA
00599       bool addCallTrans( Call & ct );
00600 
00601       /// @brief Removes the given call transition from the NWA.
00602       ///
00603       /// Removes the specified call transition from the NWA, if present. If
00604       /// it was not present, this function is a no-op (apart from the return
00605       /// value). The return value indicates whether the transition was
00606       /// successfully removed.
00607       ///
00608       /// @param - call: the state the edge departs from
00609       /// @param - sym: the symbol labeling the edge
00610       /// @param - entry: the state the edge arrives to  
00611       /// @return false if the call transition does not exist in the NWA
00612       bool removeCallTrans( State call, Symbol sym, State entry );
00613 
00614       /// @brief Removes the given call transition from the NWA.
00615       ///
00616       /// Removes the specified call transition from the NWA, if present. If
00617       /// it was not present, this function is a no-op (apart from the return
00618       /// value). The return value indicates whether the transition was
00619       /// successfully removed.
00620       ///
00621       /// @param - ct: the call transition to remove
00622       /// @return false if the call transition does not exist in the NWA
00623       bool removeCallTrans( const Call & ct );
00624 
00625       /// @brief Returns the number of call transitions in this NWA
00626       ///
00627       /// @return the number of call transitions in this NWA
00628       size_t sizeCallTrans( ) const;
00629 
00630       // }}}
00631 
00632       // {{{ Query and Mutate Return Transitions
00633 
00634       /// @brief Adds a return transition to the NWA.
00635       ///
00636       /// If the return transition is already present, this function is a
00637       /// no-op (other than the return value). The return value indicates
00638       /// whether the transition was successfully added.
00639       ///
00640       /// Note: 'sym' cannot be EPSILON.
00641       ///
00642       /// @param - exit: the state the edge departs from
00643       /// @param - sym: the symbol labeling the edge
00644       /// @param - ret: the state the edge arrives to  
00645       /// @return false if the return transition already exists in the NWA
00646       bool addReturnTrans( State exit, State pred, Symbol sym, State ret );
00647 
00648       /// @brief Adds a return transition to the NWA.
00649       ///
00650       /// If the return transition is already present, this function is a
00651       /// no-op (other than the return value). The return value indicates
00652       /// whether the transition was successfully added.
00653       ///
00654       /// @param - ct: the return transition to add
00655       /// @return false if the return transition already exists in the NWA
00656       bool addReturnTrans( Return & ct );
00657 
00658       /// @brief Removes (possibly multiple) matching return transition from
00659       ///        the NWA.
00660       ///
00661       /// Removes any return transition in the NWA with the given 'exit'
00662       /// state, symbol, and 'ret'urn state. If none were present, this
00663       /// function is a no-op (apart from the return value). The return value
00664       /// indicates whether any transition was successfully removed.
00665       ///
00666       /// @param - exit: the state the edge departs from
00667       /// @param - sym: the symbol labeling the edge
00668       /// @param - to: the state the edge arrives to  
00669       /// @return false if the return transition does not exist in the NWA
00670       bool removeReturnTrans( State exit, Symbol sym, State ret );
00671 
00672       /// @brief Removes the given return transition from the NWA.
00673       ///
00674       /// Removes the specified return transition from the NWA, if
00675       /// present. If it was not present, this function is a no-op (apart
00676       /// from the return value). The return value indicates whether the
00677       /// transition was successfully removed.
00678       ///
00679       /// @param - exit: the state the edge departs from
00680       /// @param - sym: the symbol labeling the edge
00681       /// @param - to: the state the edge arrives to  
00682       /// @return false if the return transition does not exist in the NWA
00683       bool removeReturnTrans( State exit, State pred, Symbol sym, State ret );
00684 
00685       /// @brief Removes the given return transition from the NWA.
00686       ///
00687       /// Removes the specified return transition from the NWA, if
00688       /// present. If it was not present, this function is a no-op (apart
00689       /// from the return value). The return value indicates whether the
00690       /// transition was successfully removed.
00691       ///
00692       /// @param - ct: the return transition to remove
00693       /// @return false if the return transition does not exist in the NWA
00694       bool removeReturnTrans( const Return & ct );
00695 
00696       /// @brief Returns the number of return transitions in this NWA
00697       ///
00698       /// @return the number of return transitions in this NWA
00699       size_t sizeReturnTrans( ) const;
00700 
00701       // }}}
00702 
00703       
00704 
00705       //Building NWAs
00706 
00707 
00708       /***
00709        * @brief constructs an NWA which is the projection of the given NWA to the states
00710        * provided
00711        */
00712       void projectStates(Nwa const & first, StateSet const & prjStates);
00713 
00714 
00715       
00716       //TODO: write comments
00717       virtual bool isTransitionPossible( const State &src, const Symbol &sym, const State &tgt);
00718 
00719       
00720 
00721       /**
00722        * @brief Detects (immediately) stuck states and removes them
00723        *
00724        * Detects stuck states and removes them, leaving the transitions implicit.
00725        * (It only figures this for states that have no outgoing transitions other
00726        * than itself; you can still have a SCC that acts as a stuck state.)
00727        */ 
00728       void removeImplicitTransitions();
00729 
00730 
00731       // pruning functions
00732 
00733       /**
00734        * Removes states not reachable from any of the 'sources' states
00735        * 
00736        */
00737       void pruneUnreachableForward(const StateSet & sources);
00738 
00739       /**
00740        * Removes states from which none of the 'targets' are reachable.
00741        */
00742       void pruneUnreachableBackward(const StateSet & targets);
00743 
00744       /**
00745        * Removes states not reachable from any initial state
00746        * 
00747        */
00748       void pruneUnreachableInitial();
00749 
00750       /**
00751        * Removes states from which none of the final states are reachable.
00752        */
00753 
00754       void pruneUnreachableFinal();
00755 
00756       /**
00757        * Removes states not reachable from any initial state
00758        * and from which none of the final states are reachable.
00759        */
00760       void chop();       
00761 
00762 
00763       // {{{ Deprecated construction functions (& private cheater functions)
00764       void _private_star_( Nwa const & first );
00765       void _private_determinize_( Nwa const & nondet );
00766       void _private_intersect_( Nwa const & first, Nwa const & second );
00767       // }}}
00768       
00769       bool _private_isDeterministic_() const;
00770 
00771       // {{{ intersection callbacks
00772       
00773       /**
00774        * @brief Intersects client information for the target of a call
00775        *        transition.
00776        *
00777        * This method intersects the client information associated with the states 'entry1'
00778        * and 'entry2' given that the transition that is being created is a call transition 
00779        * with the given symbol using the information in the given states and sets the 
00780        * resulting client information.
00781        *
00782        * Note: This method should only be used to intersect client information for states 
00783        *        immediately following a call transition.
00784        *
00785        * This function is called during the exceution of
00786        * 'construct::intersect'. (This is an instance of the "template
00787        * method" design pattern.)
00788        *
00789        * @param - first: the NWA in which to look up the client information for 
00790        *                'call1' and 'entry1'
00791        * @param - call1: the call site associated with the first entry whose client 
00792        *                  information to intersect
00793        * @param - entry1: the first entry point whose client information to intersect
00794        * @param - second: the NWA in which to look up the client information for
00795        *                  'call2' and 'entry2'
00796        * @param - call2: the call site associated with the second entry whose client
00797        *                  information to intersect
00798        * @param - entry2: the second entry point whose client information to intersect
00799        * @param - resSym: the symbol associated with the transition that is being created
00800        * @param - resSt: the state which will receive the computed client information
00801        */
00802       virtual void intersectClientInfoCall( Nwa const & first, State call1, State entry1, 
00803                                             Nwa const & second, State call2, State entry2, 
00804                                             Symbol resSym, State resSt );  
00805 
00806       /**
00807        * 
00808        * @brief Intersects client information for the target of an internal
00809        *        transition.
00810        *
00811        * This method intersects the client information associated with the states 'tgt1' and
00812        * 'tgt2' given that the transition that is being created is an internal transition 
00813        * with the given symbol using the information in the given states and returns the 
00814        * resulting client information.
00815        * Note: This method should only be used to intersect client information for states 
00816        *        immediately following an internal transition.
00817        *
00818        * This function is called during the exceution of
00819        * 'construct::intersect'. (This is an instance of the "template
00820        * method" design pattern.)
00821        *
00822        * @param - first: the NWA in which to look up the client information for 
00823        *                'src1' and 'tgt1'
00824        * @param - src1: the source associated with the first target whose client 
00825        *                  information to intersect
00826        * @param - tgt1: the first target whose client information to intersect
00827        * @param - second: the NWA in which to look up the client information for
00828        *                'src2' and 'tgt2'
00829        * @param - src2: the source associated with the second target whose client
00830        *                  information to intersect
00831        * @param - tgt2: the second target whose client information to intersect
00832        * @param - resSym: the symbol associated with the transition that is being created
00833        * @param - resSt: the state which will receive the computed client information
00834        *
00835        */
00836       virtual void intersectClientInfoInternal( Nwa const & first, State src1, State tgt1, 
00837                                                 Nwa const & second, State src2, State tgt2, 
00838                                                 Symbol resSym, State resSt );  
00839 
00840       /**
00841        * 
00842        * @brief Intersects client information for the target of a return
00843        *        transition.
00844        *
00845        * This method intersects the client information associated with the states 'ret1' and
00846        * 'ret2' given that the transition that is being created is a return transition with
00847        * the given symbol using the information in the given states and returns the 
00848        * resulting client information.
00849        * Note: This method should only be used to intersect client information for states 
00850        *        immediately following a return transition.
00851        *
00852        * This function is called during the exceution of
00853        * 'construct::intersect'. (This is an instance of the "template
00854        * method" design pattern.)
00855        *
00856        * @param - first: the NWA in which to look up the client information for 
00857        *                'exit1', 'call1', and 'ret1'
00858        * @param - exit1: the exit point associated with the first return site whose client 
00859        *                  information to intersect
00860        * @param - call1: the call site associated with the first return site whose client
00861        *                  information to intersect
00862        * @param - ret1: the first return site whose client information to intersect
00863        * @param - second: the NWA in which to look up the client information for
00864        *                'exit2', 'call2', and 'ret2'
00865        * @param - exit2: the exit point associated with the second return site whose client
00866        *                  information to intersect
00867        * @param - call2: the call site associated with the second return site whose client
00868        *                  information to intersect
00869        * @param - ret2: the second return site whose client information to intersect
00870        * @param - resSym: the symbol associated with the transition that is being created
00871        * @param - resSt: the state which will receive the computed client information
00872        *
00873        */
00874       virtual void intersectClientInfoReturn( Nwa const & first, State exit1, State call1, State ret1,
00875                                               Nwa const & second, State exit2, State call2, State ret2,
00876                                               Symbol resSym, State resSt );
00877 
00878       /**
00879        * 
00880        * @brief Intersect states
00881        * 
00882        * This method determines whether the given states can be intersected and returns the result
00883        * in the reference parameter 'resSt'.
00884        *
00885        * This function is called during the exceution of
00886        * 'construct::intersect'. (This is an instance of the "template
00887        * method" design pattern.)
00888        *
00889        * @param - first: the NWA in which to look up information about 'state1'
00890        * @param - state1: the first state to intersect
00891        * @param - second: the NWA in which to look up information about 'state2'
00892        * @param - state2: the second state to intersect
00893        * @param - resSt: the state that results from performing the intersection
00894        * @param - resCI: the client info that results from performing the intersection
00895        *
00896        */
00897       virtual bool stateIntersect( Nwa const & first, State state1, Nwa const & second, State state2,
00898                                    State & resSt, ClientInfoRefPtr & resCI );
00899 
00900       /**
00901        * 
00902        * @brief Intersect symbols
00903        * 
00904        * This method performs the intersection of the given symbols and returns the result
00905        * in the reference parameter 'resSym'.
00906        *
00907        * This function is called during the exceution of
00908        * 'construct::intersect'. (This is an instance of the "template
00909        * method" design pattern.)
00910        *
00911        * @param - first: the NWA in which to look up information about 'sym1'
00912        * @param - sym1: the first symbol to intersect
00913        * @param - second: the NWA in which to look up information about 'sym2'
00914        * @param - sym2: the second symbol to intersect
00915        * @param - resSym: the symbol that results from performing the intersection
00916        *
00917        */
00918       virtual bool transitionIntersect( Nwa const & first, Symbol sym1, Nwa const & second, Symbol sym2,
00919                                         Symbol & resSym );
00920 
00921       // }}}
00922       
00923       // {{{ determinization callbacks
00924 
00925       /**
00926        * 
00927        * @brief Merges clientInfo for determinize
00928        * 
00929        * This method merges the client info for the given states and returns the result in the 
00930        * reference parameter 'resCI'.
00931        *
00932        * This function is called during the exceution of
00933        * 'construct::determinize'. (This is an instance of the "template
00934        * method" design pattern.)
00935        *
00936        * @param - nwa: the NWA in which to look up information about the states
00937        * @param - binRel: the states to merge
00938        * @param - resSt: the state resulting from the merge
00939        * @param - resCI: the client info that results from performing the merge
00940        *
00941        */
00942       virtual void mergeClientInfo( Nwa const & nwa, 
00943                                     BinaryRelation const & binRel, 
00944                                     State resSt, ClientInfoRefPtr & resCI );
00945 
00946       /**
00947        * 
00948        * @brief Merges clientInfo for determinize for the target of a call
00949        *        transition.
00950        * 
00951        * This method merges the client info for the given entry states given that the transition
00952        * that is being created is a call transition with the given symbol using the information in 
00953        * the given states and returns the result in the reference parameter 'resCI'.
00954        *
00955        * @param - nwa: the NWA in which to look up information about the states
00956        * @param - binRelCall: the states that compose the call site for this call transition
00957        * @param - binRelEntry: the states to merge that compose the entry point for this call transition
00958        * @param - callSt: the call site of the transition that is being created
00959        * @param - resSym: the symbol associated with the transition that is being created
00960        * @param - resSt: the state resulting from the merge
00961        * @param - resCI: the client info that results from performing the merge
00962        *
00963        */
00964       virtual void mergeClientInfoCall( Nwa const & nwa, 
00965                                         BinaryRelation const & binRelCall, 
00966                                         BinaryRelation const & binRelEntry,
00967                                         State callSt, Symbol resSym, State resSt, ClientInfoRefPtr & resCI );
00968 
00969       /**
00970        * 
00971        * @brief Merges clientInfo for determinize for the target of an
00972        *        internal transition.
00973        * 
00974        * This method merges the client info for the given target states given that the transition
00975        * that is being created is an internal transition with the given symbol using the information in 
00976        * the given states and returns the result in the reference parameter 'resCI'.
00977        *
00978        * This function is called during the exceution of
00979        * 'construct::determinize'. (This is an instance of the "template
00980        * method" design pattern.)
00981        *
00982        * @param - nwa: the NWA in which to look up information about the states
00983        * @param - binRelSource: the states that compose the source for this internal transition
00984        * @param - binRelTarget: the states to merge that compose the target for this internal transition
00985        * @param - sourceSt: the source of the transition that is being created
00986        * @param - resSym: the symbol associated with the transition that is being created
00987        * @param - resSt: the state resulting from the merge
00988        * @param - resCI: the client info that results from performing the merge
00989        *
00990        */
00991       virtual void mergeClientInfoInternal( Nwa const & nwa, 
00992                                             BinaryRelation const & binRelSource, 
00993                                             BinaryRelation const & binRelTarget,
00994                                             State sourceSt, Symbol resSym, State resSt, ClientInfoRefPtr & resCI );
00995 
00996       /**
00997        * 
00998        * @brief Merges clientInfo for determinize for the target of a return
00999        *        transition.
01000        * 
01001        * This method merges the client info for the given return states given that the transition
01002        * that is being created is a return transition with the given symbol using the information in 
01003        * the given states and returns the result in the reference parameter 'resCI'.
01004        *
01005        * This function is called during the exceution of
01006        * 'construct::determinize'. (This is an instance of the "template
01007        * method" design pattern.)
01008        *
01009        * @param - nwa: the NWA in which to look up information about the states
01010        * @param - binRelExit: the states that compose the exit point for this return transition
01011        * @param - binRelCall: the states that compose the call site for this return transition
01012        * @param - binRelReturn: the states to merge that compose the return site for this return transition
01013        * @param - exitSt: the exit point of the transition that is being created
01014        * @param - callSt: the call site of the transition that is being created
01015        * @param - resSym: the symbol associated with the transition that is being created
01016        * @param - resSt: the state resulting from the merge
01017        * @param - resCI: the client info that results from performing the merge
01018        *
01019        */
01020       virtual void mergeClientInfoReturn( Nwa const & nwa, 
01021                                           BinaryRelation const & binRelExit,
01022                                           BinaryRelation const & binRelCall, 
01023                                           BinaryRelation const & binRelReturn,
01024                                           State exitSt, State callSt, Symbol resSym, State resSt, ClientInfoRefPtr & resCI );
01025 
01026       // }}}
01027 
01028 
01029       //Using NWAs
01030       // {{{ deprecated nwa_pds functions (and cheater functions)
01031       wali::wpds::WPDS _private_NwaToPdsReturns_( WeightGen const & wg ) const;
01032       wali::wpds::WPDS _private_NwaToBackwardsPdsReturns_( WeightGen const & wg ) const;
01033       wali::wpds::WPDS _private_NwaToPdsCalls_( WeightGen const & wg,
01034                                                 ref_ptr<wali::wpds::Wrapper> wrapper ) const;
01035       wali::wpds::WPDS _private_NwaToBackwardsPdsCalls_( WeightGen const & wg ) const;
01036       // }}}
01037 
01038       
01039       /**
01040        *
01041        * @brief tests whether the language accepted by this NWA is empty
01042        *
01043        * This method tests whether the language accepted by this NWA is empty.
01044        *
01045        * @return true if the language accepted by this NWA is empty
01046        *
01047        */
01048       bool _private_isEmpty_( ) const;
01049 
01050 
01051       const char * toStringGdb() const;
01052 
01053 
01054       /**
01055        *
01056        * @brief perform the prestar reachability query defined by the given WFA
01057        *
01058        * This method performs the prestar reachability query defined by the given WFA.
01059        *
01060        * @param - input: the starting point of the reachability query
01061        * @param - wg: the functions to use in generating weights
01062        * @return the WFA resulting from performing the prestar reachability query 
01063        *
01064        */
01065       wali::wfa::WFA prestar( wali::wfa::WFA const & input,
01066                               WeightGen const & wg ) const
01067       {
01068         return prestar(input, wg, NULL);
01069       }
01070 
01071       virtual wali::wfa::WFA prestar( wali::wfa::WFA const & input,
01072                                       WeightGen const & wg,
01073                                       ref_ptr< wali::Worklist<wali::wfa::ITrans> > worklist) const;
01074 
01075       /**
01076        *
01077        * @brief perform the prestar reachability query defined by the given WFA
01078        *
01079        * This method performs the prestar reachability query defined by the given WFA.
01080        * The result of the query is stored in the 'output' parameter. 
01081        * Note: Any transitions in output before the query will be there after the query but
01082        * will have no effect on the reachability query.
01083        *
01084        * @param - input: the starting point of the reachability query
01085        * @param - ouput: the result of performing the reachability query
01086        * @param - wg: the functions to use in generating weights
01087        *
01088        */
01089       void prestar( wali::wfa::WFA const & input,
01090                     wali::wfa::WFA & output,
01091                     WeightGen const & wg ) const
01092       {
01093         prestar(input, output, wg, NULL);
01094       }
01095 
01096       virtual void prestar( wali::wfa::WFA const & input,
01097                             wali::wfa::WFA & output,
01098                             WeightGen const & wg,
01099                             ref_ptr< wali::Worklist<wali::wfa::ITrans> > worklist) const;
01100 
01101       /**
01102        *
01103        * @brief perform the poststar reachability query defined by the given WFA
01104        *
01105        * This method performs the poststar reachability query defined by the given WFA.
01106        *
01107        * @param - input: the starting point of the reachability query
01108        * @param - wg: the functions to use in generating weights
01109        * @return the WFA resulting from performing the poststar reachability query
01110        *
01111        */
01112       wali::wfa::WFA poststar( wali::wfa::WFA const & input,
01113                          WeightGen const & wg ) const
01114       {
01115         return poststar(input, wg, NULL);
01116       }
01117 
01118 
01119       virtual wali::wfa::WFA poststar( wali::wfa::WFA const & input,
01120                                  WeightGen const & wg,
01121                                  ref_ptr< wali::Worklist<wali::wfa::ITrans> > wl) const;
01122 
01123 
01124       /**
01125        *
01126        * @brief perform the poststar reachability query defined by the given WFA
01127        * 
01128        * This method performs the poststar reachability query defined by the given WFA.
01129        * The result of the query is stored in the 'output' parameter.
01130        * Note: Any transitions in output before the query will be there after the query but
01131        * will have no effect on the reachability query.
01132        *
01133        * @param - input: the starting point of the reachability query
01134        * @param - output: the result of performing the reachability query
01135        * @param - wg: the functions to use in generating weights
01136        *
01137        */
01138       void poststar( wali::wfa::WFA const & input,
01139                          wali::wfa::WFA & output,
01140                          WeightGen const & wg ) const
01141       {
01142         poststar(input, output, wg, NULL);
01143       }
01144 
01145       virtual void poststar( wali::wfa::WFA const & input,
01146                              wali::wfa::WFA & output,
01147                              WeightGen const & wg,
01148                              ref_ptr< wali::Worklist<wali::wfa::ITrans> > worklist) const;
01149 
01150       //Utilities   
01151 
01152       /**
01153        *
01154        * @brief print the NWA
01155        *
01156        * This method prints out the NWA to the output stream provided.
01157        *
01158        * @param - o: the output stream to print to
01159        * @return the output stream that was printed to
01160        *
01161        */
01162       virtual std::ostream & print( std::ostream & o ) const;
01163 
01164       /**
01165        *
01166        * @brief print the NWA in dot format
01167        *
01168        * This method prints out the NWA in dot format to the output stream provided.
01169        *
01170        * @param - o: the output stream to print to
01171        * @return the output stream that was printed to
01172        *
01173        */
01174       virtual std::ostream & print_dot( std::ostream & o, std::string title, bool abbrev = true ) const;
01175 
01176       /**
01177        *
01178        * @brief tests whether this NWA is equivalent to the NWA 'other'
01179        *
01180        * This method tests the equivalence of this NWA and the NWA 'other'.
01181        *
01182        * @param - other: the NWA to compare this NWA to
01183        * @return true if this NWA is equivalent to the NWA 'other'
01184        *
01185        */
01186       bool operator==( const Nwa & other ) const;
01187 
01188       //TODO: add methods like ...
01189       //virtual void for_each(ConstRuleFunctor &func) const;
01190       //virtual void for_each(RuleFunctor &func) const;
01191       //virtual void operator()(wali::wfa::ITrans *t);
01192 
01193       /**
01194        *
01195        * @brief add all the states in the given StateSet to the NWA
01196        *
01197        * This method adds all of the given states to the state set for the NWA.
01198        *
01199        * @param - addStateSet: the StateSet that contains the states to add
01200        *
01201        */
01202       void addAllStates( StateStorage addStateSet );  
01203 
01204       /**
01205        *
01206        * @brief adds all of the states in the given StateSet to the initial state set 
01207        *        associated with this NWA
01208        *
01209        * This method adds all of the states associated with the given StateSet to the 
01210        * initial state set associated with this NWA.
01211        *
01212        * @param - addStateSet: the state set whose initial states to add to this NWA's
01213        *                        initial state set
01214        *
01215        */
01216       void addAllInitialStates( StateStorage addStateSet ); 
01217 
01218       /**
01219        *
01220        * @brief adds all of the final states in the given StateSet to the final state set
01221        *        associated with this NWA
01222        *
01223        * This method adds all of the final states associated with the given StateSet to 
01224        * the final state set associated with this NWA.
01225        *
01226        * @param - addStateSet: the StateSet whose final states to add to this NWA's
01227        *                        final state set
01228        *
01229        */
01230       void addAllFinalStates( StateStorage addStateSet ); 
01231 
01232       /**
01233        *
01234        * @brief add the given symbols to the NWA
01235        *
01236        * This method adds all of the given symbols to the set of symbols associated with
01237        * the NWA.  
01238        *
01239        * @param - addSymbolSet: the symbols to add
01240        *
01241        */
01242       void addAllSymbols( SymbolStorage addSymbolSet );    
01243 
01244 
01245       // {{{ Iterator functions
01246       
01247       /**
01248        *
01249        * @brief provide access to the beginning of the state set
01250        *
01251        * This method provides access to the beginning of the state set associated with 
01252        * this NWA.
01253        *
01254        * @return an iterator pointing to the beginning of the state set
01255        *
01256        */
01257       StateIterator beginStates( ) const;  
01258 
01259       /**
01260        * 
01261        * @brief provide access to the end of the state set
01262        *
01263        * This method provides access to the position one past the end of the state set
01264        * associated with this transition set.
01265        *
01266        * @return an iterator pointing just past the end of the state set
01267        *
01268        */
01269       StateIterator endStates( ) const;  
01270 
01271       /**
01272        *
01273        * @brief provide access to the beginning of the initial state set
01274        *
01275        * This method provides access to the beginning of the initial state set associated
01276        * with this NWA.
01277        *
01278        * @return an iterator pointing to the beginning of the initial state set
01279        *
01280        */ 
01281       StateIterator beginInitialStates( ) const;  
01282 
01283       /**
01284        * 
01285        * @brief provide access to the end of the initial state set
01286        *
01287        * This method provides access to the position one past the end of the initial 
01288        * state set associated with this NWA.
01289        *
01290        * @return an iterator pointing just past the end of the initial state set
01291        *
01292        */
01293       StateIterator endInitialStates( ) const;  
01294 
01295 
01296       /**
01297        *
01298        * @brief provide access to the beginning of the final state set
01299        *
01300        * This method provides access to the beginning of the final state set associated 
01301        * with this NWA.
01302        *
01303        * @return an iterator pointing to the beginning of the final state set
01304        *
01305        */
01306       StateIterator beginFinalStates( ) const;  
01307 
01308       /**
01309        * 
01310        * @brief provide access to the end of the final state set
01311        *
01312        * This method provides access to the position one past the end of the final state 
01313        * set associated with this NWA.
01314        *
01315        * @return an iterator pointing just past the end of the final state set
01316        *
01317        */
01318       StateIterator endFinalStates( ) const;  
01319 
01320       /**
01321        *
01322        * @brief provide access to the beginning of the symbol set
01323        *
01324        * This method provides access to the beginning of the symbol set associated with 
01325        * this NWA.
01326        *
01327        * @return an iterator pointing to the beginning of the symbol set
01328        *
01329        */
01330       SymbolIterator beginSymbols( ) const;  
01331 
01332       /**
01333        * 
01334        * @brief provide access to the end of the symbol set
01335        *
01336        * This method provides access to the position one past the end of the symbol set 
01337        * associated with NWA.
01338        *
01339        * @return an iterator pointing just past the end of the symbol set
01340        *
01341        */
01342       SymbolIterator endSymbols( ) const;  
01343 
01344       /**
01345        *
01346        * @brief provide access to the beginning of the call transition set
01347        *
01348        * This method provides access to the beginning of the call transition set 
01349        * associated with this NWA.
01350        *
01351        * @return an iterator pointing to the beginning of the call transition set
01352        *
01353        */
01354       CallIterator beginCallTrans( ) const;  
01355 
01356       /**
01357        * 
01358        * @brief provide access to the end of the call transition set
01359        *
01360        * This method provides access to the position one past the end of the call 
01361        * transition set associated with this NWA.
01362        *
01363        * @return an iterator pointing just past the end of the call transition set
01364        *
01365        */
01366       CallIterator endCallTrans( ) const;  
01367 
01368       /**
01369        *
01370        * @brief provide access to the beginning of the internal transition set
01371        *
01372        * This method provides access to the beginning of the internal transition set 
01373        * associated with this NWA.
01374        *
01375        * @return an iterator pointing to the beginning of the internal transition set
01376        *
01377        */
01378       InternalIterator beginInternalTrans( ) const;  
01379 
01380       /**
01381        * 
01382        * @brief provide access to the end of the internal transition set
01383        *
01384        * This method provides access to the position one past the end of the internal 
01385        * transition set associated with this NWA.
01386        *
01387        * @return an iterator pointing just past the end of the internal transition set
01388        *
01389        */
01390       InternalIterator endInternalTrans( ) const; 
01391 
01392       /**
01393        *
01394        * @brief provide access to the beginning of the return transition set
01395        *
01396        * This method provides access to the beginning of the return transition set 
01397        * associated with this NWA.
01398        *
01399        * @return an iterator pointing to the beginning of the return transition set
01400        *
01401        */
01402       ReturnIterator beginReturnTrans( ) const;  
01403 
01404       /**
01405        * 
01406        * @brief provide access to the end of the return transition set
01407        *
01408        * This method provides access to the position one past the end of the return 
01409        * transition set associated with this NWA.
01410        *
01411        * @return an iterator pointing just past the end of the return transition set
01412        *
01413        */
01414       ReturnIterator endReturnTrans( ) const;
01415 
01416       // }}}
01417 
01418     protected:
01419 
01420       /**
01421        *
01422        * @brief computes the epsilon closure of the given state
01423        *
01424        * This method computes the set of states reachable by starting at the given 
01425        * state and moving along epsilon transitions.
01426        *
01427        * @param - newPairs: the set of states reachable from the initial state pair by 
01428        *                    traversing epsilon transitions   
01429        * @param - sp: the starting point of the closure
01430        *
01431        */
01432       void epsilonClosure(  StateSet * newPairs, State sp ) const;
01433 
01434       /**
01435        *
01436        * @brief computes the epsilon closure of the given states in their respective NWAs
01437        *
01438        * This method computes the set of state pairs reachable by starting at the given 
01439        * state pair and moving along epsilon transitions.
01440        *
01441        * @param - newPairs: the set of state pairs reachable from the initial state pair
01442        *                     by traversing epsilon transitions
01443        * @param - sp: the starting point of the closure
01444        * @param - first: the NWA that determines the transitions available to the first 
01445        *                  component of the state pair
01446        * @param - second: the NWA that determines the transitions available to the second
01447        *                  component of the state pair
01448        *
01449        */
01450       void epsilonClosure(  std::set<StatePair> * newPairs, StatePair sp, Nwa const & first, Nwa const & second ) const;
01451 
01452       /**
01453        * 
01454        * @brief returns the state corresponding to the given binary relation
01455        *
01456        * This method provides access to the state corresponding to the given binary relation.
01457        *
01458        * @param - R: the binary relation whose state to access
01459        * @return the state corresponding to the given binary relation
01460        *
01461        */
01462       State makeKey(  BinaryRelation const & R ) const;
01463 
01464       //
01465       // Variables
01466       //
01467       
01468     protected:
01469       
01470       StateStorage states;         
01471       SymbolStorage symbols;        
01472       Trans trans;
01473 
01474       //TODO: ponder the following ...
01475       //Q: should we incrementally maintain a wpds?
01476       //    if we did, what would the weight gen of the wpds be?
01477 
01478     public:
01479       /// @brief Determines whether word is in the language of the given NWA.
01480       ///
01481       /// @returns true if 'word' is in L(this), and false otherwise.
01482       bool
01483       isMemberNondet( NestedWord const & word ) const;
01484 
01485 
01486       /// @brief Adds all states, symbols, and transitions from 'rhs' to 'this'.
01487       ///
01488       /// This is like unionNWA(), except that it doesn't modify the initial
01489       /// or accepting states.
01490       void combineWith(Nwa const & rhs);
01491     };
01492 
01493 }
01494 
01495 
01496 // Yo, Emacs!
01497 // Local Variables:
01498 //   c-file-style: "ellemtel"
01499 //   c-basic-offset: 2
01500 // End:
01501 
01502 #endif
01503