{'fraction_non_alphanumeric': 0.04085268275008303, 'fraction_numerical': 0.009420574292702074, 'mean_word_length': 4.1985559566787005, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Metrics for Signal Temporal Logic Formulae

Signal Temporal Logic (STL) is a formal language for describing a broad range of real-valued, temporal properties in cyber-physical systems. While there has been extensive research on verification and control synthesis from STL requirements, there is no formal framework for comparing two STL formulae. In this paper, we show that under mild assumptions, STL formulae admit a metric space. We propose two metrics over this space based on i) the Pompeiu-Hausdorff distance and ii) the symmetric difference measure, and present algorithms to compute them. Alongside illustrative examples, we present applications of these metrics for two fundamental problems: a) design quality measures: to compare all the temporal behaviors of a designed system, such as a synthetic genetic circuit, with the"desired"specification, and b) loss functions: to quantify errors in Temporal Logic Inference (TLI) as a first step to establish formal performance guarantees of TLI algorithms.


I. INTRODUCTION
Temporal logics [1] are increasingly used for describing specifications in cyber-physical systems such as robotics [2], synthetic biology [3], and transportation [4]. Variants of temporal logics, such as Computation Tree Logic (CTL) [5], Linear Temporal Logic (LTL) [6], or Signal Temporal Logic (STL) [7], can naturally describe a wide range of temporal system properties such as safety (never visit a "bad" state), liveness (eventually visit a "good" state), sequentiality, and their arbitrarily elaborate combinations.
Using model checking [1] techniques, signals or traces can be checked to determine whether or not they satisfy a specification. For STL in particular, the degree of satisfaction or robustness is a quantitative measure to characterize how far a signal is from satisfaction [8]- [10] of an STL formula. There is currently, however, no formal way to directly compare specifications against each other. Previous related approaches in planning and control have looked into specification relaxation, where the goal is to minimally enlarge the specification language to include a satisfying control policy for the system model. Various specification relaxations have been defined including minimum violation [11]- [13] for self-driving cars, temporal relaxation of deadlines [14], minimum revision of Büchi automata [15], and diagnosis and repair in reactive synthesis [16]. While language inclusion and equivalence problems are of paramount importance in computer science and control theory, they are only qualitative measures while we are interested in quantitative metrics.
This paper presents two metrics that can be used to compute the distance between two STL specifications. Under mild assumptions, we propose the metrics based on the languages of STL formulae. We propose two distance functions. The first is based on the Pompeiu-Hausdorff (PH) distance [17], which captures how much the language of one formula must be enlarged to include the other, and the second is based on the symmetric difference (SD) [18], which characterizes how much overlap there is between the two formulae. The theoretical contributions of this paper are: 1. formalization of STL formulae metrics based on the PH and the SD distances, and 2. methods for computing the PH using mixed-integer linear programming (MILP), and the SD using a recursive algorithm based on the area of satisfaction. We discuss the comparison of the two metrics in detail and provide examples that highlight their differences.
This paper additionally presents applications of the proposed metrics to a behavioral synthesis problem and to the evaluation of temporal logic inference (TLI) [19]- [23] methods. In the first case, we are interested in generating designs that exhibit desired behaviors specified in STL. For example, we study synthetic genetic circuits. Possible circuit designs are constructed and measured in laboratory experiments, and the resulting traces are abstracted into STL specifications using TLI. These formulae are compared quantitatively against the desired design specification using the proposed metrics. The second setup considers the fundamental problem of evaluating TLI methods themselves. Under the assumption that data used for inference can be characterized by ground truth STL formulae, we ask the question of how well the TLI algorithms perform. As opposed to empirical evaluation used in previous work, we propose to use our metrics as loss functions as the first step in establishing theoretical foundations for TLI. The related contributions are: 3. a design quality measure for evaluating proposed implementations against an STL specification, and 4. a loss function to quantify errors in TLI as a first step in establishing formal performance guarantees of TLI algorithms.

