cfl_regular.h
Go to the documentation of this file.
1 
2 /** @file cfl_regular.h
3 
4 Operations on regular languages.
5 See [Cassandras and Lafortune. Introduction to Discrete Event Systems] for an
6 introduction to regular language operations.
7 Operations are always performed on language(s) marked by the passed generator(s),
8 resulting in the language(s) marked by the resulting generator(s).
9 Only if mentioned extra, the same is done for the involved generated (prefix-closed)
10 languages.
11 
12 */
13 
14 /* FAU Discrete Event Systems Library (libfaudes)
15 
16  Copyright (C) 2006 Bernd Opitz
17  Exclusive copyright is granted to Klaus Schmidt
18 
19  This library is free software; you can redistribute it and/or
20  modify it under the terms of the GNU Lesser General Public
21  License as published by the Free Software Foundation; either
22  version 2.1 of the License, or (at your option) any later version.
23 
24  This library is distributed in the hope that it will be useful,
25  but WITHOUT ANY WARRANTY; without even the implied warranty of
26  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27  Lesser General Public License for more details.
28 
29  You should have received a copy of the GNU Lesser General Public
30  License along with this library; if not, write to the Free Software
31  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
32 
33 
34 #ifndef FAUDES_REGULAR_H
35 
36 #include "cfl_definitions.h"
37 #include "cfl_parallel.h"
38 #include "cfl_project.h"
39 
40 namespace faudes {
41 
42 /**
43  * Language union, nondeterministic version.
44  *
45  * This function performs the union of two languages marked by two generators;
46  * the resulting generator marks the resulting language.
47  * Moreover, the same is done for the involved generated (prefix-closed) languages.
48  * Method:
49  * This function implements the textbook version in taking unions of all generator
50  * entities (alphabets, initial states, ...) of rGen1 and rGen2. State sets are taken
51  * as disjoint by definition and thus reindexed and renamed to achieve disjoint union.
52  * The resulting language is defined over the union of the alphabets of the original
53  * languages; original languages defined over different alphabets are treated as if
54  * they were defined over the union of both alphabets.
55  *
56  * Determinism:
57  * Input parameters may be nondeterministic.
58  * This function is more economical than the deterministic version, but likely to
59  * produce a non-deterministic result; see also LanguageUnion().
60  *
61  * No restrictions on parameters.
62  *
63  * @param rGen1
64  * generator generating/marking L1/Lm1
65  * @param rGen2
66  * generator generating/marking L2/Lm2
67  * @param rResGen
68  * resulting generator generating/marking the language union of L1 and L2/of Lm1 and Lm2
69  *
70  *
71  * @ingroup GeneratorFunctions
72  */
73 void LanguageUnionNonDet(const Generator& rGen1, const Generator& rGen2,
74  Generator& rResGen);
75 
76 /**
77  * Language union, deterministic version.
78  *
79  * This function performs the union of two languages marked by two generators;
80  * the resulting generator marks the resulting language.
81  * Moreover, the same is done for the involved generated (prefix-closed) |languages.
82  * Method:
83  * This function implements the textbook version (which textbook??) in taking unions
84  * of all generator entities (alphabets, initial states, ...). State sets are taken
85  * as disjoint by definition and thus reindexed and renamed to achieve disjoint union.
86  * The resulting language is defined over the union of the alphabets of the original
87  * languages.
88  *
89  * Determinism:
90  * Input parameters may be nondeterministic.
91  * This function calls LanguageUnionNonDet() and then Deterministic() to convert the
92  * result into a deterministic generator. Note that this conversion is usually
93  * straightforward, but there exist theoretical worst-case examples of exponential complexity.
94  *
95  * No restrictions on parameters.
96  *
97  * ToDo: a version similar to parallel composition that produces a deterministic result by construction. (?)
98  *
99  * @param rGen1
100  * generator generating/marking L1/Lm1
101  * @param rGen2
102  * generator generating/marking L2/Lm2
103  * @param rResGen
104  * resulting generator generating/marking the language union of L1 and L2/of Lm1 and Lm2
105  *
106  * <h4>Example:</h4>
107  * <table border=0> <tr> <td> <table>
108  * <tr> <td> Generator G1 </td> <td> Generator G2 </td> </tr>
109  * <tr>
110  * <td> @image html tmp_boolean_g1.png </td>
111  * <td> @image html tmp_boolean_g2.png </td>
112  * </tr>
113  * </table> </td> </tr> <tr> <td> <table width=100%>
114  * <tr> <td> LanguageUnion(G1,G2,Result) </td> </tr>
115  * <tr> <td> @image html tmp_union_g1g2.png </td> </tr>
116  * </table> </td> </tr> </table>
117  *
118  * @ingroup GeneratorFunctions
119  */
120 void LanguageUnion(const Generator& rGen1, const Generator& rGen2,
121  Generator& rResGen);
122 
123 /**
124  * Language union.
125  *
126  * See also LanguageUnion(const Generator&, const Generator&, Generator&);
127  * This version takes a vector of generators as argument to perform
128  * the union for multiple languages. The implementation
129  * calls the std union multiple times, future implementations may
130  * do better.
131  *
132  * @param rGenVec
133  * Vector of input generators
134  * @param rResGen
135  * Reference to resulting generator
136  *
137  */
138 void LanguageUnion(const GeneratorVector& rGenVec, Generator& rResGen);
139 
140 
141 /**
142  * Language intersection.
143  *
144  * This function performs the intersection of two languages marked by two generators;
145  * the resulting generator marks the resulting language.
146  * Moreover, the same is done for the involved generated (prefix-closed) languages.
147  * The resulting languages are defined over the intersection of the involved alphabets.
148  * Method:
149  * This function calls Product(). In the product of two automata, an event occurs if
150  * and only if it occurs in both automata rGen1 and rGen2. The result generates/marks
151  * the intersection of the involved languages, see e.g.
152  * [Cassandras, Lafortune. Introduction to Discrete Event Systems, p.84]
153  *
154  * Determinism:
155  * Input parameters may be nondeterministic.
156  * Result can be nondeterministic only if input parameters are nondeterministic.
157  *
158  * No restrictions on parameters.
159  *
160  * @param rGen1
161  * generator generating/marking L1/Lm1
162  * @param rGen2
163  * generator generating/marking L2/Lm2
164  * @param rResGen
165  * resulting generator generating/marking the language intersection of L1 and L2/of Lm1 and Lm2
166  *
167  * <h4>Example:</h4>
168  *
169  * <table border=0> <tr> <td> <table>
170  * <tr> <td> Generator G1 </td> <td> Generator G2 </td> </tr>
171  * <tr>
172  * <td> @image html tmp_boolean_g1.png </td>
173  * <td> @image html tmp_boolean_g2.png </td>
174  * </tr>
175  * </table> </td> </tr> <tr> <td> <table width=100%>
176  * <tr> <td> LanguageIntersection(G1,G2,Result) </td> </tr>
177  * <tr> <td> @image html tmp_intersection_g1g2.png </td> </tr>
178  * </table> </td> </tr> </table>
179  *
180  * @ingroup GeneratorFunctions
181  */
182 void LanguageIntersection(const Generator& rGen1, const Generator& rGen2,
183  Generator& rResGen);
184 
185 /**
186  * Language intersection.
187  *
188  * See also LanguageUnion(const Generator&, const Generator&, Generator&);
189  * This version takes a vector of generators as argument to perform
190  * the intersection for multiple languages. The implementation
191  * calls the std intersection multiple times, future implementations may
192  * do better.
193  *
194  * @param rGenVec
195  * Vector of input generators
196  * @param rResGen
197  * Reference to resulting generator
198  *
199  */
200 void LanguageIntersection(const GeneratorVector& rGenVec, Generator& rResGen);
201 
202 
203 /**
204  * Test for empty language intersection (same as Disjoind()).
205  *
206  * This function checks if the intersection of two languages marked by two generators
207  * is empty that is the two languages are disjoint.
208  * The involved generated (prefix-closed) languages are not considered. This function
209  * is identical to Disjoint().
210  *
211  * No restrictions on parameters.
212  *
213  * @param rGen1
214  * generator marking Lm1
215  * @param rGen2
216  * generator marking Lm2
217  *
218  * @return
219  * true if language intersection is empty, false if not.
220  *
221  * @ingroup GeneratorFunctions
222  */
223 bool EmptyLanguageIntersection(const Generator& rGen1, const Generator& rGen2);
224 
225 /**
226  * Test whether two languages are disjoint.
227  *
228  * This function tests whether the intersection of two languages marked by two generators
229  * is empty, ie the two languages are disjoint.
230  * The involved generated (prefix-closed) languages are not considered. This function
231  * is identical to EmptyLanguageIntersection().
232  *
233  * No restrictions on parameters.
234  *
235  * @param rGen1
236  * generator marking Lm1
237  * @param rGen2
238  * generator marking Lm2
239  *
240  * @return
241  * true if language intersection is empty, false if not.
242  *
243  * @ingroup GeneratorFunctions
244  */
245 bool LanguageDisjoint(const Generator& rGen1, const Generator& rGen2);
246 
247 /**
248  * Convert generator to automaton.
249  *
250  * Convert a generator marking the language Lm into a formal automaton recognizing Lm
251  * with a dump state representing Sigma*-PrefixClosure(Lm). In this function, Sigma is
252  * given by the alphabet of rGen; see also Automaton(rGen,rAlphabet).
253  * For information about automata, see [Wonham. Supervisory Control of Discrete Event
254  * Systems].
255  * The original generated language is ignored.
256  * Note: An automaton is a deterministic transition structure according to the formal
257  * definition; see also "Determinism" below.
258  * Method:
259  * Uncoaccessible states are erased, as the language generated by rGen is not examined
260  * in this function. A dump state representing "Sigma*-PrefixClosure(Lm)" is created.
261  * Then, the transition relation is completed such that it is fully defined for each
262  * state and each event. Formerly undefined transitions lead to the dump state.
263  *
264  * Determinism:
265  * Input parameter has to be deterministic for correct result. If not, then the
266  * (also nondeterministic) result recognizes the correct language, but the dump state
267  * does not represent "Sigma*-PrefixClosure(Lm)" as it should;
268  * see also example ExAutomaton_basic().
269  * If FAUDES_CHECKED is defined a warning on non-deterministic input is issued.
270  *
271  * No further restrictions on parameter.
272  *
273  * @param rGen
274  * generator that is converted to automaton
275  *
276  * <h4>Example:</h4>
277  * <table>
278  * <tr> <td> Generator G </td> <td> Automaton(G) </td> </tr>
279  * <tr>
280  * <td> @image html tmp_automaton_g.png </td>
281  * <td> @image html tmp_automaton_gRes.png </td>
282  * </tr>
283  * </table>
284  *
285  * @ingroup GeneratorFunctions
286  */
287 void Automaton(Generator& rGen);
288 
289 /**
290  * Convert generator to automaton wrt specified alphabet.
291  *
292  * Convert a generator marking the language Lm into a formal automaton recognizing Lm
293  * with a dump state representing Sigma*-PrefixClosure(Lm(rGen)). In this function,
294  * Sigma is given by the parameter rAlphabet.
295  * For information about automata, see [Wonham. Supervisory Control of Discrete Event
296  * Systems].
297  * The original generated language is ignored.
298  * Note: An automaton is a deterministic transition structure according to the formal
299  * definition; see also "Determinism" below.
300  * Method:
301  * Uncoaccessible states are erased, as the language generated by rGen is not examined
302  * in this function. A dump state representing "Sigma*-PrefixClosure(Lm)" is created.
303  * Then, the transition relation is completed such that it is fully defined for each
304  * state of rGen and each event of rAlphabet. Formerly undefined transitions lead to
305  * the dump state.
306  *
307  * Determinism:
308  * Input parameter has to be deterministic for correct result. If not, then the
309  * (also nondeterministic) result recognizes the correct language, but the dump state
310  * does not represent "Sigma*-PrefixClosure(Lm)" as it should;
311  * see also example ExAutomaton_basic().
312  * If FAUDES_CHECKED is defined a warning on non-deterministic input is issued.
313  *
314  * No further restrictions on parameters.
315  *
316  * @param rGen
317  * generator that is converted to automaton
318  *
319  * @param rAlphabet
320  * the dump state of the resulting automaton represents the
321  * language L_dump=rAlphabet*-PrefixClosure(Lm(rGen))
322  *
323  * @ingroup GeneratorFunctions
324  */
325 void Automaton(Generator& rGen, const EventSet& rAlphabet);
326 
327 /**
328  * Language complement.
329  *
330  * Convert generator marking the language Lm into generator marking the language
331  * complement of Lm which is defined as Sigma*-Lm. In this function, Sigma is
332  * given by the alphabet of rGen; see also LanguageComplement(rGen,rAlphabet).
333  * The original generated language is ignored.
334  * Method:
335  * This function calls Automaton() first and then inverts the marking of the states
336  * of the result.
337  *
338  * Determinism:
339  * Input parameter has to be deterministic for correct result, see Automaton() for
340  * explanations.
341  * If FAUDES_CHECKED is defined a warning on non-deterministic input is issued.
342  * (by function Automaton()).
343  *
344  * No further restrictions on parameter.
345  *
346  * @param rGen
347  * generator on which the language complement is performed
348  *
349  * <h4>Example:</h4>
350  * <table>
351  * <tr> <td> Generator G </td> <td> LanguageComplement(G) </td> </tr>
352  * <tr>
353  * <td> @image html tmp_boolean_g1.png </td>
354  * <td> @image html tmp_complement_g1.png </td>
355  * </tr>
356  * </table>
357  *
358  *
359  * @ingroup GeneratorFunctions
360  */
361 void LanguageComplement(Generator& rGen);
362 
363 /**
364  * Language complement wrt specified alphabet.
365  *
366  * Convert generator marking the language Lm into generator marking the language
367  * complement of Lm which is defined as Sigma*-Lm. In this function, Sigma is
368  * given by the parameter rAlphabet.
369  * The original generated language is ignored.
370  * Method:
371  * This function calls Automaton() first and then inverts the marking of the states
372  * of the result.
373  *
374  * Determinism:
375  * Input parameter has to be deterministic for correct result, see Automaton() for
376  * explanations.
377  * If FAUDES_CHECKED is defined a warning on non-deterministic input is issued.
378  * (by function Automaton()).
379  *
380  * No further restrictions on parameter.
381  *
382  * @param rGen
383  * generator on which the language complement is performed
384  *
385  * @param rAlphabet
386  * reference alphabet to build the complement
387  *
388  * @ingroup GeneratorFunctions
389  */
390 void LanguageComplement(Generator& rGen, const EventSet& rAlphabet);
391 
392 
393 /**
394  * Language Complement (uniform API wrapper).
395  *
396  * @param rGen
397  * generator on which the language complement is performed
398  *
399  * @param rRes
400  * resulting generator
401  *
402  * @ingroup GeneratorFunctions
403  */
404 void LanguageComplement(const Generator& rGen, Generator& rRes);
405 
406 /**
407  * Language Complement (uniform API wrapper).
408  *
409  * @param rGen
410  * generator on which the language complement is performed
411  *
412  * @param rSigma
413  * reference alphabet to build the complement
414  *
415  * @param rRes
416  * resulting generator
417  *
418  * @ingroup GeneratorFunctions
419  */
420 void LanguageComplement(const Generator& rGen, const EventSet& rSigma, Generator& rRes);
421 
422 
423 
424 /**
425  * Language difference (set-theoretic difference).
426  *
427  * This function calculates Lm1-Lm2 (sometimes also denoted by Lm1\\Lm2), that is the
428  * set of all strings included in Lm1 but not in Lm2.
429  * Method:
430  * The language difference is computed by taking the intersection of Lm1 with the
431  * complement of Lm2.
432  *
433  * Determinism:
434  * Due to the use of LanguageComplement(), rGen2 has to be deterministic.
435  * Result can be nondeterministic only if rGen1 is nondeterministic.
436  *
437  * Restrictions on prameters:
438  * rGen2 has to be deterministic.
439  *
440  * @param rGen1
441  * generator marking the language Lm1
442  * @param rGen2
443  * generator marking the language Lm2
444  * @param rResGen
445  * generator marking the language difference Lm1-Lm2
446  *
447  * @exception Exception
448  * - nondeterministic parameter rGen2 (id 101).
449  *
450  * <h4>Example:</h4>
451  * <table border=0> <tr> <td> <table>
452  * <tr> <td> Generator G1 </td> <td> Generator G2 </td> </tr>
453  * <tr>
454  * <td> @image html tmp_difference_g1.png </td>
455  * <td> @image html tmp_difference_g2.png </td>
456  * </tr>
457  * </table> </td> </tr> <tr> <td> <table width=100%>
458  * <tr> <td> LanguageDifference(G1,G2,Result) </td> </tr>
459  * <tr> <td> @image html tmp_difference_g1minusg2.png </td> </tr>
460  * </table> </td> </tr> </table>
461  *
462  * @ingroup GeneratorFunctions
463  */
464 void LanguageDifference(const Generator& rGen1, const Generator& rGen2,
465  Generator& rResGen);
466 
467 /**
468  * Language concatenation, nondeterministic version.
469  *
470  * With the languages Lm1 and Lm2 marked by rGen1 and rGen2, respectively, the result
471  * rResGen marks the concatenation LmRes=Lm1Lm2.
472  * The languages generated by rGen1 and rGen2 are ignored. It would be possible to let
473  * the result also generate the concatenation of the generated languages; however, this can
474  * produce disproportionate computational overhead, if only the marked languages shall be
475  * concatenated.
476  * Method:
477  * rGen2 is appended to rGen1: first, the initial states of rGen2 are erased. Then,
478  * transitions, that formerly started from the initial state(s) of rGen2, are redirected
479  * and multiplied such that they start from each marked state of rGen1. The marked states
480  * corresponding to rGen2 remain marked. The marked states of rGen1 remain marked only if
481  * rGen2 has at least one marked initial state (i.e. if epsilon is concatenated to Lm1.)
482  *
483  * Determinism:
484  * Input parameters may be nondeterministic. Result can be nondeterministic even if input
485  * parameters are deterministic; see also LanguageConcatenate().
486  *
487  * No restrictions on parameters.
488  *
489  * @param rGen1
490  * generator marking Lm1
491  * @param rGen2
492  * generator marking Lm2
493  * @param rResGen
494  * resulting generator marking the language concatenation Lm1Lm2
495  *
496  * @ingroup GeneratorFunctions
497  */
498 void LanguageConcatenateNonDet(const Generator& rGen1, const Generator& rGen2,
499  Generator& rResGen);
500 
501 /**
502  * Language concatenation, deterministic version.
503  *
504  * With the languages Lm1 and Lm2 marked by rGen1 and rGen2, respectively, the result
505  * rResGen marks the concatenation LmRes=Lm1Lm2.
506  * The languages generated by rGen1 and rGen2 are ignored. It would be possible to let
507  * the result also generate the concatenation of the generated languages; however, this can
508  * produce disproportionate computational overhead, if only the marked languages shall be
509  * concatenated.
510  * Method:
511  * rGen2 is appended to rGen1: first, the initial states of rGen2 are erased. Then,
512  * transitions, that formerly started from the initial state(s) of rGen2, are redirected
513  * and multiplied such that they start from each marked state of rGen1. The marked states
514  * corresponding to rGen2 remain marked. The marked states of rGen1 remain marked only if
515  * rGen2 has at least one marked initial state (i.e. if epsilon is concatenated to Lm1.)
516  *
517  * Determinism:
518  * Input parameters may be nondeterministic.
519  * This function calls LanguageUnionNonDet() and then Deterministic() to convert the
520  * result into a deterministic generator. Note that this conversion is usually
521  * straightforward, but there exist theoretical worst-case examples of exponential complexity.
522  *
523  * No restrictions on parameters.
524  *
525  * @param rGen1
526  * generator marking Lm1
527  * @param rGen2
528  * generator marking Lm2
529  * @param rResGen
530  * Resulting generator marking the language concatenation Lm1Lm2
531  *
532  * <h4>Example:</h4>
533  * <table border=0> <tr> <td> <table>
534  * <tr> <td> Generator G1 </td> <td> </td> <td> LanguageConcatenate(G1,G3,Result) </td> </tr>
535  * <tr>
536  * <td> @image html tmp_concat_g1.png </td>
537  * <td> </td>
538  * <td> @image html tmp_concat_g1g3.png </td>
539  * </tr>
540  * <tr> <td> Generator G2 </td> <td> </td> <td> LanguageConcatenate(G1,G4,Result) </td> </tr>
541  * <tr>
542  * <td> @image html tmp_concat_g2.png </td>
543  * <td> </td>
544  * <td> @image html tmp_concat_g1g4.png </td>
545  * </tr>
546  * </tr>
547  * <tr> <td> Generator G3 </td> <td> </td> <td> LanguageConcatenate(G2,G3,Result) </td> </tr>
548  * <tr>
549  * <td> @image html tmp_concat_g3.png </td>
550  * <td> </td>
551  * <td> @image html tmp_concat_g2g3.png </td>
552  * </tr>
553  * </tr>
554  * <tr> <td> Generator G4 </td> <td> </td> <td> LanguageConcatenate(G2,G4,Result) </td> </tr>
555  * <tr>
556  * <td> @image html tmp_concat_g4.png </td>
557  * <td> </td>
558  * <td> @image html tmp_concat_g2g4.png </td>
559  * </tr>
560  * </table> </td> </tr> </table>
561  *
562  * @ingroup GeneratorFunctions
563  */
564 void LanguageConcatenate(const Generator& rGen1, const Generator& rGen2,
565  Generator& rResGen);
566 
567 /**
568  * Full Language, L(G)=Lm(G)=Sigma*.
569  *
570  * Construct generator generating and marking full language Sigma* from alphabet Sigma.
571  * Method: this function creates a generator with one state that is marked and init state. This
572  * state is selflooped with all events from rAlphabet.
573  *
574  * @param rAlphabet
575  * Alphabet Sigma from which full language Sigma* is built
576  * @param rResGen
577  * Generator generating and marking full language Sigma*
578  *
579  * <h4>Example:</h4>
580  * <table>
581  * <tr> <td> FullLanguage(Sigma={a,b},Result) </td> </tr>
582  * <tr>
583  * <td> @image html tmp_languagesFull_result.png </td>
584  * </tr>
585  * </table>
586  *
587  * @ingroup GeneratorFunctions
588  */
589 void FullLanguage(const EventSet& rAlphabet, Generator& rResGen);
590 
591 /**
592  * Alphabet Language, L(G)=Lm(G)=Sigma
593  *
594  * Construct generator generating and marking an alphabet as languages, that is L(G)=Lm(G)=Sigma.
595  * Method: this function creates a generator with one init state and one marked state. For each
596  * event from rAlphabet, a transition is inserted leading from the init state to the marked state.
597  *
598  * No restrictions on parameters.
599  *
600  * @param rAlphabet
601  * alphabet from which alphabet language is built
602  * @param rResGen
603  * generator with languages Lm(G)=Sigma
604  *
605  * <h4>Example:</h4>
606  * <table>
607  * <tr> <td> AlphabetLanguage(Sigma={a,b},Result) </td> </tr>
608  * <tr>
609  * <td> @image html tmp_languagesAlphabet_result.png </td>
610  * </tr>
611  * </table>
612  *
613  * @ingroup GeneratorFunctions
614  */
615 void AlphabetLanguage(const EventSet& rAlphabet, Generator& rResGen);
616 
617 /**
618  * Empty string language, L(G)=Lm(G)={epsilon}.
619  *
620  * Construct generator generating and marking the empty string, that is L(G)=Lm(G)={epsilon}.
621  * Method: this function creates a generator with one marked init state and the alphabet rAlphabet.
622  *
623  * No restrictions on parameters.
624  *
625  * @param rAlphabet
626  * alphabet of the resulting generator
627  * @param rResGen
628  * generator with languages L(G)=Lm(G)={epsilon} and alphabet rAlphabet
629  *
630  * <h4>Example:</h4>
631  * <table>
632  * <tr> <td> EmptyStringLanguage(Sigma={a,b},Result) </td> </tr>
633  * <tr>
634  * <td> @image html tmp_languagesEmptyString_result.png </td>
635  * </tr>
636  * </table>
637  *
638  * @ingroup GeneratorFunctions
639  */
640 void EmptyStringLanguage(const EventSet& rAlphabet, Generator& rResGen);
641 
642 /**
643  * Empty language Lm(G)={}.
644  *
645  * Construct generator and marking the empty language, that is Lm(G)={}.
646  * Method: this function creates a deterministic generator with one initial state that is not marked.
647  * The alphabet is set as specified.
648  *
649  * No restrictions on parameters.
650  *
651  * @param rAlphabet
652  * Alphabet of the resulting generator
653  * @param rResGen
654  * Generator with language Lm(G)={}
655  *
656  * @ingroup GeneratorFunctions
657  */
658 void EmptyLanguage(const EventSet& rAlphabet, Generator& rResGen);
659 
660 /**
661  * Test for Empty language Lm(G)=={}.
662  *
663  * Tests if the language marked by rGen is empty, that is if Lm(G)=={}. The generated
664  * language L(G) is not considered.
665  * Method:
666  * This function tests if
667  * a) the set of marked states is empty or else
668  * b) the intersection of the set of accessible states and the set of marked states
669  * is empty, i.e. if there is no marked state or if no marked state is accessible (reachable).
670  *
671  * No restrictions on parameter.
672  *
673  * @param rGen
674  * generator to be tested for empty marked language
675  *
676  * @return
677  * true on empty marked language, false on nonempty marked language
678  *
679  * @ingroup GeneratorFunctions
680  */
681 bool IsEmptyLanguage(const Generator& rGen);
682 
683 /**
684  * Test language inclusion, Lm1<=Lm2.
685  *
686  * Test if language Lm1 marked by rGen1 is included in language Lm2 marked by rGen2. The
687  * generated languages are not considered.
688  * Method:
689  * This function checks if there is no string in Lm1 that is not in Lm2 by testing if
690  * the intersection of Lm1 and the language complement of Lm2 is empty.
691  *
692  * Restrictions on parameters: rGen2 has to be deterministic!
693  * If FAUDES_CHECKED is defined a warning on non-deterministic input is issued.
694  * (by function Automaton()).
695  *
696  * Determinism: correctness in case of nondeterministic parameter rGen1 has been tested with an
697  * example (see ExInclusion_simple), but not proven.
698  *
699  * ToDo: implement faster version using a variant of Product():
700  * compute product without storing result, return false as soon as some event is
701  * possible in Lm2 but not in Lm1.
702  *
703  * @param rGen1
704  * generator marking Lm1
705  * @param rGen2
706  * generator marking Lm2
707  *
708  * @return
709  * true if language marked by rGen1 is included in language marked by rGen2
710  *
711  * @ingroup GeneratorFunctions
712  */
713 bool LanguageInclusion(const Generator& rGen1, const Generator& rGen2);
714 
715 /**
716  * Language equality, Lm1==Lm2.
717  *
718  * Test if the language Lm1 marked by rGen1 equals the language Lm2 marked by rGen2. The
719  * generated languages are not considered.
720  * Method:
721  * This function checks mutual inclusion of Lm1 in Lm2 and of Lm2 in Lm1 using the
722  * function LanguageInclusion().
723  *
724  * Restrictions on parameters: rGen1 and rGen2 have to be deterministic!
725  * If FAUDES_CHECKED is defined a warning on non-deterministic input is issued.
726  * (by function Automaton()).
727  *
728  * ToDo: implement faster, version using a variant of Product():
729  * compute product without storing result, return false as soon as rGen1 and rGen2
730  * "disagree" on the occurrence of some event.
731  *
732  * @param rGen1
733  * generator marking Lm1
734  * @param rGen2
735  * generator marking Lm2
736  *
737  * @return
738  * true if the language marked by rGen1 equals the language marked by rGen2
739  *
740  * @ingroup GeneratorFunctions
741  */
742 bool LanguageEquality(const Generator& rGen1, const Generator& rGen2);
743 
744 /**
745  * Kleene Closure.
746  *
747  * This function computes the Kleene Closure ( ()* - operator) of the
748  * language marked by rGen. The generated language is not considered.
749  * Method: KleeneClosureNonDet() is called, which, for all transitions
750  * leading from a state x to a marked state, inserts a transition with the
751  * same event starting from x and leading to (one of) the initial state(s).
752  * As this step causes nondeterminism, the function Deterministic() is called.
753  * See also KleeneClosureNonDet().
754  *
755  * No restrictions on parameter.
756  *
757  * @param rGen
758  * generator marking the language Lm to which the Kleene Closure is applied
759  *
760  * <h4>Example:</h4>
761  * <table>
762  * <tr> <td> Generator G </td> <td> KleeneClosure(G) </td> </tr>
763  * <tr>
764  * <td> @image html tmp_kleene_g.png </td>
765  * <td> @image html tmp_kleene_gRes.png </td>
766  * </tr>
767  * </table>
768  *
769  * @ingroup GeneratorFunctions
770  */
771 void KleeneClosure(Generator& rGen);
772 
773 /**
774  * Kleene Closure.
775  *
776  * This function is a convenience wrapper for KleeneClosure(Generator&).
777  *
778  *
779  * @ingroup GeneratorFunctions
780  */
781 void KleeneClosure(const Generator& rGen, Generator& rResGen);
782 
783 /**
784  * Kleene Closure, nondeterministic version.
785  *
786  * This function computes the Kleene Closure ( ()* - operator) of the
787  * language marked by rGen. The generated language is not considered.
788  * Method: KleeneClosureNonDet() is called, which, for all transitions
789  * leading from a state x to a marked state, inserts a transition with the
790  * same event starting from x and leading to (one of) the initial state(s).
791  *
792  * @param rGen
793  * generator marking the language Lm to which Kleene Closure is applied
794  *
795  * @ingroup GeneratorFunctions
796  */
797 void KleeneClosureNonDet(Generator& rGen);
798 
799 /**
800  * Prefix Closure.
801  *
802  * This function computes the prefix closure the language Lm marked by rGen. A
803  * language Lm is prefix closed if each string of Lm implies that all its
804  * prefixes are also element of Lm. The prefix closure of a language marked by
805  * a generator is always a subset of the generated language and is represented
806  * by the set of coaccessible states of the generator.
807  * Method:
808  * First, Coaccessible() is called to erase all states of rGen that do not
809  * represent prefixes of marked strings. Then, all remaining states are marked.
810  *
811  * No restrictions on parameter.
812  *
813  * ToDo: (slightly) more efficient version: implement generator function
814  * CoAccessibleSet() similar to AccessibleSet() and call
815  * InjectMarkedStates(AccessibleSet()).
816  *
817  * @param rGen
818  * generator marking the language Lm to which prefix closure is applied
819  *
820  * <h4>Example:</h4>
821  * <table>
822  * <tr> <td> Generator G </td> <td> PrefixClosure(G) </td> </tr>
823  * <tr>
824  * <td> @image html tmp_prefixclosure_g.png </td>
825  * <td> @image html tmp_prefixclosure_gRes.png </td>
826  * </tr>
827  * </table>
828  *
829  * @ingroup GeneratorFunctions
830  */
831 void PrefixClosure(Generator& rGen);
832 
833 
834 /**
835  * Test for prefix closed marked language.
836  *
837  * This function tests whether the language Lm(G) marked by the specified generator G
838  * is prefix closed. It does so by testing whether all accessible and coaccessible
839  * states are marked.
840  *
841  * The specified generator must be deterministic.
842  *
843  * @param rGen
844  * generator G marking the Lm(G) to test
845  * @return
846  * True <> Lm(G) is prefix closed
847  *
848  * @ingroup GeneratorFunctions
849  */
850 bool IsPrefixClosed(const Generator& rGen);
851 
852 
853 /**
854  * Test for nonblocking generator
855  *
856  * A generator G is nonblocking if closure(Lm(G)) = L(G), i.e.
857  * if every accessible state is coacessile.
858  *
859  * The specified generator must be deterministic.
860  *
861  * @param rGen
862  * generator G marking to test
863  * @return
864  * True <> G is nonblocking
865  *
866  * @ingroup GeneratorFunctions
867  */
868 bool IsNonblocking(const Generator& rGen);
869 
870 /**
871  * Test for nonblocking marked languages.
872  *
873  * Two languages L1 and L2 are nonblocking, if
874  * closure(L1 || L2) == closure(L1) || closure(L2).
875  *
876  * This function performs the parallel composition of the two
877  * specified generators and tests it for nonblockingness. Provided
878  * that both generators are trim, this is equivalent to the
879  * respective marked languages being nonblocking.
880  *
881  * The specified generators must be trim.
882  *
883  * @param rGen1
884  * Generator G1
885  * @param rGen2
886  * Generator G2
887  * @return
888  * True <> Lm(G1) and Lm(G2) are nonblocking
889  *
890  * @ingroup GeneratorFunctions
891  */
892 bool IsNonblocking(const Generator& rGen1, const Generator& rGen2);
893 
894 
895 /**
896  * Self-loop all states.
897  *
898  * This function selfoops all states of rGen with the events from rAlphabet.
899  * Method:
900  * The alphabet of rGen is extended by rAlphabet. For each state x of rGen
901  * and each event alpha of rAlphabet, a transition (x,alpha,x) is inserted,
902  * irrespective of whether this event was already active in x before.
903  * See also SelfLoop(rGen,rAlphabet,rStates) and SelfLoopMarkedStates(rGen,rAlphabet).
904  *
905  * No restrictions on parameter.
906  *
907  * Determinism: resulting generator is nondeterministic, if it was nondeterministic
908  * before, or if rGen already contains one or more (non selfloop) transitions with
909  * events from rAlphabet.
910  *
911  * @param rGen
912  * generator to be selflooped with events from rAlphabet
913  * @param rAlphabet
914  * alphabet with selfloop events
915  *
916  * <h4>Example:</h4>
917  * <table>
918  * <tr> <td> Generator G </td> <td> SelfLoop(G,Sigma={e,f}) </td> </tr>
919  * <tr>
920  * <td> @image html tmp_selfloop_g.png </td>
921  * <td> @image html tmp_selfloop_gRes.png </td>
922  * </tr>
923  * </table>
924  *
925  * @ingroup GeneratorFunctions
926  */
927 void SelfLoop(Generator& rGen,const EventSet& rAlphabet);
928 
929 /**
930  * Self-loop all marked states.
931  *
932  * This function selfoops all marked states of rGen with the events from rAlphabet.
933  * Method:
934  * The alphabet of rGen is extended by rAlphabet. For each marked state x of rGen
935  * and each event alpha of rAlphabet, a transition (x,alpha,x) is inserted,
936  * irrespective of whether this event was already active in x before.
937  * See also SelfLoop(rGen,rAlphabet) and SelfLoop(rGen,rAlphabet,rStates).
938  *
939  * No restrictions on parameter.
940  *
941  * Determinism: resulting generator is nondeterministic, if it was nondeterministic
942  * before, or if rGen already contains one or more (non selfloop) transitions
943  * starting from a marked state with events from rAlphabet.
944  *
945  * @param rGen
946  * generator with marked states to be selflooped with events from rAlphabet
947  * @param rAlphabet
948  * alphabet with selfloop events
949  *
950  * <h4>Example:</h4>
951  * <table>
952  * <tr> <td> Generator G </td> <td> SelfLoopMarkedStates(G,Sigma={e,f}) </td> </tr>
953  * <tr>
954  * <td> @image html tmp_selfloop_g.png </td>
955  * <td> @image html tmp_selfloopMarked_gRes.png </td>
956  * </tr>
957  * </table>
958  *
959  * @ingroup GeneratorFunctions
960  */
961 void SelfLoopMarkedStates(Generator& rGen,const EventSet& rAlphabet);
962 
963 /**
964  * Self-loop specified states.
965  *
966  * This function selfoops the states rStates of rGen with the events from rAlphabet.
967  * Method:
968  * The alphabet of rGen is extended by rAlphabet. For each state x of rStates
969  * and each event alpha of rAlphabet, a transition (x,alpha,x) is inserted,
970  * irrespective of whether this event was already active in x before.
971  * See also SelfLoop(rGen,rAlphabet) and SelfLoopMarkedStates(rGen,rAlphabet).
972  *
973  * No restrictions on parameter.
974  *
975  * Determinism: resulting generator is nondeterministic, if it was nondeterministic
976  * before, or if rGen already contains one or more (non selfloop) transitions
977  * starting from a state of rState with events from rAlphabet.
978  *
979  * @param rGen
980  * generator with marked states to be selflooped with events from rAlphabet
981  * @param rAlphabet
982  * alphabet with selfloop events
983  * @param rStates
984  * states to apply selfloop
985  *
986  * @exception Exception
987  * - rStates is not a subset of rGen.States() (id 100).
988  *
989  * <h4>Example:</h4>
990  * <table>
991  * <tr> <td> Generator G </td> <td> SelfLoop(G,Sigma={e,f},G.InitStates()) </td> </tr>
992  * <tr>
993  * <td> @image html tmp_selfloop_g.png </td>
994  * <td> @image html tmp_selfloopInit_gRes.png </td>
995  * </tr>
996  * </table>
997  *
998  * @ingroup GeneratorFunctions
999  */
1000 void SelfLoop(Generator& rGen,const EventSet& rAlphabet,const StateSet& rStates);
1001 
1002 
1003 
1004 
1005 } // namespace faudes
1006 
1007 #define FAUDES_REGULAR_H
1008 #endif
1009 

libFAUDES 2.24g --- 2014.09.15 --- c++ api documentaion by doxygen