Operationalizing Declarative and Procedural Knowledge: a Benchmark on Logic Programming Petri Nets (LPPNs)
Giovanni Sileno
 
	
	
	
	
	 
	
	Logic Programming Petri Nets: a Benchmark 
	
	
	
	
	
	
	
	
	Logic Programming Petri Nets: a Benchmark
	
	
	
	
	Informatics Institute, University of Amsterdam, the Netherlands

		 
	
	
	
	
	
	
	
	
	Logic Programming Petri Nets: a benchmark 
	Giovanni Sileno 
	Operationalizing Declarative and Procedural Knowledge: a Benchmark on Logic Programming Petri Nets (LPPNs)
    Giovanni Sileno^1
    Received December 14, 2016; accepted January 23, 2017
==========================================================================================================




Modelling, specifying and reasoning about complex systems requires to process in an integrated fashion declarative and procedural aspects of the target domain. The paper reports on an experiment conducted with a propositional version of Logic Programming Petri Nets (LPPNs), a notation extending Petri Nets with logic programming constructs. Two semantics are presented: a denotational semantics that fully maps the notation to ASP via Event Calculus; and a hybrid operational semantics that process separately the causal mechanisms via Petri nets, and the constraints associated to objects and to events via Answer Set Programming (ASP). These two alternative specifications enable an empirical evaluation in terms of computational efficiency. Experimental results show that the hybrid semantics is more efficient w.r.t. sequences, whereas the two semantics follows the same behaviour w.r.t. branchings (although the denotational one performs better in absolute terms).






§ INTRODUCTION

A proper treatment of cases or scenarios is based on two requirements: on the one hand, to capture and adequately process the symbolic entities used to represent the target system: instances, classes, interrelationships forming a local ontology relevant to the domain in focus; on the other hand, to reproduce—by means of elements modelling causal mechanisms, processes, courses of actions, etc.—the same dynamics exhibited by the target system. 

Consider for example this case: “While John was walking his dog, the dog ate Paul's flowers.” This event description is not sufficient for entailing that John is responsible to pay Paul for what happened, as typically this is entailed on the basis of norms as “The owner of an animal has to pay for the damages it produces.''. 
However, even this addition lacks crucial connections between the conceptual domains of the case and the one of the norm, like “dogs are animals”, “eating an object destroys the object”, “destruction is damage”, etc. 

These various elements exhibit two perspectives on knowledge: a declarative perceptive, concerning objects (physical, mental, institutional) and their logical relationships—both reified as symbols—; and a procedural perceptive, concerning patterns of events/actions, mechanisms, or processes (involving objects). Formal logic is the prototypical domain concerned with the first perspective, just as process modeling focuses on the second. Unfortunately, methodologies associated with one of the two aspects generally have a limited treatment of the other component, and they require specific mediating machinery to deal with. For instance, if you want to make a certain outcome impossible in a procedural model you need to add conditions that disable all transitions that might produce that outcome. If you want to represent a transition in a declarative way, a typical approach is to consider snapshots of the arrangements holding before and after the transition—possibly labeled with a sort of timestamp. This is essentially the principle behind situation calculus <cit.>, event calculus <cit.>, and fluent calculus <cit.>: using appropriate axioms, you can create and reason about the relations between these snapshots in a way such that they are compatible to the causal relationships between the moments they refer to.  