Notation
Let R, R ≥0 , N denote the set of real, non-negative real, and natural numbers, respectively. We use |r| to denote the absolute value of r ∈ R. Given x ∈ R n , x ∞ := max i∈{1,··· , , is also a metric space for any 0 ≤ λ ≤ 1.
We use discrete notion of time throughout this paper. Time intervals in the form An n-dimensional, real, infinite-time, discrete-time signal s is defined as a string of real values s : s 0 s 1 s 2 · · · , where s t ∈ S, S ⊂ R n , t ∈ N. The suffix of s at t, denoted by s[t], is a signal such that s[t] τ = s t+τ for all t, τ ∈ N. We use s[t 1 , t 2 ] := s t1 s t1+1 · · · s t2 to refer to a particular portion of a signal. The set of all signals with values taken in S is denoted by S. The set of all signal prefixes with time bound T is defined as S T := {s[0 : T ] | s ∈ S} . For the convenience of notation, we use s ∈ S T to say s[0 : T ] ∈ S T . The distance between two signals s, s ∈ S T is defined as

Signal Temporal Logic
The syntax of STL is defined as follows [7]: where is the Boolean true constant; π is a predicate over R n in the form of f (x) ∼ µ, f : S → R, µ ∈ R, and ∼∈ {≤, ≥}; ¬ and ∧ are the Boolean operators for negation and conjunction, respectively; and U I is the temporal operator until over bounded interval I. A predicate f (s) ∼ µ is rectangular if f is rectangular. Other Boolean operations are defined in the usual way. Additional temporal operators eventually and globally are defined as ♦ I φ ≡ U I φ and I φ ≡ ¬♦ I ¬φ, respectively, where I is an interval. The set of all STL formulae over signals in S is denoted by Φ S . The STL score, also known as robustness degree is a function ρ : S × Φ S × N → R, which is recursively defined as [7]: ρ(s, I φ, t) = min t ∈t+I ρ(s, φ, t ). (1) As one can inspect from (1), a signal satisfies an STL specification at a certain time if and only if its corresponding STL score is positive: |= is read as "satisfies". The case of ρ = 0 is usually left ambiguous -this is never a concern in practice due to issues with numerical precision. In this paper, we consider ρ = 0 as satisfaction, but by doing so, we sacrifice the principle of contradiction: s[t] |= φ and s[t] |= ¬φ if ρ(s, φ, t) = 0. The horizon of an STL formula is defined as the minimum length of the time window required to compute its score, and it is recursively computed as [24]: The set of all STL formulae over signals in S such that their horizons are less than T is denoted by Φ S T . Note that computing ρ(s, φ, t) requires s[t : t + φ ], and the rest of the values are irrelevant. Definition 1 (Bounded-Time Language): Given φ ∈ Φ S T , we define the bounded-time language as: (3) Note that L(φ) ⊂ R n(T +1) . When the predicates are rectangular, the bounded-time language becomes a finite union of hyper-rectangles in R n(T +1) .

III. METRICS
In this section, we introduce two functions d ST L : Φ S T × Φ S T → R ≥0 that quantify the dissimilarity between the properties captured by the two STL formulae. However, it is possible that different formulae may describe the same properties. For example, φ 1 and φ 4 in (4) are describing the same behavior, since any signal that satisfies φ 1 already satisfies φ 4 and vice versa. The key idea is to define the distance between two STL formulae as the distance between their time-bounded languages.
Assumption 1: The set S ⊂ R n is compact. Assumption 2: All of the predicates are rectangular. Note that bounded-time languages are constructed in finitedimensional Euclidean spaces. Also, since all inequalities in the predicates are non-strict, bounded-time languages are compact sets. Assumption 2 is theoretically restrictive, but not in most applications -usually it is the case that all predicates are rectangular as they describe thresholds for state components of a system. Definition 2: We say that the two STL formulae φ 1 and φ 2 are semantically equivalent, denoted by φ 1 ≡ φ 2 , if both induce the same language: L(φ 1 ) = L(φ 2 ).

The set of equivalence classes of
is the induced metric, φ is the equivalence class associated with φ, and φ 1 and φ 2 are formulae in the two equivalence classes. Note that, by definition, there is a one-to-one map between the equivalence classes of STL formulae and their formulae.
We adapt two common metrics between sets: (a) the Pompeiu-Hausdorff (PH) distance based on the underlying metric between signals, and (b) a measure of Symmetric Difference (SD) between sets. As it will be clarified in the paper, the choice of T , as long as it is larger than the horizons of the formulae that are considered, does not affect the fundamental properties of the defined metrics. In the case of the PH distance, it does not have any effect at all. For the SD metric, the computed distances are scaled with respect to the inverse of T . These details are explained in Section III-B.

A. Pompeiu-Hausdorff Distance
Definition 3: The (undirected) PH distance is defined as: where d P H denotes the directed PH distance: Note that the directed PH distance is obviously not a metric as it is possible to have Another way to interpret the PH distance is as follows [17]: T ]}, and addition of sets is interpreted in the Minkowski sense. In words, d P H (φ 1 , φ 2 ) is the radius of the minimum ball that should be added to L(φ 2 ) such that it contains L(φ 1 ).
) -remember that languages are compact subsets of finite dimensional Euclidean space, for which it is known that the PH distance is a metric [17]. Moreover, there is a one to one map between an equivalency class formula of a formula in Φ S T / ≡ and its language.
It is possible to interpret (6) as the distance between an STL formula and a signal: d P H (s, φ) := min s ∈L(φ) d(s, s ). It is easy to see that we have d P H (s, φ) = 0 if and only if s ∈ L(φ). The following result is a reformulation of Definition 23 in [8], which establishes a connection between the STL score and the notion of signed distance. Proposition 2: Given any φ ∈ Φ S T and s ∈ S T , the STL score is a signed distance in the sense that: The following results are extensions of classical results for signed distances [25]. Corollary 1: For any given two formulae φ 1 , φ 2 ∈ Φ S T and a signal s ∈ S T , we have the following inequalities:

