Online Fault Diagnosis of Labeled Petri Nets Based on Reachability Graphs and Topological Sorting

In this article, we propose an online fault diagnosis approach for labeled Petri nets. When observing an event, the reachability graph of the unobservable subnet (i.e., the net consisting of all places, unobservable transitions, and the attached arcs between them) is first constructed and then a topological sort (i.e., an ordered list of markings) of the reachability graph is obtained. According to the topological sort, each marking in the reachability graph is associated with a vector that contains diagnosis information to form a new graph, called a diagnosis graph. Based on the diagnosis graph constructed for each observed event, an online algorithm is developed to perform diagnosis. When the considered Petri net systems have a small amount of unobservable transitions, the proposed approach enjoys a high computational efficiency compared with the existing ones using integer linear programming.


I. INTRODUCTION
In recent decades, due to the rapid development of technology, large and complex systems are emerging in large numbers, which can be viewed as discrete event systems (DES) [1] at a certain level of abstraction. Fault diagnosis aims to ensure the safe and stable operation of these systems by isolating and repairing faults as soon as possible. Petri nets, as a typical model of DES, have been widely used in performance optimization [2]- [6], big data [7], [8] and supervisory control [9]- [14] because of their distributed nature and well-developed structural analysis techniques. In this article, we address the issue of fault diagnosis using Petri nets.
In the context of DES, the problem of fault diagnosis is originally defined and solved based on automata [15], where faults are modeled as unobservable events and a diagnoser is constructed off-line to perform online diagnosis. A reader is referred to [16]- [18] for a detailed discussion of automaton-based supervisory control and fault diagnosis.Unlike an automaton model whose states are explicitly The associate editor coordinating the review of this manuscript and approving it for publication was Shouguang Wang . represented, a Petri net has a compact structure and its state set is implicitly characterized by a linear equation, called a state equation. Consequently, in the automatic control community, many methodologies based on Petri nets are reported, which do not require the explicit enumeration of all states [19]- [23].
In [24], the faults are modeled as unobservable transitions and are identified by solving an integer linear programming (ILP) problem built according to the given fault-free Petri net and an observed Petri net language. In this study, faulty transitions representing the possible faults are not included in the given fault-free Petri net. Due to the existing of faults, the observed language possibly cannot be generated by the fault-free net. The problem of fault diagnosis is solved by adding unobservable transitions (i.e., identified faults) into the fault-free net such that the resulting Petri net generates the observed language. The study [25] extends the work [24] by assuming that some additional places are observable, where the observed output is a marking-transition sequence. Due to the introduction of observable places, a better estimation on faults can be obtained in contrast to the approach in [24]. VOLUME 8, 2020 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ On the other hand, there is a deluge of diagnosis approaches that address the diagnosis issue by assuming that faulty transitions are explicitly included in the given Petri net model of a plant and fault diagnosis focuses on inferring the occurrences of faulty transitions based on an observed transition sequence. Basile et al. [26] define the notion of g-markings (i.e., markings in which the number of tokens can be a negative integer) and propose an online diagnosis approach based on g-markings and integer linear programming.
In [27], a diagnosis approach based on integer linear programming is reported, where an ILP model is constructed on the basis of the observed transition sequence. The diagnosis results are derived by assigning different objective functions to the ILP model and solving it. This approach is extended to the case of labeled Petri nets in [28]. Cabasino et al. [29] introduce the notion of basis markings and propose a diagnosis approach by constructing the basis reachability graph (BRG) of a net, which is a compact characterization of the reachability graph. This approach is applicable to bounded nets and is extended to labeled Petri nets in [30].
Ru and Hadjicostis [31] deal with the diagnosis problem using partially observed Petri nets (POPNs). They prove the equivalence of POPNs and labeled Petri nets in the sense of fault diagnosis and solve the diagnosis problem by constructing the reachability graph of a Petri net. This approach does not require to solve ILP problems due to the construction of the reachability graph. However, the dependency issue raised when computing the diagnosis information associated with each marking in the reachability graph is not addressed. This article improves the approach from three aspects: (1) the dependency issue between markings in the reachability graph is solved by computing a topological sort of the reachability graph, (2) the advantages and applicability of reachabilitygraph-based approaches are discussed, and (3) an online diagnosis algorithm based on topological sorting is proposed.
To avoid enumerating the whole reachability set of a Petri net, multiple approaches above-mentioned [25]- [30] solve the fault diagnosis problem using ILP technique. The size of the ILP model constructed in [25]- [28] is closely related to the number of places and the length of an observation, which increases linearly as the length of the observation increases. Moreover, given an observation (i.e., an event sequence) of a labeled Petri net, there may exist a huge number of transition sequences whose firings generate the observation, which implies that a large number of ILP models require to be solved to perform diagnosis (see Section V for an example).
Enumerating the reachability set of a net is of exponential complexity and it may be computationally prohibitive for a large-size net. However, in this article, we only compute the reachability set of the unobservable subnet (i.e., the net consisting of all places, unobservable transitions, and attached arcs between them) of a Petri net. If the considered Petri net contains a small amount of unobservable transitions, the size of the unobservable subnet is also small and the proposed approach based on the enumeration of reachability set of the unobservable subnet is significantly efficient in contrast to the ILP-based ones (since the size of the ILP models and the number of times of solving these ILP models in ILP-based approaches [26]- [28] are possibly considerably large even if the number of unobservable transitions is small, as illustrated by the example shown in Section V).
More specifically, we assume that the unobservable subnet of a Petri net is acyclic and has no source transitions (i.e., transitions that have no input place) such that the reachability graph of the unobservable subnet is acyclic and has finite nodes. By associating each marking in the reachability graph of the unobservable subnet with a row vector containing diagnosis information (called a diagnosis vector), a new graph called a diagnosis graph is defined. When observing an event of a labeled Petri net, the corresponding diagnosis graph is first constructed and then diagnosis vectors are updated according to a topological sort of the graph. We propose an online diagnosis algorithm that performs diagnosis based on the diagnosis graph constructed at each step.
This article is organized as follows. Section II presents basic definitions used throughout the paper as well as some preliminary results. In Section III, the problem to be solved is formally defined. Then, in Section IV, we define the notion of diagnosis graph and present an online diagnosis algorithm. In Section V, we compare the computational efficiency of the proposed approach with an ILP-based one by considering a labeled Petri net example. Finally, the conclusion is drawn in Section VI.