Rather than trying to project one dimension on the other, an alternative tradition in AI and logic proposes to consider causality as a primitive notion. This approach is for instance behind the idea of all Action languages <cit.>. Even when the dichotomy is made clear, however, operationalizations of these languages often result in compiling action programs to logic programs <cit.>, returning again to `snapshot-handling' solutions. 

The motivation behind this work stems from the hypothesis that leaving process analysis to procedural descriptions should be in principle a better choice: procedural components can directly map to native computational mechanisms, that can be used not only to re-present, but also re-create the process object, transforming the question from what the referent should be (characteristic of logic), to what it is (characteristic of simulation and more in general of model-execution). 

The paper reports therefore on a simple benchmark experiment with an hybrid notation (that is, including procedural and declarative knowledge components), called Logic Programming Petri Nets (LPPNs).[A prototype of a LPPN interpreter is available on <http://github.com/s1l3n0/pypneu>, together with the code run for conducting the experiment.] Section <ref> will introduce the motivation and an informal semantics of LPPNs. Section <ref> will present a formalisation of a propositional version of LPPN. Section <ref> will present an hybrid operational semantics and a denotational semantics based on ASP programs with Event Calculus. Section <ref> will present the results of a first empirical experiment. Discussion and further developments end the paper. 







§ LOGIC PROGRAMMING PETRI NETS


Logic Programming Petri Nets (LPPNs) are a visual notation first introduced in <cit.> as an common representational ground where to align representations of law (norms), of  implementations of law (regulatory services in the form of business processes), and of action (behavioural scripts ascribed to social participants). It has been used for a wide class of models (business processes embedded with normative positions, representation of scenarios issued from narratives, agent scripts, deontic paradoxes, etc. <cit.>). The notation builds upon the intuition that places and transitions mirror the common-sense distinction between objects and events (e.g. <cit.>), roughly reflecting the use of noun/verb categories in language <cit.>: the procedural components captured by Petri nets can be used to model transient aspects of the system in focus; the declarative components captured by logic programming construct can be used to model steady state aspects, i.e. those on which the transient is irrelevant or does not make sense (e.g. terminological constraints). In this section we will informally describe the bases motivating their integration. 



 §.§ From Petri Nets to LPPNs


Petri nets are a simple, yet effective computational modelling representation featuring an intuitive visualisation (see Fig. 1). They consist in directed, bipartite graphs with two types of nodes: places (visually represented with circles) and transitions (with boxes). A place can be connected only to transitions and vice-versa. One or more tokens (dots) can reside in each place. The execution of Petri nets is also named “token game”: transitions fire by consuming tokens from their input places and producing tokens in their output places.[For an overview on the general properties of Petri nets see e.g. <cit.>.]

Despite their widespread use in computer science, electronics, business process modelling and biology, Petri nets are generally considered not to be enough expressive for reasoning purposes: in their simplest form, tokens are indistinct, and do not transport any data. Nevertheless, it is a common practice for modellers to introduce labels to set up a correspondence between the modelling entities and the modelled entities. This practice enables them to read the results of a model execution in reference to the modelled system. In other words, an adequate labelling is still functional to the use of a Petri net for modelling purposes, although it is not a requirement for the execution in itself. Further interaction is possible if these labels are processed according to an additional formalism, as for instance it occurs with Coloured Petri Nets (CPNs) <cit.> (for many aspects a descendant of Predicate/Transition nets <cit.>). If their expressiveness and wide application provide reasons for its adoption,  CPNs also introduce many details which are unimportant in a case modelling setting (e.g. expressions on arcs); more importantly, they still lack the ability of specifying and processing declarative bindings, necessary, for instance, to model terminological relationships. This brings us to the idea of LPPN.



Whereas Petri nets essentially specify procedural mechanisms, LPPNs extend those (a) with literals as labels, attached on places and transitions; (b) with nodes specifying (logic-based) declarative bindings on places and on transitions. This paper will focus only on propositional labelling. Under this constraint, the execution of the LPPN procedural component is the same as Condition/Event nets, Petri nets whose places do not contain more than one token (Fig. <ref>). 

Logic operator nodes might apply on places (lp-nodes) or on transitions (lt-nodes). An example of a sub-net with lp-nodes (small black squares) is given in Fig. <ref>; these are used to create logic compositions of places (via operators as , , , etc). or to specify logic inter-dependencies (via the logic conditional ). Similarly, transitions may be connected declaratively via lt-nodes (black circles), as in Fig. <ref>; these connections may be interpreted as channels enabling instantaneous propagation of firing. In this case, it is not relevant to introduce operators as , for the interleaving semantics, only one source transition may fire per step. 

Operationally, the declarative components are treated integrating the stable model semantics used in answer set programming (ASP) <cit.>. This was a natural choice because process execution exhibits a prototypical `forward' nature, and ASP solvers can be interpreted as providing forward chaining.[Both SLD/SLDNF resolution (Prolog) and DPLL (ASP) are based on backward chaining. In DPLL, however, all variables are grounded, and all intermediate atoms generated in the search are collected in stable models; without defining any goal, all the worlds that are implied by the input knowledge are returned as output. From an external perspective, this is the same result we would associate with forward chaining. The intuition that there is a relation between ASP and forward chaining is confirmed e.g. in ASPeRiX <cit.>.]



