This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

11institutetext: Collage of Software, Nanjing University of Aeronautics and Astronautics, China
11email: yuanruizhang@nuaa.edu.cn, zhangyrmath@126.com

Parameterized Dynamic Logic — Towards A Cyclic Logical Framework for General Program Specification and Verification

Yuanrui Zhang 11 0000-0002-0685-6905
Abstract

We present a theory of parameterized dynamic logic, namely 𝐷𝐿p\mathit{DL}_{p}, 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, 𝐷𝐿p\mathit{DL}_{p} 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 𝐷𝐿p\mathit{DL}_{p}, which guarantees the soundness of infinite proof trees induced by symbolically executing programs with explicit/implicit loop structures. The soundness of 𝐷𝐿p\mathit{DL}_{p} is formally analyzed and proved. 𝐷𝐿p\mathit{DL}_{p} 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 𝐷𝐿p\mathit{DL}_{p} in particular domains, showing the potential and advantages of using 𝐷𝐿p\mathit{DL}_{p} in practical usage.

Keywords:
Dynamic Logic Program Deduction Logical Framework Cyclic Proof Symbolic Execution

1 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 α\alpha is embedded into a modality [][\cdot] in a form of [α]ϕ[\alpha]\phi, meaning that after all executions of α\alpha, formula ϕ\phi holds. Formula ϕ[α]ψ\phi\to[\alpha]\psi exactly captures partial correctness of programs expressed by triple {ϕ}α{ψ}\{\phi\}\alpha\{\psi\} in Hoare logic [22]. Essentially, verification in dynamic logic is a process of continuously altering the form [α]ϕ[\alpha]\phi based on how α\alpha 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 [α]ϕ[\alpha]\phi that mixes programs and formulas, dynamic logic is able to express many complex program properties such as [α]βϕ[\alpha]\langle\beta\rangle\phi, expressing that after all executions of α\alpha, there is an execution of β\beta after which ϕ\phi holds (where \langle\cdot\rangle is the dual operator of [][\cdot] with βϕ\langle\beta\rangle\phi defined as ¬[β]¬ϕ\neg[\beta]\neg\phi). 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 \langle\cdot\rangle, 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 [αβ]ϕ[\alpha\cup\beta]\phi, we prove both formulas [α]ϕ[\alpha]\phi and [β]ϕ[\beta]\phi, where α\alpha and β\beta are sub-regular-expressions of αβ\alpha\cup\beta. 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 αβ\alpha\parallel\beta, the executions of α\alpha and β\beta 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 αβ\alpha\parallel\beta 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 (𝐷𝐿p\mathit{DL}_{p}). 𝐷𝐿p\mathit{DL}_{p} supports a general approach for specification and verification of computer programs and system models. On one hand, 𝐷𝐿p\mathit{DL}_{p} 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, 𝐷𝐿p\mathit{DL}_{p}’s forms are still compatible with the existing structural rules of dynamic logics through a lifting process. This makes 𝐷𝐿p\mathit{DL}_{p} subsume (at least partial) existing dynamic-logic theories into a single logical framework.

1.2 Illustration of Main Idea

Informally, in 𝐷𝐿p\mathit{DL}_{p} we treat dynamic formula [α]ϕ[\alpha]\phi as a ‘parameterized’ one in which program α\alpha and formula ϕ\phi can be of arbitrary forms, provided with a structure σ\sigma called “program configuration” to record current program status for programs’ symbolic executions. So, a 𝐷𝐿p\mathit{DL}_{p} dynamic formula is of the form: σ:[α]ϕ\sigma:[\alpha]\phi, following a convention of labeled formulas. It expresses the same meaning as [α]ϕ[\alpha]\phi in traditional dynamic logics, except that program status is shown explicitly alongside [α]ϕ[\alpha]\phi.

To see how 𝐷𝐿p\mathit{DL}_{p} formulas are powerful for supporting both symbolic-execution-based and structure-based reasoning, consider a simple example. We prove a formula ϕ1=df(x0[x:=x+1]x>0)\phi_{1}=_{df}(x\geq 0\to[x:=x+1]x>0) in first-order dynamic logic [19] (FODL), where xx is a variable ranging over the set of integer numbers. Intuitively, ϕ1\phi_{1} means that if x0x\geq 0 holds, then x>0x>0 holds after the execution of the assignment x:=x+1x:=x+1. In FODL, to derive formula ϕ1\phi_{1}, we apply the structural rule:

ϕ[x/e](x:=e)[x:=e]ϕ\displaystyle[x:=e]\phi\phi[x/e]

for assignment on formula [x:=x+1]x>0[x:=x+1]x>0 by substituting xx of x>0x>0 with x+1x+1, and obtain x+1>0x+1>0. Formula ϕ1\phi_{1} thus becomes ϕ1=df(x0x+1>0)\phi^{\prime}_{1}=_{df}(x\geq 0\to x+1>0), which is true for any integer number xx\in\mathbb{Z}.

While in 𝐷𝐿p\mathit{DL}_{p}, formula ϕ1\phi_{1} can be expressed as a form: ψ1=df(t0{xt}:[x:=x+1]x>0)\psi_{1}=_{df}(t\geq 0\to\{x\mapsto t\}:[x:=x+1]x>0), where formula [x:=x+1]x>0[x:=x+1]x>0 is labeled by configuration {xt}\{x\mapsto t\}, capturing the current program status with tt a free variable, meaning “variable xx has value tt”. This form may seem tedious at first sight. But one soon can find out that with a configuration explicitly showing up, to derive formula ψ1\psi_{1}, we no longer need rule (x:=e)(x:=e), but instead can directly perform a program transition of x:=x+1x:=x+1 as: (x:=x+1,{xt})(,{xt+1})(x:=x+1,\{x\mapsto t\})\longrightarrow(\downarrow,\{x\mapsto t+1\}) 111note that to distinguish ‘\longrightarrow’ and ‘\to, which assign xx’s value with its current value added by 11. Here \downarrow indicates a program termination. Formula ψ1\psi_{1} thus becomes ψ1=df(t0{xt+1}:[]x>0)\psi^{\prime}_{1}=_{df}(t\geq 0\to\{x\mapsto t+1\}:[\downarrow]x>0), which is actually ψ1′′=df(t0{xt+1}:x>0)\psi^{\prime\prime}_{1}=_{df}(t\geq 0\to\{x\mapsto t+1\}:x>0) by eliminating the dynamic part ‘[][\downarrow]’ since \downarrow behaves nothing. By applying configuration {xt+1}\{x\mapsto t+1\} on formula x>0x>0 (which means replacing variable xx of x>0x>0 with its value t+1t+1 in {xt+1}\{x\mapsto t+1\}), we obtain the same valid formula ϕ1\phi^{\prime}_{1}: t0t+1>0t\geq 0\to t+1>0 (modulo the free variables x,tx,t).

The above derivations of 𝐷𝐿p\mathit{DL}_{p} formulas benefit from that for many programs, transitions like (x:=x+1,{xt})(,{xt+1})(x:=x+1,\{x\mapsto t\})\longrightarrow(\downarrow,\{x\mapsto t+1\}) are natural from their operational semantics and can be easily formalized (as will be seen in Appendix 0.B), while structural rules like (x:=e)(x:=e) 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 σ\sigma structurally independent from their dynamic formulas [α]ϕ[\alpha]\phi, 𝐷𝐿p\mathit{DL}_{p} formulas σ:[α]ϕ\sigma:[\alpha]\phi also support programs’ structural rules through a so-called “lifting process” (Section 3.4). This capability provides 𝐷𝐿p\mathit{DL}_{p} 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 ψ\psi above, one can also apply a lifted rule from rule (x:=e)(x:=e):

{xt}:ϕ[x/e]{xt}:[x:=e]ϕ\displaystyle\{x\mapsto t\}:[x:=e]\phi\{x\mapsto t\}:\phi[x/e]

by fixing {xt}\{x\mapsto t\}, and then ψ1\psi_{1} becomes ψ1′′′=df(t0)({xt}:x+1>0)\psi^{\prime\prime\prime}_{1}=_{df}(t\geq 0)\to(\{x\mapsto t\}:x+1>0), which is also formula ϕ1\phi^{\prime}_{1}: t0t+1>0t\geq 0\to t+1>0 after applying configuration {xt}\{x\mapsto t\} on formula x+1>0x+1>0.

1.3 Main Contributions

In this paper, different from the traditional approach that relies on Kripke structures (cf. [20]), we give the semantics of 𝐷𝐿p\mathit{DL}_{p} directly based on the program behaviours of target programs.