B. Symmetric Difference
The SD is denoted by , and defined as , where X and Y are two sets. It induces a distance between compact sets as the measure of the SD [18].
Definition 4: The SD metric is defined as: where | · | is the Lebesgue measure.
Proof: Follows immediately from the definition. The metric is well-defined since the formulae have time horizons bounded by T over discrete-time signals. Their languages are compact subsets of the Euclidean space R n(T +1) . Thus, the Lebesgue measure is defined.
We define the coverage of signal sets in the space-time value set. Formally, we have the map P : For an STL formula φ, P(φ) = P(L(φ)).
Let S = U n , and p = x i ≤ µ be a rectangular predicate with µ ∈ U and i ∈ {1, . . . , n}. The coverage of p is P Theorem 1: If φ 1 and φ 2 are two STL formulae with the same language, then they cover the same space. Formally, we have L(φ 1 ) = L(φ 2 ) implies P(φ 1 ) = P(φ 2 ).
Proof: Immediately follows from the fact that P is a projection of L(φ) onto space-time S × T U.
Note that the converse is not true in general. In particular, it can fail for formulae containing disjunctions.

C. Comparison
While the PH distance and the SD difference are both metrics, they have quite different behaviors. Here, we elaborate on these differences and show an illustrative example.
Informally, the PH distance has a stronger spatial notion, and it is closely connected to STL score, as stated in Corollary 1 and Corollary 2. The PH distance, captures the worst-case spatial difference between formulae. On the other hand, the SD is a more temporal notion, as the areas also capture the length of temporal operators. It is possible that two STL formulae have a large PH distance, but a small SD distance, and vice versa. In applications, the choice is dependent on the user. The most useful may be a convex combination -which is a metric by itself -with a user-given convex coefficient.
Example 2: Consider the six STL formulae in (4). We compute the PH and the SD distances between all pairs of formulae using the methods proposed in Section IV. The directed PH distances are also reported.
1) Directed PH distance: The results are shown in Table I, where the value in the i'th row and j'th column is We have also included the truth constant in the distance table. It is observed that d P H (φ i , ) = 0, ∀i ∈ {1, · · · , 6}, which implies the fact that the language of each formula is contained within the language of , which is the set of all signals. The opposite direction, , which correspond to the extreme signal that one language contains but the other does not, or it is 0, indicating that one language is a subset of another. For instance, φ 3 is a "weak" specification in the sense that its language is broad -any signal with some value in θ 1 at some time satisfies it -so the directed distances from other formulae to φ 3 are zero. Another notable example is the relation between φ 1 and φ 4 . The directed PH distance is zero in both directions -the two formulae are equivalent. This is due to the fact that any signal that satisfies φ 4 , already satisfies φ 1 . The other direction also trivially holds. Note that some pairs, like φ 2 and φ 3 , have non-zero PH distances in both directions.
2) SD distance: The results are shown in Table II along with the PH distances for comparison. Here, it can be seen that in most cases, the SD distance is either a lot larger or a lot smaller than the PH distance. This is largely due to the fact that this metric is based on area which is particularly highlighted when comparing any of the formulae to . Since each formula's satisfaction space is very small in comparison to the entire bounded signal space, each of these values is quite large. In contrast, the SD distance between φ 1 and φ 5 is fairly small since the satisfaction regions for each of these formulae cover a similar area. The SD distance between φ 2 and φ 3 is on the larger side as their areas of satisfaction are quite different; however, these areas are still much closer to each other than they are to the entire bounded satisfaction area represented by . Similar to the PH distance, the SD distance between φ 1 and φ 4 is zero as they have completely overlapping areas of satisfaction.
The results in Table II illustrate that there are different situations when the PH distance might be favored over the SD distance and vice versa. In cases where one cares about the area covered by the satisfaction region of a formula, the SD distance should be used. For instance, the SD could be used to find a formula close to one that requires a signal to be held at a particular value for a long time interval. However, if one only cares about how close the signal bounds of the formulae are to each other, the PH distance should be used.