§ FORMALIZATION


This section presents a simplified version of the LPPN notation considering only a propositional labeling. We start from the definition of propositional literals derived from ASP <cit.>, accounting for strong and default negation.	

 Given a set of propositional atoms A, the set of literals L = L^+∪ L^- consists of positive literals (atoms) L^+ = A, negative literals (negated atoms) L^- = { -a   |  a ∈ A},	where `-' stands for strong negation.[Strong negation is used to reify an explicitly false situation (e.g. “It does not rain”).] The set of extended literals  L^* = L ∪ L^ consists of literals and default negation literals L^ = { l |  l ∈ L }, where `' stands for default negation.[Default negation is used to reify a situation in which something cannot be retrieved/inferred (e.g. `It is unknown whether it rains or not').]


We denote the basic topology of a Petri net as a procedural net.

A procedural net is a bipartite directed graph connecting two finite sets of nodes, called places and transitions. It can be written as N = P, T, E, where P = {p_1, …, p_n} is the set of place nodes; T = {t_1, …, t_m} is the set of transition nodes; E = E^+ ∪ E^- is the set of arcs connecting them: E^+ from transitions to places, E^- from places to transitions.



LPPNs consists of three components: a procedural net specifying causal relationships, and two declarative nets specifying respectively logical dependencies at the level of objects or ongoing events (on places), and on impulse events (on transitions). Furthermore, propositional LPPNs build upon a boolean marking on places (like condition/event nets).



 A propositional Logic Programming Petri Net 𝐿𝑃𝑃𝑁_prop is a Petri Net whose places and transitions are labeled with literals, enriched with declarative nets of places and of transitions. It is defined by the following components:
	 
		
  * P, T, 𝑃𝐸 is a procedural net; 𝑃𝐸 stands for procedural edges;
		
  * C_P : P → L^* and C_T : T → L are labeling functions, associating literals respectively to places and to transitions;	
		
		
  * 𝑂𝑃 = {, -, ∧, ∨, →, ↔, …} is a set of logic operators.	
		
  * 𝐿𝑃 and 𝐿𝑇 are 
		sets of logic operator nodes respectively for places (lp-nodes) and for transitions (lt-nodes).
		
  * C_𝐿𝑃 : 𝐿𝑃→𝑂𝑃 maps each lp-node to a logic operator; similarly,  C_𝐿𝑇 : 𝐿𝑇→𝑂𝑃 does the same for lt-nodes.
		
  * 𝐷𝐸_𝐿𝑃 = 𝐷𝐸^+_𝐿𝑃∪𝐷𝐸^-_𝐿𝑃
		is the set of arcs connecting lp-nodes to places; similarly,  𝐷𝐸_𝐿𝑇 = 𝐷𝐸^+_𝐿𝑇∪𝐷𝐸^-_𝐿𝑇 for lt-nodes and transitions.[Note that  𝐷𝐸^-_𝐿𝑇⊆ (T ∪ P) ×𝐿𝑇, i.e. these edges go from transitions and places (modeling contextual conditions) to lt-nodes.]
		
		
							
		
  * M: P →{0, 1} returns the marking of a place, i.e. whether the place contains (1) or does not contain (0) a token.
	