After building the logic, we propose a proof system for 𝐷𝐿p\mathit{DL}_{p}, providing a set of rules for reasoning about general programs based on program behaviours. To provide compatibilities of 𝐷𝐿p\mathit{DL}_{p} 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 𝐷𝐿p\mathit{DL}_{p} formula may lead to an infinite proof tree. We develop a cyclic proof (cf. [10]) approach for 𝐷𝐿p\mathit{DL}_{p}. 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 𝐷𝐿p\mathit{DL}_{p} formulas. We propose a “cyclic preproof” structure for 𝐷𝐿p\mathit{DL}_{p} (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 𝐷𝐿p\mathit{DL}_{p} formulas.

  • We build a proof system for 𝐷𝐿p\mathit{DL}_{p}.

  • We construct a cyclic preproof structure for 𝐷𝐿p\mathit{DL}_{p} and prove its soundness.

The rest of the paper is organized as follows. Section 2 defines the syntax and semantics of 𝐷𝐿p\mathit{DL}_{p} formulas. In Section 3, we propose a cyclic proof system for 𝐷𝐿p\mathit{DL}_{p}. In Section 4, we show how 𝐷𝐿p\mathit{DL}_{p} can be useful as a verification framework by giving some examples. Section 5 analyzes and proves the soundness of 𝐷𝐿p\mathit{DL}_{p}. 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 𝐷𝐿p\mathit{DL}_{p}

In this section, we mainly define the syntax and semantics of 𝐷𝐿p\mathit{DL}_{p}. What mostly distinguishes 𝐷𝐿p\mathit{DL}_{p} 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 𝐷𝐿p\mathit{DL}_{p} 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 𝐷𝐿p\mathit{DL}_{p}. They are prerequisites for formally defining 𝐷𝐿p\mathit{DL}_{p}. In Section 2.2 we introduce two examples of instantiations of program structures of 𝐷𝐿p\mathit{DL}_{p} 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 𝐷𝐿p\mathit{DL}_{p}.

2.1 Programs, Configurations and Formulas

The construction of 𝐷𝐿p\mathit{DL}_{p} is based on a set 𝐓𝐀\mathbf{TA} of terms defined over a set 𝑉𝑎𝑟\mathit{Var} of variables and a set Σ\Sigma of signatures. In 𝐓𝐀\mathbf{TA}, we distinguish three subsets 𝐏𝐫𝐨𝐠,𝐂𝐨𝐧𝐟\mathbf{Prog},\mathbf{Conf} and 𝐅𝐨𝐫𝐦\mathbf{Form}, representing the sets of programs, configurations and formulas respectively. 𝐓𝐀𝐏𝐫𝐨𝐠𝐂𝐨𝐧𝐟𝐅𝐨𝐫𝐦\mathbf{TA}\supseteq\mathbf{Prog}\cup\mathbf{Conf}\cup\mathbf{Form}. We use \equiv to represent the identical equivalence between two terms in 𝐓𝐀\mathbf{TA}. A function f:𝐓𝐀𝐓𝐀f:\mathbf{TA}\to\mathbf{TA} is called structural (w.r.t. Σ\Sigma) if it satisfies that for any nn-ary signature snΣs_{n}\in\Sigma (n0n\geq 0, 00-ary signature is a constant) and term sn(t1,,tn)s_{n}(t_{1},...,t_{n}) with t1,,tn𝐓𝐀t_{1},...,t_{n}\in\mathbf{TA}, f(sn(t1,,tn))sn(f1(t1),,fn(tn))f(s_{n}(t_{1},...,t_{n}))\equiv s_{n}(f_{1}(t_{1}),...,f_{n}(t_{n})) for some structural functions f1,,fn:𝐓𝐀𝐓𝐀f_{1},...,f_{n}:\mathbf{TA}\to\mathbf{TA}. Naturally, we assume that a structural function always maps a term to a term with the same type: 𝐏𝐫𝐨𝐠,𝐂𝐨𝐧𝐟\mathbf{Prog},\mathbf{Conf} and 𝐅𝐨𝐫𝐦\mathbf{Form}.

In 𝐏𝐫𝐨𝐠\mathbf{Prog}, there is one distinguished program \downarrow, called termination. It indicates a completion of executions of a program.

Program configurations have impacts on formulas. We assume that 𝐂𝐨𝐧𝐟\mathbf{Conf} is associated with a function :(𝐂𝐨𝐧𝐟×𝐅𝐨𝐫𝐦)𝐅𝐨𝐫𝐦\mathfrak{I}:(\mathbf{Conf}\times\mathbf{Form})\to\mathbf{Form}, called configuration interpretation, that returns a formula by applying a configuration on a formula.

An evaluation ρ:𝐓𝐀𝐓𝐀\rho:\mathbf{TA}\to\mathbf{TA} is a structural function that maps each formula ϕ𝐅𝐨𝐫𝐦\phi\in\mathbf{Form} to a proposition — a special formula that has a boolean semantics of either truth (represented as 11) or falsehood (represented as 0). We denote the set of all propositions as 𝐏𝐫𝐨𝐩\mathbf{Prop}. 𝐏𝐫𝐨𝐩𝐅𝐨𝐫𝐦\mathbf{Prop}\subseteq\mathbf{Form}. The boolean semantics of formulas is expressed by function 𝔗:𝐏𝐫𝐨𝐩{0,1}{\mathfrak{T}}:\mathbf{Prop}\to\{0,1\}. 𝐏𝐫𝐨𝐩\mathbf{Prop} forms the semantical domain as the basis for defining 𝐷𝐿p\mathit{DL}_{p}. An evaluation ρ𝐄𝐯𝐚𝐥\rho\in\mathbf{Eval} satisfies a formula ϕ𝐅𝐨𝐫𝐦\phi\in\mathbf{Form}, denoted by ρ𝔗ϕ\rho\models_{\mathfrak{T}}\phi, if 𝔗(ρ(ϕ))=1{\mathfrak{T}}(\rho(\phi))=1. A formula ϕ𝐅𝐨𝐫𝐦\phi\in\mathbf{Form} is valid, denoted by 𝔗ϕ\models_{\mathfrak{T}}\phi, if ρ𝔗ϕ\rho\models_{\mathfrak{T}}\phi for all ρ𝐄𝐯𝐚𝐥\rho\in\mathbf{Eval}.

In the rest of this paper, we call program domain a special instantiation of structure (𝐓𝐀,𝐄𝐯𝐚𝐥,){(\mathbf{TA},\mathbf{Eval},\mathfrak{I})} for terms 𝐓𝐀\mathbf{TA}, evaluations 𝐄𝐯𝐚𝐥\mathbf{Eval} and functions \mathfrak{I}.

2.2 Examples of Program Domains

We consider two instantiated program domains, namely (𝐓𝐀WP,𝐄𝐯𝐚𝐥WP,WP){(\mathbf{TA}_{{\textit{WP}}},\mathbf{Eval}_{{\textit{WP}}},\mathfrak{I}_{{\textit{WP}}})} and (𝐓𝐀E,𝐄𝐯𝐚𝐥E,E){(\mathbf{TA}_{E},\mathbf{Eval}_{E},\mathfrak{I}_{E})}. Table 1 depicts two program models in these domains respectively: a While program WP𝐏𝐫𝐨𝐠WP\textit{WP}\in\mathbf{Prog}_{\textit{WP}} and an Esterel program E𝐏𝐫𝐨𝐠E\textit{E}\in\mathbf{Prog}_{E}. 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 𝑉𝑎𝑟WP\mathit{Var}_{\textit{WP}} and 𝑉𝑎𝑟E\mathit{Var}_{E} respectively. In program WP, variables are s,n,xs,n,x, whose domain is the set of integer numbers \mathbb{Z}. In program E, variables are xx and SS. xx is also called a “local variable”, with \mathbb{Z} as its domain. Signal SS is a special variable distinguished from local variables, whose domain is {}\mathbb{Z}\cup\{\bot\}, with \bot to express ‘not-happened’ of a signal (also called ‘absence’). Intuitively, assignment x:=ex:=e means assigning the value of an expression ee to a variable xx. Signal emission emitS(e)\textit{emit}\ S(e) means assigning the value of an expression ee to a signal variable SS and broadcasts the value. A mapping xex\mapsto e of a configuration means that variable xx has the value of expression ee. Formulas are first-order logical formulas in the domain \mathbb{Z} or {}\mathbb{Z}\cup\{\bot\} with arithmetical expressions. Examples are n>0n>0, x.x+y=0\forall x.x+y=0, x>0y>0x>0\wedge y>0, 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 {x5,y1}\{x\mapsto 5,y\mapsto 1\} has variable xx storing value 55 and variable yy storing value 11. On the other hand, a configuration of an Esterel program is a variable stack, allowing several (local) variables with the same name. For example, {x5|y1|y2}\{x\mapsto 5\operatorname{|}y\mapsto 1\operatorname{|}y\mapsto 2\} represents a configuration in which there are 3 variables: xx, and two yys storing different values. The separator ‘|\operatorname{|}’ 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 x:=()x:=(\cdot), or quantifiers x.(),x.()\forall x.(\cdot),\exists x.(\cdot). Let FVN:𝐓𝐀N𝑉𝑎𝑟N\textit{FV}_{N}:\mathbf{TA}_{N}\to\mathit{Var}_{N} (N{WP,E}N\in\{\textit{WP},E\}) return the set of all free variables of a term. For example, in program WP, variable nn of expression n1n-1 in n:=n1n:=n-1 and variable ss of expression s+ns+n in s:=s+ns:=s+n are bound by the assignments: n:=()n:=(\cdot) and s:=()s:=(\cdot) respectively, while variable nn is free in formula n>0n>0 and in expression s+ns+n of assignment s:=s+ns:=s+n. So FVWP(WP)={n}\textit{FV}_{\textit{WP}}(\textit{WP})=\{n\}. In a configuration, while mapping xx\mapsto\cdot is a binder for labeled formulas (as defined in Appendix 0.B), a variable in an expression ee of a mapping xex\mapsto e is always free, since interpretation WP\mathfrak{I}_{\textit{WP}} introduced below is simply a type of substitutions.

An evaluation ρ(t)\rho(t) (ρ𝐄𝐯𝐚𝐥WP\rho\in\mathbf{Eval}_{\textit{WP}} or ρ𝐄𝐯𝐚𝐥E\rho\in\mathbf{Eval}_{E}) returns a “closed term” (terms without free variables) by replacing each free variable of term tt with a value in \mathbb{Z} or {}\mathbb{Z}\cup\{\bot\}. For example, if ρ(n)=5\rho(n)=5, then ρ(n>0)=(5>0)\rho(n>0)=(5>0). 5>05>0 is a proposition with a boolean semantics: 𝔗N(5>0)=1{\mathfrak{T}}_{N}(5>0)=1 in the theory of integer numbers. A substitution t[e/x]t[e/x] replaces each free variable xx of tt with term ee.

Given a configuration σ\sigma and a formula ϕ\phi, in a While program, the interpretation WP(σ,ϕ)\mathfrak{I}_{\textit{WP}}(\sigma,\phi) is defined as a type of substitutions (see Appendix 0.B). It replaces each free variable xx of ϕ\phi with its value stored in σ\sigma. For example, WP({n1,s0},n>0)=(1>0)\mathfrak{I}_{\textit{WP}}(\{n\mapsto 1,s\mapsto 0\},n>0)=(1>0). In an Esterel program, on the other hand, the interpretation E(σ,ϕ)\mathfrak{I}_{E}(\sigma,\phi) replaces each free variable xx of ϕ\phi with the value of the top-most variable xx in σ\sigma. For instance, E({n1|n2|s0},n>0)=(2>0)\mathfrak{I}_{E}(\{n\mapsto 1\ |\ n\mapsto 2\ |\ s\mapsto 0\},n>0)=(2>0) (by taking the value 22 of the right nn).

A While program: WP =df{while(n>0)dos:=s+n;n:=n1end},\begin{aligned} =_{df}&\{\textit{while}\ (n>0)\ \textit{do}\ s:=s+n\ ;\ n:=n-1\ \textit{end}\ \},\end{aligned} Configuration: {x1e1,x2e2,,xnen},(n0)\{x_{1}\mapsto e_{1},x_{2}\mapsto e_{2},...,x_{n}\mapsto e_{n}\},\ \ (n\geq 0) An Esterel program: EE =df{trapABend},=_{df}\{\textit{trap}\ A\parallel B\ \textit{end}\}, where A=df{loop(emitS(0);x:=xS;ifx=0thenexitend;pause)end},B=df{loop(emitS(1);pause)end}\begin{aligned} A=_{df}&\ \{\textit{loop}\ (\textit{emit}\ S(0)\ ;\ x:=x-S\ ;\ \textit{if}\ x=0\ \textit{then}\ \textit{exit}\ \textit{end}\ ;\ \textit{pause})\ \textit{end}\},\\ B=_{df}&\ \{\textit{loop}\ (\textit{emit}\ S(1)\ ;\ \textit{pause})\ \textit{end}\}\end{aligned} Configuration: {x1e1|x2e2||xnen},(n0)\{x_{1}\mapsto e_{1}\ |\ x_{2}\mapsto e_{2}\ |\ ...\ |\ x_{n}\mapsto e_{n}\},\ \ (n\geq 0)

Table 1: An Example of Program Domains

2.3 Program Behaviours

Program Behaviours. A program state is a pair (α,σ)𝐏𝐫𝐨𝐠×𝐂𝐨𝐧𝐟(\alpha,\sigma)\in\mathbf{Prog}\times\mathbf{Conf} of programs and configurations. In 𝐅𝐨𝐫𝐦\mathbf{Form}, we assume a binary relation (α,σ)(α,σ)(\alpha,\sigma)\longrightarrow(\alpha^{\prime},\sigma^{\prime}) called a program transition between two program states (α,σ)(\alpha,\sigma) and (α,σ)(\alpha^{\prime},\sigma^{\prime}). For any evaluation ρ𝐄𝐯𝐚𝐥\rho\in\mathbf{Eval}, proposition ρ((α,σ)(α,σ))\rho((\alpha,\sigma)\longrightarrow(\alpha^{\prime},\sigma^{\prime})) is assumed to be defined as: ρ((α,σ)(α,σ))=dfρ(α,σ)ρ(α,σ)\rho((\alpha,\sigma)\longrightarrow(\alpha^{\prime},\sigma^{\prime}))=_{df}\rho(\alpha,\sigma)\longrightarrow\rho(\alpha^{\prime},\sigma^{\prime}). Program behaviours, denoted by Λ\Lambda, is the set of all true program transitions:

Λ=df{(α,σ)(α,σ)|𝔗((α,σ)(α,σ))=1},\Lambda=_{df}\{(\alpha,\sigma)\longrightarrow(\alpha^{\prime},\sigma^{\prime})\ |\ {\mathfrak{T}}((\alpha,\sigma)\longrightarrow(\alpha^{\prime},\sigma^{\prime}))=1\},

which is assumed to be well-defined in the sense that there is no true transitions of the form: (,σ)(\downarrow,\sigma)\longrightarrow... from a terminal program.

A path trtr over Λ\Lambda is a finite or infinite sequence: s1s2sns_{1}s_{2}...s_{n}... (n1n\geq 1), where for each pair (si,si+1)(s_{i},s_{i+1}) (i1i\geq 1), (sisi+1)Λ(s_{i}\longrightarrow s_{i+1})\in\Lambda is a true program transition. A path is terminal, if it ends with program \downarrow in the form of (α1,σ1)(,σn)(\alpha_{1},\sigma_{1})...(\downarrow,\sigma_{n}) (n1n\geq 1). We call a path minimum, in the sense that in it there is no two identical program states. A state ss is called terminal, if from ss there is a terminal path over Λ\Lambda.

In order to reason about termination of a program, in 𝐅𝐨𝐫𝐦\mathbf{Form} we assume a unary operator (α,σ)(\alpha,\sigma)\Downarrow called the termination of a program state (α,σ)(\alpha,\sigma). For an evaluation ρ𝐄𝐯𝐚𝐥\rho\in\mathbf{Eval}, proposition ρ((α,σ))\rho((\alpha,\sigma)\Downarrow) is defined as: ρ((α,σ))=df(ρ(α,σ))\rho((\alpha,\sigma)\Downarrow)=_{df}(\rho(\alpha,\sigma))\Downarrow. 𝔗((α,σ))=df1{\mathfrak{T}}((\alpha,\sigma)\Downarrow)=_{df}1 if there exists a terminal path over Λ\Lambda starting from (α,σ)(\alpha,\sigma). We use Ω\Omega to denote the set of all true program terminations: Ω=df{(α,σ)|𝔗((α,σ))=1}\Omega=_{df}\{(\alpha,\sigma)\Downarrow\ |\ {\mathfrak{T}}((\alpha,\sigma)\Downarrow)=1\}.

For programming languages, usually, program behaviours Λ\Lambda (also program terminations Ω\Omega) are defined as structural operational semantics [33] of Plotkin’s style expressed as a set of rules, in a manner that a transition 𝔗((α,σ)(α,σ))=1{\mathfrak{T}}((\alpha,\sigma)\longrightarrow(\alpha^{\prime},\sigma^{\prime}))=1 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 (WP,{n5,s0})(WP,{n5,s5})(\textit{WP},\{n\mapsto 5,s\mapsto 0\})\longrightarrow(\textit{WP}^{\prime},\{n\mapsto 5,s\mapsto 5\}), where WP=dfn:=n1;WP\textit{WP}^{\prime}=_{df}n:=n-1\ ;\ \textit{WP}, by executing assignment s:=s+ns:=s+n. This transition is also a program behaviour, since it matches the operational semantics of s:=s+ns:=s+n (see Table 6 of Appendix 0.B for more details). However, transition (WP,{nv,s0})(WP,{nv,s5})(\textit{WP},\{n\mapsto v,s\mapsto 0\})\longrightarrow(\textit{WP}^{\prime},\{n\mapsto v,s\mapsto 5\}) is not a proposition, because its truth value depends on whether v>0v>0 is true.

Restrictions on Program Behaviours. In this paper, our current research on the proof system of 𝐷𝐿p\mathit{DL}_{p} (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 Λ\Lambda, it satisfies that for each program state (α,σ)(\alpha,\sigma), the following properties hold:

  1. 1.

    Branching Finiteness. From (α,σ)(\alpha,\sigma), there exists only a finite number of transitions.

  2. 2.

    Termination Finiteness. From (α,σ)(\alpha,\sigma), 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 𝐷𝐿p\mathit{DL}_{p}

Based on the assumed sets 𝐏𝐫𝐨𝐠,𝐂𝐨𝐧𝐟\mathbf{Prog},\mathbf{Conf} and 𝐅𝐨𝐫𝐦\mathbf{Form}, we give the syntax of 𝐷𝐿p\mathit{DL}_{p} as follows.

Definition 2 (𝐷𝐿p\mathit{DL}_{p} Formulas)

A parameterized dynamic logical (𝐷𝐿p\mathit{DL}_{p}) formula ϕ\phi is defined as follows in BNF form:

ψ=df\displaystyle\psi=_{df} F|¬ψ|ψψ|[α]ψ,\displaystyle\ F\ |\ \neg\psi\ |\ \psi\wedge\psi\ |\ [\alpha]\psi,
ϕ=df\displaystyle\phi=_{df} F|σ:ψ|¬ϕ|ϕϕ,\displaystyle\ F\ |\ \sigma:\psi\ |\ \neg\phi\ |\ \phi\wedge\phi,

where F𝐅𝐨𝐫𝐦F\in\mathbf{Form}, α𝐏𝐫𝐨𝐠\alpha\in\mathbf{Prog} and σ𝐂𝐨𝐧𝐟\sigma\in\mathbf{Conf}.

We denote the set of 𝐷𝐿p\mathit{DL}_{p} formulas as 𝐃𝐋𝐩\mathbf{DL_{p}}.

σ\sigma and ϕ\phi are called the label and the unlabeled part of formula σ:ϕ\sigma:\phi respectively. We call [α][\alpha] the dynamic part of a formula, and call a 𝐷𝐿p\mathit{DL}_{p} formula having dynamic parts a dynamic formula. Intuitively, formula [α]ϕ[\alpha]\phi means that after all executions of program α\alpha, formula ϕ\phi holds. \langle\cdot\rangle is the dual operator of [][\cdot]. Formula αϕ\langle\alpha\rangle\phi can be written as ¬[α]¬ϕ\neg[\alpha]\neg\phi. Other formulas with logical connectives such as \vee and \to can be expressed by formulas with ¬\neg and \wedge accordingly. Formula σ:ϕ\sigma:\phi means that ϕ\phi holds under configuration σ\sigma, as σ\sigma has an impact on the semantics of formulas as indicated by interpretation \mathfrak{I}.

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 𝐷𝐿p\mathit{DL}_{p}, we define the semantics by extending ρ\rho and 𝔗{\mathfrak{T}} from Section 2.1 to formulas 𝐃𝐋𝐩\mathbf{DL_{p}} and directly base on program behaviours Λ\Lambda.

Definition 3 (Semantics of 𝐷𝐿p\mathit{DL}_{p} Formulas)

An evaluation ρ𝐄𝐯𝐚𝐥\rho\in\mathbf{Eval} structurally maps a 𝐷𝐿p\mathit{DL}_{p} formula ϕ\phi into a proposition, whose truth value is defined inductively as follows by extending 𝔗{\mathfrak{T}}:

  1. 1.

    𝔗(ρ(F)){\mathfrak{T}}(\rho(F)) is already defined, if F𝐅𝐨𝐫𝐦F\in\mathbf{Form};

  2. 2.

    𝔗(ρ(σ:F))=df1{\mathfrak{T}}(\rho(\sigma:F))=_{df}1, if F𝐅𝐨𝐫𝐦F\in\mathbf{Form} and ρ𝔗(σ,F)\rho\models_{\mathfrak{T}}\mathfrak{I}(\sigma,F);

  3. 3.

    𝔗(ρ(σ:¬ϕ))=df𝔗(ρ(¬(σ:ϕ))){\mathfrak{T}}(\rho(\sigma:\neg\phi))=_{df}{\mathfrak{T}}(\rho(\neg(\sigma:\phi)));

  4. 4.

    𝔗(ρ(σ:ϕ1ϕ2))=df𝔗(ρ((σ:ϕ1)(σ:ϕ2))){\mathfrak{T}}(\rho(\sigma:\phi_{1}\wedge\phi_{2}))=_{df}{\mathfrak{T}}(\rho((\sigma:\phi_{1})\wedge(\sigma:\phi_{2})));

  5. 5.

    𝔗(ρ(σ:[α]ϕ))=df1{\mathfrak{T}}(\rho(\sigma:[\alpha]\phi))=_{df}1, if for all terminal paths (α1,σ1)(,σn)(\alpha_{1},\sigma_{1})...(\downarrow,\sigma_{n}) (n1n\geq 1) over Λ\Lambda with (α1,σ1)ρ(α,σ)(\alpha_{1},\sigma_{1})\equiv\rho(\alpha,\sigma), 𝔗(ρ(σn:ϕ))=df1{\mathfrak{T}}(\rho(\sigma_{n}:\phi))=_{df}1;

  6. 6.

    𝔗(ρ(¬ϕ))=df1{\mathfrak{T}}(\rho(\neg\phi))=_{df}1, if 𝔗(ρ(ϕ))=0{\mathfrak{T}}(\rho(\phi))=0;

  7. 7.

    𝔗(ρ(ϕ1ϕ2))=df1{\mathfrak{T}}(\rho(\phi_{1}\wedge\phi_{2}))=_{df}1, if both 𝔗(ρ(ϕ1))=1{\mathfrak{T}}(\rho(\phi_{1}))=1 and 𝔗(ρ(ϕ2))=1{\mathfrak{T}}(\rho(\phi_{2}))=1;

  8. 8.

    𝔗(ρ(ϕ))=df0{\mathfrak{T}}(\rho(\phi))=_{df}0 for any ϕ𝐃𝐋𝐩\phi\in\mathbf{DL_{p}}, otherwise.

For any ϕ𝐃𝐋𝐩\phi\in\mathbf{DL_{p}}, write ρ𝔗ϕ\rho\models_{\mathfrak{T}}\phi if 𝔗(ρ(ϕ))=1{\mathfrak{T}}(\rho(\phi))=1, or simply ρϕ\rho\models\phi.

Notice that for a 𝐷𝐿p\mathit{DL}_{p} formula ϕ\phi, how ρ(ϕ)\rho(\phi) is defined explicitly can vary from case to case. In Definition 3, we only assume that ρ\rho is structural and ρ(ϕ)\rho(\phi) must be a proposition. An example of evaluation ρ\rho is given in Appendix 0.B.

According to the semantics of operator \langle\cdot\rangle, we can have that 𝔗(ρ(αϕ))=1{\mathfrak{T}}(\rho(\langle\alpha\rangle\phi))=1 iff there exists a terminal path (α1,σ1)(,σn)(\alpha_{1},\sigma_{1})...(\downarrow,\sigma_{n}) (n1n\geq 1) over Λ\Lambda with (α1,σ1)ρ(α,σ)(\alpha_{1},\sigma_{1})\equiv\rho(\alpha,\sigma) such that 𝔗(ρ(σn:ϕ))=1{\mathfrak{T}}(\rho(\sigma_{n}:\phi))=1.

A 𝐷𝐿p\mathit{DL}_{p} formula ϕ\phi is called valid, if ρϕ\rho\models\phi for all evaluation ρ𝐄𝐯𝐚𝐥\rho\in\mathbf{Eval}.

Example 2 (𝐷𝐿p\mathit{DL}_{p} Specifications)

A property of program WP𝐏𝐫𝐨𝐠WP\textit{WP}\in\mathbf{Prog}_{\textit{WP}} (Table 1) is described as the following formula

v0σ1:[WP]s=((v+1)v)/2,v\geq 0\to\sigma_{1}:[\textit{WP}]s=((v+1)v)/2,

where σ1=df{nv,s0}\sigma_{1}=_{df}\{n\mapsto v,s\mapsto 0\} with vv a free variable. This formula means that given an initial value v0v\geq 0, after executing WP, ss equals to ((v+1)v)/2((v+1)v)/2, which is the sum of 1+2++v1+2+...+v. We will prove this formula in Section 4.1.

3 A Cyclic Proof System for 𝐷𝐿p\mathit{DL}_{p}

In this section, we propose a cyclic proof system for 𝐷𝐿p\mathit{DL}_{p}. In Section 3.2, we firstly propose a proof system PDLP{P_{\textit{DLP}}} to support reasoning based on program behaviours. Then in Section 3.3 we construct a cyclic preproof structure for PDLP{P_{\textit{DLP}}}, which support deriving infinite proof trees under certain soundness conditions. In Section 3.4, we propose a lifting process to allow 𝐷𝐿p\mathit{DL}_{p} 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 𝐷𝐿p\mathit{DL}_{p}. Sequent is convenient for goal-directed reversed derivation procedure which many general theorem provers, such as Coq and Isabelle, are based on.

A sequent ν\nu is a logical argumentation of the form:

ΓΔ,\Gamma\Rightarrow\Delta,

where Γ\Gamma and Δ\Delta are finite multi-sets of formulas split by an arrow \Rightarrow, called the left side and the right side of the sequent respectively. We use dot \cdot to express Γ\Gamma or Δ\Delta when they are empty sets. A sequent ΓΔ\Gamma\Rightarrow\Delta expresses the formula ϕΓϕψΔψ\bigwedge_{\phi\in\Gamma}\phi\to\bigvee_{\psi\in\Delta}\psi, denoted by 𝔓(ΓΔ)\mathfrak{P}(\Gamma\Rightarrow\Delta), meaning that if all formulas in Γ\Gamma hold, then one of formulas in Δ\Delta holds.

Inference Rules. An inference rule is of the form

ν1νnν,\displaystyle\nu\lx@proof@logical@and\nu_{1}...\nu_{n},

where each of ν,νi\nu,\nu_{i} (1in1\leq i\leq n) is also called a node. Each of ν1,,νn\nu_{1},...,\nu_{n} is called a premise, and ν\nu is called the conclusion, of the rule. The semantics of the rule is that if the validity of formulas 𝔓(ν1),,𝔓(νn)\mathfrak{P}(\nu_{1}),...,\mathfrak{P}(\nu_{n}) implies the validity of formula 𝔓(ν)\mathfrak{P}(\nu). A formula pair (τ,τi)(\tau,\tau_{i}) (1in1\leq i\leq n) with formula τ\tau in node ν\nu and formula τi\tau_{i} in node νi\nu_{i} is called a conclusion-premise (CP) pair.

We use a double-lined inference form:

ϕ1ϕnϕ\phi\lx@proof@logical@and\phi_{1}...\phi_{n}

to represent both rules

Γϕ1,ΔΓϕn,ΔΓϕ,ΔandΓ,ϕ1Δ...Γ,ϕnΔΓ,ϕΔ,\begin{aligned} \Gamma\Rightarrow\phi,\Delta\lx@proof@logical@and\Gamma\Rightarrow\phi_{1},\Delta...\Gamma\Rightarrow\phi_{n},\Delta\end{aligned}\ \ \mbox{and}\ \ \begin{aligned} \Gamma,\phi\Rightarrow\Delta\lx@proof@logical@and\Gamma,\phi_{1}\Rightarrow\Delta...\Gamma,\phi_{n}\Rightarrow\Delta\end{aligned},

provided any sets Γ\Gamma and Δ\Delta. We often call the CP pair (ϕ,ϕi)(\phi,\phi_{i}) (1in1\leq i\leq n) a target pair, call ϕ,ϕi\phi,\phi_{i} target formulas. Γ\Gamma and Δ\Delta 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 PP consists of a set of inference rules. We say that a node ν\nu can be derived from PP, denoted by Pν\vdash_{P}\nu, if a finite proof tree with ν\nu the root node can be formed by applying the rules in PP.

Notice that the rules with names shown in the tables below in this paper (e.g. rule ([α])([\alpha]) in Table 3) are actually rule schemata, that is, inferences rules with meta variables as parameters (e.g. “Γ,Δ,σ,α,ϕ,σ,α\Gamma,\Delta,\sigma,\alpha,\phi,\sigma^{\prime},\alpha^{\prime}” in rule ([α])([\alpha])). 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 𝐷𝐿p\mathit{DL}_{p}

The proof system PDLP{P_{\textit{DLP}}} of 𝐷𝐿p\mathit{DL}_{p} relies on a pre-defined proof system PΛ,ΩP_{\Lambda,\Omega} for deriving program behaviours Λ\Lambda and terminations Ω\Omega. PΛ,ΩP_{\Lambda,\Omega} is sound and complete w.r.t. Λ\Lambda and Ω\Omega in the sense that for any transition (α1,σ1)(α2,σ2)𝐏𝐫𝐨𝐩(\alpha_{1},\sigma_{1})\longrightarrow(\alpha_{2},\sigma_{2})\in\mathbf{Prop} and termination (α,σ)𝐏𝐫𝐨𝐩(\alpha,\sigma)\Downarrow\ \in\mathbf{Prop}, (α1,σ1)(α2,σ2)Λ(\alpha_{1},\sigma_{1})\longrightarrow(\alpha_{2},\sigma_{2})\in\Lambda iff PΛ,Ω(α1,σ1)(α2,σ2)\vdash_{P_{\Lambda,\Omega}}\cdot\Rightarrow(\alpha_{1},\sigma_{1})\longrightarrow(\alpha_{2},\sigma_{2}), and (α,σ)Ω(\alpha,\sigma)\Downarrow\ \in\Omega iff PΛ,Ω(α,σ)\vdash_{P_{\Lambda,\Omega}}\cdot\Rightarrow(\alpha,\sigma)\Downarrow.

Note that in PDLP{P_{\textit{DLP}}}, we usually assume that a formula does not contain a program transition or termination.

(x:=e)Γ(x:=e,σ)(,σσ(e)x),Δ\Gamma\Rightarrow(x:=e,\sigma)\longrightarrow(\downarrow,\sigma^{x}_{\sigma^{*}(e)}),\Delta   Γ(α1,σ)(α1,σ),Δ(;)Γ(α1;α2,σ)(α1;α2,σ),Δ\Gamma\Rightarrow(\alpha_{1};\alpha_{2},\sigma)\longrightarrow(\alpha^{\prime}_{1};\alpha_{2},\sigma^{\prime}),\Delta\Gamma\Rightarrow(\alpha_{1},\sigma)\longrightarrow(\alpha^{\prime}_{1},\sigma^{\prime}),\Delta Γ(α1,σ)(,σ),Δ(;)Γ(α1;α2,σ)(α2,σ),Δ\Gamma\Rightarrow(\alpha_{1};\alpha_{2},\sigma)\longrightarrow(\alpha_{2},\sigma^{\prime}),\Delta\Gamma\Rightarrow(\alpha_{1},\sigma)\longrightarrow(\downarrow,\sigma^{\prime}),\Delta   Γ,WP(σ,ϕ)(α,σ)(α,σ),ΔΓWP(σ,ϕ),Δ(wh1)Γ(whileϕdoαend,σ)(α;whileϕdoαend,σ),Δ\Gamma\Rightarrow(\textit{while}\ \phi\ \textit{do}\ \alpha\ \textit{end},\sigma)\longrightarrow(\alpha^{\prime};\ \textit{while}\ \phi\ \textit{do}\ \alpha\ \textit{end},\sigma^{\prime}),\Delta\lx@proof@logical@and\Gamma,\mathfrak{I}_{\textit{WP}}(\sigma,\phi)\Rightarrow(\alpha,\sigma)\longrightarrow(\alpha^{\prime},\sigma^{\prime}),\Delta\Gamma\Rightarrow\mathfrak{I}_{\textit{WP}}(\sigma,\phi),\Delta Γ,WP(σ,ϕ)(α,σ)(,σ),ΔΓWP(σ,ϕ),Δ(wh1)Γ(whileϕdoαend,σ)(whileϕdoαend,σ),Δ\Gamma\Rightarrow(\textit{while}\ \phi\ \textit{do}\ \alpha\ \textit{end},\sigma)\longrightarrow(\textit{while}\ \phi\ \textit{do}\ \alpha\ \textit{end},\sigma^{\prime}),\Delta\lx@proof@logical@and\Gamma,\mathfrak{I}_{\textit{WP}}(\sigma,\phi)\Rightarrow(\alpha,\sigma)\longrightarrow(\downarrow,\sigma^{\prime}),\Delta\Gamma\Rightarrow\mathfrak{I}_{\textit{WP}}(\sigma,\phi),\Delta   Γ¬WP(σ,ϕ),Δ(wh2)Γ(whileϕdoαend,σ)(,σ),Δ\Gamma\Rightarrow(\textit{while}\ \phi\ \textit{do}\ \alpha\ \textit{end},\sigma)\longrightarrow(\downarrow,\sigma),\Delta\Gamma\Rightarrow\neg\mathfrak{I}_{\textit{WP}}(\sigma,\phi),\Delta

Table 2: Partial Inference Rules for Program Behaviours of While programs
Example 3

As an example, Table 2 displays a part of inference rules of the proof system PΛWP,ΩWPP_{\Lambda_{\textit{WP}},\Omega_{\textit{WP}}} for the program behaviours ΛWP\Lambda_{\textit{WP}}, 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, σex\sigma^{x}_{e} represents a configuration that store variable xx as value ee, while storing other variables as the same value as σ\sigma. Similarly to WP\mathfrak{I}_{\textit{WP}}, σ(e)\sigma^{*}(e) is defined to return a term obtained by replacing each free variable xx of ee by the value of xx in σ\sigma (see Appendix 0.B).

Table 3 lists the primitive rules of PDLP{P_{\textit{DLP}}}. Through PDLP{P_{\textit{DLP}}}, a 𝐷𝐿p\mathit{DL}_{p} 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 (α)(\langle\alpha\rangle) instead of the version of rule ([α])([\alpha]) for the left-side derivations, which can be derived using (α)(\langle\alpha\rangle) and rules (¬L)(\neg L) and (¬R)(\neg R). The rules for other operators like \vee, \to can be derived accordingly using the rules in Table 3.

{Γσ:[α]ϕ,Δ}(α,σ)Φ1([α])Γσ:[α]ϕ,Δ\begin{aligned} \Gamma\Rightarrow\sigma:[\alpha]\phi,\Delta\{\Gamma\Rightarrow\sigma^{\prime}:[\alpha^{\prime}]\phi,\Delta\}_{(\alpha^{\prime},\sigma^{\prime})\in\Phi}\end{aligned},   where Φ=df{(α,σ)|PΛ,Ω(Γ(α,σ)(α,σ),Δ)}\Phi=_{df}\{(\alpha^{\prime},\sigma^{\prime})\ |\ \mbox{$\vdash_{P_{\Lambda,\Omega}}(\Gamma\Rightarrow(\alpha,\sigma)\longrightarrow(\alpha^{\prime},\sigma^{\prime}),\Delta)$}\} Γσ:αϕ,Δ1(α)Γσ:αϕ,Δ\begin{aligned} \Gamma\Rightarrow\sigma:\langle\alpha\rangle\phi,\Delta\Gamma\Rightarrow\sigma^{\prime}:\langle\alpha^{\prime}\rangle\phi,\Delta\end{aligned},   if PΛ,Ω(Γ(α,σ)(α,σ),Δ)\vdash_{P_{\Lambda,\Omega}}(\Gamma\Rightarrow(\alpha,\sigma)\longrightarrow(\alpha^{\prime},\sigma^{\prime}),\Delta) 2(Ter)ΓΔ\begin{aligned} \Gamma\Rightarrow\Delta\end{aligned}   (σ,ϕ)3(Int)σ:ϕ\begin{aligned} \sigma:\phi\mathfrak{I}(\sigma,\phi)\end{aligned}   σ:ϕ([])σ:[]ϕ\begin{aligned} \sigma:[\downarrow]\phi\sigma:\phi\end{aligned}   ΓΔ4(Sub)Sub(Γ)Sub(Δ)\begin{aligned} {\textit{Sub}}(\Gamma)\Rightarrow{\textit{Sub}}(\Delta)\Gamma\Rightarrow\Delta\end{aligned}   ¬(σ:ϕ)(σ¬)σ:(¬ϕ)\begin{aligned} \sigma:(\neg\phi)\neg(\sigma:\phi)\end{aligned}   (σ:ϕ)(σ:ψ)(σ)σ:(ϕψ)\begin{aligned} \sigma:(\phi\wedge\psi)(\sigma:\phi)\wedge(\sigma:\psi)\end{aligned} (ax)Γ,ϕϕ,Δ\begin{aligned} \Gamma,\phi\Rightarrow\phi,\Delta\end{aligned}   Γϕ,ΔΓ,ϕΔ(Cut)ΓΔ\begin{aligned} \Gamma\Rightarrow\Delta\lx@proof@logical@and\Gamma\Rightarrow\phi,\Delta\Gamma,\phi\Rightarrow\Delta\end{aligned}   ΓΔ(Wk L)Γ,ϕΔ\begin{aligned} \Gamma,\phi\Rightarrow\Delta\Gamma\Rightarrow\Delta\end{aligned}   ΓΔ(Wk R)Γϕ,Δ\begin{aligned} \Gamma\Rightarrow\phi,\Delta\Gamma\Rightarrow\Delta\end{aligned}   ϕ,ϕ(Con)ϕ\begin{aligned} \phi\phi,\phi\end{aligned} Γϕ,Δ(¬L)Γ,¬ϕΔ\begin{aligned} \Gamma,\neg\phi\Rightarrow\Delta\Gamma\Rightarrow\phi,\Delta\end{aligned}   Γ,ϕΔ(¬R)Γ¬ϕ,Δ\begin{aligned} \Gamma\Rightarrow\neg\phi,\Delta\Gamma,\phi\Rightarrow\Delta\end{aligned}   Γ,ϕ,ψΔ(L)Γ,ϕψΔ\begin{aligned} \Gamma,\phi\wedge\psi\Rightarrow\Delta\Gamma,\phi,\psi\Rightarrow\Delta\end{aligned}   Γϕ,ΔΓψ,Δ(R)Γϕψ,Δ\begin{aligned} \Gamma\Rightarrow\phi\wedge\psi,\Delta\lx@proof@logical@and\Gamma\Rightarrow\phi,\Delta\Gamma\Rightarrow\psi,\Delta\end{aligned} 1 α\alpha\not\equiv\downarrow. 2 for each ϕ\phi in Γ\Gamma or Δ\Delta, ϕ𝐅𝐨𝐫𝐦\phi\in\mathbf{Form}; 𝔓(ΓΔ)\mathfrak{P}(\Gamma\Rightarrow\Delta) is valid. 3 ϕ𝐅𝐨𝐫𝐦\phi\in\mathbf{Form} is a non-dynamic formula. 4 Sub is a substitution by Definition 4.

Table 3: Primitive Rules of Proof System PDLP{P_{\textit{DLP}}}

Illustration of each rule is as follows.

Rules ([α])([\alpha]) and (α)(\langle\alpha\rangle) deal with dynamic parts of 𝐷𝐿p\mathit{DL}_{p} formulas based on program transitions. Both rules rely on the sub-proof-procedures of system PΛ,ΩP_{\Lambda,\Omega}. In rule ([α])([\alpha]), {}(α,σ)Φ\{...\}_{(\alpha^{\prime},\sigma^{\prime})\in\Phi} represents the collection of premises for all program states (α,σ)Φ(\alpha^{\prime},\sigma^{\prime})\in\Phi. By the finiteness of branches of program hehaviours (Definition 1-1), set Φ\Phi must be finite. So rule ([α])([\alpha]) only has a finite number of premises. Note that when Φ\Phi is empty, the conclusion terminates. Intuitively, rule ([α])([\alpha]) says that to prove that [α]ϕ[\alpha]\phi holds under configuration σ\sigma, we prove that for each transition from (α,σ)(\alpha,\sigma) to (α,σ)(\alpha^{\prime},\sigma^{\prime}), [α]ϕ[\alpha^{\prime}]\phi holds under configuration σ\sigma^{\prime}. Compared to rule ([α])([\alpha]), rule (α)(\langle\alpha\rangle) has only one premise for (α,σ)(\alpha^{\prime},\sigma^{\prime}). Intuitively, rule (α)(\langle\alpha\rangle) says that to prove αϕ\langle\alpha\rangle\phi holds under configuration σ\sigma, we prove that after some transition from (α,σ)(\alpha,\sigma) to (α,σ)(\alpha^{\prime},\sigma^{\prime}), αϕ\langle\alpha^{\prime}\rangle\phi holds under configuration σ\sigma^{\prime}.

In rule (Ter)(\textit{Ter}), each formula in Γ\Gamma and Δ\Delta is a formula in 𝐅𝐨𝐫𝐦\mathbf{Form}. Rule (Ter)(\textit{Ter}) terminates if formula 𝔓(ΓΔ)\mathfrak{P}(\Gamma\Rightarrow\Delta) is valid. The introduction rule (Int)(\textit{Int}) for labels is applied when ϕ\phi is a formula without any dynamic parts. Through this rule we eliminate a configuration σ\sigma and obtain a formula (σ,ϕ)\mathfrak{I}(\sigma,\phi) in 𝐅𝐨𝐫𝐦\mathbf{Form}. Rule ([])([\downarrow]) deals with the situation when the program is a termination \downarrow. Its soundness is straightforward by the well-definedness of program behaviours Λ\Lambda.

Rule (Sub)({\textit{Sub}}) describes a specialization process for 𝐷𝐿p\mathit{DL}_{p} formulas. For a set AA of formulas, Sub(A)=df{Sub(ϕ)|ϕA}{\textit{Sub}}(A)=_{df}\{{\textit{Sub}}(\phi)\ |\ \phi\in A\}, with Sub a function defined as follows in Definition 4. Intuitively, if formula 𝔓(ΓΔ)\mathfrak{P}(\Gamma\Rightarrow\Delta) is valid, then its one of special cases 𝔓(Sub(Γ)Sub(Δ))\mathfrak{P}({\textit{Sub}}(\Gamma)\Rightarrow{\textit{Sub}}(\Delta)) through an abstract version of substitutions Sub on formulas is valid. Rule (Sub)({\textit{Sub}}) 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 η:𝐓𝐀𝐓𝐀\eta:\mathbf{TA}\to\mathbf{TA} is called a ‘substitution’, if for any evaluation ρ𝐄𝐯𝐚𝐥\rho\in\mathbf{Eval}, there exists a ρ𝐄𝐯𝐚𝐥\rho^{\prime}\in\mathbf{Eval} such that ρ(η(ϕ))ρ(ϕ)\rho(\eta(\phi))\equiv\rho^{\prime}(\phi) for each formula ϕ𝐃𝐋𝐩\phi\in\mathbf{DL_{p}}.

Rules (σ¬)(\sigma\neg) and (σ)(\sigma\wedge) are for transforming labeled formulas. Their soundness are direct according to the semantics of labeled formulas (Definition 3).

From rule (ax)(\textit{ax}) to (σR)(\sigma\wedge R) are the rules inherited from traditional first-order logic. Note that rule (Cut)(\textit{Cut}) and rules (WkL)(\textit{Wk}L) and (WkR)(\textit{Wk}R) have no target pairs. The meanings of these rules are classical and we omit their discussions here.

The soundness of the rules in PDLP{P_{\textit{DLP}}} is stated as follows.

Theorem 3.1

Provided that proof system PΛ,ΩP_{\Lambda,\Omega} is sound, all rules in PDLP{P_{\textit{DLP}}} (Table 3) are sound.

Following the above explanations, Theorem 3.1 can be proved according to the semantics of 𝐷𝐿p\mathit{DL}_{p} in Section 2.4. Appendix 0.A gives the proofs for rules ([α])([\alpha]) and (α)(\langle\alpha\rangle) as examples.

3.3 Construction of A Cyclic Preproof Structure in PDLP{P_{\textit{DLP}}}

In the proof system PDLP{P_{\textit{DLP}}}, given a sequent ΓΔ\Gamma\Rightarrow\Delta, we expect a finite proof tree to prove ΓΔ\Gamma\Rightarrow\Delta. However, a branch of a proof tree does not always terminate. Because the process of symbolically executing a program via rule ([α])([\alpha]) or/and rule (α)(\langle\alpha\rangle) 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 W=dfwhiletruedox:=x+1endW=_{df}\textit{while}\ \textit{true}\ \textit{do}\ x:=x+1\ \textit{end} will proceed infinitely as the following transitions: (W,{x0})(W,{x1})(W,\{x\mapsto 0\})\longrightarrow(W,\{x\mapsto 1\})\longrightarrow.... When deriving it, one may generate an infinite proof branch like this:

([α]){xn}:[W]𝑡𝑟𝑢𝑒{x1}:[W]𝑡𝑟𝑢𝑒([α]){x0}:[W]𝑡𝑟𝑢𝑒\displaystyle\cdot\Rightarrow\{x\mapsto 0\}:[W]\mathit{true}\cdot\Rightarrow\{x\mapsto 1\}:[W]\mathit{true}\cdot\Rightarrow\{x\mapsto n\}:[W]\mathit{true}...

In this paper we apply the cyclic proof approach (cf. [10]) to deal with a potential infinite proof tree in 𝐷𝐿p\mathit{DL}_{p}. 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 NN is called a companion of NN.

A derivation path in a preproof is an infinite sequence of nodes ν1ν2νm\nu_{1}\nu_{2}...\nu_{m}... (m1m\geq 1) starting from the root node ν1\nu_{1} of the preproof, where for each node pair (νi,νi+1)(\nu_{i},\nu_{i+1}) (i1i\geq 1), νi\nu_{i} is the conclusion and νi+1\nu_{i+1} is a premise, of a rule.

A derivation trace over a derivation path μ1μ2μkν1ν2νm\mu_{1}\mu_{2}...\mu_{k}\nu_{1}\nu_{2}...\nu_{m}... (k0,m1k\geq 0,m\geq 1) is an infinite sequence τ1τ2τm\tau_{1}\tau_{2}...\tau_{m}... of formulas starting from formula τ1\tau_{1} in node ν1\nu_{1} such that each CP pair (τi,τi+1)(\tau_{i},\tau_{i+1}) (i1i\geq 1) appearing on the right-sides of nodes (νi,νi+1)(\nu_{i},\nu_{i+1}) respectively is either a target pair of a rule in PDLP{P_{\textit{DLP}}}, or a CP pair satisfying τiτi+1\tau_{i}\equiv\tau_{i+1} of a rule in PDLP{P_{\textit{DLP}}}.

Progressive Steps. A crucial prerequisite of defining cyclic preproofs is to introduce the notion of (progressive) derivation traces in a preproof of PDLP{P_{\textit{DLP}}}.

Definition 5 (Progressive Step/Progressive Derivation Trace in 𝐷𝐿p\mathit{DL}_{p})

In a preproof of PDLP{P_{\textit{DLP}}}, given a derivation trace τ1τ2τm\tau_{1}\tau_{2}...\tau_{m}... over a derivation path ν1ν2νm...\nu_{1}\nu_{2}...\nu_{m}... (m1m\geq 1) starting from τ1\tau_{1} in node ν1\nu_{1}, a formula pair (τi,τi+1)(\tau_{i},\tau_{i+1}) (1im1\leq i\leq m) over (νi,νi+1)(\nu_{i},\nu_{i+1}) is called a “progressive step”, if (τi,τi+1)(\tau_{i},\tau_{i+1}) is a target pair of an instance of rule ([α])([\alpha]):

νi+1:Γτi+1:(σ:[α]ϕ),Δ([α])νi:Γτi:(σ:[α]ϕ),Δ,;\begin{gathered}\nu_{i}:\Gamma\Rightarrow\tau_{i}:(\sigma:[\alpha]\phi),\Delta,\lx@proof@logical@and...\nu_{i+1}:\Gamma\Rightarrow\tau_{i+1}:(\sigma^{\prime}:[\alpha^{\prime}]\phi),\Delta...\end{gathered};

or the target pair of an instance of rule (α)(\langle\alpha\rangle):

νi+1:Γτi+1:(σ:αϕ),Δ(α)νi:Γτi:(σ:αϕ),Δ,\begin{gathered}\nu_{i}:\Gamma\Rightarrow\tau_{i}:(\sigma:\langle\alpha\rangle\phi),\Delta\nu_{i+1}:\Gamma\Rightarrow\tau_{i+1}:(\sigma^{\prime}:\langle\alpha^{\prime}\rangle\phi),\Delta\end{gathered},

provided with an additional condition that PΛ,Ω(Γ(α,σ),Δ)\vdash_{P_{\Lambda,\Omega}}(\Gamma\Rightarrow(\alpha^{\prime},\sigma^{\prime})\Downarrow,\Delta).

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 (α)(\langle\alpha\rangle) is the key to prove the case for modality \langle\cdot\rangle 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 𝐷𝐿p\mathit{DL}_{p})

In PDLP{P_{\textit{DLP}}}, a preproof is a ‘cyclic’ one, if there exists a progressive trace over every derivation path.

The cyclic proof system PDLP{P_{\textit{DLP}}} is sound, as stated in the following theorem.

Theorem 3.2 (Soundness of the Cyclic Preproof for 𝐷𝐿p\mathit{DL}_{p})

Provided that PΛ,ΩP_{\Lambda,\Omega} is sound, a cyclic preproof of PDLP{P_{\textit{DLP}}} has a sound conclusion.

We still denote by PDLPν\vdash_{{P_{\textit{DLP}}}}\nu that ν\nu can be proved through a cyclic preproof. In Section 5, we will prove Theorem 3.2.

Proof system PΛ,ΩP_{\Lambda,\Omega} itself that PDLP{P_{\textit{DLP}}} 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 PDLP{P_{\textit{DLP}}}. Since 𝐷𝐿p\mathit{DL}_{p} 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 𝐏𝐫𝐨𝐠,𝐂𝐨𝐧𝐟\mathbf{Prog},\mathbf{Conf} and 𝐅𝐨𝐫𝐦\mathbf{Form}. For example, for the completeness, in (𝐓𝐀WP,𝐄𝐯𝐚𝐥WP,WP){(\mathbf{TA}_{{\textit{WP}}},\mathbf{Eval}_{{\textit{WP}}},\mathfrak{I}_{{\textit{WP}}})}, whether a 𝐷𝐿p\mathit{DL}_{p} formula can be proved depends on the definitions of 𝐂𝐨𝐧𝐟WP\mathbf{Conf}_{\textit{WP}}, more precisely, on whether we can successfully find proper forms of configurations using rule (Sub)({\textit{Sub}}) 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 𝐷𝐿p\mathit{DL}_{p}. It makes possible for embedding (at least partial) existing dynamic-logic theories into 𝐷𝐿p\mathit{DL}_{p}, without losing their abilities of deriving based on programs’ syntactic structures. This in turn facilitates deriving 𝐷𝐿p\mathit{DL}_{p} 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 ρϕ\rho\models\phi for an unlabeled formula ϕ\phi is well defined in some particular dynamic-logic theory.

Definition 7 (Relation \leadsto)

Given evaluations ρ,ρ𝐄𝐯𝐚𝐥\rho,\rho^{\prime}\in\mathbf{Eval}, a configuration σ𝐂𝐨𝐧𝐟\sigma\in\mathbf{Conf} and a set AA of unlabeled formulas, evaluation-configuration pair (ρ,σ)(\rho,\sigma) “has the same effect” on AA as evaluation ρ\rho^{\prime}, denoted by (ρ,σ)Aρ(\rho,\sigma)\leadsto_{A}\rho^{\prime}, if for any ϕA\phi\in A, ρσ:ϕ\rho\models\sigma:\phi iff ρϕ\rho^{\prime}\models\phi.

Example 4

In program domain (𝐓𝐀WP,𝐄𝐯𝐚𝐥WP,WP){(\mathbf{TA}_{{\textit{WP}}},\mathbf{Eval}_{{\textit{WP}}},\mathfrak{I}_{{\textit{WP}}})}, let ρ,ρ𝐄𝐯𝐚𝐥WP\rho,\rho^{\prime}\in\mathbf{Eval}_{\textit{WP}} be two evaluations satisfying ρ(x)=5,ρ(y)=1\rho(x)=5,\rho(y)=1 and ρ(x)=6,ρ(y)=1\rho^{\prime}(x)=6,\rho^{\prime}(y)=1. Let σ={xx+1}𝐂𝐨𝐧𝐟WP\sigma=\{x\mapsto x+1\}\in\mathbf{Conf}_{\textit{WP}}, formula ϕ=(x+y+1>7)𝐅𝐨𝐫𝐦WP\phi=(x+y+1>7)\in\mathbf{Form}_{\textit{WP}}. Then (ρ,σ){ϕ}ρ(\rho,\sigma)\leadsto_{\{\phi\}}\rho^{\prime}, since ρ(WP(σ,ϕ))ρ((x+1)+y+1>7)(8>7)ρ(ϕ)\rho(\mathfrak{I}_{\textit{WP}}(\sigma,\phi))\equiv\rho((x+1)+y+1>7)\equiv(8>7)\equiv\rho^{\prime}(\phi).

Definition 8 (Free Configurations)

A configuration σ\sigma is called ‘free’ w.r.t. a set AA of formulas if it satisfies that

  1. 1.

    for any ρ𝐄𝐯𝐚𝐥\rho\in\mathbf{Eval}, there is a ρ𝐄𝐯𝐚𝐥\rho^{\prime}\in\mathbf{Eval} such that (ρ,σ)Aρ(\rho,\sigma)\leadsto_{A}\rho^{\prime};

  2. 2.

    for any ρ𝐄𝐯𝐚𝐥\rho\in\mathbf{Eval}, there is a ρ𝐄𝐯𝐚𝐥\rho^{\prime}\in\mathbf{Eval} such that (ρ,σ)Aρ(\rho^{\prime},\sigma)\leadsto_{A}\rho.

We denote the set of all free configurations w.r.t. AA as 𝐂𝐨𝐧𝐟free(A)\mathbf{Conf}_{\textit{free}}(A).

Intuitively, a free configuration in some sense neither strengthen nor weaken a formula w.r.t. its boolean semantics after affections.

For a configuration σ𝐂𝐨𝐧𝐟WP\sigma\in\mathbf{Conf}_{\textit{WP}}, recall that eexe^{x}_{e} is explained in Example 3.

Example 5

In Example 4, the configuration σ\sigma is free w.r.t. {ϕ}\{\phi\}. On one hand, for any evaluation ξ𝐄𝐯𝐚𝐥WP\xi\in\mathbf{Eval}_{\textit{WP}}, let ξ=dfξξ(x)+1x\xi^{\prime}=_{df}\xi^{x}_{\xi(x)+1}, then we have (ξ,σ){ϕ}ξ(\xi,\sigma)\leadsto_{\{\phi\}}\xi^{\prime} (Definition 8-1); On the other hand, for any evaluation ξ\xi, let ξ=dfξξ(x)1x\xi^{\prime}=_{df}\xi^{x}_{\xi(x)-1}, then (ξ,σ){ϕ}ξ(\xi^{\prime},\sigma)\leadsto_{\{\phi\}}\xi holds (which is Definition 8-2). Let σ={x0,y0}\sigma^{\prime}=\{x\mapsto 0,y\mapsto 0\}, then σ\sigma^{\prime} is not free w.r.t. {ϕ}\{\phi\}, since it makes ϕ\phi too strong so that there does not exist an evaluation ξ\xi such that (ξ,σ){ϕ}ρ(\xi,\sigma^{\prime})\leadsto_{\{\phi\}}\rho^{\prime}, violating Definition 8-2.

For a set AA of unlabeled formulas, we write σ:A\sigma:A to mean the set of labeled formulas {σ:ϕ|ϕA}\{\sigma:\phi\ |\ \phi\in A\}.

Proposition 1 (Lifting Process)

Given a sound rule of the form

Γ1Δ1ΓnΔnΓΔ, n1,\begin{aligned} \Gamma\Rightarrow\Delta\lx@proof@logical@and\Gamma_{1}\Rightarrow\Delta_{1}...\Gamma_{n}\Rightarrow\Delta_{n}\end{aligned},\mbox{ $n\geq 1$},

in which all formulas are unlabelled, rule

σ:Γ1σ:Δ1σ:Γnσ:Δnσ:Γσ:Δ\displaystyle\sigma:\Gamma\Rightarrow\sigma:\Delta\lx@proof@logical@and\sigma:\Gamma_{1}\Rightarrow\sigma:\Delta_{1}...\sigma:\Gamma_{n}\Rightarrow\sigma:\Delta_{n}

is sound for any configuration σ𝐂𝐨𝐧𝐟free(ΓΔΓ1Δ1ΓnΔn)\sigma\in\mathbf{Conf}_{\textit{free}}(\Gamma\cup\Delta\cup\Gamma_{1}\cup\Delta_{1}\cup...\cup\Gamma_{n}\cup\Delta_{n}).

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 σ\sigma standard w.r.t. AA if it satisfies Definition 8-1, and write 𝐂𝐨𝐧𝐟std(A)\mathbf{Conf}_{\textit{std}}(A) as the set of all standard configurations w.r.t. AA.

Proposition 2 (Simple Version of Proposition 1)

Given a sound axiom ΓΔ,\begin{aligned} \Gamma\Rightarrow\Delta\end{aligned}, rule σ:Γσ:Δ\begin{aligned} \sigma:\Gamma\Rightarrow\sigma:\Delta\end{aligned} is sound for any standard configuration σ𝐂𝐨𝐧𝐟std(ΓΔ)\sigma\in\mathbf{Conf}_{\textit{std}}(\Gamma\cup\Delta).

4 Case Studies

In this section, we give some examples to show how 𝐷𝐿p\mathit{DL}_{p} 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 𝐷𝐿p\mathit{DL}_{p}. In Section 4.3, we show the powerfulness of 𝐷𝐿p\mathit{DL}_{p} 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 𝐷𝐿p\mathit{DL}_{p} 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

ν1=dfv0σ1:[WP](s=((v+1)v)/2).\nu_{1}=_{df}\cdot\Rightarrow v\geq 0\to\sigma_{1}:[\textit{WP}](s=((v+1)v)/2).

Recalling that σ1=df{nv,s0}\sigma_{1}=_{df}\{n\mapsto v,s\mapsto 0\} with vv a free variable; WP is defined as

WP=df\displaystyle\textit{WP}=_{df} {while(n>0)dos:=s+n;n:=n1end}.\displaystyle\{\textit{while}\ (n>0)\ \textit{do}\ s:=s+n\ ;\ n:=n-1\ \textit{end}\ \}.

(Ter)19(WkR)418(WkL)17(Sub)16(WkL)1315(WkR)14(Cut)12([α])11([α])6(Ter)10(Int)9([])8([α])7(L)5(Cut)3(Sub)2()ν1: 1\mbox{$\nu_{1}$: 1}23\lx@proof@logical@and 4195\lx@proof@logical@and 61112\lx@proof@logical@and 13161718141578910 Definitions of other symbols: α1=dfs:=s+n;n:=n1\alpha_{1}=_{df}s:=s+n;\ n:=n-1 ϕ1=df(s=((v+1)v)/2)\phi_{1}=_{df}(s=((v+1)v)/2) σ1(v)=df{nv,s0}\sigma_{1}(v)=_{df}\{n\mapsto v,s\mapsto 0\} σ2(v)=df{nv,s0}\sigma_{2}(v)=_{df}\{n\mapsto v,s\mapsto 0\} σ3(v)=df{nvm,s(2vm+1)m/2}\sigma_{3}(v)=_{df}\{n\mapsto v-m,s\mapsto(2v-m+1)m/2\} σ4(v)=df{nvm,s(2v(m+1)+1)(m+1)/2}\sigma_{4}(v)=_{df}\{n\mapsto v-m,s\mapsto(2v-(m+1)+1)(m+1)/2\} σ5(v)=df{nv(m+1),s(2v(m+1)+1)(m+1)/2}\sigma_{5}(v)=_{df}\{n\mapsto v-(m+1),s\mapsto(2v-(m+1)+1)(m+1)/2\} 1: \cdot \Rightarrow v0σ1(v):[while(n>0)doα1end]ϕ1v\geq 0\to\sigma_{1}(v):[\textit{while}\ (n>0)\ \textit{do}\ \alpha_{1}\ \textit{end}\ ]\phi_{1} 2: v0v\geq 0 \Rightarrow σ1(v):[while(n>0)doα1end]ϕ1\sigma_{1}(v):[\textit{while}\ (n>0)\ \textit{do}\ \alpha_{1}\ \textit{end}\ ]\phi_{1} 3: vm0v-m\geq 0 \Rightarrow σ3(v):[while(n>0)doα1end]ϕ1\sigma_{3}(v):[\textit{while}\ (n>0)\ \textit{do}\ \alpha_{1}\ \textit{end}\ ]\phi_{1} 4: vm0v-m\geq 0 \Rightarrow {σ3(v):[while(n>0)doα1end]ϕ1,vm>0vm0}\left\{\begin{array}[]{l}\mbox{$\sigma_{3}(v):[\textit{while}\ (n>0)\ \textit{do}\ \alpha_{1}\ \textit{end}\ ]\phi_{1}$},\\ v-m>0\vee v-m\leq 0\end{array}\right\} 19: vm0v-m\geq 0 \Rightarrow vm>0vm0v-m>0\vee v-m\leq 0 5: vm0,vm>0vm0v-m\geq 0,v-m>0\vee v-m\leq 0 \Rightarrow σ3(v):[while(n>0)doα1end]ϕ1\sigma_{3}(v):[\textit{while}\ (n>0)\ \textit{do}\ \alpha_{1}\ \textit{end}\ ]\phi_{1} 6: vm0,vm>0v-m\geq 0,v-m>0 \Rightarrow σ3(v):[while(n>0)doα1end]ϕ1\sigma_{3}(v):[\textit{while}\ (n>0)\ \textit{do}\ \alpha_{1}\ \textit{end}\ ]\phi_{1} 11: vm0,vm>0v-m\geq 0,v-m>0 \Rightarrow σ4(v):[n:=n1;while(n>0)doα1end]ϕ1\sigma_{4}(v):[n:=n-1;\ \textit{while}\ (n>0)\ \textit{do}\ \alpha_{1}\ \textit{end}\ ]\phi_{1} 12: vm0,vm>0v-m\geq 0,v-m>0 \Rightarrow σ5(v):[while(n>0)doα1end]ϕ1\sigma_{5}(v):[\textit{while}\ (n>0)\ \textit{do}\ \alpha_{1}\ \textit{end}\ ]\phi_{1} 13: {vm0,vm>0,v(m+1)1,v(m+1)0}\left\{\begin{array}[]{l}v-m\geq 0,v-m>0,\\ v-(m+1)\geq-1,v-(m+1)\geq 0\end{array}\right\} \Rightarrow σ5(v):[while(n>0)doα1end]ϕ1\sigma_{5}(v):[\textit{while}\ (n>0)\ \textit{do}\ \alpha_{1}\ \textit{end}\ ]\phi_{1} 16: v(m+1)1,v(m+1)0v-(m+1)\geq-1,v-(m+1)\geq 0 \Rightarrow σ5(v):[while(n>0)doα1end]ϕ1\sigma_{5}(v):[\textit{while}\ (n>0)\ \textit{do}\ \alpha_{1}\ \textit{end}\ ]\phi_{1} 17: vm1,vm0v-m\geq-1,v-m\geq 0 \Rightarrow σ3(v):[while(n>0)doα1end]ϕ1\sigma_{3}(v):[\textit{while}\ (n>0)\ \textit{do}\ \alpha_{1}\ \textit{end}\ ]\phi_{1} 18: vm0v-m\geq 0 \Rightarrow σ3(v):[while(n>0)doα1end]ϕ1\sigma_{3}(v):[\textit{while}\ (n>0)\ \textit{do}\ \alpha_{1}\ \textit{end}\ ]\phi_{1} 14: vm0,vm>0v-m\geq 0,v-m>0 \Rightarrow {σ5(v):[while(n>0)doα1end]ϕ1,v(m+1)1,v(m+1)0}\left\{\begin{array}[]{l}\mbox{$\sigma_{5}(v):[\textit{while}\ (n>0)\ \textit{do}\ \alpha_{1}\ \textit{end}\ ]\phi_{1}$},\\ v-(m+1)\geq-1,v-(m+1)\geq 0\end{array}\right\} 15: vm0,vm>0v-m\geq 0,v-m>0 \Rightarrow v(m+1)1,v(m+1)0v-(m+1)\geq-1,v-(m+1)\geq 0 7: vm0,vm0v-m\geq 0,v-m\leq 0 \Rightarrow σ3(v):[while(n>0)doα1end]ϕ1\sigma_{3}(v):[\textit{while}\ (n>0)\ \textit{do}\ \alpha_{1}\ \textit{end}\ ]\phi_{1} 8: vm0,vm0v-m\geq 0,v-m\leq 0 \Rightarrow σ3(v):[]ϕ1\sigma_{3}(v):[\downarrow]\phi_{1} 9: vm0,vm0v-m\geq 0,v-m\leq 0 \Rightarrow σ3(v):(s=((v+1)v)/2)\sigma_{3}(v):(s=((v+1)v)/2) 10: vm0,vm0v-m\geq 0,v-m\leq 0 \Rightarrow ((2vm+1)m)/2=((v+1)v)/2)((2v-m+1)m)/2=((v+1)v)/2)

