<?xml-model href='http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng' schematypens='http://relaxng.org/ns/structure/1.0'?><TEI xmlns="http://www.tei-c.org/ns/1.0">
	<teiHeader>
		<fileDesc>
			<titleStmt><title level='a'>Weighted Transducers for Robustness Verification</title></titleStmt>
			<publicationStmt>
				<publisher></publisher>
				<date>2020 August</date>
			</publicationStmt>
			<sourceDesc>
				<bibl> 
					<idno type="par_id">10193725</idno>
					<idno type="doi"></idno>
					<title level='j'>Leibniz international proceedings in informatics</title>
<idno>1868-8969</idno>
<biblScope unit="volume">171</biblScope>
<biblScope unit="issue"></biblScope>					

					<author>Emmanuel Filiot</author><author>Nicolas Mazzocchi</author><author>Jean-François Raskin</author><author>Sriram Sankaranarayanan</author><author>Ashutosh Trivedi</author>
				</bibl>
			</sourceDesc>
		</fileDesc>
		<profileDesc>
			<abstract><ab><![CDATA[Automata theory provides us with fundamental notions such as languages, membership, emptiness and inclusion that in turn allow us to specify and verify properties of reactive systems in a useful manner. However, these notions all yield "yes"/"no" answers that sometimes fall short of being satisfactory answers when the models being analyzed are imperfect, and the observations made are prone to errors. To address this issue, a common engineering approach is not just to verify that a system satisfies a property, but whether it does so robustly. We present notions of robustness that place a metric on words, thus providing a natural notion of distance between words. Such a metric naturally leads to a topological neighborhood of words and languages, leading to quantitative and robust versions of the membership, emptiness and inclusion problems. More generally, we consider weighted transducers to model the cost of errors. Such a transducer models neighborhoods of words by providing the cost of rewriting a word into another. The main contribution of this work is to study robustness verification problems in the context of weighted transducers. We provide algorithms for solving the robust and quantitative versions of the membership and inclusion problems while providing useful motivating case studies including approximate pattern matching problems to detect clinically relevant events in a large type-1 diabetes dataset.]]></ab></abstract>
		</profileDesc>
	</teiHeader>
	<text><body xmlns="http://www.tei-c.org/ns/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1">Introduction</head><p>Automata theoretic verification commonly uses an automaton S to specify the behaviors of a system being analyzed and another automaton P to specify the property of interest. These automata are assumed to be finite state machines accepting finite or infinite words. The key step is to verify whether the language inclusion L(S) &#8838; L(P ) holds. Failing this inclusion, a counterexample &#963; is generated such that &#963; &#8712; L(S) whereas &#963; &#8712; L(P ). Another important area lies in runtime verification, wherein given a sequence of observations represented by &#963; &#8712; &#931; * , we wish to check whether these observations satisfy the specification: &#963; &#8712; L(P ).</p><p>The verification community has considered numerous extensions to these basic ideas such as richer models of the system S that allow for succinct specifications (e.g., hierarchical state machines, state-charts), or go beyond finite state machines and include features such as real-time (timed automata) <ref type="bibr">[4]</ref>, physical quantities (hybrid automata) <ref type="bibr">[3]</ref>, and matching calls/returns <ref type="bibr">[8,</ref><ref type="bibr">23,</ref><ref type="bibr">6]</ref>. The complexity of the language inclusion and membership problems in these settings are also well understood <ref type="bibr">[11]</ref>. However, inclusion and membership problems lead to yes/no Boolean answers. The no answer for an inclusion problem is witnessed by a counterexample trace. However, the yes answer provides nothing further. A quantitative approach to these questions was proposed independently by Fainekos et al. <ref type="bibr">[16]</ref>, Donze et al. <ref type="bibr">[14]</ref> and Rizk et al. <ref type="bibr">[21]</ref> for the satisfaction of metric/signal temporal logic formula &#981; for a trace &#963; generated by continuous and hybrid systems. Therein, the authors use the euclidean metric over real-valued traces that defines a metric distance d(&#963;, &#963; ) between traces &#963;, &#963; in order to check whether traces that are in the epsilon neighborhood of a given trace &#963; also satisfy the formula: (&#8704;&#963; ) d(&#963;, &#963; ) &lt; &#8658; &#963; |= &#981;. Recent work, notably by Hasuo et al <ref type="bibr">[24,</ref><ref type="bibr">1]</ref> and Deshmukh et al <ref type="bibr">[12]</ref> generalizes these notions to time domain as well as the signal data domain. Efficient algorithms for computing the robustness of a trace with respect to metric (signal) temporal formulas are known, and furthermore, the theory led to numerous approaches to finding falsifications of complex Simulink/Stateflow models, mining robust requirements and other monitoring problems <ref type="bibr">[7]</ref>.</p><p>Robustness Using Weighted Transducers. In this paper, we specify distances between finite words over &#931; * , using the notion of cost functions. A cost function assigns a non-negative rational cost to each pair of words (w 1 , w 2 ) &#8712; &#931; * &#215; &#931; * , modelling the cost of rewriting w 1 into w 2 . By bounding the costs of rewritings, it models how words can be transformed. As a result, a neighborhood can be defined for each word, assuming that the cost of "rewriting" a word w back to itself is 0. This, in turn, allows to reason about robustness of languages. In order to model cost functions, we use weighted transducers with non-negative weights <ref type="bibr">[15]</ref> along with an aggregator that combines the cost of each individual rewriting of the transducer into an overall cost between the input and output words. We now provide motivating examples for the cost functions that can be specified by such a model. A formal definition is provided in Section 2. Motivating Example. Consider the transducer T of Figure <ref type="figure">1</ref>. This transducer is over alphabet &#931; : {a 1 , a 2 , b}. It allows to rewrite the letter a 1 into a 1 (at cost 0), and the letter a 2 into either a 2 (at cost 0) or b (at cost 1). Additionally, these rewritings are possible only at state q 1 . This allows us to have a model wherein errors appear in bursts rather than individually: I.e, an error at a location increases the likelihood of one at the subsequent location. Thus, the transducer models all possible words w that a given input word w can be rewritten into. As an example, the word w : a 1 a 2 a 2 a 2 into w : a 1 bba 2 through transitions that rewrite the first two occurrences of a 2 into b. At the same time, the transducer forbids certain rewritings. For instance, the word w above cannot be rewritten into the word w : bba 2 a 1 since the rewrite from an a 1 into a b or an a 2 into an a 1 is clearly disallowed by the transducer T in Figure <ref type="figure">1</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>T q</head><p>While the transducer T specifies the cost for individual rewritings through its transitions, we define the cost of rewriting the entire word w into another w by additionally specifying an aggregator function. For simplicity, we assume that there is exactly one run of the transducer that rewrites w into w . The case of nondeterministic transducers is defined in Section 2.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1.">Discounted Sum (DSum):</head><p>Given a discount factor &#955; &#8712; Q &#8745; (0, 1), the cost of rewriting a word w into another word w is defined as n i=1 &#955; (i-1) &#964; i , wherein n is the size of a run through the transducer and &#964; i is the cost associated with the i th transition.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.">Average (Mean):</head><p>This aggregator computes the mean cost:</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.">Sum (Sum):</head><p>This aggregator computes the sum:</p><p>Returning to our example, the Sum-cost of rewriting a 1 a 2 a 2 a 2 into a 1 bba 2 is 2, for the DSum-cost with discount factor 1/2, it is 3/4, and for Mean-cost it is 1/2.</p><p>Our approach handles a more general nondeterministic transducer model that can allow for insertions of new letters, deletion of letters, transpositions and arbitrary substitutions of one letter by a finite word. Cost functions defined by such transducers may not satisfy the axioms of a metric, however many commonly encountered type of metrics between words such as the Cantor distance and the Levenstein (or edit) distance can be modeled as weighted transducers <ref type="bibr">[13]</ref>. For example, edit distance is naturally modelled by a sum-transducer. Cantor distance maps any pair of word (w 1 , w 2 ) of same length to 2 -i where i the first position where w 1 and w 2 differ, and to 0 if w 1 = w 2 . This metric can be modelled by a discounted-sum transducer with discount factor 1/2.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Robustness problems.</head><p>Given a cost function c : (&#931; * &#215; &#931; * ) &#8594; Q &#8805;0 defined by a weightedtransducer with an aggregator function, we can define "neighborhoods" of languages for a given distance &#957; &#8805; 0. For a regular language N &#8838; &#931; * and a threshold &#957; &#8712; Q &#8805;0 , let us define its &#957;-neighborhood N &#957; : {w &#8712; &#931; * | (&#8707;w &#8712; N ) c(w, w ) &#8804; &#957;}. Given a property L &#8838; &#931; * , we consider the following robustness problems:</p><p>Robust inclusion: Given N, &#957; and L, check whether N &#957; &#8838; L. Threshold synthesis: Given N, L, find the largest threshold &#957; such that N &#957; &#8838; L.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Robust kernel synthesis: given</head><p>Example 1. Consider the transducer of Figure <ref type="figure">1</ref> using the the Sum aggregator. We take L as the set of words which does not have bbb as a subword. Now, any word of the form (a 1 a 2 ) * are &#957;-robust for any threshold &#957; since the letter a 1 is not rewritten by the transducer T . Such questions are tackled using the robust inclusion problem. On the other hand, let us choose a word w &#8712; a 2 a 2 a 2 (a * 1 ). It is &#957;-robust for all the thresholds &#957; &#8804; 2 but not for &#957; &#8805; 3. This is determined using the threshold synthesis problem. For all &#957; &#8805; 3, the set of &#957;-robust words in N = &#931; * is (a 1 + a 1 a 2 + a 1 a 2 a 2 ) * , and for &#957; &#8804; 2, any word in &#931; * is &#957;-robust. Such questions are solved using the robust kernel synthesis problem.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>17:4</head><p>Weighted Transducers for Robustness Verification Contributions. We show that the robust inclusion problem is solvable in PTime when N and L are regular languages (given as NFA and DFA respectively) and the weighted-transducer defining the cost function is also given as input (Corollary 12). To obtain this result, we show that we can effectively compute in PTime the largest threshold &#957; as defined before, thus solving the threshold synthesis problem (Theorem 11). This result holds for the three measures Sum, DSum and Mean. For Sum, we show that the robust kernel is effectively regular (Lemma 14) and testing its non-emptiness is PSpace-complete (Theorem 15). For Mean, we show that the robust kernel is not regular in general (Lemma 16), and its non-emptiness is undecidable (Theorem 17). For DSum, we leave those questions partially open. We conjecture that the robust kernel is non-regular in general and provide a sufficient condition under which it is regular (Theorem 22).</p><p>Next, we present an implementation of the algorithms to synthesize robustness thresholds and report some experiments with our implementation, illustrating its application to analyzing manual control strategies under the presence of human error and approximate pattern analysis in type-1 diabetes data. Here we analyze a publicly available dataset of blood glucose values for people with type-1 diabetes. In both cases, we use a weighted transducer to model some of the specifics of human error and glucose sensor noise patterns. For the type-1 diabetes application, we use a robust pattern matching to detect behaviors that are clinically significant while accounting for the peculiarities of the glucose sensor.</p><p>Our work bears some similarities with earlier work by Henzinger et al <ref type="bibr">[17,</ref><ref type="bibr">22]</ref>. In these papers, notions of robustness for string to string transformations are studied and the notion of continuity of these transformations is defined. This is different from our setting, in which we use weighted transducers to define notions of distances, and these transducers are not necessarily continuous. Our notion of robustness is with respect to the rewriting of the words of one language and not about the transducers. The transducers themselves serve to define neighborhoods of strings.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2">Preliminaries and Problem Statements</head><p>Let &#931; be an alphabet. We denote the empty word by the symbol &#949; &#8712; &#931; and we write &#931; * for the set of finite words over &#931;. Let &#931; &#949; = &#931; &#8746; {&#949;}. As usual, we write Q for the set of rationals, N = {0, 1, . . . } for naturals, and N * for the words over the infinite alphabet N.</p><p>A finite automaton over &#931; is a tuple</p><p>that there exist q 0 , q 1 , . . . , q n and for all 1 &#8804; i &#8804; n, t i = (q i-1 , a i , q i ). The run r is simple if no state repeats along r, i.e. i = j implies that q i = q j and, it is a cycle if q 0 = q n . We say that r is a simple cycle if its a cycle and t 2 . . . t n is simple. Also, r is accepting if it starts from an initial state q 0 &#8712; Q I and ends into a final state q n &#8712; Q F . We denote by AccRun A (u) the set of accepting runs of A on the word u. The language defined by A is the set of words</p><p>Weighted transducers extend finite automata with string outputs and weights on transitions <ref type="bibr">[15]</ref>. Any accepting run over some input word rewrites each input symbol into a (possibly empty) word, with some cost in N. Transducers can also have -input transitions with non-empty outputs, such that output symbols can be produced even though nothing is read on the input (e.g. allowing for symbol insertions). The output of a run is the concatenation of all output words occurring on its transitions. Its cost is defined by an aggregator function C : N * &#8594; Q &#8805;0 , which associates a rational number to a sequence of non-negative integers.</p><p>We consider three different aggregator functions, given later. Since there are possibly several accepting runs over the same input, and generating the same output, we take the minimal cost of them to compute the value of a pair of input and output words.</p><p>and Dest(t) = q . We say that a transition t &#8712; &#8710; can be triggered by T if it is in state Orig(t) and reads In(t) on its input (note that it is always possible to read In(t) = &#949;). It, then, moves to Dest(t) and rewrites its input into Out(t). A run r = t 1 . . . t n of T is a run of A. We write In(r) = In(t 1 ) . . . In(t n ) and Out(r) = Out(t 1 ) . . . Out(t n ) and say that r is a run of T on the pair of words (In(r), Out(r)). Let (u 1 , u 2 ) = (In(r), Out(r)). If moreover r is accepting, we say that (u 1 , u 2 ) is accepted by T , and denote by AccRun T (u 1 , u 2 ) the set of accepting runs over (u 1 , u 2 ). We also say that u 1 is accepted by T if (u 1 , u 2 ) is accepted by T for some u 2 &#8712; &#931; * . We denote the weight sequence of r by</p><p>A transducer T defines a relation from &#931; * to itself, called a translation, denoted R T and defined by: R T</p><p>The domain of T , denoted dom(T ) is the set of words u 1 for which there exists u 2 such that (u 1 , u 2 ) &#8712; R T . The cost of a pair of words (u 1 , u 2 ) is given by:</p><p>Note that since runs consume at least one symbol of the input or one of the output, there are finitely many runs on a pair (u 1 , u 2 ), hence the min is well-defined. Finally, given &#957; &#8712; Q and an input word u 1 &#8712; dom(T ), we define the threshold output language T &#8804;&#957; (u 1 ) of u 1 as:</p><p>This notation extends naturally to languages N &#8838; &#931; * by setting: T &#8804;&#957; (N ) = u1&#8712;N &#8745;dom(T ) T &#8804;&#957; (u 1 ).</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Assumption 3. We restrict our attention to C-transducers T that satisfy the condition that for all</head></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>. In other words, it is always possible to rewrite u into itself at zero cost.</head><p>This assumption requires that each point must belong to any of its neighborhoods, which naturally comes from the indiscernibility axiom of distance. However, we do not require the triangle inequality axiom, that the edit distance does not satisfy.</p><p>Cost functions. We consider three aggregator functions, namely the sum, the mean and the discounted-sum. Let &#955; &#8712; Q &#8745; (0, 1) be a discount factor. Given a sequence of weights &#964; = &#964; 1 . . . &#964; n , those three functions are defined by:</p><p>Weighted Transducers for Robustness Verification Weighted-automata. When a C-transducer outputs only empty words, then its output component can be removed and we get what is called a C-automaton, which defines a function from words to costs. For C = Sum, this definition of Sum-automaton coincides with the classical notion weighted automata over the semiring (N &#8746; {+&#8734;}, min, +) from <ref type="bibr">[15]</ref>.</p><p>Robustness problems. We study the following three fundamental problems related to robustness for three different aggregator functions C &#8712; {Sum, Mean, DSum}. Given a threshold &#957; &#8712; Q, a C-transducer T and a regular language L, a word u &#8712; dom(T ) is said to be &#957;-robust</p><p>In other words, all its rewritings of cost &#957; at most are in L. A language N &#8838; &#931; * is said to be &#957;-robust if N &#8745; dom(T ) contains only &#957;-robust words. Finally, the &#957;-robust kernel of T is the set Rob T (&#957;, L) of &#957;-robust words:</p><p>We prove that as the error threshold grows, so does the robust kernel.</p><p>We are in a position to formally define the three key problems studied in this paper. For these definitions, we let C &#8712; {Sum, Mean, DSum}.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Problem 5 (Robust Inclusion).</head><p>Given a C-transducer T , a regular language N &#8838; &#931; * as an NFA, a threshold &#957; &#8712; Q &#8805;0 and a language L &#8838; &#931; * as a DFA, the robust inclusion problem is to decide whether N &#8838; Rob T (&#957;, L), i.e. whether T &#8804;&#957; (N ) &#8838; L.</p><p>Note that we consider our specification language L deterministically presented, for tractability. Problem 6 (Threshold Synthesis). Given a C-transducer T , a regular language N &#8838; &#931; * as an NFA, and a regular language L &#8838; &#931; * as a DFA, the threshold synthesis problem is to output a partition of the set of thresholds Q &#8805;0 = G B into sets G and B of good and bad thresholds, i.e.</p><p>As direct consequence of Proposition 4, the sets G and B are intervals of values, that is for all</p><p>For the cases where we provide algorithms for solving the non-emptiness of the robust kernel, we also succeed in synthesizing the robust kernel as an automaton.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3">Robust Verification</head><p>Given an instance of the threshold synthesis problem, we show how to compute the interval of good thresholds G and the interval of bad thresholds B in PTime for all the three measures we consider. As a corollary, we show that the robust inclusion problem for Sum, Mean, DSum measures is in PTime. In the following, we assume that N = dom(T ). This is w.l.o.g. as transducers are closed (in polynomial time) under regular domain restriction (using a product construction of T with the automaton for N ). With this assumption, the set of good thresholds G becomes Then, we associate with every transducer T and property L given by some DFA A (assumed to be complete), a graph called the weighted-graph associated with T and A, and denoted by G T,A . Intuitively, G T,A is obtained by first taking the synchronised product of T and A (where A is simulated on the outputs of T ) and then by projecting this product on the inputs.</p><p>Formally, given T = (Q, Q I , Q F , &#8710;, W) and A = (P, p I , P F , &#948;), the synchronised product</p><p>is the set of edges e = (q, p) &#8594; (q , p ) such that there exists a &#8712; &#931; &#949; and a transition t = (q, a, u, q ) &#8712; &#8710; such that p = &#948;(p, u) where &#948; has been extended to words in the expected way. We say that e is compatible with t.</p><p>For all e &#8712; E, W (e) = min{W(t) | e is compatible with some t &#8712; &#8710;}. Additionally, we note</p><p>the set of final vertices of this graph. Given a path &#960; in this graph as a sequence of edges e 1 . . . e n , we let C(&#960;) = C(W (e 1 ) . . . W (e n )).</p><p>The following lemma establishes some connection between &#957; T,L and the paths of G T,A .</p><p>Lemma 9. The infimum cost of paths from a vertex in</p><p>Proof. We first show that any path &#960; from V I to V F satisfies C(&#960;) &#8805; &#957; T,L . Take such a path. By construction of G T,A , there exists an input word u 1 &#8712; dom(T ), some output word u 2 / &#8712; L and an accepting run</p><p>Weighted Transducers for Robustness Verification the minimal value of all accepting runs of T over (u 1 , u 2 ), we have C(r) &#8805; C T (u 1 , u 2 ) and u 1 is not robust for threshold C T (u 1 , u 2 ), a fortiori for threshold C(r), from which we get</p><p>Suppose that &#957; T,L is strictly smaller than this infinimum (that we denote m) and take some rational number &#957; such that &#957; T,L &lt; &#957; &lt; m. Since &#957; T,L &lt; &#957;, it is a bad threshold which means that there exists u 1 &#8712; dom(T ) such that u 1 &#8712; Rob T (&#957;, L). Hence there exists u 2 &#8712; L such that C T (u 1 , u 2 ) &#8804; &#957;, and by definition of G T,A , there exists a path &#960; from V I to V F of value C(&#960;) &#8804; &#957;. This contradicts the fact that &#957; &lt; m by definition of m. Hence, &#957; T,L = m, concluding the proof.</p><p>The next lemma establishes that the infimum of values of paths between two sets of states in a weighted graph can be computed in PTime and it is also decidable in PTime if the infimum is realized by a path, for all the three measures considered in this paper. As a direct corollary of this lemma we obtain the main theorem of the section. The full proof can be found in Appendix.</p><p>Lemma 10. For a weighted graph G = (V, E, W : E &#8594; Q &#8805;0 ), a set of sources V I &#8838; V and a set of targets V F &#8838; V , the infimum of the weights of paths from V I to V F can be computed in PTime for all C &#8712; {Sum, DSum, Mean}. Moreover, we can decide in PTime if this infimum is realizable by a path.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Sketch of proof.</head><p>First, if no state of V F are reachable from some state of V I , we have &#957; T,L = +&#8734;. Otherwise we use different procedures, depending on the aggregator C.</p><p>For Sum, the infimum can be computed in Ptime using Dijkstra algorithm and it is always feasible. For Mean, we first note that the infimum is the Mean value of either a simple path or the value of a reachable cycle that can be iterated before moving to some target. In the latter case, the infimum is not feasible but can be approximated as close as possible by iterating the cycle. So, the infimum is feasible iff it is the Mean value of a simple path. The minimal Mean values amongst simple paths and cycles can be computed in Ptime with dynamic programming thanks to <ref type="bibr">[18]</ref>. For DSum, Theorem 1 of <ref type="bibr">[5]</ref> provides a PTime algorithm that computes for all v &#8712; V , the infimum of DSum values x v of paths reaching the target V F from v.</p><p>Theorem 11. For a given C-transducer T , a language N &#8838; &#931; * given as an NFA and L &#8838; &#931; * given as a DFA, the set partition of good and bad thresholds (G, B) for C &#8712; {Sum, DSum, Mean} can be computed in PTime.</p><p>Proof. First, we restrict the domain of T to N by taking the product of T and the automaton for N (simulated over the input of T ). Then, according to Lemma 10, we can compute in PTime the value &#957; T,L . This value is the infimum of B. If this infimum is feasible then the interval B is left closed and equal to [&#957; T,L , +&#8734;) while G = [0, &#957; T,L ), and on the contrary, if this infimum is not feasible, then B is left open and equal to (&#957; T,L , +&#8734;), while G = [0, &#957; T,L ]. Note that when &#957; T,L = 0 and is feasible, then G = [0, 0) = &#8709;.</p><p>As a direct consequence, the robust inclusion problem for a threshold &#957; can be solved by checking if &#957; &#8712; G, and so we have the following corollary. </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4">Robust Kernel Synthesis</head><p>In this section, we show that the robust kernel is regular for Sum-transducers, and checking its emptiness is PSpace-complete. For Mean, we show that it is not necessarily regular, and checking its emptiness is undecidable. For DSum, we conjecture that the robust kernel is non-regular and give sufficient condition under which it is regular and computable, implying decidability of its emptiness.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.1">Sum measure</head><p>To show robust kernel regularity, we rely on the construction of Theorem 2 of <ref type="bibr">[2]</ref> in the context of weighted automata over the semiring (N &#8746; {+&#8734;}, min, +). The following lemma, use the same automata construction and provides an upper bound on the number of states required to denote a threshold language with a DFA.</p><p>Lemma 13. Let U be an n state Sum-automaton and &#957; &#8712; N. The threshold language L &#957; (U ) = {w | U (w) &#8805; &#957;}, where U (w) is defined as +&#8734; if there is no accepting run on w, otherwise as the minimal sum of the weights along accepting runs on w, is regular. Moreover L &#957; (U ) is recognized by a DFA with O (&#957; + 2) n states.</p><p>Proof. First, let assume that U has universal domain (i.e. any word has some accepting run), otherwise we complete it by assigning value &#957; to each word of its complement.</p><p>Then, U (w) &#8805; &#957; iff all the accepting runs on w have value at least &#957;. We design a DFA D that accepts exactly those words. Since the weights of U are non-negative, D just has to monitor the sum of all runs up to &#957;, by counting in its states. If Q is the set of states of U , the set of states of D is 2 Q&#215;{0,...,&#957;-1,&#957; + } , where &#957; + intuitively means any value &#8805; &#957;. We extend natural addition to X = {0, . . . , &#957; -1, &#957; + } by letting a + b = &#957; + iff a = &#957; + , or b = &#957; + , or a + b &#8805; &#957;. Then, D is obtained by subset construction: there is a transition P &#963; -&#8594; P in D iff P = {(q , i + j) | (q, i) &#8712; P &#8743; q &#963;|j --&#8594; U q }. A state P is accepting if P &#8745; (Q \ F ) &#215; {0, . . . , &#957; -1} = &#8709;, where F are the accepting states of U .</p><p>Though simple, the latter construction does not give the claimed complexity, as the number of states of D is 2 n&#957; . But the following simple observation allows us to get a better state complexity. Consider an input word of the form uv. If after reading u, D reaches some state P such that for some state q, there exists (q, i), (q, j) &#8712; P such that i &lt; j, then if there is an accepting run of U from q on v, with sum s, there is an accepting run on uv with sum i + s and one with sum j + s. Therefore if i + s &#8805; &#957;, then j + s &#8805; &#957; and the pair (q, j) is useless in P . So, we can keep only the minimal elements in the states of D, where minimality is defined with respect to the partial order (q, i) (p, j) if q = p and i &#8804; j. Let us call D opt the resulting "optimised" DFA. Its states can be therefore seen as functions from Q to {0, . . . , &#957; -1, &#957; + }, so that we get the claimed state-complexity. Lemma 14 (Robust language regularity). Let T be a Sum-transducer, &#957; &#8712; N and L be regular language. The language of robust words Rob T (&#957;, L) is a regular language. Moreover, if L is given by a DFA with n L states and T has n T states, then Rob T (&#957;, L) is recognisable by a DFA with O (&#957; + 2) n T &#215;n L states.</p><p>Proof of this lemma is provided in the appendix.</p><p>C O N C U R 2 0 2 0 17:10 Weighted Transducers for Robustness Verification Theorem 15. Let T be a Sum-transducer, &#957; &#8712; N given in binary and L a regular language given as a DFA. Then, it is PSpace-complete to decide whether there exists a robust word w &#8712; Rob T (&#957;, L). The hardness holds even if &#957; is a fixed constant, T is letter-to-letter<ref type="foot">foot_0</ref> and io-unambiguous<ref type="foot">foot_1</ref> , and its weights are fixed constants in {0, 1}.</p><p>Proof. From Lemma 14, Rob T (&#957;, L) is recognisable by a DFA with O (&#957; + 2) n T &#215;n L states, where n T is the number of states of T and n A the number of states of the DFA defining L. Checking emptiness of this automaton can be done in PSpace (apply the standard NLogSpace emptiness checking algorithm on an exponential automaton that needs not be constructed explicitly, but whose transitions can be computed on-demand).</p><p>To show PSpace-hardness, we reduce the problem from <ref type="bibr">[19]</ref> of checking the non-emptiness of the intersection of n regular languages given by n DFA A 1 , . . . , A n , over some alphabet &#915;. In particular, we construct T , &#957; and a DFA A such that i L(A i ) = &#8709; iff there exists a robust word with respect to T ,&#957; and L.</p><p>We define the alphabet as &#931; = &#915; &#8746; {# 1 , . . . , # n , } where we assume that # 1 , . . . , # n , / &#8712; &#915;, and construct a transducer T which reads a word w of length k = |w| + 1 with w &#8712; &#915; * , and rewrites it into either itself, or (# i ) k for all i &#8712; {1, . . . , n}. The identity rewriting has total weight 0 while the rewriting into # k i has total weight 1 if w &#8712; L(A i ), and 0 otherwise. The transducer T is constructed as the disjoint union of n + 1 transducers T 1 , . . . , T n , T . For all i &#8712; {1, . . . , n}, T i simulates A i on the input and outputs # i whenever it reads an input letter different from , with weight 0. When reading from an accepting state of A i , it outputs with weight 1, and if it reads from a non-accepting state, it outputs with weight 0. Finally, T just realizes the identify function with weight 0. Note that T has polynomial size in A 1 , . . . , A n and it is letter-to-letter and (input,output)-deterministic. Now we prove that a word w is robust iff w &#8712; i L(A i ). Assume that there exists a robust word w for the property L = (&#915; &#8746; { })</p><p>* and threshold &#957; = 0. Equivalently, it means that for all rewritings &#945; &#8712; &#931; * , if Sum T (w , &#945;) &#8804; 0 then &#945; &#8712; L. It is equivalent to say that all its rewritings &#945; satisfies either Sum T (w , &#945;) &#8805; 1 or &#945; &#8712; L. By definition of T , it is equivalent to say that all rewritings &#945; are such that either &#945; &#8712; (# i ) * &#8226; for some i and w &#8712; L(A i ), or &#945; = w . Since T necessarily rewrites w into w , as well as into (# 1 ) k , . . . , (# n ) k , where k = |w| + 1, the latter assumption is equivalent to saying that w &#8712; L(A i ) for all i &#8712; {1, . . . , n}, concluding the proof.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.2">Mean measure</head><p>Let us first establish non-regularity of the robust kernel.</p><p>Lemma 16. Given a regular language L, a Mean-transducer T and &#957; &#8712; Q &#8805;0 , the language Rob T (&#957;, L) is not necessarily regular, but recursive.</p><p>Proof. Consider the language L = {w | &#8707;i &#8712; N : w(i) = a} on the alphabet &#931; = {a, b}, i.e. the set of words on &#931; that contain at least one a. Now, consider a (one state) transducer T that can non-deterministically copy letters or change the current letter from a to b with weight one. Now, if we fix &#957; to be equal to 1  2 , then all the translations of w by T of cost less than  </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5">Implementation and Case Study</head><p>We describe an evaluation of the ideas presented thus far and their application to two case studies: one involving robustness of control strategies to human mistakes and the other involving glucose values for patients with type-1 diabetes. We have implemented in Python the threshold synthesis problem (Problem 6) for the discounted and average costs. Our implementation supports the specification of a language L specified as an NFA, a weighted transducer T and a property P specified as some DFA. The implementation is available upon request.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.1">Robustness of Human Control Strategies</head><p>An industrial motor operates under many gears g 1 , . . . , g 5 . Under fault, the human operator must take control of the machine and achieve the following: If the system goes into a fault the operator must ensure that (a) the system is immediately set in gears 3 -5. Subsequently, for the next 5 cycles: (b) it must never go to gear g 1 or g 2 ; and (c) must shift and stay at a higher gear g 4 or g 5 after the 5 th cycle until the fault is resolved.</p><p>Figure <ref type="figure">3</ref> shows a finite state machine P that accepts all words satisfying this property: fault is not in the operator's control but g 1 , . . . , g 5 are operator actions. Consider that the operator can perform this task in two different ways: &#963; 1 : fault g 4 g 4 g 4 g 5 g 5 versus &#963; 2 : fault g 3 g 3 g 3 g 3 g 4 . The input &#963; 1 induces the run s, s 0 , t 1 , t 2 , t 3 , r 4 , r 5 whereas the input &#963; 2 induces the run s, s 0 , s 1 , s 2 , s 3 , s 4 , t 5 . Both &#963; 1 , &#963; 2 satisfy the property of interest and as such there is nothing to choose one over the other. Suppose the human operator can make mistakes, especially since they are under stress. We will consider that the operator can substitute a command for gear g i with g i-1 (for i &gt; 1) or g i+1 (for i &lt; 5). We use a weighted transducer T 0 shown in Figure <ref type="figure">4</ref> to model these substitutions. The transducer defines possible ways in which a string &#963; can be converted to &#963; with a notion of cost for the conversion. In this example we consider two notions of cost: the DSum-cost, and the Mean-cost. These costs now allow us to compare &#963; 1 versus &#963; 2 . For instance, under both notions we will discover that &#963; 1 is much more robust than &#963; 2 . The robustness of &#963; 1 under both cost models is &#8734; since any change to &#963; 1 under the transducer continues to satisfy the desired property. On the other hand &#963; 2 has a finite robustness, since operator mistakes can cause violations.</p><p>The use of a transducer allows for a richer specification of errors. For instance, transducer T 2 in Fig. <ref type="figure">4</ref> shows a model of "bounded" number of mistakes that assume that the operator makes at most 2 mistakes whereas T 3 in Fig. <ref type="figure">4</ref> shows a model with "bursty" mistakes that C O N C U R 2 0 2 0 17:14 Weighted Transducers for Robustness Verification</p><p>id, 0</p><p>id, 0</p><p>id, 0</p><p>id, 0</p><p>Figure <ref type="figure">4</ref> Transducers modeling potential human operator mistakes along with their costs: T0 allows arbitrarily many mistakes whereas T1 restricts the number of mistakes to at most 2, whereas T2 models a "bursty" set of mistakes. The edge a | b, w denotes a replacement of the letter a by b with a cost w. For convenience T2 uses an transition that can be removed. assume that mistakes occur in bursts of at least 2 but at most 3 mistakes at a time. These models are useful in capturing fine grained assumptions about errors that are often the case in the study of human error or errors in physical systems. Using the prototype implementation, we report on the robustness of various inputs for this motivating example under the three transducer error models. The property P is as shown in Figure <ref type="figure">3</ref> and the transducers T 0 -T 2 are as shown in Fig. <ref type="figure">4</ref>. Table <ref type="table">1</ref> reports the robustness values for various input strings and the running time. We note that while our approach takes about 0.3 seconds for a string of length 50, the prototype can be made much more efficient to reduce the time to compute robustness. Also we note that discounted sum becomes smaller as the strings grow larger while the average robustness value does not. We conclude that average robustness is a more useful measure due to this property in this particular example.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.2">Robust Pattern Matching in Type-1 Diabetes Data</head><p>We will now apply our ideas to the robust pattern matching problem for analyzing clinical data for patients with type-1 diabetes. People with type-1 diabetes are required to monitor their blood glucose levels periodically using devices such as continuous glucose monitors (CGMs). Data from CGMs is uploaded online and available for review by clinicians during periodic doctor visits. Many applications such as Medtronic Carelink(tm) support the automatic upload and visualization of this data by clinicians. Physicians are commonly interested in analyzing the data to reveal potentially dangerous patterns of blood glucose levels: (a) Prolonged Hypoglycemia (P1): Do the blood glucose levels stay below 70 mg/dl (hypoglycemia) for more than 3 hours continuously?<ref type="foot">foot_2</ref> (b) Prolonged Hyperglycemia (P2): Do the blood glucose levels remain above 300 mg/dl (hyperglycemia) for more than 3 hours continuously? <ref type="foot">4</ref> ; and (c) Rebound Hyperglycemia (P3): Do the blood glucose levels go below 70 mg/dl and then rise rapidly up to 300 mg/dl or higher within 2 hours?<ref type="foot">foot_4</ref> Note that these patterns specify "bad" events that should not happen. A straightforward and strict pattern matching approach based on specifying the properties above will "hide" potentially bad scenarios that "nearly" match the desired pattern for two main reasons. First, the CGM can be noisy and inaccurate in a way that depends on the actual blood glucose value measured when it was last calibrated. (see Figure <ref type="figure">5</ref> and more detailed description below). Secondly, the cutoffs involved such as 70 mg/dl and 3 hours are not "set stone". For instance, a clinician will consider a scenario wherein the patient's blood glucose levels stays at 71 mg/dl for 2.75 hours as a serious case of prolonged hypoglycemia even though such a scenario would not satisfy the property P1.</p><p>We propose to solve the approximate "pattern matching" problem. I.e, given a string w, a transducer T and a language L, we are looking for a word w such that w &#8712; L and C T (w , w) is as small as possible. In other words, we solve the threshold synthesis problem (Problem 6) for a language L that is the complement of P1 (P2 or P3).</p><p>We partition the range of CGM outputs [40, 400] mg/dl into intervals of size 10 mg/dl over the range [40, 80] mg/dl and 20 mg/dl intervals over the remaining range [80, 400] mg/dl. This yields a finite alphabet &#931; where |&#931;| = 20. For instance a 60,70 &#8712; &#931; represents a range [60, 70]mg/dl. CGMs provide a reading periodically at 5 minute intervals. This yields a string where each letter describes the interval that contains the glucose value.</p><p>Transducer. The CGM error model is given by a transducer that considers possible errors that a CGM can make (see Fig. <ref type="figure">5</ref>). The transducer has four states: (a) Not Calib denoting that no calibration has happened, (b) Calib: denoting a calibration event in the past, (c) DropoutNC: a sensor drops out under the non calibrated mode and (d) DropoutC: a calibration event has happened and sensor drops out. The cost of changing a reading in the range [lb, ub] to one in the range [lb , ub ] is denoted by a function cost(lb, ub, lb , ub ) These costs are set to be higher for ranges <ref type="bibr">[lb, ub]</ref> that are close to hypoglycemia. Also note that we can model calibration events and the doubling of costs if the sensor is in the calibrated mode.</p><p>Property Specifications. We specify the three different properties described above formally using finite state machines over the alphabet &#931; as defined above. The prolonged hypoglycemia property can be written as a regular expression: &#931; * (a 40,50 + a 50,60 + a 60,70 ) 36 &#931; * which can be easily translated into an NFA with roughly 38 states. The number 36 represents a period of 180 minutes since CGM values are sampled at 5 minute intervals. Similarly, the other two properties are also easily expressed as NFAs.</p><p>Finally, we compose the transducer model with the properties P1-P3 individually and calculate mean robustness. More precisely, for each sequence of measures w, we compute the minimal threshold &#957; such that w can be rewritten by T at mean cost &#957; into some w satisfying P1 (and P2, P3 respectively). The discounted sum robustness is not useful in this situation since the patterns can match approximately anywhere in the middle of a trace. Also, in most cases the discounted sum robustness value was very close to zero for any discount factor &lt; 1 or became forbiddingly large for discount factors slightly larger than 1, due to the large size of the traces.</p><p>Patient Data. We used actual patient data involving nearly 50 patients with type-1 diabetes undergoing a clinical trial of an artificial pancreas device, and nearly 40 nights of data per patient, leading to an overall 2032 nights. Each night roughly corresponds to a 12 hour period when CGM data was recorded <ref type="bibr">[20]</ref>. This is converted to a string of size 140 (or slightly larger, depending on how many calibration events occurred). The threshold synthesis problem (Problem 6) was solved for each of the input strings, and the results were sorted by the threshold robustness value for properties P1-P3. Table <ref type="table">2</ref> shows for each property, the total time taken to complete the analysis of the full patient data, and the number of matches obtained corresponding to various threshold values. As the table reveals, no single trace matches any of the properties perfectly. However, our approach is more nuanced, and thus, allows us to find numerous approximate matches that can be sorted by their robustness threshold values. Note that many of the input traces yield a threshold value of &#8734;: this signifies that no possible translation as specified by the transducer can cause the property to hold.</p><p>Figure <ref type="figure">6</ref> shows two of the approximate pattern matches obtained with a small robustness value. Notice that the CGM values on the left do not satisfy the criterion for a "prolonged hypoglycemia" for 3 hours (P1) in a strict sense due to a single point at the end of the trace that is slightly above the 70 mg/dl threshold. Nevertheless, our approach assigns this trace a very low robustness. Likewise, the plot on the right shows a rapid rise from a hypoglycemia to a hyperglycemia within 120 minutes (P3) towards the beginning, except that the peak value just falls short of the threshold of 300 mg/dl. Note that related work in the area of monitoring cyber-physical systems (CPS) mentioned earlier <ref type="bibr">[16,</ref><ref type="bibr">14,</ref><ref type="bibr">12,</ref><ref type="bibr">1]</ref> can be used to perform approximate pattern matching using robustness of temporal properties over hybrid traces. However, we note important differences that are achieved due to the theory developed in this paper. For one, the use of a transducer can provide a nuanced model of how errors transform a trace, wherein the transformation itself changes based on the transducer state. A detailed transducer model of CGM errors remains beyond the scope of this study but will likely be desirable for applications to the analysis of patterns in type-1 diabetes data.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6">Conclusion</head><p>In conclusion, we have shown how notions of robustness can be defined through weighted transducers along with approaches for solving and kernel synthesis problems for various cost aggregators such as Sum, DSum and Mean. In the future, we will investigate these notions for richer classes of systems including timed and hybrid systems. We also plan to investigate connections to robust learning of automata from examples.</p><p>w 1 &#8712; Rob T (&#957;, L). The run r is called dangerous if |r| &#8805; n and DSum(r) &#8804; &#957; -B n . A dangerous run r can possibly be extended to a bad run rr . It is possible iff there exists a continuation r of r such that the of rr is not in L. Note that the cost of rr does not matter because the largest value r can achieve is B n , keeping DSum(rr ) smaller than &#957;. Hence, when a dangerous run is met, only a regular property has to be tested to extend it to a bad run. We exploit this idea in the automata construction. Namely, A n will accept words for which there exists a bad run of length n at most, or a dangerous run of length n which can be extended to a bad run.</p><p>&#8226; Automata construction. Let Runs &#8804;n T be the runs of T of length at most n, and Q its set of states. We assume that for all (w 1 , w 2 ) &#8712; R T , w 2 &#8712; L holds. This can be ensured by taking the synchronised product of T (on its outputs) with an automaton recognizing the complement of L. Let us now build the NFA A n . Its set of states is Runs &#8804;n T &#8746; Q. Its transitions are defined as follows: for all T -runs r of length n -1 at most ending in some state q, for all &#963; &#8712; &#931; &#949; , if there exists a transition t of T from state q on reading &#963;, then we create the transition r &#963; -&#8594; rt in A n . From any run r of length n, we consider two cases: if r is not dangerous, then r has no outgoing transitions in A n . If r is a dangerous run, then we add some &#949;-transition to its last state: r &#949; -&#8594; p where p is the last state of r. Finally, we add a transition from any state q to any state q on &#963; in A n whenever there is a transition from q to q on input &#963; in T . Accepting states are bad runs of Runs &#8804;n T and accepting states of T . &#8226; Correctness. Let us show that the family A n satisfies the requirements of the lemma. First, we show that L(A n ) &#8838; L(A n+1 ). Let w &#8712; L(A n ) and &#961; some accepting run of A n on w. To simplify the notations, we assume here in this proof that runs of A n , A n+1 and T are just sequences of states rather than sequences of transitions. By definition of A n , &#961; can be decomposed into two parts &#961; 1 &#961; 2 such that &#961; 1 &#8712; (Runs &#8804;n T ) * and &#961; 2 &#8712; Q * with an -transition from the last state of &#961; 1 to the first of &#961; 2 . We consider two cases. If |&#961; 2 | = 0, then &#961; = &#961; 1 and by definition of A n+1 , &#961; is still an accepting run of A n+1 . In the other case, there is a dangerous run r of T such that &#961; 1 can be written &#961; 1 = r[: 1]r[: 2] . . . r[: n] where r[: i] is the prefix of r up to position i, and &#961; 2 = q 1 q 2 . . . q k is a proper run of T . Note that q 1 is the last state of r by construction of A n . Moreover, r&#961; 2 is bad. Since r was dangerous at step n, we also get that rq 2 is dangerous at step n + 1, in the sense that |rq 2 | = n + 1 and DSum(rq 2 ) &#8804; &#957; -B n+1 , by definition of B n+1 and the fact that DSum(r) &#8804; &#957; -B n . So, we get that the sequence of states &#961; 1 .(rq 2 ).q 2 . . . q k is a run of A n+1 on w is accepting in A n+1 (note that rq 2 here is a state of A n+1 and there is an -transition from (rq 2 ) to q 2 ), concluding the first part of the proof. Now, suppose that &#957; is -isolated for some . Then, take n * as given by Lemma 18 and let us show that Rob T (&#957;, L) &#8745; dom(T ) &#8838; L(A n * ) (the other inclusion has just been proved for all n). Let w &#8712; dom(T ) such that w &#8712; Rob T (&#957;, L). There exists (w 1 , w 2 ) &#8712; R T and an accepting run r of T on it such that DSum(r) &#8804; &#957; and w 2 &#8712; L. In other words, r is bad. If </p></div><note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="1" xml:id="foot_0"><p>A transducer is letter-to-letter if &#8710; &#8838; Q &#215; &#931; &#215; &#931; &#215; Q.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="2" xml:id="foot_1"><p>For all word pairs (w1, w2), there exists at most one run of T on w1 outputting w2.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="3" xml:id="foot_2"><p>Such an event can lead to dangerous (and silent) nighttime seizures.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="4" xml:id="foot_3"><p>Such an event can lead to a potentially dangerous condition called diabetic ketacidosis.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="5" xml:id="foot_4"><p>Rebound hyperglycemia can lead to large future swings in the blood glucose level, raising the burden on the patient for managing their blood glucose levels.</p></note>
		</body>
		</text>
</TEI>