Note that if 𝐿𝑃∪𝐿𝑇 = ∅, we have a strictly procedural 𝐿𝑃𝑃𝑁_prop, i.e. a standard binary Petri net. If T = ∅, we have a strictly declarative 𝐿𝑃𝑃𝑁_prop, that can be directly mapped to an ASP program.




















For simplicity, we overlook in this document the syntaxic constraints on the network topology which are inherited from ASP. 



§ SEMANTICS


This section will present two semantics for LPPNs: a hybrid operational semantics and a denotational semantics, based on ASP and event calculus.



 §.§ Hybrid operational semantics


The execution cycle of a LPPN consists of four steps: 


  * given a “source” marking M, the bindings of the declarative net of places entail a “ground” marking M^*; 

  * an enabled transition is selected to pre-fire, so determining a “source” transition-event e; 

  * the bindings of the declarative net of transitions entail all propagations of this event, obtaining a set of transition-events, also denoted as the “ground” event-marking E^*; 

  * all transition-events are fired, producing and consuming the relative tokens.

The steps (1) and (3) are processed in distinct moments by an ASP solver: the declarative nets of places (1) or of transitions (3) are translated as rules, tokens (1) or transition-events (3) are reified as facts. The ASP solver takes as input the resulting program and, if satisfiable, it provides as output respectively one or more ground marking (1) or one or more sets transition-events to be fired (3). 

The steps (2) and (4) make clear the distinction the external firings (the “source” transition-event selected at execution level) from the internal firing, immediately propagated (the “ground” transition-events triggered by the declarative net of transitions). 
The following definitions provides a formalisation of these concepts.









	A transition t is enabled in a ground marking M^* if a token is available for each input places: 
    𝐸𝑛𝑎𝑏𝑙𝑒𝑑(t) ≡∀ p_i ∈∙ t, M^*(p) = 1


Similarly to what marking is for places, we consider an event-marking for transitions E: T→{0, 1}. E(t) = 1 if the transition t produces a transition-event e. Each step s has a “source” event-marking E.
 An enabled transition t pre-fires (implicitly, at a step s) if it is selected to produce a transition-event: 
    ∀ t ∈𝐸𝑛𝑎𝑏𝑙𝑒𝑑(T) :
    	t  pre-fires≡ 
    	E(t) = 1


Applying an interleaving semantics for the pre-firing, the interpreter selects only one transition to pre-fire per step; for any other t', E(t') = 0.

 An enabled transition t fires (implicitly, at a step s) by propagation consuming a token from each input place, and producing a token in each output place:
	
    ∀ t ∈𝐸𝑛𝑎𝑏𝑙𝑒𝑑(T) :
    	t  fires≡
    
    	E^*(t) = 1 ↔∀ p_i ∈∙ t : M'(p_i) = 0  ∧ ∀ p_o ∈ t ∙: M'(p_o) = 1







  
Running example Let us consider the LPPN in Fig. <ref>. Here, for simplicity, we will conflate the names of the transition/places with their labels; in the general case this should be made different as there might be multiple nodes with the same label. The proposed net specifies causal mechanisms, declarative constraints. There is only one token in , enabling the transitions associated to  and . The following execution paths are possible: (1)  fires, consuming the token in ,  fires, consuming the token  and producing a token in ; (2, 3)  fires, and then one of  or  fires; (4)  fires, consuming the token in ; the firing propagates to ; the source firing of  also produces a token in ; the existence of  is a sufficient condition for immediately reifying .




 §.§ Denotational semantics