Table 4: Derivations of Property ν1\nu_{1}

Table 4 shows the derivation of this formula. We omit all sub-proof-procedures in the proof system PΛWP,ΩWPP_{\Lambda_{\textit{WP}},\Omega_{\textit{WP}}} derived by the inference rules in Table 2 when deriving via rule ([α])([\alpha]). We write term t(x)t(x) if xx is a variable that has free occurrences in tt. Non-primitive rules (R)(\to R) and (L)(\vee L) are can be derived by the rules for ¬\neg and \wedge accordingly. For example, rule (L)(\vee L) can be derived as follows:

Γ,ϕΔ(¬R)Γ¬ϕ,ΔΓ,ψΔ(¬R)Γ¬ψ,Δ(R)Γ(¬ϕ)(¬ψ),Δ(¬L)Γ,ϕψΔ.\begin{aligned} \Gamma,\phi\vee\psi\Rightarrow\Delta\Gamma\Rightarrow(\neg\phi)\wedge(\neg\psi),\Delta\lx@proof@logical@and\Gamma\Rightarrow\neg\phi,\Delta\Gamma,\phi\Rightarrow\Delta\Gamma\Rightarrow\neg\psi,\Delta\Gamma,\psi\Rightarrow\Delta\end{aligned}.

The derivation from sequent 2 to 3 is according to rule

