IIST and UNU - UNU-IIST - United Nations University
IIST and UNU - UNU-IIST - United Nations University
IIST and UNU - UNU-IIST - United Nations University
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>UNU</strong>/<strong>IIST</strong><br />
International Institute for<br />
Software Technology<br />
From Durational Specifications to TLA<br />
Designs of Timed Automata<br />
Yifeng Chen <strong>and</strong> Zhiming Liu<br />
<strong>UNU</strong>-<strong>IIST</strong> Report No. 301<br />
R
<strong>UNU</strong>-<strong>IIST</strong> <strong>and</strong> <strong>UNU</strong>-<strong>IIST</strong> Reports<br />
<strong>UNU</strong>-<strong>IIST</strong> (<strong>United</strong> <strong>Nations</strong> <strong>University</strong> International Institute for Software Technology) is a Research <strong>and</strong><br />
Training Centre of the <strong>United</strong> <strong>Nations</strong> <strong>University</strong> (<strong>UNU</strong>). It is based in Macau, <strong>and</strong> was founded in<br />
1991. It started operations in July 1992. <strong>UNU</strong>-<strong>IIST</strong> is jointly funded by the Governor of Macau <strong>and</strong><br />
the governments of the People’s Republic of China <strong>and</strong> Portugal through a contribution to the <strong>UNU</strong><br />
Endownment Fund. As well as providing two-thirds of the endownment fund, the Macau authorities also<br />
supply <strong>UNU</strong>-<strong>IIST</strong> with its office premises <strong>and</strong> furniture <strong>and</strong> subsidise fellow accommodation.<br />
The mission of <strong>UNU</strong>-<strong>IIST</strong> is to assist developing countries in the application <strong>and</strong> development of software<br />
technology.<br />
<strong>UNU</strong>-<strong>IIST</strong> contributes through its programmatic activities:<br />
1. Advanced development projects, in which software techniques supported by tools are applied,<br />
2. Research projects, in which new techniques for software development are investigated,<br />
3. Curriculum development projects, in which courses of software technology for universities in developing<br />
countries are developed,<br />
4. <strong>University</strong> development projects, which complement the curriculum development projects by aiming<br />
to strengthen all aspects of computer science teaching in universities in developing countries,<br />
5. Schools <strong>and</strong> Courses, which typically teach advanced software development techniques,<br />
6. Events, in which conferences <strong>and</strong> workshops are organised or supported by <strong>UNU</strong>-<strong>IIST</strong>, <strong>and</strong><br />
7. Dissemination, in which <strong>UNU</strong>-<strong>IIST</strong> regularly distributes to developing countries information on<br />
international progress of software technology.<br />
Fellows, who are young scientists <strong>and</strong> engineers from developing countries, are invited to actively participate<br />
in all these projects. By doing the projects they are trained.<br />
At present, the technical focus of <strong>UNU</strong>-<strong>IIST</strong> is on formal methods for software development. <strong>UNU</strong>-<strong>IIST</strong><br />
is an internationally recognised center in the area of formal methods. However, no software technique is<br />
universally applicable. We are prepared to choose complementary techniques for our projects, if necessary.<br />
<strong>UNU</strong>-<strong>IIST</strong> produces a report series. Reports are either Research R , Technical T , Compendia C or<br />
Administrative A . They are records of <strong>UNU</strong>-<strong>IIST</strong> activities <strong>and</strong> research <strong>and</strong> development achievements.<br />
Many of the reports are also published in conference proceedings <strong>and</strong> journals.<br />
Please write to <strong>UNU</strong>-<strong>IIST</strong> at P.O. Box 3058, Macau or visit <strong>UNU</strong>-<strong>IIST</strong>’s home page: http://www.iist.unu.edu,<br />
if you would like to know more about <strong>UNU</strong>-<strong>IIST</strong> <strong>and</strong> its report series.<br />
Chris George, Acting Director
<strong>UNU</strong>/<strong>IIST</strong><br />
International Institute for<br />
Software Technology<br />
P.O. Box 3058<br />
Macau<br />
From Durational Specifications to TLA<br />
Designs of Timed Automata<br />
Yifeng Chen <strong>and</strong> Zhiming Liu<br />
Abstract<br />
Different temporal logics tend to emphasise different aspects of a hybrid system. In this paper,<br />
we study the predicative interpretation of Duration Calculus (DC) <strong>and</strong> Temporal Logic<br />
of Actions (TLA) <strong>and</strong> the link between them. A notation called generic composition is used<br />
to simplify the manipulation of predicates. The modalities of possibility <strong>and</strong> necessity become<br />
generic composition <strong>and</strong> its inverse of converse respectively. The transformation between different<br />
temporal logics is also characterised as such modalities. The formalism provides a framework<br />
in which human experience about hybrid system development can be formalised as refinement<br />
laws. A high-level durational specification can be decomposed to two durational specifications<br />
driven by an automaton. In such a stepwise design process, durational features are reduced<br />
while automaton features increase gradually. The application of the technique is demonstrated<br />
in the case study of the gas burner problem.
Yifeng Chen is a lecturer of the Department of computer Science at the <strong>University</strong> of Leicester.<br />
His research interest includes logics of computer science, programming <strong>and</strong> specification<br />
language designs, <strong>and</strong> formal specification. E-mail: Y.Chen@cs.le.ac.uk<br />
Zhiming Liu is a research fellow at <strong>UNU</strong>/<strong>IIST</strong>, on leave from Department of Computer Science<br />
at the <strong>University</strong> of Liecester, Liecester, Engl<strong>and</strong> where he is a lecturer in computer science.<br />
His research interests include theory of computing systems, including sound methods for specification,<br />
verification <strong>and</strong> refinement of fault-tolerant, real-time <strong>and</strong> concurrent systems, <strong>and</strong><br />
formal techniques for OO development. His teaching interests are Communication <strong>and</strong> Concurrency,<br />
Concurrent <strong>and</strong> Distributed Programming, Internet Security, Software Engineering,<br />
Formal specification <strong>and</strong> Design of Computer Systems. E-mail: Z.Liu@iis.unu.edu.<br />
Copyright c○ 2004 by <strong>UNU</strong>-<strong>IIST</strong>, Yifeng Chen <strong>and</strong> Zhiming Liu
Contents<br />
i<br />
Contents<br />
1 Introduction 1<br />
2 Predicative semantics of modal logics 2<br />
3 Temporal logic of resource cumulation 6<br />
4 Linking Duration Calculus <strong>and</strong> TLA 10<br />
5 Case study: the Gas Burner 16<br />
6 Conclusions 18<br />
Report No. 301,<br />
<strong>UNU</strong>-<strong>IIST</strong>, P.O. Box 3058, Macau
Introduction 1<br />
1 Introduction<br />
An embedding system consists of both continuous components that observe continuous physical<br />
laws <strong>and</strong> discrete components that execute digital instructions. Hybrid systems inevitably<br />
involve time as an observable <strong>and</strong> can be naturally specified using temporal logics. Different temporal<br />
logics tend to emphasise different aspects of an embedding system. For example, interval<br />
logics such as Duration Calculus (DC) [17], emphasising properties over intervals, are more suitable<br />
for describing high-level continuous properties <strong>and</strong> hence closer to the continuous aspects<br />
of embedding systems. On the other h<strong>and</strong>, Linear Temporal Logics (LTL) [11], emphasising<br />
the properties of states at discrete time points, are more suitable for modelling discrete aspects<br />
of embedding systems <strong>and</strong> can be easily verified as a timed automaton [12]. A straightforward<br />
specification in one logic may become less intuitive in another logic. In the past, all aspects of<br />
an embedding system are normally specified in one logic [8, 18]. Traditional method of combining<br />
logics is to collect syntactical constructs together <strong>and</strong> identify the axioms of the system.<br />
This usually results in a complicated axiomatic system difficult to h<strong>and</strong>le. For example, the<br />
design of an embedding system may involve an abstract specification of the requirements in DC<br />
<strong>and</strong> a concrete LTL specification that describes the behaviour of the system of implementation.<br />
Existing development techniques do not support such refinement. A more natural approach is<br />
to unify the different logics at a common semantic level.<br />
Predicative interpretation is a st<strong>and</strong>ard technique in modal logic [1, 15]. A proposition with<br />
modal operators can be interpreted as a predicate. The modality of possibility (or necessity)<br />
is represented as an existential (or universal) quantifier. Predicates are also used in semantic<br />
modelling of programming languages. This approach is often known as predicative semantics [5,<br />
7].<br />
We use a notation called generic composition [2] to simplify the manipulation of predicates. A<br />
generic composition is a relational composition with a designated interface consisting of several<br />
logical variables. Generic composition has an inverse operator. With the help of the two operators,<br />
we no longer need the existential <strong>and</strong> universal quantifiers. The modality of possibility<br />
then becomes a generic composition, while the modality of necessity becomes its inverse of converse<br />
[4]. Temporal logics have been characterised algebraically using Galois connections [16].<br />
In our approach, the accessibility relation of modal logics is directly parameterised. The link<br />
between two specifications in different temporal logics is characterised as a pointwise relation<br />
between the possible observations of the specifications. Such a pointwise relation also determines<br />
a pair of modalities <strong>and</strong> can be defined with a generic composition <strong>and</strong> its inverse.<br />
For unification, we model different temporal domains such as real time, traces, timed traces,<br />
forests (for branching time) <strong>and</strong> intervals under a notion called resource cumulator [3]. A cumulator<br />
is a quintuple compromising a monoid, a corresponding partial order <strong>and</strong> a volume function<br />
that measures the amount of resources. A cumulator provides the “type” for a logical variable<br />
of a particular temporal domain. The integration of different temporal logics will not be useful<br />
unless we provide the knowledge about how specifications in one logic can be approximated or<br />
refined by specifications in another logic. Such knowledge can be formalised as the refinement<br />
Report No. 301,<br />
<strong>UNU</strong>-<strong>IIST</strong>, P.O. Box 3058, Macau
Predicative semantics of modal logics 2<br />
laws of modalities. Identifying these laws can make the design process more systematic.<br />
In this paper, we will demonstrate this by studying the refinement from DC specifications to<br />
TLA implementations. An automaton with two states can be readily specified in TLA. A highlevel<br />
durational specification can be decomposed to two durational specifications “driven” by<br />
an automaton. Such decomposition can be repeated several times <strong>and</strong> create a hierarchical<br />
structure of two-state automata. The rest of the design is to combine the automata in a single<br />
flat one. The advantage of this approach is that implemental features are introduced step by<br />
step gradually. This allows each development step to preserve more nondeterminism from the<br />
original specification <strong>and</strong> thus keep more flexibility in the following design steps.<br />
In previous works, Schenke <strong>and</strong> Olderog [14] studied the direct refinement transformation from<br />
DC to a language similar to CSP [6]. Since the gap between DC <strong>and</strong> TLA specifications is<br />
smaller than that between DC <strong>and</strong> a real programming language, our approach yields stronger<br />
algebraic properties. The result TLA implementations can be verified with model-checking tools.<br />
Section 2 studies the predicative semantics of modal logic using the notation of generic composition<br />
<strong>and</strong> its inverse. Section 3 unifies different temporal domains under the notion of resource<br />
cumulator <strong>and</strong> defines the predicative semantics of temporal logic in general <strong>and</strong> discusses several<br />
temporal logics including DC <strong>and</strong> TLA. The relationship between DC <strong>and</strong> TLA is studied<br />
in Section 4. The refinement laws identified in Section 4 are then applied to the case study in<br />
Section 5.<br />
2 Predicative semantics of modal logics<br />
Manipulating predicates<br />
We assume that there are two types of logical variables: non-overlined variables such as x, y, z, · · ·<br />
<strong>and</strong> overlined variables such as x, y, z, · · · . Overlining is only used to associate corresponding<br />
logical variables syntactically. We use a notation called generic composition [2] to manipulate<br />
predicates. A generic composition is a relational composition with a designated interface of<br />
non-overlined variables.<br />
Def 1 P : x R ̂= ∃x 0 · P [x 0 /x] ∧ R[x 0 /x] .<br />
A ‘fresh’ variable x 0 is used to connect x of P <strong>and</strong> x of R <strong>and</strong> hidden by the existential<br />
quantifier. Generic composition is a restricted form of relational composition. It relates two<br />
predicates on only some of their logical variables. For example, the following composition relates<br />
two predicates on only x (<strong>and</strong> x ):<br />
(x = 10 ∧ y = 20) : x (x x ∧ z = 30) = (10 x ∧ y = 20 ∧ z = 30).<br />
Report No. 301,<br />
<strong>UNU</strong>-<strong>IIST</strong>, P.O. Box 3058, Macau
Predicative semantics of modal logics 3<br />
The existential quantifier ∃x· P is simply represented as P : x true , <strong>and</strong> variable substitution<br />
P [e/x] as P : x (x = e) . An interface x may split into several variables, e.g. (y, z) . For example,<br />
the generic composition P : (y, z) true is the same as the predicate ∃y∃z · P . If the vector is<br />
empty, a generic composition becomes a conjunction: P : R = P ∧ R .<br />
Generic composition has an inverse operator denoted by P / x R, which is the weakest predicate<br />
X such that (X : x R) ⊆ P . It can be defined by a Galois connection:<br />
Def 2 X ⊆ P / x R iff X : x R ⊆ P for any predicate X .<br />
Generic composition <strong>and</strong> its inverse satisfy a property:<br />
P / x R = ¬ (¬ P : x ˜R) = ∀x0 · (R[x 0 /x, x/x] ⇒ P [x 0 /x])<br />
where ˜R ̂= R[x/x, x/x] is the converse of R for the variable x . Universal quantifier ∀x· P<br />
can then be written as P / x true . Negation ¬ P becomes false / P whose interface is empty.<br />
Implication P ⇒ Q becomes Q / P with an empty interface. Disjunction P ∨ Q is a trivial<br />
combination of negation <strong>and</strong> implication. Thus all connectives, substitution <strong>and</strong> quantifiers<br />
become special cases of generic composition <strong>and</strong> its inverse [2].<br />
Theorem 1 Generic composition <strong>and</strong> its inverse are complete in the sense that any predicate<br />
that does not contain overlined free variables can be written in terms of generic composition <strong>and</strong><br />
its inverse using only the constant predicates <strong>and</strong> predicate letters.<br />
The theorem shows the expressiveness of generic composition for predicate manipulation. Generic<br />
composition <strong>and</strong> its inverse form a Galois connection <strong>and</strong> satisfy the algebraic laws of strictness,<br />
distributivity <strong>and</strong> associativity.<br />
Law 1<br />
(1) A ⊆ (A : x R) / x R<br />
(3) false : x R = false<br />
(5) A : x (R ∨ S) = (A : x R) ∨ (A : x S)<br />
(7) A / x (R ∨ S) = (A / x R) ∧ (A / x S)<br />
(9) (A : x R) : x S = A : x (R : x S)<br />
(2) (A / x R) : x R ⊆ A<br />
(4) true / x R = true<br />
(6) (A ∨ B) : x R = (A : x R) ∨ (A : x R)<br />
(8) (A ∧ B) / x R = (A / x R) ∧ (A / x R)<br />
(10) (A / x R) / x S = A / x (S : x R) .<br />
The notation is especially useful when the interfaces of the operators in a predicate are not<br />
identical. For example, in the following law we assume that x , y <strong>and</strong> z are three different<br />
logical variables, A = ∃z · A (independence of the variable z ) <strong>and</strong> C = ∃y · C (independence of<br />
the variable y ).<br />
Report No. 301,<br />
<strong>UNU</strong>-<strong>IIST</strong>, P.O. Box 3058, Macau
Predicative semantics of modal logics 4<br />
Law 2<br />
(A : (y,x) B) : (x,z) C = A : (y,x) (B : (x,z) C).<br />
Generic composition <strong>and</strong> its inverse can be used to define modalities. These properties make<br />
the composition a useful technical tool for linking temporal logics. Generic composition has also<br />
been applied to define a variety of healthiness conditions <strong>and</strong> parallel compositions. The above<br />
laws <strong>and</strong> a series of other laws can be found in [2].<br />
Interpreting modalities<br />
Under Kripke semantics [1], modal logics are logical systems of relations (called “accessibility<br />
relations”). Here, we represent a specification as a predicate on a modal variable (e.g. x) <strong>and</strong><br />
an auxiliary variable (e.g. y). The modal variable records the observable aspect related to the<br />
accessibility of the modalities, while the auxiliary variable records the unrelated observable<br />
aspect. For now, the variables are left untyped. These logical variables will later be typed<br />
in temporal logics. A logical variable may split into several ones, <strong>and</strong> its type becomes the<br />
product of several types. The semantic space is the set of all such specifications (e.g. denoted<br />
by A ). An accessibility relation R = R(x, x) is denoted by a predicate on two variables: the<br />
modal variable x <strong>and</strong> the overlined modal variable x . Overlined variables only appear in the<br />
accessibility relations. Each accessibility relation determines a pair of modalities.<br />
Def 3 ♦ A P ̂= P : x ˜R <strong>and</strong> A P ̂= P / x R .<br />
The operator ♦ A P informally means that “the predicate P may be true” <strong>and</strong> is defined as a<br />
generic composition of the specification P <strong>and</strong> the converse relation ˜R ; its dual modality A P<br />
informally means that “the predicate P must be true” is defined with an inverse operator.<br />
If we replace the accessibility relation with its converse, we will obtain a pair of converse modalities.<br />
Def 4 ˜♦A P ̂= P : x R <strong>and</strong> ˜ A P ̂= P / x ˜R .<br />
Generic composition <strong>and</strong> its inverse can be regarded as parameterised modal operators. They<br />
have a designated interface <strong>and</strong> are more convenient than traditional relational composition in<br />
this context for two reasons. Firstly, the abservable aspects (described by the auxiliary variable)<br />
unrelated to the accessibility relation can be excluded from the interface of the relational composition.<br />
Secondly, the predicate on the left-h<strong>and</strong> side of a generic composition (or its inverse) can<br />
be either a specification (without overlined variables) or an accessibility relation (with overlined<br />
variables). Thus the operators can be directly used to represent the composition of accessibility<br />
relations (i.e. the composition of modalities).<br />
Report No. 301,<br />
<strong>UNU</strong>-<strong>IIST</strong>, P.O. Box 3058, Macau
Predicative semantics of modal logics 5<br />
The converse/inverse relationships between these modalities are illustrated in a diagram (see<br />
Figure 1). The four modalities form two Galois connections.<br />
A P<br />
Converse<br />
˜A P<br />
Inverse<br />
Inverse<br />
˜ A P<br />
Converse<br />
A P<br />
Figure 1: Diagram of converse/inverse relationships<br />
Law 3 ♦ A P ⊆ Q iff P ⊆ ˜ A Q for any P ∈ A <strong>and</strong> Q ∈ B<br />
˜♦ A P ⊆ Q iff P ⊆ A Q for any P ∈ A <strong>and</strong> Q ∈ B .<br />
Transformer modalities<br />
The transformation between two temporal logics also becomes modalities. Let A (or B ) be a<br />
semantic space of specifications, each of which is a predicate on modal variable x (or x ′ ) <strong>and</strong><br />
auxiliary variable y (or y ′ ). The transformation from A to B is characterised as a transformation<br />
predicate T = T (x, y, x ′ , y ′ ) on four variables. The predicate determines a transformer<br />
modality ♦ A→B from A to B <strong>and</strong> a corresponding inverse transformer B→A from B to A .<br />
In the following definition, we assume that P = P (x, y) <strong>and</strong> Q = Q(x ′ , y ′ ) .<br />
Def 5 ♦ A→B P ̂= P : (x,y) T<br />
B→A Q ̂= Q / (x ′ ,y ′ ) T .<br />
Note that ♦ A→B <strong>and</strong> B→A form just one pair of transformers based on the predicate T .<br />
Other transformers between the two logics can be denoted as ♦ A→ ′ B <strong>and</strong> ♦ A→ ′′ B etc. Let<br />
♦ A→B <strong>and</strong> ♦ B→C be two transformers. Their composition ♦ A→B ♦ B→C is also a transformer<br />
(from A to C ), so is the composition of their inverses.<br />
If the modal variable <strong>and</strong> the auxiliary variable are untyped, the above predicative semantics is<br />
contained in predicate calculus <strong>and</strong> hence complete. A well-formed formula is always true if <strong>and</strong><br />
only if it can be proved using the laws of generic composition <strong>and</strong> its inverse (or equivalently,<br />
the axioms of predicate calculus).<br />
Report No. 301,<br />
<strong>UNU</strong>-<strong>IIST</strong>, P.O. Box 3058, Macau
Temporal logic of resource cumulation 6<br />
3 Temporal logic of resource cumulation<br />
Resource cumulation<br />
Many aspects of computing can be modelled as the cumulation of resources. In real-time computing,<br />
time is a kind of resource. A process “consumes” a non-negative amount of time. A<br />
computation may also produce resources. For example, a reactive process generates an increasingly<br />
longer sequence of intermediate states called a trace. Resource cumulation can be<br />
formalized as a quintuple called a cumulator: (X, ; 0, ⌢ ; | · |) , which consists of three<br />
parts: a well-founded partial order (X, ) in which each element is called a cumulation <strong>and</strong><br />
the greatest lower bound exists for any non-empty subset, a monoid (0, ⌢ ) in which 0 , or<br />
zero cumulation is the least cumulation, <strong>and</strong> a monotonic <strong>and</strong> associative binary operation concatenation<br />
⌢ corresponds to the addition of cumulations, <strong>and</strong> a monotonic <strong>and</strong> strict volume<br />
function | · | : X → [0, ∞] : We assume that the partial order <strong>and</strong> the monoid are consistent:<br />
a b ⇔ ∃c∈X · a ⌢ c = b . The unusual part of a cumulator is the volume function. A volume<br />
function measures the amount of resource cumulated. With such additional information we can<br />
then reason about the dynamics of resource cumulation. For example, a resource is exhausted<br />
when its volume reaches infinity ∞ . The use of volume functions can substantially simplify the<br />
reasoning of limit points, continuity, <strong>and</strong> other topological properties. Such modelling is aimed<br />
at avoiding complicated domain construction <strong>and</strong> has reflected our pragmatic view on resources.<br />
For a more complete account of resource cumulation, please refer to [3].<br />
Example: The amount of time that a computation consumes can be modelled as a cumulator:<br />
RTime ̂= ([0, ∞], ; 0, + ; id) where + is addition. id is the identity function.<br />
Example: In some applications, we are interested in temporal properties over a period of time<br />
<strong>and</strong> thus need to reason about temporal intervals. Intervals form a cumulator Interval ̂= (I, <br />
; ∅, ⌢ ; | · |) where I denotes the set of intervals, each of which is a convex subset i of the<br />
real domain [0, ∞] (such that for any t 1 , t 2 ∈ i <strong>and</strong> t 3 ∈ T , t 1 t 3 t 2 implies t 3 ∈ i ). For<br />
example, [1, 2] , [1, 2) , (1, 2] , (1, 2) <strong>and</strong> the empty set ∅ are intervals. Let I denote the set of<br />
all intervals. a ⌢ b ̂= a ∪ b if a ∩ b = ∅ , ⊔a = ⊓b <strong>and</strong> a ∪ b ∈ I . The volume of a non-empty<br />
interval is its length: |a| ̂= ⊔a − ⊓a where ⊔a <strong>and</strong> ⊓a denote the lub <strong>and</strong> glb of the interval<br />
a respectively. The volume of the empty set is zero |∅| = 0 . The orders a b means that b is<br />
a right-h<strong>and</strong> extension of a , i.e. ∃c ∈ I · a ⌢ c = b .<br />
Example: Finite <strong>and</strong> infinite traces form a typical cumulator: Trace(X) ̂= (X † , ; 〈〉, ∧ ; |·<br />
|) where X is the type of each element, <strong>and</strong> X † the set of all sequences of elements (including<br />
the infinite ones). For two sequences a, b ∈ X † , a ∧ b denotes their concatenation. If a is an<br />
infinite sequence, then for any b, a ∧ b = a . a b iff a is a prefix (i.e. pre-cumulation) of b . |a|<br />
denotes the length of a . For exampe, the length of the empty sequence 〈〉 is 0. a i denotes the<br />
i -th element of the sequence where 1 i |a| .<br />
Report No. 301,<br />
<strong>UNU</strong>-<strong>IIST</strong>, P.O. Box 3058, Macau
Temporal logic of resource cumulation 7<br />
Example: A timed trace is a trace with non-decreasing time stamps. The sequence 〈(1, p), (2, q), (4, p)〉<br />
is one example. In general, a timed trace is a trace of pairs in the form 〈(t 1 , s 1 ), (t 2 , s 2 ), · · · , (t n , s n ), · · ·〉 .<br />
Timed traces form a cumulator: TimedTrace(X) ̂= (T (X), ; 〈〉, ∧ ; | · |) where<br />
T (X) ̂=<br />
{<br />
}<br />
tr ∈ ([0, ∞] × X) † | ∀i, j < |tr|· (i j ⇒ t i t j ) .<br />
Temporal logic of resource cumulation<br />
Temporal logic of resource cumulation is a modal logic. Let (X, ; 0, ⌢ ; | · |) be a cumulator.<br />
A general cumulative specification is a predicate on a modal variable x ∈ X whose type is a<br />
cumulator <strong>and</strong> an untyped auxiliary variable y . We let R denote the semantic space of such<br />
specifications. The general cumulator gives rise to a number of accessibility relations, each of<br />
which determines two pairs of modalities. A common accessibility relation corresponds to the<br />
left-h<strong>and</strong> contractions: R ̂= ∃z ∈ X · (x = z ⌢ x) .<br />
The modality ♦ R P informally means that “the predicate P becomes true after some precumulation<br />
of resources”. More precisely, the behaviours of ♦ R P are the behaviours of P<br />
extended with arbitrary cumulations on the left-h<strong>and</strong> side. The modality R P , instead, means<br />
that “the predicate P is true for any left-h<strong>and</strong> extensions of the behaviours of P . The pair of<br />
converse modalities ˜♦ R P <strong>and</strong> ˜ R P are actually the corresponding “past-tense” modalities.<br />
All properties of general modalities are inherited.<br />
There exists a dual accessibility relation for right-h<strong>and</strong> contractions:<br />
R ′ ̂= ∃z ∈ X · (x = x ⌢ z) . Again, it determines two pairs of modalities ♦ R ′ P , R ′P , ˜♦R ′ P<br />
<strong>and</strong> ˜ R ′ P . The modalities of left-h<strong>and</strong> <strong>and</strong> right-h<strong>and</strong> extensions/contractions commute with<br />
each other respectively. Their respective compositions (e.g. ♦ R ♦ R ′ P ) becomes a bi-directional<br />
contractions/extensions.<br />
The most commonly used temporal operator ♦ P in LTL means that “the predicate P eventually<br />
becomes true in finite steps”. Its dual operator P means that “the predicate P is always true<br />
after finite steps”. They correspond to ♦ |L|
Temporal logic of resource cumulation 8<br />
Examples of temporal logics<br />
The amount of time that a computation consumes corresponds to the cumulator RTime. A<br />
real-time specification is a predicate on a typed modal variable t ∈ [0, ∞] that denotes time <strong>and</strong><br />
an untyped auxiliary variable s that denotes the system’s state at the time. We let T denote<br />
the space of such specifications. Since addition is commutative i.e. a + b = b + a, it makes no<br />
difference whether time is extended from the left-h<strong>and</strong> side or the right-h<strong>and</strong> side. For example,<br />
e t = x described a system’s temporature growing exponentially over time.<br />
Intervals within a time domain form the cumulator Interval . A specification on intervals is<br />
a predicate on a variable i ∈ I that denotes the interval <strong>and</strong> an auxiliary variable x that denotes<br />
some system feature related to the interval. We let I denote the space of all temporal<br />
specifications on intervals. An interval can be extended from either left-h<strong>and</strong> side or right-h<strong>and</strong><br />
side.<br />
Traces of elements of X form a cumulator Trace(X) . A trace specification is a predicate on<br />
a single variable tr ∈ X † . We let S denote the space of trace specifications. For example, the<br />
specification |S|
Temporal logic of resource cumulation 9<br />
another state satisfying ¬p in some time t ∈ U <strong>and</strong> then moves back to a state satisfying p in<br />
some time t ∈ V where U, V ⊆ [0, ∞] . The two-state automaton can be formalised as follows:<br />
(2)<br />
Automaton(p, U, V ) ̂=<br />
K [(p(s) ∧ ¬p(s ′ ) ∧ t ′ −t ∈ U) ∨ (¬p(s) ∧ p(s ′ ) ∧ t ′ −t ∈ V )] (s,t) .<br />
Figure 2: Automaton with two states<br />
Duration calculus (DC) is a special interval logic. A durational specification is a predicate on a<br />
variable i ∈ I that denotes the interval <strong>and</strong> an auxiliary variable x : [0, ∞] → S that denotes a<br />
real-time Boolean function. We use a boolean function p : S → {0, 1} to denote whether a state<br />
x(t) at the time t satisfies the predicate p(·) . The space of durational specifications is denoted<br />
by D.<br />
Again, we may introduce some dependent variables. For example, instead of specifying the<br />
relation (i.e. a predicate) between the interval <strong>and</strong> the real-time function, we may specify the<br />
relation between the length of the interval <strong>and</strong> the integral of the real function in the interval.<br />
Although not all computation can be specified in such a restricted way, it has been expressive<br />
enough for most applications <strong>and</strong> covers most common design patterns [13]. The following table<br />
lists the primitives of DC:<br />
P (l, ∫ p) general pattern<br />
⌈p⌉ lift<br />
D P modality of sub-interval closure<br />
P Q chop operation<br />
P ∨ Q logical disjunction<br />
¬P negation<br />
For example, the Gas Burner problem [13] includes a requirement that gas leak is bounded by<br />
4 for any interval no longer than 30. This can be formalised as a specification in DC:<br />
(3)<br />
D (|i| 30 ⇒ ∫ i<br />
Leak(x(t)) dt 4)<br />
Report No. 301,<br />
<strong>UNU</strong>-<strong>IIST</strong>, P.O. Box 3058, Macau
Linking Duration Calculus <strong>and</strong> TLA 10<br />
where Leak is a predicate denoting whether there is leaking in a state. For simplicity, we rewrite<br />
the specification using st<strong>and</strong>ard abbreviations:<br />
D (l 30 ⇒ ∫ Leak 4)<br />
where l ̂= |i| <strong>and</strong> ∫ Leak ̂= ∫ i<br />
Leak(x(t)) dt .<br />
The following two concrete DC specifications form a common design implementing the above<br />
abstract specification:<br />
(4)<br />
D (⌈Leak⌉⇒ |i| 4) <strong>and</strong> D (⌈Leak⌉ ⌈¬Leak⌉ ⌈Leak⌉ ⇒ |i| 26)<br />
where the real-time function x(t) records the state at the time point t , the specification<br />
⌈Leak⌉ ̂= ( ∫ Leak = l) describes a period with gas leak (at “most” time points of in the period<br />
[17]), <strong>and</strong> ⌈¬Leak⌉ ̂= ( ∫ Leak = l) describes a period almost without leak. The first<br />
specification requires any leaking period to be bounded by 4 seconds; the second specification<br />
states that, during any interval, the period of non-leak between two periods of leak should be<br />
no less than 26 seconds. The sequential composition (also known as the chop operation) is<br />
the pointwise concatenation of the intervals of specifications:<br />
P Q ̂= ∃i 1 i 2 · (P [i 1 /i] ∧ Q[i 2 /i] ∧ i = i ⌢ 1 i 2) .<br />
The similarity between the TLA specification (1) <strong>and</strong> the DC design (4) is obvious. They<br />
essentially describe the same controlling strategy. Their link will be captured by a transformer<br />
between the two logics.<br />
4 Linking Duration Calculus <strong>and</strong> TLA<br />
The transformer from TLA to DC<br />
We now study a technique to link DC specifications with TLA designs. Indeed each timed trace<br />
of 0s <strong>and</strong> 1s determines some real-time Boolean function in [0, ∞] → {0, 1} . For example, the<br />
timed trace 〈(1.0, 0), (2.0, 1), (4.0, 0)〉 corresponds to a Boolean real-time function whose value<br />
is 0 from time 1.0 to time 2.0 when the value becomes 1 until time 4.0 . The state between<br />
any two consecutive time points is constant. For example, the DC abstract specification (3) can<br />
be implemented with a TLA specification of timed traces (1). The TLA design is arguably more<br />
intuitive than (3) in DC alone. Such interpretation of a timed trace also directly corresponds to<br />
a timed automaton.<br />
Report No. 301,<br />
<strong>UNU</strong>-<strong>IIST</strong>, P.O. Box 3058, Macau
Linking Duration Calculus <strong>and</strong> TLA 11<br />
The link between timed-trace TLA <strong>and</strong> durational calculus can be characterised as a predicate<br />
of weak inverse on timed trace tr , interval i <strong>and</strong> real-time function x(l) :<br />
T (tr, i, x) ̂= ∧ k (l= ∫ (x= s k ) / i (i ⊆ [t k , t k+1 ] ∩ i)).<br />
Each timed trace determines a real-time function whose value may only change at the time<br />
points of the trace. The value between two consecutive time points is “stable” in the sense that<br />
the values at “most” time point (except for isolated ones not affecting the integral) during the<br />
period are the same. The transformer requires that in any sub-interval segment of the timed<br />
trace, the real-time function x matches the stable states generated by the timed trace.<br />
A timed trace may contain arbitrarily-many consecutive state transitions at a single time point.<br />
Since the above transformer allows nondeterminism at isolated time points, such zero-time transitions<br />
cause no difficulty.<br />
Def 6 ♦ K→D P ̂= P : tr T <strong>and</strong> D→K P ̂= P / tr T .<br />
It is easy to show that any DC specification transformed from a TLA specification is always<br />
sub-interval closed.<br />
Law 4 D ♦ K→D P = ♦ K→D P .<br />
An automaton can be easily specified using a TLA formula (2). We introduce a notation for<br />
DC-specified automata in which U, V ⊆ [0, ∞] are two closed non-empty sets of time points<br />
such that the lub <strong>and</strong> glb of any of their non-empty subsets are contained in them. For example,<br />
they can be closed intervals like [0, 1] .<br />
Def 7 〈 U ↑ p ↓ V 〉 ̂= ♦ K→D Automaton(p, U, V ).<br />
An automaton is symmetric <strong>and</strong> monotonic in the sense that reducing the range of timing<br />
restrictions leads to the reduction of nondeterminism.<br />
Law 5 (1) 〈 U ↑ p ↓ V 〉 = 〈 V ↑ ¬p ↓ U 〉<br />
(2) 〈 U ↑ p ↓ V 〉 ⊇ 〈 U ′ ↑ p ↓ V ′ 〉 (U ⊇ U ′ , V ⊇ V ′ ).<br />
We use ∞ to denote the singleton range [∞, ∞] . Lift <strong>and</strong> chop operators can then be expressed<br />
with special automata. Note that the chop operation implies a certain synchronisation between<br />
the system <strong>and</strong> the observer: the chopping point must always fall in the interval of observation.<br />
This is achieved by eliminating the possibility that the chopping point falls out of the observation<br />
interval.<br />
Report No. 301,<br />
<strong>UNU</strong>-<strong>IIST</strong>, P.O. Box 3058, Macau
Linking Duration Calculus <strong>and</strong> TLA 12<br />
Law 6 (1) ⌈p⌉ = 〈 ∞ ↑ p ↓ [0, 0] 〉<br />
(2) 〈 ∞ ↑ p ↓ ∞ 〉 = ⌈p⌉ ∨ ⌈¬p⌉<br />
(3) ⌈p⌉ ⌈¬p⌉ = 〈 [0, ∞] ↑ p ↓ ∞ 〉 ∧ ¬〈 ∞ ↑ p ↓ ∞ 〉 .<br />
We use an abbreviation P ⊳ p ⊲ Q of choice to denote that two durational specifications P <strong>and</strong><br />
Q are controlled by a boolean p : during any interval in which p is always true, P must hold;<br />
during any interval in which ¬p is always true, Q must hold. There is no restriction for those<br />
intervals in which p is sometimes true <strong>and</strong> sometimes not true.<br />
Def 8 P ⊳ p ⊲ Q ̂= ⌈p⌉ ⇒ P ∧ ⌈¬p⌉ ⇒ Q .<br />
The following law shows that the chop composition of any two durational specifications can<br />
be implemented as a choice between the specifications, <strong>and</strong> the change of the choice is made<br />
sometime during an interval. If p is independent of P <strong>and</strong> Q <strong>and</strong> becomes hidden, the two<br />
sides will be equal.<br />
Law 7 P Q ⊇ P ⊳ p ⊲ Q ∧ 〈 [0, ∞] ↑ p ↓ ∞ 〉 ∧ ¬〈 ∞ ↑ p ↓ ∞ 〉.<br />
General patterns of specifications <strong>and</strong> their refinement<br />
A durational specification is a predicate P (i, x) on the interval i <strong>and</strong> the real-time function<br />
x : [0, ∞] → S . A common durational specification is a predicate P (l, ∫ p) on the length l ̂= |i|<br />
of the interval <strong>and</strong> the integral of a boolean function p during the interval. This reflects the fact<br />
that the controlling of a system is normally independent of the starting time <strong>and</strong> insensitive to<br />
state changes at isolated time points.<br />
A durational specification D<br />
∫<br />
p f(l) requires the total time of the state satisfying p in<br />
any interval with length l to be bounded by a characteristic function f(l). For example, the<br />
specification D (l 30 ⇒ ∫ leak 4) is a special case of this pattern with the characteristic<br />
function f(l) ̂= 4 ⊳ l ∈ [4, 30] ⊲ l where we use a ⊳ b ⊲ c to denote the value a if b is true, or<br />
the value c otherwise. The dual pattern D<br />
∫<br />
p g(l) is equal to D<br />
∫<br />
¬p (l−f(l)).<br />
The following law shows that two specifications with different characteristic functions may describe<br />
the same requirement.<br />
Law 8 D<br />
∫<br />
p f(l) = D<br />
∫<br />
p f ′ (l) , if any of the following condition is satisfied ( l, l 0 , l 1 0 ):<br />
1. f ′ (l) = min(l, f(l)) ,<br />
2. f ′ (l) = min {f(l ′ ) | l ′ l} ,<br />
3. or f ′ (l) = min {f(l 0 ) + f(l 1 ) | l 0 + l 1 = l} .<br />
Report No. 301,<br />
<strong>UNU</strong>-<strong>IIST</strong>, P.O. Box 3058, Macau
Linking Duration Calculus <strong>and</strong> TLA 13<br />
Refinement of general patterns<br />
The durational specification 〈 U ↑ p ↓ V 〉 describes an automaton with two composite states<br />
satisfying p <strong>and</strong> ¬p , respectively. A common durational specification may be implemented with<br />
an automaton, if the timed transitions are determined properly. For example, the durational<br />
specification of gas burner[13] can be implemented as follows:<br />
D (l 30 ⇒ ∫ leak 4) ⊇ 〈 [0, 4] ↑ leak ↓ [26, ∞] 〉.<br />
In each cycle of the automaton, the designed system must stay in a state satisfying p in no<br />
more than 4 seconds <strong>and</strong> then must stay in a state satisfying ¬p in no less than 26 seconds.<br />
Note that the above implementation is not unique. We may easily replace it with an automaton<br />
〈 [0, 2] ↑ leak ↓ [13, ∞] 〉 twice as fast.<br />
The fact that general durational specifications may have different implementations reveals the<br />
considerable gap between DC <strong>and</strong> TLA. The former is more suitable for higher-level specification<br />
on continuous properties expressible with integrals, while the latter naturally describes the<br />
properties of automata. Not every non-zero durational specification can be implemented as a<br />
non-trivial automaton. For example, the specification D<br />
∫<br />
p = l/2 describes a system whose<br />
density of states satisfying p is 0.5 everywhere. However, it can not be implemented with any<br />
automaton as it does not allow the state to be stable in any short period of time.<br />
The different natures of the two formalisms suggest that we should incorporate both in most parts<br />
of the system development. A design process starts from an abstract durational specification,<br />
which is refined in a number of steps. In each step, transitional features will be enriched,<br />
with durational features reduced. The design process eventually reaches an automaton system<br />
without durational features.<br />
A durational specification in the common pattern can be decomposed into two such specifications<br />
“driven” by an automaton:<br />
(5)<br />
D<br />
∫<br />
p f(l) ⊇ (D<br />
∫<br />
p g(l) ⊳ q ⊲ D<br />
∫<br />
p h(l)) ∧ 〈 U ↑ q ↓ V 〉.<br />
The automaton 〈 U ↑ q ↓ V 〉 switches between q <strong>and</strong> ¬q according to the time restrictions<br />
∫<br />
U<br />
<strong>and</strong> V . If the automaton is in a state satisfying<br />
∫<br />
q , the system behaves like D p g(l) ;<br />
or if it is in ¬q , the system behaves like D p h(l) . Note that the above refinement only<br />
holds when the characteristic functions f, g, h <strong>and</strong> the sets U, V of time points satisfy some<br />
constraints, which can now be identified in seperate laws.<br />
We first consider the most general case of refinement. If an automaton switches between two<br />
states in exactly a <strong>and</strong> c seconds respectively, the maximum number of full segments contained<br />
Report No. 301,<br />
<strong>UNU</strong>-<strong>IIST</strong>, P.O. Box 3058, Macau
Linking Duration Calculus <strong>and</strong> TLA 14<br />
in an interval of length l is identified as follows:<br />
segnum(l, a, c) ̂= max {m + n | ma + nc < l, |m−n| 1}.<br />
Since a slower automaton can only produce less segments in an interval, the number<br />
segnum(l, inf U, inf V ) has provided the maximum number of segments for a general automaton<br />
〈 U ↑ q ↓ V 〉 . Note that we assume (inf U + inf V ) > 0 <strong>and</strong> consider only non-Zeno automata.<br />
Besides full segments, an interval may include partial segments on both ends. Their lengths are<br />
bounded by sup U or sup V , depending on the state. This is why according to the definition,<br />
we have segnum(a + c, a, c) = 1 so that the last segment on either end can be regarded as a<br />
partial segment. The purpose is to enumerate all possibilities for each interval <strong>and</strong> ensure that<br />
in every case, the right-h<strong>and</strong> side of (5) refines the left-h<strong>and</strong> side. In the following laws, we use<br />
a ⊳ b ⊲ c to denote the value a if b = 1 , or the value c if b = 0 .<br />
Def 9 A characteristic function f can be decomposed as two functions g <strong>and</strong> h under the restrictions<br />
of U <strong>and</strong> V , if (inf U + inf V ) > 0 <strong>and</strong> for any t 0 <strong>and</strong> any n segnum(t, inf U, inf V )<br />
<strong>and</strong> any t 0 , t 1 , · · · , t n+1 <strong>and</strong> t ′ 0 , t′ 1 , · · · , t′ n+1 such that t 0, t n+1 sup U, t ′ 0 , t′ n+1 sup V , t 1, · · · , t n ∈ U<br />
<strong>and</strong> t ′ 1 , · · · , t′ n ∈ V , we have: if ∑ n+1<br />
k=0 (t k ⊳ 2 | k ⊲ t ′ k ) = t then ∑ n+1<br />
k=0 (g(t k) ⊳ 2 | k ⊲ h(t ′ k )) <br />
f(t); <strong>and</strong> if ∑ n+1<br />
k=0 (t′ k ⊳ 2 | k ⊲ t k) = t then ∑ n+1<br />
k=0 (h(t′ k ) ⊳ 2 | k ⊲ g(t k)) f(t) .<br />
Law 9 If the function f can be decomposed as g <strong>and</strong> h under the restrictions of U <strong>and</strong> V ,<br />
the law (5) holds.<br />
The following theorem reveals that if g <strong>and</strong> h are maximally minimised (see Law 8), then Law 9<br />
is complete.<br />
Theorem 2 (Completeness) If (5) holds but the function f cannot be decomposed as g <strong>and</strong><br />
h under the restrictions of U <strong>and</strong> V , then there exist g ′ <strong>and</strong> h ′ ∫<br />
∫<br />
such that D p g(l) =<br />
D p g ′ ∫ ∫<br />
(l) <strong>and</strong> D p h(l) = D p h ′ ∫ ∫<br />
∫<br />
(l) <strong>and</strong> D p f(l) ⊇ (D p g ′ (l) ⊳ q ⊲<br />
D p h ′ (l)) ∧ 〈 U ↑ q ↓ V 〉 , <strong>and</strong> f can be decomposed as g ′ <strong>and</strong> h ′ under the restrictions of<br />
U <strong>and</strong> V .<br />
Unfortunately the precondition of the complete law is too complicated to check in practice. We<br />
must consider its useful special cases. If the abstract specification is related to only intervals<br />
no longer than the sum of the minimum lengths of the two phases, then the precondition of the<br />
decomposition can be reduced to a constraint on at most three segments.<br />
Law 10 If a + c > 0 , U = [a, b] , V = [c, d] , t f(t) for any t > a + c , <strong>and</strong> for any t, we have<br />
g(t 0 ) + g(t 1 ) + h(t 2 ) f(t) for any t 0 , t 1 ∈ [a, b] <strong>and</strong> t 2 ∈ [c, d] such that t 0 + t 1 + t 2 = t , <strong>and</strong><br />
h(t 0 ) + h(t 1 ) + g(t 2 ) f(t) for any t 0 , t 1 ∈ [c, d] <strong>and</strong> t 2 ∈ [a, b] such that t 0 + t 1 + t 2 = t , then<br />
the law (5) holds.<br />
Report No. 301,<br />
<strong>UNU</strong>-<strong>IIST</strong>, P.O. Box 3058, Macau
Linking Duration Calculus <strong>and</strong> TLA 15<br />
If the abstract specification is related to only intervals no longer than any phase, then the<br />
precondition can be reduced to a constraint on at most two segments.<br />
Law 11 If a, c > 0 , U = [a, b] , V = [c, d] , t f(t) for any t > min(b, c) , <strong>and</strong> for any t, we<br />
have g(t 0 ) + h(t 1 ) f(t) for any t 0 ∈ [a, b] <strong>and</strong> t 1 ∈ [c, d] or t 0 ∈ [c, d] <strong>and</strong> t 1 ∈ [a, b] such that<br />
t 0 + t 1 = t , then the law (5) holds.<br />
The above laws introduce an automaton as the structure of refinement <strong>and</strong> leave the parameters<br />
to be decided later. System developers need to determine the parameters according to their own<br />
design strategy.<br />
Refinement of basic patterns<br />
If the driven specifications are the extreme ones either almost true or almost not true, the<br />
refinement laws can be further simplified. For example, the durational specification<br />
(6)<br />
D (l A ⇒ ∫ p B)<br />
requires a system not to stay in the a state satisfying p longer than B during any period no<br />
longer than A . This is illustrated in Figure 3 (a) as sets of coordinates (t, s) where t denotes<br />
l <strong>and</strong> s denotes ∫ p. We assume that s t .<br />
10<br />
9<br />
s<br />
10<br />
9<br />
s<br />
8<br />
8<br />
7<br />
7<br />
6<br />
6<br />
5<br />
5<br />
4<br />
4<br />
3<br />
2<br />
(A,B)<br />
3<br />
2<br />
(A,B)<br />
1<br />
0<br />
0 1 2 3 4 5 6 7 8 9 10<br />
(a)<br />
t<br />
1<br />
0<br />
0 1 2 3 4 5 6 7 8 9 10<br />
(b)<br />
t<br />
Figure 3: The basic pattern <strong>and</strong> its refinement (b = B/2)<br />
Such a durational specification is directly implemented with an automaton, instead of being<br />
decomposed to a mixture of intermediate specifications.<br />
Law 12<br />
If 0 < b B <strong>and</strong> c A−B<br />
⌊B/b⌋ , then D (l A ⇒ ∫ p B) ⊇ 〈 [0, b] ↑ p ↓ [c, ∞] 〉 .<br />
Report No. 301,<br />
<strong>UNU</strong>-<strong>IIST</strong>, P.O. Box 3058, Macau
Case study: the Gas Burner 16<br />
Figure 3(b) illustrates the refinement of the basic patterns. The grey area indicates the requirements,<br />
while the dark area (contained in the grey area) illustrates the TLA design.<br />
The following law is a generalisation of Law 12 for general functional restrictions.<br />
Law 13 If l f(l) for any l b , f(l) > b for any l > b , <strong>and</strong> c sup l>b<br />
l−f(l)<br />
⌊f(l)/b⌋ , then<br />
D<br />
∫<br />
p f(l) ⊇ 〈 [0, b] ↑ p ↓ [c, ∞] 〉 .<br />
5 Case study: the Gas Burner<br />
The Gas Burner problem was first stated in [13] <strong>and</strong> has been a st<strong>and</strong>ard example of hybrid<br />
system design. A gas burner can be in any state of being idle, purging (waiting the leaked gas<br />
to disperse), attempting to ignite, monitoring flame when igniting, or burning after successful<br />
ignition. There is no leak in idling or purging, but there is always leak in any attempt of ignition<br />
before burning. In this paper, we consider a challenging version of the example in which the<br />
burning phase may have some leak due to the possibility of disturbance from the environment<br />
(see [10]).<br />
The main requirement is to ensure that the total gas leak in every 30 seconds does not exceed<br />
4 seconds. This can be neatly specified in Duration Calculus as follows:<br />
D (l 30 ⇒ ∫ Leak 4) .<br />
Our treatment of this problem consists of several steps of automata decomposition hierarchically.<br />
This process may be viewed as “refinement”, as each step corresponds to a reduction of<br />
nondeterminism. On the other h<strong>and</strong>, if the target automaton is constructed <strong>and</strong> model-checked<br />
first, the reversed process can be used to establish the link between the checked model <strong>and</strong> the<br />
original specification for verification purposes.<br />
We first decompose the original requirement into burning <strong>and</strong> non-burning phases generated<br />
by a cyclic automaton. For simplicity, we intend to use the 2-segment refinement Law 11 <strong>and</strong><br />
thus need to construct a slow automaton that takes at least 30 seconds to change state. Since<br />
the original specification is in a special form, we need to consider only intervals of length 30<br />
<strong>and</strong> choose g(·) <strong>and</strong> h(·) (to characterise the amount of leak) such that for any t 0 <strong>and</strong> t 1 ,<br />
if t 0 + t 1 = 30 g(t 0 ) + h(t 1 ) 4 . For convenience, we choose g(t) ̂= B 1 ⊳ t ∈ [B 1 , 30] ⊲ l <strong>and</strong><br />
h(t) ̂= B 2 ⊳ t ∈ [B 2 , 30] ⊲ l . We now obtain our first refinement (illustrated in Figure 5).<br />
D (l 30 ⇒ ∫ Leak 4)<br />
⊇<br />
D (l 30 ⇒ ∫ Leak B 1 ) ⊳ Burn ⊲ D (l 30 ⇒ ∫ Leak B 2 )<br />
∧ 〈 [a, ∞] ↑ Burn ↓ [b, ∞] 〉<br />
Report No. 301,<br />
<strong>UNU</strong>-<strong>IIST</strong>, P.O. Box 3058, Macau
Case study: the Gas Burner 17<br />
where the parameters satisfy the following condition:<br />
Restriction 1 a 30 , b 30 <strong>and</strong> B 1 + B 2 4 .<br />
Figure 4: Design of automata<br />
According to Law 12, the non-burning phase D (l 30 ⇒ ∫ Leak B 2 ) can be further decomposed<br />
to another automaton driven by the first one with leaking <strong>and</strong> non-leaking phases<br />
(illustrated in Figure 5):<br />
D (l 30 ⇒ ∫ Leak B 2 ) ⊇ 〈 [0, c] ↑ Leak ↓ [d, ∞] 〉 .<br />
where the parameters satisfy the following condition:<br />
Restriction 2 0 < c B 2 <strong>and</strong> d 30−B 2<br />
⌊B 2 /c⌋ .<br />
The two automata run independently. The second automaton only takes effect when the system<br />
is not burning. Further refinement of the non-burning phase can be done using st<strong>and</strong>ard<br />
automaton techniques. For example, the two automata can be combined in one in Figure5.<br />
Figure 5: Combined design<br />
Restriction 3 e B 2 , e + d b <strong>and</strong> f B 2 .<br />
Report No. 301,<br />
<strong>UNU</strong>-<strong>IIST</strong>, P.O. Box 3058, Macau
Conclusions 18<br />
There are many possible solutions to the restrictions. We take the following combination:<br />
a = b = 30, B 1 = B 2 = 2, c = 2, d = 30, e = 0, f = 2 . Note that we could let d be 28 <strong>and</strong> then<br />
e = f = 2 , but that means the control of the ignition must be exactly in 2 seconds — a requirement<br />
difficult to meet in practice. By extending the purging phase, we allow more flexibility for<br />
the ignition. Once an automaton is obtained, the transition restrictions can be strengthened to<br />
reduce nondeterminism. For example, the restriction [d, ∞] can be replaced with [30, 30 + ε]<br />
where ε indicates a tolerantable timing inaccuracy.<br />
In the final step, we split the state of non-leaking into idling <strong>and</strong> purging <strong>and</strong> the state of leaking<br />
into two states of ignition, <strong>and</strong> restrict the timing nondeterminism to obtain a reasonable design.<br />
Again the verification of this step can be conducted in TLA.<br />
Figure 6: Combined design<br />
In the above design, the state of burning must be no less than 30 seconds. This additional<br />
requirement is introduced by Law 11 <strong>and</strong> can be avoided if we decided to use Law 10 instead,<br />
although this alternative design would generate more complicated restrictions for the parameters.<br />
6 Conclusions<br />
This paper studies a formal framework in which our knowledge about the relationships between<br />
different temporal logics can be formalised in the form of algebraic or refinement laws. In the case<br />
study on DC <strong>and</strong> TLA, we have identified refinement laws for several design patterns. Some of<br />
the laws are general <strong>and</strong> cover most types of refinement with a particular target implementation.<br />
More specific laws are introduced for the most common patterns, <strong>and</strong> their parameters can be<br />
more readily determined. The technique is applied to the design of gas burner problem. It is<br />
not a trivial task to identify general but at the same time practically useful laws. However once<br />
such laws are identified, they genuinely make the design process more systematic, especially on<br />
the determination of parameters.<br />
The formalism of the framework was first presented at IFM’04. The main focus of this paper<br />
is, however, on the relationship between DC <strong>and</strong> TLA. In particular, the decomposition of<br />
durational specifications (into automata) is the main new contribution.<br />
Report No. 301,<br />
<strong>UNU</strong>-<strong>IIST</strong>, P.O. Box 3058, Macau
References 19<br />
References<br />
[1] P. Blackburn, M. de Rijke, <strong>and</strong> Y. Venema. Modal Logic. Cambridge <strong>University</strong> Press,<br />
2001.<br />
[2] Y. Chen. Generic composition. Formal Aspects of Computing, 14(2):108–122, 2002.<br />
[3] Y. Chen. Cumulative computing. In 19th Conference on the Mathematical Foundations of<br />
Programming Semantics, volume 38 of Electronic Notes in Theoretical Computer Science.<br />
Elsevier, 2004.<br />
[4] Y. Chen <strong>and</strong> Z. Liu. Integrating temporal logics. In 4nd International Conference on<br />
Integrated Formal Methods, volume 2999 of LNCS, pages 402–420. Springer-Verlag, 2004.<br />
[5] E.C.R. Hehner. Predicative programming I, II. Communications of ACM, 27(2):134–151,<br />
1984.<br />
[6] C. A. R. Hoare. Communicating Sequential Processes. Prentice Hall, 1985.<br />
[7] C. A. R. Hoare <strong>and</strong> J. He. Unifying Theories of Programming. Prentice Hall, 1998.<br />
[8] L. Lamport. Hybrid systems in TLA+. In Hybrid Systems, volume 736 of LNCS, pages<br />
77–102. Springer-Verlag, 1993.<br />
[9] L. Lamport. A temporal logic of actions. ACM Transctions on Programming Languages<br />
<strong>and</strong> Systems, 16(3):872–923, 1994.<br />
[10] Z. Liu, A. P. Ravn, <strong>and</strong> X. Li. Unifying proof methodologies of duration calculus <strong>and</strong> linear<br />
temporal logic. Technical Report 1999/14, Department of Maths <strong>and</strong> Computer Science,<br />
<strong>University</strong> of Leicester, July 1999. To appear in Formal Aspects of Computing (19 pages).<br />
[11] A. Pnueli. The temporal semantics of concurrent programs. Theoretical Computer Science,<br />
13:45–60, 1981.<br />
[12] A. Pnueli <strong>and</strong> E. Harel. Applications of temporal logic to the specification of real-time<br />
systems. In M. Joseph, editor, Formal Techniques in Real-Time <strong>and</strong> Fault-Tolerant Systems,<br />
Lecture Notes in Computer Science 331, pages 84–98. Springer-Verlag, 1988.<br />
[13] A.P. Ravn, H. Rischel, <strong>and</strong> K.M. Hansen. Specifying <strong>and</strong> verifying requirements of real-time<br />
systems. IEEE Transactions on Software Engineering, 19(1):41–55, 1993.<br />
[14] M. Schenke <strong>and</strong> E. Olderog. Transformational design of real-time systems part i: From<br />
requirements to program specifications. Acta Informatica, 36(1):1–65, 1999.<br />
[15] H. Shalqvist. Completeness <strong>and</strong> correspondence in the first <strong>and</strong> second order semantics<br />
for modal logic. In Proceedings of the third Sc<strong>and</strong>inavian logic symposium, pages 110–143.<br />
North Holl<strong>and</strong>, 1975.<br />
[16] B. von Karger. A calculational approach to reactive systems. Science of Computer Programming,<br />
37:139–161, 2000.<br />
Report No. 301,<br />
<strong>UNU</strong>-<strong>IIST</strong>, P.O. Box 3058, Macau
References 20<br />
[17] C. Zhou, C. A. R. Hoare, <strong>and</strong> A. P. Ravn. A calculus of durations. Information Processing<br />
Letters, 40(5):269–276, 1991.<br />
[18] C.C. Zhou, A.P. Ravn, <strong>and</strong> M.R. Hansen. An extended duration calculus for hybrid realtime<br />
systems. In R.L. Grossman, A. Nerode, A.P. Ravn, <strong>and</strong> H. Rischel, editors, Hybrid<br />
Systems, Lecture Notes in Computer Science 736, pages 36–59. Springer-Verlag, 1993.<br />
Report No. 301,<br />
<strong>UNU</strong>-<strong>IIST</strong>, P.O. Box 3058, Macau