One of the possibilities to validate a formal language is to map it into another formal language, i.e. to provide a denotational semantics. The declarative component of a LPPN, by design, can be directly rewritten as ASP code. As we are already halfway down the path, we can translate the remaining procedural component into ASP.



  §.§.§ Event Calculus axioms


A well-known solution to treat change in logic programming is event calculus (EC) <cit.>. The simple version is already satisfactory for our purposes. A modification of the original axioms is necessary to deal with the locality brought by places and transitions:


holdsAt(F, P, N) :-
   initially(F, P), not clipped(0, F, P, N),
   fluent(F), place(P), time(N).

holdsAt(F, P, N2) :-
   firesAt(T, N1), N1 < N2,
   initiates(T, F, P, N1), not clipped(N1, F, P, N2),
   place(P), transition(T), fluent(F), time(N1), time(N2).

clipped(N1, F, P, N2) :-
   firesAt(T, N), N1 <= N, N < N2, 
   terminates(T, F, P, N),
   place(P), transition(T), fluent(F), time(N1), time(N2), time(N).




  §.§.§ Interleaved semantics axioms
The interleaved semantics can be translated into the following rules:
 

	
  * all enabled transitions may or may not pre-fire;
	
  * pre-firing is transformed to firing;
	
  * at least one enabled transition must pre-fire per step, i.e. it is impossible that no transition fire if there are enabled transitions; 
	
  * at maximum one transition can pre-fire per step.

In ASP code:

prefiresAt(T, N) :-                                    
   enabled(T, N), transition(T), time(N).

firesAt(e1, N) :- prefiresAt(e1, N).                     

someTransitionPrefiresAt(N) :-                           
   prefiresAt(T, N), transition(T), time(N).
:- not someTransitionPrefiresAt(N), enabled(T, N), transition(T), time(N).

:- prefiresAt(T1, N), prefiresAt(T2, N), T1 != T2,       
   transition(T1), transition(T2), time(N).




  §.§.§ Transformation of a LPPN to an ASP program

The mapping of a given LPPN to an equivalent ASP program includes the previous axioms and the output of the following steps:

 

	
  * for each place p, with label C_P(p) 
	
		
  * type it as place,
		
  * specify its initial state,
		
  * for each place with more than one output, write down that you cannot consume more than the only available token.
	
	
  * for each transition t, with label C_T(t)
	
		
  * type it as transition, 
		
  * define the conditions for which it is enabled,
		
  * for each output place, define how to create tokens in the output places,
		
  * for each input place, define how to consume tokens in the output places.
	
	
  * for each lp-node 𝑙𝑝,
	
		
  * specify the logic constraint to be applied between inputs and outputs.
	
	
  * for each lt-node 𝑙𝑡,
	
		
  * write down the logic dependencies between transitions allowing the propagation.
	


As a concrete example, we apply these actions on some of the components of the LPPN in Fig. <ref>:


fluent(filled).


place(c1).                                                          
initially(filled, c1).                                              
:- 2terminates(e2, filled, c1, N); terminates(e1, filled, c1, N). 


transition(e1).	                                                    
enabled(e1, N) :- holdsAt(filled, c1, N).                           
terminates(e1, filled, c1, N) :- firesAt(e1, N).                    
initiates(e1, filled, c2, N) :- firesAt(e1, N).                     


holdsAt(filled, c5, N) :- holdsAt(filled, c2, N).                   


firesAt(e3, N) :- firesAt(e1, N), enabled(e1, N).                   
              




  
Execution With the transformation steps given above, valid LPPNs can be transformed into ASP programs. In particular, for the axioms presented here, these programs can be solved the ASP engine  <cit.>, also available online at: <https://potassco.org/clingo/run/>. Setting a temporal range (with the instruction “”) the output answer sets represent all possible executions path after at most n steps. 



 

	







§ RESULTS