IV. COMPUTATION
This section presents algorithms for computing the PH and the SD distances between STL specifications.

A. Pompeiu-Hausdorff Distance
In this section, we propose an optimization-based method to compute the PH distance between two STL formulae.
Definition 5: Given an STL formula ϕ that contains no negation, we define ϕ + with the same logical structure as ϕ with predicates replaced as follows: Intuitively, ϕ + is a relaxed version of ϕ. It is easy to verify from (1) that if ρ(s, ϕ + , 0) = ρ(s, ϕ, 0) + , ∀s ∈ S T . Lemma 1: The following relation holds: The result is a direct consequence of (7) as we have L(ϕ + 2 ) = L(ϕ 2 ) + B S T . The following statement provides the main result, and the base for the computational method of this section.
Theorem 2: Given ϕ 1 , ϕ 2 ∈ Φ S T , L(ϕ 1 ) = ∅, define * as the following optimum: Then the following holds: Proof: First, consider the case that (10) is infeasible or its value is 0. Then, it means that the constraints s ∈ L(ϕ 1 ), s ∈ L(ϕ + 2 ) are infeasible for all > 0, which implies that for any s ∈ L(ϕ 1 ), we have ρ(s, L(ϕ 2 ), 0) ≥ 0. Thus, L(ϕ 1 ) ⊂ L(ϕ 2 ) and consequently d P H (ϕ 1 , ϕ 2 ) = 0. Now consider the case (10) is feasible and * > 0. Then, s |= ϕ * + 2 is an active constraint, which implies ρ(s, ϕ * + 2 , 0) = 0. Note that s is also optimized in (10). Thus ρ(s, ϕ 2 , 0) < 0, or s ∈ L(ϕ 2 ). We can rewrite (9) as: Note that we have used sup instead of max as L(ϕ 1 ) ⊆ L(ϕ + 2 ) is a strict relation. Also note that such the supremum exists as i) the condition is satisfied for = 0 and ii) the language sets are bounded. We show that (10) captures (12). If L(ϕ 1 ) ⊆ L(ϕ + 2 ), then it means that ∃s |= ϕ 1 but ρ(s, ϕ + 2 , 0) < 0. This is what is captured by the constant in (10), with the difference that ρ(s, ϕ + 2 , 0) < 0 is replaced by a non-strict inequality and sup is replaced by max. We convert (10) into a MILP problem. The procedure for converting STL into MILP constraints is straightforward, see, e.g., [26]. The encoding details are omitted here. By solving two MILPs, we are able to obtain the PH distance. Two MILPs can be aggregated into a single MILP, but that usually more than doubles the computation time due to larger branch and bound trees. Moreover, it is often useful to have the knowledge of the directed PH distances.
Theorem 2 requires that formulae do not contain negation. Negation elimination is straightforward: first, the formula is brought into its Negation Normal Form (NNF), where all negations appear before the predicates. Next, the predicates are negated. For example, we replace ¬(x ≤ µ) by (x ≥ µ). We remind the reader that we do not consider strict inequalities, hence ¬(x ≤ µ) and (x ≤ µ) are both true if x 0 = µ. Finally, observe that the choice of T does not effect the values of PH distance, as long as it is larger than the horizons of two formulae that are compared. Given φ 1 , φ 2 ∈ Φ S T , the values of s t for t > max{ φ 1 , φ 2 } do not have any associated constraints in (10).