II. PRELIMINARY
This section recalls basic concepts of Petri nets and some preliminary results. For more details on Petri nets, the reader is referred to [1], [32].

A. BASICS OF PETRI NETS
A Petri net is a four-tuple N = (P, T , Pre, Post), where P = {p 1 , . . . , p m } is the set of places with cardinality m, T = {t 1 , . . . , t n } is the set of transitions with cardinality n, Pre : P × T → N 1 and Post : P × T → N are the pre-and post-incidence matrices, respectively, which specify the arcs of the net. Pictorially, places and transitions are represented by circles and bars, respectively. The incidence matrix of a net is denoted by For a transition t ∈ T , its preset (the set of input places) is defined as • t = {p ∈ P | Pre(p, t) > 0}, and its postset (the set of output places) is defined as t • = {p ∈ P | Post(p, t) > 0}. Analogously, we define the preset and postset of a place p ∈ P as • p = {t ∈ T | Post(p, t) > 0} and p • = {t ∈ T | Pre(p, t) > 0}, respectively. A transition t ∈ T is called a source transition if it has no input place, i.e., • t = ∅.
A directed cycle of net N is represented as τ 1 . . . τ r , where τ i ∈ P ∪ T for i = 1 . . . r, τ i ∈ τ • i−1 for i = 2 . . . r, and τ 1 = τ r . Clearly, a self-loop is the simplest form of a directed 1 N is the set of non-negative integers. cycle. A Petri net is said to be acyclic if it has no directed cycle.
A marking of a Petri net is a mapping M : P → N that assigns to each place a non-negative integer, denoted by M (p), representing the number of tokens in the place. Graphically, a token is usually denoted by a black dot. For economy of space, we write α 1 p 1 + α 2 p 2 + · · · + α m p m to represent a marking [α 1 α 2 · · · α m ] T . By associating an initial marking M 0 with a net N , we obtain a Petri net system, denoted as N , M 0 .
A transition t ∈ T is said to be enabled at marking M if there are sufficient tokens in its input places, i.e., ∀p ∈ A transition sequence The final marking M h is said to be reachable from M by firing σ , denoted as M [σ M h . We write t ∈ σ to represent that t is a transition contained in transition sequence σ . The reachability set of Petri net system N , M 0 , denoted by R(N , M 0 ), is the set of all markings reachable from M 0 . The language of Petri net N is the set of transition sequences that are enabled from M 0 , formally defined by Given a transition sequence σ ∈ T * , we define a function π : T * → N n to compute the number of occurrences of transition t ∈ T in σ such that y = π (σ ) and y(t) = h if t is contained h times in σ . A marking M that is reachable from M 0 by firing a sequence σ ∈ T * , i.e., M 0 [σ M , can be computed by the following state equation: which provides a linear algebraic characterization of the state space of a net system. A Petri net system N , M 0 is said to be bounded if there exists a positive integer K such that M (p) ≤ K for all p ∈ P and all M ∈ R(N , M 0 ). If a Petri net system is bounded for any initial marking M 0 , then we say that it is structurally bounded.
Due to the absence of sensors, the firings of some transitions cannot be observed. Thus, the transition set is partitioned into two disjoint subsets T o and T u with T = T o ∪ T u , where T o denotes the set of observable transitions with cardinality n o and T u is the set of unobservable transitions with cardinality n u .
In a Petri net for fault diagnosis, a fault is often characterized by an unobservable transition, called faulty transition (an observable fault can be readily detected). Meanwhile, there also exist some regular unobservable transitions. As a result, the unobservable transition set T u is further divided into the set T f of faulty transitions with n f = |T f | 2 and the set T reg of regular unobservable transitions with n reg = |T reg |, 2 The symbol | · | stands for the cardinality of a set.
i.e., T u = T f ∪ T reg . Obviously, it holds n = n o + n u = n o + n f + n reg .
Definition 1: Given a subset of transitions T ⊆ T , the Tinduced subnet of a net N = (P, T , Pre, Post) is a net denoted as N = (P, T , Pre , Post ), where Pre and Post are the restrictions of Pre and Post to P×T , respectively, i.e., the net N consists of places in P, transitions in T , and the associated arcs between them.

B. LABELED PETRI NET
In a real-world system, because of financial or technical reasons, a sensor is usually used to monitor two or more system events whose occurrences have the same output. To model such a situation, we assign to each transition a label by defining a labeling function : T → E ∪ {ε}, where E is the given event set and ε stands for an empty string. An unobservable transition t ∈ T u is associated with a label ε and thus we have T u = {t ∈ T | (t) = ε}. At the same time, we assign an observable transition t ∈ T o a label from set E and have T o = {t ∈ T | (t) ∈ E}. Note that two or more observable transitions may have the same label. The set of transitions that are assigned a label e ∈ E is denoted by A labeled Petri net system N , M 0 , E, is a Petri net system N , M 0 that is associated with a labeling function : T → E ∪ {ε}. We point out that the class of Petri nets can be viewed as a special subclass of labeled Petri nets by assuming E = T o and assigning each observable transition The labeling function can be extended to a sequence . . t h with h being a positive integer. Clearly, for a sequence σ ∈ T * , the sequence ω = (σ ) consists of the labels of all observable transitions in σ and is called an observed word. Given a labeled net system N , M 0 , E, , we use to denote the set of its observed words. Given an observed as the set of consistent transition sequences with ω. In plain terms, the set (ω) contains all transition sequences δ's in L(N , M 0 ) such that ω = (δ) and the last transition of δ is observable.

C. TOPOLOGICAL SORTING
exists a directed arc from v 1 to v 2 . An acyclic directed graph is a directed graph not containing directed cycles. ♦ Definition 3: A topological sort of an acyclic directed graph G = (V, E) is a linear ordering of V such that for each directed edge (v 1 , v 2 ) ∈ E, v 1 comes before v 2 in the linear ordering.
♦ Originally, topological sorting is used to schedule a sequence of jobs based on their dependencies such that some jobs must be completed before a specific one. In this article, each marking in the reachability graph of the unobservable subnet is associated with a vector including diagnosis information, which is computed based on a topological sort of the reachability graph. One of algorithms for topological sorting is proposed by Kahn [33]. To make the paper self-contained, we show Kahn's algorithm as follows. Delete θ and all edges attached to θ from G; 6 until cannot find a vertex with no input arc; 7 Output a topological sort O; According to Algorithm 1, the topological sort of an acyclic directed graph is not unique. For example, the reachability graph shown in Figure 1 is obviously an acyclic directed graph and its two topological

III. PROBLEM STATEMENT
Fault diagnosis aims to detect and isolate fault events occurring in a system as soon as possible according to the output of the system. In the context of labeled Petri nets, fault events are usually modeled as faulty transitions (i.e., T f ) and the output is characterized in terms of event sequence, i.e., an observed word ω ∈ E * .
A faulty transition t f ∈ T f has three possible diagnosis decisions when observing an event e ∈ E, represented as N , U , and F, meaning that t f does not occur, t f may have occurred, and t f necessarily have occurred, respectively. The key point of fault diagnosis consists in inferring the diagnosis decision of t f based on the output ω of a Petri net system. Formally, the diagnosis result is described by a function, as defined as follows.
Definition 4: The diagnosis function : i.e., one of the consistent sequences contains t f and the other does not.
♦ Before formally defining the diagnosis problem to be solved, we discuss the assumptions made in this article. The following assumptions are adopted: (A1) The unobservable subnet is acyclic.
(A2) The unobservable subnet has no source transitions. Assumption (A1) is usually made in the literature [24]- [30] for fault diagnosis to avoid the situation that a system runs in a cycle containing unobservable transitions only (no output is observed in such a case). We make Assumptions (A1) and (A2) to ensure that the reachability graph of the unobservable subnet is acyclic and has finite nodes such that its topological sort can be obtained.
Problem 1 (Online Diagnosis): Consider a labeled Petri net system N , M 0 , E, satisfying Assumptions (A1) and (A2) and let the observed word be null initially, i.e., ω = ε. When observing an event e ∈ E, ω is updated by ω = ωe and the problem consists in computing (ω, t f ) for all t f ∈ T f .

IV. MAIN RESULTS
Before defining some new notations for the formal presentation of the approach, we formalize a proposition to prove that the reachability graph of an acyclic net is also acyclic such that a topological sort of the reachability graph is possible.
Proposition 1: If a Petri net is acyclic and has no source transitions, then the Petri net is bounded and there is no directed cycle in its reachability graph.
Proof: The conclusion that the Petri net is bounded can be directly derived from Proposition 3 of [34]. We next prove, by contradiction, that there is no directed cycle in its reachability graph.
Suppose that the net is acyclic and there is a directed cycle in its reachability graph. If the cycle contains only one transition named t 1 (i.e., there exists a marking M ∈ R(N , M 0 ) such that M [t 1 M ), a part of the net can be simplified as Figure 2(a1). The tokens ''consuming'' by the firing of t 1 must be recovered by t 1 (since the cycle contains only one transition). Thus, there must exist a directed cycle p 1 t 1 p 1 in the net that is illustrated by Figure 2(a2). This contradicts the assumption that the net is acyclic. If the cycle contains two transitions, named t 1 and t 2 respectively, a part of the net can be simplified as Figure 2(b1). To avoid forming a selfloop, the tokens in p 1 are necessarily recovered by t 2 and the tokens in p 2 are recovered by t 1 , which is illustrated by Figure 2(b2). Obviously, there is a directed cycle p 1 t 1 p 2 t 2 p 1 in the net, which contradicts the assumption. This contradiction is readily verified when the cycle contains more than two transitions and thus we prove the conclusion.
Definition 5: Given a Petri net system N , M 0 , a diagnosis couple is a couple (M , k), where M ∈ R(N , M 0 ) is a marking and k ∈ N n f +1 is an (n f +1) dimensional row vector, called a diagnosis vector, such that ♦ Note that we write k(t f ) to denote the entry corresponding to fault transition t f in k, and k(n f + 1) to denote the last entry of k. In plain terms, the first n f entries of k denote the number of paths from M 0 to M that pass the according fault transition in the reachability graph and the entry k(n f + 1) stands for the number of all paths from M 0 to M . The set X (ω) is not straightforward and is usually not trivial to obtain in a labeled Petri net. However, we show that it can be computed recursively in an acyclic net without source transitions by developing an algorithm (see Algorithm 2). By associating each marking with an (n f + 1) dimensional vector in the reachability graph of the net in Figure 3(a), we obtain a new graph, called a diagnosis graph, as shown in Figure 3(b). The marking M i in each vertex (M i , k i ) with i ∈ {0, 1, . . . , 7} can be trivially computed by Equation (1) and is not shown in the figure for simplicity. According to Definition 5, the vector k i in each diagnosis couple (M i , k i ) is computed. Note that the vector k 0 associating with the initial marking M 0 is set to [0 1] by default. In node (M 2 , k 2 ), k 2 = [0 1] means that there exists one (indicated by 1 in [0 1]) path (i.e., t 1 t 2 ) from M 0 to M 2 and there is zero (indicated by 0 in [0 1]) path between them that passes the faulty transition t 3 . On the other hand, k 6 = [3 3] in (M 6 , k 6 ) implies that there are three possible paths from M 0 to M 6 (i.e., t 1 t 2 t 3 t 5 , t 1 t 3 t 2 t 5 , and t 1 t 3 t 5 t 2 ) and all these three paths contain a faulty transition t 3 .
Assume that the observed word is ω = a. By Definition 6, it is easy to verify that the diagnosis group corresponding to ω is X (a) = {(M 1 , k 1 )} by inspecting as the sum of all k's in X (ω). According to set X (ω), the diagnosis result can be directly obtained, as shown in the following theorem.
Theorem 1: Given an observed word ω ∈ L E (N , M 0 ) in a labeled Petri net N , M 0 , E, , for each t f ∈ T f , the following statements hold Proof: According to Definition 5, the last entry of k, i.e., k(n f + 1), in a diagnosis couple (M , k) represents the number of transition sequences σ 's satisfying M 0 [σ M . Moreover, the set X (ω) contains all diagnosis couples (M , k)'s whose markings M 's are reachable from M 0 by firing consistent transition sequences with ω. Thus,k(n f + 1) stands for the number of transition sequences consistent with ω andk(t f ) represents the number of consistent transition sequences passing t f . The conditionk(t f ) = 0 implies for all σ ∈ (ω), t f / ∈ σ , and thus (ω, t f ) = N by Definition 4. The conditionk(t f ) =k(n f + 1) means that the numbers of consistent transition sequences and consistent transition sequences passing t f are equal, i.e., for all σ ∈ (ω), t f ∈ σ . Thus we have (ω, t f ) = F by Definition 4. Conclusion (3) is readily proved according to the similar reasoning.
To conveniently describe the proposed algorithm, we give the definition of diagnosis graph. By regarding a diagnosis couple (M , k) as a node of a graph, a diagnosis graph is defined as following.
Definition 7: A diagnosis graph is an acyclic directed graph G = (V, E, W ), where V is the set of vertices, i.e., the set of diagnosis couple (M , k)'s, E ⊆ V × V is the set of edges such that ((M 1 , k 1 ), (M 2 , k 2 )) ∈ E if there is a directed arc from vertex (M 1 , k 1 ) to (M 2 , k 2 ), and W : V × V → T is a mapping that associates a transition t ∈ T with an edge. ♦ The successors of a vertex v ∈ V in a diagnosis graph is defined as The topological sort of a diagnosis graph G is represented by O = toposort(G). The reader is referred to Subsection II-C for the algorithm of topological sorting (i.e., Algorithm 1).
Example 2: Figure 3(b) is an example of a diagnosis graph. We observe that suc ((M 1 , k 1 One of the topological sorts of Figure 3 =k(n f + 1), we have (ω, t 3 ) = F by Theorem 1.
♦ For a labeled Petri net satisfying Assumptions (A1) and (A2), when observing an event e ∈ E, a diagnosis graph is constructed by enumerating the transition sequences enabled in the unobservable subnet. Then, the diagnosis group X (ω) is computed based on the diagnosis graph and the diagnosis results for each step are obtained by Theorem 1. The detailed diagnosis procedure is shown by Algorithm 2.

Algorithm 2: Online Diagnosis Using Diagnosis Graphs and Topological Sorting
Input: A labeled net system N , M 0 , E, satisfying Assumptions (A1) and (A2) Output: Diagnosis results for each observed event e 1 ω = ε, R = 0 n f ; 14 Build the diagnosis graph G = (V , E, W ); 15 Obtain its topological sort O = toposort(G); 16 for eachṽ ∈ O from head to tail do 17 Find the vertex v corresponding toṽ in G, represented as v = (M , k); 18 Obtain the successors suc if t ∈ T f then / * Case I * / At the beginning of this algorithm, the diagnosis graph has only one node (M 0 , k 0 ) (see the variable X in Line 2) and k 0 is initialized as [ 0 1×n f , 1]. Meanwhile, the default diagnosis vector attached to each marking is defined as a vector of zeros in Line 2, i.e., v 0 = 0 1×(n f +1) . Since the unobservable subnet is acyclic and has no source transitions, the while loop in Line 5 is ensured to terminate. Note that the diagnosis decisions for n f faulty transitions are represented by a row vector R such that, for In summary, the flow of Algorithm 2 can be broken into four steps: Step 1: Build the diagnosis graph corresponding to the current observed event (Lines 5-14); Step 2: Obtain the topological sort of the diagnosis graph (Line 15); Step 3: Update k of each vertex (M , k) in the diagnosis graph according to the topological sort (from Line 16 to 30); Step 4: Build the diagnosis group X and make a diagnosis (from Line 31 to 49).
We next explain these four steps in detail. In Step 1, we construct the reachability graph of the unobservable subnet and associate each marking with a diagnosis vector of zeros, i.e., v 0 (except the initial marking M 0 that is associated with k 0 to constitute the first vertex (M 0 , k 0 ) considered when updating the diagnosis vector in Step 3). In the following example, we visualize the diagnosis graph constructed in Step 1. In Step 3, we update each diagnosis vector of zeros in the diagnosis graph built in Step 1. However, diagnosis vectors necessarily are updated in a specific order (i.e., each diagnosis vector in a vertex should be updated before all its successors), otherwise they possibly do not satisfy Definition 5. A topological sort of the diagnosis graph built in Step 1 is ideally suited to form such a specific order.
In Step 3, for each elementṽ from head to tail in a topological sort (see Line 16), the vertex v corresponding toṽ in the diagnosis graph G possibly has been updated. Thus, we first find the corresponding vertex v = (M , k) in G in Line 17 and then update all successors of v. When updating each successor (M , k ) of v, there are four cases based on the original value k and the transition t between (M , k) and (M , k ): Case I: k = v 0 and t ∈ T f (i.e., Line 22); Case II: k = v 0 and t / ∈ T f (i.e., Line 24); Case III: k = v 0 and t ∈ T f (i.e., Line 27); Case IV: k = v 0 and t / ∈ T f (i.e., Line 29). In Cases I and II, the condition k = v 0 means that the vertex (M , k ) has not been updated. If t ∈ T f , we update k by setting k = k and k (t) = k (n f + 1). The assignment statement k (t) = k (n f + 1) means that from M 0 to M , all paths pass the faulty transition t since the last transition in all paths is t ∈ T f . Otherwise, if t / ∈ T f (i.e., Case II), we simply update k by setting k = k according to Definition 5. In Cases III and IV, the condition k = v 0 implies that the diagnosis vector k in (M , k ) has been updated and further updates will be performed. If t / ∈ T f (i.e., Case IV), the update k = k + k (i.e., for a transition t f ∈ T f , the update is k (t f ) = k (t f ) + k(t f )) means that there are k(t f ) additional paths from M 0 to M that contain t f and go through the marking M in (M , k). If t ∈ T f (i.e., Case III), we first set k = k + k for all faulty transitions in T f \{t} and then update k (t) by k (t) = k (t) + k(n f + 1). The equation k (t) = k (t) + k(n f + 1) means that there are k(n f + 1) additional paths from M 0 to M that pass the marking M as well as the last faulty transition t. In Step 4, to obtain the diagnosis group X , we inspect each vertex (M , k) of the diagnosis graph G to decide if an observable transition t labeled e (i.e., t ∈ T e ) is enabled at M (see Lines 32 and 33), where e is the event observed at the current step. If t is enabled at M , a new diagnosis couple (M , k) withM = M + C(·, t) is obtained and stored into X . Note that if the set X has contained an element (M ,k) witĥ M =M , then the new diagnosis couple (M , k) will not be stored and the existing element (M ,k) is updated byk =k +k in Line 37. The unobservable subnet is acyclic and has no source transitions. Suppose that the observed word ω = ab. Two diagnosis graphs are generated for two observed events (i.e., a and b) respectively by Algorithm 2, as shown in Figure 5.
Specifically, when w = a, the corresponding diagnosis graph G a is first constructed according to Step 1 of Algorithm 2, as illustrated by Figure 5(a), where v 0 is a diagnosis vector of zeros implying that the diagnosis vector in each vertex has not been updated. The topological sort Then, according to Step 3, G a is updated and illustrated by the unobservable part of Figure 5(b), i.e., a subgraph consisting of edges labeled unobservable transitions (pictorially depicted by dashed lines) and the attached vertices. By inspecting each vertex of G a , we find that t 4 with label a is enabled at vertices (M 2 , k 2 ), (M 3 , k 3 ), (M 5 , k 5 ) and (M 7 , k 7 ). Finally, according to Step 4, we obtain the diagnosis group X (a) = {(M 8 , k 8 ), (M 9 , k 9 ), (M 10 , k 10 ), (M 11 , k 11 )}. By Theorem 1, it is readily verified that (a, t 3 ) = U . For ω = ab, the corresponding diagnosis graph G ab is shown in the unobservable part of Figure 5(c). In Figure 5(c), we observe that the corresponding VOLUME 8, 2020  Proof: We prove this theorem by induction. (basis step) If the observed word ω is an empty string (i.e., ω = ε), the corresponding diagnosis graph has only one node (M 0 , k 0 ) with k 0 = [ 0 1×n f , 1]. According to Theorem 1, the diagnosis decision for each faulty transition t f ∈ T f is (ω, t f ) = N . On the other hand, for ω = ε, the set of consistent transition sequences with ω is empty, i.e., (ω) = ∅. Thus, by Definition 4, we have (ω, t f ) = N for each t f ∈ T f . This coincides with the diagnosis result obtained by applying Theorem 1, which implies the correctness of Algorithm 2 for ω = ε.
(inductive step) Assuming that Algorithm 2 provides a correct solution to Problem 1 for an observed word ω ∈ E * , we next prove that it holds for the observed word ωe, where e is an observed event after ω. When observing a new event e (see Line 3), the objective of Algorithm 2 is to compute the diagnosis group X (we). To achieve the objective, the diagnosis graph G e for the new event e is assigned to contain all elements in X (w) as the set of vertices at first (see V = X in Line 4). Assumptions (A1) and (A2) ensure that Step 1 of Algorithm 2 can terminate. After Step 1, the diagnosis graph G e with default diagnosis vector v 0 in each vertex (except (M 0 , k 0 )) is obtained, which is acyclic and has finite nodes. Thus, we can obtain a topological sort of G e and update all diagnosis vectors in G e according to Cases I, II, III and IV such that each vertex of G e satisfies Definition 5. According to the definition of symbol (ωe) in Definition 4 (i.e., the last transition is observable), we need to check if an observable transition t labeled e is enabled at each vertex of G e . If t is enabled at a vertex (M , k), the reached diagnosis couple (M , k) withM = M + C(·, t) is stored into X (we) (see Line 39). After checking each vertex of G e , we obtain the diagnosis group X (we) (see Lines 31-39). Then, by Theorem 1, the diagnosis decision (ωe, t f ) of each faulty transition t f ∈ T f is trivially concluded.

V. NUMERICAL EXAMPLE
In this section, we discuss the computational efficiency of the proposed approach by means of a labeled Petri net shown in Figure 6, which is originally presented in [35] and is slightly modified by using different labeling function and initial marking herein. Obviously, the net shown in Figure 6 satisfies Assumptions (A1) and (A2). Moreover, we have M 0 = 3p 1 + 10p 9 + 10p 13 , T u = {t 1 , t 2 , t 8 , t 10 , t 16 }, and T f = {t 8 , t 10 }. The labeling function of the net is represented as T a = {t 3 , t 6 , t 11 , t 14 }, T b = {t 4 , t 7 , t 12 , t 15 }, T c = {t 9 , t 13 , t 17 }, and T d = {t 5 }.
One of typical ILP-based diagnosis approaches for labeled Petri nets is proposed in [28]. The main drawback of the approach is the possibility of solving considerably large number of ILP problems even if the size of the considered net is small. For example, if an observed word of the net shown in Figure 6 is an event sequence of length 30 ω = abcabddababccabcababdcaabcabca, then there exist 59966 possible observable transition sequences whose firings generate the observed word ω (one of which is t 14 t 15 t 17 t 3 t 4 t 5 t 5 t 14 t 15 t 14 t 15 t 17 t 17 t 14 t 15 t 17 t 14 t 15 t 14 t 15 t 5 t 17 t 14 t 14 t 15 t 17 t 6 t 7 t 9 t 3 ). To perform diagnosis when observing the thirtieth event (i.e., 'a') of ω, 383981 ILP problems require to be solved according to the Diagnoser Algorithm shown in Figure 3 of [28]. In such a case, the main   computational cost stems from the solutions of 383981 ILP problems, resulting in a low computational efficiency.
Different from the approaches using integer linear programming, the proposed approach only constructs the reachability graph (which necessarily has finite nodes by Proposition 1) of the unobservable subnet to perform diagnosis. In Figure 6, the numbers of tokens in the initial marking are not so big and the structure of the unobservable subnet is small. The reachability graph of the unobservable subnet has relatively small number of markings. Thus, for the labeled net in Figure 6, the proposed approach enjoys a high computational efficiency in contrast to the one in [28], as shown in the following comparisons.
For the observed word ω above-mentioned, we perform fault diagnosis using the proposed approaches and the one in [28] and the comparisons are shown in Tables 1, 2, and 3. In these tables, the row ''index'' denotes the index of each event in ω. The rows ''time I (s)'', ''time II (s)'', ''RG size'' and ''ILP solving'' denote the running time of our approach (i.e., Algorithm 2), the running time of the approach in [28], the number of nodes in the reachability graph of the unobservable subnet, and the number of solving ILP problems in [28], respectively, for each observed event. The running time is tested on a computer with Intel i7-7700 processor and the ILP problems are solved using GUROBI solver.
We observe that these two approaches have similar computational performance in the first 12 observed events since the observed word is very short. However, the number of solving ILP problems in [28] increases very rapidly (see ''ILP solving'' row) as the length of the observed word increases but the number of markings in the constructed reachability graph for each observed event increases slowly (see ''RG size'' row). In such a case, the proposed approach is more efficient. Meanwhile, we point out that the proposed approach is not always more efficient than the one in [28]. For example, if the initial marking is M 0 = 30p 1 +50p 9 +50p 13 , the reachability graph of the unobservable subnet is significantly large and our approach is less efficient than the one in [28]. As far as we know, there does not exist a diagnosis approach that is most efficient for all cases in contrast to the other ones. The users are responsible to select a more suitable approach according to the concrete system settings. The proposed approach is more suitable to Petri net systems where the proportion of unobservable transitions is relatively small.

VI. CONCLUSION
The paper addresses the problem of fault diagnosis of labeled Petri nets. The main contributions are the application of topological sorting to update the diagnosis vectors and an online diagnosis algorithm based on diagnosis graphs. The proposed approach is more appropriate to Petri net systems with a small VOLUME 8, 2020 number of unobservable transitions. In future works, we plan to extend this approach to the case of timed Petri nets.