The proposal presented above has been used for developing a prototype Python application for specifying, executing and analyzing LPPNs[Available at <http://github.com/s1l3n0/pypneu>.]; it exploits  <cit.>, as this provide runtime interfaces enabling a direct control of the solver instance without regrounding the program at each cycle. 
This enabled us to perform some direct evaluation of any given LPPN input.

When we process the input LPPN by means of the denotational semantics, the input is transformed to an ASP program, and the solver intervenes fully to provide the possible execution paths. Instead, when we refer to the hybrid operational semantics, the solver intervenes only partially in the execution cycle, to entail the constraints implied by the declarative components of the net; the rest of the computational burden is on the module responsible for the Petri net execution. In this context, one might ask if we can observe some performances between these two alternative modes of analysis/execution.

At the moment, we have only evaluated a propositional version of LPPN, and a limited series of structures, namely compositions of minimal serial elements (a transition with an input and output places) or minimal forking elements (a place with two output transitions). In order to implement the procedural component of the operational semantics, the current Petri Net analysis module builds upon a simple brute force (BF) execution algorithm, and depth-first search with backtracking (BT) to cover all the possible execution paths. 

Table <ref> summarises the performances of 10 executions of different network configurations.[The tests were run on a MacBook Pro (2018) provided with a 2.2 GHz 6-core processor Intel Code i7 and 16Gb RAM DDR4.] Results are also illustrated on Fig. <ref>. The data essentially confirms our hypothesis: the analysis based on the operational semantics (BF+BT) clearly outperforms and scales excellently for the serial configurations, while that based on the denotational semantics (EC) scales poorly in this configuration. For the forking configurations, BF+BT is evidently slower in absolute terms. Intuitively this is due to the efficient search and pruning capabilities of ASP. Unlike clingo, the Python code of the Petri net executor/analyzer is not optimised; on the contrary, for many aspects this represents a lower-bound on the possible implementation choices. Nevertheless, if we consider execution times in logarithmic scale, we observe that the two methods are essentially comparable in terms of tractability.



§ CONCLUSION


The paper presents an empirical experiment with LPPNs, a logic programming-based extension to Petri Nets. LPPNs were introduced with a practical goal in mind: a visual modelling notation relatively simple for non-experts, that could handle explicit declarative knowledge, and that could model causation and other procedural aspects <cit.>. It was inspired by the point made in <cit.> on the widespread confusion in cognitive science and computational disciplines around the notion of rules (namely between declarative and reactive rules). Previous contributions <cit.> highlighted the potential use of LPPNs in normative modelling tasks in combination with business process modelling, thus potentially facilitating cross-fertilization between theoretical to practical settings. 




Here the focus has been put on its computational properties, showing that maintaining the two levels separated can bring better performances. The declarative dimension allows to treat at higher abstraction phenomena for which there is a viable specification at outcome level. The procedural dimension works better for processes that can be directly executed. 



Future developments concern the extension of this work to a wider range of experiments, first considering mixed networks (of declarative, procedural components) with mixed configurations (serial compositions, forks, joins, etc.) and then passing to the extended LPPN notation accounting for predicates. The actual impact on real models should be evaluated as well: scenarios describing cases have very few forks, they rather function as orchestrated (i.e. directed from the scenario) scripts (procedural models distributed amongst actors). Consequently, applications that require the use of scenarios (e.g. for interpretation, model-based diagnosis, conformance checking, etc.) may take advantage of the hybrid operational semantics. The computational improvement may be further extended considering existing proposals in the literature. For instance, execution algorithms alternative to brute execution <cit.>; or decomposition techniques, for instance in single-entry-single-exit (SESE) components <cit.>, that open up the possibility of concurrent execution. 

Further, these results should be confronted with existing techniques for handling temporal reasoning and causality, e.g. the already cited Action languages <cit.>, related works (e.g. F2LP <cit.>) and applications (CCalc, Coala, Cplus2ASP); optimized versions of Event Calculus (e.g. <cit.>); applications based on LTL, CTL and related formalisms. 



splncs03 
 