ΓΔ(Sub)Γ[e/x]Δ[e/x],\displaystyle\Gamma[e/x]\Rightarrow\Delta[e/x]\Gamma\Rightarrow\Delta,

where function ()[e/x](\cdot)[e/x] is an instantiation of abstract substitution defined in Definition 4. Recalling that for any formula ϕ\phi, ϕ[e/x]\phi[e/x] substitutes each free variable xx of ϕ\phi with term ee (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:

(vm0)[0/m](σ3(v):[while(n>0)doα1end]ϕ1)[0/m],(v-m\geq 0)[0/m]\Rightarrow(\sigma_{3}(v):[\textit{while}\ (n>0)\ \textit{do}\ \alpha_{1}\ \textit{end}\ ]\phi_{1})[0/m],

as a special case of sequent 3. Intuitively, sequent 3 captures the situation after the mmth loop (m0m\geq 0) 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: vm>0vm0v-m>0\vee v-m\leq 0, which is obvious valid. Sequent 16 indicates the end of the (m+1)(m+1)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 (Sub)({\textit{Sub}}). From sequent 16 to 17 rule (Sub)({\textit{Sub}}) is applied, with 16 can be written as:

(vm1)[m+1/m],(vm0)[m+1/m](σ3:[while(n>0)doα1end]ϕ1)[m+1/m].(v-m\geq-1)[m+1/m],(v-m\geq 0)[m+1/m]\Rightarrow(\sigma_{3}:[\textit{while}\ (n>0)\ \textit{do}\ \alpha_{1}\ \textit{end}\ ]\phi_{1})[m+1/m].

The whole proof tree is a cyclic preproof because the only derivation path: 1,2,3,5,6,11,12,13,16,17,18,3,1,2,3,5,6,11,12,13,16,17,18,3,... has a progressive derivation trace whose elements are underlined in Table 4.

The configurations in 𝐷𝐿p\mathit{DL}_{p} 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 XX, 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 X[0/s][1/x]X[0/s][1/x] that carries two substitutions in sequence. When applying to formulas, these substitutions are passed to formulas: (X[0/s][1/x],s+x+1>0)=df((s+x+1>0)[0/s])[1/x](0+x+1>0)[1/x]0+1+1>0\mathfrak{I}(X[0/s][1/x],s+x+1>0)=_{df}((s+x+1>0)[0/s])[1/x]\equiv(0+x+1>0)[1/x]\equiv 0+1+1>0 through a well-defined \mathfrak{I}. From this we see that one of the advantages of 𝐷𝐿p\mathit{DL}_{p} 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 𝐷𝐿p\mathit{DL}_{p}.

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 𝐷𝐿p\mathit{DL}_{p}.

In FODL, consider an axiom

([;])[α][β]ϕ[α;β]ϕ,[\alpha][\beta]\phi\Rightarrow[\alpha\operatorname{;}\beta]\phi,

which comes from the valid formula [α][β]ϕ[α;β]ϕ[\alpha][\beta]\phi\rightarrow[\alpha\operatorname{;}\beta]\phi, as a useful rule appearing in many dynamic logic calculi that are based on FODL (e.g. [4]). By Proposition 2, we lift ([;])([;]) as

σ:[α][β]ϕσ:[α;β]ϕ\sigma:[\alpha][\beta]\phi\Rightarrow\sigma:[\alpha\operatorname{;}\beta]\phi

for any standard configuration σ𝐂𝐨𝐧𝐟std({[α][β]ϕ,[α;β]ϕ})\sigma\in\mathbf{Conf}_{\textit{std}}(\{[\alpha][\beta]\phi,[\alpha\operatorname{;}\beta]\phi\}). And by Lemma 2 (Appendix 0.A), we obtain a labeled rule

Γσ:[α][β]ϕ,Δ(σ[;])Γσ:[α;β]ϕ,Δ,\Gamma\Rightarrow\sigma:[\alpha\operatorname{;}\beta]\phi,\Delta\Gamma\Rightarrow\sigma:[\alpha][\beta]\phi,\Delta,

which provides a compositional reasoning for sequential programs in PDLP{P_{\textit{DLP}}} as an additional rule. It is useful when verifying a property like Γ,σ:[β]ϕσ:[α;β]ϕ,Δ\Gamma,\sigma^{\prime}:[\beta]\phi\Rightarrow\sigma:[\alpha\operatorname{;}\beta]\phi,\Delta, in which we might finish the proof by only symbolic executing program α\alpha as:

(ax)Γ,σ:[β]ϕσ:[β]ϕ,Δ([])Γ,σ:[β]ϕσ:[][β]ϕ,Δ([α])([α])Γ,σ:[β]ϕσ:[α][β]ϕ,Δ(σ[;])Γ,σ:[β]ϕσ:[α;β]ϕ,Δ,\Gamma,\sigma^{\prime}:[\beta]\phi\Rightarrow\sigma:[\alpha\operatorname{;}\beta]\phi,\Delta\Gamma,\sigma^{\prime}:[\beta]\phi\Rightarrow\sigma:[\alpha][\beta]\phi,\Delta......\Gamma,\sigma^{\prime}:[\beta]\phi\Rightarrow\sigma^{\prime}:[\downarrow][\beta]\phi,\Delta\Gamma,\sigma^{\prime}:[\beta]\phi\Rightarrow\sigma^{\prime}:[\beta]\phi,\Delta,

especially when verifying program β\beta can be very costly.

Another example is rule

ϕψ([Gen])[α]ϕ[α]ψ[\alpha]\phi\Rightarrow[\alpha]\psi\phi\Rightarrow\psi

for generating modality [][\cdot], which were used for deriving the structural rule of loop programs in FODL (cf. [20]). By Proposition 1, we lift ([Gen])([\textit{Gen}]) as the following rule

σ:ϕσ:ψ(σ[Gen])σ:[α]ϕσ:[α]ψ,\sigma:[\alpha]\phi\Rightarrow\sigma:[\alpha]\psi\sigma:\phi\Rightarrow\sigma:\psi,

where σ𝐂𝐨𝐧𝐟free({[α]ϕ,[α]ψ,ϕ,ψ})\sigma\in\mathbf{Conf}_{\textit{free}}(\{[\alpha]\phi,[\alpha]\psi,\phi,\psi\}). It is useful, for example, when deriving a property σ:[α]βϕσ:[α]βψ\sigma:[\alpha]\langle\beta\rangle\phi\Rightarrow\sigma:[\alpha]\langle\beta^{\prime}\rangle\psi, where we can skip the verification of program α\alpha as follows:

σ:βϕσ:βψ(σ[Gen])σ:[α]βϕσ:[α]βψ\sigma:[\alpha]\langle\beta\rangle\phi\Rightarrow\sigma:[\alpha]\langle\beta^{\prime}\rangle\psi\sigma:\langle\beta\rangle\phi\Rightarrow\sigma:\langle\beta^{\prime}\rangle\psi

and directly focus on verifying program β\beta^{\prime}.

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 𝐷𝐿p\mathit{DL}_{p}. From this example, we see that a configuration interpretation \mathfrak{I} can be more than just substitutions of terms like WP\mathfrak{I}_{\textit{WP}} and E\mathfrak{I}_{E} 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 eee\dashrightarrow e^{\prime} and a critical operator {*} (while omitting another critical operator {-\!*}); for programs, we only introduce atomic program statements: x:=𝐜𝐨𝐧𝐬(e)x:=\mathbf{cons}(e), x:=[e]x:=[e], [e]:=e[e]:=e^{\prime} and 𝐝𝐢𝐬𝐩(e)\mathbf{disp}(e) 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 𝐷𝐿p\mathit{DL}_{p} as labeled formulas and explain how they actually capture the same meaning.

Below we follow some conventions of notations: Given a partial function f:ABf:A\rightarrowtail B, we use dom(f)\textit{dom}(f) to denote the domain of ff. For a set CC, partial function f|C:ABf|_{C}:A\rightarrowtail B is the function ff restricted on domain dom(f)C\textit{dom}(f)\cap C. f[xe]f[x\mapsto e] represents the partial function that maps xx to ee, and maps the other variables in its domain to the same value as ff.

Let 𝕍=Addr\mathbb{V}=\mathbb{Z}\cup\textit{Addr} 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 s:V𝕍s:V\to\mathbb{V} is a function that maps each variable to a value of 𝕍\mathbb{V}, a heap h:Addr𝕍h:\textit{Addr}\rightarrowtail\mathbb{V} is a partial function that maps each address to a value of 𝕍\mathbb{V}, expressing that the value is stored in a memory indicated by the address. dom(h)\textit{dom}(h) is a finite subset of Addr. Let ee be an arithmetic expression with or without variables, s(e)s(e) returns the value by replacing each variable xx of ee with value s(x)s(x). A state is a store-heap pair (s,h)(s,h). The disjoint relation h1h2h_{1}\operatorname{\bot}h_{2} is defined if dom(h1)dom(h2)=\textit{dom}(h_{1})\cap\textit{dom}(h_{2})=\emptyset.

Here we informally explain the behaviours of program statements. Given a state (s,h)(s,h), statement x:=𝐜𝐨𝐧𝐬(e)x:=\mathbf{cons}(e) allocates a memory addressed by a new integer nn in hh to store the value of expression ee (thus obtaining a new heap h{(n,s(e))}h\cup\{(n,s(e))\} where ndom(h)n\notin\textit{dom}(h)), and assigns nn to xx. Statement x:=[e]x:=[e] assigns the value of the address ee in hh (i.e. h(s(e))h(s(e))) to variable xx. [e]:=e[e]:=e^{\prime} means to assign the value ee^{\prime} to the memory of the address ee in hh (i.e. obtaining a new heap h[s(e)s(e)]h[s(e)\mapsto s(e^{\prime})]). 𝐝𝐢𝐬𝐩(e)\mathbf{disp}(e) means to de-allocate the memory of address ee in heap (i.e. obtaining a new heap h|dom(h){s(e)}h|_{\textit{dom}(h)\setminus\{s(e)\}}).

Formula eee\dashrightarrow e^{\prime} means that value ee^{\prime} is stored in the memory of address ee. Given a state (s,h)(s,h), s,hees,h\models e\dashrightarrow e^{\prime} is defined if h(s(e))=s(e)h(s(e))=s(e^{\prime}). For any separation logical formulas ϕ\phi and ψ\psi, s,hϕψs,h\models\phi\ {*}\ \psi if there exist heaps h1,h2h_{1},h_{2} such that h=h1h2h=h_{1}\cup h_{2}, h1h2h_{1}\operatorname{\bot}h_{2}, and s,h1ϕs,h_{1}\models\phi and s,h2ψs,h_{2}\models\psi.

Example 6

Let (s,h)(s,h) be a state such that s(x)=3,s(y)=4s(x)=3,s(y)=4 and h=h=\emptyset, then the following table shows the information of each state about focused variables and addresses during the process of the following executions:

(s,h)x:=𝐜𝐨𝐧𝐬(1)(s1,h1)y:=𝐜𝐨𝐧𝐬(1)(s2,h2)[y]:=37(s3,h3)y:=[x+1](s4,h4)𝐝𝐢𝐬𝐩(x+1)(s5,h5).(s,h)\xrightarrow{x:=\mathbf{cons}(1)}(s_{1},h_{1})\xrightarrow{y:=\mathbf{cons}(1)}(s_{2},h_{2})\xrightarrow{[y]:=37}(s_{3},h_{3})\xrightarrow{y:=[x+1]}(s_{4},h_{4})\xrightarrow{\mathbf{disp}(x+1)}(s_{5},h_{5}).
Store Heap
ss x:3x:3, y:4y:4 hh empty
s1s_{1} x:37x:37, y:4y:4 h1h_{1} 37:137:1
s2s_{2} x:37x:37, y:38y:38 h2h_{2} 37:137:1, 38:138:1
s3s_{3} x:37x:37, y:38y:38 h3h_{3} 37:137:1, 38:3738:37
s4s_{4} x:37x:37, y:37y:37 h4h_{4} 37:137:1, 38:3738:37
s5s_{5} x:37x:37, y:37y:37 h5h_{5} 37:137:1

Let ϕ=df(x1y1)\phi=_{df}(x\dashrightarrow 1\ {*}\ y\dashrightarrow 1), ψ=df(x1y1)\psi=_{df}(x\dashrightarrow 1\ \wedge\ y\dashrightarrow 1), we have s2,h2ϕs_{2},h_{2}\models\phi and s2,h2ψs_{2},h_{2}\models\psi, s5,h5ψs_{5},h_{5}\models\psi, but s5,h5⊧̸ϕs_{5},h_{5}\not\models\phi since xx and yy point to the single memory storing value 11.

Configurations σSP\sigma_{\textit{SP}}: (s,h)(s,h) Interpretations SP\mathfrak{I}_{\textit{SP}}: SP((s,h),ee)=dfh(s(e))=s(e)\mathfrak{I}_{\textit{SP}}((s,h),e\dashrightarrow e^{\prime})=_{df}h(s(e))=s(e^{\prime}) SP((s,h),ϕψ)=dfX,Y.(h=XY)(XY)SP((s,X),ϕ)SP((s,Y),ψ)\mathfrak{I}_{\textit{SP}}((s,h),\phi\ {*}\ \psi)=_{df}\exists X,Y.(h=X\cup Y)\wedge(X\bot Y)\wedge\mathfrak{I}_{\textit{SP}}((s,X),\phi)\wedge\mathfrak{I}_{\textit{SP}}((s,Y),\psi) Inference rules for behaviours of program statements: 1(𝐜𝐨𝐧𝐬)Γ(x:=𝐜𝐨𝐧𝐬(e),(s,h))(,(s[xn],h{(n,s(e))})),Δ\Gamma\Rightarrow(x:=\mathbf{cons}(e),(s,h))\longrightarrow(\downarrow,(s[x\mapsto n],h\cup\{(n,s(e))\})),\Delta   (x:=[e])Γ(x:=[e],(s,h))(,(s[xh(s(e))],h)),Δ\Gamma\Rightarrow(x:=[e],(s,h))\longrightarrow(\downarrow,(s[x\mapsto h(s(e))],h)),\Delta ([e]:=e)Γ([e]:=e,(s,h))(,(s,h[s(e)s(e)])),Δ\Gamma\Rightarrow([e]:=e^{\prime},(s,h))\longrightarrow(\downarrow,(s,h[s(e)\mapsto s(e^{\prime})])),\Delta   (𝐝𝐢𝐬𝐩)Γ(𝐝𝐢𝐬𝐩(e),(s,h))(,(s,h|dom(h){s(e)})),Δ\Gamma\Rightarrow(\mathbf{disp}(e),(s,h))\longrightarrow(\downarrow,(s,h|_{\textit{dom}(h)\setminus\{s(e)\}})),\Delta 1 nn is new w.r.t. hh.

Table 5: Encoding of A Part of Separation Logic in 𝐷𝐿p\mathit{DL}_{p}

Encoding of Separation Logic in 𝐷𝐿p\mathit{DL}_{p}. In 𝐷𝐿p\mathit{DL}_{p}, we choose the store-heap pairs as the configurations namely σSP\sigma_{\textit{SP}}. Table 5 lists the rules for the program behaviours of the atomic program statements. To capture the semantics of separation logical formulas, interpretations SP\mathfrak{I}_{\textit{SP}} are defined in an inductive way according to their syntactical structures. Note that the formula SP((s,h),ϕψ)\mathfrak{I}_{\textit{SP}}((s,h),\phi\ {*}\ \psi) requires variables X,YX,Y ranging over heaps.

To tackle a formula like SP((s,h),ϕψ)\mathfrak{I}_{\textit{SP}}((s,h),\phi\ {*}\ \psi), additional rules can be proposed. In this example, we can propose a rule

Γh1h2,ΔΓ(s,h1):ϕ,ΔΓ(s,h2):ψ,Δ(σ)Γ(s,h1h2):ϕψ,Δ\displaystyle\Gamma\Rightarrow(s,h_{1}\cup h_{2}):\phi\ {*}\ \psi,\Delta\lx@proof@logical@and\Gamma\Rightarrow h_{1}\bot h_{2},\Delta\Gamma\Rightarrow(s,h_{1}):\phi,\Delta\Gamma\Rightarrow(s,h_{2}):\psi,\Delta

to decompose the heap’s structure, or a rule

Γ(s,h):ϕ,Δ(σFrm)Γ(s,h):ϕψ,Δ, if no variables of dom(h) appear in ψ,\begin{aligned} \Gamma\Rightarrow(s,h):\phi\ {*}\ \psi,\Delta\Gamma\Rightarrow(s,h):\phi,\Delta\end{aligned},\mbox{ if no variables of $\textit{dom}(h)$ appear in $\psi$},

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 (s,h)(s,h). Similar encoding can be obtained accordingly. From this example, we envision that the entire theory of separation logic can actually be embedded into 𝐷𝐿p\mathit{DL}_{p}, where additional rules like the above ones will support a “configuration-level reasoning” of separation logical formulas.

5 Soundness of Cyclic Proof System PDLP{P_{\textit{DLP}}}

We analyze and prove the soundness of PDLP{P_{\textit{DLP}}} 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 τ\tau in a node ν\nu leads to an infinite descent sequence of elements along this trace ordered by a well-founded relation m\preceq_{m} (introduced in Section 5.1), which violates the definition of well-foundedness itself.

Below, we only consider the case when τ{σ:[α]ϕ,σ:αϕ}\tau\in\{\sigma:[\alpha]\phi,\sigma:\langle\alpha\rangle\phi\} in a node ν\nu of the form Γτ,Δ\Gamma\Rightarrow\tau,\Delta for arbitrary Γ\Gamma and Δ\Delta. Other cases for τ\tau are trivial.

In the rest of this section, we firstly introduce the well-founded relation m\prec_{m}, 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 m\prec_{m}

Well-foundedness. A relation \preceq on a set SS is partially ordered, if it satisfies the following properties: (1) Reflexivity. ttt\preceq t for each tSt\in S. (2) Anti-symmetry. For any t1,t2St_{1},t_{2}\in S, if t1t2t_{1}\preceq t_{2} and t2t1t_{2}\preceq t_{1}, then t1t_{1} and t2t_{2} are the same element in SS, we denote by t1=t2t_{1}=t_{2}. (3) Transitivity. For any t1,t2,t3St_{1},t_{2},t_{3}\in S, if t1t2t_{1}\preceq t_{2} and t2t3t_{2}\preceq t_{3}, then t1t3t_{1}\preceq t_{3}.

t1t2t_{1}\prec t_{2} is defined as t1t2t_{1}\preceq t_{2} and t1t2t_{1}\neq t_{2}.

Given a set SS and a partial-order relation \preceq on SS, \preceq is called a well-founded relation over SS, if for any element aa in SS, there is no infinite descent sequence: aa1a2a\succ a_{1}\succ a_{2}\succ... in SS. Set SS is called a well-founded set w.r.t. \preceq.

Relation m\preceq_{m}. Given two paths tr1tr_{1} and tr2tr_{2}, relation tr1str2tr_{1}\preceq_{s}tr_{2} is defined if tr2tr_{2} is a suffix of tr1tr_{1}. Obviously s\preceq_{s} is partially ordered. Relation tr1str2tr_{1}\prec_{s}tr_{2} expresses that tr1tr_{1} is a proper suffix of tr2tr_{2}. In a set of finite paths, relation s\preceq_{s} is well-founded, because every finite path has only a finite number of suffixes.

Definition 9 (Relation m\preceq_{m})

Given two finite sets C1\mathit{C}_{1} and C2\mathit{C}_{2} of finite paths, C1mC2\mathit{C}_{1}\preceq_{m}\mathit{C}_{2} is defined if either (1) C1=C2\mathit{C}_{1}=\mathit{C}_{2}; or (2) set C1\mathit{C}_{1} can be obtained from C2\mathit{C}_{2} by replacing (or removing) one or more elements of C2\mathit{C}_{2} each with a finite number of elements, such that for each replaced element trtr, its replacements tr1,,trntr_{1},...,tr_{n} (n1n\geq 1) in C1\mathit{C}_{1} satisfies that tristrtr_{i}\prec_{s}tr for any ii, 1in1\leq i\leq n.

Proposition 3

m\preceq_{m} is a partial-order relation.

The proof of Proposition 3 is given in Appendix 0.A.

Example 7

Let C1={tr1,tr2,tr3}C_{1}=\{tr_{1},tr_{2},tr_{3}\}, where tr1=df(α,σ)(α1,σ1)(α2,σ2)(α3,σ3)(,σ4),tr2=df(α,σ)(α1,σ1)(β1,δ1)(β2,δ2)(,δ3)tr_{1}=_{df}(\alpha,\sigma)(\alpha_{1},\sigma_{1})(\alpha_{2},\sigma_{2})(\alpha_{3},\sigma_{3})(\downarrow,\sigma_{4}),tr_{2}=_{df}(\alpha,\sigma)(\alpha_{1},\sigma_{1})(\beta_{1},\delta_{1})(\beta_{2},\delta_{2})(\downarrow,\delta_{3}) and tr3=df(α,σ)(,τ)tr_{3}=_{df}(\alpha,\sigma)(\downarrow,\tau); C2={tr1,tr2}C_{2}=\{tr^{\prime}_{1},tr^{\prime}_{2}\}, where tr1=df(α1,σ1)(α2,σ2)(α3,σ3)(,σ4),tr2=df(α1,σ1)(β1,δ1)(β2,δ2)(,δ3)tr^{\prime}_{1}=_{df}(\alpha_{1},\sigma_{1})(\alpha_{2},\sigma_{2})(\alpha_{3},\sigma_{3})(\downarrow,\sigma_{4}),tr^{\prime}_{2}=_{df}(\alpha_{1},\sigma_{1})(\beta_{1},\delta_{1})(\beta_{2},\delta_{2})(\downarrow,\delta_{3}). We see that tr1str1tr^{\prime}_{1}\prec_{s}tr_{1} and tr2str2tr^{\prime}_{2}\prec_{s}tr_{2}. C2C_{2} can be obtained from C1C_{1} by replacing tr1tr_{1} and tr2tr_{2} with tr1tr^{\prime}_{1} and tr2tr^{\prime}_{2} respectively, and removing tr3tr_{3}. Hence C2mC1C_{2}\preceq_{m}C_{1}. Since C1C2C_{1}\neq C_{2}, C2mC1C_{2}\prec_{m}C_{1}.

Proposition 4

The relation m\preceq_{m} between any two finite sets of finite paths is a well-founded relation.

We omit the proof since relation m\preceq_{m} 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 σ:[α]ϕ\sigma:[\alpha]\phi or σ:αϕ\sigma:\langle\alpha\rangle\phi invalid.

Definition 10 (Counter-example Paths)

A “counter-example” CT(ρ,τ,ν)\textit{CT}(\rho,\tau,\nu) of a formula τ{σ:[α]ϕ,σ:αϕ}\tau\in\{\sigma:[\alpha]\phi,\sigma:\langle\alpha\rangle\phi\} in a sequent ν=df(Γτ,Δ)\nu=_{df}(\Gamma\Rightarrow\tau,\Delta) is a set of minimum paths defined as: CT(ρ,τ,ν)=df{ρ(α,σ)(,σ)|ρΓ,ρ⊧̸σ:ϕ}.\textit{CT}(\rho,\tau,\nu)=_{df}\{\rho(\alpha,\sigma)...(\downarrow,\sigma^{\prime})\ |\ \rho\models\Gamma,\rho\not\models\sigma^{\prime}:\phi\}.

We write ρΓ\rho\models\Gamma to mean that ρϕ\rho\models\phi for all ϕΓ\phi\in\Gamma. 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 (τ,τ)(\tau,\tau^{\prime}) be a pair of a derivation trace over a node pair (ν,ν)(\nu,\nu^{\prime}) of an invalid derivation path, where τ{σ:[α]ϕ,σ:αϕ}\tau\in\{\sigma:[\alpha]\phi,\sigma:\langle\alpha\rangle\phi\} and ν=df(Γτ,Δ)\nu=_{df}(\Gamma\Rightarrow\tau,\Delta). For any counter-example CT(ρ,τ,ν)\textit{CT}(\rho,\tau,\nu) of τ\tau, there exists an evaluation ρ\rho^{\prime} and a counter-example CT(ρ,τ,ν)\textit{CT}(\rho^{\prime},\tau^{\prime},\nu^{\prime}) of τ\tau^{\prime} such that CT(ρ,τ,ν)mCT(ρ,τ,ν)\textit{CT}(\rho^{\prime},\tau^{\prime},\nu^{\prime})\preceq_{m}\textit{CT}(\rho,\tau,\nu). Moreover, if (τ,τ)(\tau,\tau^{\prime}) is a progressive step, then CT(ρ,τ,ν)mCT(ρ,τ,ν)\textit{CT}(\rho^{\prime},\tau^{\prime},\nu^{\prime})\prec_{m}\textit{CT}(\rho,\tau,\nu).

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.

Based on Theorem 3.1 and Lemma 1, we give the proof of Theorem 3.2 as follows.

Proof (Proof of Theorem 3.2)

As stated previously, we prove by contradiction and only focus on the cases where the first formula τ1\tau_{1} of a progressive trace is of the form: σ:[α]ϕ\sigma:[\alpha]\phi or σ:αϕ\sigma:\langle\alpha\rangle\phi. Let the progressive trace be τ1τ2τm\tau_{1}\tau_{2}...\tau_{m}... over a derivation path ν1ν2νm...\nu_{1}\nu_{2}...\nu_{m}... (m1m\geq 1) starting from τ1\tau_{1} in ν1\nu_{1}, where ν1=df(Γτ1,Δ)\nu_{1}=_{df}(\Gamma\Rightarrow\tau_{1},\Delta), and formula 𝔓(νi)\mathfrak{P}(\nu_{i}) (i1)(i\geq 1) for each node νi\nu_{i} is invalid.

From that 𝔓(Γτ1,Δ)\mathfrak{P}(\Gamma\Rightarrow\tau_{1},\Delta) is invalid, there is an evaluation ρ\rho satisfying that ρΓ\rho\models\Gamma but ρ⊧̸τ1\rho\not\models\tau_{1}, so CT1(ρ,τ1,ν1)\textit{CT}_{1}(\rho,\tau_{1},\nu_{1}) is well defined. By Lemma 1, from CT1\textit{CT}_{1} we can obtain an infinite sequence of counter-examples: CT1,CT2,,CTm,\textit{CT}_{1},\textit{CT}_{2},...,\textit{CT}_{m},..., with each CTi\textit{CT}_{i} (i1i\geq 1) being the counter-example of formula τi\tau_{i}, and which satisfies that CT1mCT2mmCTmm\textit{CT}_{1}\succeq_{m}\textit{CT}_{2}\succeq_{m}...\succeq_{m}\textit{CT}_{m}\succeq_{m}.... Moreover, since τ1τ2τm\tau_{1}\tau_{2}...\tau_{m}... is progressive (Definition 6), there must be an infinite number of strict relation m\prec_{m} among these m\preceq_{m}s. This thus forms an infinite descent sequence w.r.t. m\prec_{m}, violating the well-foundedness of relation m\preceq_{m} (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 φφ\varphi\Rightarrow\varphi^{\prime} (where \Rightarrow means differently from in sequents here), captures whether pattern φ\varphi^{\prime} is reachable from pattern φ\varphi 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 𝐷𝐿p\mathit{DL}_{p}. 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 μ\mu-logic [11] was proposed by adding a least fixpoint μ\mu-binder to matching logic.

In terms of expressiveness, the semantics of modality [][\cdot] 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 μ\mu-logic can encode 𝐷𝐿p\mathit{DL}_{p}. As a generic calculus, it has been claimed that matching μ\mu-logic can encode traditional dynamic logics (cf. [11]). Compared to these theories based on rewriting logics, 𝐷𝐿p\mathit{DL}_{p} has a more specific logical structure and belongs to a type of modal logics, with modalities [][\cdot] and \langle\cdot\rangle to efficiently capture and reason about program specifications. On the other hand, to encode a 𝐷𝐿p\mathit{DL}_{p} specification ϕ(σ:αψ)\phi\to(\sigma:\langle\alpha\rangle\psi) in matching logic for example, one needs to somehow ‘mix up’ all structures together to form a pattern, in a form like: φ=dfασϕ\varphi=_{df}\alpha\wedge\sigma\wedge\phi and φ=dfσψ\varphi^{\prime}=_{df}\downarrow\wedge\sigma^{\prime}\wedge\psi for some configuration σ\sigma^{\prime}, in order to conduct a reachability rule φφ\varphi\Rightarrow{}\varphi^{\prime}.

[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 (c,P)(c,P) with cc a program state and PP a set of program states, capturing the exact meaning of formula σ:[α]ϕ\sigma:[\alpha]\phi in 𝐷𝐿p\mathit{DL}_{p} if we let cc be (α,σ)(\alpha,\sigma) and let PP represent the semantics of formula ϕ\phi. The authors designed a method to derive a program specification (c,P)(c,P) in a coinductive way according to the operational semantics of cc. 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, 𝐷𝐿p\mathit{DL}_{p} is a logic, which in some cases is more convenient to catch program properties. In terms of expressiveness, 𝐷𝐿p\mathit{DL}_{p} can also express the negation of a dynamic formula σ:[α]ϕ\sigma:[\alpha]\phi as the dual formula σ:α¬ϕ\sigma:\langle\alpha\rangle\neg\phi, 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 𝐷𝐿p\mathit{DL}_{p} can be more than just a “delay substitution” (cf. [3]) of variables and terms.

The proof system of 𝐷𝐿p\mathit{DL}_{p} 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 μ\mu-calculus, which subsumes PDL [15] in its expressiveness. In [13], Docherty and Rowe proposed a complete labelled cyclic proof system for PDL. Both μ\mu-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, 𝐷𝐿p\mathit{DL}_{p} is relatively simpler than PDL, in which programs can also depend on dynamic formulas. The labelled form of 𝐷𝐿p\mathit{DL}_{p} formula σ:[α]ϕ\sigma:[\alpha]\phi is inspired from [13], where a labelled PDL formula is of the form s:[α]ϕs:[\alpha]\phi, with ss a world in a Kripke structure. While in 𝐷𝐿p\mathit{DL}_{p}, a configuration σ\sigma 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 𝐷𝐿p\mathit{DL}_{p}, 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 𝐷𝐿p\mathit{DL}_{p}. 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. 𝐷𝐿p\mathit{DL}_{p} 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 𝐷𝐿p\mathit{DL}_{p} 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, 𝐷𝐿p\mathit{DL}_{p} 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 𝐷𝐿p\mathit{DL}_{p} 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 𝐷𝐿p\mathit{DL}_{p}, 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 𝐷𝐿p\mathit{DL}_{p}, we are also trying to use 𝐷𝐿p\mathit{DL}_{p} 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 π\pi-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 mumu-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 μ\mu-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 ϕ1,,ϕn,ϕ\phi_{1},...,\phi_{n},\phi, if formula ϕ1ϕnϕ\phi_{1}\wedge...\wedge\phi_{n}\to\phi is valid, then sequent

Γϕ1,ΔΓϕn,ΔΓϕ,Δ\displaystyle\Gamma\Rightarrow\phi,\Delta\lx@proof@logical@and\Gamma\Rightarrow\phi_{1},\Delta...\Gamma\Rightarrow\phi_{n},\Delta

is sound for any contexts Γ,Δ\Gamma,\Delta.

Proof

Assume 𝔓(Γϕ1,Δ)\mathfrak{P}(\Gamma\Rightarrow\phi_{1},\Delta),…,𝔓(Γϕn,Δ)\mathfrak{P}(\Gamma\Rightarrow\phi_{n},\Delta) are valid, for any evaluation ρ𝐄𝐯𝐚𝐥\rho\in\mathbf{Eval}, let ρΓ\rho\models\Gamma and ρ⊧̸ψ\rho\not\models\psi for all ψΔ\psi\in\Delta, we need to prove ρϕ\rho\models\phi. From the assumption we have ρϕ1\rho\models\phi_{1}, …, ρϕn\rho\models\phi_{n}. ρϕ\rho\models\phi is an immediate result since ϕ1ϕnϕ\phi_{1}\wedge...\wedge\phi_{n}\to\phi.

Content of Theorem 3.1: Provided that proof system PΛ,ΩP_{\Lambda,\Omega} is sound, all rules in 𝒟p\mathcal{DL}_{p} (Table 3) are sound.

Below we only prove the soundness of rules ([α])([\alpha]), (α)(\langle\alpha\rangle) and (Sub)({\textit{Sub}}). Other rules can be proved similarly based on the semantics of 𝐷𝐿p\mathit{DL}_{p} formulas (Definition 3). By Lemma 2, it is sufficient to prove ϕ1ϕnϕ\phi_{1}\wedge...\wedge\phi_{n}\to\phi, that is, for any evaluation ρ\rho, if ρϕ1\rho\models\phi_{1}, …, ρϕn\rho\models\phi_{n}, then ρϕ\rho\models\phi.

Proof (Proof of Theorem 3.1)

For rule ([α])([\alpha]), by the soundness of proof system PΛ,ΩΓ(α,σ)(α,σ),Δ\vdash_{P_{\Lambda,\Omega}}\Gamma\Rightarrow(\alpha,\sigma)\longrightarrow(\alpha^{\prime},\sigma^{\prime}),\Delta, it is sufficient to prove that for any evaluation ρ\rho, if ρσ:[α]ϕ\rho\models\sigma^{\prime}:[\alpha^{\prime}]\phi and (ρ(α,σ)ρ(α,σ))Λ(\rho(\alpha,\sigma)\longrightarrow\rho(\alpha^{\prime},\sigma^{\prime}))\in\Lambda for all (α,σ)Φ(\alpha^{\prime},\sigma^{\prime})\in\Phi, then ρσ:[α]ϕ\rho\models\sigma:[\alpha]\phi. However, this is straightforward by Definition 3 and the completeness of PΛ,ΩP_{\Lambda,\Omega} w.r.t. Λ\Lambda, because since α\alpha\not\equiv\downarrow, any path starting from ρ(α,σ)\rho(\alpha,\sigma) is of the form: ρ(α,σ)ρ(α,σ)(,σ′′)\rho(\alpha,\sigma)\rho(\alpha^{\prime},\sigma^{\prime})...(\downarrow,\sigma^{\prime\prime}) for some (α,σ)Φ(\alpha^{\prime},\sigma^{\prime})\in\Phi.

For rule (α)(\langle\alpha\rangle), by the soundness of proof system PΛ,ΩΓ(α,σ)(α,σ),Δ\vdash_{P_{\Lambda,\Omega}}\Gamma\Rightarrow(\alpha,\sigma)\longrightarrow(\alpha^{\prime},\sigma^{\prime}),\Delta, it is sufficient to prove that for any evaluation ρ\rho, if ρσ:αϕ\rho\models\sigma^{\prime}:\langle\alpha^{\prime}\rangle\phi and (ρ(α,σ)ρ(α,σ))Λ(\rho(\alpha,\sigma)\longrightarrow\rho(\alpha^{\prime},\sigma^{\prime}))\in\Lambda for some (α,σ)(\alpha^{\prime},\sigma^{\prime}), then ρσ:αϕ\rho\models\sigma:\langle\alpha\rangle\phi. However, this is direct by Definition 3.

For rule (Sub)({\textit{Sub}}), it is sufficient to prove that for any evaluation ρ𝐄𝐯𝐚𝐥\rho\in\mathbf{Eval}, there exists an evaluation ρ𝐄𝐯𝐚𝐥\rho^{\prime}\in\mathbf{Eval} such that for each formula ϕΓΔ\phi\in\Gamma\cup\Delta, we have ρ(Sub(ϕ))ρ(ϕ)\rho({\textit{Sub}}(\phi))\equiv\rho^{\prime}(\phi). But this just matches the definition of Sub in Definition 4.

Content of Proposition 3: m\preceq_{m} 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 s\prec_{s}. Below we only prove the anti-symmetry.

For any finite sets D1,D2D_{1},D_{2} of finite paths, if D1mD2D_{1}\preceq_{m}D_{2} but D1D2D_{1}\neq D_{2}, let fD1,D2:D1D2f_{D_{1},D_{2}}:D_{1}\to D_{2} be the function defined such that for any trD1tr\in D_{1}, either (1) fD1,D2(tr)strf_{D_{1},D_{2}}(tr)\approx_{s}tr; or (2) trtr is one of the replacements of a replaced element fD1,D2(tr)f_{D_{1},D_{2}}(tr) in D2D_{2} with trsfD1,D2(tr)tr\prec_{s}f_{D_{1},D_{2}}(tr).

For the anti-symmetry, suppose C1mC2\mathit{C}_{1}\preceq_{m}\mathit{C}_{2} and C2mC1\mathit{C}_{2}\preceq_{m}\mathit{C}_{1} but C1C2\mathit{C}_{1}\neq\mathit{C}_{2}. Let trC1tr\in\mathit{C}_{1} but trC2tr\notin\mathit{C}_{2}. Then from C1mC2\mathit{C}_{1}\preceq_{m}\mathit{C}_{2}, we have trsfC1,C2(tr)tr\prec_{s}f_{\mathit{C}_{1},\mathit{C}_{2}}(tr). Since fC1,C2(tr)f_{\mathit{C}_{1},\mathit{C}_{2}}(tr) is the replaced element, so fC1,C2(tr)C1f_{\mathit{C}_{1},\mathit{C}_{2}}(tr)\notin\mathit{C}_{1}. By C2mC1\mathit{C}_{2}\preceq_{m}\mathit{C}_{1}, we have fC1,C2(tr)sfC2,C1(fC1,C2(tr))f_{\mathit{C}_{1},\mathit{C}_{2}}(tr)\prec_{s}f_{\mathit{C}_{2},\mathit{C}_{1}}(f_{\mathit{C}_{1},\mathit{C}_{2}}(tr)). Continuing this process, we can construct an infinite descent sequence trsfC1,C2(tr)sfC2,C1(fC1,C2(tr))str\prec_{s}f_{\mathit{C}_{1},\mathit{C}_{2}}(tr)\prec_{s}f_{\mathit{C}_{2},\mathit{C}_{1}}(f_{\mathit{C}_{1},\mathit{C}_{2}}(tr))\prec_{s}... w.r.t. relation s\preceq_{s}, which violates its well-foundedness. So the only possibility is C1=C2\mathit{C}_{1}=\mathit{C}_{2}.

Content of Lemma 1: In a cyclic preproof (where there is at least one derivation path), let (τ,τ)(\tau,\tau^{\prime}) be a pair of a derivation trace over a node pair (ν,ν)(\nu,\nu^{\prime}) of an invalid derivation path, where τ{σ:[α]ϕ,σ:αϕ}\tau\in\{\sigma:[\alpha]\phi,\sigma:\langle\alpha\rangle\phi\} and ν=df(Γτ,Δ)\nu=_{df}(\Gamma\Rightarrow\tau,\Delta). For any counter-example CT(ρ,τ,ν)\textit{CT}(\rho,\tau,\nu) of τ\tau, there exists an evaluation ρ\rho^{\prime} and a counter-example CT(ρ,τ,ν)\textit{CT}(\rho^{\prime},\tau^{\prime},\nu^{\prime}) of τ\tau^{\prime} such that CT(ρ,τ,ν)mCT(ρ,τ,ν)\textit{CT}(\rho^{\prime},\tau^{\prime},\nu^{\prime})\preceq_{m}\textit{CT}(\rho,\tau,\nu). Moreover, if (τ,τ)(\tau,\tau^{\prime}) is a progressive step, then CT(ρ,τ,ν)mCT(ρ,τ,ν)\textit{CT}(\rho^{\prime},\tau^{\prime},\nu^{\prime})\prec_{m}\textit{CT}(\rho,\tau,\nu).

Proof (Proof of Lemma 1)

Consider the rule application from node ν\nu, actually the only non-trivial cases are when it is an instance of rule ([α])([\alpha]) (namely “case 1”) , rule (α)(\langle\alpha\rangle) (namely “case 2”) or a substitution rule (σSub)(\sigma{\textit{Sub}}) (namely “case 3”).

Case 1: If from node ν\nu rule ([α])([\alpha]) is applied with τ=dfσ:[α]ϕ\tau=_{df}\sigma:[\alpha]\phi the target formula, let τ=(σ:[α]ϕ)\tau^{\prime}=(\sigma^{\prime}:[\alpha^{\prime}]\phi) for some (α,σ)(\alpha^{\prime},\sigma^{\prime}), so ν=(Γτ,Δ)\nu^{\prime}=(\Gamma\Rightarrow\tau^{\prime},\Delta). For any ρ\rho that violates 𝔓(ν)\mathfrak{P}(\nu), CT(ρ,τ,ν)\textit{CT}(\rho,\tau,\nu) is obviously non-empty. So CT(ρ,τ,ν)\textit{CT}(\rho,\tau^{\prime},\nu^{\prime}) is also non-empty (since ρΓ\rho\models\Gamma and 𝔓(ν)\mathfrak{P}(\nu^{\prime}) is invalid). By Definition 1-2, CT(ρ,τ,ν)\textit{CT}(\rho,\tau,\nu) is also finite. By the derivation PΛ,Ω(Γ(α,σ)(α,σ),Δ)\vdash_{P_{\Lambda,\Omega}}(\Gamma\Rightarrow(\alpha,\sigma)\longrightarrow(\alpha^{\prime},\sigma^{\prime}),\Delta), for each path tr=ρ(α,σ)(,σn)CT(ρ,τ,ν)tr=\rho(\alpha^{\prime},\sigma^{\prime})...(\downarrow,\sigma_{n})\in\textit{CT}(\rho,\tau^{\prime},\nu^{\prime}) (n1n\geq 1), tr=ρ(α,σ)trtr^{\prime}=\rho(\alpha,\sigma)tr is a path in CT(ρ,τ,ν)\textit{CT}(\rho,\tau,\nu) that has trtr as its proper suffix. So we obtain the finiteness of CT(ρ,τ,ν)\textit{CT}(\rho,\tau^{\prime},\nu^{\prime}) from the finiteness of CT(ρ,τ,ν)\textit{CT}(\rho,\tau,\nu), and thus we have CT(ρ,τ,ν)mCT(ρ,τ,ν)\textit{CT}(\rho,\tau^{\prime},\nu^{\prime})\prec_{m}\textit{CT}(\rho,\tau,\nu).

Case 2: If from node ν\nu rule (α)(\langle\alpha\rangle) is applied with τ=dfσ:αϕ\tau=_{df}\sigma:\langle\alpha\rangle\phi the target formula, let τ=(σ:αϕ)\tau^{\prime}=(\sigma^{\prime}:\langle\alpha^{\prime}\rangle\phi) for some (α,σ)(\alpha^{\prime},\sigma^{\prime}), so ν=(Γτ,Δ)\nu^{\prime}=(\Gamma\Rightarrow\tau^{\prime},\Delta). For any ρ\rho that violates 𝔓(ν)\mathfrak{P}(\nu), ρΓ\rho\models\Gamma, so both CT(ρ,τ,ν)\textit{CT}(\rho,\tau,\nu) and CT(ρ,τ,ν)\textit{CT}(\rho,\tau^{\prime},\nu^{\prime}) are well defined. By Definition 1-2, CT(ρ,τ,ν)\textit{CT}(\rho,\tau,\nu) is finite. According to the derivation PΛ,Ω(Γ(α,σ)(α,σ),Δ)\vdash_{P_{\Lambda,\Omega}}(\Gamma\Rightarrow(\alpha,\sigma)\longrightarrow(\alpha^{\prime},\sigma^{\prime}),\Delta), for each path tr=ρ(α,σ)(,σn)CT(ρ,τ,ν)tr=\rho(\alpha^{\prime},\sigma^{\prime})...(\downarrow,\sigma_{n})\in\textit{CT}(\rho,\tau^{\prime},\nu^{\prime}) (n1n\geq 1), tr=ρ(α,σ)trtr^{\prime}=\rho(\alpha,\sigma)tr is a path in CT(ρ,τ,ν)\textit{CT}(\rho,\tau,\nu) that has trtr as its proper suffix. From the finiteness of CT(ρ,τ,ν)\textit{CT}(\rho,\tau,\nu), we have the finiteness of CT(ρ,τ,ν)\textit{CT}(\rho,\tau^{\prime},\nu^{\prime}). Now consider two cases: (1) If CT(ρ,τ,ν)\textit{CT}(\rho,\tau,\nu) is empty, then by the above CT(ρ,τ,ν)\textit{CT}(\rho,\tau^{\prime},\nu^{\prime}) is also empty. So CT(ρ,τ,ν)=CT(ρ,τ,ν)\textit{CT}(\rho,\tau^{\prime},\nu^{\prime})=\textit{CT}(\rho,\tau,\nu); (2) If CT(ρ,τ,ν)\textit{CT}(\rho,\tau^{\prime},\nu^{\prime}) is not empty, especially, when (τ,τ)(\tau,\tau^{\prime}) is a progressive step with the support of the derivation PΛ,Ω(Γ(α,σ),Δ))\vdash_{P_{\Lambda,\Omega}}(\Gamma\Rightarrow(\alpha^{\prime},\sigma^{\prime})\Downarrow,\Delta)), then from the above, CT(ρ,τ,ν)\textit{CT}(\rho,\tau,\nu) must also be non-empty. Moreover, in this case, we have CT(ρ,τ,ν)mCT(ρ,τ,ν)\textit{CT}(\rho,\tau^{\prime},\nu^{\prime})\prec_{m}\textit{CT}(\rho,\tau,\nu).

Case 3: If from node ν\nu a substitution rule (σSub)(\sigma{\textit{Sub}}) is applied, let τ=Sub(σ:[α]ϕ)\tau={\textit{Sub}}(\sigma:[\alpha]\phi) be the target formula of ν\nu, then τ=σ:[α]ϕ\tau^{\prime}=\sigma:[\alpha]\phi and ν=(Γτ,Δ)\nu^{\prime}=(\Gamma\Rightarrow\tau^{\prime},\Delta). The situation for τσ:αϕ\tau\equiv\sigma:\langle\alpha\rangle\phi is similar and we omit it here. For any evaluation ρ\rho that violates 𝔓(ν)\mathfrak{P}(\nu), by Definition 4 there exists a ρ𝐄𝐯𝐚𝐥\rho^{\prime}\in\mathbf{Eval} such that for any formula ψ𝐃𝐋𝐩\psi\in\mathbf{DL_{p}}, ρ(Sub(ψ))ρ(ψ)\rho({\textit{Sub}}(\psi))\equiv\rho^{\prime}(\psi). Especially, by the structureness of Sub, there exist α0,σ0\alpha_{0},\sigma_{0} and ϕ0\phi_{0} such that ρ(Sub(σ:[α]ϕ))σ0:[α0]ϕ0ρ(σ:[α]ϕ)\rho({\textit{Sub}}(\sigma:[\alpha]\phi))\equiv\sigma_{0}:[\alpha_{0}]\phi_{0}\equiv\rho^{\prime}(\sigma:[\alpha]\phi). Therefore, it is not hard to see that ρ\rho^{\prime} violates 𝔓(ν)\mathfrak{P}(\nu^{\prime}) and we have CT(ρ,τ,ν)=CT(ρ,τ,ν)\textit{CT}(\rho^{\prime},\tau^{\prime},\nu^{\prime})=\textit{CT}(\rho,\tau,\nu).

From the “case 2” of the above proof, we see that derivation PΛ,Ω(Γ(α,σ),Δ))\vdash_{P_{\Lambda,\Omega}}(\Gamma\Rightarrow(\alpha^{\prime},\sigma^{\prime})\Downarrow,\Delta)) plays the crucial role for proving the non-emptiness of the counter-examples in order to obtain a strict relation m\prec_{m}.

