libFAUDES
Sections
Index
|
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 * Method: 00211 * This function checks if the Product() of both automata marks the empty language. 00212 * 00213 * ToDo: modify such that the product is computed only to the necessary extend, i.e. 00214 * do not store product in temporary generator and return false as soon as a 00215 * common transition is found. 00216 * 00217 * No restrictions on parameters. 00218 * 00219 * @param rGen1 00220 * generator marking Lm1 00221 * @param rGen2 00222 * generator marking Lm2 00223 * 00224 * @return 00225 * true if language intersection is empty, false if not. 00226 * 00227 * @ingroup GeneratorFunctions 00228 */ 00229 bool EmptyLanguageIntersection(const Generator& rGen1, const Generator& rGen2); 00230 00231 /** 00232 * Test whether two languages are disjoint. 00233 * 00234 * This function tests whether the intersection of two languages marked by two generators 00235 * is empty, ie the two languages are disjoint. 00236 * The involved generated (prefix-closed) languages are not considered. This function 00237 * is identical to EmptyLanguageIntersection(). 00238 * Method: 00239 * This function checks if the Product() of both automata marks the empty language. 00240 * 00241 * ToDo: modify such that the product is computed only to the necessary extend, i.e. 00242 * do not store product in temporary generator and return false as soon as a 00243 * common transition is found. 00244 * 00245 * No restrictions on parameters. 00246 * 00247 * @param rGen1 00248 * generator marking Lm1 00249 * @param rGen2 00250 * generator marking Lm2 00251 * 00252 * @return 00253 * true if language intersection is empty, false if not. 00254 * 00255 * @ingroup GeneratorFunctions 00256 */ 00257 bool LanguageDisjoint(const Generator& rGen1, const Generator& rGen2); 00258 00259 /** 00260 * Convert generator to automaton. 00261 * 00262 * Convert a generator marking the language Lm into a formal automaton recognizing Lm 00263 * with a dump state representing Sigma*-PrefixClosure(Lm). In this function, Sigma is 00264 * given by the alphabet of rGen; see also Automaton(rGen,rAlphabet). 00265 * For information about automata, see [Wonham. Supervisory Control of Discrete Event 00266 * Systems]. 00267 * The original generated language is ignored. 00268 * Note: An automaton is a deterministic transition structure according to the formal 00269 * definition; see also "Determinism" below. 00270 * Method: 00271 * Uncoaccessible states are erased, as the language generated by rGen is not examined 00272 * in this function. A dump state representing "Sigma*-PrefixClosure(Lm)" is created. 00273 * Then, the transition relation is completed such that it is fully defined for each 00274 * state and each event. Formerly undefined transitions lead to the dump state. 00275 * 00276 * Determinism: 00277 * Input parameter has to be deterministic for correct result. If not, then the 00278 * (also nondeterministic) result recognizes the correct language, but the dump state 00279 * does not represent "Sigma*-PrefixClosure(Lm)" as it should; 00280 * see also example ExAutomaton_basic(). 00281 * If FAUDES_CHECKED is defined a warning on non-deterministic input is issued. 00282 * 00283 * No further restrictions on parameter. 00284 * 00285 * @param rGen 00286 * generator that is converted to automaton 00287 * 00288 * <h4>Example:</h4> 00289 * <table> 00290 * <tr> <td> Generator G </td> <td> Automaton(G) </td> </tr> 00291 * <tr> 00292 * <td> @image html tmp_automaton_g.png </td> 00293 * <td> @image html tmp_automaton_gRes.png </td> 00294 * </tr> 00295 * </table> 00296 * 00297 * @ingroup GeneratorFunctions 00298 */ 00299 void Automaton(Generator& rGen); 00300 00301 /** 00302 * Convert generator to automaton wrt specified alphabet. 00303 * 00304 * Convert a generator marking the language Lm into a formal automaton recognizing Lm 00305 * with a dump state representing Sigma*-PrefixClosure(Lm(rGen)). In this function, 00306 * Sigma is given by the parameter rAlphabet. 00307 * For information about automata, see [Wonham. Supervisory Control of Discrete Event 00308 * Systems]. 00309 * The original generated language is ignored. 00310 * Note: An automaton is a deterministic transition structure according to the formal 00311 * definition; see also "Determinism" below. 00312 * Method: 00313 * Uncoaccessible states are erased, as the language generated by rGen is not examined 00314 * in this function. A dump state representing "Sigma*-PrefixClosure(Lm)" is created. 00315 * Then, the transition relation is completed such that it is fully defined for each 00316 * state of rGen and each event of rAlphabet. Formerly undefined transitions lead to 00317 * the dump state. 00318 * 00319 * Determinism: 00320 * Input parameter has to be deterministic for correct result. If not, then the 00321 * (also nondeterministic) result recognizes the correct language, but the dump state 00322 * does not represent "Sigma*-PrefixClosure(Lm)" as it should; 00323 * see also example ExAutomaton_basic(). 00324 * If FAUDES_CHECKED is defined a warning on non-deterministic input is issued. 00325 * 00326 * No further restrictions on parameters. 00327 * 00328 * @param rGen 00329 * generator that is converted to automaton 00330 * 00331 * @param rAlphabet 00332 * the dump state of the resulting automaton represents the 00333 * language L_dump=rAlphabet*-PrefixClosure(Lm(rGen)) 00334 * 00335 * @ingroup GeneratorFunctions 00336 */ 00337 void Automaton(Generator& rGen, const EventSet& rAlphabet); 00338 00339 /** 00340 * Language complement. 00341 * 00342 * Convert generator marking the language Lm into generator marking the language 00343 * complement of Lm which is defined as Sigma*-Lm. In this function, Sigma is 00344 * given by the alphabet of rGen; see also LanguageComplement(rGen,rAlphabet). 00345 * The original generated language is ignored. 00346 * Method: 00347 * This function calls Automaton() first and then inverts the marking of the states 00348 * of the result. 00349 * 00350 * Determinism: 00351 * Input parameter has to be deterministic for correct result, see Automaton() for 00352 * explanations. 00353 * If FAUDES_CHECKED is defined a warning on non-deterministic input is issued. 00354 * (by function Automaton()). 00355 * 00356 * No further restrictions on parameter. 00357 * 00358 * @param rGen 00359 * generator on which the language complement is performed 00360 * 00361 * <h4>Example:</h4> 00362 * <table> 00363 * <tr> <td> Generator G </td> <td> LanguageComplement(G) </td> </tr> 00364 * <tr> 00365 * <td> @image html tmp_boolean_g1.png </td> 00366 * <td> @image html tmp_complement_g1.png </td> 00367 * </tr> 00368 * </table> 00369 * 00370 * 00371 * @ingroup GeneratorFunctions 00372 */ 00373 void LanguageComplement(Generator& rGen); 00374 00375 /** 00376 * Language complement wrt specified alphabet. 00377 * 00378 * Convert generator marking the language Lm into generator marking the language 00379 * complement of Lm which is defined as Sigma*-Lm. In this function, Sigma is 00380 * given by the parameter rAlphabet. 00381 * The original generated language is ignored. 00382 * Method: 00383 * This function calls Automaton() first and then inverts the marking of the states 00384 * of the result. 00385 * 00386 * Determinism: 00387 * Input parameter has to be deterministic for correct result, see Automaton() for 00388 * explanations. 00389 * If FAUDES_CHECKED is defined a warning on non-deterministic input is issued. 00390 * (by function Automaton()). 00391 * 00392 * No further restrictions on parameter. 00393 * 00394 * @param rGen 00395 * generator on which the language complement is performed 00396 * 00397 * @param rAlphabet 00398 * reference alphabet to build the complement 00399 * 00400 * @ingroup GeneratorFunctions 00401 */ 00402 void LanguageComplement(Generator& rGen, const EventSet& rAlphabet); 00403 00404 00405 /** 00406 * Language Complement (uniform API wrapper). 00407 * 00408 * @param rGen 00409 * generator on which the language complement is performed 00410 * 00411 * @param rRes 00412 * resulting generator 00413 * 00414 * @ingroup GeneratorFunctions 00415 */ 00416 void LanguageComplement(const Generator& rGen, Generator& rRes); 00417 00418 /** 00419 * Language Complement (uniform API wrapper). 00420 * 00421 * @param rGen 00422 * generator on which the language complement is performed 00423 * 00424 * @param rSigma 00425 * reference alphabet to build the complement 00426 * 00427 * @param rRes 00428 * resulting generator 00429 * 00430 * @ingroup GeneratorFunctions 00431 */ 00432 void LanguageComplement(const Generator& rGen, const EventSet& rSigma, Generator& rRes); 00433 00434 00435 00436 /** 00437 * Language difference (set-theoretic difference). 00438 * 00439 * This function calculates Lm1-Lm2 (sometimes also denoted by Lm1\\Lm2), that is the 00440 * set of all strings included in Lm1 but not in Lm2. 00441 * Method: 00442 * The language difference is computed by taking the intersection of Lm1 with the 00443 * complement of Lm2. 00444 * 00445 * Determinism: 00446 * Due to the use of LanguageComplement(), rGen2 has to be deterministic. 00447 * Result can be nondeterministic only if rGen1 is nondeterministic. 00448 * 00449 * Restrictions on prameters: 00450 * rGen2 has to be deterministic. 00451 * 00452 * @param rGen1 00453 * generator marking the language Lm1 00454 * @param rGen2 00455 * generator marking the language Lm2 00456 * @param rResGen 00457 * generator marking the language difference Lm1-Lm2 00458 * 00459 * @exception Exception 00460 * - nondeterministic parameter rGen2 (id 101). 00461 * 00462 * <h4>Example:</h4> 00463 * <table border=0> <tr> <td> <table> 00464 * <tr> <td> Generator G1 </td> <td> Generator G2 </td> </tr> 00465 * <tr> 00466 * <td> @image html tmp_difference_g1.png </td> 00467 * <td> @image html tmp_difference_g2.png </td> 00468 * </tr> 00469 * </table> </td> </tr> <tr> <td> <table width=100%> 00470 * <tr> <td> LanguageDifference(G1,G2,Result) </td> </tr> 00471 * <tr> <td> @image html tmp_difference_g1minusg2.png </td> </tr> 00472 * </table> </td> </tr> </table> 00473 * 00474 * @ingroup GeneratorFunctions 00475 */ 00476 void LanguageDifference(const Generator& rGen1, const Generator& rGen2, 00477 Generator& rResGen); 00478 00479 /** 00480 * Language concatenation, nondeterministic version. 00481 * 00482 * With the languages Lm1 and Lm2 marked by rGen1 and rGen2, respectively, the result 00483 * rResGen marks the concatenation LmRes=Lm1Lm2. 00484 * The languages generated by rGen1 and rGen2 are ignored. It would be possible to let 00485 * the result also generate the concatenation of the generated languages; however, this can 00486 * produce disproportionate computational overhead, if only the marked languages shall be 00487 * concatenated. 00488 * Method: 00489 * rGen2 is appended to rGen1: first, the initial states of rGen2 are erased. Then, 00490 * transitions, that formerly started from the initial state(s) of rGen2, are redirected 00491 * and multiplied such that they start from each marked state of rGen1. The marked states 00492 * corresponding to rGen2 remain marked. The marked states of rGen1 remain marked only if 00493 * rGen2 has at least one marked initial state (i.e. if epsilon is concatenated to Lm1.) 00494 * 00495 * Determinism: 00496 * Input parameters may be nondeterministic. Result can be nondeterministic even if input 00497 * parameters are deterministic; see also LanguageConcatenate(). 00498 * 00499 * No restrictions on parameters. 00500 * 00501 * @param rGen1 00502 * generator marking Lm1 00503 * @param rGen2 00504 * generator marking Lm2 00505 * @param rResGen 00506 * resulting generator marking the language concatenation Lm1Lm2 00507 * 00508 * @ingroup GeneratorFunctions 00509 */ 00510 void LanguageConcatenateNonDet(const Generator& rGen1, const Generator& rGen2, 00511 Generator& rResGen); 00512 00513 /** 00514 * Language concatenation, deterministic version. 00515 * 00516 * With the languages Lm1 and Lm2 marked by rGen1 and rGen2, respectively, the result 00517 * rResGen marks the concatenation LmRes=Lm1Lm2. 00518 * The languages generated by rGen1 and rGen2 are ignored. It would be possible to let 00519 * the result also generate the concatenation of the generated languages; however, this can 00520 * produce disproportionate computational overhead, if only the marked languages shall be 00521 * concatenated. 00522 * Method: 00523 * rGen2 is appended to rGen1: first, the initial states of rGen2 are erased. Then, 00524 * transitions, that formerly started from the initial state(s) of rGen2, are redirected 00525 * and multiplied such that they start from each marked state of rGen1. The marked states 00526 * corresponding to rGen2 remain marked. The marked states of rGen1 remain marked only if 00527 * rGen2 has at least one marked initial state (i.e. if epsilon is concatenated to Lm1.) 00528 * 00529 * Determinism: 00530 * Input parameters may be nondeterministic. 00531 * This function calls LanguageUnionNonDet() and then Deterministic() to convert the 00532 * result into a deterministic generator. Note that this conversion is usually 00533 * straightforward, but there exist theoretical worst-case examples of exponential complexity. 00534 * 00535 * No restrictions on parameters. 00536 * 00537 * @param rGen1 00538 * generator marking Lm1 00539 * @param rGen2 00540 * generator marking Lm2 00541 * @param rResGen 00542 * Resulting generator marking the language concatenation Lm1Lm2 00543 * 00544 * <h4>Example:</h4> 00545 * <table border=0> <tr> <td> <table> 00546 * <tr> <td> Generator G1 </td> <td> </td> <td> LanguageConcatenate(G1,G3,Result) </td> </tr> 00547 * <tr> 00548 * <td> @image html tmp_concat_g1.png </td> 00549 * <td> </td> 00550 * <td> @image html tmp_concat_g1g3.png </td> 00551 * </tr> 00552 * <tr> <td> Generator G2 </td> <td> </td> <td> LanguageConcatenate(G1,G4,Result) </td> </tr> 00553 * <tr> 00554 * <td> @image html tmp_concat_g2.png </td> 00555 * <td> </td> 00556 * <td> @image html tmp_concat_g1g4.png </td> 00557 * </tr> 00558 * </tr> 00559 * <tr> <td> Generator G3 </td> <td> </td> <td> LanguageConcatenate(G2,G3,Result) </td> </tr> 00560 * <tr> 00561 * <td> @image html tmp_concat_g3.png </td> 00562 * <td> </td> 00563 * <td> @image html tmp_concat_g2g3.png </td> 00564 * </tr> 00565 * </tr> 00566 * <tr> <td> Generator G4 </td> <td> </td> <td> LanguageConcatenate(G2,G4,Result) </td> </tr> 00567 * <tr> 00568 * <td> @image html tmp_concat_g4.png </td> 00569 * <td> </td> 00570 * <td> @image html tmp_concat_g2g4.png </td> 00571 * </tr> 00572 * </table> </td> </tr> </table> 00573 * 00574 * @ingroup GeneratorFunctions 00575 */ 00576 void LanguageConcatenate(const Generator& rGen1, const Generator& rGen2, 00577 Generator& rResGen); 00578 00579 /** 00580 * Full Language, L(G)=Lm(G)=Sigma*. 00581 * 00582 * Construct generator generating and marking full language Sigma* from alphabet Sigma. 00583 * Method: this function creates a generator with one state that is marked and init state. This 00584 * state is selflooped with all events from rAlphabet. 00585 * 00586 * @param rAlphabet 00587 * Alphabet Sigma from which full language Sigma* is built 00588 * @param rResGen 00589 * Generator generating and marking full language Sigma* 00590 * 00591 * <h4>Example:</h4> 00592 * <table> 00593 * <tr> <td> FullLanguage(Sigma={a,b},Result) </td> </tr> 00594 * <tr> 00595 * <td> @image html tmp_languagesFull_result.png </td> 00596 * </tr> 00597 * </table> 00598 * 00599 * @ingroup GeneratorFunctions 00600 */ 00601 void FullLanguage(const EventSet& rAlphabet, Generator& rResGen); 00602 00603 /** 00604 * Alphabet Language, L(G)=Lm(G)=Sigma 00605 * 00606 * Construct generator generating and marking an alphabet as languages, that is L(G)=Lm(G)=Sigma. 00607 * Method: this function creates a generator with one init state and one marked state. For each 00608 * event from rAlphabet, a transition is inserted leading from the init state to the marked state. 00609 * 00610 * No restrictions on parameters. 00611 * 00612 * @param rAlphabet 00613 * alphabet from which alphabet language is built 00614 * @param rResGen 00615 * generator with languages Lm(G)=Sigma 00616 * 00617 * <h4>Example:</h4> 00618 * <table> 00619 * <tr> <td> AlphabetLanguage(Sigma={a,b},Result) </td> </tr> 00620 * <tr> 00621 * <td> @image html tmp_languagesAlphabet_result.png </td> 00622 * </tr> 00623 * </table> 00624 * 00625 * @ingroup GeneratorFunctions 00626 */ 00627 void AlphabetLanguage(const EventSet& rAlphabet, Generator& rResGen); 00628 00629 /** 00630 * Empty string language, L(G)=Lm(G)={epsilon}. 00631 * 00632 * Construct generator generating and marking the empty string, that is L(G)=Lm(G)={epsilon}. 00633 * Method: this function creates a generator with one marked init state and the alphabet rAlphabet. 00634 * 00635 * No restrictions on parameters. 00636 * 00637 * @param rAlphabet 00638 * alphabet of the resulting generator 00639 * @param rResGen 00640 * generator with languages L(G)=Lm(G)={epsilon} and alphabet rAlphabet 00641 * 00642 * <h4>Example:</h4> 00643 * <table> 00644 * <tr> <td> EmptyStringLanguage(Sigma={a,b},Result) </td> </tr> 00645 * <tr> 00646 * <td> @image html tmp_languagesEmptyString_result.png </td> 00647 * </tr> 00648 * </table> 00649 * 00650 * @ingroup GeneratorFunctions 00651 */ 00652 void EmptyStringLanguage(const EventSet& rAlphabet, Generator& rResGen); 00653 00654 /** 00655 * Empty language Lm(G)={}. 00656 * 00657 * Construct generator and marking the empty language, that is Lm(G)={}. 00658 * Method: this function creates a deterministic generator with one initial state that is not marked. 00659 * The alphabet is set as specified. 00660 * 00661 * No restrictions on parameters. 00662 * 00663 * @param rAlphabet 00664 * Alphabet of the resulting generator 00665 * @param rResGen 00666 * Generator with language Lm(G)={} 00667 * 00668 * @ingroup GeneratorFunctions 00669 */ 00670 void EmptyLanguage(const EventSet& rAlphabet, Generator& rResGen); 00671 00672 /** 00673 * Test for Empty language Lm(G)=={}. 00674 * 00675 * Tests if the language marked by rGen is empty, that is if Lm(G)=={}. The generated 00676 * language L(G) is not considered. 00677 * Method: 00678 * This function tests if 00679 * a) the set of marked states is empty or else 00680 * b) the intersection of the set of accessible states and the set of marked states 00681 * is empty, i.e. if there is no marked state or if no marked state is accessible (reachable). 00682 * 00683 * No restrictions on parameter. 00684 * 00685 * @param rGen 00686 * generator to be tested for empty marked language 00687 * 00688 * @return 00689 * true on empty marked language, false on nonempty marked language 00690 * 00691 * @ingroup GeneratorFunctions 00692 */ 00693 bool IsEmptyLanguage(const Generator& rGen); 00694 00695 /** 00696 * Test language inclusion, Lm1<=Lm2. 00697 * 00698 * Test if language Lm1 marked by rGen1 is included in language Lm2 marked by rGen2. The 00699 * generated languages are not considered. 00700 * Method: 00701 * This function checks if there is no string in Lm1 that is not in Lm2 by testing if 00702 * the intersection of Lm1 and the language complement of Lm2 is empty. 00703 * 00704 * Restrictions on parameters: rGen2 has to be deterministic! 00705 * If FAUDES_CHECKED is defined a warning on non-deterministic input is issued. 00706 * (by function Automaton()). 00707 * 00708 * Determinism: correctness in case of nondeterministic parameter rGen1 has been tested with an 00709 * example (see ExInclusion_simple), but not proven. 00710 * 00711 * ToDo: implement faster version using a variant of Product(): 00712 * compute product without storing result, return false as soon as some event is 00713 * possible in Lm2 but not in Lm1. 00714 * 00715 * @param rGen1 00716 * generator marking Lm1 00717 * @param rGen2 00718 * generator marking Lm2 00719 * 00720 * @return 00721 * true if language marked by rGen1 is included in language marked by rGen2 00722 * 00723 * @ingroup GeneratorFunctions 00724 */ 00725 bool LanguageInclusion(const Generator& rGen1, const Generator& rGen2); 00726 00727 /** 00728 * Language equality, Lm1==Lm2. 00729 * 00730 * Test if the language Lm1 marked by rGen1 equals the language Lm2 marked by rGen2. The 00731 * generated languages are not considered. 00732 * Method: 00733 * This function checks mutual inclusion of Lm1 in Lm2 and of Lm2 in Lm1 using the 00734 * function LanguageInclusion(). 00735 * 00736 * Restrictions on parameters: rGen1 and rGen2 have to be deterministic! 00737 * If FAUDES_CHECKED is defined a warning on non-deterministic input is issued. 00738 * (by function Automaton()). 00739 * 00740 * ToDo: implement faster, version using a variant of Product(): 00741 * compute product without storing result, return false as soon as rGen1 and rGen2 00742 * "disagree" on the occurrence of some event. 00743 * 00744 * @param rGen1 00745 * generator marking Lm1 00746 * @param rGen2 00747 * generator marking Lm2 00748 * 00749 * @return 00750 * true if the language marked by rGen1 equals the language marked by rGen2 00751 * 00752 * @ingroup GeneratorFunctions 00753 */ 00754 bool LanguageEquality(const Generator& rGen1, const Generator& rGen2); 00755 00756 /** 00757 * Kleene Closure. 00758 * 00759 * This function computes the Kleene Closure ( ()* - operator) of the 00760 * language marked by rGen. The generated language is not considered. 00761 * Method: KleeneClosureNonDet() is called, which, for all transitions 00762 * leading from a state x to a marked state, inserts a transition with the 00763 * same event starting from x and leading to (one of) the initial state(s). 00764 * As this step causes nondeterminism, the function Deterministic() is called. 00765 * See also KleeneClosureNonDet(). 00766 * 00767 * No restrictions on parameter. 00768 * 00769 * @param rGen 00770 * generator marking the language Lm to which the Kleene Closure is applied 00771 * 00772 * <h4>Example:</h4> 00773 * <table> 00774 * <tr> <td> Generator G </td> <td> KleeneClosure(G) </td> </tr> 00775 * <tr> 00776 * <td> @image html tmp_kleene_g.png </td> 00777 * <td> @image html tmp_kleene_gRes.png </td> 00778 * </tr> 00779 * </table> 00780 * 00781 * @ingroup GeneratorFunctions 00782 */ 00783 void KleeneClosure(Generator& rGen); 00784 00785 /** 00786 * Kleene Closure. 00787 * 00788 * This function is a convenience wrapper for KleeneClosure(Generator&). 00789 * 00790 * 00791 * @ingroup GeneratorFunctions 00792 */ 00793 void KleeneClosure(const Generator& rGen, Generator& rResGen); 00794 00795 /** 00796 * Kleene Closure, nondeterministic version. 00797 * 00798 * This function computes the Kleene Closure ( ()* - operator) of the 00799 * language marked by rGen. The generated language is not considered. 00800 * Method: KleeneClosureNonDet() is called, which, for all transitions 00801 * leading from a state x to a marked state, inserts a transition with the 00802 * same event starting from x and leading to (one of) the initial state(s). 00803 * 00804 * @param rGen 00805 * generator marking the language Lm to which Kleene Closure is applied 00806 * 00807 * @ingroup GeneratorFunctions 00808 */ 00809 void KleeneClosureNonDet(Generator& rGen); 00810 00811 /** 00812 * Prefix Closure. 00813 * 00814 * This function computes the prefix closure the language Lm marked by rGen. A 00815 * language Lm is prefix closed if each string of Lm implies that all its 00816 * prefixes are also element of Lm. The prefix closure of a language marked by 00817 * a generator is always a subset of the generated language and is represented 00818 * by the set of coaccessible states of the generator. 00819 * Method: 00820 * First, Coaccessible() is called to erase all states of rGen that do not 00821 * represent prefixes of marked strings. Then, all remaining states are marked. 00822 * 00823 * No restrictions on parameter. 00824 * 00825 * ToDo: (slightly) more efficient version: implement generator function 00826 * CoAccessibleSet() similar to AccessibleSet() and call 00827 * InjectMarkedStates(AccessibleSet()). 00828 * 00829 * @param rGen 00830 * generator marking the language Lm to which prefix closure is applied 00831 * 00832 * <h4>Example:</h4> 00833 * <table> 00834 * <tr> <td> Generator G </td> <td> PrefixClosure(G) </td> </tr> 00835 * <tr> 00836 * <td> @image html tmp_prefixclosure_g.png </td> 00837 * <td> @image html tmp_prefixclosure_gRes.png </td> 00838 * </tr> 00839 * </table> 00840 * 00841 * @ingroup GeneratorFunctions 00842 */ 00843 void PrefixClosure(Generator& rGen); 00844 00845 00846 /** 00847 * Test for prefix closed marked language. 00848 * 00849 * This function tests whether the language Lm(G) marked by the specified generator G 00850 * is prefix closed. It does so by testing whether all accessible and coaccessible 00851 * states are marked. 00852 * 00853 * The specified generator must be deterministic. 00854 * 00855 * @param rGen 00856 * generator G marking the Lm(G) to test 00857 * @return 00858 * True <> Lm(G) is prefix closed 00859 * 00860 * @ingroup GeneratorFunctions 00861 */ 00862 bool IsPrefixClosed(const Generator& rGen); 00863 00864 00865 /** 00866 * Test for nonblocking generator 00867 * 00868 * A generator G is nonblocking if closure(Lm(G)) = L(G), i.e. 00869 * if every accessible state is coacessile. 00870 * 00871 * The specified generator must be deterministic. 00872 * 00873 * @param rGen 00874 * generator G marking to test 00875 * @return 00876 * True <> G is nonblocking 00877 * 00878 * @ingroup GeneratorFunctions 00879 */ 00880 bool IsNonblocking(const Generator& rGen); 00881 00882 /** 00883 * Test for nonblocking marked languages. 00884 * 00885 * Two languages L1 and L2 are nonblocking, if 00886 * closure(L1 || L2) == closure(L1) || closure(L2). 00887 * 00888 * This function performs the parallel composition of the two 00889 * specified generators and tests it for nonblockingness. Provided 00890 * that both generators are trim, this is equivalent to the 00891 * respective marked languages being nonblocking. 00892 * 00893 * The specified generators must be trim. 00894 * 00895 * @param rGen1 00896 * Generator G1 00897 * @param rGen2 00898 * Generator G2 00899 * @return 00900 * True <> Lm(G1) and Lm(G2) are nonblocking 00901 * 00902 * @ingroup GeneratorFunctions 00903 */ 00904 bool IsNonblocking(const Generator& rGen1, const Generator& rGen2); 00905 00906 00907 /** 00908 * Self-loop all states. 00909 * 00910 * This function selfoops all states of rGen with the events from rAlphabet. 00911 * Method: 00912 * The alphabet of rGen is extended by rAlphabet. For each state x of rGen 00913 * and each event alpha of rAlphabet, a transition (x,alpha,x) is inserted, 00914 * irrespective of whether this event was already active in x before. 00915 * See also SelfLoop(rGen,rAlphabet,rStates) and SelfLoopMarkedStates(rGen,rAlphabet). 00916 * 00917 * No restrictions on parameter. 00918 * 00919 * Determinism: resulting generator is nondeterministic, if it was nondeterministic 00920 * before, or if rGen already contains one or more (non selfloop) transitions with 00921 * events from rAlphabet. 00922 * 00923 * @param rGen 00924 * generator to be selflooped with events from rAlphabet 00925 * @param rAlphabet 00926 * alphabet with selfloop events 00927 * 00928 * <h4>Example:</h4> 00929 * <table> 00930 * <tr> <td> Generator G </td> <td> SelfLoop(G,Sigma={e,f}) </td> </tr> 00931 * <tr> 00932 * <td> @image html tmp_selfloop_g.png </td> 00933 * <td> @image html tmp_selfloop_gRes.png </td> 00934 * </tr> 00935 * </table> 00936 * 00937 * @ingroup GeneratorFunctions 00938 */ 00939 void SelfLoop(Generator& rGen,const EventSet& rAlphabet); 00940 00941 /** 00942 * Self-loop all marked states. 00943 * 00944 * This function selfoops all marked states of rGen with the events from rAlphabet. 00945 * Method: 00946 * The alphabet of rGen is extended by rAlphabet. For each marked state x of rGen 00947 * and each event alpha of rAlphabet, a transition (x,alpha,x) is inserted, 00948 * irrespective of whether this event was already active in x before. 00949 * See also SelfLoop(rGen,rAlphabet) and SelfLoop(rGen,rAlphabet,rStates). 00950 * 00951 * No restrictions on parameter. 00952 * 00953 * Determinism: resulting generator is nondeterministic, if it was nondeterministic 00954 * before, or if rGen already contains one or more (non selfloop) transitions 00955 * starting from a marked state with events from rAlphabet. 00956 * 00957 * @param rGen 00958 * generator with marked states to be selflooped with events from rAlphabet 00959 * @param rAlphabet 00960 * alphabet with selfloop events 00961 * 00962 * <h4>Example:</h4> 00963 * <table> 00964 * <tr> <td> Generator G </td> <td> SelfLoopMarkedStates(G,Sigma={e,f}) </td> </tr> 00965 * <tr> 00966 * <td> @image html tmp_selfloop_g.png </td> 00967 * <td> @image html tmp_selfloopMarked_gRes.png </td> 00968 * </tr> 00969 * </table> 00970 * 00971 * @ingroup GeneratorFunctions 00972 */ 00973 void SelfLoopMarkedStates(Generator& rGen,const EventSet& rAlphabet); 00974 00975 /** 00976 * Self-loop specified states. 00977 * 00978 * This function selfoops the states rStates of rGen with the events from rAlphabet. 00979 * Method: 00980 * The alphabet of rGen is extended by rAlphabet. For each state x of rStates 00981 * and each event alpha of rAlphabet, a transition (x,alpha,x) is inserted, 00982 * irrespective of whether this event was already active in x before. 00983 * See also SelfLoop(rGen,rAlphabet) and SelfLoopMarkedStates(rGen,rAlphabet). 00984 * 00985 * No restrictions on parameter. 00986 * 00987 * Determinism: resulting generator is nondeterministic, if it was nondeterministic 00988 * before, or if rGen already contains one or more (non selfloop) transitions 00989 * starting from a state of rState with events from rAlphabet. 00990 * 00991 * @param rGen 00992 * generator with marked states to be selflooped with events from rAlphabet 00993 * @param rAlphabet 00994 * alphabet with selfloop events 00995 * @param rStates 00996 * states to apply selfloop 00997 * 00998 * @exception Exception 00999 * - rStates is not a subset of rGen.States() (id 100). 01000 * 01001 * <h4>Example:</h4> 01002 * <table> 01003 * <tr> <td> Generator G </td> <td> SelfLoop(G,Sigma={e,f},G.InitStates()) </td> </tr> 01004 * <tr> 01005 * <td> @image html tmp_selfloop_g.png </td> 01006 * <td> @image html tmp_selfloopInit_gRes.png </td> 01007 * </tr> 01008 * </table> 01009 * 01010 * @ingroup GeneratorFunctions 01011 */ 01012 void SelfLoop(Generator& rGen,const EventSet& rAlphabet,const StateSet& rStates); 01013 01014 01015 01016 01017 } // namespace faudes 01018 01019 #define FAUDES_REGULAR_H 01020 #endif 01021 |
libFAUDES 2.20s --- 2011.10.12 --- c++ source docu by doxygen