pd_counterexample_griffin.cpp
Go to the documentation of this file.
1 /** @file pd_counterexample_griffin.cpp
2 
3 Synthesizes the minimal restrictive supervisor for a combination of plant and specification presented in the appendix of the technical report by Schneider and Schmuck (referenced at the webpage of this plugin). This is a counterexample to the results by Griffin (2008) as his algorithm returns a real subset of the supremal controllable sublanguage. Using our tool (i.e. this tutorial), the correct supervisor is synthesized.
4 
5 To run the tutorial and both save the output to a file and display it in the terminal, use
6 "./pd_counterexample_griffin ls -l 2>&1 | tee pd_counterexample_griffin.txt"
7 
8 @ingroup Tutorials
9 
10 @include pd_counterexample_griffin.cpp
11 
12 */
13 
14 /* Pushdown plugin for FAU Discrete Event Systems Library (libfaudes)
15 
16  Copyright (C) 2013 Sven Schneider,Anne-Kathrin Schmuck,Stefan Jacobi
17 
18 */
19 
20 #include "libfaudes.h"
21 #include "pd_include.h"
22 
23 // make the faudes namespace available to our program
24 using namespace faudes;
25 
26 int main(){
27 
28  //***********************************************
29  //create the specification, a pushdown generator
30  //************************************************
32 
33  //insert states
34  g.InsState("q0");
35  g.InsState("q1");
36  g.InsState("q2");
37 
38  //insert stack symbols
39  Idx lambda = g.InsStackSymbol(FAUDES_PD_LAMBDA); //always use FAUDES_PD_LAMBDA for lambda!
40  Idx dot = g.InsStackSymbol("dot");
41  Idx square = g.SetStackBottom("square");
42 
43  //insert events
44  g.InsControllableEvent("a");
45  g.InsControllableEvent("b");
47  //g.InsUncontrollableEvent(FAUDES_PD_LAMBDA); //here, we do not have lambda-transitions
48 
49  //build stack symbol vectors to be inserted as pop and push attributes of transitions
50  std::vector<Idx> vLambda; //vLambda is the abbreviation for the empty string
51  vLambda.push_back(lambda);
52 
53  std::vector<Idx> vSquare; //vSquare is the abbreviation for the string "Box"
54  vSquare.push_back(square);
55 
56  std::vector<Idx> vDot; //vDot is the abbreviation for the string "Dot"
57  vDot.push_back(dot);
58 
59  std::vector<Idx> vDotSquare; // vDotSquare is the abbreviation for the string "Dot Box"
60  vDotSquare.push_back(dot); // here the dot is pushed AFTER (popped BEFORE) the Box
61  vDotSquare.push_back(square);
62 
63  std::vector<Idx> vDotDot; // vDotDot is the abbreviation for the string "Dot Dot"
64  vDotDot.push_back(dot); // here two dots are pushed (popped)
65  vDotDot.push_back(dot);
66 
67  //insert transitions
68  g.SetTransition("q0", "a", "q0",vSquare,vDotSquare);
69  g.SetTransition("q0", "a", "q0",vDot,vDotDot);
70  g.SetTransition("q0", "b", "q1",vDot,vLambda);
71  g.SetTransition("q1", "u", "q2",vDot,vDot);
72 
73  //set state attributes
74  g.SetInitState("q0"); // one initial state
75  g.SetMarkedState("q0");//here all states are marked, as required by the algorithm of Griffin (2008)
76  g.SetMarkedState("q1");
77  g.SetMarkedState("q2");
78 
79  //*******************************
80  //create the plant, a DFA
81  //*******************************
82  System s;
83 
84  s.InsState("p0");
85  s.InsState("p1");
86  s.InsState("p2");
87 
88  s.InsControllableEvent("a");
89  s.InsControllableEvent("b");
91 
92  s.SetTransition("p0", "a", "p0");
93  s.SetTransition("p0", "b", "p1");
94  s.SetTransition("p1", "u", "p2");
95 
96  s.SetInitState("p0"); // one initial state
97  s.SetMarkedState("p0");//here all states are marked, as required by the algorithm of Griffin (2008)
98  s.SetMarkedState("p1");
99  s.SetMarkedState("p2");
100 
101  //*******************************
102  //print plant and specification
103  //*******************************
104  g.Write();
105  s.Write();
106 
107  //*******************************
108  //call synthesis algorithm
109  //*******************************
110  PushdownGenerator rPd;
112 
113  //*******************************
114  //print result
115  //*******************************
116  std::cout << "***************** RESULT *****************" << std::endl;
117  rPd.Write();
118 
119  //*******************************
120  //print words that are possible in the closed loop
121  //*******************************
122  LangK test(rPd);
123  test.FindLangK(50); //at most 50 are checked when generating words in the language
124  test.PrintWords();
125 
126  return 0;
127 }
128 

libFAUDES 2.28c --- 2016.09.30 --- c++ api documentaion by doxygen