3_functions.cpp
Go to the documentation of this file.
1 /** @file 3_functions.cpp
2 
3 Tutorial, operations on genarators.
4 
5 This tutorial demonstrates the use of
6 general purpose operations on generators.
7 It also produces example output for the HTML
8 documentation.
9 
10 @ingroup Tutorials
11 
12 @include 3_functions.cpp
13 */
14 
15 
16 #include "libfaudes.h"
17 
18 
19 // make the faudes namespace available to our program
20 
21 using namespace faudes;
22 
23 
24 
25 /////////////////
26 // main program
27 /////////////////
28 
29 int main() {
30 
31 
32 
33  ////////////////////////////
34  // make deterministic
35  ////////////////////////////
36 
37 
38  // read nondeterministic generator and perform operation
39  Generator deter_nondet("data/deterministic_nondet.gen");
40  Generator deter_det;
41  Deterministic(deter_nondet, deter_det);
42  deter_det.Write("tmp_deterministic_det.gen");
43  deter_nondet.Write("tmp_deterministic_nondet.gen");
44 
45  // report result to console
46  std::cout << "################################\n";
47  std::cout << "# deterministic generator \n";
48  deter_det.DWrite();
49  std::cout << "################################\n";
50 
51 
52  // Test protocol
53  FAUDES_TEST_DUMP("deterministic",deter_det);
54 
55 
56  ////////////////////////////
57  // make minimal
58  ////////////////////////////
59 
60 
61  // read nonminimal generator and perform operation
62  Generator minimal_nonmin("data/minimal_nonmin.gen");
63  Generator minimal_min;
64  StateMin(minimal_nonmin, minimal_min);
65  minimal_nonmin.Write("tmp_minimal_nonmin.gen");
66  minimal_min.Write("tmp_minimal_min.gen");
67 
68  // report result to console
69  std::cout << "################################\n";
70  std::cout << "# minimal generator \n";
71  minimal_min.DWrite();
72  std::cout << "################################\n";
73 
74 
75  // Test protocol
76  FAUDES_TEST_DUMP("minimal",minimal_min);
77 
78  ////////////////////////////
79  // project
80  ////////////////////////////
81 
82 
83  // read generator to project
84  Generator project_g("data/project_g.gen");
85  Generator project_prog;
86  EventSet alph_proj;
87  alph_proj.Insert("a");
88  alph_proj.Insert("c");
89  alph_proj.Insert("e");
90  alph_proj.Insert("g");
91  Project(project_g, alph_proj, project_prog);
92  project_g.Write("tmp_project_g.gen");
93 
94  // tmoor 201308: minimize stateset (for html docu, purely cosmetic)
95  Generator project_prog_min;
96  project_prog_min.StateNamesEnabled(false);
97  StateMin(project_prog,project_prog_min);
98  project_prog_min.Write("tmp_project_prog.gen");
99 
100  // report result to console
101  std::cout << "################################\n";
102  std::cout << "# projected generator \n";
103  project_prog_min.DWrite();
104  std::cout << "################################\n";
105 
106  // Test protocol
107  FAUDES_TEST_DUMP("project",project_prog_min);
108 
109 
110  ////////////////////////////
111  // synchronous composition
112  ////////////////////////////
113 
114 
115  // read generators
116  Generator parallel_g1("data/parallel_g1.gen");
117  Generator parallel_g2("data/parallel_g2.gen");
118 
119  // perform composition
120  Generator parallel_g1g2;
121  Parallel(parallel_g1, parallel_g2, parallel_g1g2);
122 
123  // write result and operands for html docu
124  parallel_g1.Write("tmp_parallel_g1.gen");
125  parallel_g2.Write("tmp_parallel_g2.gen");
126  parallel_g1g2.Write("tmp_parallel_g1g2.gen");
127 
128  // read generators
129  Generator parallel_m1("data/wparallel_g1.gen");
130  Generator parallel_m2("data/wparallel_g2.gen");
131 
132  // perform composition
133  Generator parallel_m1m2;
134  Parallel(parallel_m1, parallel_m2, parallel_m1m2);
135 
136  // write result and operands for html docu
137  parallel_m1.Write("tmp_parallel_m1.gen");
138  parallel_m2.Write("tmp_parallel_m2.gen");
139  parallel_m1m2.Write("tmp_parallel_m1m2.gen");
140 
141  // read generators
142  Generator wparallel_g1("data/wparallel_g1.gen");
143  Generator wparallel_g2("data/wparallel_g2.gen");
144 
145  // perform composition
146  Generator wparallel_g1g2;
147  OmegaParallel(wparallel_g1, wparallel_g2, wparallel_g1g2);
148 
149  // write result and operands for html docu
150  wparallel_g1.Write("tmp_wparallel_g1.gen");
151  wparallel_g2.Write("tmp_wparallel_g2.gen");
152  wparallel_g1g2.Write("tmp_wparallel_g1g2.gen");
153 
154  // Test protocol
155  FAUDES_TEST_DUMP("parallel",parallel_g1g2);
156  FAUDES_TEST_DUMP("wparallel",wparallel_g1g2);
157 
158 
159  ////////////////////////////
160  // boolean language operations
161  ////////////////////////////
162 
163 
164  // read generators
165  Generator boolean_g1("data/boolean_g1.gen");
166  Generator boolean_g2("data/boolean_g2.gen");
167  Generator lequal_g1("data/lequal_g1.gen");
168  Generator lequal_g2("data/lequal_g2.gen");
169 
170  // perform union
171  Generator boolean_union;
172  boolean_union.StateNamesEnabled(false);
173  LanguageUnion(boolean_g1, boolean_g2, boolean_union);
174 
175  // perform intersection
176  Generator boolean_intersection;
177  boolean_intersection.StateNamesEnabled(false);
178  LanguageIntersection(boolean_g1, boolean_g2, boolean_intersection);
179 
180  // perform complement twice
181  Generator boolean_complement_g1=boolean_g1;
182  boolean_complement_g1.StateNamesEnabled(false);
183  LanguageComplement(boolean_complement_g1);
184  Generator boolean_complement2_g1=boolean_complement_g1;
185  LanguageComplement(boolean_complement2_g1);
186 
187  // write results and operands for html docu
188  boolean_g1.Write("tmp_boolean_g1.gen");
189  boolean_g2.Write("tmp_boolean_g2.gen");
190  boolean_union.Write("tmp_union_g1g2.gen");
191  boolean_intersection.Write("tmp_intersection_g1g2.gen");
192  boolean_complement_g1.Write("tmp_complement_g1.gen");
193  boolean_complement2_g1.Write("tmp_complement2_g1.gen");
194 
195  // inspect on console
196  std::cout << "################################\n";
197  std::cout << "# boolean language operations\n";
198  boolean_union.DWrite();
199  boolean_intersection.DWrite();
200  boolean_complement_g1.DWrite();
201  std::cout << "################################\n";
202 
203  // compare languages
204  std::cout << "################################\n";
205  std::cout << "# boolean language operations\n";
206  if(LanguageInclusion(boolean_g1,boolean_union))
207  std::cout << "Lm(g1) <= Lm(g1) v Lm(g2): OK\n";
208  else
209  std::cout << "Lm(g1) <= Lm(g1) v Lm(g2): ERR\n";
210  if(LanguageDisjoint(boolean_complement_g1,boolean_g1))
211  std::cout << "Lm(g1) ^ ~Lm(g1) = empty: OK\n";
212  else
213  std::cout << "(Lm(g1) v Lm(g2)) ^ ~(Lm(g1) v Lm(g2)) != empty: ERR\n";
214  if(LanguageEquality(boolean_g1,boolean_complement2_g1))
215  std::cout << "Lm(g1) = ~~Lm(g1) : OK\n";
216  else
217  std::cout << "Lm(g1) != ~~Lm(g1) : ERR\n";
218  std::cout << "################################\n";
219 
220  // compare languages (track error report, thanks)
221  std::cout << "################################\n";
222  std::cout << "# boolean language operations for empty Lm(g1)\n";
223  if(LanguageInclusion(lequal_g1,lequal_g2))
224  std::cout << "Lm(g1) <= Lm(g2): OK\n";
225  else
226  std::cout << "Lm(g1) <= Lm(g2): ERR\n";
227  if(LanguageInclusion(lequal_g2,lequal_g1))
228  std::cout << "Lm(g2) <= Lm(g1): ERR\n";
229  else
230  std::cout << "~(Lm(g2) <= Lm(g1)): OK\n";
231  bool boolean_lequal = LanguageEquality(lequal_g1,lequal_g2);
232  if(boolean_lequal)
233  std::cout << "Lm(g1) == Lm(g2): ERR\n";
234  else
235  std::cout << "Lm(g1) != Lm(g2): OK\n";
236 
237  // Record test case
238  FAUDES_TEST_DUMP("boolean union",boolean_union);
239  FAUDES_TEST_DUMP("boolean inter",boolean_intersection);
240  FAUDES_TEST_DUMP("boolean compl",boolean_complement_g1);
241  FAUDES_TEST_DUMP("boolean equal",boolean_lequal);
242 
243 
244  ////////////////////////////
245  // language difference
246  ////////////////////////////
247 
248 
249  // read generator and write for html docu
250  Generator difference_g1("data/difference_g1.gen");
251  difference_g1.Write("tmp_difference_g1.gen");
252 
253  Generator difference_g2("data/difference_g2.gen");
254  difference_g2.Write("tmp_difference_g2.gen");
255 
256  // compute language difference Lm(g1)-Lm(g2)
257 
258  Generator difference_g1minusg2;
259  LanguageDifference(difference_g1,difference_g2,difference_g1minusg2);
260  difference_g1minusg2.Write("tmp_difference_g1minusg2.gen");
261 
262  // inspect on console
263  std::cout << "################################\n";
264  std::cout << "# language difference Lm(g1)-Lm(g2) \n";
265  difference_g1minusg2.DWrite();
266  std::cout << "################################\n";
267 
268  // Record test case
269  FAUDES_TEST_DUMP("difference",difference_g1minusg2);
270 
271 
272  ////////////////////////////
273  // convert to automaton
274  ////////////////////////////
275 
276 
277  // read generator and write for html docu
278  Generator automaton_g("data/automaton_g.gen");
279  automaton_g.Write("tmp_automaton_g.gen");
280 
281  // convert to automaton
282  Automaton(automaton_g);
283  automaton_g.Write("tmp_automaton_gRes.gen");
284 
285  // inspect on console
286  std::cout << "################################\n";
287  std::cout << "# automaton from generator \n";
288  automaton_g.DWrite();
289  std::cout << "################################\n";
290 
291 
292 
293  ////////////////////////////
294  // language concatenation
295  ////////////////////////////
296 
297 
298  // read generators and write for html docu
299  Generator concat_g1("data/concat_g1.gen");
300  Generator concat_g2("data/concat_g2.gen");
301  Generator concat_g3("data/concat_g3.gen");
302  Generator concat_g4("data/concat_g4.gen");
303  Generator concat_g5("data/concat_g5.gen");
304  Generator concat_g6("data/concat_g6.gen");
305  concat_g1.Write("tmp_concat_g1.gen");
306  concat_g2.Write("tmp_concat_g2.gen");
307  concat_g3.Write("tmp_concat_g3.gen");
308  concat_g4.Write("tmp_concat_g4.gen");
309  concat_g5.Write("tmp_concat_g5.gen");
310  concat_g6.Write("tmp_concat_g6.gen");
311 
312 
313  // perform language concatenations and inspect on console
314  std::cout << "################################\n";
315  std::cout << "# language concatenation\n";
316  Generator concat;
317  concat.StateNamesEnabled(false);
318  LanguageConcatenate(concat_g1,concat_g3,concat);
319  concat.Write("tmp_concat_g1g3.gen");
320  concat.DWrite();
321  LanguageConcatenate(concat_g1,concat_g4,concat);
322  concat.Write("tmp_concat_g1g4.gen");
323  concat.DWrite();
324  LanguageConcatenate(concat_g2,concat_g3,concat);
325  concat.Write("tmp_concat_g2g3.gen");
326  concat.DWrite();
327  LanguageConcatenate(concat_g2,concat_g4,concat);
328  concat.Write("tmp_concat_g2g4.gen");
329  concat.DWrite();
330  LanguageConcatenate(concat_g5,concat_g6,concat);
331  concat.Write("tmp_concat_g5g6.gen");
332  concat.DWrite();
333  std::cout << "################################\n";
334 
335  // Record test case
336  FAUDES_TEST_DUMP("concat ", concat);
337 
338 
339  ////////////////////////////
340  // full language, alphabet language, empty string language and empty language
341  ////////////////////////////
342 
343  // create alphabet={a,b}
344  EventSet languages_alphabet;
345  languages_alphabet.Insert("a");
346  languages_alphabet.Insert("b");
347 
348  // generator for result
349  Generator languages_g;
350 
351  // construct full language from alphabet
352  FullLanguage(languages_alphabet,languages_g);
353  languages_g.Write("tmp_languagesFull_result.gen");
354 
355  // inspect on console
356  std::cout << "################################\n";
357  std::cout << "# full language \n";
358  languages_g.DWrite();
359 
360  // construct alphabet language from alphabet
361  AlphabetLanguage(languages_alphabet,languages_g);
362  languages_g.Write("tmp_languagesAlphabet_result.gen");
363  std::cout << "# alphabet language \n";
364  languages_g.DWrite();
365 
366  // construct empty string language from alphabet
367  EmptyStringLanguage(languages_alphabet,languages_g);
368  languages_g.Write("tmp_languagesEmptyString_result.gen");
369  std::cout << "# empty string language \n";
370  languages_g.DWrite();
371 
372  // construct empty language from alphabet
373  EmptyLanguage(languages_alphabet,languages_g);
374  languages_g.Write("tmp_languagesEmpty_result.gen");
375  std::cout << "# empty language \n";
376  languages_g.DWrite();
377  std::cout << "################################\n";
378 
379 
380 
381  ////////////////////////////
382  // Kleene closure
383  ////////////////////////////
384 
385 
386  // read generator and write for html docu
387  Generator kleene_g1("data/kleene_g1.gen");
388  kleene_g1.Write("tmp_kleene_g1.gen");
389 
390  // compute Kleene closure
391  kleene_g1.StateNamesEnabled(false);
392  KleeneClosure(kleene_g1);
393  kleene_g1.Write("tmp_kleene_g1Res.gen");
394 
395  // inspect on console
396  std::cout << "################################\n";
397  std::cout << "# Kleene closure \n";
398  kleene_g1.DWrite();
399  std::cout << "################################\n";
400 
401  // Record test case
402  FAUDES_TEST_DUMP("kleene closure ", kleene_g1);
403 
404 
405  // read generator and write for html docu
406  Generator kleene_g2("data/kleene_g2.gen");
407  kleene_g2.Write("tmp_kleene_g2.gen");
408 
409  // compute Kleene closure
410  kleene_g2.StateNamesEnabled(false);
411  KleeneClosureNonDet(kleene_g2);
412  kleene_g2.Write("tmp_kleene_g2Res.gen");
413 
414  // inspect on console
415  std::cout << "################################\n";
416  std::cout << "# Kleene closure \n";
417  kleene_g2.DWrite();
418  std::cout << "################################\n";
419 
420  // Record test case
421  FAUDES_TEST_DUMP("kleene closure ", kleene_g2);
422 
423  ////////////////////////////
424  // prefix closure
425  ////////////////////////////
426 
427 
428  // read generator and write for html docu
429  Generator prefixclosure_g("data/prefixclosure_g.gen");
430  prefixclosure_g.Write("tmp_prefixclosure_g.gen");
431 
432  // test prefix closure
433  bool isprefixclosed_g = IsPrefixClosed(prefixclosure_g);
434 
435  // compute prefix closure
436  PrefixClosure(prefixclosure_g);
437  prefixclosure_g.Write("tmp_prefixclosure_gRes.gen");
438 
439  // test prefix closure
440  bool isprefixclosed_gRes = IsPrefixClosed(prefixclosure_g);
441 
442  // inspect on console
443  std::cout << "################################\n";
444  std::cout << "# prefix closure \n";
445  if(isprefixclosed_g)
446  std::cout << "# argument was prefix closed (test case error!)\n";
447  else
448  std::cout << "# argument was not prefix closed (expected)\n";
449  if(isprefixclosed_gRes)
450  std::cout << "# result is prefix closed (expected)\n";
451  else
452  std::cout << "# result is not prefix closed (test case error!)\n";
453  prefixclosure_g.DWrite();
454  std::cout << "################################\n";
455 
456  // Record test case
457  FAUDES_TEST_DUMP("prefix closure", prefixclosure_g);
458 
459 
460  ////////////////////////////
461  // omega closure
462  ////////////////////////////
463 
464 
465  // read generator and write for html docu
466  Generator omegaclosure_g("data/omegaclosure_g.gen");
467  omegaclosure_g.Write("tmp_omegaclosure_g.gen");
468 
469  // test omega closure
470  bool isomegaclosed_g = IsOmegaClosed(omegaclosure_g);
471 
472  // compute omega closure
473  OmegaClosure(omegaclosure_g);
474  omegaclosure_g.Write("tmp_omegaclosure_gRes.gen");
475 
476  // test omega closure
477  bool isomegaclosed_gRes = IsOmegaClosed(omegaclosure_g);
478 
479  // inspect on console
480  std::cout << "################################\n";
481  std::cout << "# omega closure \n";
482  if(isomegaclosed_g)
483  std::cout << "# argument was omega closed (test case error!)\n";
484  else
485  std::cout << "# argument was not omega closed (expected)\n";
486  if(isomegaclosed_gRes)
487  std::cout << "# result is omega closed (expected)\n";
488  else
489  std::cout << "# result is not omega closed (test case error!)\n";
490  omegaclosure_g.DWrite();
491  std::cout << "################################\n";
492 
493  // Record test case
494  FAUDES_TEST_DUMP("omega closure", omegaclosure_g);
495 
496 
497  ////////////////////////////
498  // selfloop
499  ////////////////////////////
500 
501 
502  // read generator and write for html docu
503  Generator selfloop_g("data/selfloop_g.gen");
504  selfloop_g.Write("tmp_selfloop_g.gen");
505 
506  // create alphabet={e,f}
507  EventSet selfloop_alphabet;
508  selfloop_alphabet.Insert("e");
509  selfloop_alphabet.Insert("f");
510 
511  // generator for result
512  Generator selfloop_gRes=selfloop_g;
513 
514  // add selfloops in each state
515  SelfLoop(selfloop_gRes,selfloop_alphabet);
516  selfloop_gRes.Write("tmp_selfloop_gRes.gen");
517 
518  // inspect on console
519  std::cout << "################################\n";
520  std::cout << "# selfloop, each state \n";
521  selfloop_gRes.DWrite();
522 
523  // add selfloops in marked states
524  selfloop_gRes=selfloop_g;
525  SelfLoopMarkedStates(selfloop_gRes,selfloop_alphabet);
526  selfloop_gRes.Write("tmp_selfloopMarked_gRes.gen");
527  std::cout << "# selfloop, marked states \n";
528  selfloop_gRes.DWrite();
529 
530  // add selfloops in inital state(s)
531  selfloop_gRes=selfloop_g;
532  SelfLoop(selfloop_gRes,selfloop_alphabet,selfloop_gRes.InitStates());
533  selfloop_gRes.Write("tmp_selfloopInit_gRes.gen");
534  std::cout << "# selfloop, init state(s) \n";
535  selfloop_gRes.DWrite();
536  std::cout << "################################\n";
537 
538 
539  ////////////////////////////
540  // nonconflicting
541  ////////////////////////////
542 
543  // under construction --
544 
545  std::cout << "################################\n";
546  std::cout << "# non-blocking test \n";
547 
548 
549  std::cout << "# conflict equiv. abstract test 1 \n";
550  Generator nonblocking_g;
551  EventSet silent;
552  silent.Insert("tau");
553  nonblocking_g.Read("data/noblo_gae2.gen");
554  ConflictEquivalentAbstraction(nonblocking_g,silent);
555  nonblocking_g.Write();
556 
557  FAUDES_TEST_DUMP("nonblocking 0", nonblocking_g);
558 
559  // test cases from Michael Meyer's thesis
560  // Nonblocking: (1,2,3,6,7); (1,2,3,4,5,6,7); (1,2,3,4,5,6); (2,4,6,8); (2,3,4,5); (5,6,7,8,9)
561  // Blocking: (3,4,5,6,7); (1,3,5,7)
562 
563  // read generators from file
564  GeneratorVector nonblocking_gv;
565  nonblocking_gv.PushBack("data/noblo_g2.gen");
566  nonblocking_gv.PushBack("data/noblo_g3.gen");
567  nonblocking_gv.PushBack("data/noblo_g4.gen");
568  nonblocking_gv.PushBack("data/noblo_g5.gen");
569  // test for conflicts
570  std::cout << "# non-blocking exec test 1\n";
571  bool nonblocking_ok1;
572  nonblocking_ok1=IsNonblocking(nonblocking_gv);
573  if(nonblocking_ok1)
574  std::cout << "# non-blocking test: passed (expected)\n";
575  else
576  std::cout << "# non-blocking test: failed (test case error!)\n";
577 
578  FAUDES_TEST_DUMP("nonblocking 1", nonblocking_ok1);
579 
580  // read generators from file
581  nonblocking_gv.Clear();
582  nonblocking_gv.PushBack("data/noblo_g5.gen");
583  nonblocking_gv.PushBack("data/noblo_g6.gen");
584  nonblocking_gv.PushBack("data/noblo_g7.gen");
585  nonblocking_gv.PushBack("data/noblo_g8.gen");
586  nonblocking_gv.PushBack("data/noblo_g9.gen");
587  // test for conflicts
588  std::cout << "# non-blocking exec test 2\n";
589  bool nonblocking_ok2;
590  nonblocking_ok2=IsNonblocking(nonblocking_gv);
591  if(nonblocking_ok2)
592  std::cout << "# non-blocking test: passed (expected)\n";
593  else
594  std::cout << "# non-blocking test: failed (test case error!)\n";
595 
596  FAUDES_TEST_DUMP("nonblocking 2", nonblocking_ok2);
597 
598  // read generators from file
599  nonblocking_gv.Clear();
600  nonblocking_gv.PushBack("data/noblo_g3.gen");
601  nonblocking_gv.PushBack("data/noblo_g4.gen");
602  nonblocking_gv.PushBack("data/noblo_g5.gen");
603  nonblocking_gv.PushBack("data/noblo_g6.gen");
604  nonblocking_gv.PushBack("data/noblo_g7.gen");
605  // test for conflicts
606  std::cout << "# non-blocking exec test 3\n";
607  bool nonblocking_ok3;
608  nonblocking_ok3=IsNonblocking(nonblocking_gv);
609  if(nonblocking_ok3)
610  std::cout << "# non-blocking test: passed (test case error!)\n";
611  else
612  std::cout << "# non-blocking test: failed (expected)\n";
613 
614  FAUDES_TEST_DUMP("nonblocking 3", nonblocking_ok3);
615 
616  // read generators from file
617  nonblocking_gv.Clear();
618  nonblocking_gv.PushBack("data/noblo_g1.gen");
619  nonblocking_gv.PushBack("data/noblo_g3.gen");
620  nonblocking_gv.PushBack("data/noblo_g5.gen");
621  nonblocking_gv.PushBack("data/noblo_g7.gen");
622  // test for conflicts
623  std::cout << "# non-blocking exec test 4\n";
624  bool nonblocking_ok4;
625  nonblocking_ok4=IsNonblocking(nonblocking_gv);
626  if(nonblocking_ok4)
627  std::cout << "# non-blocking test: passed (test case error!)\n";
628  else
629  std::cout << "# non-blocking test: failed (expected)\n";
630 
631  FAUDES_TEST_DUMP("nonblocking 4", nonblocking_ok4);
632 
633  // read generators from file
634  nonblocking_gv.Clear();
635  nonblocking_gv.PushBack("data/noblo_g1.gen");
636  nonblocking_gv.PushBack("data/noblo_g2.gen");
637  nonblocking_gv.PushBack("data/noblo_g3.gen");
638  nonblocking_gv.PushBack("data/noblo_g6.gen");
639  nonblocking_gv.PushBack("data/noblo_g7.gen");
640  // test for conflicts
641  std::cout << "# non-blocking exec test 5\n";
642  bool nonblocking_ok5;
643  nonblocking_ok5=IsNonblocking(nonblocking_gv);
644  if(nonblocking_ok5)
645  std::cout << "# non-blocking test: passed (expected)\n";
646  else
647  std::cout << "# non-blocking test: failed (test case error!)\n";
648 
649  // read generators from file
650  nonblocking_gv.Clear();
651  nonblocking_gv.PushBack("data/noblo_g1.gen");
652  nonblocking_gv.PushBack("data/noblo_g2.gen");
653  nonblocking_gv.PushBack("data/noblo_g3.gen");
654  nonblocking_gv.PushBack("data/noblo_g4.gen");
655  nonblocking_gv.PushBack("data/noblo_g5.gen");
656  nonblocking_gv.PushBack("data/noblo_g6.gen");
657  nonblocking_gv.PushBack("data/noblo_g7.gen");
658  // test for conflicts
659  std::cout << "# non-blocking exec test 6\n";
660  bool nonblocking_ok6;
661  nonblocking_ok6=IsNonblocking(nonblocking_gv);
662  if(nonblocking_ok6)
663  std::cout << "# non-blocking test: passed (expected)\n";
664  else
665  std::cout << "# non-blocking test: failed (test case error!)\n";
666 
667  // read generators from file
668  nonblocking_gv.Clear();
669  nonblocking_gv.PushBack("data/noblo_g1.gen");
670  nonblocking_gv.PushBack("data/noblo_g2.gen");
671  nonblocking_gv.PushBack("data/noblo_g3.gen");
672  nonblocking_gv.PushBack("data/noblo_g4.gen");
673  nonblocking_gv.PushBack("data/noblo_g5.gen");
674  nonblocking_gv.PushBack("data/noblo_g6.gen");
675  // test for conflicts
676  std::cout << "# non-blocking exec test 7\n";
677  bool nonblocking_ok7;
678  nonblocking_ok7=IsNonblocking(nonblocking_gv);
679  if(nonblocking_ok7)
680  std::cout << "# non-blocking test: passed (expected)\n";
681  else
682  std::cout << "# non-blocking test: failed (test case error!)\n";
683 
684  // read generators from file
685  nonblocking_gv.Clear();
686  nonblocking_gv.PushBack("data/noblo_g2.gen");
687  nonblocking_gv.PushBack("data/noblo_g4.gen");
688  nonblocking_gv.PushBack("data/noblo_g6.gen");
689  nonblocking_gv.PushBack("data/noblo_g8.gen");
690  // test for conflicts
691  std::cout << "# non-blocking exec test 8\n";
692  bool nonblocking_ok8;
693  nonblocking_ok8=IsNonblocking(nonblocking_gv);
694  if(nonblocking_ok8)
695  std::cout << "# non-blocking test: passed (expected)\n";
696  else
697  std::cout << "# non-blocking test: failed (test case error!)\n";
698 
699 
700  // test cases from Yiheng Tang (blocking)
701  nonblocking_gv.Clear();
702  nonblocking_gv.PushBack("data/noblo_yt1.gen");
703  nonblocking_gv.PushBack("data/noblo_yt2.gen");
704 
705  // test for conflicts A
706  std::cout << "# non-blocking exec test 9a\n";
707  Generator parallel12;
708  Parallel(nonblocking_gv.At(0),nonblocking_gv.At(1),parallel12);
709  bool nonblocking_ok9;
710  nonblocking_ok9=parallel12.BlockingStates().Size()==0;
711  if(nonblocking_ok9)
712  std::cout << "# non-blocking test: passed (test case error!)\n";
713  else
714  std::cout << "# non-blocking test: failed (expected)\n";
715 
716  FAUDES_TEST_DUMP("nonblocking 9a", nonblocking_ok9);
717 
718  // test for conflicts B
719  std::cout << "# non-blocking exec test 9b\n";
720  nonblocking_ok9=IsNonblocking(nonblocking_gv);
721  if(nonblocking_ok9)
722  std::cout << "# non-blocking test: passed (test case error!)\n";
723  else
724  std::cout << "# non-blocking test: failed (expected)\n";
725 
726  FAUDES_TEST_DUMP("nonblocking 9b", nonblocking_ok9);
727 
728 
730 
731  // say good bye
732  std::cout << "done.\n";
733  return 0;
734 }
735 
736 
737 
int main()
Definition: 3_functions.cpp:29
#define FAUDES_TEST_DIFF()
Test protocol diff macro.
Definition: cfl_helper.h:493
#define FAUDES_TEST_DUMP(mes, dat)
Test protocol record macro ("mangle" filename for platform independance)
Definition: cfl_helper.h:483
Set of indices with symbolic names.
Definition: cfl_nameset.h:69
bool Insert(const Idx &rIndex)
Add an element by index.
virtual const T & At(const Position &pos) const
Access element.
void DWrite(const Type *pContext=0) const
Write configuration data to console, debugging format.
Definition: cfl_types.cpp:225
void Read(const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
Read configuration data from file with label specified.
Definition: cfl_types.cpp:261
void Write(const Type *pContext=0) const
Write configuration data to console.
Definition: cfl_types.cpp:139
virtual void PushBack(const Type &rElem)
Append specified entry.
virtual void Clear(void)
Clear all vector.
Base class of all FAUDES generators.
const StateSet & InitStates(void) const
Const ref to initial states.
StateSet BlockingStates(void) const
Compute set of blocking states.
bool StateNamesEnabled(void) const
Whether libFAUEDS functions are requested to generate state names.
Idx Size(void) const
Get Size of TBaseSet.
Definition: cfl_baseset.h:1819
void ConflictEquivalentAbstraction(vGenerator &rGen, EventSet &rSilentEvents)
Conflict equivalent abstraction.
void StateMin(const Generator &rGen, Generator &rResGen)
State set minimization.
void FullLanguage(const EventSet &rAlphabet, Generator &rResGen)
Full Language, L(G)=Lm(G)=Sigma*.
void LanguageUnion(const Generator &rGen1, const Generator &rGen2, Generator &rResGen)
Language union, deterministic version.
void SelfLoop(Generator &rGen, const EventSet &rAlphabet)
Self-loop all states.
bool LanguageDisjoint(const Generator &rGen1, const Generator &rGen2)
Test whether two languages are disjoint.
bool LanguageInclusion(const Generator &rGen1, const Generator &rGen2)
Test language inclusion, Lm1<=Lm2.
void KleeneClosure(Generator &rGen)
Kleene Closure.
void PrefixClosure(Generator &rGen)
Prefix Closure.
void Deterministic(const Generator &rGen, Generator &rResGen)
Make generator deterministic.
void Automaton(Generator &rGen, const EventSet &rAlphabet)
Convert generator to automaton wrt specified alphabet.
bool IsOmegaClosed(const Generator &rGen)
Test for topologically closed omega language.
Definition: cfl_omega.cpp:488
void AlphabetLanguage(const EventSet &rAlphabet, Generator &rResGen)
Alphabet Language, L(G)=Lm(G)=Sigma.
void OmegaParallel(const Generator &rGen1, const Generator &rGen2, Generator &rResGen)
Parallel composition with relaxed acceptance condition.
Definition: cfl_omega.cpp:261
void OmegaClosure(Generator &rGen)
Topological closure.
Definition: cfl_omega.cpp:470
void LanguageConcatenate(const Generator &rGen1, const Generator &rGen2, Generator &rResGen)
Language concatenation, deterministic version.
bool LanguageEquality(const Generator &rGen1, const Generator &rGen2)
Language equality, Lm1==Lm2.
void LanguageDifference(const Generator &rGen1, const Generator &rGen2, Generator &rResGen)
Language difference (set-theoretic difference).
void LanguageIntersection(const Generator &rGen1, const Generator &rGen2, Generator &rResGen)
Language intersection.
bool IsPrefixClosed(const Generator &rGen)
Test for prefix closed marked language.
void Project(const Generator &rGen, const EventSet &rProjectAlphabet, Generator &rResGen)
Deterministic projection.
void EmptyLanguage(const EventSet &rAlphabet, Generator &rResGen)
Empty language Lm(G)={}.
void Parallel(const Generator &rGen1, const Generator &rGen2, Generator &rResGen)
Parallel composition.
void LanguageComplement(Generator &rGen, const EventSet &rAlphabet)
Language complement wrt specified alphabet.
void EmptyStringLanguage(const EventSet &rAlphabet, Generator &rResGen)
Empty string language, L(G)=Lm(G)={epsilon}.
void KleeneClosureNonDet(Generator &rGen)
Kleene Closure, nondeterministic version.
void SelfLoopMarkedStates(Generator &rGen, const EventSet &rAlphabet)
Self-loop all marked states.
Includes all libFAUDES headers, incl plugings
libFAUDES resides within the namespace faudes.
bool IsNonblocking(const GeneratorVector &rGvec)

libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen