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