libFAUDES

Sections

Index

cfl_regular.h

Go to the documentation of this file.
00001 /** @file cfl_regular.h 
00002 
00003 Operations on regular languages.
00004 See [Cassandras and Lafortune. Introduction to Discrete Event Systems] for an
00005 introduction to regular language operations.
00006 Operations are always performed on language(s) marked by the passed generator(s),
00007 resulting in the language(s) marked by the resulting generator(s).
00008 Only if mentioned extra, the same is done for the involved generated (prefix-closed)
00009 languages.
00010 
00011 */
00012 
00013 /* FAU Discrete Event Systems Library (libfaudes)
00014 
00015    Copyright (C) 2006  Bernd Opitz
00016    Exclusive copyright is granted to Klaus Schmidt
00017 
00018    This library is free software; you can redistribute it and/or
00019    modify it under the terms of the GNU Lesser General Public
00020    License as published by the Free Software Foundation; either
00021    version 2.1 of the License, or (at your option) any later version.
00022 
00023    This library is distributed in the hope that it will be useful,
00024    but WITHOUT ANY WARRANTY; without even the implied warranty of
00025    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00026    Lesser General Public License for more details.
00027 
00028    You should have received a copy of the GNU Lesser General Public
00029    License along with this library; if not, write to the Free Software
00030    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00031 
00032 
00033 #ifndef FAUDES_REGULAR_H
00034 
00035 #include "cfl_definitions.h"
00036 #include "cfl_parallel.h"
00037 #include "cfl_project.h" 
00038 
00039 namespace faudes {
00040 
00041 /**
00042  * Language union, nondeterministic version.
00043  *
00044  * This function performs the union of two languages marked by two generators;
00045  * the resulting generator marks the resulting language.
00046  * Moreover, the same is done for the involved generated (prefix-closed) languages.
00047  * Method:
00048  * This function implements the textbook version in taking unions of all generator
00049  * entities (alphabets, initial states, ...) of rGen1 and rGen2. State sets are taken
00050  * as disjoint by definition and thus reindexed and renamed to achieve disjoint union.
00051  * The resulting language is defined over the union of the alphabets of the original
00052  * languages; original languages defined over different alphabets are treated as if
00053  * they were defined over the union of both alphabets.
00054  * 
00055  * Determinism:
00056  * Input parameters may be nondeterministic.
00057  * This function is more economical than the deterministic version, but likely to
00058  * produce a non-deterministic result; see also LanguageUnion().
00059  *
00060  * No restrictions on parameters.
00061  *
00062  * @param rGen1
00063  *   generator generating/marking L1/Lm1
00064  * @param rGen2
00065  *   generator generating/marking L2/Lm2
00066  * @param rResGen
00067  *   resulting generator generating/marking the language union of L1 and L2/of Lm1 and Lm2
00068  *
00069  *
00070  * @ingroup GeneratorFunctions
00071  */
00072 void LanguageUnionNonDet(const vGenerator& rGen1, const vGenerator& rGen2, 
00073     vGenerator& rResGen);
00074 
00075 /**
00076  * Language union, deterministic version.
00077  *
00078  * This function performs the union of two languages marked by two generators;
00079  * the resulting generator marks the resulting language.
00080  * Moreover, the same is done for the involved generated (prefix-closed) |languages.
00081  * Method:
00082  * This function implements the textbook version (which textbook??) in taking unions
00083  * of all generator entities (alphabets, initial states, ...). State sets are taken
00084  * as disjoint by definition and thus reindexed and renamed to achieve disjoint union.
00085  * The resulting language is defined over the union of the alphabets of the original
00086  * languages.
00087  *
00088  * Determinism:
00089  * Input parameters may be nondeterministic.
00090  * This function calls LanguageUnionNonDet() and then Deterministic() to convert the 
00091  * result into a deterministic generator. Note that this conversion is usually
00092  * straightforward, but there exist theoretical worst-case examples of exponential complexity.
00093  *
00094  * No restrictions on parameters.
00095  *
00096  * ToDo: a version similar to parallel composition that produces a deterministic result by construction. (?)
00097  *
00098  * @param rGen1
00099  *   generator generating/marking L1/Lm1
00100  * @param rGen2
00101  *   generator generating/marking L2/Lm2
00102  * @param rResGen
00103  *   resulting generator generating/marking the language union of L1 and L2/of Lm1 and Lm2
00104  * 
00105  * <h4>Example:</h4>
00106  * <table border=0> <tr> <td> <table>
00107  * <tr> <td> Generator G1 </td> <td> Generator G2 </td> </tr>
00108  * <tr>
00109  * <td> @image html tmp_boolean_g1.png </td>
00110  * <td> @image html tmp_boolean_g2.png </td>
00111  * </tr>
00112  * </table> </td> </tr> <tr> <td> <table width=100%>
00113  * <tr> <td> LanguageUnion(G1,G2,Result) </td> </tr>
00114  * <tr> <td> @image html tmp_union_g1g2.png </td> </tr>
00115  * </table> </td> </tr> </table>
00116  *
00117  * @ingroup GeneratorFunctions
00118  */
00119 void LanguageUnion(const vGenerator& rGen1, const vGenerator& rGen2,
00120     vGenerator& rResGen);
00121 
00122 /**
00123  * Language union.
00124  *
00125  * See also LanguageUnion(const vGenerator&, const vGenerator&, vGenerator&);
00126  * This version takes a vector of generators as argument to perform
00127  * the union for multiple languages. The implementation
00128  * calls the std union multiple times, future implementations may
00129  * do better.
00130  *
00131  * @param rGenVec
00132  *   Vector of input generators
00133  * @param rResGen
00134  *   Reference to resulting generator
00135  *
00136  */
00137 void LanguageUnion(const GeneratorVector& rGenVec, vGenerator& rResGen);
00138 
00139 
00140 /**
00141  * Language intersection.
00142  *
00143  * This function performs the intersection of two languages marked by two generators;
00144  * the resulting generator marks the resulting language.
00145  * Moreover, the same is done for the involved generated (prefix-closed) languages.
00146  * The resulting languages are defined over the intersection of the involved alphabets.
00147  * Method:
00148  * This function calls Product(). In the product of two automata, an event occurs if
00149  * and only if it occurs in both automata rGen1 and rGen2. The result generates/marks
00150  * the intersection of the involved languages, see e.g.
00151  * [Cassandras, Lafortune. Introduction to Discrete Event Systems, p.84]
00152  *
00153  * Determinism:
00154  * Input parameters may be nondeterministic.
00155  * Result can be nondeterministic only if input parameters are nondeterministic.
00156  *
00157  * No restrictions on parameters.
00158  *
00159  * @param rGen1
00160  *   generator generating/marking L1/Lm1
00161  * @param rGen2
00162  *   generator generating/marking L2/Lm2
00163  * @param rResGen
00164  *   resulting generator generating/marking the language intersection of L1 and L2/of Lm1 and Lm2
00165  *
00166  * <h4>Example:</h4>
00167  *
00168  * <table border=0> <tr> <td> <table>
00169  * <tr> <td> Generator G1 </td> <td> Generator G2 </td> </tr>
00170  * <tr>
00171  * <td> @image html tmp_boolean_g1.png </td>
00172  * <td> @image html tmp_boolean_g2.png </td>
00173  * </tr>
00174  * </table> </td> </tr> <tr> <td> <table width=100%>
00175  * <tr> <td> LanguageIntersection(G1,G2,Result) </td> </tr>
00176  * <tr> <td> @image html tmp_intersection_g1g2.png </td> </tr>
00177  * </table> </td> </tr> </table>
00178  *
00179  * @ingroup GeneratorFunctions
00180  */
00181 void LanguageIntersection(const vGenerator& rGen1, const vGenerator& rGen2, 
00182     vGenerator& rResGen);
00183         
00184 /**
00185  * Language intersection.
00186  *
00187  * See also LanguageUnion(const vGenerator&, const vGenerator&, vGenerator&);
00188  * This version takes a vector of generators as argument to perform
00189  * the intersection for multiple languages. The implementation
00190  * calls the std intersection multiple times, future implementations may
00191  * do better.
00192  *
00193  * @param rGenVec
00194  *   Vector of input generators
00195  * @param rResGen
00196  *   Reference to resulting generator
00197  *
00198  */
00199 void LanguageIntersection(const GeneratorVector& rGenVec, vGenerator& rResGen);
00200 
00201 
00202 /**
00203  * Test for empty language intersection  (same as Disjoind()).
00204  *
00205  * This function checks if the intersection of two languages marked by two generators
00206  * is empty that is the two languages are disjoint.
00207  * The involved generated (prefix-closed) languages are not considered. This function
00208  * is identical to Disjoint().
00209  * Method:
00210  * This function checks if the Product() of both automata marks the empty language.
00211  *
00212  * ToDo: modify such that the product is computed only to the necessary extend, i.e.
00213  *       do not store product in temporary generator and return false as soon as a
00214  *       common transition is found.
00215  *
00216  * No restrictions on parameters.
00217  *
00218  * @param rGen1
00219  *   generator marking Lm1
00220  * @param rGen2
00221  *   generator marking Lm2
00222  *
00223  * @return
00224  *   true if language intersection is empty, false if not.
00225  *
00226  * @ingroup GeneratorFunctions
00227  */  
00228 bool EmptyLanguageIntersection(const vGenerator& rGen1, const vGenerator& rGen2);
00229 
00230 /**
00231  * Test whether two languages are disjoint.
00232  *
00233  * This function tests whether the intersection of two languages marked by two generators
00234  * is empty, ie the two languages are disjoint.
00235  * The involved generated (prefix-closed) languages are not considered. This function
00236  * is identical to EmptyLanguageIntersection().
00237  * Method:
00238  * This function checks if the Product() of both automata marks the empty language.
00239  *
00240  * ToDo: modify such that the product is computed only to the necessary extend, i.e.
00241  *       do not store product in temporary generator and return false as soon as a
00242  *       common transition is found.
00243  *
00244  * No restrictions on parameters.
00245  *
00246  * @param rGen1
00247  *   generator marking Lm1
00248  * @param rGen2
00249  *   generator marking Lm2
00250  *
00251  * @return
00252  *   true if language intersection is empty, false if not.
00253  *
00254  * @ingroup GeneratorFunctions
00255  */  
00256 bool LanguageDisjoint(const vGenerator& rGen1, const vGenerator& rGen2);
00257 
00258 /**
00259  * Convert generator to automaton.
00260  *
00261  * Convert a generator marking the language Lm into a formal automaton recognizing Lm
00262  * with a dump state representing Sigma*-PrefixClosure(Lm). In this function, Sigma is
00263  * given by the alphabet of rGen; see also Automaton(rGen,rAlphabet).
00264  * For information about automata, see [Wonham. Supervisory Control of Discrete Event
00265  * Systems].
00266  * The original generated language is ignored.
00267  * Note: An automaton is a deterministic transition structure according to the formal
00268  *       definition; see also "Determinism" below.
00269  * Method:
00270  * Uncoaccessible states are erased, as the language generated by rGen is not examined
00271  * in this function. A dump state representing "Sigma*-PrefixClosure(Lm)" is created.
00272  * Then, the transition relation is completed such that it is fully defined for each
00273  * state and each event. Formerly undefined transitions lead to the dump state.
00274  *
00275  * Determinism:
00276  * Input parameter has to be deterministic for correct result. If not, then the 
00277  * (also nondeterministic) result recognizes the correct language, but the dump state
00278  * does not represent "Sigma*-PrefixClosure(Lm)" as it should;
00279  * see also example ExAutomaton_basic().
00280  * If FAUDES_CHECKED is defined a warning on non-deterministic input is issued.
00281  * 
00282  * No further restrictions on parameter.
00283  * 
00284  * @param rGen
00285  *   generator that is converted to automaton
00286  *
00287  * <h4>Example:</h4>
00288  * <table>
00289  * <tr> <td> Generator G </td> <td> Automaton(G) </td> </tr>
00290  * <tr>
00291  * <td> @image html tmp_automaton_g.png </td>
00292  * <td> @image html tmp_automaton_gRes.png </td>
00293  * </tr>
00294  * </table> 
00295  *
00296  * @ingroup GeneratorFunctions
00297  */
00298 void Automaton(vGenerator& rGen);
00299 
00300 /**
00301  * Convert generator to automaton wrt specified alphabet.
00302  *
00303  * Convert a generator marking the language Lm into a formal automaton recognizing Lm
00304  * with a dump state representing Sigma*-PrefixClosure(Lm(rGen)). In this function,
00305  * Sigma is given by the parameter rAlphabet.
00306  * For information about automata, see [Wonham. Supervisory Control of Discrete Event
00307  * Systems].
00308  * The original generated language is ignored.
00309  * Note: An automaton is a deterministic transition structure according to the formal
00310  *       definition; see also "Determinism" below.
00311  * Method:
00312  * Uncoaccessible states are erased, as the language generated by rGen is not examined
00313  * in this function. A dump state representing "Sigma*-PrefixClosure(Lm)" is created.
00314  * Then, the transition relation is completed such that it is fully defined for each
00315  * state of rGen and each event of rAlphabet. Formerly undefined transitions lead to
00316  * the dump state.
00317  *
00318  * Determinism:
00319  * Input parameter has to be deterministic for correct result. If not, then the 
00320  * (also nondeterministic) result recognizes the correct language, but the dump state
00321  * does not represent "Sigma*-PrefixClosure(Lm)" as it should;
00322  * see also example ExAutomaton_basic().
00323  * If FAUDES_CHECKED is defined a warning on non-deterministic input is issued.
00324  * 
00325  * No further restrictions on parameters.
00326  * 
00327  * @param rGen
00328  *   generator that is converted to automaton
00329  *
00330  * @param rAlphabet
00331  *   the dump state of the resulting automaton represents the
00332  *   language L_dump=rAlphabet*-PrefixClosure(Lm(rGen))
00333  *
00334  * @ingroup GeneratorFunctions
00335  */
00336 void Automaton(vGenerator& rGen, const EventSet& rAlphabet);
00337 
00338 /**
00339  * Language complement.
00340  *
00341  * Convert generator marking the language Lm into generator marking the language
00342  * complement of Lm which is defined as Sigma*-Lm. In this function, Sigma is
00343  * given by the alphabet of rGen; see also LanguageComplement(rGen,rAlphabet).
00344  * The original generated language is ignored.
00345  * Method:
00346  * This function calls Automaton() first and then inverts the marking of the states
00347  * of the result.
00348  *
00349  * Determinism:
00350  * Input parameter has to be deterministic for correct result, see Automaton() for
00351  * explanations.
00352  * If FAUDES_CHECKED is defined a warning on non-deterministic input is issued.
00353  * (by function Automaton()).
00354  *
00355  * No further restrictions on parameter.
00356  *
00357  * @param rGen
00358  *   generator on which the language complement is performed
00359  *
00360  * <h4>Example:</h4>
00361  * <table>
00362  * <tr> <td> Generator G </td> <td> LanguageComplement(G) </td> </tr>
00363  * <tr>
00364  * <td> @image html tmp_boolean_g1.png </td>
00365  * <td> @image html tmp_complement_g1.png </td>
00366  * </tr>
00367  * </table> 
00368  *
00369  *
00370  * @ingroup GeneratorFunctions
00371  */
00372 void LanguageComplement(vGenerator& rGen);
00373 
00374 /**
00375  * Language complement wrt specified alphabet.
00376  *
00377  * Convert generator marking the language Lm into generator marking the language
00378  * complement of Lm which is defined as Sigma*-Lm. In this function, Sigma is
00379  * given by the parameter rAlphabet.
00380  * The original generated language is ignored.
00381  * Method:
00382  * This function calls Automaton() first and then inverts the marking of the states
00383  * of the result.
00384  *
00385  * Determinism:
00386  * Input parameter has to be deterministic for correct result, see Automaton() for
00387  * explanations.
00388  * If FAUDES_CHECKED is defined a warning on non-deterministic input is issued.
00389  * (by function Automaton()).
00390  *
00391  * No further restrictions on parameter.
00392  *
00393  * @param rGen
00394  *   generator on which the language complement is performed
00395  *
00396  * @param rAlphabet
00397  *   reference alphabet to build the complement
00398  *
00399  * @ingroup GeneratorFunctions
00400  */
00401 void LanguageComplement(vGenerator& rGen, const EventSet& rAlphabet);
00402 
00403 
00404 /** 
00405  * Language Complement (uniform API wrapper). 
00406  *
00407  * @param rGen
00408  *   generator on which the language complement is performed
00409  *
00410  * @param rRes
00411  *   resulting generator
00412  *
00413  * @ingroup GeneratorFunctions
00414  */
00415 void LanguageComplement(const vGenerator& rGen, vGenerator& rRes);
00416 
00417 /** 
00418  * Language Complement (uniform API wrapper).
00419  *
00420  * @param rGen
00421  *   generator on which the language complement is performed
00422  *
00423  * @param rSigma
00424  *   reference alphabet to build the complement
00425  *
00426  * @param rRes
00427  *   resulting generator
00428  *
00429  * @ingroup GeneratorFunctions
00430  */
00431 void LanguageComplement(const vGenerator& rGen, const EventSet& rSigma, vGenerator& rRes);
00432 
00433 
00434 
00435 /**
00436  * Language difference (set-theoretic difference).
00437  *
00438  * This function calculates Lm1-Lm2 (sometimes also denoted by Lm1\\Lm2), that is the
00439  * set of all strings included in Lm1 but not in Lm2.
00440  * Method:
00441  * The language difference is computed by taking the intersection of Lm1 with the
00442  * complement of Lm2.
00443  * 
00444  * Determinism:
00445  * Due to the use of LanguageComplement(), rGen2 has to be deterministic.
00446  * Result can be nondeterministic only if rGen1 is nondeterministic.
00447  *
00448  * Restrictions on prameters:
00449  * rGen2 has to be deterministic.
00450  *
00451  * @param rGen1 
00452  *  generator marking the language Lm1
00453  * @param rGen2
00454  *  generator marking the language Lm2 
00455  * @param rResGen
00456  *  generator marking the language difference Lm1-Lm2 
00457  *
00458  * @exception Exception
00459  *   - nondeterministic parameter rGen2 (id 101). 
00460  *
00461   * <h4>Example:</h4>
00462  * <table border=0> <tr> <td> <table>
00463  * <tr> <td> Generator G1 </td> <td> Generator G2 </td> </tr>
00464  * <tr>
00465  * <td> @image html tmp_difference_g1.png </td>
00466  * <td> @image html tmp_difference_g2.png </td>
00467  * </tr>
00468  * </table> </td> </tr> <tr> <td> <table width=100%>
00469  * <tr> <td> LanguageDifference(G1,G2,Result) </td> </tr>
00470  * <tr> <td> @image html tmp_difference_g1minusg2.png </td> </tr>
00471  * </table> </td> </tr> </table>
00472  *
00473  * @ingroup GeneratorFunctions
00474  */
00475 void LanguageDifference(const vGenerator& rGen1, const vGenerator& rGen2,
00476                  vGenerator& rResGen);
00477 
00478 /**
00479  * Language concatenation, nondeterministic version.
00480  *
00481  * With the languages Lm1 and Lm2 marked by rGen1 and rGen2, respectively, the result
00482  * rResGen marks the concatenation LmRes=Lm1Lm2.
00483  * The languages generated by rGen1 and rGen2 are ignored. It would be possible to let
00484  * the result also generate the concatenation of the generated languages; however, this can
00485  * produce disproportionate computational overhead, if only the marked languages shall be
00486  * concatenated.
00487  * Method:
00488  * rGen2 is appended to rGen1: first, the initial states of rGen2 are erased. Then,
00489  * transitions, that formerly started from the initial state(s) of rGen2, are redirected 
00490  * and multiplied such that they start from each marked state of rGen1. The marked states
00491  * corresponding to rGen2 remain marked. The marked states of rGen1 remain marked only if
00492  * rGen2 has at least one marked initial state (i.e. if epsilon is concatenated to Lm1.)
00493  * 
00494  * Determinism:
00495  * Input parameters may be nondeterministic. Result can be nondeterministic even if input
00496  * parameters are deterministic; see also LanguageConcatenate().
00497  *
00498  * No restrictions on parameters.
00499  * 
00500  * @param rGen1
00501  *   generator marking Lm1
00502  * @param rGen2
00503  *   generator marking Lm2
00504  * @param rResGen
00505  *   resulting generator marking the language concatenation Lm1Lm2
00506  *
00507  * @ingroup GeneratorFunctions
00508  */
00509 void LanguageConcatenateNonDet(const vGenerator& rGen1, const vGenerator& rGen2,
00510     vGenerator& rResGen);
00511 
00512 /**
00513  * Language concatenation, deterministic version.
00514  *
00515  * With the languages Lm1 and Lm2 marked by rGen1 and rGen2, respectively, the result
00516  * rResGen marks the concatenation LmRes=Lm1Lm2.
00517  * The languages generated by rGen1 and rGen2 are ignored. It would be possible to let
00518  * the result also generate the concatenation of the generated languages; however, this can
00519  * produce disproportionate computational overhead, if only the marked languages shall be
00520  * concatenated.
00521  * Method:
00522  * rGen2 is appended to rGen1: first, the initial states of rGen2 are erased. Then,
00523  * transitions, that formerly started from the initial state(s) of rGen2, are redirected 
00524  * and multiplied such that they start from each marked state of rGen1. The marked states
00525  * corresponding to rGen2 remain marked. The marked states of rGen1 remain marked only if
00526  * rGen2 has at least one marked initial state (i.e. if epsilon is concatenated to Lm1.)
00527  * 
00528  * Determinism:
00529  * Input parameters may be nondeterministic.
00530  * This function calls LanguageUnionNonDet() and then Deterministic() to convert the 
00531  * result into a deterministic generator. Note that this conversion is usually
00532  * straightforward, but there exist theoretical worst-case examples of exponential complexity.
00533  *
00534  * No restrictions on parameters.
00535  * 
00536  * @param rGen1
00537  *   generator marking Lm1
00538  * @param rGen2
00539  *   generator marking Lm2
00540  * @param rResGen
00541  *   Resulting generator marking the language concatenation Lm1Lm2
00542  *
00543  * <h4>Example:</h4>
00544  * <table border=0> <tr> <td> <table>
00545  * <tr> <td> Generator G1 </td> <td> </td> <td> LanguageConcatenate(G1,G3,Result) </td> </tr>
00546  * <tr>
00547  * <td> @image html tmp_concat_g1.png </td>
00548  * <td> </td>
00549  * <td> @image html tmp_concat_g1g3.png </td>
00550  * </tr>
00551  * <tr> <td> Generator G2 </td> <td> </td> <td> LanguageConcatenate(G1,G4,Result) </td> </tr>
00552  * <tr>
00553  * <td> @image html tmp_concat_g2.png </td>
00554  * <td> </td> 
00555  * <td> @image html tmp_concat_g1g4.png </td>
00556  * </tr>
00557  * </tr>
00558  * <tr> <td> Generator G3 </td> <td> </td> <td> LanguageConcatenate(G2,G3,Result) </td> </tr>
00559  * <tr>
00560  * <td> @image html tmp_concat_g3.png </td>
00561  * <td> </td> 
00562  * <td> @image html tmp_concat_g2g3.png </td>
00563  * </tr>
00564  * </tr>
00565  * <tr> <td> Generator G4 </td> <td> </td> <td> LanguageConcatenate(G2,G4,Result) </td> </tr>
00566  * <tr>
00567  * <td> @image html tmp_concat_g4.png </td>
00568  * <td> </td> 
00569  * <td> @image html tmp_concat_g2g4.png </td>
00570  * </tr>
00571  * </table> </td> </tr> </table>
00572  *
00573  * @ingroup GeneratorFunctions
00574  */
00575 void LanguageConcatenate(const vGenerator& rGen1, const vGenerator& rGen2,
00576     vGenerator& rResGen);
00577 
00578 /**
00579  * Full Language, L(G)=Lm(G)=Sigma*.
00580  *
00581  * Construct generator generating and marking full language Sigma* from alphabet Sigma.
00582  * Method: this function creates a generator with one state that is marked and init state. This
00583  * state is selflooped with all events from rAlphabet.
00584  *
00585  * @param rAlphabet
00586  *   Alphabet Sigma from which full language Sigma* is built
00587  * @param rResGen
00588  *   Generator generating and marking full language Sigma*
00589  *
00590  * <h4>Example:</h4>
00591  * <table>
00592  * <tr> <td> FullLanguage(Sigma={a,b},Result) </td> </tr>
00593  * <tr>
00594  * <td> @image html tmp_languagesFull_result.png </td>
00595  * </tr>
00596  * </table> 
00597  *
00598  * @ingroup GeneratorFunctions
00599  */
00600 void FullLanguage(const EventSet& rAlphabet, vGenerator& rResGen);
00601 
00602 /**
00603  * Alphabet Language, L(G)=Lm(G)=Sigma
00604  *
00605  * Construct generator generating and marking an alphabet as languages, that is L(G)=Lm(G)=Sigma.
00606  * Method: this function creates a generator with one init state and one marked state. For each
00607  * event from rAlphabet, a transition is inserted leading from the init state to the marked state.
00608  *
00609  * No restrictions on parameters.
00610  * 
00611  * @param rAlphabet
00612  *   alphabet from which alphabet language is built
00613  * @param rResGen
00614  *   generator with languages Lm(G)=Sigma
00615  *
00616  * <h4>Example:</h4>
00617  * <table>
00618  * <tr> <td> AlphabetLanguage(Sigma={a,b},Result) </td> </tr>
00619  * <tr>
00620  * <td> @image html tmp_languagesAlphabet_result.png </td>
00621  * </tr>
00622  * </table> 
00623  *
00624  * @ingroup GeneratorFunctions
00625  */
00626 void AlphabetLanguage(const EventSet& rAlphabet, vGenerator& rResGen);
00627 
00628 /**
00629  * Empty string language, L(G)=Lm(G)={epsilon}.
00630  *
00631  * Construct generator generating and marking the empty string, that is L(G)=Lm(G)={epsilon}.
00632  * Method: this function creates a generator with one marked init state and the alphabet rAlphabet.
00633  *
00634  * No restrictions on parameters.
00635  * 
00636  * @param rAlphabet
00637  *   alphabet of the resulting generator
00638  * @param rResGen
00639  *   generator with languages L(G)=Lm(G)={epsilon} and alphabet rAlphabet
00640  *
00641  * <h4>Example:</h4>
00642  * <table>
00643  * <tr> <td> EmptyStringLanguage(Sigma={a,b},Result) </td> </tr>
00644  * <tr>
00645  * <td> @image html tmp_languagesEmptyString_result.png </td>
00646  * </tr>
00647  * </table> 
00648  *
00649  * @ingroup GeneratorFunctions
00650  */
00651 void EmptyStringLanguage(const EventSet& rAlphabet, vGenerator& rResGen);
00652 
00653 /**
00654  * Empty language Lm(G)={}.
00655  *
00656  * Construct generator and marking the empty language, that is Lm(G)={}.
00657  * Method: this function creates a deterministic generator with one initial state that is not marked. 
00658  * The alphabet is set as specified. 
00659  *
00660  * No restrictions on parameters.
00661  * 
00662  * @param rAlphabet
00663  *   Alphabet of the resulting generator
00664  * @param rResGen
00665  *   Generator with language Lm(G)={}
00666  *
00667  * @ingroup GeneratorFunctions
00668  */
00669 void EmptyLanguage(const EventSet& rAlphabet, vGenerator& rResGen);
00670 
00671 /**
00672  * Test for Empty language Lm(G)=={}.
00673  *
00674  * Tests if the language marked by rGen is empty, that is if Lm(G)=={}. The generated
00675  * language L(G) is not considered.
00676  * Method:
00677  * This function tests if 
00678  * a) the set of marked states is empty or else
00679  * b) the intersection of the set of accessible states and the set of marked states
00680  * is empty, i.e. if there is no marked state or if no marked state is accessible (reachable).
00681  *
00682  * No restrictions on parameter.
00683  *
00684  * @param rGen
00685  *   generator to be tested for empty marked language
00686  *
00687  * @return
00688  *   true on empty marked language, false on nonempty marked language
00689  *
00690  * @ingroup GeneratorFunctions
00691  */
00692 bool IsEmptyLanguage(const vGenerator& rGen);
00693 
00694 /**
00695  * Test language inclusion, Lm1<=Lm2.
00696  *
00697  * Test if language Lm1 marked by rGen1 is included in language Lm2 marked by rGen2. The
00698  * generated languages are not considered.
00699  * Method:
00700  * This function checks if there is no string in Lm1 that is not in Lm2 by testing if
00701  * the intersection of Lm1 and the language complement of Lm2 is empty.
00702  *
00703  * Restrictions on parameters: rGen2 has to be deterministic!
00704  * If FAUDES_CHECKED is defined a warning on non-deterministic input is issued.
00705  * (by function Automaton()).
00706  *
00707  * Determinism: correctness in case of nondeterministic parameter rGen1 has been tested with an
00708  *              example (see ExInclusion_simple), but not proven.
00709  *
00710  * ToDo: implement faster version using a variant of Product():
00711  * compute product without storing result, return false as soon as some event is
00712  * possible in Lm2 but not in Lm1.
00713  *
00714  * @param rGen1
00715  *   generator marking Lm1
00716  * @param rGen2
00717  *   generator marking Lm2
00718  *
00719  * @return
00720  *   true if language marked by rGen1 is included in language marked by rGen2
00721  *
00722  * @ingroup GeneratorFunctions
00723  */
00724 bool LanguageInclusion(const vGenerator& rGen1, const vGenerator& rGen2);
00725 
00726 /**
00727  * Language equality, Lm1==Lm2.
00728  *
00729  * Test if the language Lm1 marked by rGen1 equals the language Lm2 marked by rGen2. The
00730  * generated languages are not considered.
00731  * Method:
00732  * This function checks mutual inclusion of Lm1 in Lm2 and of Lm2 in Lm1 using the
00733  * function LanguageInclusion().
00734  *
00735  * Restrictions on parameters: rGen1 and rGen2 have to be deterministic!
00736  * If FAUDES_CHECKED is defined a warning on non-deterministic input is issued.
00737  * (by function Automaton()).
00738  *
00739  * ToDo: implement faster, version using a variant of Product():
00740  * compute product without storing result, return false as soon as rGen1 and rGen2
00741  * "disagree" on the occurrence of some event.
00742  *
00743  * @param rGen1
00744  *   generator marking Lm1
00745  * @param rGen2
00746  *   generator marking Lm2
00747  *
00748  * @return
00749  *   true if the language marked by rGen1 equals the language marked by rGen2
00750  *
00751  * @ingroup GeneratorFunctions
00752  */
00753 bool LanguageEquality(const vGenerator& rGen1, const vGenerator& rGen2);
00754 
00755 /**
00756  * Kleene Closure.
00757  *
00758  * This function computes the Kleene Closure ( ()* - operator) of the
00759  * language marked by rGen. The generated language is not considered.
00760  * Method: KleeneClosureNonDet() is called, which, for all transitions
00761  * leading from a state x to a marked state, inserts a transition with the
00762  * same event starting from x and leading to (one of) the initial state(s).
00763  * As this step causes nondeterminism, the function Deterministic() is called.
00764  * See also KleeneClosureNonDet().
00765  *
00766  * No restrictions on parameter.
00767  *
00768  * @param rGen
00769  *   generator marking the language Lm to which the Kleene Closure is applied
00770  *
00771  * <h4>Example:</h4>
00772  * <table>
00773  * <tr> <td> Generator G </td> <td> KleeneClosure(G) </td> </tr>
00774  * <tr>
00775  * <td> @image html tmp_kleene_g.png </td>
00776  * <td> @image html tmp_kleene_gRes.png </td>
00777  * </tr>
00778  * </table> 
00779  *
00780  * @ingroup GeneratorFunctions
00781  */
00782 void KleeneClosure(vGenerator& rGen);
00783 
00784 /**
00785  * Kleene Closure, nondeterministic version.
00786  *
00787  * This function computes the Kleene Closure ( ()* - operator) of the
00788  * language marked by rGen. The generated language is not considered.
00789  * Method: KleeneClosureNonDet() is called, which, for all transitions
00790  * leading from a state x to a marked state, inserts a transition with the
00791  * same event starting from x and leading to (one of) the initial state(s).
00792  *
00793  * @param rGen
00794  *   generator marking the language Lm to which Kleene Closure is applied
00795  *
00796  * @ingroup GeneratorFunctions
00797  */
00798 void KleeneClosureNonDet(vGenerator& rGen);
00799 
00800 /**
00801  * Prefix Closure.
00802  *
00803  * This function computes the prefix closure the language Lm marked by rGen. A
00804  * language Lm is prefix closed if each string of Lm implies that all its
00805  * prefixes are also element of Lm. The prefix closure of a language marked by
00806  * a generator is always a subset of the generated language and is represented
00807  * by the set of coaccessible states of the generator.
00808  * Method:
00809  * First, Coaccessible() is called to erase all states of rGen that do not
00810  * represent prefixes of marked strings. Then, all remaining states are marked.
00811  *
00812  * No restrictions on parameter.
00813  *
00814  * ToDo: (slightly) more efficient version: implement generator function
00815  * CoAccessibleSet() similar to AccessibleSet() and call
00816  * InjectMarkedStates(AccessibleSet()).
00817  *
00818  * @param rGen
00819  *   generator marking the language Lm to which prefix closure is applied
00820  *
00821  * <h4>Example:</h4>
00822  * <table>
00823  * <tr> <td> Generator G </td> <td> PrefixClosure(G) </td> </tr>
00824  * <tr>
00825  * <td> @image html tmp_prefixclosure_g.png </td>
00826  * <td> @image html tmp_prefixclosure_gRes.png </td>
00827  * </tr>
00828  * </table>
00829  *
00830  * @ingroup GeneratorFunctions
00831  */
00832 void PrefixClosure(vGenerator& rGen);
00833 
00834 
00835 /**
00836  * Test for prefix closed marked language.
00837  *
00838  * This function tests whether the language Lm(G) marked by the specified generator G
00839  * is prefix closed. It does so by testing whether all accessible and coaccessible
00840  * states are marked. 
00841  *
00842  * The specified generator must be deterministic.
00843  *
00844  * @param rGen
00845  *   generator G marking the Lm(G) to test
00846  * @return
00847  *   True <> Lm(G) is prefix closed
00848  *
00849  * @ingroup GeneratorFunctions
00850  */
00851 bool IsPrefixClosed(const vGenerator& rGen);
00852 
00853 
00854 /**
00855  * Test for nonblocking generator
00856  *
00857  * A generator G is nonblocking if closure(Lm(G)) = L(G), i.e.
00858  * if every accessible state is coacessile.
00859  *
00860  * The specified generator must be deterministic.
00861  *
00862  * @param rGen
00863  *   generator G marking to test
00864  * @return
00865  *   True <> G is nonblocking
00866  *
00867  * @ingroup GeneratorFunctions
00868  */
00869 bool IsNonblocking(const vGenerator& rGen);
00870 
00871 /**
00872  * Test for nonblocking marked languages.
00873  *
00874  * Two languages L1 and L2 are nonblocking, if
00875  * closure(L1 || L2) == closure(L1) || closure(L2).
00876  *
00877  * This function performs the parallel composition of the two
00878  * specified generators and tests it for nonblockingness. Provided
00879  * that both generators are trim, this is equivalent to the
00880  * respective marked languages being nonblocking.
00881  *
00882  * The specified generators must be trim.
00883  *
00884  * @param rGen1
00885  *   Generator G1
00886  * @param rGen2
00887  *   Generator G2
00888  * @return
00889  *   True <> Lm(G1) and Lm(G2) are nonblocking
00890  *
00891  * @ingroup GeneratorFunctions
00892  */
00893 bool IsNonblocking(const vGenerator& rGen1, const vGenerator& rGen2);
00894 
00895 
00896 /**
00897  * Self-loop all states.
00898  *
00899  * This function selfoops all states of rGen with the events from rAlphabet.
00900  * Method:
00901  * The alphabet of rGen is extended by rAlphabet. For each state x of rGen
00902  * and each event alpha of rAlphabet, a transition (x,alpha,x) is inserted,
00903  * irrespective of whether this event was already active in x before.
00904  * See also SelfLoop(rGen,rAlphabet,rStates) and SelfLoopMarkedStates(rGen,rAlphabet).
00905  *
00906  * No restrictions on parameter.
00907  *
00908  * Determinism: resulting generator is nondeterministic, if it was nondeterministic
00909  * before, or if rGen already contains one or more (non selfloop) transitions with
00910  * events from rAlphabet.
00911  *
00912  * @param rGen
00913  *   generator to be selflooped with events from rAlphabet
00914  * @param rAlphabet
00915  *   alphabet with selfloop events
00916  *
00917  * <h4>Example:</h4>
00918  * <table>
00919  * <tr> <td> Generator G </td> <td> SelfLoop(G,Sigma={e,f}) </td> </tr>
00920  * <tr>
00921  * <td> @image html tmp_selfloop_g.png </td>
00922  * <td> @image html tmp_selfloop_gRes.png </td>
00923  * </tr>
00924  * </table>
00925  *
00926  * @ingroup GeneratorFunctions
00927  */
00928 void SelfLoop(vGenerator& rGen,const EventSet& rAlphabet);
00929 
00930 /**
00931  * Self-loop all marked states.
00932  *
00933  * This function selfoops all marked states of rGen with the events from rAlphabet.
00934  * Method:
00935  * The alphabet of rGen is extended by rAlphabet. For each marked state x of rGen
00936  * and each event alpha of rAlphabet, a transition (x,alpha,x) is inserted,
00937  * irrespective of whether this event was already active in x before.
00938  * See also SelfLoop(rGen,rAlphabet) and SelfLoop(rGen,rAlphabet,rStates).
00939  *
00940  * No restrictions on parameter.
00941  *
00942  * Determinism: resulting generator is nondeterministic, if it was nondeterministic
00943  * before, or if rGen already contains one or more (non selfloop) transitions
00944  * starting from a marked state with events from rAlphabet.
00945  *
00946  * @param rGen
00947  *   generator with marked states to be selflooped with events from rAlphabet
00948  * @param rAlphabet
00949  *   alphabet with selfloop events
00950  *
00951  * <h4>Example:</h4>
00952  * <table>
00953  * <tr> <td> Generator G </td> <td> SelfLoopMarkedStates(G,Sigma={e,f}) </td> </tr>
00954  * <tr>
00955  * <td> @image html tmp_selfloop_g.png </td>
00956  * <td> @image html tmp_selfloopMarked_gRes.png </td>
00957  * </tr>
00958  * </table>
00959  *
00960  * @ingroup GeneratorFunctions
00961  */
00962 void SelfLoopMarkedStates(vGenerator& rGen,const EventSet& rAlphabet);
00963 
00964 /**
00965  * Self-loop specified states.
00966  *
00967  * This function selfoops the states rStates of rGen with the events from rAlphabet.
00968  * Method:
00969  * The alphabet of rGen is extended by rAlphabet. For each state x of rStates
00970  * and each event alpha of rAlphabet, a transition (x,alpha,x) is inserted,
00971  * irrespective of whether this event was already active in x before.
00972  * See also SelfLoop(rGen,rAlphabet) and SelfLoopMarkedStates(rGen,rAlphabet).
00973  *
00974  * No restrictions on parameter.
00975  *
00976  * Determinism: resulting generator is nondeterministic, if it was nondeterministic
00977  * before, or if rGen already contains one or more (non selfloop) transitions
00978  * starting from a state of rState with events from rAlphabet.
00979  *
00980  * @param rGen
00981  *   generator with marked states to be selflooped with events from rAlphabet
00982  * @param rAlphabet
00983  *   alphabet with selfloop events
00984  * @param rStates
00985  *   states to apply selfloop
00986  *
00987  * @exception Exception
00988  *   - rStates is not a subset of rGen.States() (id 100). 
00989  *
00990  * <h4>Example:</h4>
00991  * <table>
00992  * <tr> <td> Generator G </td> <td> SelfLoop(G,Sigma={e,f},G.InitStates()) </td> </tr>
00993  * <tr>
00994  * <td> @image html tmp_selfloop_g.png </td>
00995  * <td> @image html tmp_selfloopInit_gRes.png </td>
00996  * </tr>
00997  * </table>
00998  *
00999  * @ingroup GeneratorFunctions
01000  */
01001 void SelfLoop(vGenerator& rGen,const EventSet& rAlphabet,const StateSet& rStates);
01002 
01003 
01004 
01005 
01006 } // namespace faudes
01007 
01008 #define FAUDES_REGULAR_H
01009 #endif 
01010 

libFAUDES 2.16b --- 2010-9-8 --- c++ source docu by doxygen 1.6.3