1_generator.cppGo to the documentation of this file.00001 /** @file 1_generator.cpp 00002 00003 Tutorial, Generator methods. 00004 00005 The Generator class implements the 5-tuple automaton G, consisting of 00006 - Set of States Q, 00007 - Alphabet Sigma, 00008 - Transition Relation Delta, 00009 - Set of Initial States Qo, and 00010 - Set of Marked States Qm. 00011 00012 This tutorial demonstrates how to insert/erase states, events and transitions. 00013 It also demonstrates file IO. 00014 00015 @ingroup Tutorials 00016 00017 @include 1_generator.cpp 00018 */ 00019 00020 00021 #include "libfaudes.h" 00022 00023 // make faudes namespace available 00024 using namespace faudes; 00025 00026 00027 00028 ///////////////// 00029 // main program 00030 ///////////////// 00031 00032 int main() { 00033 00034 //////////////////////////////////////////// 00035 // Constructors (part 1) and filling example 00036 //////////////////////////////////////////// 00037 00038 // at first we create an empty Generator object 00039 00040 Generator g1; 00041 00042 // do some random "user interaction" stuff with the Generator g1 00043 00044 g1.InsState("s1"); 00045 g1.InsState("s2"); 00046 g1.InsState("s3"); 00047 00048 g1.InsEvent("a"); 00049 g1.InsEvent("b"); 00050 00051 g1.SetTransition("s1", "a", "s2"); 00052 g1.SetTransition("s2", "a", "s3"); 00053 g1.SetTransition("s3", "b", "s1"); 00054 00055 g1.SetInitState("s1"); 00056 g1.SetMarkedState("s2"); 00057 g1.SetMarkedState("s3"); 00058 00059 // inspect result on console 00060 00061 std::cout << "################################\n"; 00062 std::cout << "# tutorial, handcraft generator \n"; 00063 g1.Write(); 00064 std::cout << "################################\n"; 00065 00066 // record test case 00067 FAUDES_TEST_DUMP("g1", g1); 00068 00069 00070 00071 /////////////////////////////////////////////////// 00072 // Constructors (part 2) & Copying and versioning 00073 /////////////////////////////////////////////////// 00074 00075 // Create a 1:1 copy of the Generator with the copy constructor ... 00076 00077 Generator g_copy(g1); 00078 00079 // ... with assignment method, or assignement operator 00080 00081 Generator g2; 00082 g2.Assign(g1); 00083 Generator g3=g2; 00084 00085 // create a Generator copy with versioned events (for testing algorithms): 00086 // versioning by an integer. E.g. for integer 3 events {"a", "b", "c"} 00087 // become {"a_3", "b_3", "c_3"}. 00088 00089 Generator version1; 00090 g3.Version(3, version1); 00091 00092 // versioning by a string. "a" -> "a_versionstring" 00093 00094 Generator version2; 00095 g3.Version("str", version2); 00096 00097 // versioning by replacing a pattern "_str" -> "_machine_3" 00098 00099 Generator version3; 00100 version2.Version("_str", "_machine_3",version3); 00101 00102 // editing by renaming an individual event 00103 00104 version3.EventRename("a_machine_3","synch"); 00105 00106 // inspect result on console 00107 00108 std::cout << "################################\n"; 00109 std::cout << "# tutorial, version of generator \n"; 00110 version3.Write(); 00111 std::cout << "################################\n"; 00112 00113 // record test case 00114 FAUDES_TEST_DUMP("generator", version1); 00115 00116 00117 /////////////////////////////////////////////// 00118 // Methods for Input/Output 00119 /////////////////////////////////////////////// 00120 00121 // read a Generator from file 00122 00123 g2.Read("data/simplemachine.gen"); 00124 00125 // create a Generator by reading a Generator file 00126 00127 Generator g4("data/simplemachine.gen"); 00128 00129 00130 // write a Generator to file 00131 00132 g4.Write("tmp_simplemachine.gen"); 00133 00134 // write a Generator to file with re-indexed states 00135 00136 g4.ReindexOnWrite(true); 00137 g4.Write("tmp_simplemachine_ridx.gen"); 00138 00139 // read back files (testing token io) 00140 g4.Read("tmp_simplemachine.gen"); 00141 g4.Read("tmp_simplemachine_ridx.gen"); 00142 00143 // debug output of Generator to console 00144 00145 std::cout << "################################\n"; 00146 std::cout << "# tutorial, debug dump \n"; 00147 g4.DWrite(); 00148 std::cout << "################################\n"; 00149 00150 // create dotfile for further processing by graphviz 00151 // (map state indices to begin with 1) 00152 00153 g4.DotWrite("tmp_simplemachine.dot"); 00154 g4.DDotWrite("tmp_simplemachine_debug.dot"); 00155 00156 // there also is a convenience method, that runs graphviz to 00157 // generate graphical output; requires "dot" binary in $PATH 00158 try { 00159 g4.GraphWrite("tmp_simplemachinie.png"); 00160 } catch(faudes::Exception& exception) { 00161 std::cout << "1_generator: cannot execute graphviz' dot. " << std::endl; 00162 } 00163 00164 00165 // create a debug string for an event with symbolic name + index 00166 00167 std::string str_singleevent = g1.EStr(2); 00168 00169 // create a debug string for a state with symbolic name + index. 00170 // If there is no symblic name, a symbolic name of the index is constructed. 00171 00172 std::string str_singlestate = g1.SStr(3); 00173 00174 // build string of events in the Generator's alphabet 00175 00176 std::string str_alph = g1.AlphabetToString(); 00177 00178 // build string of states in the Generator's set of states 00179 std::string str_states = g1.StatesToString(); 00180 00181 // there also are TransRelToString(), InitStatesToString() and MarkedStatesToString() 00182 00183 00184 ////////////////////////////////////// 00185 // Accessing the Generator's Members 00186 ////////////////////////////////////// 00187 00188 // get the Generator's name 00189 00190 std::string str_name = g1.Name(); 00191 00192 // set new name for Generator 00193 00194 g1.Name("NewName"); 00195 00196 00197 00198 // the core members alphabet, stateset and transitionrelation may be retrieved 00199 // as const references; ie. they can be inspected freely, but write access is 00200 // exclusively via the provided Generator methods. 00201 00202 // retrieve a const reference to and copy of the Generator's alphabet 00203 00204 const EventSet& eset_ref_alph = g1.Alphabet(); 00205 EventSet eset_copy_alph = g1.Alphabet(); 00206 00207 // you cannot alter the alphabet of a generator via an alphabet method 00208 // eset_ref_alph.Insert("new_event"); // compile time error! 00209 00210 // however, the copy can be altered, but with no effect on the original generator 00211 00212 eset_copy_alph.Insert("new_event"); 00213 if(g1.ExistsEvent("new_event")) std::cout << "### THIS CANNOT HAPPEN ###"; 00214 00215 // retrieve a const reference to and copy of the Generator's set of states "mStates" 00216 00217 const StateSet& sset_ref_states = g1.States(); 00218 StateSet sset_copy_states = g1.States(); 00219 00220 // retrieve a const reference to and a copy of the Generator's transition relation "mTransRel" 00221 00222 const TransSet& tset_ref_trel = g1.TransRel(); 00223 TransSet tset_copy_trel = g1.TransRel(); 00224 00225 // same with initial states and marked states 00226 00227 const StateSet& sset_ref_istates = g1.InitStates(); 00228 StateSet sset_copy_istates = g1.InitStates(); 00229 00230 const StateSet& sset_ref_mstates = g1.MarkedStates(); 00231 StateSet sset_copy_mstates = g1.MarkedStates(); 00232 00233 00234 00235 ////////////////////////////////////////////////////////////////////////////// 00236 // Modifying the 5-tuple Generator (X, Sigma, Delta, X0 and Xm) 00237 ////////////////////////////////////////////////////////////////////////////// 00238 00239 // insert an event by it's symbolic name in the alphabet 00240 // (if the event is not known so far, a new index for the symbolic name is generated) 00241 g1.InsEvent("newevent"); 00242 00243 00244 // insert an existing event into the Generator's alphabet (mAlphabet) 00245 // (by "existing event" we refer to an event that has been previously inserted to some Generator) 00246 00247 g1.InsEvent(1); // of course index 1 is already in the alphabet here... 00248 00249 // insert a bunch of events (EventSet) and get the integer index if requested 00250 00251 EventSet eset1; 00252 eset1.Insert("newevent1"); 00253 Idx idx_tmp = eset1.Insert("newevent2"); 00254 g1.InsEvents(eset1); 00255 00256 // delete an event from Generator ie delete from alphabet and transition relation 00257 00258 g1.DelEvent("newevent1"); // by symbolic name 00259 g1.DelEvent(idx_tmp); // by index 00260 00261 // delete a bunch of events 00262 // g1.DelEvents(eset1); // .. of course we have already deleted them before... 00263 00264 // insert a new state. The state gets a integer index that is unique within 00265 // the Generator 00266 00267 idx_tmp = g1.InsState(); // anonymous state 00268 idx_tmp = g1.InsState("newstate2"); // named state 00269 idx_tmp = g1.InsState("77"); // named state 00270 00271 // insert a new state as initial state 00272 00273 idx_tmp = g1.InsInitState(); 00274 idx_tmp = g1.InsInitState("newinitstate"); 00275 00276 // ... same for marked states 00277 00278 idx_tmp = g1.InsMarkedState(); 00279 idx_tmp = g1.InsMarkedState("newmarkedstate"); 00280 00281 00282 // delete single states from Generator ie stateset and transitionrelation 00283 00284 g1.DelState(idx_tmp); // by index (relatively fast, for algorithms) 00285 g1.DelState("newinitstate"); // by symbolic name, if name assigned 00286 00287 // delete a bunch of states 00288 // (this should be more efficient than deleting states individually) 00289 00290 StateSet stateset1; 00291 stateset1.Insert(1); 00292 stateset1.Insert(2); 00293 stateset1.Insert(3); 00294 g1.DelStates(stateset1); 00295 00296 // for further proceeding we insert some new states and events... 00297 00298 Idx idx_s10 = g1.InsState("s10"); 00299 Idx idx_s11 = g1.InsState("s11"); 00300 Idx idx_s12 = g1.InsState("s12"); 00301 Idx idx_e10 = g1.InsEvent("e10"); 00302 Idx idx_e11 = g1.InsEvent("e11"); 00303 00304 // set a state that already exists in Generator as initial state 00305 00306 g1.SetInitState(idx_s10); 00307 00308 // set a state that already exists in Generator as marked state 00309 00310 g1.SetMarkedState(idx_s11); 00311 00312 // unset an existing state as initial state (does not remove from mStates) 00313 00314 g1.ClrInitState(idx_s10); 00315 00316 // unset an existing state as marked state (does not remove from stateset) 00317 00318 g1.ClrMarkedState(idx_s10); 00319 00320 // clear all initial states (does not remove from stateset) 00321 00322 // g1.ClrInitStates(); // we do not really do it here, so it's commented 00323 00324 // clear all marked states (mStates stays untouched) 00325 00326 // g1.ClrMarkedStates(); // we do not really do it here, so it's commented 00327 00328 // set a transition for existing states and events 00329 00330 g1.SetTransition(idx_s10, idx_e10, idx_s11); // by indices 00331 g1.SetTransition("s10", "e11", "s10"); // by symbolic names (slow) 00332 00333 00334 // report back to console 00335 00336 std::cout << "################################\n"; 00337 std::cout << "# tutorial, on the way ... \n"; 00338 g1.Write(); 00339 std::cout << "################################\n"; 00340 00341 00342 // clear a transition (does not touch mStates, mInitStates and mMarkedStates) 00343 00344 g1.ClrTransition(idx_s10, idx_e10, idx_s11); // by index 00345 00346 // transitions can also be cleared by names (slower) or by an assigned 00347 // TransSet::Iterator (faster); use ClearTransRel() to remove all transitions 00348 00349 00350 // clear the symbolic name for a state in the StateSymbolTable 00351 00352 g1.ClrStateName(idx_s10); 00353 00354 // exists event index/name in mAlphabet? 00355 00356 bool bool_eventexists1 = g1.ExistsEvent("e11"); 00357 bool bool_eventexists2 = g1.ExistsEvent(2); 00358 00359 00360 // exists state in mStates? 00361 00362 bool bool_stateexists1 = g1.ExistsState(4); 00363 00364 00365 // check if a state is an initial state 00366 00367 bool bool_initstateexists = g1.ExistsInitState(4); 00368 00369 // check if a state is a marked state 00370 00371 bool bool_ismarkedstate = g1.ExistsMarkedState(4); 00372 00373 // look up event name for index in the EventSymbolTable of the event domain 00374 00375 std::string str_eventname1 = g1.EventName(1); 00376 00377 // look up event index for name in the EventSymbolTable of the event domain 00378 00379 Idx idx_eventindex = g1.EventIndex("e11"); 00380 00381 // get symbolic name assigned to state (returns "" if no name assigned). 00382 00383 std::string str_tmp = g1.StateName(idx_s10); 00384 00385 // get index for symbolic state name. only possible for state names of states in 00386 // the Generator 00387 00388 idx_tmp = g1.StateIndex("s12"); 00389 00390 // clear Generator (including alphabet) 00391 00392 g4.Clear(); 00393 00394 // get the number of events in the Generator's alphabet 00395 00396 Idx idx_eventnum = g1.AlphabetSize(); 00397 00398 // get the number of states 00399 00400 Idx idx_statenum = g1.Size(); 00401 00402 // get the number of transitions 00403 00404 Idx idx_transnum = g1.TransRelSize(); 00405 00406 // there also are InitStatesSize(), MarkedStatesSize() 00407 00408 // is the alphabet of the Generator empty? 00409 00410 bool bool_alphempty = g1.AlphabetEmpty(); 00411 00412 // is the Generator empty (number of states == 0) ? 00413 00414 bool bool_isempty = g1.Empty(); 00415 00416 // see also TransRelEmpty, InitStatesEmpty, MarkedStatesEmpty 00417 00418 00419 // insert a small loop 00420 00421 Idx initstate = g1.InsInitState("in"); 00422 Idx markedstate = g1.InsMarkedState("out"); 00423 g1.SetTransition("in","a","out"); 00424 g1.SetTransition("out","a","in"); 00425 00426 00427 // show effect on console 00428 00429 std::cout << "################################\n"; 00430 std::cout << "# tutorial, after ins and del \n"; 00431 g1.DWrite(); 00432 std::cout << "################################\n"; 00433 00434 // record test case 00435 FAUDES_TEST_DUMP("g1, edited", g1); 00436 00437 /////////////////////// 00438 // Iterators 00439 /////////////////////// 00440 00441 // since the core members are all implemented as sets, iterators 00442 // effectively are const_iterators, i.e. you cannot change the 00443 // current value of an iterator. instead you may remove the value 00444 // and insert the new value. 00445 00446 // iteration over alphabet indices (member "mAlphabet") 00447 00448 std::cout << "################################\n"; 00449 std::cout << "# tutorial, iterators 1 \n"; 00450 EventSet::Iterator eit; 00451 for (eit = g1.AlphabetBegin(); eit != g1.AlphabetEnd(); ++eit) { 00452 std::cout << "event \"" << g1.EventName(*eit) << "\" with index "<< *eit << std::endl; 00453 } 00454 std::cout << "################################\n"; 00455 00456 // iteration over state indices (member "mStates") 00457 00458 std::cout << "################################\n"; 00459 std::cout << "# tutorial, iterators 2 \n"; 00460 StateSet::Iterator sit; 00461 for (sit = g1.StatesBegin(); sit != g1.StatesEnd(); ++sit) { 00462 std::cout << *sit << std::endl; 00463 } 00464 std::cout << "################################\n"; 00465 00466 // iteration over complete transition relation (member "mTransRel") 00467 00468 std::cout << "################################\n"; 00469 std::cout << "# tutorial, iterators 3 \n"; 00470 TransSet::Iterator tit; 00471 for (tit = g1.TransRelBegin(); tit != g1.TransRelEnd(); ++tit) { 00472 std::cout << g1.TStr(*tit) << std::endl; 00473 } 00474 std::cout << "################################\n"; 00475 00476 // iteration over transitions from a given state; note that we avoid 00477 // computation of the end of the iteration in every step 00478 00479 std::cout << "################################\n"; 00480 std::cout << "# tutorial, iterators 4 \n"; 00481 idx_tmp = g1.StateIndex("s1"); 00482 TransSet::Iterator tit_end; 00483 tit = g1.TransRelBegin(idx_tmp); 00484 tit_end = g1.TransRelEnd(idx_tmp); 00485 for (; tit != tit_end; ++tit) { 00486 std::cout << g1.TStr(*tit) << std::endl; 00487 } 00488 std::cout << "################################\n"; 00489 00490 // variations: transitions of given state index + given event index: 00491 // TransRelBegin(x1, ev) - TransRelEnd(x1, ev) 00492 00493 // iteration over initial and marked states: 00494 // InitStatesBegin() - InitStatesEnd() (member "mInitStates") 00495 // MarkedStatesBegin() - MarkedStatesEnd() (member "mMarkedStates") 00496 00497 00498 //////////////////////////////////////////////////////////// 00499 // retrieve copies of the Generator's transition releation 00500 // in different sorting orders than X1 -> Ev -> X2 00501 //////////////////////////////////////////////////////////// 00502 00503 // note: the availabity of iterator ranges depends on the sorting order; 00504 // eg iteration with specified x2 requires X2->Ev->X1 or X2->X1->Ev sorting. 00505 00506 // retrieve a copy that is sorted by X2 -> Ev -> X1 by the binary 00507 // predicate TransSort::X2EvX1. 00508 00509 TransSetX2EvX1 tset_x2evx1; 00510 g1.TransRel(tset_x2evx1); 00511 00512 // report to console 00513 00514 std::cout << "################################\n"; 00515 std::cout << "# tutorial, x2-ev-x1 sorting\n"; 00516 TransSetX2EvX1::Iterator tit2; 00517 for (tit2 = tset_x2evx1.Begin(); tit2 != tset_x2evx1.End(); ++tit2) { 00518 std::cout << g1.TStr(*tit2) << std::endl; 00519 } 00520 std::cout << "################################\n"; 00521 00522 00523 00524 //////////////////////// 00525 // Convenience Methods 00526 //////////////////////// 00527 00528 // remove all events from mAlphabet, that do not have a transition in 00529 // mTransRel: g1.MinimizeAlphabet() 00530 00531 // get an EventSet containing all the events that drive some transition 00532 00533 EventSet eset_usedevents = g1.UsedEvents(); 00534 00535 // get an EventSet containing all the events that do not drive any transition 00536 00537 EventSet eset_unusedevents = g1.UnusedEvents(); 00538 00539 // return the active event set at a given state 00540 00541 EventSet eset_activeeventset = g1.ActiveEventSet(idx_s12); 00542 00543 // return a StateSet containing all the states that are connected by 00544 // some transition 00545 00546 StateSet sset_trel_sspace = g1.TransRelStates(); 00547 00548 // return a StateSet containing all the successor states of a given predecessor 00549 // state. 00550 00551 StateSet sset_successors = g1.SuccessorStates(idx_s12); 00552 00553 // note: if you need predecessor states, use a resorted transition relation 00554 00555 ///////////////////////////////// 00556 // Symbolic state name handling 00557 ///////////////////////////////// 00558 00559 // are symbolic state names enabled? depending on this boolean value 00560 // library functions like Determine or StateMin may create symbolic 00561 // state names automatically 00562 00563 bool bool_statenamesenabled = g1.StateNamesEnabled(); 00564 00565 // disable state name creation in resulting generators for functions in 00566 // the faudes library, that support this feature (nearly all) with 00567 // "false"; enable state name creation with "true". 00568 00569 g1.StateNamesEnabled(true); // anyway .. true is the default value 00570 00571 // clear existing symbolic statenames for states in the Generator 00572 00573 // g1.ClearStateNames(); 00574 00575 // set symbolic names for all states in the generator. the symbolic name becomes 00576 // the equivalent string representation of the state's integer index. This is 00577 // only usefull for debugging purposes. 00578 00579 g1.SetDefaultStateNames(); 00580 00581 00582 // show effect on console 00583 00584 std::cout << "################################\n"; 00585 std::cout << "# tutorial, default names \n"; 00586 g1.Write(); 00587 std::cout << "################################\n"; 00588 00589 00590 /////////////////////////////////// 00591 // Accessible, Coaccessible, Complete, Trim 00592 /////////////////////////////////// 00593 00594 // read example generator for reachability analysis 00595 Generator greach("data/trimness_nottrim.gen"); 00596 00597 std::cout << "################################\n"; 00598 std::cout << "# tutorial, reachability test case \n"; 00599 greach.Write(); 00600 std::cout << "# tutorial, reachability relevant sets \n"; 00601 StateSet astates = greach.AccessibleSet(); 00602 StateSet cstates = greach.CoaccessibleSet(); 00603 StateSet tstates = greach.TerminalStates(); 00604 astates.Write(); 00605 cstates.Write(); 00606 tstates.Write(); 00607 std::cout << "# tutorial, reachability analysis \n"; 00608 bool isacc = greach.IsAccessible(); 00609 if(isacc) 00610 std::cout << "accesibility: ok [error]\n"; 00611 else 00612 std::cout << "accesibility: failed [expected]\n"; 00613 bool iscoacc = greach.IsCoaccessible(); 00614 if(iscoacc) 00615 std::cout << "coaccesibility: ok [error]\n"; 00616 else 00617 std::cout << "coaccesibility: failed [expected]\n"; 00618 bool iscompl = greach.IsComplete(); 00619 if(iscompl) 00620 std::cout << "completeness: ok [error]\n"; 00621 else 00622 std::cout << "completeness: failed [expected]\n"; 00623 bool istrim = greach.IsTrim(); 00624 if(istrim) 00625 std::cout << "trimness: ok [error]\n"; 00626 else 00627 std::cout << "trimness: failed [expected]\n"; 00628 bool isotrim = greach.IsOmegaTrim(); 00629 if(isotrim) 00630 std::cout << "w-trimness: ok [error]\n"; 00631 else 00632 std::cout << "w-trimness: failed [expected]\n"; 00633 std::cout << "################################\n"; 00634 00635 // record test case 00636 FAUDES_TEST_DUMP("acc",astates); 00637 FAUDES_TEST_DUMP("coacc",cstates); 00638 FAUDES_TEST_DUMP("term",tstates); 00639 00640 // Make the Generator accessible by removing transitions and states. 00641 // The routine returns true if the generator has an initial state. 00642 Generator gaccess(greach); 00643 gaccess.Name("GAccessible"); 00644 bool bool_hasinit = gaccess.Accessible(); 00645 00646 // Make the Generator coaccessible by removing transitions and states. 00647 // The routine returns true if the generator has a marked state. 00648 Generator gcoaccess(greach); 00649 gcoaccess.Name("GCoccessible"); 00650 bool bool_hasmarked = gcoaccess.Coaccessible(); 00651 00652 // Make the Generator complete by removing transitions and states. 00653 // The routine returns true if the generator has an initial state. 00654 Generator gcompl(greach); 00655 gcompl.Name("GComplete"); 00656 gcompl.Complete(); 00657 00658 // Make the Generator trim by removing transitions and states. 00659 // The routine returns true if the generator has an initial state 00660 // and a marked state. 00661 Generator gtrim(greach); 00662 gtrim.Name("GTrim"); 00663 bool bool_isnontrivial = gtrim.Trim(); 00664 00665 // Make the Generator omega-trim by removing transitions and states. 00666 // The routine returns true if the generator has an initial state 00667 // and a marked state. 00668 Generator gotrim(greach); 00669 gotrim.Name("GOmegaTrim"); 00670 gotrim.OmegaTrim(); 00671 00672 // show effect on console 00673 std::cout << "################################\n"; 00674 std::cout << "# tutorial, reachability results \n"; 00675 gaccess.Write(); 00676 gcoaccess.Write(); 00677 gcompl.Write(); 00678 gtrim.Write(); 00679 gotrim.Write(); 00680 std::cout << "################################\n"; 00681 00682 // contribute to html docu 00683 greach.Write("tmp_greach.gen"); 00684 gaccess.Write("tmp_gaccess.gen"); 00685 gcoaccess.Write("tmp_gcoaccess.gen"); 00686 gcompl.Write("tmp_gcompl.gen"); 00687 gtrim.Write("tmp_gtrim.gen"); 00688 gotrim.Write("tmp_gotrim.gen"); 00689 00690 // Test protocol 00691 FAUDES_TEST_DUMP("accessible",gaccess); 00692 FAUDES_TEST_DUMP("coaccessible",gcoaccess); 00693 FAUDES_TEST_DUMP("complete",gcompl); 00694 FAUDES_TEST_DUMP("trim",gtrim); 00695 FAUDES_TEST_DUMP("omega trim",gotrim); 00696 00697 00698 /////////////////////////////////// 00699 // Generalized Completeness 00700 /////////////////////////////////// 00701 00702 // read example generator for generalized completeness 00703 Generator gsigcomplB("data/trimness_nottrim.gen"); 00704 Generator gsigcomplC("data/trimness_nottrim.gen"); 00705 EventSet sigoB; 00706 sigoB.FromString("<A> b </A>"); 00707 EventSet sigoC; 00708 sigoC.FromString("<A> c </A>"); 00709 00710 std::cout << "################################\n"; 00711 std::cout << "# tutorial, sigma_o-completeness test case \n"; 00712 greach.Write(); 00713 bool issigcompl = gsigcomplB.IsComplete(sigoB); 00714 if(iscompl) 00715 std::cout << "completeness: ok [error]\n"; 00716 else 00717 std::cout << "completeness: failed [expected]\n"; 00718 00719 00720 // Make the Generator complete by removing transitions and states. 00721 // The routine returns true if the generator has an initial state. 00722 gsigcomplB.Name("GSigoCompleteB"); 00723 gsigcomplB.Complete(sigoB); 00724 gsigcomplC.Name("GSigoCompleteC"); 00725 gsigcomplC.Complete(sigoC); 00726 00727 // record test case 00728 FAUDES_TEST_DUMP("iscmpl",issigcompl); 00729 FAUDES_TEST_DUMP("gsigcomplB",gsigcomplB); 00730 FAUDES_TEST_DUMP("gsigcomplC",gsigcomplC); 00731 00732 // contribute to html docu 00733 gsigcomplB.Write("tmp_gsigcomplb.gen"); 00734 gsigcomplC.Write("tmp_gsigcomplc.gen"); 00735 00736 00737 /////////////////////////////////// 00738 // Test case evaluation 00739 /////////////////////////////////// 00740 FAUDES_TEST_DIFF(); 00741 00742 return 0; 00743 } 00744 00745 00746 libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen |