Elsevier

Theoretical Computer Science

Volume 857, 12 February 2021, Pages 29-42
Theoretical Computer Science

Temporal logic specification mining of programs

https://doi.org/10.1016/j.tcs.2020.12.032Get rights and content

Highlights

  • A PPTL specification mining approach is proposed.

  • A tool PPTLMiner is developed.

  • An open and user-editable pattern library is built.

Abstract

This paper proposes a dynamic approach of specification mining for Propositional Projection Temporal Logic (PPTL). To this end, a pattern library is built to collect some common temporal relation among events. Further, several algorithms of specification mining for PPTL are designed. With our approach, PPTL specifications are mined from a trace set of a target program by using patterns in the library. In addition, a specification mining tool PPTLMiner supporting this approach is developed. In practice, given a trace set and user selected patterns, PPTLMiner can capture PPTL specifications of target programs.

Introduction

A software system specification is a formal description of the system requirements. Formal languages are often employed to write specifications so as to prevent the ambiguity written in natural languages. The common used formal languages include Temporal Logic (TL) and Finite State Automata (FSA). Software system specification can be used to test and verify the correctness and reliability of software systems [13], [24], [26]. However, due to various kinds of reasons, a great number of software systems lack formal specifications. In particular, for most of legacy software systems, formal specifications are missed. This makes the maintenance of software systems difficult. To fight this problem, various kinds of specification mining approaches are proposed [3], [9], [10], [11], [12], [14], [15], [16], [18], [21], [22], [23], [25].

Walkinshaw et al. [22] present a semi-automated approach to inferring FSAs from dynamic execution traces that builds on the QSM algorithm [7]. This algorithm infers a finite state automaton by successively merging states. Lo et al. propose Deep Specification Miner (DSM) approach that performs deep learning for mining FSA-based specifications [11]. FSA specifications are intuitive and easily to be used for verifying and testing programs. However, most of FSA specification mining approaches suffer from accuracy and correctness for representing properties of programs. Yang et al. [25] present an interesting work on mining two-event temporal logic rules (i.e., of the form G(aXF(b)), where G, X and F are LTL operators, which are statistically significant with respect to a user-defined “satisfaction rate”. Wasylkowski et al. [23] mine temporal rules as Computational Tree Logic (CTL) properties by leveraging a model checking algorithm and using concept analysis. Lemieux et al. [12] propose an approach to mine LTL properties of arbitrary length and complexity. Similar to the above research work, most of specification mining approaches employ LTL and CTL as the property description languages. Due to the limitation of the expressiveness of LTL and CTL, some temporal properties such as periodic repetition properties cannot be characterized.

Since the expressiveness of Propositional Projection Temporal Logic (PPTL) is full regular [20], in this paper, we propose a dynamic approach to mining PPTL properties based on a pattern library. PPTL contains two primitive temporal operators: next (◯) and projection (prj). Apart from some common temporal properties that can be formalized in LTL and CTL, PPTL is able to describe two other kinds of properties: interval sensitive properties and periodic repetition properties. With the proposed approach, we abstract API/method calls as events. A trace is a sequence of API/method calls occurred during program execution. Daikon [1] is used to generate raw traces first, then a tool DtraceFilter we developed is employed to further refine the traces. Patterns are used to characterize common temporal relations among events. Two categories of patterns, Occurrence and Order, are used. These patterns are predefined in a pattern library. The proposed mining algorithms require two inputs: an instantiated pattern formula P and a refined execution trace τ. To obtain an instantiated pattern formula, we need to specify a pattern formula which can be either a user-defined one or a predefined one in the library. The pattern is instantiated by substituting atomic propositions with concrete events. After pattern instantiation, several mining algorithms based on PPTL normal form [5], [6] are employed to recursively check whether τ satisfies P.

The contribution of the paper is three-fold. First, we propose a PPTL temporal rule specification mining approach so that full regular properties can be mined. Second, we develop a tool PPTLMiner which supports the proposed mining approach. Third, we build a pattern library to cover all common patterns accumulated from literatures and abstracted from the existing software systems. The library is open and user-editable.

This paper is organized as follows. In the next section, PPTL is briefly introduced. In section 3, the trace generation and the construction of the pattern library are presented. In section 4, the overall framework of PPTLMiner and key algorithms are elaborated. In section 5, an example is given to show how PPTLMiner works. In section 6, related work is discussed. Finally, conclusions are drawn in section 7.

Section snippets

Propositional projection temporal logic

In this section, we briefly introduce our underlying logic, Propositional Projection Temporal Logic (PPTL), including its syntax and semantics. It is used to describe specifications of programs. For more detail, please refer to [4].

Syntax of PPTL Let Prop be a set of atomic propositions and pProp. The syntax of PPTL is inductively defined as follows.P::=p|P|¬P|PQ|(P1,...,Pm)prjQ|P+ where P1,...,Pm,P and Q are well-formed PPTL formulas. Here, ◯ (next) and prj (projection) are primitive

Pattern library construction and trace generation

Our specification mining algorithm relies on two inputs: a pattern and a program execution trace. A pattern is a property template in which the atomic proposition symbols need to be instantiated as events (namely, API or method calls) occurred during program execution. A trace is a sequence of method calls in the execution of a program. In this section, we present how to build the pattern library and traces.

PPTL specification mining

Based on the Pattern Library and set of refined traces presented in the previous section, an approach to PPTL specification mining is proposed and a specification mining tool, PPTLMiner, is developed. In this section, the framework of PPTLMiner and some key algorithms are presented in detail.

An example

In the following, an example is given to demonstrate the proposed mining approach. The pattern we choose is Precedence(11) in Table 4.

PPTL pattern Formula: Event s takes precedence over event p.P:p(¬p;s) Trace: The following are two short traces.τ1=open,read,write,read,read,write,write,read,write,closeτ2=open,write,read,write,write,write,read,write,read,close Mining process:

Step 1. Building the event set

By checking two traces τ1 and τ2, we obtain event set E={open,read,write,close}.

Step

Related work

Temporal rules mining is a branch in specification mining. There exist numerous temporal property mining approaches using various kinds of logic languages. These approaches have one thing in common, that is, they all use rules represented by temporal logic formulas as constraints which we call patterns to mine specifications.

David Lo et al. [14] propose algorithms to mine closed frequent iterative patterns and non-redundant significant recurrent rules from a sequence database collecting program

Conclusion

This paper presents an approach to mining PPTL specification from program execution traces. A tool PPTLMiner has been developed to support the proposed approach. This allows us to mine full regular temporal rules represented by PPTL formulas from traces. However, a mined PPTL formula has to be checked over all traces so as to ensure its validity. This is not a easy job since there might be error traces involved.

In the future, we will investigate how to evaluate the mined properties so that

Declaration of Competing Interest

The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.

References (26)

  • O. Iegorov et al.

    Mining task precedence graphs from real-time embedded system traces

  • S. Konrad et al.

    Facilitating the construction of specification pattern-based properties

  • T.B. Le et al.

    Deep specification mining

  • Cited by (0)

    This research is supported by National Key Research and Development Program of China under Grant No. 2018AAA0103202, National Natural Science Foundation of China under Grant Nos. 61751207 and 61732013, and Shaanxi Key Science and Technology Innovation Team Project under Grant No. 2019TD-001.

    View full text