Learning Signal Temporal Logic through Neural Network for
Interpretable Classification
Danyang Li1, Mingyu Cai2, Cristian-Ioan Vasile2, Roberto Tron1
Abstract— Machine learning techniques using neural net-
works have achieved promising success for time-series data
classification. However, the models that they produce are
challenging to verify and interpret. In this paper, we propose an
explainable neural-symbolic framework for the classification of
time-series behaviors. In particular, we use an expressive formal
language, namely Signal Temporal Logic (STL), to constrain
the search of the computation graph for a neural network.
We design a novel time function and sparse softmax function
to improve the soundness and precision of the neural-STL
framework. As a result, we can efficiently learn a compact STL
formula for the classification of time-series data through off-the-
shelf gradient-based tools. We demonstrate the computational
efficiency, compactness, and interpretability of the proposed
method through driving scenarios and naval surveillance case
studies, compared with state-of-the-art baselines.
I. INTRODUCTION
Binary classification is a standard task in Supervised
Machine Learning (ML). Many techniques such as K-Nearest
Neighbors (KNN), Supported Vector Machine (SVM), and
Random Forest can be employed. A particular version of
the procedure introduces data derived from the evolution of
dynamic systems, which are in the form of time-series data;
this task can still be challenging for the current state-of-the-art
ML algorithm.
In recent years, deep learning (DL) methods have achieved
great success in complex pattern recognition, with a variety
of architectures such as convolutional [1], recurrent [2],
etc. However, the common drawback of DL and other ML
techniques is the lack of human-interpretability of the learned
models. This property is very important in control and robotics
since it can support qualitative and quantitative analysis.
In this paper, we propose to use the rich expressivity of
Signal Temporal Logic (STL) [3] for training classification
of symbolic neural networks.
Signal Temporal Logic (STL) is a formal language designed
to express rich and human-interpretable specifications over
time series. Its quantitative satisfaction can be measured via
a recursive definition of robustness [3], which can be used in
control optimization problems [4] and sequential predication
task [5]. The task of learning STL formulas for classification
also leverages the robustness to formulate an optimization
problem. Previous attempts [6]–[8] for learning temporal
logic properties assumed fixed formula structures. Decision
1
Danyang Li and Roberto Tron are with Mechanical Engi-
neering Department, Boston University, Boston, MA 02215, USA.
danyangl@bu.edu, tron@bu.edu
2
M. Cai and C.I. Vasile are with the Department of Mechanical
Engineering and Mechanics, Lehigh University, Bethlehem, PA, USA
mingyu-cai@lehigh.edu, cvasile@lehigh.edu
tree based approaches [9]–[13] are proposed to learn both
operators and parameters via growing logic branches. The
branches growing of decision trees increases as the structure
of desired STL formula becomes more complicated. To the
best of our knowledge, the training time for the decision
tree based method is in order of minutes while the temporal
logic neural network can achieve order of seconds. To learn
temporal logic formulas from scratch, developing logic neural
networks [14], [15] attracts more attention. However, the
max/min operations in the computation of robustness are
not continuously differentiable. These operations cannot be
directly applied in a neural network since the network is not
able to learn with it.
Related works: Many works use STL for classification.
Some works [16]–[20] use the recursive definition of the STL
and the structure of multi-layer neural networks, allowing
to directly apply off-the-shelf gradient-based deep learning
software. This kind of work can be divided into two categories
i.e., template-free and template-based learning. Intuitively,
template-based learning [16]–[19] fixes the STL formula to be
learned from data and only learns some parameters. Whereas
template-free learning [20] learns the overall STL formula
including its structure from scratch. Our work uses this latter
category.
To address the non-smooth issues of the original STL
robustness [3], the differentiable versions of robustness
computation were proposed in [16], [18], which, however,
can not guarantee the soundness properties of STL and
the accuracy of satisfaction. The work [20] proposes an
alternative formulation that uses arithmetic-geometric mean
(AGM) STL robustness [21]. The AGM robustness is not
continuous and can not directly be backpropagated in a neural
network, resulting in problems of efficiency and adaptation
to gradient-based tools. In addition, both works [18], [20]
learn a weighted STL (wSTL) [22] that is harder for a user
to interpret if the complex weights are not manually omitted.
Contributions: First, we propose a template-free neural
network architecture with given fragments for the classifica-
tion of time-series signals. The network can be interpreted
as level-one STL formulae. Our proposed models rely on
novel activation functions, especially on two new components:
a compact way to represent time intervals for temporal
operators, and a sound, differentiable approximation to
the maximum operator. As an additional contribution, we
introduce a synthetic dataset containing prototypical behaviors
inspired by autonomous driving situations. We use this dataset
to evaluate the performance of our methods, showing that we
are able to achieve high efficiency and automatically extract
arXiv:2210.01910v2 [cs.FL] 30 Jun 2023