Modeling and Verification Devoir Maison 6 : DSL Alexis Marechal & Levi Lucio April 20, 2009 Introduction In homework 3 we saw an introduction to BPMN. BPMN is a well known formalism to define a system behaviour, but it doesn t have formal semantics (you cannot execute a Business Process). On the other hand we saw in the course an in-depth description of Algebraic Petri Nets, that can be used to model the same systems, but also have formal semantics. The objective of the homework 3 was to give semantics to a particular Bussiness Process using a tranlation to APN. In this homework, we will study some elements of a generic way to achieve this translation. We could try to translate directly the Business Process defined with Intalio, but this can be a bit complicated. Instead we ll use the XText plugin, seen during the exercises session, to create a simple language that will allow us to create and translate Business Process. This task presents two major issues, we ll try to avoid them in this exercise. The first issue is data types. In BPMN there is no way to define precisely which data structures are used. In APN, on the other hand, data structures are clearly defined (including semantics) with ADTs. In order to simplify this exercise, we will only consider P/T Petri Nets and we won t care about the data handled. The second issue is that a BPMN activity doesn t have clear semantics, when we create a Business Process we suppose that any activity is simple and that we won t have any problem implementing it. We can t make this assumption if we want to define clear and formal semantics for our Business Process. In order to
by-pass this problem, we will consider that a BPMN activity only represents a state of our system, and it doesn t have any behaviour. In clear, a BPMN activity will be translated as a single place in our Petri Nets. If you check the Business Process that we used for the homework 3 (still available in the course website), and consider the first subprocess, you will notice that activities like Database request or decode PIN where complex, and thus were translated using more than one place/transition. On the other hand, the activity called verify PIN was extremely simple, and was translated as a single place. We will consider in the following exercises that all BPMN activites are like the last one. 2 Exercise : DSL creation During the exercises session we saw how to use xtext in order to create a DSL for Petri Nets. Create a DSL for BPMN using XText. Your DSL must allow a user to specify a Business Process that contains the elements defined in the table (given the restrictions stated in the introduction). Please note that, in order to simplify your work, we changed a bit the structure of the BPMN elements: in BPMN there is no difference between an In Gateway" and an Out Gateway". Creating this difference should make the translation into Petri Nets much easier. While creating your DSL try to keep in mind that you will have to generate code from your models like we saw during the exercises session, so try to think how would you translate the elements you are defining into P/T Petri Nets. 3 Exercice 2: Semantics definition by transformation We will now give semantics to the Business Process diagram you have expressed in your DSL. The semantics will be given by translation into a Petri Net and we will then produce the state space for the given Petri Net. We saw in the exrcises session how to translate Petri Nets to Java, using XPand. In this exercise we will use XPand to translate our Business Process to Petri Nets, using a Prolog syntax. The required prolog syntax includes three simple facts: inarc/3 define arcs going from places into transitions; 2
outarc/3 initial/ define arcs going from transitions into places; defines the initial state for the Petri Net. for example, the facts: inarc(p,t,). outarc(t,p2,). inarc(p5,t3,). outarc(t3,p,). inarc(p2,t4,). outarc(t4,p3,). inarc(p2,t2,). outarc(t2,p4,). inarc(p,t5,). outarc(t5,p5,). initial([(p,),(p2,0),(p3,0),(p4,0),(p5,0)]). define the Petri Net in figure. p t t5 p2 p5 t4 t2 t3 p3 p4 Figure : Petri Net Example From the course site you can download a file called semantic_tools.zip containing the following files: engine.pl: contains the prolog engine that will produce the state space for a petri net; petri_net.pl: contains a definition of the Petri Net you want to explore, you will have to override this file with your own results; 3
launch.pl: contains a script that produces a visual form of the Petri Net you are exploring and the state space of that Petri Net. From your XPand translation you will produce a file petri_net.pl that will replace the example given. You can then load the launch.pl script in the prolog interpreter and call the predicate launch. Two files will be created: petri_net.dot: contains the visual description of the Petri Net you have translated from your Business Process diagram; state_space.dot: contains the visual description of the state space of the Petri Net you have you have translated from your Business Process diagram. In order to obtain SWI Prolog you can go to the webpage http://www.swiprolog.org/download/stable. The output in dot format can be read by an application called Graphviz that pretty prints diagrams. You can obtain Graphviz freely at http://www.graphviz.org/. 4 Exercise 3: example In order to test your implementation, you should provide a very small but fully functional example, i.e. a Business Process described using with your DSL that can be executed using the Prolog API. You should include in your solution the Busines Process specification and talk about your results in your final report. Figure 2: Business Process Example 4
Send your solutions by mail to levi.lucio@unige.ch and alexis.marechal@unige.ch with the subject of the mail starting by TP and including the number of the devoir maison and you name. Example: TP_7_your_name_here. Deadline: 29th of may, noon, for the first version. 2nd of june, midnight, for the final version. 5
Activities (as simple places). Start events. End events. Exclusive in gateways. Exclusive out gateways. Inclusive in gateways. Inclusive out gateways. Control flows. Table : Elements of BPMN to be defined in the DSL. 6