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