11email: yuanruizhang@nuaa.edu.cn, zhangyrmath@126.com
Parameterized Dynamic Logic — Towards A Cyclic Logical Framework for General Program Specification and Verification
Abstract
We present a theory of parameterized dynamic logic, namely , for specifying and reasoning about a rich set of program models based on their transitional behaviours. Different from most dynamic logics that deal with regular expressions or a particular type of formalisms, introduces a type of labels called “program configurations” as explicit program status for symbolic executions, allowing programs and formulas to be of arbitrary forms according to interested domains. This characteristic empowers dynamic logical formulas with a direct support of symbolic-execution-based reasoning, while still maintaining reasoning based on syntactic structures in traditional dynamic logics through a rule-lifting process. We propose a proof system and build a cyclic preproof structure special for , which guarantees the soundness of infinite proof trees induced by symbolically executing programs with explicit/implicit loop structures. The soundness of is formally analyzed and proved. provides a flexible verification framework based on the theories of dynamic logics. It helps reduce the burden of developing different dynamic-logic theories for different programs, and save the additional transformations in the derivations of non-compositional programs. We give some examples of instantiations of in particular domains, showing the potential and advantages of using in practical usage.
Keywords:
Dynamic Logic Program Deduction Logical Framework Cyclic Proof Symbolic Execution1 Introduction
1.1 Background and Motivations
Program verification based on theorem proving has become a hot topic recently, especially with the rapid development of AI-assisted technologies that can greatly enhance the automation of interactive proof processes [39].
Dynamic logic [20] is an extension of modal logic for reasoning about programs. Here, the term ‘program’ can mean an abstract formal model, not necessarily an explicit computer program. In dynamic logic, a program is embedded into a modality in a form of , meaning that after all executions of , formula holds. Formula exactly captures partial correctness of programs expressed by triple in Hoare logic [22]. Essentially, verification in dynamic logic is a process of continuously altering the form based on how evolves according to its semantics. This characteristic brings an advantage of clearly observing programs’ behavioral changes throughout the whole verification processes. With a dynamic form that mixes programs and formulas, dynamic logic is able to express many complex program properties such as , expressing that after all executions of , there is an execution of after which holds (where is the dual operator of with defined as ). As one of popular logical formalisms, dynamic logic has been used for many types of programs, such as process algebras [5], programming languages [4], synchronous systems [43, 42], hybrid systems [31, 32] and probabilistic systems [30, 24, 14]. Because of modality , it is a natural candidate for unifying correctness and ‘incorrectness’ reasoning recently proposed and developed in work e.g. [29, 44].
The programs of dynamic logics are usually (tailored) regular expressions with tests (e.g. [15, 31]) or actual programming languages like Java [4]. The denotational semantics of these models is usually compositional, in the sense that the deductions of the logics mean to dissolve the syntactic structures of these models. For example, in propositional dynamic logic (PDL) [15], to prove a formula , we prove both formulas and , where and are sub-regular-expressions of . This so-called ‘divide-and-conquer’ approach to program verification has brought numerous benefits, the most significant being its ability to scale verifications by allowing parts of programs to be skipped (see an example in Section 4.2).
However, this typical structure-based reasoning heavily relies on programs’ denotational semantics, thus brings two major drawbacks:
Firstly, dynamic logics are some special theories aiming for particular domains. Thus for a new type of programs, one needs to either perform a transformation from target programs into the program models of a dynamic logic so that existing inference rules can be utilized, or carefully design a set of particular rules to adapt the new programs’ semantics. The former usually means losses of partial program structural information during the transformations, while the latter often demands a large amount of work. For example, Verifiable C [1], a famous program verifier for C programming language based on Hoare logic, used nearly 40,000 lines of Coq code to define the logic theory.
Secondly but importantly as well, some programs are naturally non-compositional or do not temporally provide a compositional semantics at some level of system design. Typical examples are neural networks [18], automata-based system models (e.g. a transition model of AADL [40]) and some programming languages (as we will see soon). For these models, one can only re-formalize their structures by additional transformation procedures so that structure-based reasoning is possible. One example is synchronous imperative programming languages such as Esterel [6] and Quartz [17]. In a synchronous parallel program , the executions of and cannot be reasoned independently because the concurrent executions at each instance are generally not true interleaving. To maintain the consistency of synchrony, events in one instance have to be arranged in a special order, which makes symbolic executions of as a whole a necessary step in program derivations. We will see an example in Appendix 0.C.
In this paper, to compensate for the above two shortcomings in existing dynamic-logic theories, we present a theory of parameterized dynamic logic (). supports a general approach for specification and verification of computer programs and system models. On one hand, offers an abstract-leveled setting for describing a broad set of programs and formulas, and is empowered to support a symbolic-execution-based reasoning based on a set of program transitions, called “program behaviours”. This reduces the burden of developing different dynamic-logic theories for different programs, and saves the additional transformations in the derivations of non-compositional programs. On the other hand, ’s forms are still compatible with the existing structural rules of dynamic logics through a lifting process. This makes subsume (at least partial) existing dynamic-logic theories into a single logical framework.
1.2 Illustration of Main Idea
Informally, in we treat dynamic formula as a ‘parameterized’ one in which program and formula can be of arbitrary forms, provided with a structure called “program configuration” to record current program status for programs’ symbolic executions. So, a dynamic formula is of the form: , following a convention of labeled formulas. It expresses the same meaning as in traditional dynamic logics, except that program status is shown explicitly alongside .
To see how formulas are powerful for supporting both symbolic-execution-based and structure-based reasoning, consider a simple example. We prove a formula in first-order dynamic logic [19] (FODL), where is a variable ranging over the set of integer numbers. Intuitively, means that if holds, then holds after the execution of the assignment . In FODL, to derive formula , we apply the structural rule:
for assignment on formula by substituting of with , and obtain . Formula thus becomes , which is true for any integer number .
While in , formula can be expressed as a form: , where formula is labeled by configuration , capturing the current program status with a free variable, meaning “variable has value ”. This form may seem tedious at first sight. But one soon can find out that with a configuration explicitly showing up, to derive formula , we no longer need rule , but instead can directly perform a program transition of as: 111note that to distinguish ‘’ and ‘’, which assign ’s value with its current value added by . Here indicates a program termination. Formula thus becomes , which is actually by eliminating the dynamic part ‘’ since behaves nothing. By applying configuration on formula (which means replacing variable of with its value in ), we obtain the same valid formula : (modulo the free variables ).
The above derivations of formulas benefit from that for many programs, transitions like are natural from their operational semantics and can be easily formalized (as will be seen in Appendix 0.B), while structural rules like would consume more efforts to design. And there might exists no structural rules in certain cases, as will be illustrated in the example of Esterel programs in Appendix 0.C.
With the labels structurally independent from their dynamic formulas , formulas also support programs’ structural rules through a so-called “lifting process” (Section 3.4). This capability provides with a flexible framework in which different inference rules can be applied to make a trade-off between symbolic-execution-based and structure-based reasoning in practical deduction processes. For example, here, to derive the formula above, one can also apply a lifted rule from rule :
by fixing , and then becomes , which is also formula : after applying configuration on formula .
1.3 Main Contributions
In this paper, different from the traditional approach that relies on Kripke structures (cf. [20]), we give the semantics of directly based on the program behaviours of target programs.
After building the logic, we propose a proof system for , providing a set of rules for reasoning about general programs based on program behaviours. To provide compatibilities of with existing dynamic-logic theories, we propose a lifting process for introducing additional structural rules from particular program domains.
Unlike the derivation processes based on dissolving program structures, deriving a formula may lead to an infinite proof tree. We develop a cyclic proof (cf. [10]) approach for . Generally, cyclic proof is a technique to ensure that a certain infinite proof tree, called ‘preproof’, can lead to a valid conclusion if it is ‘cyclic’, that is, containing a certain type of derivation traces (Definition 5). Cyclic proof system provides a solution for reasoning about programs with implicit loop structures and well supports the symbolic-execution-based reasoning of formulas. We propose a “cyclic preproof” structure for (Definition 6) and prove that it is sound under certain conditions.
To summarize, our contributions are mainly three folds:
-
•
We give the syntax and semantics of formulas.
-
•
We build a proof system for .
-
•
We construct a cyclic preproof structure for and prove its soundness.
The rest of the paper is organized as follows. Section 2 defines the syntax and semantics of formulas. In Section 3, we propose a cyclic proof system for . In Section 4, we show how can be useful as a verification framework by giving some examples. Section 5 analyzes and proves the soundness of . Section 6 introduces some previous work that is closely related to ours, while Section 7 makes some discussions and talks about future work.
2 Dynamic Logic
In this section, we mainly define the syntax and semantics of . What mostly distinguishes from other dynamic logics is that its programs and formulas are not in particular forms, but instead can be of any forms, only provided that some restrictions (see Definition 1) are respected. Program configurations are introduced in as explicit program status for describing program behaviours, enabling reasoning directly through symbolic executions. In Section 2.1, we introduce the basic settings for the ingredients of . They are prerequisites for formally defining . In Section 2.2 we introduce two examples of instantiations of program structures of which will be used throughout this paper to illustrate our ideas. Section 2.3 introduces the notion of program behaviours and its restriction under which this current work is concerned. In Section 2.4, we formally define the syntax and semantics of .
2.1 Programs, Configurations and Formulas
The construction of is based on a set of terms defined over a set of variables and a set of signatures. In , we distinguish three subsets and , representing the sets of programs, configurations and formulas respectively. . We use to represent the identical equivalence between two terms in . A function is called structural (w.r.t. ) if it satisfies that for any ary signature (, ary signature is a constant) and term with , for some structural functions . Naturally, we assume that a structural function always maps a term to a term with the same type: and .
In , there is one distinguished program , called termination. It indicates a completion of executions of a program.
Program configurations have impacts on formulas. We assume that is associated with a function , called configuration interpretation, that returns a formula by applying a configuration on a formula.
An evaluation is a structural function that maps each formula to a proposition — a special formula that has a boolean semantics of either truth (represented as ) or falsehood (represented as ). We denote the set of all propositions as . . The boolean semantics of formulas is expressed by function . forms the semantical domain as the basis for defining . An evaluation satisfies a formula , denoted by , if . A formula is valid, denoted by , if for all .
In the rest of this paper, we call program domain a special instantiation of structure for terms , evaluations and functions .
2.2 Examples of Program Domains
We consider two instantiated program domains, namely and . Table 1 depicts two program models in these domains respectively: a While program and an Esterel program . Below we only give an informal explanation of relevant structures, but at the same time providing comprehensive formal definitions in Appendix 0.B for While programs, in case readers want to know more details.
In these two program domains, the sets of variables are denoted by and respectively. In program WP, variables are , whose domain is the set of integer numbers . In program E, variables are and . is also called a “local variable”, with as its domain. Signal is a special variable distinguished from local variables, whose domain is , with to express ‘not-happened’ of a signal (also called ‘absence’). Intuitively, assignment means assigning the value of an expression to a variable . Signal emission means assigning the value of an expression to a signal variable and broadcasts the value. A mapping of a configuration means that variable has the value of expression . Formulas are first-order logical formulas in the domain or with arithmetical expressions. Examples are , , , etc.
A configuration of a While program is a variable storage in which each variable has a unique value of an expression. For example, a configuration has variable storing value and variable storing value . On the other hand, a configuration of an Esterel program is a variable stack, allowing several (local) variables with the same name. For example, represents a configuration in which there are 3 variables: , and two s storing different values. The separator ‘’ instead of ‘,’ is used to distinguish from a configuration of a While program, with the right-most side as the top of the stack.
“Free variables” are those occurrences of variables that are not in the effect scope of any binders, such as the assignment , or quantifiers . Let () return the set of all free variables of a term. For example, in program WP, variable of expression in and variable of expression in are bound by the assignments: and respectively, while variable is free in formula and in expression of assignment . So . In a configuration, while mapping is a binder for labeled formulas (as defined in Appendix 0.B), a variable in an expression of a mapping is always free, since interpretation introduced below is simply a type of substitutions.
An evaluation ( or ) returns a “closed term” (terms without free variables) by replacing each free variable of term with a value in or . For example, if , then . is a proposition with a boolean semantics: in the theory of integer numbers. A substitution replaces each free variable of with term .
Given a configuration and a formula , in a While program, the interpretation is defined as a type of substitutions (see Appendix 0.B). It replaces each free variable of with its value stored in . For example, . In an Esterel program, on the other hand, the interpretation replaces each free variable of with the value of the top-most variable in . For instance, (by taking the value of the right ).
A While program: WP Configuration: An Esterel program: where Configuration:
2.3 Program Behaviours
Program Behaviours. A program state is a pair of programs and configurations. In , we assume a binary relation called a program transition between two program states and . For any evaluation , proposition is assumed to be defined as: . Program behaviours, denoted by , is the set of all true program transitions:
which is assumed to be well-defined in the sense that there is no true transitions of the form: from a terminal program.
A path over is a finite or infinite sequence: (), where for each pair (), is a true program transition. A path is terminal, if it ends with program in the form of (). We call a path minimum, in the sense that in it there is no two identical program states. A state is called terminal, if from there is a terminal path over .
In order to reason about termination of a program, in we assume a unary operator called the termination of a program state . For an evaluation , proposition is defined as: . if there exists a terminal path over starting from . We use to denote the set of all true program terminations: .
For programming languages, usually, program behaviours (also program terminations ) are defined as structural operational semantics [33] of Plotkin’s style expressed as a set of rules, in a manner that a transition only when it can be inferred according to these rules in a finite number of steps. Appendix 0.B gives an example of the operational semantics of While programs (Table 6).
Example 1 (Examples of Program Behaviours)
In the example of Table 1, we have a program transition , where , by executing assignment . This transition is also a program behaviour, since it matches the operational semantics of (see Table 6 of Appendix 0.B for more details). However, transition is not a proposition, because its truth value depends on whether is true.
Restrictions on Program Behaviours. In this paper, our current research on the proof system of (Section 3) confines us to only consider a certain type of programs whose behaviours satisfy the following properties. We simply call them program properties.
Definition 1 (Properties of Program Behaviours)
In program behaviours , it satisfies that for each program state , the following properties hold:
-
1.
Branching Finiteness. From , there exists only a finite number of transitions.
-
2.
Termination Finiteness. From , there is only a finite number of minimum terminal paths.
The currently discussed programs restricted by Definition 1 are actually a rich set, including, for example, all deterministic programs (i.e., there is only one transition from any closed program state) and programs with finite state spaces (i.e., from each closed program state, only a finite number of closed program states can be reached). While programs and Esterel programs introduced in Table 1 above are both deterministic programs. They satisfy the program properties in Definition 1.
However, there exist types of programs that do not satisfy (some of) these program properties. For example, hybrid programs (cf. [31]) with continuous behaviours do not satisfy branching finiteness. Some non-deterministic programs, like probabilistic programs [2], do not satisfy termination finiteness. More future work will focus on relaxing these conditions to include a wider range of programs.
2.4 Syntax and Semantics of
Based on the assumed sets and , we give the syntax of as follows.
Definition 2 ( Formulas)
A parameterized dynamic logical () formula is defined as follows in BNF form:
where , and .
We denote the set of formulas as .
and are called the label and the unlabeled part of formula respectively. We call the dynamic part of a formula, and call a formula having dynamic parts a dynamic formula. Intuitively, formula means that after all executions of program , formula holds. is the dual operator of . Formula can be written as . Other formulas with logical connectives such as and can be expressed by formulas with and accordingly. Formula means that holds under configuration , as has an impact on the semantics of formulas as indicated by interpretation .
The semantics of a traditional dynamic logic is based on a Kripke structure [20], in which programs are interpreted as a set of world pairs and logical formulas are interpreted as a set of worlds. In , we define the semantics by extending and from Section 2.1 to formulas and directly base on program behaviours .
Definition 3 (Semantics of Formulas)
An evaluation structurally maps a formula into a proposition, whose truth value is defined inductively as follows by extending :
-
1.
is already defined, if ;
-
2.
, if and ;
-
3.
;
-
4.
;
-
5.
, if for all terminal paths () over with , ;
-
6.
, if ;
-
7.
, if both and ;
-
8.
for any , otherwise.
For any , write if , or simply .
Notice that for a formula , how is defined explicitly can vary from case to case. In Definition 3, we only assume that is structural and must be a proposition. An example of evaluation is given in Appendix 0.B.
According to the semantics of operator , we can have that iff there exists a terminal path () over with such that .
A formula is called valid, if for all evaluation .
3 A Cyclic Proof System for
In this section, we propose a cyclic proof system for . In Section 3.2, we firstly propose a proof system to support reasoning based on program behaviours. Then in Section 3.3 we construct a cyclic preproof structure for , which support deriving infinite proof trees under certain soundness conditions. In Section 3.4, we propose a lifting process to allow support reasoning with existing rules from particular dynamic-logic theories. Section 3.1 introduces the notion of sequent calculus.
3.1 Sequent Calculus
Sequents. In this paper, we adopt sequents [16] as the derivation form of . Sequent is convenient for goal-directed reversed derivation procedure which many general theorem provers, such as Coq and Isabelle, are based on.
A sequent is a logical argumentation of the form:
where and are finite multi-sets of formulas split by an arrow , called the left side and the right side of the sequent respectively. We use dot to express or when they are empty sets. A sequent expresses the formula , denoted by , meaning that if all formulas in hold, then one of formulas in holds.
Inference Rules. An inference rule is of the form
where each of () is also called a node. Each of is called a premise, and is called the conclusion, of the rule. The semantics of the rule is that if the validity of formulas implies the validity of formula . A formula pair () with formula in node and formula in node is called a conclusion-premise (CP) pair.
We use a double-lined inference form:
to represent both rules
provided any sets and . We often call the CP pair () a target pair, call target formulas. and are called the context of a sequent.
Proof Systems. A proof tree is a tree-like structure formed by deducing a node as a conclusion backwardly by consecutively applying inference rules. In a proof tree, each node is the conclusion of a rule. The root node of the tree is called the conclusion of the proof. Each leaf node of the tree is called terminal, if it is the conclusion of an axiom. A proof tree is called finite if all of its leaf nodes terminate.
A proof system consists of a set of inference rules. We say that a node can be derived from , denoted by , if a finite proof tree with the root node can be formed by applying the rules in .
Notice that the rules with names shown in the tables below in this paper (e.g. rule in Table 3) are actually rule schemata, that is, inferences rules with meta variables as parameters (e.g. “” in rule ). But in the discussions below we usually still call them “inference rules”, and sometimes do not distinguish them from their instances if no ambiguities are caused.
3.2 A Proof System for
The proof system of relies on a pre-defined proof system for deriving program behaviours and terminations . is sound and complete w.r.t. and in the sense that for any transition and termination , iff , and iff .
Note that in , we usually assume that a formula does not contain a program transition or termination.
Example 3
As an example, Table 2 displays a part of inference rules of the proof system for the program behaviours , which are obtained directly from the operational semantics of While programs (Table 6 of Appendix 0.B). The whole proof system is shown in Table 7, 8 of Appendix 0.B. The rules in Table 2 will be used in the proof procedure of the example in Section 4.1. In Table 2, represents a configuration that store variable as value , while storing other variables as the same value as . Similarly to , is defined to return a term obtained by replacing each free variable of by the value of in (see Appendix 0.B).
Table 3 lists the primitive rules of . Through , a formula can be transformed into proof obligations as non-dynamic formulas, which can then be encoded and verified accordingly through, for example, an SAT/SMT checking procedure. For easy understanding, we give rule instead of the version of rule for the left-side derivations, which can be derived using and rules and . The rules for other operators like , can be derived accordingly using the rules in Table 3.
, where , if 1 . 2 for each in or , ; is valid. 3 is a non-dynamic formula. 4 Sub is a substitution by Definition 4.
Illustration of each rule is as follows.
Rules and deal with dynamic parts of formulas based on program transitions. Both rules rely on the sub-proof-procedures of system . In rule , represents the collection of premises for all program states . By the finiteness of branches of program hehaviours (Definition 1-1), set must be finite. So rule only has a finite number of premises. Note that when is empty, the conclusion terminates. Intuitively, rule says that to prove that holds under configuration , we prove that for each transition from to , holds under configuration . Compared to rule , rule has only one premise for . Intuitively, rule says that to prove holds under configuration , we prove that after some transition from to , holds under configuration .
In rule , each formula in and is a formula in . Rule terminates if formula is valid. The introduction rule for labels is applied when is a formula without any dynamic parts. Through this rule we eliminate a configuration and obtain a formula in . Rule deals with the situation when the program is a termination . Its soundness is straightforward by the well-definedness of program behaviours .
Rule describes a specialization process for formulas. For a set of formulas, , with Sub a function defined as follows in Definition 4. Intuitively, if formula is valid, then its one of special cases through an abstract version of substitutions Sub on formulas is valid. Rule plays an important role in constructing a bud in a cyclic preproof structure (Section 3.3). See Section 4.1 as an example.
Definition 4 (Substitution)
A structural function is called a ‘substitution’, if for any evaluation , there exists a such that for each formula .
Rules and are for transforming labeled formulas. Their soundness are direct according to the semantics of labeled formulas (Definition 3).
From rule to are the rules inherited from traditional first-order logic. Note that rule and rules and have no target pairs. The meanings of these rules are classical and we omit their discussions here.
The soundness of the rules in is stated as follows.
Theorem 3.1
Provided that proof system is sound, all rules in (Table 3) are sound.
3.3 Construction of A Cyclic Preproof Structure in
In the proof system , given a sequent , we expect a finite proof tree to prove . However, a branch of a proof tree does not always terminate. Because the process of symbolically executing a program via rule or/and rule might not stop. This is well known when a program has an explicit/implicit loop structure that may run infinitely. For example, a while program will proceed infinitely as the following transitions: . When deriving it, one may generate an infinite proof branch like this:
In this paper we apply the cyclic proof approach (cf. [10]) to deal with a potential infinite proof tree in . Cyclic proof is a technique to ensure a valid conclusion of a special type of infinite proof trees, called ‘preproof’, under some certain conditions called “soundness conditions”. Below we firstly introduce a preproof structure, then based on it we propose a ‘cyclic’ preproof — a structure that satisfies certain soundness conditions. The key idea is that, if the conclusion is invalid, then the structure of a cyclic preproof, as will be shown in Section 5 in detail, would induce an infinite descent sequence of elements of a well-founded set, which would contradict the definition of ‘well-foundedness’ (Section 5) itself.
Preproof & Derivation Traces. A preproof (cf. [10]) is an infinite proof tree expressed as a tree structure with finite nodes, in which there exist non-terminal leaf nodes, called buds. Each bud is identical to one of its ancestors in the tree. The ancestor identical to a bud is called a companion of .
A derivation path in a preproof is an infinite sequence of nodes () starting from the root node of the preproof, where for each node pair (), is the conclusion and is a premise, of a rule.
A derivation trace over a derivation path () is an infinite sequence of formulas starting from formula in node such that each CP pair () appearing on the right-sides of nodes respectively is either a target pair of a rule in , or a CP pair satisfying of a rule in .
Progressive Steps. A crucial prerequisite of defining cyclic preproofs is to introduce the notion of (progressive) derivation traces in a preproof of .
Definition 5 (Progressive Step/Progressive Derivation Trace in )
In a preproof of , given a derivation trace over a derivation path () starting from in node , a formula pair () over is called a “progressive step”, if is a target pair of an instance of rule :
or the target pair of an instance of rule :
provided with an additional condition that .
If a derivation trace has an infinite number of progressive steps, we say that the trace is ‘progressive’.
As we will see in Section 5 and Appendix 0.A, the additional condition of the instance of rule is the key to prove the case for modality in Theorem 3.2.
As an example, we propose a proof system for termination checking of While programs shown in Table 8 of Appendix 0.B.
Cyclic Preproofs. We define cyclic preproof structures as the following definition.
Definition 6 (A Cyclic Preproof for )
In , a preproof is a ‘cyclic’ one, if there exists a progressive trace over every derivation path.
The cyclic proof system is sound, as stated in the following theorem.
Theorem 3.2 (Soundness of the Cyclic Preproof for )
Provided that is sound, a cyclic preproof of has a sound conclusion.
We still denote by that can be proved through a cyclic preproof. In Section 5, we will prove Theorem 3.2.
Proof system itself that relies on can also be cyclic. In Appendix 0.B, we propose a cyclic proof system for termination checking of While programs in Table 9, which does not rely on programs’ syntactic structures.
About Other Properties of . Since is not a specific logic, it is impossible to discuss about its decidability, completeness or whether it is cut-free without any restrictions on sets and . For example, for the completeness, in , whether a formula can be proved depends on the definitions of , more precisely, on whether we can successfully find proper forms of configurations using rule from which a preproof structure can be constructed. One of our future work will focus on analyzing under what restrictions, these properties can be obtained in a general sense.
3.4 Lifting Rules From Dynamic Logic Theories
We introduce a technique of lifting rules from particular dynamic-logic theories to labeled ones in . It makes possible for embedding (at least partial) existing dynamic-logic theories into , without losing their abilities of deriving based on programs’ syntactic structures. This in turn facilitates deriving formulas in particular program domains by making use of special structural rules. Below, we propose a lifting process for general inference rules under a certain condition of configurations (Proposition 1). One example of applications of this technique will be given later in Section 4.2.
We first introduce the basic concepts. In the following definitions of this section, we always assume for an unlabeled formula is well defined in some particular dynamic-logic theory.
Definition 7 (Relation )
Given evaluations , a configuration and a set of unlabeled formulas, evaluation-configuration pair “has the same effect” on as evaluation , denoted by , if for any , iff .
Example 4
In program domain , let be two evaluations satisfying and . Let , formula . Then , since .
Definition 8 (Free Configurations)
A configuration is called ‘free’ w.r.t. a set of formulas if it satisfies that
-
1.
for any , there is a such that ;
-
2.
for any , there is a such that .
We denote the set of all free configurations w.r.t. as .
Intuitively, a free configuration in some sense neither strengthen nor weaken a formula w.r.t. its boolean semantics after affections.
For a configuration , recall that is explained in Example 3.
Example 5
In Example 4, the configuration is free w.r.t. . On one hand, for any evaluation , let , then we have (Definition 8-1); On the other hand, for any evaluation , let , then holds (which is Definition 8-2). Let , then is not free w.r.t. , since it makes too strong so that there does not exist an evaluation such that , violating Definition 8-2.
For a set of unlabeled formulas, we write to mean the set of labeled formulas .
Proposition 1 (Lifting Process)
Given a sound rule of the form
in which all formulas are unlabelled, rule
is sound for any configuration .
Proposition 1 is proved in Appendix 0.A based on the notion of free configurations defined above. From the proof of Proposition 1, we can see that when the rule is an axiom, we actually only need Definition 8-1, as stated in the following proposition, where we call a configuration standard w.r.t. if it satisfies Definition 8-1, and write as the set of all standard configurations w.r.t. .
Proposition 2 (Simple Version of Proposition 1)
Given a sound axiom rule is sound for any standard configuration .
4 Case Studies
In this section, we give some examples to show how can be useful in reasoning about programs. In the first example (Section 4.1), we show how a cyclic deduction of a traditional While program is carried out. Section 4.2 gives an example showing by applying the results obtained in Section 3.4 that how lifting rules from the theory of FODL can be helpful in deriving programs in . In Section 4.3, we show the powerfulness of by encoding a type of more complex configurations in the programs of separation logic [34] than in While programs. This example shows the potential of to be applied in real programming languages with the ability to manipulate storage.
4.1 Cyclic Deduction of A While Program
We prove the property given in Example 2, stated as the following sequent
Recalling that with a free variable; WP is defined as
Definitions of other symbols: 1: 2: 3: 4: 19: 5: 6: 11: 12: 13: 16: 17: 18: 14: 15: 7: 8: 9: 10:
Table 4 shows the derivation of this formula. We omit all sub-proof-procedures in the proof system derived by the inference rules in Table 2 when deriving via rule . We write term if is a variable that has free occurrences in . Non-primitive rules and are can be derived by the rules for and accordingly. For example, rule can be derived as follows:
The derivation from sequent 2 to 3 is according to rule
where function is an instantiation of abstract substitution defined in Definition 4. Recalling that for any formula , substitutes each free variable of with term (Section 2.2). Its formal definition and the proof of instantiation are given in Appendix 0.B. We observe that sequent 2 can be writen as:
as a special case of sequent 3. Intuitively, sequent 3 captures the situation after the th loop () of program WP. This step is crucial as starting from sequent 3, we can find a bud node — 18 — that is identical to node 3. The derivation from sequent 3 to {4, 5} provides a lemma: , which is obvious valid. Sequent 16 indicates the end of the th loop of program WP. From node 12 to 16, we rewrite the formulas on the left side into an obvious logical equivalent form in order to apply rule . From sequent 16 to 17 rule is applied, with 16 can be written as:
The whole proof tree is a cyclic preproof because the only derivation path: has a progressive derivation trace whose elements are underlined in Table 4.
The configurations in subsume the concept of ‘updates’ in dynamic logics, which were adopted in work like [3]. In this example, if we allow a configuration to be a meta variable, say , then it is just an update, which has no explicit structures but carries a series of “delayed substitutions”. For instance, we can have a configuration that carries two substitutions in sequence. When applying to formulas, these substitutions are passed to formulas: through a well-defined . From this we see that one of the advantages of is that it allows explicit structures of program status such as stores or stacks we have seen in Section 2.2.
Appendix 0.C introduces another example of derivations of a program with implicit loop structures, which can better highlight the advantages brought by the cyclic proof framework of .
4.2 Lifting Structural Rules From FODL
We give two examples from the theory of FODL (cf. [20]) to illustrate how existing rules in FODL can be helpful for deriving compositional programs in .
In FODL, consider an axiom
which comes from the valid formula , as a useful rule appearing in many dynamic logic calculi that are based on FODL (e.g. [4]). By Proposition 2, we lift as
for any standard configuration . And by Lemma 2 (Appendix 0.A), we obtain a labeled rule
which provides a compositional reasoning for sequential programs in as an additional rule. It is useful when verifying a property like , in which we might finish the proof by only symbolic executing program as:
especially when verifying program can be very costly.
Another example is rule
for generating modality , which were used for deriving the structural rule of loop programs in FODL (cf. [20]). By Proposition 1, we lift as the following rule
where . It is useful, for example, when deriving a property , where we can skip the verification of program as follows:
and directly focus on verifying program .
4.3 Encoding of Complex Configurations
The examples of configurations we have seen in both While programs and Esterel programs (Section 2.2) are both a simple version of variable storage. We show an example of defining a type of more complex configurations to capture the notion of ‘heaps’ for separation logic [34] — an extension of Hoare logic for reasoning about program data structures. We will encode a partial separation logic into . From this example, we see that a configuration interpretation can be more than just substitutions of terms like and seen in previous examples.
Separation Logic. In the following, we assume readers are familiar with separation logic and only give an informal explanations of its semantics. For simplicity, we only introduce a partial separation logic primitives: for formulas, we only introduce an atomic formula and a critical operator (while omitting another critical operator ); for programs, we only introduce atomic program statements: , , and that have direct influences on heaps, and ignore compositional programs that varies from case to case. After the introductions of the semantics, we give the encoding of separation logic into as labeled formulas and explain how they actually capture the same meaning.
Below we follow some conventions of notations: Given a partial function , we use to denote the domain of . For a set , partial function is the function restricted on domain . represents the partial function that maps to , and maps the other variables in its domain to the same value as .
Let be the set of values, where Addr is a set of addresses. We assume Addr to be expressed with an infinite set of integer numbers. In separation logic, a store is a function that maps each variable to a value of , a heap is a partial function that maps each address to a value of , expressing that the value is stored in a memory indicated by the address. is a finite subset of Addr. Let be an arithmetic expression with or without variables, returns the value by replacing each variable of with value . A state is a store-heap pair . The disjoint relation is defined if .
Here we informally explain the behaviours of program statements. Given a state , statement allocates a memory addressed by a new integer in to store the value of expression (thus obtaining a new heap where ), and assigns to . Statement assigns the value of the address in (i.e. ) to variable . means to assign the value to the memory of the address in (i.e. obtaining a new heap ). means to de-allocate the memory of address in heap (i.e. obtaining a new heap ).
Formula means that value is stored in the memory of address . Given a state , is defined if . For any separation logical formulas and , if there exist heaps such that , , and and .
Example 6
Let be a state such that and , then the following table shows the information of each state about focused variables and addresses during the process of the following executions:
Store | Heap | ||
---|---|---|---|
, | empty | ||
, | |||
, | , | ||
, | , | ||
, | , | ||
, |
Let , , we have and , , but since and point to the single memory storing value .
Configurations : Interpretations : Inference rules for behaviours of program statements: 1 is new w.r.t. .
Encoding of Separation Logic in . In , we choose the store-heap pairs as the configurations namely . Table 5 lists the rules for the program behaviours of the atomic program statements. To capture the semantics of separation logical formulas, interpretations are defined in an inductive way according to their syntactical structures. Note that the formula requires variables ranging over heaps.
To tackle a formula like , additional rules can be proposed. In this example, we can propose a rule
to decompose the heap’s structure, or a rule
to simplify the formula’s structure. These rules are inspired from their counterparts for programs in separation logic.
In practice, configurations can be more explicit structures than store-heap pairs . Similar encoding can be obtained accordingly. From this example, we envision that the entire theory of separation logic can actually be embedded into , where additional rules like the above ones will support a “configuration-level reasoning” of separation logical formulas.
5 Soundness of Cyclic Proof System
We analyze and prove the soundness of stated as Theorem 3.2. We need to show that if a preproof is cyclic (Definition 6), that is, if every derivation path of the preproof is followed by a safe and progressive trace, then the conclusion is valid. We follow the main idea behind [8] to carry out a proof by contradiction: suppose the conclusion is invalid, then we will show that there exists an invalid derivation path in which each node is invalid, and one of its progressive traces starting from a formula in a node leads to an infinite descent sequence of elements along this trace ordered by a well-founded relation (introduced in Section 5.1), which violates the definition of well-foundedness itself.
Below, we only consider the case when in a node of the form for arbitrary and . Other cases for are trivial.
In the rest of this section, we firstly introduce the well-founded relation , then focus on the main skeleton of proving Theorem 3.2. Other proof details are given in Appendix 0.A.
5.1 Well-founded Relation
Well-foundedness. A relation on a set is partially ordered, if it satisfies the following properties: (1) Reflexivity. for each . (2) Anti-symmetry. For any , if and , then and are the same element in , we denote by . (3) Transitivity. For any , if and , then .
is defined as and .
Given a set and a partial-order relation on , is called a well-founded relation over , if for any element in , there is no infinite descent sequence: in . Set is called a well-founded set w.r.t. .
Relation . Given two paths and , relation is defined if is a suffix of . Obviously is partially ordered. Relation expresses that is a proper suffix of . In a set of finite paths, relation is well-founded, because every finite path has only a finite number of suffixes.
Definition 9 (Relation )
Given two finite sets and of finite paths, is defined if either (1) ; or (2) set can be obtained from by replacing (or removing) one or more elements of each with a finite number of elements, such that for each replaced element , its replacements () in satisfies that for any , .
Proposition 3
is a partial-order relation.
Example 7
Let , where and ; , where . We see that and . can be obtained from by replacing and with and respectively, and removing . Hence . Since , .
Proposition 4
The relation between any two finite sets of finite paths is a well-founded relation.
We omit the proof since relation is in fact a special case of the “multi-set ordering” introduced in [12], where it has been proved that multi-set ordering is well-founded.
5.2 Proof of Theorem 3.2
Below we give the main skeleton of the proof by skipping the details of the critical Lemma 1, whose proof can be found in Appendix 0.A.
Following the main idea in the beginning of Section 5, next we first introduce the notion of “counter-example paths” that makes a formula or invalid.
Definition 10 (Counter-example Paths)
A “counter-example” of a formula in a sequent is a set of minimum paths defined as:
We write to mean that for all . Recall that a path being minimum is defined in Section 2.4.
Lemma 1
In a cyclic preproof (where there is at least one derivation path), let be a pair of a derivation trace over a node pair of an invalid derivation path, where and . For any counter-example of , there exists an evaluation and a counter-example of such that . Moreover, if is a progressive step, then .
In Lemma 1, note that if there is no derivation paths, then the preproof itself must be a finite proof tree. Then its soundness is straightforward according to the soundness of rules in Table 3.
Proof (Proof of Theorem 3.2)
As stated previously, we prove by contradiction and only focus on the cases where the first formula of a progressive trace is of the form: or . Let the progressive trace be over a derivation path () starting from in , where , and formula for each node is invalid.
From that is invalid, there is an evaluation satisfying that but , so is well defined. By Lemma 1, from we can obtain an infinite sequence of counter-examples: , with each () being the counter-example of formula , and which satisfies that . Moreover, since is progressive (Definition 6), there must be an infinite number of strict relation among these s. This thus forms an infinite descent sequence w.r.t. , violating the well-foundedness of relation (Proposition 4).
6 Related Work
The idea of reasoning about programs directly based on program behaviours is not new. Previous work such as [35, 36, 37, 11] in last decade has addressed this issue using theories based on rewriting logics [26]. Matching logic [35] is based on patterns and pattern matching. Its basic form, a reachability rule (where means differently from in sequents here), captures whether pattern is reachable from pattern in a given pattern reachability system. The concept of ‘patterns’ in matching logic has a wider scope of meaning than the concepts of ‘programs’, ‘configurations’ and ‘formulas’ in . Based on matching logic, one-path and all-paths reachability logics [36, 37] were developed by enhancing the expressive power of the reachability rule. A more powerful matching -logic [11] was proposed by adding a least fixpoint -binder to matching logic.
In terms of expressiveness, the semantics of modality in dynamic logic cannot be fully captured by matching logic and one-path reachability logic when the programs are non-deterministic. We conjecture that matching -logic can encode . As a generic calculus, it has been claimed that matching -logic can encode traditional dynamic logics (cf. [11]). Compared to these theories based on rewriting logics, has a more specific logical structure and belongs to a type of modal logics, with modalities and to efficiently capture and reason about program specifications. On the other hand, to encode a specification in matching logic for example, one needs to somehow ‘mix up’ all structures together to form a pattern, in a form like: and for some configuration , in order to conduct a reachability rule .
[27] proposed a general program verification framework based on coinduction. Using the terminology in this paper, in [27] a program specification can be expressed as a pair with a program state and a set of program states, capturing the exact meaning of formula in if we let be and let represent the semantics of formula . The authors designed a method to derive a program specification in a coinductive way according to the operational semantics of . Following [27], [25] also proposed a general framework for program reasoning, but via big-step operational semantics. Unlike the frameworks in [27] and [25], which are directly based on mathematical set theory, is a logic, which in some cases is more convenient to catch program properties. In terms of expressiveness, can also express the negation of a dynamic formula as the dual formula , whose meaning cannot be captured in the framework of [27].
The structure ‘updates’ in dynamic logics, used in Java dynamic logic [4], differential dynamic logic [31], dynamic trace logic [3], etc., works as a special case of the configurations proposed in this paper. As illustrated in Section 4.1, a configuration in can be more than just a “delay substitution” (cf. [3]) of variables and terms.
The proof system of relies on the cyclic proof theory which firstly arose in [38] and was later developed in different logics such as [10] and [8]. Traditional dynamic logics’ proof systems are not cyclic ones. In [23], Jungteerapanich proposed a complete cyclic proof system for -calculus, which subsumes PDL [15] in its expressiveness. In [13], Docherty and Rowe proposed a complete labelled cyclic proof system for PDL. Both -calculus and PDL, as mentioned in Section 1, are logics designed for dissolving regular expressions as their program models. In terms of program structures, however, is relatively simpler than PDL, in which programs can also depend on dynamic formulas. The labelled form of formula is inspired from [13], where a labelled PDL formula is of the form , with a world in a Kripke structure. While in , a configuration can be an explicit term.
There has been some other work for generalizing the theories of dynamic logics, such as [28, 21]. However, generally speaking, they neither consider structures as general as allowed by configurations and programs in , nor adopt a similar approach for reasoning about programs. [28] proposed a complete generic dynamic logic for monads of programming languages. In [21], the authors proposed a dynamic logic for reasoning about program models that are more general than regular expressions of PDL, also based on program behaviours (where it is called “interaction-based” behaviours). But there the program states are still abstract worlds of Kripke structures as in PDL, unlike the configurations in . And yet no proof systems have been proposed and analyzed for the logic.
7 Some Discussions & Future Work
In this paper, we propose a dynamic-logic-like parameterized formalism allowing instantiations of a rich set of programs and formulas in interested domains. provides a flexible verification framework to encompass existing dynamic-logic theories, by supporting a direct symbolic-execution-based reasoning according to programs behaviours, while still preserving structure-based reasoning through lifting processes. In practical verification, trade-off can be made between these two types of reasoning. Through examples displayed in this paper, one can see the potential of to be used for other types of programs, especially those do not support structural rules, such as transitional models [21] or neural networks [41]. On the other hand, due to its generality, loses the completeness that a dynamic logic usually possesses, and must rely on additional lifted rules to support a compositional reasoning.
About future work, currently we plan a full mechanization of using Coq [7], which on one hand can help verifying the correctness of the theory itself, and on the other hand provides a verification framework built upon Coq to support verifying general programs. Our long-term goal is to develop an independent program verifier based on the theory of , which could fully make use of the advantages of symbolic-execution-based reasoning and cyclic proofs to maximize automation of verifications. One possible way is based on Cyclist [9], a proof engine supported by an efficient cyclic-proof-search algorithm. To see the full potential of , we are also trying to use to describe and verify more types of programs or system models.
Acknowledgment
This work is partially supported by the Youth Project of National Science Foundation of China (No. 62102329), the Project of National Science Foundation of China (No. 62272397), and the New Faculty Start-up Foundation of NUAA (No. 90YAT24003).
References
- [1] Appel, A.W., Dockins, R., Hobor, A., Beringer, L., Dodds, J., Stewart, G., Blazy, S., Leroy, X.: Program Logics for Certified Compilers. Cambridge University Press (2014)
- [2] Barthe, G., Katoen, J.P., Silva, A.: Foundations of Probabilistic Programming. Cambridge University Press (2020)
- [3] Beckert, B., Bruns, D.: Dynamic logic with trace semantics. In: Bonacina, M.P. (ed.) Automated Deduction – CADE-24. pp. 315–329. Springer Berlin Heidelberg, Berlin, Heidelberg (2013)
- [4] Beckert, B., Klebanov, V., Weiß, B.: Dynamic Logic for Java, pp. 49–106. Springer International Publishing, Cham (2016)
- [5] Benevides, M.R., Schechter, L.M.: A propositional dynamic logic for concurrent programs based on the -calculus. Electronic Notes in Theoretical Computer Science 262, 49–64 (2010), proceedings of the 6th Workshop on Methods for Modalities (M4M-6 2009)
- [6] Berry, G., Gonthier, G.: The Esterel synchronous programming language: design, semantics, implementation. Science of Computer Programming 19(2), 87 – 152 (1992)
- [7] Bertot, Y., Castéran, P.: Interactive Theorem Proving and Program Development - Coq’Art: The Calculus of Inductive Constructions. Texts in Theoretical Computer Science. An EATCS Series, Springer (2004)
- [8] Brotherston, J., Bornat, R., Calcagno, C.: Cyclic proofs of program termination in separation logic. SIGPLAN Not. 43(1), 101–112 (jan 2008)
- [9] Brotherston, J., Gorogiannis, N., Petersen, R.L.: A generic cyclic theorem prover. In: Jhala, R., Igarashi, A. (eds.) Programming Languages and Systems. pp. 350–367. Springer Berlin Heidelberg, Berlin, Heidelberg (2012)
- [10] Brotherston, J., Simpson, A.: Complete sequent calculi for induction and infinite descent. In: 22nd Annual IEEE Symposium on Logic in Computer Science (LICS 2007). pp. 51–62 (2007)
- [11] Chen, X., Rosu, G.: Matching -logic. In: 2019 34th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS). pp. 1–13. IEEE Computer Society, Los Alamitos, CA, USA (jun 2019)
- [12] Dershowitz, N., Manna, Z.: Proving termination with multiset orderings. In: Maurer, H.A. (ed.) Automata, Languages and Programming. pp. 188–202. Springer Berlin Heidelberg, Berlin, Heidelberg (1979)
- [13] Docherty, S., Rowe, R.N.S.: A non-wellfounded, labelled proof system for propositional dynamic logic. In: Cerrito, S., Popescu, A. (eds.) Automated Reasoning with Analytic Tableaux and Related Methods. pp. 335–352. Springer International Publishing, Cham (2019)
- [14] Feldman, Y.A., Harel, D.: A probabilistic dynamic logic. Journal of Computer and System Sciences 28(2), 193–215 (1984)
- [15] Fischer, M.J., Ladner, R.E.: Propositional dynamic logic of regular programs. Journal of Computer and System Sciences 18(2), 194–211 (1979)
- [16] Gentzen, G.: Untersuchungen über das logische Schließen. Ph.D. thesis, NA Göttingen (1934)
- [17] Gesell, M., Schneider, K.: A hoare calculus for the verification of synchronous languages. In: Proceedings of the Sixth Workshop on Programming Languages Meets Program Verification. p. 37–48. PLPV ’12, Association for Computing Machinery, New York, NY, USA (2012)
- [18] Goodfellow, I.J., Bengio, Y., Courville, A.: Deep Learning. MIT Press, Cambridge, MA, USA (2016)
- [19] Harel, D.: First-Order Dynamic Logic, Lecture Notes in Computer Science (LNCS), vol. 68. Springer (1979)
- [20] Harel, D., Kozen, D., Tiuryn, J.: Dynamic Logic. MIT Press (2000)
- [21] Hennicker, R., Wirsing, M.: A Generic Dynamic Logic with Applications to Interaction-Based Systems, pp. 172–187. Springer International Publishing, Cham (2019)
- [22] Hoare, C.A.R.: An axiomatic basis for computer programming. Commun. ACM 12(10), 576–580 (Oct 1969)
- [23] Jungteerapanich, N.: A tableau system for the modal -calculus. In: Giese, M., Waaler, A. (eds.) Automated Reasoning with Analytic Tableaux and Related Methods. pp. 220–234. Springer Berlin Heidelberg, Berlin, Heidelberg (2009)
- [24] Kozen, D.: A probabilistic pdl. Journal of Computer and System Sciences 30(2), 162–178 (1985)
- [25] Li, X., Zhang, Q., Wang, G., Shi, Z., Guan, Y.: Reasoning about iteration and recursion uniformly based on big-step semantics. In: Qin, S., Woodcock, J., Zhang, W. (eds.) Dependable Software Engineering. Theories, Tools, and Applications. pp. 61–80. Springer International Publishing, Cham (2021)
- [26] Meseguer, J.: Twenty years of rewriting logic. The Journal of Logic and Algebraic Programming 81(7), 721–781 (2012), rewriting Logic and its Applications
- [27] Moore, B., Peña, L., Rosu, G.: Program verification by coinduction. In: Ahmed, A. (ed.) Programming Languages and Systems. pp. 589–618. Springer International Publishing, Cham (2018)
- [28] Mossakowski, T., Schröder, L., Goncharov, S.: A generic complete dynamic logic for reasoning about purity and effects. Formal Aspects of Computing 22(3-4), 363–384 (2010)
- [29] O’Hearn, P.W.: Incorrectness logic. Proc. ACM Program. Lang. 4(POPL) (dec 2019)
- [30] Pardo, R., Johnsen, E.B., Schaefer, I., Wąsowski, A.: A specification logic for programs in the probabilistic guarded command language. In: Theoretical Aspects of Computing – ICTAC 2022: 19th International Colloquium, Tbilisi, Georgia, September 27–29, 2022, Proceedings. p. 369–387. Springer-Verlag, Berlin, Heidelberg (2022)
- [31] Platzer, A.: Differential dynamic logic for verifying parametric hybrid systems. In: International Conference on Theorem Proving with Analytic Tableaux and Related Methods (TABLEAUX). Lecture Notes in Computer Science (LNCS), vol. 4548, pp. 216–232. Springer Berlin Heidelberg (2007)
- [32] Platzer, A.: Logical Foundations of Cyber-Physical Systems. Springer, Cham (2018)
- [33] Plotkin, G.D.: A structural approach to operational semantics. Tech. Rep. DAIMI FN-19, University of Aarhus (1981)
- [34] Reynolds, J.: Separation logic: a logic for shared mutable data structures. In: Proceedings 17th Annual IEEE Symposium on Logic in Computer Science. pp. 55–74 (2002)
- [35] Roşu, G., Ştefănescu, A.: Towards a unified theory of operational and axiomatic semantics. In: Czumaj, A., Mehlhorn, K., Pitts, A., Wattenhofer, R. (eds.) Automata, Languages, and Programming. pp. 351–363. Springer Berlin Heidelberg, Berlin, Heidelberg (2012)
- [36] Rosu, G., Stefanescu, A., Ciobâcá, S., Moore, B.M.: One-path reachability logic. In: 2013 28th Annual ACM/IEEE Symposium on Logic in Computer Science. pp. 358–367 (2013)
- [37] Ştefănescu, A., Ciobâcă, Ş., Mereuta, R., Moore, B.M., Şerbănută, T.F., Roşu, G.: All-path reachability logic. In: Dowek, G. (ed.) Rewriting and Typed Lambda Calculi. pp. 425–440. Springer International Publishing, Cham (2014)
- [38] Stirling, C., Walker, D.: Local model checking in the modal mu-calculus. Theor. Comput. Sci. 89(1), 161–177 (aug 1991)
- [39] Yang, K., Poesia, G., He, J., Li, W., Lauter, K., Chaudhuri, S., Song, D.: Formal mathematical reasoning: A new frontier in AI (2024), https://arxiv.org/abs/2412.16075
- [40] Yang, Z., Hu, K., Ma, D., Bodeveix, J.P., Pi, L., Talpin, J.P.: From AADL to timed abstract state machines: A verified model transformation. Journal of Systems and Software 93, 42–68 (2014)
- [41] Zhang, X., Chen, X., Sun, M.: Towards a unifying logical framework for neural networks. In: Seidl, H., Liu, Z., Pasareanu, C.S. (eds.) Theoretical Aspects of Computing – ICTAC 2022. pp. 442–461. Springer International Publishing, Cham (2022)
- [42] Zhang, Y., Mallet, F., Liu, Z.: A dynamic logic for verification of synchronous models based on theorem proving. Front. Comput. Sci. 16(4) (aug 2022)
- [43] Zhang, Y., Wu, H., Chen, Y., Mallet, F.: A clock-based dynamic logic for the verification of ccsl specifications in synchronous systems. Science of Computer Programming 203, 102591 (2021)
- [44] Zilberstein, N., Dreyer, D., Silva, A.: Outcome logic: A unifying foundation for correctness and incorrectness reasoning. Proc. ACM Program. Lang. 7(OOPSLA1) (apr 2023)
Appendix 0.A Other Propositions and Proofs
Lemma 2
For any formulas , if formula is valid, then sequent
is sound for any contexts .
Proof
Assume ,…, are valid, for any evaluation , let and for all , we need to prove . From the assumption we have , …, . is an immediate result since .
Below we only prove the soundness of rules , and . Other rules can be proved similarly based on the semantics of formulas (Definition 3). By Lemma 2, it is sufficient to prove , that is, for any evaluation , if , …, , then .
Proof (Proof of Theorem 3.1)
For rule , by the soundness of proof system , it is sufficient to prove that for any evaluation , if and for all , then . However, this is straightforward by Definition 3 and the completeness of w.r.t. , because since , any path starting from is of the form: for some .
For rule , by the soundness of proof system , it is sufficient to prove that for any evaluation , if and for some , then . However, this is direct by Definition 3.
For rule , it is sufficient to prove that for any evaluation , there exists an evaluation such that for each formula , we have . But this just matches the definition of Sub in Definition 4.
Content of Proposition 3: is a partial-order relation.
Proof (Proof of Proposition 3)
The reflexivity is trivial. The transitivity can be proved by the definition of ‘replacements’ as described in Definition 9 and the transitivity of relation . Below we only prove the anti-symmetry.
For any finite sets of finite paths, if but , let be the function defined such that for any , either (1) ; or (2) is one of the replacements of a replaced element in with .
For the anti-symmetry, suppose and but . Let but . Then from , we have . Since is the replaced element, so . By , we have . Continuing this process, we can construct an infinite descent sequence w.r.t. relation , which violates its well-foundedness. So the only possibility is .
Content of Lemma 1: In a cyclic preproof (where there is at least one derivation path), let be a pair of a derivation trace over a node pair of an invalid derivation path, where and . For any counter-example of , there exists an evaluation and a counter-example of such that . Moreover, if is a progressive step, then .
Proof (Proof of Lemma 1)
Consider the rule application from node , actually the only non-trivial cases are when it is an instance of rule (namely “case 1”) , rule (namely “case 2”) or a substitution rule (namely “case 3”).
Case 1: If from node rule is applied with the target formula, let for some , so . For any that violates , is obviously non-empty. So is also non-empty (since and is invalid). By Definition 1-2, is also finite. By the derivation , for each path (), is a path in that has as its proper suffix. So we obtain the finiteness of from the finiteness of , and thus we have .
Case 2: If from node rule is applied with the target formula, let for some , so . For any that violates , , so both and are well defined. By Definition 1-2, is finite. According to the derivation , for each path (), is a path in that has as its proper suffix. From the finiteness of , we have the finiteness of . Now consider two cases: (1) If is empty, then by the above is also empty. So ; (2) If is not empty, especially, when is a progressive step with the support of the derivation , then from the above, must also be non-empty. Moreover, in this case, we have .
Case 3: If from node a substitution rule is applied, let be the target formula of , then and . The situation for is similar and we omit it here. For any evaluation that violates , by Definition 4 there exists a such that for any formula , . Especially, by the structureness of Sub, there exist and such that . Therefore, it is not hard to see that violates and we have .
From the “case 2” of the above proof, we see that derivation plays the crucial role for proving the non-emptiness of the counter-examples in order to obtain a strict relation .
Content of Proposition 1: Given a sound rule of the form
in which all formulas are unlabelled, rule
is sound for any configuration .
Proof (Proof of Proposition 1)
Let . Assume formulas ,…, are valid, we need to prove the validity of formula . First, notice that formula () is valid, because for any evaluation , by Definition 8-2 there exists a satisfying that . So for any formula , iff . Therefore, formula is valid. On the other hand, from that is valid, we can get that is valid. This is because for any evaluation , by Definition 8-1 there is a such that , which means for any formula , iff .
Appendix 0.B Formal Definitions of While Programs in
0.B.1 Syntax and Semantics of While Programs
We formally define program domain for While programs. Below, given a set , represents its power set. Given a function , represents the function that maps to value , and maps the other variables to the same value as .
Expressions. The variable set ranges over the set of integer numbers .
An expression is defined inductively as:
-
(1)
a variable , a constant are expressions;
-
(2)
where are expressions if and are expressions.
are the usual arithmetic operators in domain . Denote the set of expressions as .
& & . A formula is an arithmetic first-order logical formula defined as follows:
Relation is the usual “less-than-equal relation” in domain . Other logical operators such as , , can be expressed by and accordingly in the usual way. Other relations such as and can be expressed by and logical operators accordingly.
A program is defined as follows in BNF forms:
where .
A configuration is defined as follows in BNF forms:
where there is at most one for each variable . We use to wrap a configuration as: .
Let . With defined, we have formulas in program domain according to Definition 2.
Free Variables. For each term, its set of free variables is captured as function , which is inductively defined as follows:
-
(1)
, where ;
-
(2)
, where ;
-
(3)
;
-
(4)
;
-
(5)
;
-
(6)
;
-
(7)
;
-
(8)
;
-
(9)
;
-
(10)
;
-
(11)
;
-
(12)
;
where function returns the set of binding variables in programs and configurations, which is formally defined as:
-
(1)
;
-
(2)
;
-
(3)
;
-
(4)
;
-
(5)
;
-
(6)
.
If for a term , we call it a closed term. For a set of terms, we use to denote its subset of all closed terms.
We extend function FV to program states and formulas . For any program state or formula , is defined inductively as follows:
-
(i)
, if ;
-
(ii)
is already defined, if ;
-
(iii)
;
-
(iv)
, if is not in a form: ;
-
(v)
;
-
(vi)
.
A closed program state is a program state satisfying that . A closed formula is a formula such that .
Substitutions. Given a function that maps each variables to an expression, its extension restricted on a set of variables, called a substitution, maps each term to a term by replacing each free variable of with expression . is inductively defined as follows:
-
(1)
if , otherwise;
-
(2)
if ;
-
(3)
, where ;
-
(4)
;
-
(5)
;
-
(6)
;
-
(7)
;
-
(8)
;
-
(9)
;
-
(10)
;
-
(11)
;
-
(12)
;
-
(13)
.
For any term , we define . We often use to denote a substitution , with .
For a substitution of a term , we always assume that it is admissible in the usual sense that we guarantee that each free variable of a replacing term, say for some variable , is still free in after the substitution by variable renaming if necessary.
We extend substitution to program states and formulas as follows:
-
(i)
, if ;
-
(ii)
is already defined, if ;
-
(iii)
;
-
(iv)
, if is not in a form: ;
-
(v)
;
-
(vi)
.
& . Let be a function , then is an evaluation of . Given a configuration , is a function defined inductively as follows:
-
(1)
;
-
(2)
if , otherwise.
For any and , we define interpretation .
& & . Propositions is defined as the set of all closed formulas of . For a formula , if formula is true in the theory of integer numbers. Table 6 depicts the operational semantics of While programs. For a program transition , if can be inferred according to Table 6. With defined, we can obtain according to Section 2.3.
0.B.2 Proof System
Proof System . Table 7 and 8 list the inference rules for program behaviours and program terminations respectively. Here we omit the other rules in first-order logic (cf. [20], some of them are already shown in Table 3) that are sometimes necessary when making derivations in .
The rules for program behaviours in Table 7 are directly from the operational semantics of While programs (Table 6). Their soundness and completeness w.r.t. are trivial. Table 8, 9 list two types of inference rules for program terminations. In Table 8, termination means terminating with configuration as the result. In other words, there exists a path over . In rule , where is an invariant of the loop body ; is a termination factor of the while statement indicating its terminations. The soundness and completeness of the rules in Table 8 w.r.t. can be proved based on the boolean semantics in an inductively way according to the syntax of While programs.
The soundness of rule in While-programs domain is instantiated by choosing the substitution ():
To see its soundness, we only need to prove that function is just a ‘substitution’ defined in Definition 4. We observe that for any evaluation , let . Then for any formula , by the definition of the substitutions above, we can have .
An Alternative Cyclic Proof System for Program Terminations. The rules in Table 8 actually rely on the syntactic structures of While programs. Table 9 gives another possible set of rules for reasoning about program terminations in a cyclic approach like , which also relies on rule and other rules in first-order logic. In rule , given a configuration , expresses that an expression called the termination factor of appears in , which indicates how far a program can terminate. Rule helps constructing a configuration with a suitable form in order to derive a bud for each potential infinite proof branch. The soundness conditions of the cyclic proof system based on Table 9 can be defined similarly as in Section 3.3, where a progressive step of a derivation trace is a pair of an instance of rule , but with the premise ‘’.
The soundness of rule is obvious. Here we skip the detailed proof of the soundness of the cyclic proof system based on Table 9 but only give a rough idea, which makes use of the well-foundedness of the less-than relation between integer numbers. Intuitively, starting from a state , if , then by the definition of ‘cyclic preproof’ (Defnition 6) we have an infinite sequence of relations: with expressions . And by the definition of progressive step, among the sequence there is an infinite number of relation ‘’, thus violating the well-foundedness of relation . We conjecture that such a cyclic proof system is also complete. More analysis will be given in future work.
Appendix 0.C Cyclic Deduction of A Synchronous Program
This example shows that we can use to verify a program whose “loop structures” are implicit. That is where is really useful as the loop information can be tracked in the cyclic proof structures of . Consider the synchronous program (Table 1) written in Esterel [6]:
where , are two programs running in parallel.
Different from while programs, the behaviour of a synchronous program is characterized by a sequence of instances. At each instance, several (atomic) executions of a program may occur. The value of each variable is unique in an instance. When several programs run in parallel, their executions at one instance are thought to occur simultaneously. In this manner, the behaviour of a parallel synchronous program is deterministic.
In this example, the key word pause marks the end of an instance. At the beginning of each instance, the values of all signals are set to , representing ‘absent’ state. The loop statements in programs and are executed repeatedly for an infinite number of times until some exit statement is encountered. At each instance, program firstly emits signal with value and substracts the local variable with the current value of ; then checks if . While program emits signal with value . The value of signal in one instance should be the sum of all of its emitted values by different current programs. So the value of should be . The whole program continues executing until is satisfied, when exit terminates the whole program by jumping out of the trap statement.
As an instance, when initializing as value , the values of all variables at the end of each instance are listed as follows:
-
•
instance 1: ;
-
•
instance 2: ;
-
•
instance 3: ;
-
•
instance 4: .
In a parallel Esterel program, the executions of concurrent programs are usually dependent on each other to maintain the consistency of simultaneous executions, imposing special orders of atomic executions in one instance. In the program above, for instance, the assignment can only be executed after all values of in both programs and are collected. In other words, the assignment can only be executed after and . This characteristic of Esterel programs makes direct compositional reasoning impossible because the executions between parallel programs in an instance are not true interleaving. One has to symbolically execute the parallel program as a whole in order to obtain the right execution orders in each instance.
In the following we prove the property
which says that under configuration (with a free variable), if , then can finally terminate (satisfying ).
Definitions of other symbols: 1: 2: 3: 4: 5: 17: 6: 7: 12: 13: 14: 15: 16: 8: 9: 10: 11:
The derivations of is depicted in Table 10. We omit the sub-proof-procedures of all program transitions when applying rule , which depends on the operational semantics of Esterel programs (cf. [6]).
From node 2 to 3 is a progressive step, where we omit the derivations of the termination , which depends on the operational semantics of Esterel (cf. [6]). It is not hard to see that this program does terminate as the value of variable decreases by (by executing ) in each loop so that statement exit will finally be reached. From node 13 to 14 and node 15 to 16, rule
is applied, which can be derived by the following derivations:
From node 14 to 15, rule
is applied, whose substitution function is as introduced in Section 2.2. Observe that sequent 14 can be written as:
Sequent 16 is a bud with sequent 1 as its companion. The whole preproof is cyclic as the only derivation path: has a progressive trace whose elements are underlined in Table 10.