Content of Proposition 1: Given a sound rule of the form

Γ1Δ1ΓnΔnΓΔ, n1,\begin{aligned} \Gamma\Rightarrow\Delta\lx@proof@logical@and\Gamma_{1}\Rightarrow\Delta_{1}...\Gamma_{n}\Rightarrow\Delta_{n}\end{aligned},\mbox{ $n\geq 1$},

in which all formulas are unlabelled, rule

σ:Γ1σ:Δ1σ:Γnσ:Δnσ:Γσ:Δ\displaystyle\sigma:\Gamma\Rightarrow\sigma:\Delta\lx@proof@logical@and\sigma:\Gamma_{1}\Rightarrow\sigma:\Delta_{1}...\sigma:\Gamma_{n}\Rightarrow\sigma:\Delta_{n}

is sound for any configuration σ𝐂𝐨𝐧𝐟free(ΓΔΓ1Δ1ΓnΔn)\sigma\in\mathbf{Conf}_{\textit{free}}(\Gamma\cup\Delta\cup\Gamma_{1}\cup\Delta_{1}\cup...\cup\Gamma_{n}\cup\Delta_{n}).

Proof (Proof of Proposition 1)

Let A=ΓΔΓ1Δ1ΓnΔnA=\Gamma\cup\Delta\cup\Gamma_{1}\cup\Delta_{1}\cup...\cup\Gamma_{n}\cup\Delta_{n}. Assume formulas 𝔓(σ:Γ1σ:Δ1)\mathfrak{P}(\sigma:\Gamma_{1}\Rightarrow\sigma:\Delta_{1}),…,𝔓(σ:Γnσ:Δn)\mathfrak{P}(\sigma:\Gamma_{n}\Rightarrow\sigma:\Delta_{n}) are valid, we need to prove the validity of formula 𝔓(σ:Γσ:Δ)\mathfrak{P}(\sigma:\Gamma\Rightarrow\sigma:\Delta). First, notice that formula 𝔓(ΓiΔi)\mathfrak{P}(\Gamma_{i}\Rightarrow\Delta_{i}) (i1i\geq 1) is valid, because for any evaluation ρ𝐄𝐯𝐚𝐥\rho\in\mathbf{Eval}, by Definition 8-2 there exists a ρ𝐄𝐯𝐚𝐥\rho^{\prime}\in\mathbf{Eval} satisfying that (ρ,σ)Aρ(\rho^{\prime},\sigma)\leadsto_{A}\rho. So for any formula ϕA\phi\in A, ρϕ\rho\models\phi iff ρσ:ϕ\rho^{\prime}\models\sigma:\phi. Therefore, formula 𝔓(ΓΔ)\mathfrak{P}(\Gamma\Rightarrow\Delta) is valid. On the other hand, from that 𝔓(ΓΔ)\mathfrak{P}(\Gamma\Rightarrow\Delta) is valid, we can get that 𝔓(σ:Γσ:Δ)\mathfrak{P}(\sigma:\Gamma\Rightarrow\sigma:\Delta) is valid. This is because for any evaluation ρ𝐄𝐯𝐚𝐥\rho\in\mathbf{Eval}, by Definition 8-1 there is a ρ𝐄𝐯𝐚𝐥\rho^{\prime}\in\mathbf{Eval} such that (ρ,σ)Aρ(\rho,\sigma)\leadsto_{A}\rho^{\prime}, which means for any formula ϕA\phi\in A, ρσ:ϕ\rho\models\sigma:\phi iff ρϕ\rho^{\prime}\models\phi.