Complexity
The complexity of (10) is exponential in the number of integers, which grows with the number of predicates and horizons of the formulae. However, since signal values do not have any dynamical constraints, we found solving (10) to be orders of magnitudes faster than comparable STL control problems, such as those studied in [26]. All the values obtained in Table I were evaluated almost instantaneously using Gurobi MILP solver on a personal computer.

B. Symmetric Difference
This section presents an algorithm for computing boxes representing the area of satisfaction of a formula as well as a method for determining the SD between two sets of boxes. Each set of boxes approximates the projection (P) of the formula and represents the valid value-space that a timevarying signal can take such that traces that are contained entirely within the boxes satisfy the formula.
Computing the set of boxes representing the area of satisfaction is a recursive process that takes as input an STL formula, φ, a set of max values, X max , for each signal, x ∈ X (used to normalize the signal values to a unit space), and a discretization threshold, δ. This algorithm, AoS, is presented in Algorithm 1 Here, box(t 1 , t 2 , creates a new box with minimum and maximum times t 1 and t 2 , minimum and maximum values x 1 and x 2 , and spatial dimension i ∈ {1, . . . , n}, respectively; overlap determines the time window of the overlap between two boxes; combine takes two boxes and produces a set of boxes representing the intersection of the overlapping time window region; b.lt, b.ut, b.lv ∈ S, and b.uv ∈ S return the lower time window, upper time window, lower variable, and upper variable values for box b, respectively; * in the definition of a box denotes that it may restrict multiple spatial dimensions; and the operator is used to create a "choice" set representing that either of the two sets separated by it can be selected as the set of boxes representing the area of satisfaction. if φ := x i ≤ π then return box(0, 0, 0, π/xmax, i) else if φ := x i > π then return box(0, 0, π/xmax, 1, i) To address the problem of projection of formulae containing disjunction (the converse to Theorem 1), AoS utilizes the operator. If this algorithm instead generated boxes representing the projection of all formulae, it would be possible for the satisfaction space represented by the boxes to capture signals that the original formula does not allow. The application in Section V highlights this problem and presents a way of dealing with it for that particular example.
For operators such as globally ( ), AoS is exact and produces boxes bound by the time bounds of the operator that represent the projection of the primitive. However, operators such as eventually (♦) do not immediately lend themselves to conversion into a set of boxes. In order to deal with this operator, we approximate it by converting it into a disjunction of globally predicates. Each globally predicate is generated using a small threshold value (δ) for its time window width. The new formula requires that the expression be true in at least one of the smaller time windows essentially introducing a mandatory δ "hold" time for eventually operators. The tunability of δ allows for a user to give up some accuracy for gains in performance of box computation and ultimately distance comparison. Examples of computing the area of satisfaction boxes for some of the formulae in Example 2 are shown in Figure 1.
The SD between two sets of boxes is computed by calculating the area of the sum of the non-intersected area for each box set. This value is normalized by the maximum time horizon, T , and results in the SD computation: Figure 1c visually illustrates how the SD between φ 1 and φ 5 is computed.
Note that the SD distance is scaled by T +1 T +T +1 if the maximum horizon is increased by T . This again shows the temporal nature of the SD as opposed to the PH distance which does not change.

Complexity
The complexity of Algorithm 1 depends on the complexity of the operation which may be exponential depending on how it is implemented. Otherwise, the algorithm is polynomial due to the box combination operations carried out whenever a conjunction predicate is encountered. In practice, computing the SD distance using this method for formulae with a few dozen predicates typically takes only a few seconds.

V. QUANTIFICATION OF DESIGN QUALITY
In our first application, we show an example of how the proposed metrics can be used in behavioral synthesis. Behavioral synthesis is an important process in design automation where the description of a desired behavior is interpreted and a system is created that implements the desired behavior. Our goal is to check if the characterized implementations satisfy the specifications of a system. Implementations include simulations and execution traces of a system. These implementations are characterized into formal specifications using TLI. We show that the proposed metrics can be used in the synthesis step to choose a design from the solution space that can best implement the desired specification. The specific example we have chosen to highlight this application is the synthesis of genetic circuits in synthetic biology.

Synthetic Genetic Circuit Synthesis
In this example, we have a set of desired behaviors (each formally represented by STL) which describe the various behaviors expected of a genetic circuit. This set of behaviors is referred to as a performance specification: S φ . S φ consists of 2 STL formulae: φ low and φ high which describe the desired amount of output produced by the genetic circuit over time: In this case, the output of the circuit corresponds to the expression of a fluorescent protein. φ low specifies that the output must consistently be below 40 units from time 0 to 300, and φ high specifies that that output must gradually increase over time and must end up between 150 and 320 units between time 200 and 300. Our solution space consists of two genetic circuits. The first circuit has a constitutive promoter as shown in Figure 2a. Constitutive expression removes flexibility for consistency allowing constant protein production independent of the state or inputs of the system, which is highlighted in Figure 2c. The second circuit has an inducible promoter: a sugar detecting transcription factor AraC*, which will turn on the protein production if and only if it is in the presence of a specific input molecule (arabinose) as shown in Figure 2b. Figure 2d shows the output of the circuit for various concentrations of arabinose. Both of these synthetic genetic circuits were built in Escherichia coli. The traces were obtained from biological experiments by measuring fluorescence. Our goal is to choose the circuit that can "satisfy as many behaviors as possible" in S φ . It is important to note here that it is difficult to express the term "satisfy as many behaviors Fig. 3: (a) shows the union of the areas of satisfaction for φ low and φ high . The vertical stripe and horizontal stripe areas represent P(φ low ) and P(φ high ), respectively. (b) shows the boxes created for B φ low ∪ B φ high . as possible" using the syntax and semantics of STL. For instance, expressing the desired specification as a disjunction of all the formulae in S φ would imply that satisfying any one specification is sufficient for the genetic circuit to satisfy the performance specification. Similarly, expressing the desired specification as a conjunction of all the formulae in S φ would imply that at any point in time, the output of a genetic circuit must have multiple distinct values, which is physically impossible.
This conundrum is highlighted in the current example. The output of constitutive expression satisfies φ low but cannot satisfy φ high . The induction circuit produces traces that can satisfy both φ low and φ high . However, traditional model checking techniques may not help a designer choose the desired circuit. Using statistical model checking, for example, the circuit with constitutive expression yields a satisfaction likelihood of 1.0 and the induction circuit yields a satisfaction likelihood of 0.83 when checked against φ low ∨ φ high . With these results, one might think that the circuit with constitutive expression best satisfies the performance specification.
To address the issue of satisfying as many behaviors as possible, we treat the performance specification's region of satisfaction as the union of the regions of satisfaction of all the formulae in S φ as shown in Figure 3a. We compute this region by taking the union of the generated boxes for each formula that are computed using Algorithm 1. The union of the box sets of all STL formulae in S φ is represented as B φ low ∪ B φ high = B S φ and is shown in Figure 3b.
Using Grid TLI [22], we produce STL formulae, φ con and φ ind , for each circuit using the traces shown in Figures 2c and 2d, respectively. We then use the SD metric and get the following values: d SD (B S φ , B φcon ) = 0.636 and d SD (B S φ , B φ ind ) = 0.304. Using the PH metric, we get: d P H (B S φ , B φcon ) = 0.067 and d P H (B S φ , B φ ind ) = 0. These results imply that the behavior of the induction circuit is closer to the desired specification than the circuit with constitutive expression, and thus, it should be selected as the desired circuit.

VI. LOSS FUNCTIONS FOR TLI
Loss functions play a fundamental role in statistical inference and learning theory. In this framework, we usually have a pair (X , Y) of real vector spaces corresponding to the state and observation spaces, respectively. Three ingredients are used in the formalization: (a) a model of the states p X (x)the prior distribution, (b) a model of the observations given the state p Y |X (y | x), and (c) a real-valued loss function L : X × X → R. Let h : Y → X be a decision rule, which can also be interpreted as a partition of the state space X based on observations, and H be the set of all decision rules or the hypothesis space. The frequentist and Bayesian risks are defined based on the loss functions, and induce optimal decision rules. This general framework is the basis for the study and design of decision algorithms in statistical inference and learning. For more details, see [27].
In the following, we show how we adapt this framework for TLI, where we use the proposed metrics, PH and SD, as loss functions. In this paper, we only focus on the loss functions, while characterization of optimal decision rules, their computation, and regularization are left for future work.
For TLI, the state space X = Φ S T is the set of all timebounded STL formulae, while the observation space Y = 2 S T is the set of all languages. The hypothesis space H is composed of decision rules that map languages to STL formulae. Lastly, the loss functions are defined as L ST L : represents the dissimilarity between the ground truth formula φ and the STL formula obtained by the decision rule using the signal set S ⊆ S T . We propose to use the PH and the SD metrics as loss functions L ST L .
We assess the performance of the two decision rules from TLI: TreeTLI [21] based on decision trees, and GridTLI [22] based on minimum covers of signals in space-time S×[0, T ], with respect to the two metrics as shown in Figure 4b.
The results in Figure 4b show the distances between the ground truth formula φ GT and the iterations of TreeTLI (lower plot) as the decision tree grows [21]. For GridTLI (upper plot), we varied the discretization thresholds [22] from rougher to finer grids, δ s ∈ {0.5, 0.45, . . . , 0.1} and δ t ∈ {5, 4.5, . . . , 1} for space and time, respectively. The upper plot for GridTLI highlights the over-fitting phenomenon in the PH metric (red), where reducing the discretization thresholds helps reducing the error, but further reduction leads to over-fitting. For the SD (blue), the loss has a decreasing trend which we hypothesize is due to a better temporal fitting that the PH distance does not capture. In the case of TreeTLI (lower plot), the PH distance (red) is constant. This masking behavior might be due to the compounding effect of i) the primitives used do not match the structure of φ GT , and ii) the  Fig. 4: (a) shows the blue positive, and red and orange negative example signals used by the two TLI algorithms. The positive signals start in the gray region, and end in one of the black regions. The red negative signals do not start in the gray region, while the orange ones do not end in the black regions. (b) shows the PH and the SD distances between the ground truth formula φGR and the learned formulae using GridTLI and TreeTLI, respectively. incremental and local nature of TreeTLI. Thus, the first step of the decision tree is heavily penalized by the PH metric. The SD metric (blue), which shows an increasing trend, is consistent with this conclusion.
Thus, the statistical learning approach to TLI gives insight into the ability of algorithms to recover temporal logic rules assumed to underlie data. It also provides a formal framework to study TLI methods. A detailed account of problems GridTLI and TreeTLI are appropriate for based on the insights provided by the proposed metrics is left for future work.

VII. DISCUSSION AND FUTURE WORK
We presented two metrics for computing the distance of one STL formula to another. These methods are very useful in applications where temporal logic specifications are mined from simulation or experimental data, and need to be compared against a desired specification. Fields such as synthetic biology and robotics, where systems are characterized with performance specifications, can greatly benefit from our methods. We also showed how these metrics are useful as a first step in evaluating the performance of TLI methods.
An immediate theoretical extension is studying continuous-time signals. By assuming Lipschitz continuity of signals, it is possible to provide bounds between the metrics computed in discrete-time and the ones in continuous-time. A similar idea was used in [8] to compute sampled-time STL scores. The second extension is relaxing the assumption on rectangular predicates.