Appendix 0.B Formal Definitions of While Programs in 𝐷𝐿p\mathit{DL}_{p}

0.B.1 Syntax and Semantics of While Programs

We formally define program domain (𝐓𝐀WP,𝐄𝐯𝐚𝐥WP,WP){(\mathbf{TA}_{{\textit{WP}}},\mathbf{Eval}_{{\textit{WP}}},\mathfrak{I}_{{\textit{WP}}})} for While programs. Below, given a set AA, 𝒫(A)\mathcal{P}(A) represents its power set. Given a function f:ABf:A\to B, f[xv]f[x\mapsto v] represents the function that maps xx to value vv, and maps the other variables to the same value as ff.

Expressions. The variable set 𝑉𝑎𝑟WP\mathit{Var}_{\textit{WP}} ranges over the set of integer numbers \mathbb{Z}.

An expression ee is defined inductively as:

  1. (1)

    a variable x𝑉𝑎𝑟WPx\in\mathit{Var}_{\textit{WP}}, a constant nn\in\mathbb{Z} are expressions;

  2. (2)

    e1e2e_{1}\sim e_{2} where {+,,×,/}\sim\in\{+,-,\times,/\} are expressions if e1e_{1} and e2e_{2} are expressions.

+,,×,/+,-,\times,/ are the usual arithmetic operators in domain \mathbb{Z}. Denote the set of expressions as 𝐄𝐱𝐩WP\mathbf{Exp}_{\textit{WP}}.

𝐏𝐫𝐨𝐠WP\mathbf{Prog}_{\textit{WP}} & 𝐂𝐨𝐧𝐟WP\mathbf{Conf}_{\textit{WP}} & 𝐅𝐨𝐫𝐦WP\mathbf{Form}_{\textit{WP}}. A formula ϕ𝐅𝐨𝐫𝐦WP\phi\in\mathbf{Form}_{\textit{WP}} is an arithmetic first-order logical formula defined as follows:

ϕ=dfe1e2|¬ϕ|ϕϕ|x.ϕ.\phi=_{df}e_{1}\leq e_{2}\ |\ \neg\phi\ |\ \phi\wedge\phi\ |\ \forall x.\phi.

Relation \leq is the usual “less-than-equal relation” in domain \mathbb{Z}. Other logical operators such as \to, \vee, \exists can be expressed by ¬,\neg,\wedge and \forall accordingly in the usual way. Other relations such as == and << can be expressed by \leq and logical operators accordingly.

A program α𝐏𝐫𝐨𝐠WP\alpha\in\mathbf{Prog}_{\textit{WP}} is defined as follows in BNF forms:

α=dfx:=e|α;α|ifϕthenαelseαend|whileϕdoαend,\alpha=_{df}x:=e\ |\ \alpha\operatorname{;}\alpha\ |\ \textit{if}\ \phi\ \textit{then}\ \alpha\ \textit{else}\ \alpha\ \textit{end}\ |\ \textit{while}\ \phi\ \textit{do}\ \alpha\ \textit{end},

where ϕ𝐅𝐨𝐫𝐦WP\phi\in\mathbf{Form}_{\textit{WP}}.

A configuration σ𝐂𝐨𝐧𝐟WP\sigma\in\mathbf{Conf}_{\textit{WP}} is defined as follows in BNF forms:

σ=dfxe|xe,σ,\sigma=_{df}x\mapsto e\ |\ x\mapsto e,\sigma,

where there is at most one xex\mapsto e for each variable x𝑉𝑎𝑟WPx\in\mathit{Var}_{\textit{WP}}. We use {}\{\cdot\} to wrap a configuration σ\sigma as: {σ}\{\sigma\}.

Let 𝐓𝐀WP=df𝐄𝐱𝐩WP𝐏𝐫𝐨𝐠WP𝐂𝐨𝐧𝐟WP𝐅𝐨𝐫𝐦WP\mathbf{TA}_{\textit{WP}}=_{df}\mathbf{Exp}_{\textit{WP}}\cup\mathbf{Prog}_{\textit{WP}}\cup\mathbf{Conf}_{\textit{WP}}\cup\mathbf{Form}_{\textit{WP}}. With 𝐏𝐫𝐨𝐠WP,𝐂𝐨𝐧𝐟WP,𝐅𝐨𝐫𝐦WP\mathbf{Prog}_{\textit{WP}},\mathbf{Conf}_{\textit{WP}},\mathbf{Form}_{\textit{WP}} defined, we have 𝐷𝐿p\mathit{DL}_{p} formulas (𝐃𝐋𝐩)WP(\mathbf{DL_{p}})_{\textit{WP}} in program domain (𝐓𝐀WP,𝐄𝐯𝐚𝐥WP,WP){(\mathbf{TA}_{{\textit{WP}}},\mathbf{Eval}_{{\textit{WP}}},\mathfrak{I}_{{\textit{WP}}})} according to Definition 2.

Free Variables. For each term, its set of free variables is captured as function FV:𝐓𝐀WP𝒫(𝑉𝑎𝑟WP)\textit{FV}:\mathbf{TA}_{\textit{WP}}\to\mathcal{P}(\mathit{Var}_{\textit{WP}}), which is inductively defined as follows:

  1. (1)

    FV(x)=df{x}\textit{FV}(x)=_{df}\{x\}, FV(n)=df\textit{FV}(n)=_{df}\emptyset where nn\in\mathbb{Z};

  2. (2)

    FV(e1e2)=dfFV(e1)FV(e2)\textit{FV}(e_{1}\sim e_{2})=_{df}\textit{FV}(e_{1})\cup\textit{FV}(e_{2}), where {+,,×,/}\sim\in\{+,-,\times,/\};

  3. (3)

    FV(e1e2)=dfFV(e1)FV(e2)\textit{FV}(e_{1}\leq e_{2})=_{df}\textit{FV}(e_{1})\cup\textit{FV}(e_{2});

  4. (4)

    FV(¬ϕ)=dfFV(ϕ)\textit{FV}(\neg\phi)=_{df}\textit{FV}(\phi);

  5. (5)

    FV(ϕ1ϕ2)=dfFV(ϕ1)FV(ϕ2)\textit{FV}(\phi_{1}\wedge\phi_{2})=_{df}\textit{FV}(\phi_{1})\cup\textit{FV}(\phi_{2});

  6. (6)

    FV(x.ϕ)=dfFV(ϕ){x}\textit{FV}(\forall x.\phi)=_{df}\textit{FV}(\phi)\setminus\{x\};

  7. (7)

    FV(x:=e)=dfFV(e){x}\textit{FV}(x:=e)=_{df}\textit{FV}(e)\setminus\{x\};

  8. (8)

    FV(α;β)=dfFV(α)(FV(β)BD(α))\textit{FV}(\alpha\operatorname{;}\beta)=_{df}\textit{FV}(\alpha)\cup(\textit{FV}(\beta)\setminus\textit{BD}(\alpha));

  9. (9)

    FV(ifϕthenαelseβend)=dfFV(ϕ)FV(α)FV(β)\textit{FV}(\textit{if}\ \phi\ \textit{then}\ \alpha\ \textit{else}\ \beta\ \textit{end})=_{df}\textit{FV}(\phi)\cup\textit{FV}(\alpha)\cup\textit{FV}(\beta);

  10. (10)

    FV(whileϕdoαend)=dfFV(ϕ)FV(α)\textit{FV}(\textit{while}\ \phi\ \textit{do}\ \alpha\ \textit{end})=_{df}\textit{FV}(\phi)\cup\textit{FV}(\alpha);

  11. (11)

    FV(xe)=dfFV(e)\textit{FV}(x\mapsto e)=_{df}\textit{FV}(e);

  12. (12)

    FV(xe,σ)=dfFV(xe)FV(σ)\textit{FV}(x\mapsto e,\sigma)=_{df}\textit{FV}(x\mapsto e)\cup\textit{FV}(\sigma);

where function BD:(𝐏𝐫𝐨𝐠WP𝐂𝐨𝐧𝐟WP)𝒫(𝑉𝑎𝑟WP)\textit{BD}:(\mathbf{Prog}_{\textit{WP}}\cup\mathbf{Conf}_{\textit{WP}})\to\mathcal{P}(\mathit{Var}_{\textit{WP}}) returns the set of binding variables in programs and configurations, which is formally defined as:

  1. (1)

    BD(x:=e)=df{x}\textit{BD}(x:=e)=_{df}\{x\};

  2. (2)

    BD(α;β)=dfBD(α)BD(β)\textit{BD}(\alpha\operatorname{;}\beta)=_{df}\textit{BD}(\alpha)\cup\textit{BD}(\beta);

  3. (3)

    BD(ifϕthenαelseβend)=dfBD(α)BD(β)\textit{BD}(\textit{if}\ \phi\ \textit{then}\ \alpha\ \textit{else}\ \beta\ \textit{end})=_{df}\textit{BD}(\alpha)\cup\textit{BD}(\beta);

  4. (4)

    BD(whileϕdoαend)=dfBD(α)\textit{BD}(\textit{while}\ \phi\ \textit{do}\ \alpha\ \textit{end})=_{df}\textit{BD}(\alpha);

  5. (5)

    BD(xe)=df{x}\textit{BD}(x\mapsto e)=_{df}\{x\};

  6. (6)

    BD(xe,σ)=dfBD(xe)BD(σ)\textit{BD}(x\mapsto e,\sigma)=_{df}\textit{BD}(x\mapsto e)\cup\textit{BD}(\sigma).

If FV(t)=\textit{FV}(t)=\emptyset for a term t𝐓𝐀WPt\in\mathbf{TA}_{\textit{WP}}, we call it a closed term. For a set AA of terms, we use 𝐂𝐥(A)\mathbf{Cl}(A) to denote its subset of all closed terms.

We extend function FV to program states and 𝐷𝐿p\mathit{DL}_{p} formulas (𝐃𝐋𝐩)WP(\mathbf{DL_{p}})_{\textit{WP}}. For any program state (α,σ)𝐏𝐫𝐨𝐠WP×𝐂𝐨𝐧𝐟WP(\alpha,\sigma)\in\mathbf{Prog}_{\textit{WP}}\times\mathbf{Conf}_{\textit{WP}} or 𝐷𝐿p\mathit{DL}_{p} formula ϕ(𝐃𝐋𝐩)WP\phi\in(\mathbf{DL_{p}})_{\textit{WP}}, FV((α,σ))/FV(ϕ)\textit{FV}((\alpha,\sigma))/\textit{FV}(\phi) is defined inductively as follows:

  1. (i)

    FV((α,σ))=dfFV(σ)(FV(α)BD(σ))\textit{FV}((\alpha,\sigma))=_{df}\textit{FV}(\sigma)\cup(\textit{FV}(\alpha)\setminus\textit{BD}(\sigma)), if (α,σ)𝐏𝐫𝐨𝐠WP×𝐂𝐨𝐧𝐟WP(\alpha,\sigma)\in\mathbf{Prog}_{\textit{WP}}\times\mathbf{Conf}_{\textit{WP}};

  2. (ii)

    FV(F)\textit{FV}(F) is already defined, if F𝐅𝐨𝐫𝐦WPF\in\mathbf{Form}_{\textit{WP}};

  3. (iii)

    FV(σ:[α]ϕ)=dfFV(σ)(FV(α)BD(σ))(FV(ϕ)BD(σ))\textit{FV}(\sigma:[\alpha]\phi)=_{df}\textit{FV}(\sigma)\cup(\textit{FV}(\alpha)\setminus\textit{BD}(\sigma))\cup(\textit{FV}(\phi)\setminus\textit{BD}(\sigma));

  4. (iv)

    FV(σ:ϕ)=dfFV(σ)(FV(ϕ)BD(σ))\textit{FV}(\sigma:\phi)=_{df}\textit{FV}(\sigma)\cup(\textit{FV}(\phi)\setminus\textit{BD}(\sigma)), if ϕ\phi is not in a form: [α]ψ[\alpha]\psi;

  5. (v)

    FV(¬ϕ)=dfFV(ϕ)\textit{FV}(\neg\phi)=_{df}\textit{FV}(\phi);

  6. (vi)

    FV(ϕ1ϕ2)=dfFV(ϕ1)FV(ϕ2)\textit{FV}(\phi_{1}\wedge\phi_{2})=_{df}\textit{FV}(\phi_{1})\cup\textit{FV}(\phi_{2}).

A closed program state (α,σ)𝐏𝐫𝐨𝐠WP×𝐂𝐨𝐧𝐟WP(\alpha,\sigma)\in\mathbf{Prog}_{\textit{WP}}\times\mathbf{Conf}_{\textit{WP}} is a program state satisfying that FV(α,σ)=\textit{FV}(\alpha,\sigma)=\emptyset. A closed 𝐷𝐿p\mathit{DL}_{p} formula ϕ(𝐃𝐋𝐩)WP\phi\in(\mathbf{DL_{p}})_{\textit{WP}} is a formula such that FV(ϕ)=\textit{FV}(\phi)=\emptyset.

Substitutions. Given a function η:𝑉𝑎𝑟WP𝐄𝐱𝐩WP\eta:\mathit{Var}_{\textit{WP}}\to\mathbf{Exp}_{\textit{WP}} that maps each variables to an expression, its extension ηA:𝐓𝐀WP𝐓𝐀WP\eta^{*}_{A}:\mathbf{TA}_{\textit{WP}}\to\mathbf{TA}_{\textit{WP}} restricted on a set AA of variables, called a substitution, maps each term t𝐓𝐀WPt\in\mathbf{TA}_{\textit{WP}} to a term by replacing each free variable xAx\in A of tt with expression η(x)\eta(x). ηA\eta^{*}_{A} is inductively defined as follows:

  1. (1)

    ηA(x)=dfη(x)\eta^{*}_{A}(x)=_{df}\eta(x) if xAx\in A, ηA(x)=dfx\eta^{*}_{A}(x)=_{df}x otherwise;

  2. (2)

    ηA(n)=dfn\eta^{*}_{A}(n)=_{df}n if nn\in\mathbb{Z};

  3. (3)

    ηA(e1e2)=dfηA(e1)ηA(e2)\eta^{*}_{A}(e_{1}\sim e_{2})=_{df}\eta^{*}_{A}(e_{1})\sim\eta^{*}_{A}(e_{2}), where {+,,×,/}\sim\in\{+,-,\times,/\};

  4. (4)

    ηA(e1e2)=dfηA(e1)ηA(e2)\eta^{*}_{A}(e_{1}\leq e_{2})=_{df}\eta^{*}_{A}(e_{1})\leq\eta^{*}_{A}(e_{2});

  5. (5)

    ηA(¬ϕ)=dfηA(ϕ)\eta^{*}_{A}(\neg\phi)=_{df}\eta^{*}_{A}(\phi);

  6. (6)

    ηA(ϕ1ϕ2)=dfηA(ϕ1)ηA(ϕ2)\eta^{*}_{A}(\phi_{1}\wedge\phi_{2})=_{df}\eta^{*}_{A}(\phi_{1})\wedge\eta^{*}_{A}(\phi_{2});

  7. (7)

    ηA(x.ϕ)=dfx.ηA{x}(ϕ)\eta^{*}_{A}(\forall x.\phi)=_{df}\forall x.\eta^{*}_{A\setminus\{x\}}(\phi);

  8. (8)

    ηA(x:=e)=dfx:=ηA{x}(e)\eta^{*}_{A}(x:=e)=_{df}x:=\eta^{*}_{A\setminus\{x\}}(e);

  9. (9)

    ηA(α;β)=dfηA(α);ηABD(α)(β)\eta^{*}_{A}(\alpha\operatorname{;}\beta)=_{df}\eta^{*}_{A}(\alpha)\operatorname{;}\eta^{*}_{A\setminus\textit{BD}(\alpha)}(\beta);

  10. (10)

    ηA(ifϕthenαelseβend)=dfifηA(ϕ)thenηA(α)elseηA(β)end\eta^{*}_{A}(\textit{if}\ \phi\ \textit{then}\ \alpha\ \textit{else}\ \beta\ \textit{end})=_{df}\textit{if}\ \eta^{*}_{A}(\phi)\ \textit{then}\ \eta^{*}_{A}(\alpha)\ \textit{else}\ \eta^{*}_{A}(\beta)\ \textit{end};

  11. (11)

    ηA(whileϕdoαend)=dfwhileηA(ϕ)doηA(α)end\eta^{*}_{A}(\textit{while}\ \phi\ \textit{do}\ \alpha\ \textit{end})=_{df}\textit{while}\ \eta^{*}_{A}(\phi)\ \textit{do}\ \eta^{*}_{A}(\alpha)\ \textit{end};

  12. (12)

    ηA(xe)=dfxηA(e)\eta^{*}_{A}(x\mapsto e)=_{df}x\mapsto\eta^{*}_{A}(e);

  13. (13)

    ηA(xe,σ)=dfηA(xe),ηA(σ)\eta^{*}_{A}(x\mapsto e,\sigma)=_{df}\eta^{*}_{A}(x\mapsto e),\eta^{*}_{A}(\sigma).

For any term t𝐓𝐀WPt\in\mathbf{TA}_{\textit{WP}}, we define η(t)=dfη𝐓𝐀WP(t)\eta^{*}(t)=_{df}\eta^{*}_{\mathbf{TA}_{\textit{WP}}}(t). We often use t[e/x]t[e/x] to denote a substitution η{x}(t)\eta^{*}_{\{x\}}(t), with η(x)=e\eta(x)=e.

For a substitution η(t)\eta^{*}(t) of a term t𝐓𝐀WPt\in\mathbf{TA}_{\textit{WP}}, we always assume that it is admissible in the usual sense that we guarantee that each free variable yy of a replacing term, say η(x)\eta(x) for some variable xx, is still free in η(t)\eta^{*}(t) after the substitution by variable renaming if necessary.

We extend substitution ηA\eta^{*}_{A} to program states 𝐏𝐫𝐨𝐠WP×𝐂𝐨𝐧𝐟WP\mathbf{Prog}_{\textit{WP}}\times\mathbf{Conf}_{\textit{WP}} and 𝐷𝐿p\mathit{DL}_{p} formulas (𝐃𝐋𝐩)WP(\mathbf{DL_{p}})_{\textit{WP}} as follows:

  1. (i)

    ηA((α,σ))=df(ηABD(σ)(α),ηA(σ))\eta^{*}_{A}((\alpha,\sigma))=_{df}(\eta^{*}_{A\setminus\textit{BD}(\sigma)}(\alpha),\eta^{*}_{A}(\sigma)), if (α,σ)𝐏𝐫𝐨𝐠WP×𝐂𝐨𝐧𝐟WP(\alpha,\sigma)\in\mathbf{Prog}_{\textit{WP}}\times\mathbf{Conf}_{\textit{WP}};

  2. (ii)

    ηA(F)\eta^{*}_{A}(F) is already defined, if F𝐅𝐨𝐫𝐦WPF\in\mathbf{Form}_{\textit{WP}};

  3. (iii)

    ηA(σ:[α]ϕ)=dfηA(σ):[ηABD(σ)(α)]ηABD(σ)(ϕ)\eta^{*}_{A}(\sigma:[\alpha]\phi)=_{df}\eta^{*}_{A}(\sigma):[\eta^{*}_{A\setminus\textit{BD}(\sigma)}(\alpha)]\eta^{*}_{A\setminus\textit{BD}(\sigma)}(\phi);

  4. (iv)

    ηA(σ:ϕ)=dfηA(σ):ηABD(σ)(ϕ)\eta^{*}_{A}(\sigma:\phi)=_{df}\eta^{*}_{A}(\sigma):\eta^{*}_{A\setminus\textit{BD}(\sigma)}(\phi), if ϕ\phi is not in a form: [α]ψ[\alpha]\psi;

  5. (v)

    ηA(¬ϕ)=df¬ηA(ϕ)\eta^{*}_{A}(\neg\phi)=_{df}\neg\eta^{*}_{A}(\phi);

  6. (vi)

    ηA(ϕ1ϕ2)=dfηA(ϕ1)ηA(ϕ2)\eta^{*}_{A}(\phi_{1}\wedge\phi_{2})=_{df}\eta^{*}_{A}(\phi_{1})\wedge\eta^{*}_{A}(\phi_{2}).

𝐄𝐯𝐚𝐥WP\mathbf{Eval}_{\textit{WP}} & WP\mathfrak{I}_{\textit{WP}}. Let ss be a function s:𝑉𝑎𝑟WP𝐂𝐥(𝐄𝐱𝐩WP)s:\mathit{Var}_{\textit{WP}}\to\mathbf{Cl}(\mathbf{Exp}_{\textit{WP}}), then ss^{*} is an evaluation of 𝐄𝐯𝐚𝐥WP\mathbf{Eval}_{\textit{WP}}. Given a configuration σ𝐂𝐨𝐧𝐟WP\sigma\in\mathbf{Conf}_{\textit{WP}}, σ():𝑉𝑎𝑟WP𝐄𝐱𝐩WP\sigma(\cdot):\mathit{Var}_{\textit{WP}}\to\mathbf{Exp}_{\textit{WP}} is a function defined inductively as follows:

  1. (1)

    (xe)(x)=dfe(x\mapsto e)(x)=_{df}e;

  2. (2)

    (xe,σ)(y)=df(xe)(y)(x\mapsto e,\sigma)(y)=_{df}(x\mapsto e)(y) if yxy\equiv x, (xe,σ)(y)=dfσ(y)(x\mapsto e,\sigma)(y)=_{df}\sigma(y) otherwise.

For any σ𝐂𝐨𝐧𝐟WP\sigma\in\mathbf{Conf}_{\textit{WP}} and ϕ𝐅𝐨𝐫𝐦WP\phi\in\mathbf{Form}_{\textit{WP}}, we define interpretation WP(σ,ϕ)=dfσ(ϕ)\mathfrak{I}_{\textit{WP}}(\sigma,\phi)=_{df}\sigma^{*}(\phi).

𝐏𝐫𝐨𝐩WP\mathbf{Prop}_{\textit{WP}} & ΛWP\Lambda_{\textit{WP}} & ΩWP\Omega_{\textit{WP}}. Propositions 𝐏𝐫𝐨𝐩WP\mathbf{Prop}_{\textit{WP}} is defined as the set of all closed formulas of 𝐅𝐨𝐫𝐦WP\mathbf{Form}_{\textit{WP}}. For a formula ϕ𝐂𝐥(𝐅𝐨𝐫𝐦WP)\phi\in\mathbf{Cl}(\mathbf{Form}_{\textit{WP}}), 𝔗WP(ϕ)=df1{\mathfrak{T}}_{\textit{WP}}(\phi)=_{df}1 if formula ϕ\phi is true in the theory of integer numbers. Table 6 depicts the operational semantics of While programs. For a program transition (α,σ)(α,σ)𝐂𝐥(𝐅𝐨𝐫𝐦WP)(\alpha,\sigma)\longrightarrow(\alpha^{\prime},\sigma^{\prime})\in\mathbf{Cl}(\mathbf{Form}_{\textit{WP}}), 𝔗WP((α,σ)(α,σ))=df1{\mathfrak{T}}_{\textit{WP}}((\alpha,\sigma)\longrightarrow(\alpha^{\prime},\sigma^{\prime}))=_{df}1 if (α,σ)(α,σ)(\alpha,\sigma)\longrightarrow(\alpha^{\prime},\sigma^{\prime}) can be inferred according to Table 6. With ΛWP\Lambda_{\textit{WP}} defined, we can obtain ΩWP\Omega_{\textit{WP}} according to Section 2.3.

(o:x:=e)(x:=e,σ)(,σσ(e)x)(x:=e,\sigma)\longrightarrow(\downarrow,\sigma^{x}_{\sigma^{*}(e)})   (α1,σ)(α1,σ)α1(o:;)(α1;α2,σ)(α1;α2,σ)(\alpha_{1};\alpha_{2},\sigma)\longrightarrow(\alpha^{\prime}_{1};\alpha_{2},\sigma^{\prime})\lx@proof@logical@and(\alpha_{1},\sigma)\longrightarrow(\alpha^{\prime}_{1},\sigma^{\prime})\alpha^{\prime}_{1}\not\equiv\downarrow   (α1,σ)(,σ)(o:;)(α1;α2,σ)(α2,σ)(\alpha_{1};\alpha_{2},\sigma)\longrightarrow(\alpha_{2},\sigma^{\prime})(\alpha_{1},\sigma)\longrightarrow(\downarrow,\sigma^{\prime}) (α1,σ)(α1,σ)ϕ is true(o:ite-1)(ifϕthenα1elseα2end,σ)(α1,σ)(\textit{if}\ \phi\ \textit{then}\ \alpha_{1}\ \textit{else}\ \alpha_{2}\ \textit{end},\sigma)\longrightarrow(\alpha^{\prime}_{1},\sigma^{\prime})\lx@proof@logical@and(\alpha_{1},\sigma)\longrightarrow(\alpha^{\prime}_{1},\sigma^{\prime})\phi\mbox{ is true}   (α2,σ)(α2,σ)ϕ is false(o:ite-2)(ifϕthenα1elseα2end,σ)(α2,σ)(\textit{if}\ \phi\ \textit{then}\ \alpha_{1}\ \textit{else}\ \alpha_{2}\ \textit{end},\sigma)\longrightarrow(\alpha^{\prime}_{2},\sigma^{\prime})\lx@proof@logical@and(\alpha_{2},\sigma)\longrightarrow(\alpha^{\prime}_{2},\sigma^{\prime})\phi\mbox{ is false} (α,σ)(α,σ)σ(ϕ) is true(o:wh-1)(whileϕdoαend,σ)(α;whileϕdoαend,σ)(\textit{while}\ \phi\ \textit{do}\ \alpha\ \textit{end},\sigma)\longrightarrow(\alpha^{\prime}\ ;\ \textit{while}\ \phi\ \textit{do}\ \alpha\ \textit{end},\sigma^{\prime})\lx@proof@logical@and(\alpha,\sigma)\longrightarrow(\alpha^{\prime},\sigma^{\prime})\sigma^{*}(\phi)\mbox{ is true}   (α,σ)(,σ)σ(ϕ) is true(o:wh-1)(whileϕdoαend,σ)(whileϕdoαend,σ)(\textit{while}\ \phi\ \textit{do}\ \alpha\ \textit{end},\sigma)\longrightarrow(\textit{while}\ \phi\ \textit{do}\ \alpha\ \textit{end},\sigma^{\prime})\lx@proof@logical@and(\alpha,\sigma)\longrightarrow(\downarrow,\sigma^{\prime})\sigma^{*}(\phi)\mbox{ is true} σ(ϕ) is false(o:wh-2)(whileϕdoαend,σ)(,σ)(\textit{while}\ \phi\ \textit{do}\ \alpha\ \textit{end},\sigma)\longrightarrow(\downarrow,\sigma)\sigma^{*}(\phi)\mbox{ is false}

Table 6: Operational Semantics of While Programs

0.B.2 Proof System PΛWP,ΩWPP_{\Lambda_{\textit{WP}},\Omega_{\textit{WP}}}

Proof System PΛWP,ΩWPP_{\Lambda_{\textit{WP}},\Omega_{\textit{WP}}}. Table 7 and 8 list the inference rules for program behaviours ΛWP\Lambda_{\textit{WP}} and program terminations ΩWP\Omega_{\textit{WP}} 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 PΛWP,ΩWPP_{\Lambda_{\textit{WP}},\Omega_{\textit{WP}}}.

(x:=e)Γ(x:=e,σ)(,σσ(e)x),Δ\Gamma\Rightarrow(x:=e,\sigma)\longrightarrow(\downarrow,\sigma^{x}_{\sigma^{*}(e)}),\Delta   Γ(α1,σ)(α1,σ),Δ(;)Γ(α1;α2,σ)(α1;α2,σ),Δ\Gamma\Rightarrow(\alpha_{1};\alpha_{2},\sigma)\longrightarrow(\alpha^{\prime}_{1};\alpha_{2},\sigma^{\prime}),\Delta\Gamma\Rightarrow(\alpha_{1},\sigma)\longrightarrow(\alpha^{\prime}_{1},\sigma^{\prime}),\Delta   Γ(α1,σ)(,σ),Δ(;)Γ(α1;α2,σ)(α2,σ),Δ\Gamma\Rightarrow(\alpha_{1};\alpha_{2},\sigma)\longrightarrow(\alpha_{2},\sigma^{\prime}),\Delta\Gamma\Rightarrow(\alpha_{1},\sigma)\longrightarrow(\downarrow,\sigma^{\prime}),\Delta Γ(α1,σ)(α1,σ),ΔΓ(σ,ϕ),Δ(ite-1)Γ(ifϕthenα1elseα2end,σ)(α1,σ),Δ\Gamma\Rightarrow(\textit{if}\ \phi\ \textit{then}\ \alpha_{1}\ \textit{else}\ \alpha_{2}\ \textit{end},\sigma)\longrightarrow(\alpha^{\prime}_{1},\sigma^{\prime}),\Delta\lx@proof@logical@and\Gamma\Rightarrow(\alpha_{1},\sigma)\longrightarrow(\alpha^{\prime}_{1},\sigma^{\prime}),\Delta\Gamma\Rightarrow\mathfrak{I}(\sigma,\phi),\Delta   Γ(α2,σ)(α2,σ),ΔΓ¬(σ,ϕ),Δ(ite-2)Γ(ifϕthenα1elseα2end,σ)(α2,σ),Δ\Gamma\Rightarrow(\textit{if}\ \phi\ \textit{then}\ \alpha_{1}\ \textit{else}\ \alpha_{2}\ \textit{end},\sigma)\longrightarrow(\alpha^{\prime}_{2},\sigma^{\prime}),\Delta\lx@proof@logical@and\Gamma\Rightarrow(\alpha_{2},\sigma)\longrightarrow(\alpha^{\prime}_{2},\sigma^{\prime}),\Delta\Gamma\Rightarrow\neg\mathfrak{I}(\sigma,\phi),\Delta Γ,(σ,ϕ)(α,σ)(α,σ),ΔΓ(σ,ϕ),Δ(wh1)Γ(whileϕdoαend,σ)(α;whileϕdoαend,σ),Δ\Gamma\Rightarrow(\textit{while}\ \phi\ \textit{do}\ \alpha\ \textit{end},\sigma)\longrightarrow(\alpha^{\prime};\ \textit{while}\ \phi\ \textit{do}\ \alpha\ \textit{end},\sigma^{\prime}),\Delta\lx@proof@logical@and\Gamma,\mathfrak{I}(\sigma,\phi)\Rightarrow(\alpha,\sigma)\longrightarrow(\alpha^{\prime},\sigma^{\prime}),\Delta\Gamma\Rightarrow\mathfrak{I}(\sigma,\phi),\Delta Γ,(σ,ϕ)(α,σ)(,σ),ΔΓ(σ,ϕ),Δ(wh1)Γ(whileϕdoαend,σ)(whileϕdoαend,σ),Δ\Gamma\Rightarrow(\textit{while}\ \phi\ \textit{do}\ \alpha\ \textit{end},\sigma)\longrightarrow(\textit{while}\ \phi\ \textit{do}\ \alpha\ \textit{end},\sigma^{\prime}),\Delta\lx@proof@logical@and\Gamma,\mathfrak{I}(\sigma,\phi)\Rightarrow(\alpha,\sigma)\longrightarrow(\downarrow,\sigma^{\prime}),\Delta\Gamma\Rightarrow\mathfrak{I}(\sigma,\phi),\Delta   Γ¬(σ,ϕ),Δ(wh2)Γ(whileϕdoαend,σ)(,σ),Δ\Gamma\Rightarrow(\textit{while}\ \phi\ \textit{do}\ \alpha\ \textit{end},\sigma)\longrightarrow(\downarrow,\sigma),\Delta\Gamma\Rightarrow\neg\mathfrak{I}(\sigma,\phi),\Delta

Table 7: Inference Rules for Program Behaviours of While programs

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. ΛWP\Lambda_{\textit{WP}} are trivial. Table 8, 9 list two types of inference rules for program terminations. In Table 8, termination (α,σ)σ(\alpha,\sigma)\Downarrow\sigma^{\prime} means terminating with configuration σ\sigma^{\prime} as the result. In other words, there exists a path (α,σ)(,σ)(\alpha,\sigma)...(\downarrow,\sigma^{\prime}) over ΛWP\Lambda_{\textit{WP}}. In rule (wh1)(\Downarrow\textit{wh}1), where II is an invariant of the loop body α\alpha; xx is a termination factor of the while statement indicating its terminations. The soundness and completeness of the rules in Table 8 w.r.t. ΩWP\Omega_{\textit{WP}} can be proved based on the boolean semantics 𝔗WP{\mathfrak{T}}_{\textit{WP}} in an inductively way according to the syntax of While programs.

(x:=e)Γ(x:=e,σ)σσ(e)x,Δ\Gamma\Rightarrow(x:=e,\sigma)\Downarrow\sigma^{x}_{\sigma^{*}(e)},\Delta   Γ(α1,σ)σ′′,ΔΓ(α2,σ′′)σ,Δ(;)Γ(α1;α2,σ)σ,Δ\Gamma\Rightarrow(\alpha_{1};\alpha_{2},\sigma)\Downarrow\sigma^{\prime},\Delta\lx@proof@logical@and\Gamma\Rightarrow(\alpha_{1},\sigma)\Downarrow\sigma^{\prime\prime},\Delta\Gamma\Rightarrow(\alpha_{2},\sigma^{\prime\prime})\Downarrow\sigma^{\prime},\Delta Γ(α1,σ)σ,ΔΓσ(ϕ),Δ(ite-1)Γ(ifϕthenα1elseα2end,σ)σ,Δ\Gamma\Rightarrow(\textit{if}\ \phi\ \textit{then}\ \alpha_{1}\ \textit{else}\ \alpha_{2}\ \textit{end},\sigma)\Downarrow\sigma^{\prime},\Delta\lx@proof@logical@and\Gamma\Rightarrow(\alpha_{1},\sigma)\Downarrow\sigma^{\prime},\Delta\Gamma\Rightarrow\sigma^{*}(\phi),\Delta   Γ(α2,σ)σ,ΔΓσ(¬ϕ),Δ(ite-2)Γ(ifϕthenα1elseα2end,σ)σ,Δ\Gamma\Rightarrow(\textit{if}\ \phi\ \textit{then}\ \alpha_{1}\ \textit{else}\ \alpha_{2}\ \textit{end},\sigma)\Downarrow\sigma^{\prime},\Delta\lx@proof@logical@and\Gamma\Rightarrow(\alpha_{2},\sigma)\Downarrow\sigma^{\prime},\Delta\Gamma\Rightarrow\sigma^{*}(\neg\phi),\Delta Γσ(x>0Iϕ),Δσ(x=nI)(α,σ)σ′′σ′′(x<nI)σ(x0I)σ(¬ϕ)(wh1)Γ(whileϕdoαend,σ)σ,Δ\Gamma\Rightarrow(\textit{while}\ \phi\ \textit{do}\ \alpha\ \textit{end},\sigma)\Downarrow\sigma^{\prime},\Delta\lx@proof@logical@and\Gamma\Rightarrow\sigma^{*}(x>0\wedge I\wedge\phi),\Delta\sigma^{*}(x=n\wedge I)\Rightarrow(\alpha,\sigma)\Downarrow\sigma^{\prime\prime}\wedge\sigma^{\prime\prime*}(x<n\wedge I)\sigma^{\prime*}(x\leq 0\wedge I)\Rightarrow\sigma^{\prime*}(\neg\phi) Γσ(¬ϕ),Δ(wh2)Γ(whileϕdoαend,σ)σ,Δ\Gamma\Rightarrow(\textit{while}\ \phi\ \textit{do}\ \alpha\ \textit{end},\sigma)\Downarrow\sigma,\Delta\Gamma\Rightarrow\sigma^{*}(\neg\phi),\Delta   Γ(α,σ)σ,Δ()Γ(α,σ),Δ\Gamma\Rightarrow(\alpha,\sigma)\Downarrow,\Delta\Gamma\Rightarrow(\alpha,\sigma)\Downarrow\sigma^{\prime},\Delta

Table 8: Inference Rules for Program Terminations of While programs

The soundness of rule (Sub)({\textit{Sub}}) in While-programs domain is instantiated by choosing the substitution ()[e/x](\cdot)[e/x] (e𝐄𝐱𝐩WPe\in\mathbf{Exp}_{\textit{WP}}):

ΓΔ(Sub)Γ[e/x]Δ[e/x].\begin{aligned} \Gamma[e/x]\Rightarrow\Delta[e/x]\Gamma\Rightarrow\Delta\end{aligned}.

To see its soundness, we only need to prove that function ()[e/x](\cdot)[e/x] is just a ‘substitution’ defined in Definition 4. We observe that for any evaluation σ𝐄𝐯𝐚𝐥WP\sigma^{*}\in\mathbf{Eval}_{\textit{WP}}, let ρ=dfσ[xσ(e)]\rho=_{df}\sigma^{*}[x\mapsto\sigma^{*}(e)]. Then for any formula ϕ(𝐃𝐋𝐩)WP\phi\in(\mathbf{DL_{p}})_{\textit{WP}}, by the definition of the substitutions above, we can have σ(ϕ[e/x])σ𝑉𝑎𝑟WP{x}(ϕ)[σ(e)/x]ρ𝑉𝑎𝑟WP{x}(ϕ)[σ(e)/x]ρ(ϕ)\sigma^{*}(\phi[e/x])\equiv\sigma^{*}_{\mathit{Var}_{\textit{WP}}\setminus\{x\}}(\phi)[\sigma^{*}(e)/x]\equiv\rho_{\mathit{Var}_{\textit{WP}}\setminus\{x\}}(\phi)[\sigma^{*}(e)/x]\equiv\rho(\phi).

Γ(α,σ{e}),ΔΓ(α,σ)(α,σ),ΔΓe0,ΔΓee,Δ()Γ(α,σ{e}),Δ\begin{aligned} \Gamma\Rightarrow(\alpha,\sigma\{e\})\Downarrow,\Delta\lx@proof@logical@and\Gamma\Rightarrow(\alpha^{\prime},\sigma^{\prime}\{e^{\prime}\})\Downarrow,\Delta\Gamma\Rightarrow(\alpha,\sigma)\longrightarrow(\alpha^{\prime},\sigma^{\prime}),\Delta\Gamma\Rightarrow e^{\prime}\geq 0,\Delta\Gamma\Rightarrow e^{\prime}\leq e,\Delta\end{aligned} ΓΔ(Sub)Γ[e/x]Δ[e/x]\begin{aligned} \Gamma[e/x]\Rightarrow\Delta[e/x]\Gamma\Rightarrow\Delta\end{aligned}

Table 9: Another Type of Inference Rules for Program Terminations of While programs

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 PDLP{P_{\textit{DLP}}}, which also relies on rule (Sub)({\textit{Sub}}) and other rules in first-order logic. In rule ()(\Downarrow\longrightarrow), given a configuration σ𝐂𝐨𝐧𝐟WP\sigma\in\mathbf{Conf}_{\textit{WP}}, σ{e}\sigma\{e\} expresses that an expression ee called the termination factor of σ\sigma appears in σ\sigma, which indicates how far a program can terminate. Rule (Sub)({\textit{Sub}}) 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 ((α,σ{e}),(α,σ{e}))((\alpha,\sigma\{e\})\Downarrow,(\alpha^{\prime},\sigma^{\prime}\{e^{\prime}\})\Downarrow) of an instance of rule ()(\Downarrow\longrightarrow), but with the premise ‘Γe<e,Δ\Gamma\Rightarrow e^{\prime}<e,\Delta’.

The soundness of rule ()(\Downarrow\longrightarrow) 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 (α1,σ1{e1})(\alpha_{1},\sigma_{1}\{e_{1}\}), if (α1,σ1)⇓̸(\alpha_{1},\sigma_{1})\not\Downarrow, then by the definition of ‘cyclic preproof’ (Defnition 6) we have an infinite sequence of relations: e1e2ene_{1}\geq e_{2}\geq...\geq e_{n}\geq... with expressions e1,,en0e_{1},...,e_{n}\geq 0. 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 𝐷𝐿p\mathit{DL}_{p} to verify a program whose “loop structures” are implicit. That is where 𝐷𝐿p\mathit{DL}_{p} is really useful as the loop information can be tracked in the cyclic proof structures of 𝐷𝐿p\mathit{DL}_{p}. Consider the synchronous program E𝐏𝐫𝐨𝐠EE\in\mathbf{Prog}_{E} (Table 1) written in Esterel [6]:

E=dftrapABend,E=_{df}\textit{trap}\ A\parallel B\ \textit{end},

where A=dfloop(emitS(0);x:=xS;ifx=0thenexitend;pause)endA=_{df}\textit{loop}\ (\textit{emit}\ S(0)\ ;\ x:=x-S\ ;\ \textit{if}\ x=0\ \textit{then}\ \textit{exit}\ \textit{end}\ ;\ \textit{pause})\ \textit{end}, B=dfloop(emitS(1);pause)endB=_{df}\textit{loop}\ (\textit{emit}\ S(1)\ ;\ \textit{pause})\ \textit{end} 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 \bot, representing ‘absent’ state. The loop statements in programs AA and BB are executed repeatedly for an infinite number of times until some exit statement is encountered. At each instance, program AA firstly emits signal SS with value 0 and substracts the local variable xx with the current value of SS; then checks if x=0x=0. While program BB emits signal SS with value 11. The value of signal SS in one instance should be the sum of all of its emitted values by different current programs. So the value of SS should be 1+0=11+0=1. The whole program EE continues executing until x=0x=0 is satisfied, when exit terminates the whole program by jumping out of the trap statement.

As an instance, when initializing xx as value 33, the values of all variables at the end of each instance are listed as follows:

  • instance 1: (x=3,S=1)(x=3,S=1);

  • instance 2: (x=2,S=1)(x=2,S=1);

  • instance 3: (x=1,S=1)(x=1,S=1);

  • instance 4: (x=0,S=1)(x=0,S=1).

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 EE above, for instance, the assignment x:=xSx:=x-S can only be executed after all values of SS in both programs AA and BB are collected. In other words, the assignment x:=xSx:=x-S can only be executed after emitS(0)\textit{emit}\ S(0) and emitS(1)\textit{emit}\ S(1). 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

ν2=df(v>0){xv|S}:E𝑡𝑟𝑢𝑒,\nu_{2}=_{df}(v>0)\Rightarrow\{x\mapsto v\operatorname{|}S\mapsto\bot\}:\langle E\rangle\mathit{true},

which says that under configuration {xv,S}\{x\mapsto v,S\mapsto\bot\} (with vv a free variable), if v>0v>0, then EE can finally terminate (satisfying 𝑡𝑟𝑢𝑒\mathit{true}).

(Ter)17(WkR)516(LE)15(Sub)14(LE)13(α)12(α)7(Ter)11(Int)10()9(α)8(σL)6(σCut)4(α)3(α)2(α)ν2:1\mbox{$\nu_{2}:1$}234\lx@proof@logical@and 5176\lx@proof@logical@and 71213141516891011 Definitions of other symbols: A=dfloop(emitS(0);x:=xS;ifx=0thenexitend;pause)endA=_{df}\textit{loop}\ (\textit{emit}\ S(0)\ ;\ x:=x-S\ ;\ \textit{if}\ x=0\ \textit{then}\ \textit{exit}\ \textit{end}\ ;\ \textit{pause})\ \textit{end} B=dfloop(emitS(1);pause)endB=_{df}\textit{loop}\ (\textit{emit}\ S(1)\ ;\ \textit{pause})\ \textit{end} A=df(ifx=0thenexitend;pause)A^{\prime}=_{df}(\textit{if}\ x=0\ \textit{then}\ \textit{exit}\ \textit{end}\ ;\ \textit{pause}) σ1(v)=df{xv|S}\sigma_{1}(v)=_{df}\{x\mapsto v\operatorname{|}S\mapsto\bot\} σ2(v)=df{xv|S0}\sigma_{2}(v)=_{df}\{x\mapsto v\operatorname{|}S\mapsto 0\} σ3(v)=df{xv|S1}\sigma_{3}(v)=_{df}\{x\mapsto v\operatorname{|}S\mapsto 1\} σ4(v)=df{xv1|S1}\sigma_{4}(v)=_{df}\{x\mapsto v-1\operatorname{|}S\mapsto 1\} σ5(v)=df{xv1|S}\sigma_{5}(v)=_{df}\{x\mapsto v-1\operatorname{|}S\mapsto\bot\} 1: v>0v>0 \Rightarrow σ1(v):trapABend𝑡𝑟𝑢𝑒\sigma_{1}(v):\langle\textit{trap}\ A\parallel B\ \textit{end}\rangle\mathit{true} 2: v>0v>0 \Rightarrow σ2(v):trap((x:=xS;A);A)B)end𝑡𝑟𝑢𝑒\sigma_{2}(v):\langle\textit{trap}\ ((x:=x-S\ ;A^{\prime})\ ;\ A)\parallel B)\ \textit{end}\rangle\mathit{true} 3: v>0v>0 \Rightarrow σ3(v):trap((x:=xS;A);A)(pause;B)end𝑡𝑟𝑢𝑒\sigma_{3}(v):\langle\textit{trap}\ ((x:=x-S\ ;A^{\prime})\ ;\ A)\parallel(\textit{pause}\ ;\ B)\ \textit{end}\rangle\mathit{true} 4: v>0v>0 \Rightarrow σ4(v):trap(A;A)(pause;B)end𝑡𝑟𝑢𝑒\sigma_{4}(v):\langle\textit{trap}\ (A^{\prime}\ ;\ A)\parallel(\textit{pause}\ ;\ B)\ \textit{end}\rangle\mathit{true} 5: v>0v>0 \Rightarrow σ4(v):trap(A;A)(pause;B)end𝑡𝑟𝑢𝑒,v10v1=0\sigma_{4}(v):\langle\textit{trap}\ (A^{\prime}\ ;\ A)\parallel(\textit{pause}\ ;\ B)\ \textit{end}\rangle\mathit{true},v-1\neq 0\vee v-1=0 17: v>0v>0 \Rightarrow v10v1=0v-1\neq 0\vee v-1=0 6: v>0,x10x1=0v>0,x-1\neq 0\vee x-1=0 \Rightarrow σ4(v):trap(A;A)(pause;B)end𝑡𝑟𝑢𝑒\sigma_{4}(v):\langle\textit{trap}\ (A^{\prime}\ ;\ A)\parallel(\textit{pause}\ ;\ B)\ \textit{end}\rangle\mathit{true} 7: v>0,v10v>0,v-1\neq 0 \Rightarrow σ4(v):trap(A;A)(pause;B)end𝑡𝑟𝑢𝑒\sigma_{4}(v):\langle\textit{trap}\ (A^{\prime}\ ;\ A)\parallel(\textit{pause}\ ;\ B)\ \textit{end}\rangle\mathit{true} 12: v>0,v10v>0,v-1\neq 0 \Rightarrow σ4(v):trap(pause;A)(pause;B)end𝑡𝑟𝑢𝑒\sigma_{4}(v):\langle\textit{trap}\ (\textit{pause}\ ;\ A)\parallel(\textit{pause}\ ;\ B)\ \textit{end}\rangle\mathit{true} 13: v>0,v10v>0,v-1\neq 0 \Rightarrow σ5(v):trapABend𝑡𝑟𝑢𝑒\sigma_{5}(v):\langle\textit{trap}\ A\parallel B\ \textit{end}\rangle\mathit{true} 14: (v1)+1>0,v10(v-1)+1>0,v-1\neq 0 \Rightarrow σ5(v):trapABend𝑡𝑟𝑢𝑒\sigma_{5}(v):\langle\textit{trap}\ A\parallel B\ \textit{end}\rangle\mathit{true} 15: v+1>0,v0v+1>0,v\neq 0 \Rightarrow σ1(v):trapABend𝑡𝑟𝑢𝑒\sigma_{1}(v):\langle\textit{trap}\ A\parallel B\ \textit{end}\rangle\mathit{true} 16: v>0v>0 \Rightarrow σ1(v):trapABend𝑡𝑟𝑢𝑒\sigma_{1}(v):\langle\textit{trap}\ A\parallel B\ \textit{end}\rangle\mathit{true} 8: v>0,v1=0v>0,v-1=0 \Rightarrow σ4(v):trap(A;A)(pause;B)end𝑡𝑟𝑢𝑒\sigma_{4}(v):\langle\textit{trap}\ (A^{\prime}\ ;\ A)\parallel(\textit{pause}\ ;\ B)\ \textit{end}\rangle\mathit{true} 9: v>0,v1=0v>0,v-1=0 \Rightarrow σ5(v):𝑡𝑟𝑢𝑒\sigma_{5}(v):\langle\downarrow\rangle\mathit{true} 10: v>0,v1=0v>0,v-1=0 \Rightarrow σ5(v):𝑡𝑟𝑢𝑒\sigma_{5}(v):\mathit{true} 11: v>0,v1=0v>0,v-1=0 \Rightarrow 𝑡𝑟𝑢𝑒\mathit{true}

Table 10: Derivations of Property ν2\nu_{2}

The derivations of ν2\nu_{2} is depicted in Table 10. We omit the sub-proof-procedures of all program transitions when applying rule (α)(\langle\alpha\rangle), 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 (trap((x:=xS;A);A)(pause;B)end,σ3(v))(\textit{trap}\ ((x:=x-S\ ;A^{\prime})\ ;\ A)\parallel(\textit{pause}\ ;\ B)\ \textit{end},\sigma_{3}(v))\Downarrow, 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 xx decreases by 11 (by executing x:=xSx:=x-S) in each loop so that statement exit will finally be reached. From node 13 to 14 and node 15 to 16, rule

Γ,ϕΔ(LE)Γ,ϕΔ,if ϕϕ𝐅𝐨𝐫𝐦 is valid\begin{aligned} \Gamma,\phi\Rightarrow\Delta\Gamma,\phi^{\prime}\Rightarrow\Delta,\end{aligned}\ \ \mbox{if $\phi\to\phi^{\prime}\in\mathbf{Form}$ is valid}

is applied, which can be derived by the following derivations:

Γ,ϕΔ(WkL)Γ,ϕ,ϕΔ(Ter)Γ,ϕϕ,Δ(Cut)Γ,ϕΔ\displaystyle\Gamma,\phi\Rightarrow\Delta\lx@proof@logical@and\Gamma,\phi,\phi^{\prime}\Rightarrow\Delta\Gamma,\phi^{\prime}\Rightarrow\Delta\Gamma,\phi\Rightarrow\phi^{\prime},\Delta

From node 14 to 15, rule

ΓΔ(Sub)Γ[e/x]Δ[e/x]\displaystyle\Gamma[e/x]\Rightarrow\Delta[e/x]\Gamma\Rightarrow\Delta

is applied, whose substitution function is ()[e/x](\cdot)[e/x] as introduced in Section 2.2. Observe that sequent 14 can be written as:

(v+1>0)[v1/v],(v0)[v1/v](σ1(v):trapABend𝑡𝑟𝑢𝑒)[v1/v].(v+1>0)[v-1/v],(v\neq 0)[v-1/v]\Rightarrow(\sigma_{1}(v):\langle\textit{trap}\ A\parallel B\ \textit{end}\rangle\mathit{true})[v-1/v].

Sequent 16 is a bud with sequent 1 as its companion. The whole preproof is cyclic as the only derivation path: 1,2,3,4,6,7,12,13,14,15,16,1,1,2,3,4,6,7,12,13,14,15,16,1,... has a progressive trace whose elements are underlined in Table 10.