Fcps 13
Fcps 13
Lecture Notes on
Foundations of Cyber-Physical Systems
Andre Platzer
Carnegie Mellon University
Lecture 0
1 Overview
Cyber-physical systems (CPSs) combine cyber capabilities (computation and/or communication) with physical capabilities (motion or other physical processes). Cars, aircraft,
and robots are prime examples, because they move physically in space in a way that is
determined by discrete computerized control algorithms. Designing these algorithms
to control CPSs is challenging due to their tight coupling with physical behavior. At the
same time, it is vital that these algorithms be correct, since we rely on CPSs for safetycritical tasks like keeping aircraft from colliding. In this course we will strive to answer
the fundamental question posed by Jeannette Wing:
How can we provide people with cyber-physical systems they can bet their
lives on?
Students who successfully complete this course will:
Understand the core principles behind CPSs.
Develop models and controls.
Identify safety specifications and critical properties of CPSs.
Understand abstraction and system architectures.
Learn how to design by invariant.
Reason rigorously about CPS models.
Verify CPS models of appropriate scale.
L0.2
2 Course Materials
Course material will be made available on the course web page.1 There also is an optional textbook:
Andre Platzer, Logical Analysis of Hybrid Systems: Proving Theorems for Complex
Dynamics. Springer, 2010.
More information on the design of the undergraduate course Foundations of CyberPhysical Systems can be found in the Course Syllabus.2
1
2
http://symbolaris.com/course/fcps13.html
http://symbolaris.com/course/15424-syllabus.pdf
A NDR E P LATZER
L0.3
3 Lectures
These course consists of the following sequence of lectures (lecture notes are hyperlinked):
1. Cyber-physical systems: introduction
2. Differential equations & domains
3. Choice & control
4. Safety & contracts
5. Dynamical systems & dynamic axioms
6. Truth & proof
7. Control loops & invariants
8. Events & delays
9. Proofs & arithmetic
10. Differential equations & differential invariants
11. Differential equations & proofs
12. Dynamic logic & dynamical systems
13. Differential invariants & proof theory
14. Ghosts & differential ghosts
15. Trains & proofs
16. Differential & temporal logic
17. Differential & temporal proofs
18. Virtual substitution & real equations
19. Virtual substitution & real arithmetic
20. Hybrid systems & games
21. Winning strategies & regions
22. Winning & proving hybrid games
23. Game proofs & separations
24. Logical theory & completeness
25. Logical foundations of CPS
A NDR E P LATZER
Lecture Notes on
Differential Equations & Domains
Andre Platzer
Carnegie Mellon University
Lecture 2
1. Introduction
In the last lecture, we have learned about the characteristic features of cyber-physical systems (CPS): they combine cyber capabilities (computation and/or communication) with
physical capabilities (motion or other physical processes). Cars, aircraft, and robots are
prime examples, because they move physically in space in a way that is determined by
discrete computerized control algorithms. Designing these algorithms to control CPSs
is challenging due to their tight coupling with physical behavior. At the same time, it is
vital that these algorithms be correct, since we rely on CPSs for safety-critical tasks like
keeping aircraft from colliding.
Since CPS combine cyber and physical capabilities, we need to understand both to
understand CPS. It is not enough to understand both in isolation, though, because we
also need to understand how the cyber and the physics work together, i.e. what happens when they interface and interact, because this is what CPSs are all about.
You already have experience with models of computation and algorithms for the
cyber part of CPS, because you have seen the use of programming languages for computer programming in previous courses. In CPS, we do not program computers, but
program CPS instead. So we program computers that interact with physics to achieve
their goals. In this lecture, we study models of physics and the most elementary part of
how they can interact with cyber. Physics by and large is obviously a deep subject. But
for CPS one of the most fundamental models of physics is sufficient, that of ordinary
differential equations.
While this lecture covers the most important parts of differential equations, it is not
to be understood as doing complete diligence to the area of ordinary differential equations. You are advised to refer back to your differential equations course and follow the
A NDR E P LATZER
L2.2
supplementary information1 available on the course web page as needed during this
course. We refer to the book by Walter [Wal98] for details and proofs about differential equations. For further background on differential equations, we refer you to the
literature [Har64, Rei71, EEHJ96].
These lecture notes are based on material on cyber-physical systems, hybrid programs, and logic [Pla12, Pla10, Pla08, Pla07]. Cyber-physical systems play an important
role in numerous domains [PCA07, LS10, LSC+ 12] with applications in cars [DGV96],
aircraft [TPS98], robots [PKV09], and power plants [FKV04], chemical processes [RKR10,
KGDB10], medical models [GBF+ 11, KAS+ 11], and even an importance for understanding biological systems [Tiw11].
More information about CPS can be found in [Pla10, Chapter 1]. Differential equations and domains are described in [Pla10, Chapter 2.2,2.3] in more detail.
http://symbolaris.com/course/fcps13-resources.html
A NDR E P LATZER
L2.3
Note that the value of x changes over time, so it is really a function of time. Hence, the notation
x (t) = v(t), v (t) = a is sometimes used. It is customary, however, to suppress the argument t for time
and just write x = v, v = a instead.
A NDR E P LATZER
L2.4
with ordinary differential equation (ODE) y = f (t, y), if, for all t I
1. (t, Y (t)) D,
2. Y (t) exists and Y (t) = f (t, Y (t)),
3. Y (t0 ) = y0 .
If f : D Rn is continuous, then it is easy to see that Y : I Rn is continuously
differentiable. Similarly if f is k-times continuously differentiable then Y is k + 1-times
continuously differentiable. The definition is accordingly for higher-order differential
equations, i.e., differential equations involving higher-order derivatives y (n) (t) for n >
1.
Let us consider the intuition for this definition. A differential equation (system) can
be thought of as a vector field such as the one in Fig. 1, where, at each point, the vector
shows in which direction the solution evolves. At every point, the vector would correspond to the right-hand side of the differential equation. A solution of a differential
equation adheres to this vector field at every point, i.e., the solution (e.g., the solid line
in Fig. 1) locally follows the direction indicated by the vector of the right-hand side of
the differential equation. There are many solutions of the differential equation corresponding to the vector field illustrated in Fig. 1. For the particular initial value problem, however, a solution also has to start at the position y0 at time t0 and then follow
the differential equations or vector field from this point. In general, there could still be
multiple solutions for the same initial value problem.
Example 2. Some differential equations are easy to solve. The initial value problem
x (t) = 5
x(0) = 2
has a solution x(t) = 5t + 2. This can be checked easily by inserting the solution into
the differential equation and initial value equation:
(x(t)) = (5t + 2) = 5
x(0) = 5 0 + 2 = 2
Example 3. Consider the initial value problem
x (t) = 2x
x(1) = 3
which has a solution x(t) = 3e2(t1) . The test, again, is to insert the solution into the
(differential) equations of the initial value problems and check:
A NDR E P LATZER
L2.5
Example 4. Consider the differential equation system z = v, v = a and the initial value
problem
z (t) = v(t)
v (t) = a
z(0) = z0
v(0) = v0
Note that this initial value problem is a symbolic initial value problem with symbols z0 , v0
as initial values (not specific numbers like 5 and 2.3). Moreover, the differential equation has a constant symbol a, and not a specific number like 0.6, in the differential
equation. In vectorial notation, the initial value problem with this differential equation
system corresponds to a vectorial system when we denote y(t) := (z(t), v(t)), i.e., with
dimension n = 2 in Def. 1:
z
v(t)
y (t) = v (t) =
a
z
z0
y(0) =
(0) =
v0
v
The solution of this initial value problem is
a 2
t + v 0 t + z0
2
v(t) = at + v0
z(t) =
We can show that this is the solution by inserting the solution into the (differential)
equations of the initial value problems and checking:
( a2 t2 + v0 t + z0 ) = 2 a2 t + v0 = v(t)
(at + v0 ) = a
a 2
z(0) = 2 0 + v0 0 + z0 = z0
v(0) = a0 + v0 = v0
x (t) = y(t)
y (t) = x(t)
x(0) = 1
y(0) = 1
The solution of this initial value problem is
A NDR E P LATZER
L2.6
We can show that this is the solution by inserting the solution into the (differential)
equations of the initial value problems and checking:
(cos(t) + sin(t)) =
(cos(t) sin(t)) =
x(0) =
y(0) =
cos(0) + sin(0) = 1
cos(0) sin(0) = 1
Note 1 (Descriptive power of differential equations). As a general phenomenon, observe that solutions of differential equations can be much more involved than the differential equations themselves, which is part of the representational and descriptive power of
differential equations.
A NDR E P LATZER
L2.7
ther. The evolution domain H (v 0), instead, restricts the system x = v, v = a & v 0
to nonnegative velocities. Should the velocity ever become negative while following
the differential equation x = v, v = a, then the system stops before that happens.
In the scenario illustrated in Fig. 2, the system starts at time 0 inside the evolution
domain that is depicted as a shaded green region in Fig. 2. Then the system follows the
differential equation x = f (x) for any period of time, but has to stop before it leaves H.
Here, it stops at time r.
x
x)
x = f(
H
x)
x = f (
H
0
Figure 2: System x = f (x) & H follows the differential equation x = f (x) but cannot
leave the (shaded) evolution domain H.
In contrast, consider the scenario shown on the right of Fig. 2. The system is not
allowed to evolve until time s, becauseeven if the system is back in the evolution
domain H at that timeit has left the evolution domain H between time r and s (indicated by dotted lines), which is not allowed. Consequently, the continuous evolution
on the right of Fig. 2 will also stop at time r at the latest.
How can we properly describe the evolution domain H? We will need some logic for
that.
A NDR E P LATZER
L2.8
the other.
Continuous Programs. The first element of the syntax of hybrid programs is the
following.
Note 3. Version 1 of hybrid programs (HPs) are continuous programs. These are
defined by the following grammar ( is a HP, x a variable, a term possibly containing x,
and H a formula of first-order logic of real arithmetic):
::= x = & H
This means that a hybrid program consists of a single statement of the form x = & H.
In later lectures, we will add more statements to hybrid programs, but focus on differential equations for now. The formula H is called evolution domain constraint of the continuous evolution x = & H. Further x is allowed to be a vector of variables and, then,
is a vector of terms of the same dimension. This corresponds to the case of differential
equation systems such as:
x = v, v = a & (v 0 v 10)
Differential equations are allowed without an evolution domain constraint H as well,
for example:
x = y, y = x + y 2
which corresponds to choosing true for H, since the formula true is true everywhere
and imposes no condition on the state.
Terms. A rigorous definition of the syntax of hybrid programs also depends on defining what a term is and what a formula H of first-order logic of real arithmetic is. A
term is a polynomial term defined by the grammar (where , are terms, x a variable,
and c a rational number constant):
, ::= x | c | + |
This means that a term is either a variable x, or a rational number constant c Q,
or a sum of terms , , or a product of terms , . Subtraction is another useful
case, but it turns out that it is already included, because subtraction can be defined by
+ (1) .
First-order Formulas. The formulas of first-order logic of real arithmetic are defined
as usual in first-order logic, yet using the language of real arithmetic. The formulas
of first-order logic of real arithmetic are defined by the following grammar (where F, G
are formulas of first-order logic of real arithmetic, , are (polynomial) terms, and x a
variable):
F, G ::= = | | F | F G | F G | F G | F G | x F | x F
A NDR E P LATZER
L2.9
The usual abbreviations are allowed, such as for and < for ( ).
Terms. The meaning of a continuous evolution x = & H depends on understanding the meaning of terms . A term is a syntactic expression. Its value depends on
the interpretation of the variables contained in . What values those variables have
changes depending on the state of the CPS. A state is a mapping from variables to real
numbers. The set of states is denoted S.
Definition 6 (Valuation of terms). The value of term in state is denoted [[]] and
defined by induction on the structure of :
[[x]] = (x)
if x is a variable
[[c]] = c
if c is a rational constant
[[ + ]] = [[]] + [[]]
[[ ]] = [[]] [[]]
In particular, the value of a variable-free term like 4+52 does not depend on the state
. In this case, the value is 14. The value of a term with variables, like 4 + x 2, depends
on . Suppose (x) = 5, then [[4 + x 2]] = 14. If (x) = 2, then [[4 + x 2]] = 8.
First-order Formulas. Unlike for terms, the value of a logical formula is not a number
but instead true or false. Whether a logical formula evaluates to true or false depends
on the interpretation of its symbols. In first-order logic of real arithmetic, the meaning
of all symbols except variables is fixed. The meaning of terms and of formulas of firstorder logic of real arithmetic is as usual in first-order logic, except that + really means
addition, means multiplication, means greater or equals, and that the quantifiers x
and x quantify over the reals.
Let xd denote the state that agrees with state except for the interpretation of variable x, which is changed to the value d R:
(
d
if y is the variable x
xd (y) =
(y) otherwise
We write |= F to indicate that F evaluates to true in state and define it as follows.
Definition 7 (First-order logic semantics). The satisfaction relation |= F for a first-order
formula F of real arithmetic in state is defined inductively:
A NDR E P LATZER
L2.10
A NDR E P LATZER
L2.11
(t). Let
means that (t) |= x = for all 0 t r, when interpreting (t)(x ) = d()(x)
d
us elaborate what this means and explicitly consider differential equation systems:
Definition 8 (Semantics of continuous programs). (, ) (x1 = 1 , . . . , xn = n & H)
iff there is a flow of some duration r 0 along x1 = 1 , . . . , xn = n & H from state
to state , i.e. a function : [0, r] S such that:
(0) = , (r) = ;
respects the differential equations: For each variable xi , the valuation [[xi ]]() = ()(xi )
of xi at state () is continuous in on [0, r] and has a derivative of value [[i ]]()
at each time (0, r);
the value of other variables z 6 {x1 , . . . , xn } remains constant, that is, we have
[[z]]() = [[z]] for all [0, r];
and respects the invariant: () |= H for each [0, r].
Observe that this definition is explicit about the fact that variables without differential equations do not change during a continuous program. The semantics of HP is
explicit change: nothing changes unless (an assignment or) a differential equation specifies how. Also observe the explicit passing from syntax to semantics by the use of the
valuation function [[]] in Def. 8.
A NDR E P LATZER
L2.12
A. Existence Theorems
For your reference, this appendix contains a short primer on some important results
about differential equations [Pla10, Appendix B].
There are several classical theorems that guarantee existence and/or uniqueness of
solutions of differential equations (not necessarily closed-form solutions with elementary functions, though). The existence theorem is due to Peano [Pea90]. A proof can be
found in [Wal98, Theorem 10.IX].
Theorem 9 (Existence theorem of Peano). Let f : D Rn be a continuous function on an
open, connected domain D R Rn . Then, the initial value problem (1) with (t0 , y0 ) D
has a solution. Further, every solution of (1) can be continued arbitrarily close to the boundary
of D.
Peanos theorem only proves that a solution exists, not for what duration it exists.
Still, it shows that every solution can be continued arbitrarily close to the boundary of
the domain D. That is, the closure of the graph of the solution, when restricted to
[0, 0] Rn , is not a compact subset of D. In particular, there is a global solution on the
interval [0, ) if D = Rn+1 then.
Peanos theorem shows the existence of solutions of continuous differential equations
on open, connected domains, but there can still be multiple solutions.
Example 10. The initial value problem with the following continuous differential equation
p
y = 3 |y|
y(0) = 0
has multiple solutions:
y(t) = 0
3
2 2
y(t) =
t
3
(
0
y(t) =
3
2
2
3 (t s)
for t s
for t > s
A NDR E P LATZER
L2.13
with L =
by mean value theorem. Similarly, f is locally Lipschitz
continuous iff for each (t, y) D, there is a neighbourhood in which f is Lipschitz continuous. In particular, if f is continuously differentiable, i.e., f C 1 (D, Rn ), then f is
locally Lipschitz continuous.
Picard-Lindelofs
theorem does not show the duration of the solution, but shows
theorem,
only that the solution is unique. Under the assumptions of Picard-Lindelofs
every solution can be extended to a solution of maximal duration arbitrarily close to
the boundary of D by Peanos theorem, however. The solution is unique, except that
all restrictions of the solution to a sub-interval are also solutions.
Example 12. The initial value problem
y = y2
y(0) = 1
1
has the unique maximal solution y(t) = 1t
on the domain t < 1. This solution cannot
be extended to include the singularity at t = 1.
The following global uniqueness theorem shows a stronger property when the domain is [0, a] Rn . It is a corollary to Theorems 9 and 11, but used prominently in
the proof of Theorem 11, and is of independent interest. A direct proof of the follow theorem can be found in [Wal98, Proposiing global version of the Picard-Lindelof
tion 10.VII].
Let f : [0, a] Rn Rn
Corollary 13 (Global uniqueness theorem of Picard-Lindelof).
be a continuous function that is Lipschitz continuous with respect to y. Then, there is a unique
solution of the initial value problem (1) on [0, a].
Exercises
Exercise 1. Review the basic theory of ordinary differential equations and examples.
Exercise 2. Review the syntax and semantics of first-order logic.
A NDR E P LATZER
L2.14
References
[DGV96]
u,
and Pravin Varaiya. SHIFT: A formalism
Akash Deshpande, Aleks Goll
and a programming language for dynamic networks of hybrid automata.
In Panos J. Antsaklis, Wolf Kohn, Anil Nerode, and Shankar Sastry, editors,
Hybrid Systems, volume 1273 of LNCS, pages 113133. Springer, 1996.
[EEHJ96] Kenneth Eriksson, Donald Estep, Peter Hansbo, and Claes Johnson. Computational Differential Equations. Cambridge University Press, 1996.
[FKV04]
[GBF+ 11] Radu Grosu, Gregory Batt, Flavio H. Fenton, James Glimm, Colas Le Guernic, Scott A. Smolka, and Ezio Bartocci. From cardiac cells to genetic
regulatory networks. In Ganesh Gopalakrishnan and Shaz Qadeer, editors, CAV, volume 6806 of LNCS, pages 396411. Springer, 2011. doi:
10.1007/978-3-642-22110-1_31.
[Har64]
[KAS+ 11] BaekGyu Kim, Anaheed Ayoub, Oleg Sokolsky, Insup Lee, Paul L. Jones,
Yi Zhang, and Raoul Praful Jetley. Safety-assured development of the gpca
infusion pump software. In Samarjit Chakraborty, Ahmed Jerraya, Sanjoy K. Baruah, and Sebastian Fischmeister, editors, EMSOFT, pages 155164.
ACM, 2011. doi:10.1145/2038642.2038667.
[KGDB10] Branko Kerkez, Steven D. Glaser, John A. Dracup, and Roger C. Bales. A
hybrid system model of seasonal snowpack water balance. In Karl Henrik
Johansson and Wang Yi, editors, HSCC, pages 171180. ACM, 2010. doi:
10.1145/1755952.1755977.
[Lin94]
[LS10]
Insup Lee and Oleg Sokolsky. Medical cyber physical systems. In Sachin S.
Sapatnekar, editor, DAC, pages 743748. ACM, 2010.
[LSC+ 12] Insup Lee, Oleg Sokolsky, Sanjian Chen, John Hatcliff, Eunkyoung Jee,
BaekGyu Kim, Andrew L. King, Margaret Mullen-Fortino, Soojin Park, Alex
Roederer, and Krishna K. Venkatasubramanian. Challenges and research directions in medical cyber-physical systems. Proc. IEEE, 100(1):7590, 2012.
doi:10.1109/JPROC.2011.2165270.
A NDR E P LATZER
L2.15
[PCA07]
[Pea90]
Giuseppe Peano.
Demonstration de lintegrabilite des e quations
differentielles ordinaires. Mathematische Annalen, 37(2):182228, 1890.
[PKV09]
[Pla07]
[Pla08]
[Pla10]
Andre Platzer.
Logical Analysis of Hybrid Systems: Proving Theorems
doi:10.1007/
for Complex Dynamics.
Springer, Heidelberg, 2010.
978-3-642-14509-4.
[Pla12]
[Rei71]
[RKR10]
Derek Riley, Xenofon Koutsoukos, and Kasandra Riley. Reachability analysis of stochastic hybrid systems: A biodiesel production system. European
Journal on Control, 16(6):609623, 2010.
[Tiw11]
[TPS98]
[Wal98]
A NDR E P LATZER
Lecture Notes on
Choice & Control
Andre Platzer
Carnegie Mellon University
Lecture 3
1 Introduction
In the previous lecture, we have seen the beginning of cyber-physical systems, yet emphasized their continuous part in the form of differential equations x = . The sole interface between continuous physical capabilities and cyber capabilities was by way of
their evolution domain. The evolution domain H in a continuous program x = & H
imposes restrictions on how far or how long the system can evolve along that differential equation. Suppose a continuous evolution has succeeded and the system stops
following its differential equation, e.g., because the state would otherwise leave the
evolution domain. What happens now? How does the cyber take control? How do we
describe what the cyber elements compute and how they interact with physics?
This lecture extends the model of continuous programs for continuous dynamics to
the model of hybrid programs for hybrid dynamics.
This lecture is based on material on cyber-physical systems and hybrid programs
[Pla12b, Pla10, Pla08, Pla07].
Continuous programs x = & H are very powerful for modeling continuous processes. They cannoton their ownmodel discrete changes of variables, however.1
During the evolution along a differential equation, all variables change continuously
in time, because the solution of a differential equation is (sufficiently) smooth. Discontinuous change of variables, instead, needs a way for a discrete change of state. What
could be a model for describing discrete changes in a system?
1
There is a much deeper sense [Pla12a] in which continuous dynamics and discrete dynamics are quite
surprisingly close together. That understanding requires a lot more logic than we have at our disposal
at this stage of the course. It also leads to a full understanding of what constitutes the hybridness of
hybrid systems. Yet, its understanding does rest on the foundations of hybrid systems, which we need
to understand first.
September 4, 2013
A NDR E P LATZER
L3.2
There are many models for describing discrete change. You will have seen a number
of them already. CPSs combine cyber and physics. In CPS, we do not program computers, but program CPSs instead. As part of that, we program the computers that control
the physics. And programming computers amounts to using a programming language.
Of course, for programming an actual CPS, our programming language will ultimately
have to involve physics. But we have already seen continuous programs in the previous lecture for that very purpose. Whats missing is a way to program the discrete and
cyber aspects.
Does it matter which discrete programming language we choose as a basis? It could
be argued that the discrete programming language does not matter as much as the
hybrid aspects do. After all, there are many programming languages that are Turingequivalent, i.e. that compute the same functions. Yet even among them there are numerous differences for various purposes in the discrete case, which are studied in the
area of Programming Languages.
For the particular purposes of CPS, however, we will find further desiderata, i.e.
things that we expect from a programming language to be adequate for CPS. We will
develop what we need as we go.
More information about choice and control can be found in [Pla10, Chapter 2.2,2.3].
(1)
will first let cyber perform a discrete change of setting a to a + 1 and then let physics
follow the differential equation x = a. The overall effect is that cyber increases a and
physics then lets x evolve with acceleration a (and increases velocity v with derivative
A NDR E P LATZER
L3.3
a). Thus, HP (1) models a situation where the desired acceleration is commanded once
to increase and the robot then moves with that acceleration. Note that the sequential
composition operator (;) has basically the same effect that it has in programming languages like Java or C0. It separates statements that are to be executed sequentially one
after the other. If you look closely, however, you will find a subtle difference in that
Java and C0 expect more ; than hybrid programs.
The HP in (1) executes control (it sets the acceleration for physics), but it has very
little choice. Actually no choice at all. So only if the CPS is very lucky will an increase
in acceleration be the right action to remain safe.
(2)
x = v, v = a
This HP will check the condition v < 4 to see if the current velocity is still less then 4.
If it is, then a will be increased by 1. Otherwise, a will be set to b for some braking
deceleration constant b > 0. Afterwards, i.e. when the if-then-else statement has run to
completion, the HP will again evolve x with acceleration a along a differential equation.
The HP (2) takes only the current velocity into account to reach a decision on whether
to accelerate or brake. That is usually not enough information to guarantee safety, because a robot doing that would be so fixated on achieving its desired speed that it
would happily speed into any walls or other obstacles along the way. Consequently,
programs that control robots also take other state information into account, for example the distance x o to an obstacle o from the robots position x, not just its velocity
v:
if(x o > 5) a := a + 1 else a := b;
(3)
x = v, v = a
They could also take both distance and velocity into account for the decision:
if(x o > 5 v < 4) a := a + 1 else a := b;
x = v, v = a
(4)
Note 1 (Iterative design). As part of the labs of this course, you will develop increasingly
more intelligent controllers for robots that face increasingly challenging environments.
Designing controllers for robots or other CPS is a serious challenge. You will want to
start with simple controllers for simple circumstances and only move on to more advanced
challenges when you have fully understood and mastered the previous controllers, what
behavior they guarantee and what functionality they are still missing.
A NDR E P LATZER
L3.4
(5)
The extra condition S may be very complicated and often depends on many factors. It
could check to smooth the ride, optimize battery efficiency, or pursue secondary goals.
Consequently, (4) is not actually a faithful model for (5), because (4) insists that the
acceleration would always be increased just because x o > 5 v < 4, unlike (5), which
checks the additional condition S. Likewise, (3) certainly is no faithful model of (5). But
it looks simpler.
How can we describe a model that is simpler than (5) by ignoring the details of S yet
that is still faithful? What we want this model to do is characterize that the controller
may either increase acceleration by 1 or brake and that acceleration certainly only happens when x o > 5. But the model should make less commitment than (3) about
under which circumstances braking is chosen. So we want a model that allows braking under more circumstances than (3) without having to model precisely under which
circumstances that is. In order to simplify the system faithfully, we want a model that
allows more behavior than (3).
Note 2 (Abstraction). Successful CPS models often include relevant aspects of the system only and simplify irrelevant detail. The benefit of doing so is that the model and its
analysis becomes simpler, enabling us to focus on the critical parts without being bogged
down in tangentials. This is the power of abstraction, arguably the primary secret weapon
of computer science. It does take considerable skill, however, to find the best level of abstraction for a system. A skill that you will continue to sharpen through your entire career
as a computer scientist.
Let us take the development of this model this step by step. The first feature that the
controller of this model has is a choice. The controller can choose to increase acceleration or to brake, instead. Such a choice between two actions is denoted by the operator
:
(a := a + 1 a := b);
(6)
x = v, v = a
When running this hybrid program, the first thing that happens is a choice between
whether to run a := a + 1 or whether to run a := b. That is, the choice is whether to
increase a by 1 or whether to reset a to b for braking. After this choice (i.e. after the ;
operator), the system follows the usual differential equation x = a.
A NDR E P LATZER
L3.5
A NDR E P LATZER
L3.6
A NDR E P LATZER
L3.7
bad ones. Say, one of those controllers, e.g. (7), inspects the state and finds it still okay to
accelerate. If it chooses a := a + 1 and then lets physics move in the differential equation
x = a, there will probably come a time at which acceleration is no longer such a great
idea. But the controller of (7) has no way to change its mind, because he has no more
choices and so no control anymore.
If the controller of (7) is supposed to be able to make a second control choice later after
physics has followed the differential equation for a while, then (7) can be sequentially
composed with itself:
(?x o > 5; a := a + 1) a := b ;
x = v, v = a;
(?x o > 5; a := a + 1) a := b ;
(8)
x = v, v = a
In (8), the cyber controller can first choose to accelerate or brake (depending on whether
x o > 5), then physics evolves along differential equation x = a for some while, then
the controller can again choose whether to accelerate or brake (depending on whether
x o > 5 holds in the state reached then), and finally physics again evolves along
x = a.
For a controller that is supposed to be allowed to have a third control choice, replication would again help:
(?x o > 5; a := a + 1) a := b ;
x = v, v = a;
(?x o > 5; a := a + 1) a := b ;
x = v, v = a;
(9)
(?x o > 5; a := a + 1) a := b ;
x = v, v = a
But this is neither a particularly concise nor a particularly useful modeling style. What
if a controller could need 10 control decisions or 100? Or what if there is no way of
telling ahead of time how many control decisions the cyber part will have to take to
reach its goal? Think of how many control decisions you might need when driving in a
car from the East Coast to the West Coast. Do you know that ahead of time? Even if you
do, do you want to model a system by explicitly replicating its controller that often?
Note 5 (Repetition). As a more concise and more general way of describing repeated
control choices, hybrid programs allow for the repetition operator , which works like the
in regular expressions, except that it applies to a hybrid program as in . It repeats
any number n N of times, by a nondeterministic choice.
Thus, a way of summarizing (7), (8), (9) and the infinitely many more n-fold replica-
A NDR E P LATZER
L3.8
(10)
A NDR E P LATZER
L3.9
in the current state, then the system execution cannot continue, is cut off, and not considered any further.
Nondeterministic choice , sequential composition ; , and nondeterministic
repetition of programs are as in regular expressions but generalized to a semantics
in hybrid systems. Nondeterministic choice expresses behavioral alternatives between the runs of and . That is, the HP can choose nondeterministically to
follow the runs of HP , or, instead, to follow the runs of HP . The sequential composition ; models that the HP starts running after HP has finished ( never starts if
does not terminate). In ; , the runs of take effect first, until terminates (if it does),
and then continues. Observe that, like repetitions, continuous evolutions within
can take more or less time, which causes uncountable nondeterminism. This nondeterminism occurs in hybrid systems, because they can operate in so many different ways,
which is as such reflected in HPs. Nondeterministic repetition is used to express that
the HP repeats any number of times, including zero times. When following , the
runs of HP can be repeated over and over again, any nondeterministic number of
times (0).
Unary operators (including ) bind stronger than binary operators and let ; bind
stronger than , so ; (; ) and ; (; ). Further, ; ; ( ).
for a solution : [0, r] S of any duration r}; i.e., with (t)(x ) = d()(x)
(t),
d
solves the differential equation and satisfies H at all times, see lecture 2.
4. ( ) = () ()
5. (; ) = () () = {(, ) : (, ) (), (, ) ()}
[
(n ) with n+1 n ; and 0 ?true.
6. ( ) =
nN
A NDR E P LATZER
L3.10
For graphical illustrations of the transition semantics of hybrid programs and example dynamics, see Fig. 1. On the left of Fig. 1, we illustrate the generic shape of the
transition structure () for transitions along various cases of hybrid programs from
state to state . On the right of Fig. 1, we show examples of how the value of a variable x may evolve over time t when following the dynamics of the respective hybrid
program .
A NDR E P LATZER
L3.11
x
x :=
if (x) = [[]]
and (z) = (z) for z 6= x
0
x
f (t)
= &H
r
= &H
?H
0
1
no change if |= H
otherwise no transition
t
Figure 1: Transition semantics (left) and example dynamics (right) of hybrid programs
A NDR E P LATZER
L3.12
Exercises
Exercise 1. Consider your favorite programming language and discuss in what ways
it introduces discrete change and discrete dynamics. Can it model all behavior that
hybrid programs can describe? Can your programming language model all behavior
that hybrid programs without differential equations can describe? How about the other
way around?
Exercise 2. Consider the grammar of hybrid programs. The ; in hybrid programs is
similar to the ; in Java and C0. If you look closely you will find a subtle difference.
Identify the difference and explain why there is such a difference.
Exercise 3. Sect. 3 considered if-then-else statements for hybrid programs. But they no
longer showed up in the grammar of hybrid programs. Is this a mistake?
References
[DBL12] Proceedings of the 27th Annual ACM/IEEE Symposium on Logic in Computer Science, LICS 2012, Dubrovnik, Croatia, June 2528, 2012. IEEE, 2012.
[Pla07]
Andre Platzer. Differential dynamic logic for verifying parametric hybrid systems. In Nicola Olivetti, editor, TABLEAUX, volume 4548 of LNCS, pages
216232. Springer, 2007. doi:10.1007/978-3-540-73099-6_17.
[Pla08]
Andre Platzer. Differential dynamic logic for hybrid systems. J. Autom. Reas.,
41(2):143189, 2008. doi:10.1007/s10817-008-9103-8.
[Pla10]
Andre Platzer. Logical Analysis of Hybrid Systems: Proving Theorems for Complex
Dynamics. Springer, Heidelberg, 2010. doi:10.1007/978-3-642-14509-4.
[Pla12a] Andre Platzer. The complete proof theory of hybrid systems. In LICS [DBL12],
pages 541550. doi:10.1109/LICS.2012.64.
[Pla12b] Andre Platzer. Logics of dynamical systems. In LICS [DBL12], pages 1324.
doi:10.1109/LICS.2012.13.
[Pla13]
Andre Platzer. A complete axiomatization of differential game logic for hybrid games. Technical Report CMU-CS-13-100R, School of Computer Science,
Carnegie Mellon University, Pittsburgh, PA, January, Revised and extended
in July 2013.
A NDR E P LATZER
Lecture Notes on
Safety & Contracts
Andre Platzer
Carnegie Mellon University
Lecture 4
1 Introduction
In the previous lectures, we have studied models of cyber-physical systems. Hybrid
programs provide a programming language for cyber-physical systems with the most
prominent features being differential equations and nondeterminism alongside the usual
classical control structures and discrete assignments. This gives powerful and flexible
ways of modeling even very challenging systems and very complex control principles.
This lecture will start studying ways of making sure that the resulting behavior meets
the required correctness standards.
In 15-122 Principles of Imperative Computation, you have experienced how contracts
can be used to make properties of programs explicit. You have seen how contracts can
be checked dynamically at runtime, which, if they fail, alert you right away to flaws in
the design of the programs. You have experienced first hand that it is much easier to
find and fix problems in programs starting from the first contract that failed in the middle of the program, rather than from the mere observation that the final output is not as
expected (which you may not notice either unless the output is checked dynamically).
Another aspect of contracts that you have had the opportunity to observe in Principles of Imperative Computation is that they can be used in proofs that show that every
program run will satisfy the contracts. Unlike in dynamic checking, the scope of correctness arguments with proofs extends beyond the (clever) test cases that have been
tried. Both uses of contracts, dynamic checking and rigorous proofs, are very helpful
to check whether a system does what we intend it to, as has been argued on numerous
occasions in various contexts in the literature, e.g., [Flo67, Hoa69, Pra76, Mey92, XJC09,
PCL11, Log11].
The principles of contracts help cyber-physical systems [Pla08, Pla10, Pla13, DLTT13]
as well. Yet, their use in proving may, arguably, be more important than their use in dy-
September 9, 2013
A NDR E P LATZER
L4.2
namic checking. The reason has to do with the physical impact of CPS and the (relative)
non-negotiability of the laws of physics. The reader is advised to imagine a situation
where a self-driving car is propelling him or her down the street. Suppose the cars
control software is covered with contracts all over, but all of them are exclusively for
dynamic checking, none have been proved. If that self-driving car speeds up to 100mph
on a 55mph highway and drives up very close to a car in front of it, then dynamically
checking the contract distance to car in front should be more than 1 meter does not
help. If that contract fails, the cars software would know that it made a mistake, but
it has become too late to do anything about it, because the brakes of the car will never
work out in time. So the car would be trapped in its own physics, in the sense that
it has run out of all safe control options. There are still effective ways of making use of
dynamic contract checking in CPS, but the design of those contracts then requires proof
to ensure that safety is always maintained.
For those reasons, this course will focus on the role of proofs as correctness arguments much more than on dynamical checking of contracts. Because of the physical
consequences of malfunctions, correctness requirements on CPS are also more stringent. And their proofs involve significantly more challenging arguments than in Principles of Imperative Computation. For those reasons, we will approach CPS proofs
with much more rigor than what you have seen in Principles of Imperative Computation. But that is a story for a later lecture. The focus of todays lecture will be to
understand CPS contracts and the first basics of reasoning about CPS.
This material is based on correctness specifications and proofs for CPS [Pla12c, Pla07,
Pla08, Pla10]. We will come back to more details in later lectures, where we will also
use the KeYmaera prover for verifying CPS [PQ08]. More information about safety and
contracts can be found in [Pla10, Chapter 2.2,2.3].
A NDR E P LATZER
L4.3
(2)
Such a model may be useful for other systems, but would be rather at odds with our
physical experience with bouncing balls, because the ball is indeed slowly climbing
back up rather than suddenly being way up in the air again.
The bouncing ball ponders about what happens when it hits the ground. It does not
suddenly get teleported to a new position above ground like (2) would suggest. Instead, the ball suddenly changes its direction. A moment ago, it used to fall down with
a negative velocity (i.e. one that is pointing down into the ground) and suddenly climbs
A NDR E P LATZER
L4.4
back up with a positive velocity (pointing up into the sky). In order to be able to write
such a model, the velocity v will be made explicit in the bouncing balls differential
equation:
h = v, v = g;
(3)
if(h = 0) v := v
Of course, something happens after the bouncing ball reversed its direction because
it hit the ground. Physics continues until it hits the ground again.
h = v, v = g;
if(h = 0) v := v
(4)
h = v, v = g;
if(h = 0) v := v
Then, of course, physics moves on again, so the model actually involves a repetition:
h = v, v = g;
if(h = 0) v := v
(5)
Yet, the bouncing ball is now rather surprised. For if it follows that HP (5), it seems as
if it should always be able to come back up to its initial height again. Excited about that
possibility, it tries and tries again but never succeeds to bounce back up as high as it
was before. So there must be something wrong with the model in (5), the ball concludes
and sets out to fix (5).
Having observed itself rather carefully, the bouncing ball concludes that it feels slower
when bouncing back up than it used to be when falling on down. Indeed, it feels less
energetic on its way up. So its velocity must not only flip direction from down to up,
at a bounce, but also seems to shrink in magnitude. The bouncing ball swiftly calls the
corresponding damping factor c and quickly comes up with a better model of itself:
h = v, v = g;
if(h = 0) v := cv
(6)
Yet, running that model in clever ways, the bouncing ball observes that model (6)
could make it fall through the cracks in the ground. Terrified at that thought, the
bouncing ball quickly tries to set the physics right, lest it falls through the cracks in
space before it had a chance to fix its physics. The issue with (6) is that its differential
equation isnt told when to stop. Yet, the bouncing ball luckily remembers that this is
quite exactly what evolution domains were meant for. Above ground is what it wants
to remain, and so h 0 is what the ball asks dear physics to obey, since the table is of
rather sturdy built:
h = v, v = g & h 0;
(7)
if(h = 0) v := cv
Now, indeed, physics will have to stop evolving before gravity has made our little
bouncing ball fall through the ground. Yet, physics could still choose to stop evolving
A NDR E P LATZER
L4.5
while the ball is still high up in the sky. In that case, the ball will not yet be on the
ground and line 2 of (7) would have no effect because h 6= 0 still. This is not a catastrophe, however, because the loop in (7) could simply repeat, which would allow physics
to continue to evolve the differential equation further.
Quite happy with model (7) for itself, the bouncing ball goes on to explore whether
the model does what the ball expects it to do.
(8)
Safety of robots has, of course, been aptly defined by Asimov [Asi42] with his Three Laws of Robotics:
1. A robot may not injure a human being or, through inaction, allow a human being to come to harm.
2. A robot must obey the orders given to it by human beings, except where such orders would conflict
with the First Law.
3. A robot must protect its own existence as long as such protection does not conflict with the First or
Second Law.
But their exact rendition in logic still remains a challenge.
A NDR E P LATZER
L4.6
(9)
h = v, v = g & h 0;
if(h = 0) v := cv
A NDR E P LATZER
L4.7
(10)
h = v, v = g & h 0;
if(h = 0) v := cv @invariant(h 0)
On second thought, the little bouncing ball is less sure what exactly the @invariant(F )
contract would mean for a CPS. So it decides to first give more thought to the proper
way of phrasing CPS contracts and what they mean.
We will get back to the @invariant(F ) construct in a later lecture.
A NDR E P LATZER
L4.8
Recall that this relationship, (), is what ultimately constitutes the semantics of HP .
Note 2 (Differential dynamic logic principle). Differential dynamic logic (dL) extends
first-order logic of real arithmetic with operators that refer to the future states of a CPS in
the sense of referring to the states that are reachable by running a given HP. The logic dL
provides a modal operator [], parametrized by , that refers to all states reachable by HP
according to the reachability relation () of its semantics. This modal operator can be
placed in front of any dL formula . The dL formula
[]
expresses that all states reachable by HP satisfy formula .
The logic dL also provides a modal operator hi, parametrized by , can be placed in
front of any dL formula . The dL formula
hi
expresses that there is at least one state reachable by HP for which holds. The modalities [] and hican be used to express necessary or possible properties of the transition
behavior of .
An @ensures(E) postcondition for a HP can be expressed directly as a logical formula in dL:
[]E
So, the first CPS postcondition @ensures(0 h) for the bouncing ball HP in (8) can be
stated as a dL formula:
[ h = v, v = g & h 0; if(h = 0) v := cv ] 0 h
(11)
The second CPS postcondition @ensures(h H) for the bouncing ball HP in (8) can be
stated as a dL formula as well:
[ h = v, v = g & h 0; if(h = 0) v := cv ] h H
(12)
The logic dL allows all other logical operators from first-order logic, including conjunction (). So, the two dL formulas (11) and (12) can be stated together as a single dL
formula:
[ h = v, v = g & h 0; if(h = 0) v := cv ] 0 h
(13)
[ h = v, v = g & h 0; if(h = 0) v := cv ] h H
Stepping back, we could also have combined the two postconditions @ensures(0
h) and @ensures(h H) into a single postcondition @ensures(0 h h H). The
translation of that into dL would have gotten us an alternative way of combining both
statements about the lower and upper bound on the height of the bouncing ball into a
single dL formula:
[ h = v, v = g & h 0; if(h = 0) v := cv ] (0 h h H)
(14)
A NDR E P LATZER
L4.9
Which way of representing what we expect bouncing balls to do is better? Like (13) or
like (14)? Are they equivalent? Or do they express different things?
A NDR E P LATZER
L4.10
It turns out that there is a very simple argument within the logic dL that shows that
(13) and (14) are equivalent. And not just that those two particular logical formulas are
equivalent but that the same equivalence holds for any dL formulas of this form. This
will be investigated formally in a later lecture, but it is useful to observe now already
to sharpen our intuition.
Having said that, do we believe dL formula (13) should be valid? Should (14) be
valid? Before we study this question in any further detail, the first question should be
what it means for a modal formula [] to be true. What is its semantics? Better yet,
what exactly is its syntax in the first place?
Quantifiers are only quite arguably understood as unary operators. Yet, x is a unary operator on
formulas while would be an operator with arguments of mixed syntactic categories. In a higher-order
context, it can also be understood more formally by understanding x as an operator on functions:
(x.). Similar cautionary remarks apply to the understanding of modalities as unary operators. The
primary reason for adopting this understanding is that it simplifies the precedence rules.
A NDR E P LATZER
L4.11
A NDR E P LATZER
L4.12
(15)
So if (13) is valid, then so should (14) be (Exercise 1). But is (13) valid?
A NDR E P LATZER
L4.13
Certainly, (13) is not true in a state where (h) < 0, because from that initial state,
no repetitions of the loop (which is allowed by nondeterministic repetition, Exercise 3),
def
will lead to a state = in which 6|= 0 h. Thus, (13) only has a chance of being
valid in initial states that satisfy further assumptions, including 0 h and h H. In
fact, that is what the preconditions were meant for in Sect. 4. How can we express a
precondition contract in a dL formula?
Preconditions serve a very different role than postconditions do. Postconditions of
HP are what we want to hold true after every run of . The meaning of a postcondition is what is rather difficult to express in first-order logic (to say the least). That
is what dL has modalities for. Do we also need any extra logical operator to express
preconditions?
The meaning of a precondition @requires(A) of a HP is that it is assumed to hold
before the HP starts. If A holds when the HP starts, then its postcondition @ensures(B)
holds after all runs of HP . What if A does not hold when the HP starts?
If precondition A does not hold initially, then all bets are off, because the person who
started the HP did not obey its requirements, which says that it should only be run
if its preconditions are met. The CPS contract @requires(A) @ensures(B) for a HP
promises that B will always hold after running if A was true initially when started.
Thus, the meaning of a precondition can be expressed easily using an implication
A []B
(16)
because an implication is valid if, in every state, its left-hand side is false or its righthand side true. The implication (16) is valid ( A []B), if, indeed, for every state
in which precondition A holds ( |= A), it is the case that all runs of HP lead to
states (with (, ) ()) in which postcondition B holds ( |= B). The dL formula
(16) does not say what happens in states in which the precondition A does not hold
( 6|= A).
How does formula (16) talk about the runs of a HP and postcondition B again? Recall
that the dL formula []B is true in exactly those states in which all runs of HP lead
only to states in which postcondition B is true. The implication in (16), thus, ensures
that this holds in all (initial) states that satisfy precondition A.
Note 5 (Contracts to dL Formulas). Consider a HP with a CPS contract using a single
@requires(A) precondition and a single @ensures(B) postcondition:
@requires(A)
@ensures(B)
A NDR E P LATZER
L4.14
CPS contracts with multiple preconditions and multiple postconditions can directly
be expressed as a dL formula as well (Exercise 4).
Recall HP (10), which is shown here in a slightly simplified form:
@requires(0 h h = H)
@ensures(0 h h H)
h = v, v = g & h 0;
if(h = 0) v := cv
(17)
The dL formula expressing that the CPS contract for HP (17) holds is:
0 hh = H h = v, v = g & h 0; if(h = 0) v := cv
(0 hh H) (18)
So to find out whether (17) satisfies its CPS contract, we ask whether the dL formula
(18) is valid.
In order to find out whether such a formula is valid, i.e. true in all states, we need
some operational way that allows us to tell whether it is valid, because mere inspection of the semantics alone is not a particularly scalable way of approaching validity
question.
A NDR E P LATZER
L4.15
Note 6 (Parameters). A common feature of CPS is that their behavior is subject to parameters, which can have quite a non-negligible impact. Yet, it is very hard to determine
precise values for parameters by measurements. When a particular concrete value for a parameter has been assumed to prove a property of a CPS, it is not clear whether that property
holds for the true system, which may in reality have a slightly different parameter value.
Instead of a numerical value for a parameter, our analysis can proceed by treating the
parameter as a symbolic parameter, i.e. a variable such as g, which is not assumed to hold
a specific numerical value like 9.81. Instead, we would only assume certain constraints
about the parameter, say g > 1 without choosing a specific value. If we then analyze
the CPS with this symbolic parameter g, all analysis results will continue to hold for any
concrete choice of g respecting its constraints (here g > 1). That results in a stronger
statement about the system, which is less fragile as it does not break down just because the
true g is 9.8067 rather than the previously assumed g = 9.81. Often times, those more
general statements with symbolic parameters can even be easier to prove than statements
about systems with specific magic numbers chosen for their parameters.
In light of these thoughts, we could assume 9 < g < 10 to be the gravity constant for
Earth. Yet, we can also just consider all bouncing balls on all planets in the solar system
or elsewhere at once by assuming only g > 0 instead of g = 9.81 as in (19), since this is
the only aspect of gravity that the usual behavior of a bouncing ball depends on:
0 hh = Hg > 0 h = v, v = g & h 0; if(h = 0) v := cv
(0 hh H)
(20)
Do we expect dL formula (20) to be valid, i.e. true in all states? What could go wrong?
The insight from modifying (18) to (19) and finally to (20) started with the observation
that (18) did not include any assumptions about g. It is worth noting that (20) also
does not assume anything about c. Bouncing balls clearly would not work as expected
if c > 1, because such anti-damping would cause the bouncing ball to jump back up
higher and higher and higher and ultimately as high up as the moon, clearly falsifying
(20). Consequently, (20) only has a chance of being true when assuming that c is not too
big:
0hh=H g >01>c0
h = v, v = g & h 0; if(h = 0) v := cv
(0 h h H) (21)
Is (21) valid now? Or does its truth depend on more assumptions that have not been
identified yet? Now, all parameters (H, g, c) have some assumptions in (21). Is there
some requirement we forgot about? Or did we find them all?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L4.16
What about variable v? Why is there no assumption about it yet? Should there be
one? Velocity v changes over time. What is its initial value allowed to be? What could
go wrong?
Indeed, the initial velocity v of the bouncing ball could be positive (v > 0), which
would make the bouncing ball climb initially, clearly exceeding its initial height H. This
would correspond to the bouncing ball being thrown high up in the air in the beginning,
so that its initial velocity v is upwards from its initial height h = H. Consequently, (21)
has to be modified to assume v 0 holds initially:
0hh=H v 0g >01>c0
h = v, v = g & h 0; if(h = 0) v := cv
(0 h h H) (22)
Now theres finally assumptions about all parameters and variables of (22). That does
not mean that we found the right assumptions, yet, obviously, but is still a good sanity
check. Before wasting cycles on trying to prove or otherwise justify (22), lets try once
more whether we can find an initial state that satisfies all assumptions v 0 0
h h = H g > 0 1 > c 0 in the antecedent (i.e. left-hand side of the implication) of
(22) so that does not satisfy the succedent (i.e. right-hand side of implication) of (22).
Such an initial state falsifies (22) and would, thus, represent a counterexample.
Is there still a counterexample to (22)? Or have we successfully identified all assumptions so that it is now valid?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L4.17
Formula (22) still has a problem. Even if the initial state satisfies all requirements
in the antecedent of (22), the bouncing ball might still jump higher than it ought to,
i.e. higher than its initial height H. That happens if the bouncing ball has a very big
downwards velocity, so if v is a lot smaller than 0 (sometimes written v 0). If v is
a little smaller than 0, then the damping c will eat up enough the balls kinetic energy
so that it cannot jump back up higher than it was initially (H). But if v is a lot smaller
than 0, then it starts falling down with so much kinetic energy that the damping on the
ground does not slow it down enough, so the ball will come bouncing back higher than
it was originally. Under which circumstance this happens depends on the relationship
of the initial velocity and height to the damping coefficient.
We could explore this relationship in more detail. But it is actually easier to infer this
relationship by conducting a proof. So we modify (22) to simply assume v = 0 initially:
0hh=H v =0g >01>c0
h = v, v = g & h 0; if(h = 0) v := cv
(0 h h H) (23)
Is dL formula (23) valid now? Or does it still have a counterexample?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L4.18
It seems like all required assumptions have been identified to make the dL formula
(23) valid so that the bouncing ball described in (23) satisfies the postcondition 0 h
H. But after so many failed starts and missing assumptions and requirements for the
bouncing ball, it is a good idea to prove (23) once and for all beyond any doubt.
In order to be able to prove dL formula (23), however, we need to investigate how
proving works. How can dL formulas be proved? And, since first-order formulas are
dL formulas as well, one part of the question will be: how can first-order formulas be
proved? How can real arithmetic be proved? How can requirements for the safety of
CPS be identified systematically? All these questions will be answered in this course,
but not all of them in this lecture.
In order to make sure we only need to worry about a minimal set of operators of dL
for proving purposes, lets simply (23) by getting rid of if-then-else (Exercise 7):
0hh=H v =0g >01>c0
h = v, v = g & h 0; (?h = 0; v := cv ?h 6= 0) (0 h h H) (24)
Observing the non-negligible difference between the original conjecture (19) and the
revised and improved conjecture (24), leads us to often adopt the following principle.
A NDR E P LATZER
L4.19
velocity reverted without actually climbing back up. So if we manage to prove (25),
we certainly have not shown the actual dL formula (24). But its a start, because the
behavior modeled in (25) is a part of the behavior of (24). So it is useful (and easier) to
understand (25) first.
The dL formula (25) has a number of assumptions 0 h h = H v = 0 g > 0 1 >
c 0 that can be used during the proof. It claims that the postcondition 0 h h H
holds after all runs of the HP in the [] modality. The top-level operator in the modality
of (25) is a sequential composition (;), for which we need to find a proof argument.3
The HP in (25) follows a differential equation first and then, after the sequential composition (;), proceeds to run a discrete program (?h = 0; v := cv ?h 6= 0). Depending
on how long the HP follows its differential equation, the intermediate state after the
differential equation and before the discrete program will be rather different.
Note 8 (Intermediate states of sequential compositions). This phenomenon happens
in general for sequential compositions ; . The first HP may reach a whole range of
states, which represent intermediate states for the sequential composition ; , i.e. states
that are final states for and initial states for . The intermediate states of ; are the
states in the semantics (; ) from Lecture 3:
(; ) = () () = {(, ) : (, ) (), (, ) ()}
Can we find a way of summarizing what all intermediate states between the differential equation and the discrete program of (25) have in common? They differ by how
long the CPS has followed the differential equation.
If the system has followed the differential equation of (25) for time t, then the resulting velocity v(t) at time t and height h(t) at time t will be
g
v(t) = gt, h(t) = H t2
2
(26)
This answer can be found by integrating or solving the differential equations. This
knowledge (26) is useful but it is not (directly) clear how to use it to describe what
all intermediate states have in common, because the time t in (26) is not available as
a variable in the HP (25).4 Can the intermediate states be described by a relation of
the variables that (unlike t) are actually in the system? That is, an (arithmetic) formula
relating h, v, g, H?
Before you read on, see if you can find the answer for yourself.
The way we proceed here to prove (25) is actually not the recommended way. Later on, we will see a
much easier way. But it is instructive to understand the more verbose approach we take first. This also
prepares us for the challenges that lie ahead when proving properties of loops.
Following these thoughts a bit further reveals how (26) can actually be used perfectly well to describe
intermediate states when changing the HP (25) a little bit. But working with solutions is still not the
way that gets us to the goal the quickest, usually.
A NDR E P LATZER
L4.20
One way of producing a relation from (26) is to get the units aligned and get rid of
time t. Time drops out of the equation when squaring the identity for velocity:
g
v(t)2 = g 2 t2 , h(t) = H t2
2
and multiplying the identity for position by 2g:
g2 2
t
2
Then substituting the first equation into the second yields
v(t)2 = g 2 t2 ,
2gh(t) = 2gH 2
(27)
We conjecture the intermediate condition (27) to hold in the intermediate state of the
sequential composition in (25). In order to prove (25) we can decompose our reasoning
into two parts. The first part will prove that the intermediate condition (27) holds after
all runs of the first differential equation. The second part will assume (27) to hold and
prove that all runs of the discrete program in (25) from any state satisfying (27) satisfy
the postcondition 0 h h H.
Note 9 (Intermediate conditions as contracts for sequential composition). For a
HP that is a sequential composition ; an intermediate condition is a formula that
characterizes the intermediate states in between HP and . That is, for a dL formula
A [; ]B
an intermediate condition is a formula E such that the following dL formulas are valid:
A []E
and
E []B
The first dL formula expresses that intermediate condition E characterizes the intermediate
states accurately, i.e. E actually holds after all runs of HP from states satisfying A. The
second dL formula says that the intermediate condition E characterizes intermediate states
well enough, i.e. E is all we need to know about a state to conclude that all runs of end up
in B. That is, from all states satisfying E (in particular from those that result by running
from a state satisfying A), B holds after all runs of .
For proving (25), we conjecture that (27) is an intermediate condition, which requires
us to prove the following two dL formulas:
0 h h = H v = 0 g > 0 1 > c 0 [h = v, v = g & h 0]2gh = 2gH v 2
2gh = 2gH v 2 [?h = 0; v := cv ?h 6= 0] (0 h h H)
(28)
A NDR E P LATZER
L4.21
Lets focus on the latter formula. Do we expect to be able to prove it? Do we expect it
to be valid?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L4.22
The second formula of (28) claims that 0 h holds after all runs of ?h = 0; v := cv
?h 6= 0 from all states that satisfy 2gh = 2gH v 2 . That is a bit much to hope for,
however, because 0 h is not even ensured in the precondition of this second formula.
So the second formula of (28) is not valid. How can this problem be resolved? By
adding 0 h into the intermediate condition, thus, requiring us to prove:
0 h h = H v = 0 g > 0 1 > c 0 [h = v, v = g & h 0](2gh = 2gH v 2 h 0)
2gh = 2gH v 2 h 0 [?h = 0; v := cv ?h 6= 0] (0 h h H)
(29)
Proving the first formula in (29) requires us to handle differential equations, which
we will get to later. The second formula in (29) is the one whose proof is discussed first.
12 A Proof of Choice
The second formula in (29) has a nondeterministic choice ( ) as the top-level operator
in its [] modality. How can we prove a formula of the form
A [ ]B
(30)
and
A []B
Using these thoughts on the second formula of (29), we could prove that formula if
we would manage to prove both of the following dL formulas:
2gh = 2gH v 2 h 0 [?h = 0; v := cv] (0 h h H)
2gh = 2gH v 2 h 0 [?h 6= 0] (0 h h H)
(31)
A NDR E P LATZER
L4.23
13 Proofs of Tests
Consider the second formula of (31). Proving it requires us to understand how to handle a test ?H in a modality [?H]. The semantics of a test ?H from Lecture 3
(?H) = {(, ) : |= H}
(32)
says that a test ?H completes successfully without changing the state in any state in
which H holds (i.e. |= H) and fails to run in all other states (i.e. where 6|= H). How
can we prove a formula with a test:
A [?H]B
(33)
This formula expresses that from all initial states satisfying A all runs of ?H reach states
satisfying B. When is there a run of ?H at all? There is a run from state if and only
if H holds in . So the only cases to worry about those initial states that satisfy H
as, otherwise, the HP in (33) cannot execute at all by fails miserably so that the run is
discarded. Hence, we get to assume H holds, as the HP ?H does not otherwise execute.
In all states that the HP ?H reaches from states satisfying A, (33) conjectures that B
holds. Now, by (32), the final states that ?H reaches are the same as the initial state (as
long as they satisfy H so that HP ?H can be executed at all). That is, postcondition B
needs to hold in all states from which ?H runs (i.e. that satisfy H) and that satisfy the
precondition A. So (33) can be proved by proving
AH B
(34)
Now we are left with arithmetic that we need to prove. Proofs for arithmetic and
propositional logical operators such as and will be considered in a later lecture.
For now, we notice that the formula 0 h in the right-hand side of seems justified
A NDR E P LATZER
L4.24
A NDR E P LATZER
L4.25
Exercises
Exercise 1. Let A, B be dL formulas. Suppose A B is valid and A is valid. Is B valid?
Prove or disprove.
Exercise 2. Let A, B be dL formulas. Suppose A B is true in state and A is true in
state . That is, |= A B and |= A. Is B true in state ? Prove or disprove. Is B
valid? Prove or disprove.
Exercise 3. Let be an HP. Let be a state with 6|= . Does 6|= [ ] hold? Prove or
disprove.
Exercise 4. Suppose you have a HP with a CPS contract using multiple preconditions
A1 , . . . , An and multiple postconditions B1 , . . . , Bm :
@requires(A1 )
@requires(A2 )
..
.
@requires(An )
@ensures(B1 )
@ensures(B2 )
..
.
@ensures(Bm )
A NDR E P LATZER
L4.26
References
[Asi42]
[DBL12]
Proceedings of the 27th Annual ACM/IEEE Symposium on Logic in Computer Science, LICS 2012, Dubrovnik, Croatia, June 2528, 2012. IEEE, 2012.
[DLTT13] Patricia Derler, Edward A. Lee, Stavros Tripakis, and Martin Torngren.
Cyber-physical system design contracts. In Chenyang Lu, P. R. Kumar, and
Radu Stoleru, editors, ICCPS, pages 109118. ACM, 2013.
[Flo67]
[Hoa69]
Charles Antony Richard Hoare. An axiomatic basis for computer programming. Commun. ACM, 12(10):576580, 1969.
[Log11]
[Mey92]
A NDR E P LATZER
L4.27
[PCL11]
[Pla07]
[Pla08]
Andre Platzer. Differential dynamic logic for hybrid systems. J. Autom. Reas.,
41(2):143189, 2008. doi:10.1007/s10817-008-9103-8.
[Pla10]
Andre Platzer.
Logical Analysis of Hybrid Systems: Proving Theorems
doi:10.1007/
for Complex Dynamics.
Springer, Heidelberg, 2010.
978-3-642-14509-4.
[Pla12a]
[Pla12b]
[Pla12c]
[Pla13]
[PQ08]
[Pra76]
[XJC09]
Dana N. Xu, Simon L. Peyton Jones, and Koen Claessen. Static contract
checking for haskell. In Zhong Shao and Benjamin C. Pierce, editors, POPL,
pages 4152. ACM, 2009. doi:10.1145/1480881.1480889.
In LICS
A NDR E P LATZER
Lecture Notes on
Dynamical Systems & Dynamic Axioms
Andre Platzer
Carnegie Mellon University
Lecture 5
1 Introduction
Lecture 4 demonstrated how useful and crucial CPS contracts are for CPS. Their role
and understanding goes beyond dynamic testing, though. In CPS, proven CPS contracts are infinitely more valuable than dynamically tested contracts, because dynamical tests of contracts at runtime of a CPS generally leave open very little flexibility for
reacting to them in any safe way. After all, the failure of a contract indicates that some
safety condition that was expected to hold is not longer true. Unless provably sufficient
safety margin and fallback plans remain, the system is already in trouble then.1
Consequently, CPS contracts really shine in relation to how they are proved for CPS.
Understanding how to prove CPS contracts requires us to understand the dynamical
effects of hybrid programs in more detail. This deeper understanding of the effects of
hybrid program statements is not only useful for conducting proofs but also for developing and sharpening our intuition about hybrid programs for CPS. This phenomenon
illustrates a more general point that proof and effect (and/or meaning) are intimately
linked and that truly understanding effect is ultimately the same as, as well as a prerequisite to, understanding how to prove properties of that effect [Pla12c, Pla12a, Pla10].
You may have seen this point demonstrated amply already in other courses from the
Principles of Programming Languages group at CMU.
The route that we choose to get to this level of understanding is one that involves a
closer look at dynamical systems and Kripke models, or rather, the effect that hybrid
programs have on them. This will enable us to devise authoritative proof principles for
differential dynamic logic and hybrid programs [Pla12c, Pla12a, Pla10, Pla08]. While
there are many more interesting things to say about dynamical systems and Kripke
1
Although, in combination with formal verification, the Simplex architecture exploits this relationship of
dynamic contracts for safety purposes [SKSC98].
A NDR E P LATZER
L5.2
structures, this lecture will limit information to the truly essential parts that are crucial
right now and leave more elaboration for later lectures.
More information can be found in [Pla12b, Pla12c] as well as [Pla10, Chapter 2.3].
and
A []B
Note 2 (Proving choices: proof-rule style). Note 1 is captured more concisely in the
following proof rule:
A []B A []B
(R1)
A [ ]B
If we can prove all premises (above rule bar) of a proof rule, then that proof rule infers the
conclusion (below rule bar).
Alas, the way we have been using proof rules so far is the other way around. We had been
looking at a formula such as the second formula of (2) that has the shape of the conclusion
of a rule such as R1. And then we went on trying to prove the premises of that proof rule
instead. This conclusion-to-premise style of using our proof rules is perfectly acceptable
and useful as well. Should we ever succeed in proving the premises of R1, that proof rule
would allow us to infer its conclusion too. In this way, proof rules are even useful in directing us at which formulas we should try to prove next: the premises of the instantiation
of that rule.
A NDR E P LATZER
L5.3
Using these thoughts on the second formula of (2), we could prove that formula using
proof rule R1 if we would manage to prove both of its premises, which, in this instance,
are the following dL formulas:
2gh = 2gH v 2 g > 0 [?h = 0; v := cv] (0 h h H)
2gh = 2gH v 2 g > 0 [?h 6= 0] (0 h h H)
(4)
Before proceeding with proofs of (4), revisit the reasoning that led to the principle in
Note 2. We said that (3) can be justified by proving that, when assuming A, all runs of
lead to states satisfying B and all runs of lead to B states. Is that argument reflected
directly in Note 2?
Kind of, but not quite, because there is a minor difference. Our informal argument
assumed A once and concluded both []B and []B from A. The principle captured in
Note 2 assumes A to prove []B and then, separately, assumes A again to prove []B.
These two arguments are clearly closely related, but still slightly different. Can we
formalize and follow the original argument directly somehow? Or is Note 2 our only
chance?
Following the original argument, we would argue that (3) holds by proving
A ([]B []B)
or, since the parentheses are superfluous according to the usual precedence rules:
A []B []B
(5)
Is there a direct way how we can justify going from (3) to (5)? Preferably one that
simultaneously justifies going from (3) to the formulas identified in Note 2 as well.
These considerations will take us to a more general and more elegant proof principle
than R1, to a more refined understanding of the behavior of nondeterministic choices,
and to a way of justifying proof rules as being sound.
(6)
A NDR E P LATZER
L5.4
[] []
1
( )
Note 3 ( ). The nondeterministic choice can lead to exactly the states to which
either could take us or to which could take us or to which both could lead. The dynamic
effect of a nondeterministic choice is that running it at any time either results in a
behavior of or of . So both the behaviors of and are possible when running .
If we want to understand whether and where dL formula [ ] is true, we need to
understand which states the modality [ ] refers to. In which states does have to
be true so that [ ] is true in state ?
By definition of the semantics, needs to be true in all states that can reach
according to ( ) from for [ ] to be true in . Referring to (6) or looking at
Fig. 1, shows us that this includes exactly all states that can reach from according to
(), hence [] has to be true in . And that it also includes all states that can reach
from , hence [] has to be true in .
Consequently,
|= [] and |= []
(7)
are necessary conditions for
|= [ ]
(8)
That is, unless (7) holds, (8) cannot possibly hold. So (7) is necessary for (8). Are there
any states missing? Are there any states that (8) would require to satisfy , which (7)
does not already ensure to satisfy ? No, because, by (6), does not admit any
behavior that neither nor can exhibit. Hence (7) is also sufficient for (8), i.e. (7)
implies (8).
Thus, when adopting a more logical language again, this justifies:
|= [ ] [] []
This reasoning did not depend on the particular state but holds for all . Therefore,
[ ] [] []
Exciting! We have just proved our first axiom to be sound:
A NDR E P LATZER
L5.5
Lemma 1 ([] soundness). The axiom of choice is sound, i.e. all its instances are valid:
([]) [ ] [] []
Nondeterministic choices split into their alternatives in axiom []. From right to left:
If all runs lead to states satisfying (i.e., [] holds) and all runs lead to states
satisfying (i.e., [] holds), then all runs of HP , which may choose between
following and following , also lead to states satisfying (i.e., [ ] holds). The
converse implication from left to right holds, because can run all runs of and all
runs of , so all runs of (and of ) lead to states satisfying if that holds for all runs
of [].
From now on, every time we see a formula of the form [ ], we can remember
that axiom [] knows a formula, namely [] [] that is equivalent to it. Of course,
whenever we find a formula of the form [ ], we also remember that axiom []
knows a formula, namely [] [] that is equivalent to it, just by instantiation of
axiom [].
Armed with this axiom [] at our disposal, we can now easily do a proof step from
(3) to (5) just by invoking the equivalence that [] justifies. Lets elaborate. We want to
prove:
A [ ]B
(3)
By [], or rather an instance of [] formed by using B for , we know:
[ ]B []B []B
(9)
Since (9) is a valid equivalence, replacing the place where the left-hand side of (9) occurs
in (3) by the right-hand side of (9) gives us a formula that is equivalent to (3):
A []B []B
(5)
After all, according to the valid equivalence (9) justified by axiom [], (5) can be obtained from (3) just by replacing a formula with one that is equivalent.
Actually, stepping back, the same argument can be made to go from (5) to (3) instead
of from (3) to (5). Both ways of using [] are perfectly fine. Although the direction
that gets rid of the operator tends to be much more useful, because it made progress
(getting rid of an HP operator). Yet axiom [] can also be useful in many more situations
than rule R1. For example, if want to prove a dL formula
[ ]A B
where [ ] is on the left-hand side of an implication, then axiom [] justifies that it is
enough to prove the following dL formula instead:
[]A []A B
A NDR E P LATZER
L5.6
This inference cannot be justified with proof rule R1, but would need a separate proof
rule such as
[]A []A B
(R3)
[ ]A B
Yet, axiom [] justifies both R1 and R3 and many other uses of splitting a boxed choice
into a conjunction. Axiom [] is, thus, more fundamental.
A general principle behind the dL axioms is most noticeable in axiom []. All equivalence axioms of dL are primarily intended to be used by reducing the formula on
the left to the (structurally simpler) formula on the right. Such a reduction symbolically decomposes a property of a more complicated system into separate properties
of easier fragments and . This decomposition makes the problem tractable and is
good for scalability purposes. For these symbolic structural decompositions, it is very
helpful that dL is a full logic that is closed under all logical operators, including disjunction and conjunction, for then both sides in [] are dL formulas again (unlike in
Hoare logic [Hoa69]). This also turns out to be an advantage for computing invariants
[PC08, PC09, Pla10], which will be discussed much later in this course.
The definition of soundness was not specific to axiom [], but applies to all dL axioms.
Definition 2 (Soundness). An axiom is sound iff all its instances are valid.
A NDR E P LATZER
L5.7
Formula () is obtained from (x) by substituting for x at all occurrences of x, provided x does not occur in the scope of a quantifier or modality binding x or a variable
of .
Note 7 (Bound variables). A modality containing x := or x outside the scope of tests
?H or evolution domain constraints binds x, because it may change the value of x. A
quantifier x or x also binds variable x.
Substitutions are defined as usual [Pla10, Chapter 2.5.1].
(x = )
(x := yx (t))
One possible approach of proving properties of differential equations is to work with
a solution if one is available (and expressible in the logic).
Lemma 4 ([ ] soundness). The solution axiom is sound:
([ ]) [x = ] t0 [x := y(t)]
where y (t) =
In axiom [ ], y() is the solution of the symbolic initial-value problem y (t) = , y(0) = x.
Solution y() is unique since is smooth (Lecture 2). Given such a solution y(), continuous evolution along differential equation x = can be replaced by a discrete assignment x := y(t) with an additional quantifier for the evolution time t. It goes without
saying that variables like t are fresh in [ ] and other axioms and proof rules. Notice that
conventional initial-value problems are numerical with concrete numbers x Rn as initial values, not symbols x [Wal98]. This would not be enough for our purpose, because
we need to consider all states in which the system could start, which may be uncountably many. That is why axiom [ ] solves one symbolic initial-value problem, instead,
because we could hardly solve uncountable many numerical initial-value problems.
What we have so far about the dynamics of differential equations does not yet help
us prove properties of differential equations with evolution domain constraints (a.k.a.
continuous programs) x = & H. It also does not yet tell us what to do if we cannot
solve the differential equation or if the solution is too complicated. We will get to that
matter in a much later lecture.
A NDR E P LATZER
L5.8
(?H)
if |= H
if 6|= H
A NDR E P LATZER
L5.9
Fortunately, there is a much better way that we also identify by investigating the
dynamical system resulting from ; and its induced Kripke structure. Recall from
Lecture 4 that
(; ) = () () = {(, ) : (, ) (), (, ) ()}
(10)
(; )
[][]
()
[]
()
By its semantics, the dL formula [; ] is true in a state iff is true in all states that
; can reach according to (; ) from , i.e. all those states for which (, ) (; ).
Which states are those? And how do they relate to the states reachable by or by ?
They do not relate to those in a way that is as direct as for axiom []. But they still relate,
and they do so by way of (10).
Postcondition has to be true in all states reachable by ; from for [; ] to be
true at . By (10), those are exactly the states to which we can get by running from
an intermediate state to which we have gotten from by running . Thus, for [; ]
to be true at it is necessary that holds in all states to which we can get by running
from an intermediate state to which we can get by running from . Consequently,
[; ] is only true at if [] holds in all those intermediate states to which we can
get from by running . How do we characterize those states? And how can we then
express these thoughts in a single logical formula of dL?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L5.10
If we want to express that [] holds in all states to which we can get to from by
running , then that is exactly what truth of dL formula [][] at means, because this
is the semantics of the modality [].
Consequently,
|= [][] [; ]
Reexamining our argument backwards, we see that the converse implication also holds
|= [; ] [][]
The same argument works for all , so both implications are even valid.
Lemma 6 ([;] soundness). The composition axiom is sound:
([;]) [; ] [][]
Proof. Since (; ) = () (), we have that (, ) (; ) iff (, ) () and
(, ) () for some intermediate state . Hence, |= [; ] iff |= [] for all
with (, ) (). That is |= [; ] iff |= [][].
Sequential compositions are proven using nested modalities in axiom [;]. From right to
left: If, after all -runs, it is the case that all -runs lead to states satisfying (i.e., [][]
holds), then all runs of the sequential composition ; lead to states satisfying (i.e.,
[; ] holds). The converse implication uses the fact that if after all -runs all -runs
lead to (i.e., [][]), then all runs of ; lead to (that is, [; ]), because the runs of
; are exactly those that first do any -run, followed by any -run. Again, it is crucial
that dL is a full logic that considers reachability statements as modal operators, which
can be nested, for then both sides in [;] are dL formulas.
Axiom [;] directly explains sequential composition ; in terms of a structurally simpler formula, one with nested modal operators but simpler hybrid programs. Again,
using axiom [;] by reducing occurrences of its left-hand side to its right-hand side decomposes the formula into structurally simpler pieces, thereby making progress. One
of the many ways of using axiom [;] is, therefore, captured in the following proof rule:
(R9)
A [][]B
A [; ]B
Comparing rule R9 to rule R7, the new rule R9 is much easier to apply, because it does
not require us to first provide an intermediate condition E like R7 would. It also does
not branch into two premises, which helps keeping the proof lean. Is there a way of
reuniting R9 with R7 by using the expressive power of dL?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L5.11
Yes, indeed, there is a very smart choice for the intermediate condition E that makes
def
R7 behave almost as the more efficient R9 would. The clever choice E []B:
A [][]B []B []B
A [; ]B
which trivializes the right premise and makes the left premise identical to that of R9.
nN
( )
[ ]
()
[][ ]
()
()
( )
Lemma 7 ([ ] soundness). The iteration axiom is sound:
([ ]) [ ] [][ ]
Axiom [ ] is the iteration axiom, which partially unwinds loops. It uses the fact that
always holds after repeating (i.e., [ ]), if holds at the beginning (for holds
after zero repetitions then), and if, after one run of , holds after every number of
repetitions of , including zero repetitions (i.e., [][ ]). So axiom [ ] expresses that
[ ] holds iff holds immediately and after one or more repetitions of . The same
axiom [ ] can be used to unwind loops N N times, which corresponds to Bounded
Model Checking [CBRZ01]. If the formula is not valid, a bug has been found, otherwise
N increases. An obvious issue with this simple approach is that we can never stop
increasing N if the formula is actually valid, because we can never find a bug then. A
later lecture will discuss proof techniques for repetitions based on invariants that are
not subject to this issue. In particular, axiom [ ] is characteristically different from the
other axioms discussed in this lecture. Unlike the other axioms, [ ] does not exactly
get rid of the formula on the left-hand side. It just puts it in a different syntactic place,
which does not sound like much progress.2
2
With a much more subtle and tricky analysis, it is possible to prove that [ ] still makes progress [Pla13].
But this is out of scope for our course.
A NDR E P LATZER
L5.12
Bh,v 0 h h H
def
(h = g) (h = v, v = g)
With these abbreviations, (11) is
Ah,v [h = g; (?h = 0; v := cv ?h 0)]Bh,v
Let there be proof:
Ah,v t0 (H g2 t2 = 0 BH g t2 ,c(gt) ) (H g2 t2 0 BH g t2 ,gt )
2
2
[:=]
Ah,v t0 [h := H g2 t2 ] (h = 0 Bh,c(gt) ) (h 0 Bh,gt )
[:=]
Ah,v t0 [h := H g2 t2 ][v := gt] (h = 0 Bh,cv ) (h 0 Bh,v )
[;]
Ah,v t0 [h := H g2 t2 ; v := gt] (h = 0 Bh,cv,) (h 0 Bh,v )
[ ]
Ah,v [h = g] (h = 0 Bh,cv,) (h 0 Bh,v )
[:=]
Ah,v [h = g] (h = 0 [v := cv]Bh,v ) (h 0 Bh,v )
[?],[?]
Ah,v [h = g] [?h = 0][v := cv]Bh,v [?h 0]Bh,v
[;]
Ah,v [h = g] [?h = 0; v := cv]Bh,v [?h 0]Bh,v
[]
Ah,v [h = g][?h = 0; v := cv ?h 0]Bh,v
[;]
Ah,v [h = g; (?h = 0; v := cv ?h 0)]Bh,v
Since each of the steps in this proof are justified by using one of the dL axioms, the
conclusion at the very bottom of this derivation is proved if the premise at the very top
can be proved. That premise
g
g
Ah,v t0 (H t2 = 0 BH g t2 ,c(gt) ) (H t2 0 BH g t2 ,gt )
2
2
2
2
A NDR E P LATZER
L5.13
expands out to the following formula of first-order real arithmetic by expanding the
abbreviations
0hh=H v =0g >01>c0
g
g
g
t0 (H t2 = 0 0 H t2 H t2 H)
2
2
2
g 2
g
g
(H t 0 0 H t2 H t2 H)
2
2
2
In this case, this remaining premise can be easily seen to be valid. The first assumption
H g2 t2 = 0 . . . in the middle line directly implies the first conjunct of its right-hand
side
g
g
0 H t2 H t2 H
2
2
and reduces the second conjunct to 0 H, which the assumption in the first line assumed (0 h = H). Similarly, the first assumption H g2 t2 0 of the last line implies
the first conjunct of its right-hand side
g
g
0 H t2 H t2 H
2
2
and the second conjunct holds by assumption g > 0 from the first line and the real
arithmetic fact that t2 0.
How first-order logic and first-order real arithmetic formulas such as this one can be
proved in general, however, is an interesting topic for a later lecture. For now, we are
happy to report that we have just formally verified our very first CPS. Exciting! We
have found a proof of (11).
Okay, admittedly, the CPS we just verified was only a bouncing ball. And all we
know about it now is that it wont fall through the cracks in the ground nor jump high
up to the moon. But most big steps for mankind start with a small step by someone.
Yet, before we get too carried away, we first need to remember that (11) is just a
single-hop bouncing ball. So theres still an argument to be made about what happens
if the bouncing ball repeats. And a rather crucial argument too, because bouncing balls
let loose in the air tend not to jump any higher without hitting the ground first, which
is where the model (11) stops prematurely, because it is missing a repetition. So lets
put worrying about loops on the agenda for an upcoming lecture.
Yet, theres one more issue with the proof for the bouncing ball that we derived. It
works in a somewhat undisciplined chaotic way, by using dL axioms all over the place.
This liberal proof style can be useful for manual proofs and creative shortcuts. Albeit,
since the dL axioms are sound, even such a liberal proof is a proof. But liberal proofs
are also somewhat unfocused and non-systematic, which makes them unreasonable for
automation purposes and also tends to get people lost if the problems at hand are more
complex than the single-hop bouncing ball. That is the reason why we will investigate
more focused, more systematic, and more algorithmic proofs next.
A NDR E P LATZER
L5.14
10 Summary
The differential dynamic logic axioms that we have seen in this lecture are summarized
in Fig. 2. There are further axioms and proof rules of differential dynamic logic that
later lectures will examine [Pla12c, Pla12a].
Note 13. The following axioms of dL are sound:
[:=] [x := ](x) ()
[?] [?H] (H )
[ ] [x = ] t0 [x := y(t)]
(y (t) = )
[] [ ] [] []
[;] [; ] [][]
[ ] [ ] [][ ]
Exercises
Exercise 1. Explain why the subtle transformation from (1) to (11) was okay in this case.
Exercise 2. Identify which of the assumptions of (11) are actually required for the proof
of (11). Which formulas could we have dropped from 0 h h = H v = 0 g >
0 1 > c 0 and still be able to prove
0 h h = H v = 0 g > 0 1 > c 0[h = g; (?h = 0; v := cv ?h 0)]0 h h H
Exercise 3. Develop an axiom for differential equations with evolution domains in a
style that is similar to [ ]. That is, develop an axiom for [x = & H]. As in [ ], you can
assume to have a unique solution for the corresponding symbolic initial-value problem.
Exercise 4. All axioms need to be proved to be sound. These lecture notes only did
a proper proof for [;]. Turn the informal arguments for the other axioms into proper
soundness proofs using the semantics of dL formulas.
Exercise 5. Would the following be a useful replacement for the [ ] axiom?
[ ] [ ]
A NDR E P LATZER
L5.15
References
[CBRZ01] Edmund M. Clarke, Armin Biere, Richard Raimi, and Yunshan Zhu.
Bounded model checking using satisfiability solving. Form. Methods Syst.
Des., 19(1):734, 2001.
[DBL12]
[Hoa69]
Charles Antony Richard Hoare. An axiomatic basis for computer programming. Commun. ACM, 12(10):576580, 1969.
[PC08]
[PC09]
Andre Platzer and Edmund M. Clarke. Computing differential invariants of hybrid systems as fixedpoints. Form. Methods Syst. Des., 35(1):98
120, 2009. Special issue for selected papers from CAV08. doi:10.1007/
s10703-009-0079-8.
[Pla08]
Andre Platzer. Differential dynamic logic for hybrid systems. J. Autom. Reas.,
41(2):143189, 2008. doi:10.1007/s10817-008-9103-8.
[Pla10]
Andre Platzer.
Logical Analysis of Hybrid Systems: Proving Theorems
doi:10.1007/
for Complex Dynamics.
Springer, Heidelberg, 2010.
978-3-642-14509-4.
[Pla12a]
[Pla12b]
[Pla12c]
[Pla13]
Andre Platzer. A complete axiomatization of differential game logic for hybrid games. Technical Report CMU-CS-13-100R, School of Computer Science, Carnegie Mellon University, Pittsburgh, PA, January, Revised and extended in July 2013.
[SKSC98] Danbing Seto, Bruce Krogh, Lui Sha, and Alongkrit Chutinan. The Simplex
architecture for safe online control system upgrades. In ACC, volume 6,
pages 35043508, 1998.
[Wal98]
A NDR E P LATZER
Lecture Notes on
Truth & Proof
Andre Platzer
Carnegie Mellon University
Lecture 6
1 Introduction
1
Lecture 5 investigated dynamic axioms for dynamical systems, i.e. axioms in differential dynamic logic (dL) that characterize operators of the dynamical systems that dL
describes by hybrid programs in terms of structurally simpler dL formulas. That lecture
did not show all important axioms yet, but still showed enough to prove a property of
a bouncing ball. Yet, theres more to proofs than just axioms. Proofs also have proof
rules for combining fragments of arguments into a bigger proof by proof steps.
Recall that our proof about the (single-hop) bouncing ball still suffered from at least
two issues. It was a sound proof and an interesting proof. But the way we had come up
with the proof was somewhat undisciplined, because we just applied axioms seemingly
at random at all kinds of places all over the logical formulas. After we see such a
proof, that is not a concern. But better structuring would help us find proofs more
constructively. The second issue was that the axioms for the dynamics that Lecture 5
showed us did not actually help in proving the propositional logic and arithmetic parts.
The lecture today addresses both issues by imposing more structure on proofs and,
as part of that, handle the operators of first-order logic that differential dynamic logic
inherits (propositional connectives such as , , ) and quantifiers , ). As part of the
structuring, we will make ample and crucial use of the dynamic axioms from Lecture
5. Yet, they will be used in a more structured way than so far.
These notes are based on [Pla08, Pla10, Chapter 2.5.2], where more information can
be found in addition to more information in [Pla10, Appendix A]. Sequent calculus is
By both sheer coincidence and by higher reason, the title of this lecture turns out to be closely related to
the subtitle of a well-known book on mathematical logic [And02], which summarizes the philosophy
we pursue here in a way that is impossible to improve upon any further: To truth through proof.
A NDR E P LATZER
L6.2
discussed in more detail also in the handbook of proof theory [Bus98]. More resources
and background material on first-order logic is also listed on the course web page.
3 Sequents
Sequent calculus was originally developed by Gerhard Gentzen [Gen35] for studying
properties of natural deduction calculi. Sequent calculus has been used very successfully for numerous other purposes since.
Sequents are essentially a standard form for logical formulas that is convenient for
proving purposes.
A NDR E P LATZER
L6.3
and
, B, A
and
D, C,
Antecedent and succedent are considered as sets, not multisets, so we implicitly adopt
what is called the contraction rule and do not distinguish between the following two
sequents
, A, A
and
, A
nor do we distinguish between
C, C,
and
C,
The only structural rule of sequent calculus that we will find reason to use explicitly
in practice is the weakening proof rule (alias hiding proof rule) that can be used to remove
or hide formulas from the antecedent (Wl) or succedent (Wr), respectively:
(Wr)
,
(Wl)
,
Weakening rules are sound, since it is fine in structural logics to prove a sequent with
more formulas in the antecedent or succedent by a proof that uses only some of those
formulas. This is different in substructural logics such as linear logic.
A NDR E P LATZER
L6.4
,
,
,
(l)
,
, ,
,
, ,
(l)
,
(r)
(r)
, ,
,
, ,
(l)
,
(r)
, ,
,
, ,
(l)
,
(r)
(ax)
, ,
, ,
(cut)
A NDR E P LATZER
L6.5
succedent. Dually: regardless of whether is actually true or false, both cases are covered by proof branches. We only use cuts in an orderly fashion to derive simple rule
dualities and to simplify meta-proofs. In practical applications, cuts are not needed in
theory. But in practice, complex practical applications make use of cuts for efficiency
reasons. Cuts an be used, for example, to simplify arithmetic.
Even though we write sequent rules as if the principal formula (like in r,l)
were at the end of the antecedent or at the beginning of the succedent, respectively, the
sequent proof rules can be applied to other formulas in the antecedent or succedent,
respectively, because we consider their order to be irrelevant.
5 Proofs
The dL calculus has further proof rules. But before investigating those, let us first understand already what a proof is and what it means to prove a logical formula. The
same notion of proof and provability works for propositional logic as it does for differential dynamic logic, except that the latter has more proof rules.2
A formula is provable or derivable (in the dL calculus) if we can find a dL proof
for it that starts with axioms (rule ax) at the leaves and ends with a sequent at the
bottom and that has only used dL proof rules in between. While constructing proofs,
however, we would start with the desired goal at the bottom and work our way
backwards to the subgoals until they can be proven to be valid as axioms (ax). Once all
subgoals have been proven to be valid axioms, they entail their consequences, which,
recursively, entail the original goal . This property of preserving truth or preserving
entailment is called soundness. Thus, while constructing proofs, we work bottom-up
from the goal. When we have found a proof, we justify formulas from the axioms topdown to the original goal.
We write dL iff dL formula can be proved with dL rules from dL axioms. That
is, a dL formula is inductively defined to be provable in the dL sequent calculus if it is
the conclusion (below the rule bar) of an instance of one of the dL sequent proof rules,
whose premises (above the rule bar) are all provable. A formula is provable from a
set of formulas, denoted by dL , iff there is a finite subset 0 for which the
sequent 0 is provable.
Example 1. A very simple (in fact propositional) proof of the formula
v 2 10 b > 0 b > 0 ((v 0) v 2 10)
(1)
is shown in Fig. 2. The proof starts with the proof goal as a sequent at the bottom:
v 2 10 b > 0 b > 0 ((v 0) v 2 10).
and proceeds applying proof rules upwards.
The first (i.e., bottom most) proof step applies proof rule r to turn the implication () to the sequent level by moving the assumption into the antecedent. The next
2
A NDR E P LATZER
L6.6
ax
ax
l 2
v
r
10 b > 0 b > 0
v2
l 2
v
10 b > 0 (v 0), v 2 10
r 2
v
10 b > 0 (v 0) v 2 10
proof step applies rule r to split the proof into the left branch for showing that conjunct b > 0 follows from the assumptions in the antecedent and into the right branch
for showing that conjunct (v 0) v 2 10 follows from the antecedent also. On the
left branch, the proof closes with an axiom ax after splitting the conjunction on the
antecedent with rule l. We mark closed proof goals with , just to indicate that we did
not just stopped writing. The right branch closes with an axiom ax after splitting the
disjunction () in the succedent with rule r and then splitting the conjunction () in
the antecedent with rule l. Now that all branches of the proof have closed (with ax),
we know that all leaves at the top are valid, and, hence, since the premises are valid,
each application of a proof rule ensures that their respective conclusions are valid also.
By recursively following this derivation from the leaves at the top to the original root at
the bottom, we see that the original goal is valid and formula (1) is, indeed, true under
all circumstances (valid).
While this proof does not show anything particularly exciting, because it only uses
propositional rules, it shows how a proof can be built systematically in the dL calculus
and gives an intuition as to how validity is inherited from the premises to the conclusions.
A NDR E P LATZER
L6.7
[] [],
[ ],
, [] []
([]l)
, [ ]
The sequent proof rules []r,[]l are more systematic in that they orient the use of
the axiom [] in the direction that makes formulas structurally simpler. Without such
direction, proofs could apply axiom [] from left to right and then from right to left and
from left to right again forever without making any progress. That does not happen
with []r,[]l, because they cannot simply go back.3 Furthermore, the sequent rules
[]r,[]l focus the application of axiom [] to the top level of sequents. That is, []r,[]l
can only be used for formulas of the succedent or antecedent, respectively, that are
of the form [ ], not to any subformulas within that happen to be of this form.
Abiding both of those restrictions imposes more structure on the proof, compared to
the proof we produced in Lecture 5.
Reconsidering the contract-type rules from Lecture 4, we could have turned [] into
the following two sequent proof rules instead of into []r,[]l:
[], [],
(R14)
[ ],
, [], []
(R15)
, [ ]
These rules R14,R15 already split into separate subgoals (R14) or separate formulas
(R15), respectively. It would be fine to use sequent rules R14,R15 instead of []r,[]l,
and, in fact, earlier versions of KeYmaera did. The disadvantage of rules R14,R15 compared to []r,[]l is that rules R14,R15 have a less obvious relation to axiom [] and that
they are asymmetric (they both look surprisingly different). This nuisance is overcome
in []r,[]l, from which rules R14,R15 follow immediately with just one more application of rules r or l, respectively. Thus, []r,[]l are more elementary and more atomic
in that they isolate the proof-theoretical meaning of [ ], as opposed to already incorporating parts of the meaning of as well, which is what propositional rules r,l
are supposed to capture.
The other dL axioms from Lecture 5 translate into sequent calculus proof rules in the
same way. The dynamic modality rules transform a hybrid program into structurally
simpler logical formulas by symbolic decomposition.
For Fig. 3, we adopt a convention to simplify notation. Instead of rules []r,[]l, Fig. 3
shows a single symmetric rule [] that does not mention the sequent sign :
([]r)
[] []
[ ]
This is abbreviated notation to say that the same rule from a conclusion with a formula
[ ] in either antecedent or succedent can be proved from a premise with formula
3
Albeit, going back is still possible indirectly when using a reasonably creative cut. But that requires an
intentional extra effort to do so.
A NDR E P LATZER
L6.8
[] [] in the antecedent or succedent, respectively. That is, we consider the symmetric rule [] as an abbreviation for the two rules []r,[]l. Fig. 3 lists a single symmetric rule [] but we pretend it had both rules []r,[]l. The same applies to the other
symmetric rules in Fig. 3, which each have a version of the rule for the antecedent and
a version of the rule for the succedent. The antecedent version of [;] is called [;]l, its
succedent version is called [;]r. The antecedent version of [ ] is called [ ]l, its succedent
version is called [ ]r and so on.
hihi
h; i
[][]
([;])
[; ]
hi hi
(hi)
h i
[] []
([])
[ ]
(h;i)
x
hih i
(h:=i)
h i
hx := i
[][ ]
x
([n ])
([:=])
[ ]
[x := ]
H
t0 (0tt hx := y(t)iH) hx := y(t)i 1
(h?i)
(h i)
h?Hi
hx = & Hi
t [x := y(t)]H) [x := y(t)]
H
t0
(0
t
1
([?])
([ ])
[?H]
[x = & H]
(hn i)
t and t are fresh logical variables and hx := y(t)i is the discrete assignment belonging to the solution y
of the differential equation with constant symbol x as symbolic initial value.
A NDR E P LATZER
L6.9
uses the fact that holds after repeating (i.e., h i), if holds at the beginning
(for holds after zero repetitions then), or if, after one execution of , holds after
any number of repetitions of , including zero repetitions (i.e., hih i). So rule hn i
expresses that for h i to hold, must hold either immediately or after one or more
repetitions of . Rule [n ] is the dual rule expressing that must hold after all of those
combinations for [ ] to hold.
Tests are proven by showing (with a conjunction in rule h?i) or assuming (with an
implication in rule [?]) that the test succeeds, because test ?H can only make a transition
when condition H actually holds true. Thus, for dL formula h?Hi, rule h?i is used
to prove that H holds true (otherwise there is no transition and thus the reachability
property is false) and that holds after the resulting no-op. Rule [?] for dL formula
[?H], in contrast, assumes that H holds true (otherwise there is no transition and thus
nothing to show) and shows that holds after the resulting no-op.
Given first-order definable flows for their differential equations, proof rules h i,[ ]
handle continuous evolutions. These flows are combined in the discrete jump set x := y(t).
Given a solution x := y(t) for the differential equation system with symbolic initial values x1 , . . . , xn , continuous evolution along differential equations can be replaced by a
discrete jump hx := y(t)i with an additional quantifier for the evolution time t. The
effect of the constraint on H is to restrict the continuous evolution such that its solution x := y(t) remains in the evolution domain H at all intermediate times t t. This
constraint simplifies to true if the evolution domain restriction H is true, which makes
sense, because there are no special constraints on the evolution (other than the differential equations) if the evolution domain region is described by true, hence the full space
Rn . A notable special case of rules [ ] and h i is when the evolution domain H is true:
t0 hx := y(t)i
= 1 , . . , xn = n ]
[x1
t0 hx := y(t)i
= 1 , . . , xn = n i
(2)
hx1
(r)
1
2
(s(X1 , . . , Xn )), 2
x (x),
, (s(X1 , . . , Xn )) 2
(l)
, x (x)
(r)
A NDR E P LATZER
L6.10
KeYmaera does not actually keep x (x) around in the succedent for rule r and, for a fundamental
reason [Pla08], does not have to. The same holds for rule l, where KeYmaera does not keep x (x)
around in the antecedent, because it does not have to. That means, however, that if you conjecture to
produce the right instance, and your conjecture turns out wrong during the proof, then you have to go
back in the proof and undo your instantiation with .
A NDR E P LATZER
L6.11
8 Real Arithmetic
We will see more details on the handling of real arithmetic in a later lecture. In a nutshell, QE() denotes the use of real arithmetic on formula . That is, for a formula of
first-order real arithmetic, QE() is a logical formula that is equivalent to but simpler,
because QE() is quantifier-free.
Theorem 2 (Quantifier elimination). The first-order theory of real arithmetic admits quantifier elimination that is, with each formula , a quantifier-free formula QE() can be associated
effectively that is equivalent (i.e., QE() is valid) and has no additional free variables or
function symbols. The operation QE is further assumed to evaluate ground formulas (i.e., without variables), yielding a decision procedure for closed formulas of this theory (i.e., formulas
without free variables).
Quantifier elimination yields, e.g., the following equivalence by real arithmetic:
QE(x (ax + b = 0)) (a 6= 0 b = 0).
Both sides are easily seen to be equivalent, i.e.
x (ax + b = 0) (a 6= 0 b = 0)
A NDR E P LATZER
L6.12
because a linear equation with nonzero inhomogeneous part has a solution iff its linear part is nonzero as well. Real arithmetic equivalences can be used in differential
dynamic logic to eliminate quantifiers (or otherwise simplify arithmetic).
With the rule i, we can reintroduce a universal quantifier for a Skolem term s(X1 , . . . , Xn ),
which corresponds to a previously universally quantified variable in the succedent or a
previously existentially quantified variable in the antecedent. The point of reintroducing the quantifier is that this makes sense when the remaining formulas are first-order
in the quantified variable so that they can be handled equivalently by quantifier elimination in real-closed fields. When we have proven the subgoal (with for all X) then
this entails the goal for the particular s(X1 , . . . , Xn ). In particular, when we remove a
quantifier with r,l to obtain a Skolem term, we can continue with other proof rules to
handle the dynamic modalities and then reintroduce the quantifier for the Skolem term
with i once quantifier elimination for real arithmetic becomes applicable.
The dual rule i can reintroduce an existential quantifier for a free logical variable
that was previously existentially quantified in the succedent or previously universally
quantified in the antecedent. Again, this makes sense when the resulting formula in
the premise is first-order in the quantified variable X so that quantifier elimination can
eliminate the quantifier equivalently. When we remove a quantifier with r,l to obtain
a free logical variable, we can continue using other proof rules to handle the dynamic
modalities and then reintroduce the quantifier for the free logical variable with i once
quantifier elimination is applicable.
V
QE(X i (i i )) 2
QE(X ((X) (X)))
1
(i)
(i)
(s(X1 , . . , Xn )) (s(X1 , . . , Xn ))
1 1 . . . n n
1
2
X is a new logical variable. Further, QE needs to be defined for the formula in the premise.
Among all open branches, free logical variable X only occurs in the branches i i . Further, QE
needs to be defined for the formula in the premise, especially, no Skolem dependencies on X can
occur.
Bh,v 0 h h H
def
(h = g) (h = v, v = g)
And the single-hop bouncing ball formula from Lecture 5:
Ah,v [h = g; (?h = 0; v := cv ?h 0)]Bh,v
We only consider a simpler formula instead:
Ah,v [h = g]Bh,v
(3)
A NDR E P LATZER
L6.13
ax
Ah,v , r0 0rr
l
Ah,v , r0, 0rr [h := H g2 s2 ]h 0
l
Ah,v , r0, 0sr [h := H g2 s2 ]h 0
r
Ah,v , r0
r
Ah,v
r
Ah,v
[ ]r
Ah,v
r
[:=]r
We just wrote that the left premise closes by ax, except that
Ah,v , r0 0rr
is not exactly an instance of the ax rule, so even here we need simple arithmetic to
conclude that 0 r r is the same as r 0, at which point that premise turns into a
literal instance of ax
Ah,v , r0 r0
A full formal proof and a KeYmaera proof, thus, need an extra proof step of arithmetic
in the left premise.
The right premise is
g
Ah,v , r0, H s2 h 0 BH g r2 ,gt
2
2
which, when resolving abbreviations turns into
g
g
g
0 h h = H v = 0 g > 0 1 > c 0, r0, H s2 h 0 0 H r2 H r2 H
2
2
2
This sequent proves using r plus simple arithmetic for the left branch resulting from
r and a little more arithmetic on the right branch resulting from r. Finishing the
above sequent proof up as indicated shows that dL formula (3) is provable.
A NDR E P LATZER
L6.14
Wl
11 Summary
The differential dynamic logic sequent proof rules that we have seen in this lecture are
summarized in Fig. 5. They turn out to be sound [Pla08]. Yet, the notion of soundness
for axioms that we investigated in Lecture 5 does not directly apply to proof rules. We
will investigate soundness of the proof rules in Fig. 5 in a later lecture. There are further
proof rules of differential dynamic logic that later lectures will examine [Pla08].
References
[And02] Peter B. Andrews. An Introduction to Mathematical Logic and Type Theory: To
Truth Through Proof. Kluwer, 2nd edition, 2002.
[Bus98] Samuel R. Buss. An introduction to proof theory. In Samuel R. Buss, editor,
Handbook of Proof Theory, chapter 1, pages 178. Elsevier, 1998.
[Fit96]
[FM99] Melvin Fitting and Richard L. Mendelsohn. First-Order Modal Logic. Kluwer,
Norwell, MA, USA, 1999.
A NDR E P LATZER
L6.15
,
,
,
(l)
,
, ,
,
, ,
(l)
,
(r)
, ,
,
, ,
(l)
,
(r)
hihi
h; i
[][]
([;])
[; ]
hi hi
(hi)
h i
[] []
([])
[ ]
(h;i)
, ,
,
, ,
(l)
,
(r)
(ax)
, ,
, ,
(cut)
(r)
(Wl)
,
(Wr)
hih i
x
(h:=i)
h i
hx := i
[][ ]
x
([n ])
([:=])
[ ]
[x := ]
H
t0 (0tt hx := y(t)iH) hx := y(t)i 1
(h?i)
(h i)
h?Hi
hx = & Hi
H
t0 (0tt [x := y(t)]H) [x := y(t)] 1
([?])
([ ])
[?H]
[x = & H]
(hn i)
(), x (x), 2
x (x),
, (), x (x) 2
(l)
, x (x)
(r)
(s(X1 , . . , Xn )), 3
x (x),
, (s(X1 , . . , Xn )) 3
(l)
, x (x)
(r)
V
QE(X i (i i )), 5
(i)
, 1 1 , . . . , n n ,
t and t are fresh logical variables and hx := y(t)i is the discrete assignment belonging to the solution y
of the differential equation with constant symbol x as symbolic initial value.
2
is an arbitrary term, often a new (existential) logical variable X.
3
s is a new (Skolem) function and X1 , . . , Xn are all (existential) free logical variables of x (x).
4
X is a new logical variable. Further, QE needs to be defined for the formula in the premise.
5
Among all open branches, free logical variable X only occurs in the branches , i i , . Further,
QE needs to be defined for the formula in the premise, especially, no Skolem dependencies on X can
occur.
1
A NDR E P LATZER
L6.16
[Hoa69] Charles Antony Richard Hoare. An axiomatic basis for computer programming. Commun. ACM, 12(10):576580, 1969.
[HS94]
Reiner Hahnle and Peter H. Schmitt. The liberalized -rule in free variable
semantic tableaux. J. Autom. Reasoning, 13(2):211221, 1994.
[Pla08]
Andre Platzer. Differential dynamic logic for hybrid systems. J. Autom. Reas.,
41(2):143189, 2008. doi:10.1007/s10817-008-9103-8.
[Pla10]
Andre Platzer. Logical Analysis of Hybrid Systems: Proving Theorems for Complex
Dynamics. Springer, Heidelberg, 2010. doi:10.1007/978-3-642-14509-4.
[Pla12]
Andre Platzer. Logics of dynamical systems. In LICS, pages 1324. IEEE, 2012.
doi:10.1109/LICS.2012.13.
A NDR E P LATZER
Lecture Notes on
Control Loops & Invariants
Andre Platzer
Carnegie Mellon University
Lecture 7
1 Introduction
Lecture 3 on Choice & Control demonstrated how important control is in CPS and that
control loops are a very important feature for making this control happen. Without
loops, CPS controllers are limited to short finite sequences of control actions, which
are rarely sufficient. With loops, CPS controllers shine, because they can inspect the
current state of the system, take action to control the system, let the physics evolve,
and then repeat these steps in a loop over and over again to slowly get the state where
the controller wants the system to be. Think of programming a robot to drive on a
highway. Would you be able to do that without some means of repetition or iteration?
Probably not, because youll need to write a CPS program that monitors the traffic
situation frequently and reacts in response to what the other cars do on the highway.
Hybrid programs way of exercising repetitive control actions is the repetition operator that can be applied to any hybrid program . The resulting hybrid program
repeats any number of times, nondeterministically.
More information can be found in [Pla12b, Pla12a] as well as [Pla10, Chapter 2.5.2,2.5.4].
2 Control Loops
Recall the little acrophobic bouncing ball from Lecture 4 on Safety & Contracts.
@requires(0 h h = H v = 0)
@requires(g > 0 1 c 0)
@ensures(0 h h H)
(1)
h = v, v = g & h 0;
if(h = 0) v := cv
A NDR E P LATZER
L7.2
The contracts above have been augmented with the ones that we have identified in
Lecture 4 by converting the initial contract specification into a logical formula in differential dynamic logic and then identifying the required assumptions to make it true in
all states:
0hh=H v =0g >01c0
h = v, v = g & h 0; if(h = 0) v := cv
(0 h h H) (2)
Because we did not want to be bothered by the presence of the additional if-then-else
operator, which is not officially part of the minimal set of operators of dL, we simplified
(2) to:
0hh=H v =0g >01c0
h = v, v = g & h 0; (?h = 0; v := cv ?h 6= 0) (0 h h H) (3)
In Lecture 4, we had an informal understanding why (3) is valid (true in all states),
but no formal proof, albeit we proved a much simplified version of (3) in which we
simply threw away the loop. Ignorance is clearly not a correct way of understanding
loops. Lets make up for that now by properly proving (3) in the dL calculus.
Yet, before going for a proof, let us take a step back and understand the role of loops
in more general terms. Their semantics has been explored in Lecture 3 on Choice &
Control and more formally in Lecture 5 on Dynamical Systems & Dynamic Axioms.
The little bouncing ball had a loop in which physics and its bounce control alternated.
The bouncing ball desperately needs a loop for it wouldnt know ahead of time how
often it would bounce. When falling from great heights, it bounces quite a bit. The
bouncing ball also has a controller, albeit a rather impoverished one. All it could do is
inspect the current height, compare it to the ground floor (at height 0) and, if h = 0,
flip its velocity vector around after a little damping by factor c. That is not a whole lot
of flexibility for control choices, but the bouncing ball was still rather proud to serve
such an important role in controlling the bouncing balls behavior. Indeed, without the
control action, the ball would never bounce back from the ground but would keep on
falling foreverwhat a frightful thought for the acrophobic bouncing ball. On second
thought, the ball would not fall for very long without its controller, because of the
evolution domain h 0 for physics h = g & h 0, which would only allow physics
to evolve for time zero if the ball is already at height 0, because gravity would otherwise
try to pull it further down, except that h 0 wont have it. So, in summary, without the
bouncing balls control statement, it would simply fall and then lie flat on the ground
without time being allowed to proceed. That would not sound very reassuring and
certainly not as much fun as bouncing back up, so the bouncing ball is really quite
proud of its control.
This principle is not specific to the bouncing ball, but, rather, quite common in CPS.
The controller performs a crucial task, without which physics would not evolve in the
way that we want it to. After all, if physics did already always do what we want it
to without any input from our side, we would not need a controller in the first place.
A NDR E P LATZER
L7.3
Hence, control is crucial and understanding and analyzing its effect on physics one of
the primary responsibilities in CPS.
Before proving (3), we apply one more simplification that we have also done in Lecture 5, just to save space on the page. We boldly drop the evolution domain constraint
and make up for it by modifying the condition in the second test (Exercise 1):
0hh=H v =0g >01c0
h = v, v = g; (?h = 0; v := cv ?h 0) (0 h h H) (4)
Hold on, why is that okay? Doesnt our previous investigation say that the ball could
suddenly fall through the cracks in the floor if physics insists on evolving for hours
before giving the poor bouncing ball controller a chance to react? To make sure the
bouncing ball does not panic in light of this threat, solve Exercise 1 to investigate this.
3 Proofs of Loops
There is a loop in (4). As we have seen, its behavior is crucial to the bouncing ball. So
lets prove to understand what it does and to see whether we have to be just as nervous
as the bouncing ball about losing it to the earth (if postcondition 0 h is not ensured)
or to the sky (if h H is not ensured).
Abbreviations have served us well in trying to keep proofs onto one page.
def
Ah,v 0 h h = H v = 0 g > 0 1 c 0
def
Bh,v 0 h h H
def
(h = g) (h = v, v = g)
With these abbreviations, the bouncing ball formula (4) turns into:
(4)
This formula is swiftly turned into the sequent at the top using proof rule r:
Ah,v [(h = g; (?h = 0; v := cv ?h 0)) ]Bh,v
r
Ah,v [(h = g; (?h = 0; v := cv ?h 0)) ]Bh,v
This leaves a loop to be worried about. Inspecting our dL proof rules from Lecture 6 on
Truth there is exactly one that addresses loops:
[][ ]
([ ])
[ ]
n
A NDR E P LATZER
L7.4
Ah,v
r
[n ]r
[;]r
Bh,v
Ah,v [h = g; (?h = 0; v := cv ?h 0)][(h = g; (?h = 0; v := cv ?h 0)) ]Bh,v
Ah,v Bh,v [h = g; (?h = 0; v := cv ?h 0)][(h = g; (?h = 0; v := cv ?h 0)) ]Bh,v
Ah,v [(h = g; (?h = 0; v := cv ?h 0)) ]Bh,v
The left subgoal that results from using r closes by very simple arithmetic. The
right subgoal is more of a challenge to prove. We can solve the differential equation
and proceed using [ ]r, which will produce a quantifier that r can handle and leaves us
with a sequent that we need to consider further to prove.
4 Loops of Proofs
After a lot of proof effort, the above sequent prove continues so that the modalities
. . . [h = g][?h = 0; v := cv ?h 0]
can be handled. But there is still a loop in the postcondition . How can we prove that
postcondition, then? Investigating our proof rules, there is exactly one that addresses
loops: [n ]r again. If we use [n ]r again, what will happen?
Recall from Lecture 5
[
(n )
with n+1 n ; and 0 ?true
( ) =
nN
( )
[ ]
()
[][ ]
()
()
( )
Lemma 1 ([ ] soundness). The iteration axiom is sound:
([ ]) [ ] [][ ]
Using proof rule [n ]r on the succedent of a sequent has the same effect as using axiom
[ ] from left-hand side to right-hand side. Axiom [ ] can be used to turn a formula
A [ ]B
(5)
into
A B [][ ]B
What happens if we use that axiom [ ] again?
A NDR E P LATZER
L7.5
Recall that, unlike sequent proof rules such as [n ]r, axioms do not say where they can
be used, so we might as well use them anywhere in the middle of the formula. Hence
using axiom [ ] on the inner loop yields:
A B [](B [][ ]B)
Lets do that again and use [ ] to obtain
A B [](B [](B [][ ]B))
(6)
This is all very interesting but wont exactly get us any closer to a proof, because we
could keep expanding the star forever that way. How do we ever break out of this
loop of never-ending proofs?
Before we get too disillusioned about our progress with [ ] so far, notice that (6) still
allows us to learn something about and whether it always satisfies B when repeating
. Since [ ] is an equivalence axiom, formula (6) still expresses the same thing as (5),
i.e. that B always holds after repeating when A was true in the beginning. Yet, (6)
explicitly singles out the first 3 runs of . Lets make this more apparent by recalling
([]) [](B ) []B []
Using this valid equivalence turns (6) into
A B []B [][](B [][ ]B)
Using [] again gives us
A B []B []([]B [][][ ]B)
Using [] once more gives
A B []B [][]B [][][][ ]B
(7)
Looking at it this way, (7) could be more useful than the original (5), because, even
though both are equivalent, (7) explicitly singles out the fact that B has to hold initially,
after doing once, after doing twice, and that [ ]B has to hold after doing three
times. Even if we are not quite sure what to make of the latter [][][][ ]B, because it
still involves a loop, we are quite certain how to understand and handle the first three:
A B []B [][]B
(8)
If this formula is not valid, then, certainly, neither is (7) and, thus, neither is the original
(5). Hence, if we find a counterexample to (8), we disproved (7) and (5). That can
actually be rather useful.
Yet, if (8) is still valid, we do not know whether (7) and (5) are, since they involve
stronger requirements (B holds after any number of repetitions of ). What can we do
then? Simply unroll the loop once more by using [ ] on (6) to obtain
A B [](B [](B [](B [][ ]B)))
(9)
A NDR E P LATZER
L7.6
(10)
By sufficiently many uses of axiom [], (9) and (10) are both equivalent to
A B []B [][]B [][][]B [][][ ]B
(11)
which we can again examine to see if we can find a counterexample to the first part
A B []B [][]B [][][]B
If yes, we disproved (5), otherwise we use [ ] once more.
This process of iteratively unrolling a loop with either axiom [ ] or rule [n ]r is called
Bounded Model Checking and has been used very successfully, e.g., in the context of finitestate systems [CBRZ01]. The same principle can be useful to disprove properties of
loops in differential dynamic logic by unwinding the loop.
(11)
to recall that there was a derivation involving one use of r and 4 uses of r from the
four premises to the single conclusion without saying which derivation it was exactly.
Mentioning r 4 times seems a bit repetitive, so simply abbreviate this as:
AB
r,r
A NDR E P LATZER
L7.7
How could we prove the premises? Sect. 4 investigated one way, which essentially
amounts to Bounded Model Checking. Can we be more clever and prove the same
premises in a different way? Preferably one that is more efficient?
There is to much we can do to improve the way we prove the first premise. We simply
have to bite the bullet and do it, armed with all our knowledge of arithmetic. But its
actually very easy at least for the bouncing ball. Besides, no dynamics has actually
happened yet in the first premise, so if we despair in proving this one, the rest cannot
become any easier either. For the second premise, there is not much that we can do,
because we will have to analyze the effect of the loop body running once at least in
order to be able to understand what happens if we run repeatedly.
Yet, whats with the third premise A [][]B? We could just approach it as is and
try to prove it directly using the dL proof rules. Alternatively, however, we could try
to take advantage of the fact that it is the same hybrid program that is running in the
first and the second modality. Maybe they should have something in common that we
can exploit as part of our proof?
How could that work? Can we possibly find something that the is true after the
first run of and is all we need to know about the state for []B to hold? Can we
characterize the intermediate state after the first and before the second ? Suppose
we manage to do that and identify a formula E that characterizes the intermediate state
in this way. How do we use intermediate condition E to simplify our proof?
Recall the intermediate condition contract version of the sequential composition proof
rule from Lecture 4 and Lecture 5.
(R4)
A []E E []B
A [; ]B
Lecture 5 ended up dismissing the intermediate contract rule R4 in favor of the more
general axiom
([;]) [; ] [][]
But, let us revisit R4 and see if we can learn something from its way of using intermediate condition E. The first obstacle is that the conclusion of R4 does not match the
form we need for A [][]B. Thats not a problem in principle, because we could use
axiom [;] backwards from right-hand side to left-hand side in order to turn A [][]B
into
A [; ]B
and then use rule R4. However, this is what we wanted to stay away from, because using the axioms both forwards and backwards can get our proof search into trouble because we might loop around trying to find a proof forever without making any progress
by simply using [;] forwards and then backwards and then forwards again and so on
until the end of time. That does not strike us as useful. Instead, well adopt a proof rule
that has some of the thoughts of R4 but is more general. It is called generalization:
[],
([]gen )
[],
A NDR E P LATZER
L7.8
Rule []gen on the third premise A [][]B with the intermediate condition E for
that we assume to have identified
[]gen
A []E
E []B
A [][]B
Let us try to use this principle to see if we can find a way to prove
A B [](B [](B [](B [][ ]B)))
AB
r
(9)
A NDR E P LATZER
L7.9
( )
[]
()
()
()
Lemma 2 (Induction). The induction rule is sound:
(ind )
, []
[ ],
First observe that the inductive invariant (which we called E in the previous examples)
occurs in all premises but not in the conclusion of ind . The first premise of ind says
that the initial state, about which we assume (and that does not hold), satisfies the
invariant . The second premise of ind shows that the invariant is inductive. That
is, whenever was true before running the loop body , then is always true again
after running . The third premise of ind shows that the invariant is strong enough
to imply the postcondition that the conclusion was interested in.
Rule ind says that holds after any number of repetitions of if an invariant holds
initially (left premise) and invariant remains true after one iteration of (middle
premise), and invariant finally implies the desired postcondition (right premise).
If is true after executing whenever has been true before (middle premise), then,
if holds in the beginning (left premise), will continue to hold, no matter how often
we repeat in [ ], which is enough to imply [ ] if implies .
Taking a step back, these three premises correspond exactly to the proof steps that 15122 Principles of Imperative Computation used to show that the contract of a function
with a @requires contract (and not ), @ensures contract , and a loop invariant
is correct. Now, we have this reasoning in a more general and formally more precisely
defined context.
A NDR E P LATZER
L7.10
(12)
h = v, v = g & h 0;
(?h = 0; v := cv ?h 0)) @invariant(2gh = 2gH v 2 h 0)
Let us again use abbreviations:
def
Ah,v 0 h h = H v = 0 g > 0 1 c 0
def
Bh,v 0 h h H
def
(h = . . . ) (h = v, v = g & h 0)
def
Ah,v Eh,v
ind
A NDR E P LATZER
L7.11
a proof whose pieces we have seen in previous lectures (Exercise 2). The third premise
Eh,v , h = 0 Eh,cv is
2gh = 2gH v 2 h 0, h = 0 2gh = 2gH (cv)2 h 0
which would prove easily if we knew c = 1. Do we know c = 1? No we do not know
c = 1, because we only assumed 1 c 0 in Ah,v . But we could prove this third
premise easily if we would change the definition of Ah,v around to include c = 1. Note
that even then, however, we still need to augment Eh,v to include c = 1 as well, since we
otherwise would have lost this knowledge before we need it in the third premise. The
fourth premise, Eh,v , h 0 Eh,v proves whatever the abbreviations stand for simply
using the axiom rule ax. Finally, the fifth premise Eh,v Bh,v , which is
2gh = 2gH v 2 h 0 0 h h H
proves easily with arithmetic as long as we know g > 0. This condition is already included in Ah,v . But we still managed to forget about that in our intermediate condition.
So, again, g > 0 should have been included in the invariant Eh,v , which should have
been defined as
def
A NDR E P LATZER
L7.12
def
[] []
For example, using a cut with [ ], rule ind can be derived from ind and []gen
as follows (using weakening Wl,Wr without notice):
[]
[]gen
[ ] [ ]
,
[ ]
r
l
[ ],
, [ ] [ ],
cut
[ ],
ind
Hence ind is a derived rule, because it can be derived using ind and some other rules.
Thus, ind is not necessary in theory, but still useful in practice.
Yet, now, in order to derive rule ind out of the more fundamental ind, we had to add
the revised generalization rule []gen. Is that any easier? Well it is, because []gen actually makes []gen unnecessary by another smart argument using a cut with the desired
formula [].
[]gen
[] []
[],
Wr
Wl,Wr
[], [],
, [] [],
cut
[],
This leaves exactly the premises of rule []gen , making []gen a derived rule. Whenever
we need []gen , we could simply expand the proof out in the above form to reduce it
just a proof involving []gen and cut and weakening.
These are two illustrations how creative uses of cuts can suddenly make proves and
concepts easier. A phenomenon that we will see in action much more often in this
course.
A NDR E P LATZER
L7.13
Before you despair that you would have to derive ind and []gen every time you
need them: that is not the case. The theorem prover KeYmaera is very well aware of
how useful both versions of the proof rules are and has them at your disposal. For
theoretical investigations, however, as well as for understanding the truly fundamental
reasoning steps, it is instructive to see that ind and []gen are fundamental, while the
others are mere consequences.
Exercises
Exercise 1 (Give bouncing ball back its evolution domain). Explain why the transformation from (3) to (4) was okay in this case.
Exercise 2. Give a sequent proof for
2gh = 2gH v 2 h 0 [h = v, v = g & h 0](2gh = 2gH v 2 h 0)
Does this property also hold if we remove the evolution domain constraint h 0? That
is, is the following formula valid?
2gh = 2gH v 2 h 0 [h = v, v = g](2gh = 2gH v 2 h 0)
Exercise 3. To develop an inductive proof rule, we have started systematic unwinding
considerations from formula (9) in Sect. 5. In lecture, we started from the form (11)
instead and have seen that that takes us to the same inductive principle. Which of
the two ways of proceeding is more efficient? Which one produces less premises that
are distractions in the argument? Which one has less choices of different intermediate
conditions Ei in the first place?
References
[CBRZ01] Edmund M. Clarke, Armin Biere, Richard Raimi, and Yunshan Zhu.
Bounded model checking using satisfiability solving. Form. Methods Syst.
Des., 19(1):734, 2001.
[Pla10]
Andre Platzer.
Logical Analysis of Hybrid Systems: Proving Theorems
for Complex Dynamics.
Springer, Heidelberg, 2010.
doi:10.1007/
978-3-642-14509-4.
[Pla12a]
[Pla12b]
A NDR E P LATZER
Lecture Notes on
Events & Delays
Andre Platzer
Carnegie Mellon University
Lecture 8
1 Introduction
Lecture 3 on Choice & Control demonstrated the importance of control and loops in
CPS models, Lecture 5 on Dynamical Systems & Dynamic Axioms presented a way of
unwinding loops iteratively to relate repetition to runs of the loop body, Lecture 6 on
Truth & Proof showed a corresponding way of unwinding loops in sequent calculus,
and Lecture 7 on Control Loops & Invariants finally explained the central proof principle for loops based on induction.
That has been a lot of attention on loops, but there are even more things to be learned
about loops. Not by coincidence, because loops are one of the difficult challenges in
CPS. The other difficult challenge comes from the differential equations. If the differential equations are simple and there are no loops, CPS suddenly become easy (they are
even decidable).
This lecture will focus on how the two difficult parts of CPS interact: how loops interface with differential equations. That interface is ultimately the connection between the
cyber and the physical part, which, as we know since Lecture 2 on Differential Equations & Domains, is fundamentally represented by the evolution domain constraints
that determine when physics pauses to let cyber look and act.
Todays lecture focuses on two important paradigms for making cyber interface with
physics to form cyber-physical systems, which played an equally important role in
classical embedded systems. One paradigm is that of event-driven architecture, where
reactions to events dominate the behavior of the system. The other paradigm is timetriggered control, which use periodic actions to affect the behavior of the system. Both
paradigms fall out naturally from an understanding of the hybrid program principle
for CPS.
These lecture notes are loosely based on [Pla12b, Pla10].
A NDR E P LATZER
L8.2
Munchausian
concerns about how effective ping pong paddles can be for the ball if
itself is in control of the paddle to be used on itself in light of Newtons third law about
opposing forces, let us investigate this situation regardless. After all, it has what it takes
to make control interesting: the dynamics of a physical system and decisions on when
to react how to the observed status of the system.
Lecture 7 developed a sequent proof of the undamped bouncing ball with repetitions:
0hh=H v =0g >01=c
[ h = v, v = g & h 0; (?h = 0; v := cv ?h 0) ](0 h h H) (1)
A NDR E P LATZER
L8.3
also rather dangerous. Moving the ping pong paddle up when the ball was above it to
give it a pat on the bottom was tricky, but when it worked would even make the ball
fly up higher than before. Yet that is what the acrophobic bouncing ball did not enjoy
so much, so it tries to control the ping pong paddle so that the ball only bounces down,
never up.
As a height that the bouncing ball feels comfortable with, it chose 5 and so it wants
to establish 0 h 5 to always hold as its safety condition. The ball further puts the
ping pong paddle at a similar height so that it can actuate somewhere between 4 and 5.
It exercises great care to make sure it would every only move the paddle downwards
when the ball is underneath, never above. Thus, the effect of the ping pong paddle will
be to reverse the balls direction. For simplicity, the ball figures that being hit by a ping
pong paddle might have a similar effect as being hit by the floor, except with a possibly
different factor f > 0 instead of the damping coefficient c.1 So the paddle actuated this
way is simply assumed to have effect v := f v.
Taking these thoughts into account, the ball devises the following HP model and
conjectures safety expressed in the following dL formula:
0hh5v 0g >01c0f >0
h = v, v = g & h 0;
(?h = 0; v := cv ?4 h 5; v := f v ?h 0)
(2)
(0 h 5)
Having taken the Principle of Cartesian Doubt from Lecture 4 on Safety & Contracts
to heart, the aspiring ping-pong ball first scrutinizes conjecture (2) before setting out to
prove it. What could go wrong?
For one thing, (2) allows the right control options of using the paddle by ?4 h
5; v := f v but also always allows the wrong choice ?h 6= 0 when above ground. So if
the bouncing ball is unlucky, the HP in (2) could run so that the middle choice is never
chosen and, if the ball has a large downwards velocity v initially, it will jump back up
higher than 5 even if it was below 5 initially. That scenario falsifies (2) and a concrete
counterexample can be constructed correspondingly, e.g., from initial state with
1
(h) = 5, (v) = 1010 , (c) = , (f ) = 1, (g) = 10
2
How can the bouncing ball bugfix its control and turn itself into a proper ping pong
ball? The problem with the controller in (2) is that it permits too much choice, some
of which are unsafe. Restricting these choices and making them more deterministic is
what it takes to ensure the ping pong paddle is actuated as intended:
0hh5v 0g >01c0f >0
h = v, v = g & h 0;
(?h = 0; v := cv ?4 h 5; v := f v ?h 0 h < 4 h > 5)
1
(0 h 5)
(3)
The real story is quite a bit more complicated, but the bouncing ball does not know any better.
A NDR E P LATZER
L8.4
Recalling the if(E) else statement, the same system can be modeled equivalently:
0hh5v 0g >01c0f >0
h = v, v = g & h 0;
(?h = 0; v := cv ?h 6= 0; if(4 h 5) v := f v)
(0 h 5)
(4)
(0 h 5)
A NDR E P LATZER
L8.5
3 Events in Control
The problem with (4) is that, even though it exercises the right control choice whenever
the controller runs, the model does not ensure the controller would run at all when
needed. The paddle control only runs after the differential equation stops. That is
guaranteed to happen when the ball bounces down to the ground (h = 0) but could
otherwise be any time. Recall from Lecture 2 that the semantics of differential equations
is nondeterministic. The system can follow a differential equation any amount of time
as long as it does not violate the evolution domain constraints. In particular, the HP in
(4) could miss the event 4 h 5 that the ping pong balls paddle control wanted to
react to. The system might simply skip over that region by following the differential
equation h = v, v = g & h 0 obliviously.
How can the HP from (4) be modified to make sure the event 4 h 5 is always
noticed and never missed?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L8.6
The only way to prevent the system from following a differential equation for too
long is to restrict the evolution domain constraint, which is the predominant way to
make cyber and physical interact. Indeed, that is what the evolution domain constraint . . . & h 0 in (4) did in the first place. Even though this domain was introduced
for different reasons (first principle arguments that light balls never fall through solid
ground), its secondary effect was to make sure that the ground controller ?h = 0; v := cv
will never miss the right time to take action and reverse the direction of the ball from
falling to climbing.
Note 1 (Evolution domains detect events). Evolution domain constraints of differential
equations in hybrid programs can detect events. That is, they can make sure the system
evolution stops whenever an event happens on which the control wants to take action.
Without such evolution domain constraints, the controller is not necessarily guaranteed to
execute but may miss the event.
Following these thoughts further indicates that the evolution domain somehow ought
to be augmented with more constraints that ensure the interesting event 4 h 5 will
never be missed accidentally. How can this be done? Should the event be conjoined to
the evolution domain as follows
0hh5v 0g >01c0f >0
h = v, v = g & h 0 4 h 5;
if(h = 0) v := cv else if(4 h 5) v := f v
(0 h 5)
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L8.7
Of course not! This evolution domain would require the ball to always be at height
between 4 and 5, which is hardly the right model. How could the ball ever fall on the
ground and bounce back, this way? It couldnt.
Yet, on second thought, the way the event . . . & h = 0 got detected by the HP in the
first place was not by including h = 0 in the evolution domain constraint, but by including the inclusive limiting constraint . . . & h 0, which made sure the system could
perfectly well evolve outside this event domain h = 0, but that it couldnt just miss
the event rushing past h = 0. What would the inclusion of such an inclusivelimiting
constraint correspond to for the event 4 h 5?
When the ball is hurled up into the sky, the last point at which action has to be taken
to make sure not to miss the event 4 h 5 is h = 5. The corresponding inclusive
limiting constraint h 5 thus should be somewhere in the evolution domain constraint.
0hh5v 0g >01c0f >0
h = v, v = g & h 0 h 5;
if(h = 0) v := cv else if(4 h 5) v := f v
(5)
(0 h 5)
Is this the right model? Is dL formula (5) valid? Will its HP ensure that the critical event
4 h 5 will not be missed out on?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L8.8
Formula (5) is valid. And, yet, (5) is not at all the appropriate formula to consider. It
is crucial to understand why.
So, formula (5) is valid. But why? Because all runs of the differential equation
h = v, v = g & h 0 h 5 remain within the safety condition 0 h 5 by construction. None of them are ever allowed to leave the region h 0 h 5, which, after
all, is their evolution domain constraint. So formula (5) is trivially safe. A more careful
argument involves that, every time around the loop, the postcondition holds trivially,
because the differential equations evolution constraint maintains it by definition, the
subsequent discrete control never changes the only variable h on which the postcondition depends. Hold on, the loop does not have to run but could be skipped over by
zero iterations as well. Yet, in that case, the precondition ensures the postcondition, so,
indeed, (5) is valid, but trivially so.
Note 2 (Non-negotiability of Physics). Usually, it is a good idea to make systems safe
by construction. For computer programs, that is a great idea. But we need to remember
that physics is unpleasantly non-negotiable. So if the only reason why a CPS model is
safe is because we forgot to model all relevant behavior of the real system, then correctness
statements about those inadequate models are not particularly applicable to reality.
One common cause for counterfactual models are too generous evolution domain constraints that rule out physically realistic behavior.
And that is what happened in (5). The bouncing ball got so carried away with trying
not to miss the event 4 h 5 that it forgot to include a behavior in the model that
happens after the event has happened. The evolution domain constraint . . . & h 0
came was in the system for physical reasons: to model the guaranteed bouncing back
on the ground and to prevent the ball from falling through the ground. We added the
evolution domain constraint h 5 for an entirely different reason. It came into play to
model what our controller does, and inaptly so, because our feeble attempt ruled out
physical behavior that could actually have happened in reality.
Lets make up for this by developing a model that has both behaviors, just in different
continuous programs so that the decisive event in the middle could not accidentally
have been missed.
0hh5v 0g >01c0f >0
((h = v, v = g & h 0 h 5) (h = v, v = g & h 5));
if(h = 0) v := cv else if(4 h 5) v := f v (0 h 5)
(6)
Now (6) has a much better model of events than the ill-advised (5). Is (6) valid?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L8.9
When the ball is jumping up from the ground, the model in (6) makes it impossible for
the controller to miss the event 4 h 5, because the only evolution domain constraint
in the HP that applies at the ground is h 0 h 5. And that evolution domain stops
being true above 5. Yet, suppose the ping pong ball was jumping up from the ground
following the continuous program in the left choice and then stopped its evolution
at height h = 4.5, which always remains perfectly within the evolution domain h
0 h 5 and is, thus, allowed. Then, after the sequential composition between the
middle and last line of (6), the controller in the last line of (6) runs, notices that the
formula 4 h 5 for the event checking is true, and changes the velocity according
to v := f v, corresponding to the assumed effect of a pat with the paddle. That is
actually its only choice in such a state, because the controller is deterministic, much
unlike the differential equation. Consequently, the velocity has just become negative
since it was positive before as the ball was climbing up. So the loop can repeat and the
differential equation runs again. Yet, then the differential equation might evolve until
the ball is at height h = 4.25, which will happen since its velocity is negative. If the
differential equation stops then, the controller will run again, determine that 4 h 5
is true still and so take action to change the velocity to v := f v. That will, however,
make the velocity positive again, since it was previously negative as the ball was in the
process of falling. Hence, the ball will keep on climbing now, which, again, threatens
the postcondition 0 h 5. Will this falsify (6) or is it valid?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L8.10
On second thought, that alone still will not cause the postcondition to evaluate to
false, because the only way the bouncing ball can evolve continuously from h = 4.25 is
still by the continuous program in the left choice of (6). And that differential equation
is restricted to the evolution domain h 0 h 5, which causes the controller to run
before leaving h 5. That is, the event 4 h 5 will again be noticed by the controller
so that the ball is ping pong paddle pats the ball back down.
However, the exact same reasoning applies also to the case where the ball successfully made it up to height h = 5, which is the height at which any climbing ball has
to stop its continuous evolution, because it would otherwise violate the evolution domain h 0 h 5. As soon as that happens, the controller runs, notices that the event
4 h 5 came true and reacts with a ping pong paddle to cause v := f v. If, now,
the loop repeats, yet the continuous evolution evolves for duration zero only, which is
perfectly allowed, then the condition 4 h 5 will still be true so that the controller
again notices this event and reacts with ping pong paddle v := f v. That will make
the velocity positive, the loop can repeat, the continuous program on the right of the
choice can be chosen since h 5 holds true, and then the bouncing ball can climb and
disappear into nothingness high up in the sky if only its velocity has been large enough.
Ergo, (6) is not valid. What a pity. And the bouncing ball would have to be afraid of
heights when following the control in (6). How can this problem be resolved?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L8.11
The problem in (6) is that its left differential equation makes sure never to miss out
on the event 4 h 5 but its control may react to it multiple times. It is not even sure
whether each occasion of 4 h 5 should be called an event. But certainly repeated
reaction to the same event according to control (6) causes trouble.
One way of solving this problem is to change the condition in the controller to make
sure it only reacts to the 4 h 5 event when the ball is on its way up, i.e. when its
velocity is not negative. That is what the bouncing ball wanted to ensure in any case.
The ping pong paddle should only be actuated downwards when the ball is flying up.
These thoughts lead to the following variation:
0hh5v 0g >01c0f >0
((h = v, v = g & h 0 h 5) (h = v, v = g & h 5));
if(h = 0) v := cv else if(4 h 5 v 0) v := f v (0 h 5)
(7)
Because the paddle action v := f v will disable the condition v 0 for nonzero velocities, the controller in (7) can only react once to the event 4 h 5 to turn the
upwards velocity into a downwards velocity, scaled by f . Unlike in (6), this control
decision cannot be reverted inadvertently by the controller.
Is dL formula (7) valid?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L8.12
In order to convince ourselves that the ping pong paddle control works as expected,
we simplify the assumptions in formula (7) so that they match the ones in our prior
proofs about bouncing balls in Lecture 7 on Control Loops & Invariants. Those additional assumptions are not all strictly necessary, but simplify the argument somewhat.
0h5v 01c0g >0f 0
((h = v, v = g & h 0 h 5) (h = v, v = g & h 5));
if(h = 0) v := cv else if(4 h 5 v 0) v := f v (0 h 5)
(8)
How could dL formula (8) be proved? The most critical element of a proof is finding
a suitable invariant. What could be the invariant for proving (8)?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L8.13
The formula
5h0
(9)
is an obvious candidate for an invariant. If it is true, it trivially implies the postcondition 0 h 5 and it holds in the initial state. It is not inductive, though, because a state
that satisfies (9) could follow the right differential equation if it satisfies h 5. In that
case, if the velocity is positive, the invariant (9) would be violated immediately. Hence,
at the height h = 5, the control has to make sure that the velocity is negative, so that the
right differential equation in (8) has to stop immediately. Could (9) be augmented with
a conjunction v 0? No that would not work either, because the bounce on the ground
violates that invariant. In fact, the controller literally only ensures v 0 at the event,
which is detected at h = 5 at the latest. Indeed, the dL formula (7) can be proved in the
dL calculus using the invariant
5 h 0 (h = 5 v 0)
This invariant is just strong enough to remember the control choice at the event h =
5 and that the possible range of h is safe. Recall that (global) invariants need to be
augmented with the usual assumptions about the unchanged variables, like c 0 g >
0 f 0.
The model that (8) and the other controllers in this section adhere to is called eventdriven control or also event-driven architecture.
Note 3 (Event-driven control). One common paradigm for designing controllers is the
event-driven architecture, in which the controller runs in response to certain events that
happen in the system. The controller could possibly run under other circumstances as
wellwhen in doubt, the controller simply skips over without any effect if it does not want
to change anything about the behavior of the system. But event-driven controllers assume
they will run for sure whenever certain events in the system happen.
These events cannot be all too narrow, or else the system will not be implementable,
though. For example, it is nearly impossible to build a controller that reacts exactly at the
point in time when the height of the bouncing ball is h = 4.12345. Chances are high that
any particular execution of the system will have missed this particular height. Care must
be taken in event-driven design models also that the events do not inadvertently restrict the
evolution of the system to the behavioral cases outside or after the events have happened.
Those executions must still be verified.
Are we sure in model (8) that events are taken into account faithfully? That depends
on what exactly we mean by an event like 4 h 5. Do we mean that this event
happens for the first time? Or do we mean every time this event happens? If multiple successive runs of the ping pong balls controller see this condition satisfied, do
these count as the same or separate instances of that event happening? Comparing the
validity of (6) with the non-validity of (7) illustrates that these subtleties can have considerable impact on the system. Hence, a precise understanding of events and careful
modeling is required.
A NDR E P LATZER
L8.14
The controller in (8) only takes an action for event 4 h 5 when the ball is on the
way up. Hence, the evolution domain constraint in the right continuous evolution is
h 5. Had we wanted to model the occurrence of event 4 h 5 also when the ball
is on its way down, then we would have to have a differential equation with evolution
domain h 4 to make sure the system does not miss 4 h 5 when the ball is on its
way down either, without imposing that it would have to notice h = 5 already. This
could be achieved by splitting the evolution domain regions appropriately, but was not
necessary for (8) since it never reacts to balls falling down, only those climbing up.
Note 4. Events are a slippery slope and great care needs to be exercised to use them without
introducing an inadequate executional bias into the model.
There is a highly disciplined way of defining, detecting, and reacting to general
events in differential dynamic logic based on the there and back again axiom [Pla12a].
That is, however, much more complicated than the simpler account shown here.
4 Delays in Control
Event-driven control is a useful and intuitive model matching our expectation of having controllers react in response to certain critical conditions or events that necessitate
intervention by the controller. Yet, one of its difficulties is that event-driven control can
be hard or impossible to implement in reality. On a higher level of abstraction, it is very
intuitive to design controllers that react to certain events and change the control actuation in response to what events have happened. Closer to the implementation, this
turns out to be difficult, because actual computer control algorithms do not actually
run all the time, only sporadically every once in a while, albeit sometimes very often.
Implementing event-driven control faithfully would, in principle, require permanent
continuous monitoring of the state to check whether an event has happened. That is
not quite realistic.
Back to the drawing desk. Let us reconsider the original dL formula (4) that we
started out from for designing the event-driven version in (8).
0hh5v 0g >01c0f >0
h = v, v = g & h 0;
if(h = 0) v := cv else if(4 h 5) v := f v
(4)
(0 h 5)
This simplistic formula (4) turned out not to be valid, because its differential equation was not guaranteed to be interrupted when the event 4 h 5 happens. Consequently, (4) needs some other evolution domain constraint to make sure all continuous
evolutions are stopped at some point for the control to have a chance to react to situation changes. Yet, it should not be something like . . . & h 5 as in (8), because
A NDR E P LATZER
L8.15
(10)
In order to bound time by 1, the evolution domain now includes . . . & t 1 and the
variable t is reset to 0 by t := 0 right before the differential equation. Hence, t represents
a local clock measuring how long the evolution of the differential equation was. Its
bound of 1 ensures that physics gives the controller a chance to react at least once per
second. The system could very well stop the continuous evolution more often and
earlier, because there is no lower bound on t in (10). Also see Exercise 1.
Before going any further, lets take a step back to notice an annoyance in the way
the control in (10) was written. It is written in the style that the original bouncing ball
and the event-driven ping pong ball were phrased: continuous dynamics followed by
control. That has the unfortunate effect that (10) lets physics happen before control does
anything, which is not a very safe start. In other words, the initial condition would have
to be modified to assume the initial control was fine. That is a nuisance duplicating
part of the control into the assumptions on the initial state. Instead, lets switch the
statements around to make sure control always happens before physics.
0hh5v 0g =1>01c0f >0
if(h = 0) v := cv else if(4 h 5) v := f v;
t := 0; h = v, v = g, t = 1 & h 0 t 1 (0 h 5)
(11)
Now that dL formula (11) has an upper bound on the time it takes between two
subsequent control actions, is it valid?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L8.16
Even though (11) ensures a bound on how long it may take at most until the controller
inspects the state and reacts, there is still a fundamental issue with (11). We can try to
prove (11) and inspect the non-provable cases in the proof to find out what the issue
is. The controller of (11) runs at least after one second (hence at least once per second)
and then checks whether 4 h 5. But if 4 h 5 was not true when the controller
ran last, there is no guarantee that it will be true when the controller runs next. In fact,
the ball might very well have been at h = 3 at the last controller run, then evolved
continuously to h = 6 within a second and so missed the event 4 h 5 that it was
supposed to detect (Exercise 2). Worse than that, the ping pong ball has then already
become unsafe.
For illustration, driving a car would be similarly unsafe if you would only open your
eyes once a second and monitor whether there is a car right in front of you. Too many
things could have happened in between that should have prompted you to brake.
Note 5 (Delays may miss events). Delays in controller reactions may cause events to
be missed that they were supposed to monitor. When that happens, there is a discrepancy
between an event-driven understanding of a CPS and the real time-triggered implementation. That happens especially for slow controllers monitoring small regions of a fast moving
system. This relationship deserves special attention to make sure the impact of delays on a
system controller cannot make it unsafe.
It is often a good idea to first understand and verify an event-driven design of a CPS
controller and then refine it to a time-triggered controller to analyze and verify that CPS
in light of its reaction time. Discrepancies in this analysis hint at problems that eventdriven designs will likely experience at runtime and they indicate a poor event abstraction.
How can this problem of (11) be solved? How can the CPS model make sure the
controller does not miss its time to take action? Waiting until 4 h 5 holds true is
not guaranteed to be the right course of action for the controller.
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L8.17
The problem with (11) is that its controller is unaware of its own delay. It does not
take into account how the ping pong ball could have moved further before it gets a
chance to react next. If the ball is already close to the ping pong paddles intended
range of actuation, then the controller had better take action already if it is not sure
whether next time will still be fine.
The controller would be in trouble if, in its next control cycle after the continuous
evolution, h > 5. The continuous evolution can take at most 1 time unit, after which
the ball will be at position h + v g2 as we have observed in Lecture 4 by solving the
differential equation. We chose g = 1 for the time-triggered case, so the controller could
be in trouble in the next control cycle if h > 5 21 v holds now. Hence, the idea is to make
the controller now act based on how it estimates the state might have evolved until the
next control cycle. The difference of (6) vs. (7) in the event-driven case indicates that the
controller only wants to trigger action if the ball is flying up. Thus, making (11) aware
of the future in this way leads to:
0hh5v 0g =1>01c0f >0
1
if(h = 0) v := cv else if((h > 5 v) v 0) v := f v;
2
t := 0; h = v, v = g, t = 1 & h 0 t 1 (0 h 5)
(12)
A NDR E P LATZER
L8.18
The controller in formula (12) has been designed based on the prediction that the
future may evolve for 1 time unit. If action will no longer be possible in 1 time unit,
because the event h 5 has passed in that future instant, the controller in (12) takes
action right now already. The issue with that is there is no guarantee that the ping
pong ball will fly for exactly 1 time unit before the controller is asked to act again (and
the postcondition is checked). The controller in (12) checks whether the ping pong ball
could be too far up after one time unit and does not intervene unless that is the case.
Yet, what if the ball flies for 12 time units? Clearly, if the ball will be safe after 1 time
unit, which is what the controller in (12) checks, it will also be save after just 12 time
unit, right?.
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L8.19
Wrong! The ball may well be below 5 after 1 time unit but still could have been above
5 in between the current point of time and 1 time unit from now. Recall Fig. 1 to see how
this can happen.
In order to understand this further, we use the invariant that we have derived for the
bouncing ball in an earlier lecture and then used in Lecture 7 to prove (1).
2gh = 2gH v 2 h 0 c = 1 g > 0
(13)
We assume this invariant to hold in the beginning of the ping pong balls life and also
adopt the global assumptions c = 1 g = 1 f = 1 to simplify the arithmetic.
Substituting the critical height 5 for H in (13) for this instance of parameter choices
leads to the following condition which indicates that the ball could end up climbing too
high
2h > 2 5 v 2
(14)
Adding this condition to the controller (12) leads to:
2h = 2H v 2 0 h h 5 v 0 g = 1 > 0 1 = c 0 1 = f > 0
1
if(h = 0) v := cv else if((h > 5 v 2h > 2 5 v 2 ) v 0) v := f v;
2
t := 0; h = v, v = g, t = 1 & h 0 t 1 (0 h 5)
(15)
A NDR E P LATZER
L8.20
Formula (15) is almost valid. But it is still not valid for a very subtle reason. It is
great to have proof to catch those subtle issues. The controller in (15) takes action for
two different conditions on the height h. However, the ping pong paddle controller
actually only runs in (15) if the ball is not at height h = 0, for otherwise ground control
takes action of reversing the direction of the ball. Now, if the ball is flat on the floor
(h = 0) yet its velocity so incredibly high that it will rush past height 5 in less than
1 time unit, then the ping pong paddle controller will not have had a chance to react
before it is too late, because it does not run on the ground according to (15).
Fortunately, these thoughts already indicate how that problem can be fixed. By turning the nested if-then-else cascade into a sequential compositions of if-then that
will ensure the ping pong paddle controller to run for sure.
2h = 2H v 2 0 h h 5 v 0 g = 1 > 0 1 = c 0 1 = f > 0
1
if(h = 0) v := cv; if((h > 5 v 2h > 2 5 v 2 ) v 0) v := f v;
2
t := 0; h = v, v = g, t = 1 & h 0 t 1 (0 h 5)
(16)
A NDR E P LATZER
L8.21
Yes, formula (16) is valid and can be proved with the invariant
2h = 2H v 2 h 0 h 5
(17)
Yet, is the controller in (16) useful? That is where the problem lies now. The condition
(14) checks whether the ping pong ball could possibly ever fly up to height 5. If this is
ever true, it might be true long before the bouncing ball approaches the critical control
cycle where ping pong paddle action needs to be taken. In fact, if (14) is ever true, it
will also be true in the beginning. After all, the formula (13), from which (14) derived,
is an invariant. That would cause the controller in (16) to take action right away even if
the ping pong ball is still close to the ground and far away from height 5. That would
make the ping pong ball safe, after all (16) is valid, but also rather conservative, and
would not allow the ping pong ball to bounce around as much as it would have loved
to. How can the controller in (16) be modified to resolve this problem?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L8.22
Restrict the use of condition Exercise 1 to slow velocities to only make up for the
occasions that the first controller condition h > 5 21 v misses. Only with slow velocities
(v < 1) does the ball move so slowly that it is near its turning point to start falling down,
and only then could the first condition miss out on the ball being able to have evolve
above 5 before 1 time unit.
2h = 2H v 2 0 h h 5 v 0 g = 1 > 0 1 = c 0 1 = f > 0
1
if(h = 0) v := cv; if((h > 5 v 2h > 2 5 v 2 v < 1) v 0) v := f v;
2
t := 0; h = v, v = g, t = 1 & h 0 t 1 (0 h 5)
(18)
This dL formula is valid and provable with the same invariant (17) that was used to
prove (16). It has a much more aggressive controller than (16), though, so it is more
fun for the ping pong ball to bounce around with it. Recall that (global) invariants
need to be augmented with the usual assumptions about the unchanged variables, like
g = 1 1 = c 1 = f.
Note 6 (Time-triggered control). One common paradigm for designing controllers is
time-triggered control, in which controllers run periodically or pseudo-periodically with
certain frequencies to inspect the state of the system. Time-triggered systems are closer to
implementation than event-driven control. They can be harder to build, however, because
they invariably require the designer to understand the impact of delay on control decisions.
That impact is important in reality, however, and, thus, effort invested in understanding
the impact of time delays usually pays off in designing a safer system that is robust to
bounded time delays.
Exercises
Exercise 1. The HP in (11) imposes an upper bound on the duration of a continuous
evolution. How can you impose an upper bound 1 and a lower bound 0.5?
Exercise 2. Give an initial state for which the controller in (11) would skip over the event
without noticing it.
Exercise 3. The formula (18) with the time-triggered controller of reaction time at most
1 time unit is valid. Yet, if a ball is let loose a wee bit above ground with a very fast
negative velocity, couldnt it possibly bounce back and exceed the safe height 5 faster
than the reaction time of 1 time unit? Does that mean the formula ought to have been
falsifiable? No! Identify why and give a physical interpretation.
Exercise 4. The event-driven controller we designed in Sect. 3 monitored the event 4
h 5. The time-triggered controller in Sect. 4, however, ultimately only took the upper bound 5 into account. How and under which circumstances can you modify the
controller so that it really only reacts for the event 4 h 5.
A NDR E P LATZER
L8.23
Exercise 5. Devise a controller that reacts if the height changes by 1 when comparing
the height before the continuous evolution to the height after. Can you make it safe?
Can you implement it? Is it an event-driven or a time-triggered controller? How does
it compare to the controllers developed in this lecture?
References
[Pla10]
Andre Platzer. Logical Analysis of Hybrid Systems: Proving Theorems for Complex
Dynamics. Springer, Heidelberg, 2010. doi:10.1007/978-3-642-14509-4.
[Pla12a] Andre Platzer. The complete proof theory of hybrid systems. In LICS, pages
541550. IEEE, 2012. doi:10.1109/LICS.2012.64.
[Pla12b] Andre Platzer. Dynamic logics of dynamical systems. CoRR, abs/1205.4788,
2012. arXiv:1205.4788.
A NDR E P LATZER
Lecture Notes on
Proofs & Arithmetic
Andre Platzer
Carnegie Mellon University
Lecture 9
1 Introduction
Lecture 8 on Events & Delays discussed and developed two models for the ping pong
ball whose control was a ping pong paddle. First an event-driven controller and then a
time-triggered controller. Invariants have been identified in Lecture 8 but not proved.
This lecture will study proofs.
This lecture discusses:
What is a proof?
How does arithmetic happen in a proof?
Arithmetic hiding to weaken arithmetic
Instantiating arithmetic quantifiers to the extreme
Updates as delayed substitutions/assignments
Creative cuts for arithmetic
Substituting equations
If-then-else proofs
There are many more interesting things to be discussed about the mysteries of arithmetic and how real arithmetic properties themselves can be proved [PQR09, Pla10,
Appendix D]. That is a topic for a later lecture, though. This lecture focuses on how
arithmetic interfaces with proofs.
A NDR E P LATZER
L9.2
(1)
Lecture 8 on Events & Delays identified the following invariant for this system:
5 h 0 (h = 5 v 0)
This invariant is just strong enough to remember the control choice at the event h =
5 and that the possible range of h is safe. Recall that (global) invariants need to be
augmented with the usual assumptions about the unchanged variables, like c 0 g >
0 f 0.
def
0 h 5 (h = 5 v 0) 1 c 0 g > 0 f 0
Lets use some (slightly awkward) abbreviations to keep proofs onto one page.
def
Ah,v 2h = 2H v 2 0 h h 5 v 0 g = 1 1 = c 1 = f
def
Bh,v 0 h h H
def
h =..5 (h = v, v = g & h 0 h 5)
def
h =..5 (h = v, v = g & h 5)
def
l,r,ax
ind
The left premise (initial case) and the right premise (use case) prove directly by splitting the conjunctions with l,r and then closing by axiom ax. The middle premise
(inductive step for preserving the invariant) requires more work:
A NDR E P LATZER
L9.3
...
...
(2)
t0
0st
[h
:=
..(s)](h
5)
[h
:=
..(t)][if(h=0)
..if(4,
h5)
..]
[ ]r
[h =..5][if(h=0) ..if(4, h5) ..]
l
The top-most step instantiates the universal quantifier s in the antecedent by a smart
choice. That formula in the antecedent expresses that the evolution domain h 0 h 5
holds at all times s between 0 and the duration t of the continuous evolution. That may
very well be true, but what our thinking actually only depends on is that the evolution
domain still holds at the end time, t of the continuous evolution. The fact that the evolution domain was also true before is not so crucial for our argument here, so we simply
instantiate the universally quantifier variable s in the antecedent by the time endpoint
t using rule l.
A NDR E P LATZER
L9.4
Note 1 (Extreme instantiation). The proof rule l for universal quantifiers in the antecedent as well as the rule r for existential quantifiers in the succedent allow instantiation
of the quantified variable x with any term .
, (), x (x) a
(l)
, x (x)
The way this rule is used in KeYmaera is with a direct use of weakening rule Wl to hide
the quantified formula:
, () b
(l)
, x (x)
This instantiation is very helpful if only a single instance is important for the argument. Often, an extremal value for x is all it takes for the proof.
This happens often for quantifiers coming from the handling of evolution domains in
proof rule [ ]r. The proof steps that often help then is instantiation of intermediate time s
by the end time t:
, t0 0tt, [x := y(t)]
l
, t0, 0tt [x := y(t)]H
l
, t0, 0st [x := y(s)]H
r
, t0
r
...
, t0, [x := y(t)]H [x := y(t)]
[x := y(t)]
[x := y(t)]
(0st [x := y(s)]H) [x := y(t)]
t0 (0st [x := y(s)]H) [x := y(t)]
t0 (0st [x := y(s)]H) [x := y(t)]
Continuing the above proof as explained in Note 1 recalls that h := ..(t) abbreviates
the solution (2) and leads to:
, t0, h g2 t2 vt 0, h g2 t2 vt 5
l
, t0, h g2 t2 vt 0 h g2 t2 vt 5
[:=]l
, t0, [h := ..(s)](h 0 h 5)
, t0, 0tt [h := ..(s)](h 0 h 5)
and abbreviate
This formula has gotten a bit lengthy, so abbreviate1 h g2 t2 vt by h
v gt by v. Hence,
v := v)
h := ..(t) (h := h;
But there also is a problem that we have not noticed before. Which proof rule do we
apply next? Sequent proof rules insist on being applied only to formulas on the top
level of the sequent, i.e. directly as a formula of the antecedent or directly to a formula
1
Abbreviating long terms or long formulas by short names can help simplify KeYmaera proofs as well.
A NDR E P LATZER
L9.5
in the succedent. Except for splitting conjunctions in by l, the only other formula
to apply a proof rule to is the single formula in the succedent, which has a [] modality
with an assignment as the top-level operator. Thus, the only proof rule that applies is
[:=]r. Rule [:=]r substitutes the right-hand side of an assignment for the variable x
assigned to.
x
([:=])
[x := ]
For simple arithmetic and propositional formulas, it is obvious what such a substitution
does. It just replaces x by everywhere in the scope of the substitution. That is exactly
when using rule [:=]l in the antecedent in the above
what we have done with h := h
proof.
Yet, the above formula
[h := ..(t)][if(h=0) ..if(4, h5) ..]
in the succedent has a postcondition [if(h=0) ..if(4, h5) ..] with a modality. It is
for h in such a modality which
not necessarily entirely obvious how to substitute h
involves a HP. In this particular case, we could actually perform such a substitution
without much difficulty.
Even though such substitutions can be defined [Pla10, Chapter 2.5.1] with a little bit
of care, we usually stay away from using them.2
KeYmaera would even need to be persuaded to use these substitutions on HPs at all by setting the
advanced option update modalities.
A NDR E P LATZER
L9.6
Note 2 (Excursion: Updates). For that reason, KeYmaera simply postpones the substitution resulting from an assignment according to rule [:=]r,[:=]l,h:=ir,h:=il if the postcondition is not a first-order formula but involves modalities with HPs. What this corresponds
to is, essentially to leave the assignment as is and apply proof rules to the postcondition,
but only in this particular case of assignments! Because that would be a bit confusing
without further notice, KeYmaera changes the notation slightly and turns an assignment
into what it calls an update.
(R4)
{x := }
[x := ]
(R5)
x
{x := }
The meaning of the formula {x := } in the premise of R4 is exactly the same as the
formula [x := ] in the conclusion of R4. The notation {x := } is only meant as a
reminder for the user that KeYmaera decided to put the handling of the assignment by
substitution on hold until the postcondition looks more civilized (meaning: first-order).
KeYmaera collects all the state changes in such an update (or a list of updates). KeYmaera
will then, essentially, just carry the {x := } around with it and apply the sequent proof
rules directly to postcondition until the substitution can be applied (R5) which will make
the update disappear again. Thus, KeYmaera splits the assignment rule [:=] into two parts:
R4 followed by R5.
More information on updates can be found in [Pla08, Pla10, Chapter 2.2,2.3,2.5].
and v and, hence h := ..(t) is just h :=
Recall that we use the abbreviated notation h
v := v.
h;
After using rule R4 to changing the assignment notation into an update notation (remember that this only changes notation because both are equivalent) the above sequent
reads
0, h
5 {h := h;
v := v}[if(h=0) ..if(4, h5) ..]
, t0, h
(3)
Before proceeding with any proof, we need to figure out what to do with the if-then-else
statements. Before doing any proofs, previous lectures, replaced if-then-else statements by other hybrid program statements, which is always possible. In this lecture,
we decide differently and develop a direct proof rule for if-then-else.
(H []) (H [])
(H hi) (H hi)
([if])
(hifi)
hif(H) else i
[if(H) else ]
When following up on a use of the [if] rule in the succedent of a sequent (call the
corresponding sequent rule [if]r) with propositional rules r,r, the sequent splits into
two cases as expected:3
These propositional steps following the [if]r rule are so useful that KeYmaera does them for you right
away. In fact, KeYmaera even jumps from the formula at the bottom directly to the two premises.
A NDR E P LATZER
L9.7
, H []
, H []
r
H []
H []
(H []) (H [])
[if(H) else ],
r
r
[if]r
Indeed, the conjecture at the bottom says that we want to show that all behavior of
a system whose behavior branches by an if-then-else is safe (satisfies ). We do
not know which state we are in, except that we get to assume it satisfies (and the
negation of by the sequent semantics). So there are usually many possible states.
Hence, there is generally no way of knowing whether if-condition H evaluates to true
or false. Hence, we need to consider both options. If H evaluates to true, then runs, so
all behavior needs to be shown to be safe in that case (left premise). If H evaluates to
false, then runs instead, so all behavior needs to be shown to be safe (right premise).
Applying the [if]r rule two times to the sequent (3) yields 3 premises corresponding
to the 3 possible outcomes of the if-then-else statements (Exercise 1):
0, h
5, h
= 0 {h := h;
v := v}[v := cv]
, t0, h
0, h
5, h
6= 0, 4 h
5 v 0 {h := h;
v := v}[v := f v]
, t0, h
(4)
0, h
5, h
6= 0, (4 h
5 v 0) {h := h;
v := v}
, t0, h
Lets address the three branches separately. The first branch of (4) turns into the following using either [:=]r or R4 via R5:
0, h
5, h
= 0 {h := h;
v := c
, t0, h
v }
which gives the following by applying the update using R5 (can also be obtained directly by [:=]r):
0, h
5, h
=00h
5 (h
= 5 c
, t0, h
v 0) 1 c 0 g > 0 f 0
= 0 and implies 0 h
5 and h
=
That proves by arithmetic, because h
6 5 and the
4
other parts prove similarly.
The second branch of (4) turns by either [:=] or via R4 and R5 into:
0, h
5, h
6= 0, 4 h
5 v 0 {h := h;
v := f v}
, t0, h
which R5 turns into
0, h
5, h
6= 0, 4 h
5 v 0 0 h
5 (h
= 5 f v 0) 1 c 0 g > 0 f 0
, t0, h
5
which proves by arithmetic using that f 0 and v 0 as well as the fact that 4 h
Note how abbreviations simplify this proof step compared to what would have happened when ex
panding h.
A NDR E P LATZER
L9.8
A NDR E P LATZER
L9.9
(6)
although there was no proof yet. Recall that (global) invariants need to be augmented
with the usual assumptions about the unchanged variables, like g = 1 1 = c 1 = f .
So lets define the formula we conjecture to be an invariant as:
def
2h = 2H v 2 h 0 h 5 g = 1 1 = c 1 = f
With this invariant, (5) is provable in KeYmaera.
ax
(x y)2 0 y = x
(x), y = x (x)
Wr
=r
(x y)2 0 y = x, (y)
(x), y = x (y)
Wl
Wl
2
2
(x y) 0, (x) y = x, (y)
(x y) 0, (x), y = x (y)
cut
(x y)2 0, (x) (y)
l
(x y)2 0 (x) (y)
r
(x y)2 0 (x) (y)
Indeed, the left premise proves easily using real arithmetic. The right premise proves
comparably easily as well. This proof uses proof rule =r that we discuss next.
A NDR E P LATZER
L9.10
Exercises
Exercise 1. Explicitly complete the proof steps that lead from (3) to the 3 branches identified in the lecture notes by writing a proper sequent derivation. Recall how updates
are delayed substitutions and that they hang around until they can be applied.
Exercise 2. The sequent proof shown in these lecture notes is for the case coming from
the lower dynamics h =..5. This alone does not prove (1). Write a sequent proof for
the missing branches coming from the upper dynamics h =..5.
Exercise 3. Develop a sequent proof for the time-triggered ping pong ball (5). Is it easier
or more difficult than the proof for (1)?
Exercise 4. Relate the event-driven system proof for (1) discussed in lecture to the proof
that KeYmaera produces. What do they have in common? Where do they differ?
References
[Pla08]
Andre Platzer. Differential dynamic logic for hybrid systems. J. Autom. Reas.,
41(2):143189, 2008. doi:10.1007/s10817-008-9103-8.
[Pla10]
Andre Platzer. Logical Analysis of Hybrid Systems: Proving Theorems for Complex
Dynamics. Springer, Heidelberg, 2010. doi:10.1007/978-3-642-14509-4.
A NDR E P LATZER
Lecture Notes on
Differential Equations & Differential
Invariants
Andre Platzer
Carnegie Mellon University
Lecture 10
1 Introduction
Lecture 5 on Dynamical Systems & Dynamic Axioms gave us a first simple proof principle for differential equations if we find a representable solution of the differential equation. The axiom [ ] replaces properties of differential equations with suitably quantified
properties of solutions, with a universal quantifier over all durations of the solution.
Yet, that does not work for all differential equations, because only some of them have
explicit closed-form solutions, and, of those, only very few have solutions that are simple enough to be quantified over without leaving the decidable parts of the resulting
arithmetic.
Lecture 2 on Differential Equations & Domains allows many more differential equations to be part of CPS models than just the ones that happen to have simple solutions.
In fact, in a certain sense, most of the interesting differential equations do not possess
useful closed-form solutions. Todays lecture reinvestigates the way we prove properties of differential equations from a much more fundamental perspective, which will
lead to a way of proving properties of CPS with more general differential equations.
More details can be found in [Pla10a, Pla10b, Chapter 3.5] and also [Pla12b]. Differential invariants were originally conceived in 2008 [Pla10a, Pla08] and later used for an
automatic proof procedure for hybrid systems [PC08].
A NDR E P LATZER
L10.2
vs.
(x = )
How does the differential equation x = compare to the same differential equation in a
loop (x = ) instead? Unlike the differential equation x = , the repeated differential
equation (x = ) can run the differential equation x = repeatedly. Albeit, on second
A NDR E P LATZER
L10.3
thought, does that get the repetitive differential equation (x = ) to any more states
than where the differential equation x = could evolve to?
Not really, because chaining lots of solutions of differential equations from a repetitive differential equation (x = ) together will give a single solution for the same differential equation x = that we could have followed just once all the way.1
Note 2 (Looping differential equations). (x = ) is equivalent to x = , i.e. both
have the same transition semantics. Differential equations are their own loop.2
In light of Note 2, differential equations look somewhat like loops. Like nondeterministic repetitions, differential equations might stop right away. Like nondeterministic repetitions, differential equations could evolve for longer or shorter durations. Like
in nondeterministic repetitions, the outcome of the evolution of the system so far determines what happens next. And, in fact, in a deeper sense, differential equations
actually really do correspond to loops [Pla12a].
With this rough relation in mind, lets advance the dictionary translating differential
equation phenomena into loop phenomena and back. The local description of a differential equation as a relation x = of the state to its derivative corresponds to the local
description of a loop by a repetition operator . The global behavior of a solution of a
differential equation x = corresponds to the full execution of a system that performs
a repetition in a loop . We also say that the local relation x = is the generator of
the global system solution and that the loop body is the generator of the global behavior of repetition of the loop, because both local generators tell us everything about
the system by way of their global interpretation as either differential or repetitive effect. Proving a property of a differential equation in terms of its solution corresponds
to proving a property of a loop by unwinding it (infinitely long) by axiom [n ] from
Lecture 5 on Dynamical Systems & Dynamic Axioms.
Now Lecture 7 on Control Loops & Invariants made the case that unwinding the iterations of a loop can be a rather tedious way of proving properties about the loop,
because there is no good way of ever stopping to unwind, unless a counterexample can
be found after a finite number of unwindings. Lecture 7 introduced induction with invariants instead to prove properties of loops, by, essentially, cutting the loop open and
arguing that the generic state after any run of the loop body has the same characterization as the generic state before. After all these analogous correspondences between
loops and differential equations, the obvious question is what the differential equation
analogue proof concept would be that corresponds to proofs by induction for loops,
which is the premier technique for proving loops.
Induction can be defined for differential equations using what is called differential
invariants [Pla10a, Pla12b]. The have a similar principle as the proof rules for induction
for loops. Differential invariants prove properties of the solution of the differential
1
2
This is related to classical results about the continuation of solutions, e.g., [Pla10b, Proposition B.1].
Beware not to confuse this with the case for differential equations with evolution domain constraints,
which is subtly different.
A NDR E P LATZER
L10.4
equation using only its local generator: the right-hand side of the differential equation.
Note 3 (Correspondence map between loops and differential equations).
loop
differential equation x =
can skip over
can evolve for duration 0
repeat any number n N of times
evolve for any duration 0 r R
effect depends on previous iteration
effect depends on past solution
local generator
local generator x =
full execution trace
global solution
n
proof by unwinding iterations [ ]
proof by solution [ ]
proof by induction with invariant ind
proofs by differential invariants
Recall from Lecture 7:
[
(n )
( ) =
nN
( )
F
()
(ind)
F []F
()
()
F, F []F F
[ ],
A NDR E P LATZER
L10.5
Figure 1: Vector field and one solution of a differential equation that does not enter the
blue regions
many points in time to check. Furthermore, that only considers a single initial sate ,
so proving validity of a formula would require considering every of the uncountably
infinitely many possible initial states and computing a solution in each of them. That is
why this nave approach would not compute.
A similar idea can still be made to work when the symbolic initial-value problem can
be solved with a symbolic initial value x and a quantifier for time can be used, which
is what the solution axiom [ ] does. Yet, even that only works when a solution to the
symbolic initial-value problem can be computed and the arithmetic resulting from the
quantifier for time can be decided. For polynomial solutions, this works, for example. But polynomial come from very simple systems (called nilpotent linear differential
equation systems).
Reexamining the illustration in Fig. 1, we suggest an entirely different way of checking whether the system could ever lead to an unsafe state in F when following the
differential equation x = . The intuition is the following. If there were a vector in
Fig. 1 that points from a safe state in F to an unsafe state F (in the blue region), then
following that vector could get the system into an unsafe F . If, instead, all vectors
point from safe states to safe states in F , then, intuitively, following such a chain of
vectors will only lead from safe states to safe states. So if the system also started in a
safe state, it would stay safe.
Let us make this intuition rigorous to obtain a sound proof principle.
A NDR E P LATZER
L10.6
represent the direction of a vector rotating clockwise in a circle of radius r (Fig. 2):
d2 + e2 = r2 [d = e, e = d]d2 + e2 = r2
(1)
The conjectured dL formula (1) is valid, because, indeed, if the vector (d, e) is initially at
e
r sin = e
d = r cos
Figure 2: One scenario for the rotational dynamics and relationship of vector (d, e) to
radius r and angle
distance r from the origin (0,0), then it will always be when rotating around the origin,
which is what the dynamics does. That is, the point (d, e) will always remain on the
circle of radius r. But how can we prove that? In this particular case, we could possibly
investigate solutions, which are trigonometric functions (although the ones shown in
Fig. 2 are not the only solution). With those solutions, we could perhaps find an argument why they stay at distance r from the origin. But the resulting arithmetic will be
unnecessarily difficult and, after all, the argument for why the simple dL formula (1)
is valid should be easy. And it is, after we have discovered the right proof principle as
this lecture will do.
First, what is the direction into which a continuous dynamical system evolves? The
direction is exactly described by the differential equation, because the differential equation describes in which direction the state evolves at every point in space. So the direction into which a continuous system obeying x = follows from state is exactly
described by the time-derivative of the state being the term , i.e. [[]] . Recall that term
can mention x and other variables so its value [[]] depends on the state .
Note 4. Proving dL formula [x = ]F does not require us to answer where the system
evolves to but how the evolution of the system relates to formula F and the set of states
in which F evaluates to true.
The logical formula F is built from atomic formulas that are comparisons of (polynomial or rational) terms. Let denote such a (polynomial) term in the variable (vector)
A NDR E P LATZER
L10.7
x. The semantics of a polynomial term in a state is the real number [[]] that it evaluates to. In which direction does the value of evolve when following the differential
equation x = for some time? That depends both on the term that is being evaluated
and on the differential equation x = that describes the evolution of x.
Directions of evolutions are described by derivatives, after all the differential equation x = describes that the time-derivative of x is . Lets derive some term of
interest and see what that tells us about how evolves over time. How can we derive
? The term could be built from any of the operators discussed in Lecture 2, to which
we now add division for rational terms to make it more interesting. Let denote the set
of all variables. Terms are defined by the grammar (where , are terms, x a variable,
and r a rational number constant):
, ::= x | r | + | | | /
It is, of course, important to take care that division / only makes sense in a context
where the divisor is guaranteed not to be zero in order to avoid undefinedness. Thus,
we only allow division to be used in a context where the divisor is ensured not to be
zero.
If is a sum a + b, its derivative is the derivative of a plus the derivative of b. If is
a product a b, its derivative is the derivative of a times b plus a times the derivative of
b. The derivative of a rational number constant r Q is zero.3 The other operators are
similar, leaving only the case of a single variable x. What is its derivative?
Before you read on, see if you can find the answer for yourself.
Of course, the derivative of real number constants r R is also zero, but only rational number constants
are allowed in the first-order logic of real arithmetic, more precisely, of real-closed fields.
A NDR E P LATZER
L10.8
The exact value of the derivative of x certainly depends on the state and on the evolution of the system. So for now, we just define the derivative of a variable x to be the
symbol x and consider what to do with it later.
Definition 1 (Derivation). The operator () that is defined as follows on terms is
called syntactic (total) derivation:
(r) = 0
(x) = x
(a + b) = (a) + (b)
(a b) = (a) (b)
for numbers r Q
(2a)
for variable x
(2b)
(a b) = (a) b + a (b)
(2c)
(2d)
(2e)
(2f)
Even though the following names are not crucial for the understanding of this course,
lets briefly align Def. 1 with the algebraic structures from differential algebra [Kol72].
Case (2a) defines number symbols as differential constants, which do not change during
continuous evolution. Their total derivative is zero. Equation (2c) and the Leibniz or
product rule (2e) are defining conditions for derivation operators on rings. The derivative
of a sum is the sum of the derivatives (additivity or a homomorphic property with
respect to addition, i.e. the operator () applied to a sum equals the sum of the operator
applied to each summand) according to equation (2c). Furthermore, the derivative of a
product is the derivative of one factor times the other factor plus the one factor times the
derivative of the other factor as in (2e). Equation (2d) is a derived rule for subtraction
according to a b = a + (1) b and again expresses a homomorphic property, now
with respect to subtraction. In addition, equation (2b) uniquely defines operator ()
on the differential polynomial algebra spanned by the differential indeterminates x . It
says that we understand the differential symbol x as the derivative of the symbol x for
all state variables x . Equation (2f) canonically extends () to the differential field
of quotients by the usual quotient rule. As the base field R has no zero divisors4 , the
right-hand side of (2f) is defined whenever the original division a/b can be carried out,
which, as we assumed, is guarded by b 6= 0.
The derivative of a division a/b uses a division, which is where we need to make sure
not to accidentally divide by zero. Yet, in the definition of (a/b) , the division is by b2
which has the same roots that b has. So b = 0 b2 = 0 is valid for any term b. Hence,
in any context in which a/b was defined, its derivative (a/b) will also be.
Which of the terms should we derive when trying to prove (1)? Since that is not
necessarily clear so far, lets turn the formula (1) around and consider the following
equivalent dL formula instead, which only has a single nontrivial term to worry about:
d2 + e2 r2 = 0 [d = e, e = d]d2 + e2 r2 = 0
4
(3)
In this setting, R have no zero divisors, because the formula ab = 0 a = 0 b = 0 is valid, i.e. a
product is zero only if a factor is zero.
A NDR E P LATZER
L10.9
(4)
Def. 1 makes it possible to derive polynomial and rational terms. Deriving them with
the total derivative operator () does not result in a term over the signature of the
original variables in , but, instead, a differential term, i.e. a term over the extended
def
A NDR E P LATZER
L10.10
()(x)
x0
0
3
x = x
[[x ]] (
A NDR E P LATZER
L10.11
() = [[() ]]()
d (t)(x)
() =
() = [[(x) ]]() .
dt
dt
The derivative exists, because is assumed to be differentiable.
If is of the form a + b, the desired result can be obtained by using the properties of analytic derivatives, synctactic derivations (Def. 1), and valuation of terms
(Lecture 2):
d
([[a + b]](t) )()
dt
d
= ([[a]](t) + [[b]](t) )()
dt
d
d
= ([[a]](t) )() + ([[b]](t) )()
dt
dt
= [[(a + b) ]]()
() is a syntactic derivation
A NDR E P LATZER
L10.12
Proof. The proof is a simple inductive consequence of Lemma 3 using that [[x ]]() = [[]]()
at each time in the domain of .
The operation mapping term to () x is called Lie-derivative of with respect to x = .
Differential substitution of the differential equation d = e, e = d from (3) into (4)
results in
e
(d2 + e2 r2 ) d d
e = (2dd + 2ee 2rr )d e = 2de + 2e(d) + 2rr
A NDR E P LATZER
L10.13
Oops, that did not make all differential symbols disappear, because r is still around,
since r did not have a differential equation in (3). Stepping back, what we mean by a
differential equation like d = e, e = d that does not mention r is that r is not supposed to change. If r is supposed to change during a continuous evolution, there has to
be a differential equation for r.
Note 10 (Explicit change). Hybrid programs are explicit change: nothing changes unless an assignment or differential equation specifies how (compare the semantics from Lecture 3). In particular, if a differential equation (system) x = does not mention z , then
z does not change during x = , so the original system x = and x = , z = 0 are
equivalent.
We will often assume z = 0 without further notice for variables z that do not change
during a differential equation.
Since (3) does not have a differential equation for r, Note 10 implies that its differential
equation d = e, e = d is equivalent to d = e, e = d, r = 0. Hence, when adding
zero derivatives for all unchanged variables, differential substitution of the differential
equation d = e, e = d along with the explicit-change assumption r = 0 into (4) gives
e
d 0
0
(d2 + e2 r2 ) d d
e r = (2dd + 2ee 2rr )d e r = 2de + 2e(d)
(5)
This is good news, because the last part of (5) is a standard term of first-order logic of
real arithmetic, because it no longer has any differential symbols. So we can make sense
of 2de+2e(d) and, by Lemma 4, its value along a solution of d = e, e = d is the same
as that of the derivative (d2 + e2 r2 ) , which, by Lemma 3 is the same as the value
of the time-derivative of the original term d2 + e2 r2 along such a solution. Simple
arithmetic shows that the term 2de + 2e(d) in (5) is 0. Consequently, by Lemma 3 and
Lemma 4, the time-derivative of the term d2 + e2 r2 in the postcondition of (3) is 0
along any solution of its differential equation:
d[[d2 + e2 r2 ]](t)
dt
Lem3
() = [[(d2 + e2 r2 ) ]]()
Lem4
0
= [[(d2 + e2 r2 ) d d
e r ]]()
(5)
= [[2de + 2e(d)]]() = 0
for all times . That means that the value of d2 + e2 r2 never changes during the
rotation, and, hence (3) is valid, because d2 + e2 r2 stays 0 if it was 0 in the beginning,
which is what (3) assumes.
A NDR E P LATZER
L10.14
this particular argument. The argument is not specific to the term d2 + e2 r2 but
works for any other term and for any differential equation x = . This would give us
a soundness proof for the following proof rule.
Lemma 5 (Differential invariant terms). The following special case of the differential
invariants proof rule is sound, i.e. if its premise is valid then so is its conclusion:
x = 0
(DI=0 )
= 0 [x = ] = 0
Proof. Assume the premise x = 0 to be valid, i.e. true in all states. In order to prove
that the conclusion = 0 [x = ] = 0 is valid, consider any state . Assume that
|= = 0, as there is otherwise nothing to show (sequent is trivially true since antecedent evaluates to false). If [0, r] is any time during any solution : [0, r] S of
any duration r R of x = beginning in initial state (0) = , then
d[[]](t)
dt
Lem3
Lem4
premise
2de + 2e(d) 0 = 0
0
(2dd + 2ee 2rr = 0)ed d
e r
DI=0 2
d
+ e2 r2 = 0 [d = e, e = d]d2 + e2 r2 = 0
d2 + e2 r2 = 0 [d = e, e = d]d2 + e2 r2 = 0
The line proof step that This is an exciting development, because, thanks to differential
invariants, the property (3) of a differential equation with a nontrivial solution has a
very simple proof that we can easily check.
A NDR E P LATZER
L10.15
8 Summary
This lecture showed one simple special form of differential invariants: the form where
the differential invariants are terms whose value always stays 0 along all solutions of a
differential equation. The next lecture will investigate more general forms of differential invariants and more advanced proof principles for differential equations.
The most important insight of todays lecture was that complicated behavior of systems defined in terms of real analytic properties and semantics can be captured by
purely syntactical proof principles using derivations. The derivation lemma proved
that the values of syntactic derivations coincides with the analytic derivatives of the
values. The differential substitution lemma allowed us the intuitive operation of substituting differential equations into terms. Proving properties of differential equations
using these simple proof principles is much more civilized and effective than working with solutions of differential equations. The proofs are also computationally easier,
because the proof arguments are local.
Exercises
Exercise 1. What happens in the proof of Lemma 5 if there is no solution ? Show that
this is not a counterexample to proof rule DI=0 , but that the rule is sound in that case.
References
[Kol72] Ellis Robert Kolchin. Differential Algebra and Algebraic Groups. Academic Press,
New York, 1972.
[PC08]
[Pla08]
Andre Platzer. Differential Dynamic Logics: Automated Theorem Proving for Hybrid Systems. PhD thesis, Department of Computing Science, University of
Oldenburg, Dec 2008. Appeared with Springer.
A NDR E P LATZER
L10.16
[Pla12b] Andre Platzer. The structure of differential invariants and differential cut
elimination. Logical Methods in Computer Science, 8(4):138, 2012. doi:10.
2168/LMCS-8(4:16)2012.
A NDR E P LATZER
Lecture Notes on
Differential Equations & Proofs
Andre Platzer
Carnegie Mellon University
Lecture 11
1 Introduction
Lecture 5 on Dynamical Systems & Dynamic Axioms gave us a first simple proof principle for differential equations if we find a representable solution of the differential equation. The axiom [ ] replaces properties of differential equations with suitably quantified
properties of solutions, with a universal quantifier over all durations of the solution.
Yet, that does not work for all differential equations, because only some of them have
explicit closed-form solutions let alone solutions that are simple enough to be quantified over without leaving the decidable parts of the resulting arithmetic.
Lecture 2 on Differential Equations & Domains allows many more differential equations to be part of CPS models than just the ones that happen to have simple solutions.
In fact, in a certain sense, most of the interesting differential equations do not possess
useful closed-form solutions. Todays lecture reinvestigates the way we prove properties of differential equations from a much more fundamental perspective, which will
lead to a way of proving properties of CPS with more general differential equations.
More details can be found in [Pla10a, Pla10b, Chapter 3.5] and also [Pla12b]. Differential invariants were originally conceived in 2008 [Pla10a, Pla08] and later used for an
automatic proof procedure for hybrid systems [PC08].
2 Recall
Recall the following results from Lecture 10 on Differential Equations & Differential
Invariants:
October 2, 2013
A NDR E P LATZER
L11.2
for numbers r Q
(1a)
for variable x
(1b)
(x) = x
(a + b) = (a) + (b)
(a b) = (a) (b)
(a b) = (a) b + a (b)
(1c)
(1d)
(1e)
(1f)
() = [[() ]]()
A NDR E P LATZER
L11.3
Lemma 5 (Differential invariant terms). The following special case of the differential
invariants proof rule is sound, i.e. if its premise is valid then so is its conclusion:
x = 0
(DI=0 )
= 0 [x = ] = 0
4 Proof by Generalization
So far, the argument captured in the differential invariant term proof rule DI=0 works
for
d2 + e2 r2 = 0 [d = e, e = d]d2 + e2 r2 = 0
(2)
with an equation d2 + e2 r2 = 0 normalized to having 0 on the right-hand side but
not for the original formula
d2 + e2 = r2 [d = e, e = d]d2 + e2 = r2
(3)
A NDR E P LATZER
L11.4
of the (provable) (2) and adapting the precondition using a corresponding cut with
d2 + e2 r2 = 0:
2de + 2e(d) 0 = 0
0
2
d +e =r d +e r =0
d + e r = 0 [d = e, e = d]d + e2 r2 = 0
cut,Wl,Wr
2
2
2
d + e = r [d = e, e = d]d2 + e2 r2 = 0
[]gen
d2 + e2 = r2 [d = e, e = d]d2 + e2 = r2
r
2
d + e2 = r2 [d = e, e = d]d2 + e2 = r2
R
d2 + e 2 r 2 = 0 d2 + e 2 = r 2
This is a possible way of proving the original (3), but also unnecessarily complicated.
Differential invariants can prove (3) directly once we generalize proof rule DI=0 appropriately. For other purposes, however, it is still important to have the principle of
generalization Note 6 in our repertoire of proof techniques.
A NDR E P LATZER
L11.5
2de + 2e(d) = 0
(2dd + 2ee = 0)ed d
e
DI 2
d
+ e2 = r2 [d = e, e = d]d2 + e2 = r2
d2 + e2 = r2 [d = e, e = d]d2 + e2 = r2
This proof is certainly much easier and more direct than the previous proof based on
[]gen .
A NDR E P LATZER
L11.6
0 5 2x(x3 )
3
DI 1
3
(0 5 2xx )xx
5x2 [x = x3 ] 31 5x2
Figure 1: a Cubic dynamics proof
x0
0
3
x = x
t
1b: Cubic dynamics
tive of the differential invariant F 31 5x2 , which gives the differential expression
F ( 13 5x2 ) 0 5 2xx . Now, the differential induction rule DI takes into account that the derivative of state variable x along the dynamics is known. Substituting
3
the differential equation x = x3 into the inequality yields F xx 0 5 2xx3 , which is
a valid formula and closes by quantifier elimination with R.
Differential invariants that are inequalities are not just a minor variation of equational differential invariants, because they can prove more. That is, it can be shown
[Pla12b] that there are valid formulas that can be proved using differential invariant
inequalities but cannot be proved just using equations as differential invariants (DI= ).
So sometimes, you need to be prepared to look for inequalities that you can use as differential invariants. The converse is not true. Everything that is provable using DI= is
also provable using differential invariant inequalities [Pla12b], but you should still look
for equational differential invariants if they give easier proofs.
Strict inequalities can also be used as differential invariants when defining their total
derivatives as:
( < ) (() < () )
It is easy to see (Exercise 1) that the following slightly relaxed definition would also be
sound:
( < ) (() () )
Understanding that differential substitution is sound for formulas, i.e. replacing the
left-hand side of the differential equation by its right-hand side, requires a few more
thoughts now, because the equational differential substitution principle Lemma 4 does
not apply directly. The differential substitution principle not only works for terms,
however, but also for differential first-order formulas, i.e. first-order formulas in which
differential symbols occur:
A NDR E P LATZER
L11.7
A NDR E P LATZER
L11.8
By analogy to the previous cases, one might expect the following definition:
?
( 6= ) (() 6= () )
???
x
(unsound)
1 6= 0
x 6= 5 [x = 1]x 6= 5
x =
t
different, does not mean they would always stay different if they evolve with different
derivatives.
Instead, if and start out differently and evolve with the same derivatives, they
will always stay different. So the sound definition is slightly unexpected:
( 6= ) (() = () )
A NDR E P LATZER
L11.9
DI 2
d
+ e2 r2 d2 + e2 r2 [d = e, e = d](d2 + e2 r2 d2 + e2 r2 )
A NDR E P LATZER
L11.10
The total derivative of a conjunction is the conjunction of the total derivatives. So,
by analogy, it might stand to reason to define the total derivative of a disjunction as the
disjunction of the total derivatives.
?
(F G) (F ) (G)
???
2de + 2e(d) = 0 5d + re 0
(2dd + 2ee = 0 r d + rd 0)ed d
e
d2 + e2 = r2 rd 0 [d = e, e = d, r = 5](d2 + e2 = r2 rd 0)
That would be spectacularly wrong, however, because the formula at the bottom is not
actually valid. We have no business of proving formulas that are not valid and if we
ever could, we would have found a serious unsoundness in the proof rules.
For soundness of differential induction, it is crucial that Def. 1 defines the total derivative (F G) of a disjunction conjunctively as (F ) (G) instead of as (F ) (G) . From
an initial state which satisfies |= F , and hence |= F G, the formula F G only
is sustained differentially if F itself is a differential invariant, not if G is. For instance,
d2 + e2 = r2 rd 0 is no invariant of the above differential equation, because rd 0
will be invalidated if we just follow the circle dynamics long enough. So if the disjunction was true because rd 0 was true in the beginning, it does not stay invariant.
In practice, splitting differential induction proofs over disjunctions can be useful if a
direct proof with a single differential invariant does not succeed:
ax
ax
A x
A A, B
B A, B
x
DI
r
r
DI
= ]A
= ]B
A
[x
A
B
B
[x
B
AB
[]gen
[]gen
A [x = ](A B)
B [x = ](A B)
l
A B [x = ](A B)
r
A B [x = ](A B)
10 Differential Invariants
Differential invariants are a general proof principles for proving invariants of formulas.
Summarizing what this lecture has discovered so far leads to a single proof rule for
differential invariants. That is why all previous proofs just indicated DI when using the
various special cases of the differential invariant proof rule to be developed next.
All previous arguments remain valid when the differential equation has an evolution
domain constraint H that it cannot leave by definition. In that case, the inductive proof
step can even assume the evolution domain constraint to hold, because the system, by
definition, is not allowed to leave it.
A NDR E P LATZER
L11.11
(F G) (F ) (G)
(x F ) x (F )
(x F ) x (F )
(a b) (a) (b)
(4a)
(4b)
(4c)
(4d)
(4e)
F
F
A NDR E P LATZER
L11.12
there is otherwise nothing to show (sequent is trivially true since antecedent evaluates
to false). If [0, r] is any time during any solution : [0, r] S of any duration r R
of x = beginning in initial state (0) = , then it remains to be shown that (r) |= F .
By antecedent, |= F , in the initial state = (0).
If the duration of is r = 0, we have (0) |= F immediately, because |= F . For
duration r > 0, we show that F holds all along , i.e., () |= F for all [0, r].
We have to show that |= F [x = & H]F for all states . Let satisfy |= F as,
otherwise, there is nothing to show. We can assume F to be in disjunctive normal form
and consider any disjunct G of F that is true at . In order to show that F remains
true during the continuous evolution, it is sufficient to show that each conjunct of G
is. We can assume these conjuncts to be of the form 0 (or > 0 where the proof
is accordingly). Finally, using vectorial notation, we write x = for the differential
equation system. Now let : [0, r] (V R) be any solution of x = & H beginning
in (0) = . If the duration of is r = 0, we have (0) |= 0 immediately, because
|= 0. For duration r > 0, we show that 0 holds all along the solution ,
i.e., () |= 0 for all [0, r].
Suppose there was a [0, r] with () |= < 0, which will lead to a contradiction.
The function h : [0, r] R defined as h(t) = [[]]() satisfies the relation h(0) 0 > h(),
because h(0) = [[]](0) = [[]] and |= 0 by antecedent of the conclusion. By Lemma 3,
h is continuous on [0, r] and differentiable at every (0, r). By mean value theorem,
there is a (0, ) such that dh(t)
dt () ( 0) = h() h(0) < 0. In particular, since
dh(t)
2de + 2e(d) 0
0
(2dd + 2ee 2rr )ed d
e r
DI 2
d
+ e2 r2 [d = e, e = d]d2 + e2 r2
d2 + e2 r2 [d = e, e = d]d2 + e2 r2
A NDR E P LATZER
L11.13
11 Example Proofs
Example 11 (Quartic dynamics). The following simple dL proof uses DI to prove an
invariant of a quartic dynamics.
a 0 (3x2 x 0)x
DI 3
x
Observe that rule DI directly makes the evolution domain constraint a 0 available as
an assumption in the premise, because the continuous evolution is never allowed to
leave it.
Example 12. Consider the dynamics x = y, y = 2 x 2dy of the damped oscillator
with the undamped angular frequency and the damping ratio d. See Fig. 4 for one
example of an evolution along this continuous dynamics. Figure 4 shows a trajectory
x
t
y
0 d 0 2 2 xy 2 2 xy 4dy 2 0
y
0 d 0 (2 2 xx + 2yy 0)x y
DI 2 2
x
2 x2dy
A NDR E P LATZER
L11.14
12 Assuming Invariants
Lets make the dynamics more interesting and see what happens. Suppose there is a
robot at a point with coordinates (x, y) that is facing in direction (d, e). Suppose the
robot moves with constant (linear) velocity into direction (d, e), which is rotating as
before. Then the corresponding dynamics is:
x = d, y = e, d = e, e = d
because the derivative of the x coordinate is the component d of the direction and the
derivative of the y coordinate is the component e of the direction. If the rotation of
the direction (d, e) is faster or slower, the differential equation would be formed correspondingly. Consider the following conjecture:
(x 1)2 + (y 2)2 p2 [x = d, y = e, d = e, e = d](x 1)2 + (y 2)2 p2 (5)
This conjecture expresses that the robot at position (x, y) will always stay at distance p
from the point (1, 2) if it started there. Lets try to prove conjecture (5):
2(x 1)d + 2(y 2)e 0
(2(x 1)x + 2(y 2)y 0)dx ey
DI
Unfortunately, this differential invariant proof does not work. As a matter of fact, fortunately it does not work out, because conjecture (5) is not valid, so we will, fortunately,
not be able to prove it with a sound proof technique. Conjecture (5) is too optimistic.
Starting from some directions far far away, the robot will most certainly get too close to
the point (1,2). Other directions may be fine.
Inspecting the above failed proof attempt, we could prove (5) if we knew something
about the directions (d, e) that would make the remaining premise prove. What could
that be?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L11.15
Certainly, if we knew d = e = 0, the resulting premise would prove. Yet, that case
is pretty boring because it corresponds to the point (x, y) being stuck forever. A more
interesting case in which the premise would easily prove is if we knew x 1 = e and
y 2 = d. In what sense could we know x 1 = e y 2 = d? Certainly, we would
have to assume this compatibility condition for directions versus position is true in the
initial state, otherwise we would not necessarily know the condition holds true where
we need it. So lets modify (5) to include this assumption:
x 1 = e y 2 = d (x 1)2 + (y 2)2 p2
[x = d, y = e, d = e, e = d](x 1)2 + (y 2)2 p2 (6)
Yet, where we need to know x 1 = e y 2 = d for the above sequent prove to
continue is in the middle of the inductive step. How could we make that happen?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L11.16
d = (d) e = e
(x = e y = d )dx ey ed d
e
DI
x 1 = e y 2 = d [x = d, y = e, d = e, e = d](x 1 = e y 2 = d)
because the differential invariant proof rule DI does not make the invariant F available
in the antecedent of the premise.
In the case of loops, invariants can be assumed to hold before the loop body in the
induction step.
F []F
(ind)
F [ ]F
By analogy, we could augment the differential invariant proof rule DI similarly to
include F in the assumptions. Is that a good idea?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L11.17
It looks tempting to suspect that rule DI could be improved by assuming the differential invariant F in the antecedent of the premise:
H F F x
(DI?? )
sound?
F [x = & H]F
After all, we really only care about staying safe when we are still safe. But implicit
properties of differential equations are a subtle business. Assuming F like in rule DI??
would, in fact, be unsound, as the following simple counterexample shows, which
proves an invalid property using the unsound proof rule DI?? :
(unsound)
(x y)2 0 2(x y)(1 y) 0
(x y)2 0 (2(x y)(x y ) 0)1x yy
(x y)2 0 [x = 1, y = y]((x y)2 0)
Assuming an invariant of a differential equation during its own proof is, thus, incorrect, even though it has been suggested numerous times in the literature. There
are some cases for which rule DI?? would be sound, but these are nontrivial [Pla10a,
Pla12b, Pla12a].
13 Differential Cuts
Instead, there is a complementary proof rule for differential cuts [Pla10a, Pla08, Pla12b,
Pla12a] that can be used to strengthen assumptions in a sound way:
[x = & H]C,
[x = & (H C)]F ,
(DC)
[x = & H]F,
The differential cut rule works like a cut, but for differential equations. In the right
premise, rule DC restricts the system evolution to the subdomain H C of H, which
changes the system dynamics but is a pseudo-restriction, because the left premise proves
that C is an invariant anyhow (e.g. using rule DI). Note that rule DC is special in that
it changes the dynamics of the system (it adds a constraint to the system evolution domain region), but it is still sound, because this change does not reduce the reachable
set. The benefit of rule DC is that C will (soundly) be available as an extra assumption
for all subsequent DI uses on the right premise (see, e.g., the use of the evolution domain constraint in Example 12). In particular, the differential cut rule DC can be used
to strengthen the right premise with more and more auxiliary differential invariants C
that will be available as extra assumptions on the right premise, once they have been
proven to be differential invariants in the left premise.
Proving (6) in a sound way is now easy using a differential cut DC by x 1 = e
y 2 = d:
A NDR E P LATZER
L11.18
d = (d) e = e
(x = e y = d )x ey ed d
e
DI
x1=.. [x = d, . . .](x1=ey2=d)
DC
Using this differential cut process repeatedly has turned out to be extremely useful
in practice and even simplifies the invariant search, because it leads to several simpler
properties to find and prove instead of a single complex property [PC08, PC09, Pla10b].
Proof of Soundness of DC. For simplicity, consider only the case where H true. Rule
DC is sound using the fact that the left premise implies that every solution that satisfies x = also satisfies C all along the solution. Thus, if solution satisfies x = , it
also satisfies x = & C, so that the right premise entails the conclusion. The proof is
accordingly for the case
14 Differential Weakening
One simple but computable proof rule is differential weakening:
HF
(DW)
[x = & H]F,
This rule is obviously sound, because the system x = & H, by definition, can never
leave H, hence, if H implies F (i.e. the region H is contained in the region F ), then F is
an invariant, no matter what x = does. Unfortunately, this simple proof rule cannot
prove very interesting properties, because it only works when H is very informative.
It can, however, be useful in combination with stronger proof rules (e.g., differential
cuts).
15 Summary
This lecture introduced very powerful proof rules for differential invariants, with which
you can prove even complicated properties of differential equations in easy ways. Just
like in the case of loops, where the search for invariants is nontrivial, differential invariants also require some smarts (or good automatic procedures) to be found. Yet, once a
differential invariant has been identified, the proof follows easily.
Note 10 (Proof rules for differential equations).
HF
H F x
(DW)
(DI)
F [x = & H]F
[x = & H]F,
(DC)
[x = & H]C,
[x = & (H C)]F ,
[x = & H]F,
A NDR E P LATZER
L11.19
Exercises
Exercise 1. We have chosen to define
( < ) (() < () )
Prove that the following slightly relaxed definition would also give a sound proof rule
for differential invariants:
( < ) (() () )
Exercise 2. We have defined
( 6= ) (() = () )
Suppose you remove this definition so that you can no longer use the differential invariant proof rule for formulas involving 6=. Can you derive a proof rule to prove such
differential invariants regardless? If so, how? If not, why not?
References
[PC08]
[PC09]
Andre Platzer and Edmund M. Clarke. Computing differential invariants of hybrid systems as fixedpoints. Form. Methods Syst. Des., 35(1):98
120, 2009. Special issue for selected papers from CAV08. doi:10.1007/
s10703-009-0079-8.
[Pla08]
Andre Platzer. Differential Dynamic Logics: Automated Theorem Proving for Hybrid Systems. PhD thesis, Department of Computing Science, University of
Oldenburg, Dec 2008. Appeared with Springer.
A NDR E P LATZER
Lecture Notes on
Differential Invariants & Proof Theory
Andre Platzer
Carnegie Mellon University
Lecture 14
1 Introduction
Lecture 10 on Differential Equations & Differential Invariants and Lecture 11 on Differential Equations & Proofs equipped us with powerful tools for proving properties of
differential equations without having to solve them. Differential invariants (DI) [Pla10a]
prove properties of differential equations by induction based on the right-hand side of
the differential equation, rather than its much more complicated global solution. Differential cuts (DC) [Pla10a] made it possible to prove another property C of a differential
equation and then change the dynamics of the system around so that it can never leave
region C. Differential cuts turned out to be very useful when stacking inductive properties of differential equations on top of each other, so that easier properties are proved
first and then assumed during the proof of the more complicated properties. Differential weakening (DW) [Pla10a] proves simple properties that are entailed by the evolution domain, which becomes especially useful after the evolution domain constraint
has been augmented sufficiently by way of a differential cut.
Just like in the case of loops, where the search for invariants is nontrivial, differential invariants also require some smarts (or good automatic procedures) to be found.
Once a differential invariant has been identified, the proof follows easily, which is a
computationally attractive property.
Finding invariants of loops is very challenging. It can be shown to be the only
fundamental challenge in proving safety properties of conventional discrete programs
[HMP77]. Likewise, finding invariants and differential invariants is the only fundamental challenge in proving safety properties of hybrid systems [Pla08, Pla10b, Pla12a].
A more careful analysis even shows that just finding differential invariants is the only
fundamental challenge for hybrid systems safety verification [Pla12a].
A NDR E P LATZER
L14.2
That is reassuring, because we know that the proofs will work1 as soon as we find
the right differential invariants. But it also tells us that we can expect the search for differential invariants (and invariants) to be challenging, because cyber-physical systems
are extremely challenging, albeit very important.
Since, at the latest after this revelation, we fully realize the importance of studying
and understanding differential invariants, we subscribe to developing a deeper understanding of differential invariants right away. The part of their understanding that
todays lecture develops is how various classes of differential invariants relate to each
other in terms of what they can prove. That is, are there properties that only differential
invariants of the form A can prove, because differential invariants of the form B cannot
prove them. Or are all properties provable by differential invariants of the form A also
provable by differential invariants of the form B.
These relations between classes of differential invariants tell us which forms of differential invariants we need to search for. A secondary goal of todays lecture besides this
theoretical understanding is the practical understanding of developing more intuition
about differential invariants and seeing them in action more thoroughly.
This lecture is based on [Pla12b]. In this lecture, we try to strike a balance between
comprehensive handling of the subject matter and core intuition. This lecture will
mostly focus on the core intuition of the heart of the proofs and leaves a more comprehensive argument and further study for articles [Pla12b]. Many proofs in this lecture are simplified and only prove the core argument, while leaving out other aspects.
Those very important further details are beyond the scope of this course and can be
found elsewhere [Pla12b]. For example, this lecture will not study whether indirect
proofs could conclude the same properties. With a more careful analysis [Pla12b], it
turns out that indirect proofs do not change the results reported in this lecture, but the
proofs become significantly more complicated and require a more precise choice of the
sequent calculus formulation. In this lecture, we will also not always prove all statements conjectured in a theorem. The remaining proofs can be found in the literature
[Pla12b].
Note 1 (Proof theory of differential equations). The results in this lecture are part of
the proof theory of differential equations. They are proofs about proofs, because they prove
relations between the provability of logical formulas with different (sequent) proof calculi.
2 Recap
Recall the following proof rules for differential equations from Lecture 11 on Differential Equations & Proofs:
Although it may still be a lot of work in practice to make the proofs work. At least they become possible.
A NDR E P LATZER
L14.3
F [x = & H]F
[x = & H]F,
(DC)
[x = & H]C,
[x = & (H C)]F ,
[x = & H]F,
With cuts and generalizations, earlier lectures have also shown that the following can
be proved:
A F F [x = & H]F F B
(1)
A [x = & H]B
A NDR E P LATZER
L14.4
H G x
DI
G [x = & H]G
F [x = & H]F
The bottom proof step is easy to see using (1), because precondition F implies the new
precondition G and postcondition F is implied by the new postcondition G propositionally. Subgoal H G x is provable, because H F x is provable and G is defined
as a conjunction over all literals of G. The set of literals of G is identical to the set
of literals of F , because the literals do not change by using propositional tautologies.
Furthermore, we assumed a propositionally complete base calculus [Pla12b].
In subsequent proofs, we can use propositional equivalence transformations by Lemma 1.
In the following, we will also implicitly use equivalence reasoning for pre- and postconditions as we have done in Lemma 1. Because of Lemma 1, we can, without loss of
generality, work with arbitrary propositional normal forms for proof search.
A NDR E P LATZER
L14.5
2x2 0
(2xx 0)x
x
DI 2
2
x 5 [x = x]x2 52
R
5 x x 5 [x = x](5 x x 5)
When we want to prove the property in the proof of Lemma 2, we need to use the
principle (1) with the differential invariant F x2 52 and cannot use 5 x x 5.
By Lemma 2, we cannot just use arbitrary equivalences when investigating differential invariance, but have to be more careful. Not just the elementary real arithmetical equivalence of having the same set of satisfying assignments matters, but also the differential
structures need to be compatible. Some equivalence transformations that preserve the
solutions still destroy the differential structure. It is the equivalence of real differential
structures that matters. Recall that differential structures are defined locally in terms of
the behavior in neighborhoods of a point, not the point itself.
Lemma 2 illustrates a notable point about differential equations. Many different formulas characterize the same set of satisfying assignments. But not all of them have
the same differential structure. Quadratic polynomials have inherently different differential structure than linear polynomials even when they have the same set of solutions over the reals. The differential structure is a more fine-grained information.
This is similar to the fact that two elementary equivalent models of first-order logic
can still be non-isomorphic. Both the set of satisfying assignments and the differential structure matter for differential invariance. In particular, there are many formulas
with the same solutions but different differential structures. The formulas x2 0 and
x6 + x4 16x3 + 97x2 252x + 262 0 have the same solutions (all of R), but very different differential structure; see Fig. 1.
The first two rows in Fig. 1 correspond to the polynomials from the latter two cases.
The third row is a structurally different degree 6 polynomial with again the same set of
solutions (R) but a rather different differential structure. The differential structure also
depends on what value x assumes according to the differential equation. Fig. 1 illustrates that p alone can already have a very different characteristic even if the respective
sets of satisfying assignments of p 0 are identical.
A NDR E P LATZER
L14.6
p
8
p
15
6
4
10
2
-3
-2
-1
-2
-4
-3
-2
-1
-6
p
4000
3000
3000
2000
1000
2000
-3
-2
1000
-3
-2
-1
-1
-1000
-2000
20
30
25
10
20
15
-10
5
-2
-2
10
-20
A NDR E P LATZER
L14.7
We can, however, always normalize all atomic subformulas to have right-hand side
0, that is, of the form p = 0, p 0, or p > 0. For instance, p q is a differential invariant
if and only if q p 0 is, because p q is equivalent (in first-order real arithmetic)
to q p 0 and, moreover, for any variable x and term , (p q )x is equivalent to
(q p 0)x in first-order real arithmetic.
A NDR E P LATZER
L14.8
One direction is simple. Proving DI = DI =,, is obvious, because every proof using a differential invariant equation p1 = p2 also is a proof using a propositional combination of differential invariant equations. The propositional combination that just
consists of the only conjunct p1 = p2 .
The other way around DI = DI =,, is more difficult. If a formula can be proved
using a differential invariant that is a propositional combination of equations, such
as p1 = p2 q1 = q2 , how could it possibly be proved using just a single equation?
Note 6 (Proofs of equal provability). A proof of Proposition 3 needs to show that every
such provable property is also provable with a structurally simpler differential invariant.
It effectively needs to transform proofs with propositional combinations of equations as
differential invariants into proofs with just differential invariant equations. And, of course,
the proof of Proposition 3 needs to prove that the resulting equations are actually provably
differential invariants and prove the same properties as before.
Proof of Proposition 3. Let x = be the (vectorial) differential equation to consider. We
show that every differential invariant that is a propositional combination F of polynomial equations is expressible as a single atomic polynomial equation (the converse
inclusion is obvious). We can assume F to be in negation normal form by Lemma 1 (recall that negations are resolved and 6= can be assumed not to appear). Then we reduce F
inductively to a single equation using the following transformations:
If F is of the form p1 = p2 q1 = q2 , then F is equivalent to the single equation
(p1 p2 )(q1 q2 ) = 0. Furthermore, F x (p1 = p2 q1 = q2 )x directly implies
((p1 p2 )(q1 q2 )) = 0 x (p1 p2 )(q1 q2 ) + (p1 p2 )(q1 q2 ) = 0 x
If F is of the form p1 = p2 q1 = q2 , then F is equivalent to the single equation
(p1 p2 )2 + (q1 q2 )2 = 0. Furthermore, F x p1 = p2 q1 = q2 x implies
(p1 p2 )2 + (q1 q2 )2 =0 x 2(p1 p2 )(p1 p2 ) + 2(q1 q2 )(q1 q2 ) = 0 x
Note that the polynomial degree increases quadratically by the reduction in Proposition 3, but, as a trade-off, the propositional structure simplifies. Consequently, differential invariant search for the equational case can either exploit propositional structure
with lower degree polynomials or suppress the propositional structure at the expense
of higher degrees.
A NDR E P LATZER
L14.9
7 Equational Incompleteness
Focusing exclusively on differential invariants with equations, however, reduces the
deductive power, because sometimes only differential invariant inequalities can prove
properties.
Proposition 4 (Equational incompleteness). The deductive power of differential induction with equational formulas is strictly less than the deductive power of general differential
induction, because some inequalities cannot be proven with equations.
DI = DI =,, < DI
DI 6 DI = DI =,,
DI > 6 DI = DI =,,
How could such a proposition be proved?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L14.10
The proof strategy in Proposition 3 involved transforming proofs into proofs to prove
the inclusion DI = DI =,, . Could the same strategy prove Proposition 4? No, because we need to show the opposite! Proposition 4 conjectures DI 6 DI =,, , which
means that there are true properties that are only provable using a differential invariant
inequality p1 p2 and not using any differential invariant equations or propositional
combinations thereof.
For one thing, this means that we ought to find a property that a differential invariant
inequality can prove. That ought to be easy enough, because Lecture 11 on Differential
Equations & Proofs showed us how useful differential invariants are. But then a proof
of Proposition 4 also requires a proof why that very same formula cannot possibly ever
be proved with any way of using differential invariant equations or their propositional
combinations. That is a proof about nonprovability. Proving provability in proof theory
amounts to producing a proof (in sequent calculus). Proving nonprovability most certainly does not mean it would be enough to write something down that is not a proof.
After all, just because one proof attempt fails does not mean that others would not be
successful. You have experienced this while you were working on proving your labs
for this course. The first proof attempt might have failed miserably and was impossible
to ever work out. But, come next day, you had a better idea with a different proof, and
suddenly the same property turned out to be provable even if the first proof attempt
failed.
How could we prove that all proof attempts do not work?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L14.11
One way of showing that a logical formula cannot be proved is by giving a counterexample, i.e. a state which assigns values to the variables that falsify the formula. That is,
of course, not what can help us proving Proposition 4, because a proof of Proposition 4
requires us to find a formula that can be proved with DI (so it cannot have a counterexample, since it is valid), just cannot be proved with DI =,, . Proving that a valid
formula cannot be proved with DI =,, requires us to show that all proofs in DI =,,
do not prove that formula.
By analogy, recall sets. The way to prove that two sets M, N have the same number
of elements is to come up with a pair of functions : M N and : N M
between the sets and then prove that , are inverses of each other, i.e. ((y)) = y
and ((x)) = x for all x M, y N . Proving that two sets M, N do not have the
same number of elements works entirely differently, because that has to prove for all
pairs of functions : M N and : N M that there is is an x M such that
((x)) 6= x or an y N such that ((y)) 6= y. Since that is a lot of work, indirect
criteria such as cardinality or countability are often used instead, e.g. for proving that
the reals R and rationals Q do not have the same number of elements, because Q are
countable but R are not (by Cantors diagonal argument).
By analogy, recall vector spaces from linear algebra. The way to prove that two vector
spaces V, W are isomorphic is to think hard and construct a function : V W and
a function : W V and then prove that , are linear functions and inverses
of each other. Proving that two vector spaces V, W are not isomorphic works entirely
differently, because that has to prove that all pairs of functions : V W and :
W V are either not linear or not inverses of each other. Proving the latter literally
is a lot of work. So instead, indirect criteria are being used. One proof that V, W are
not isomorphic could show that both have different dimensions and then prove that
isomorphic vector spaces always have the same dimension, so V and W cannot possibly
be isomorphic.
Consequently, proving non-provability leads to a study of indirect criteria about
proofs of differential equations.
Note 8 (Proofs of different provability). Proving non-reducibility A 6 B for classes of
differential invariants requires an example formula that is provable in A plus a proof that
no proof using B proves . The preferred way of doing that is finding an indirect criterion
that all proofs in B possess but that does not have.
Proof of Proposition 4. Consider any term a > 0 (e.g., 5 or x2 + 1 or x2 + x4 + 2). The
following formula is provable by differential induction with the weak inequality x 0:
a0
DI
x 0 [x = a]x 0
R
A NDR E P LATZER
L14.12
the half space x 0. By the equational deductive power theorem 3, the above formula
then is not provable with any Boolean combination of equations as differential invariant
either.
The other parts of the theorem are proved elsewhere [Pla12b].
It might be tempting to think that at least equational postconditions only need equational differential invariants for proving them. But that is not the case either [Pla12b].
2xy + 2y(x) = 0
DI 2
x + y 2 = c2 [x = y, y = x]x2 + y 2 = c2
R
But it is not provable with a differential invariant of the form p > 0. An invariant of
the form p > 0 describes an open set and, thus, cannot be equivalent to the (nontrivial)
closed domain where x2 + y 2 = c2 . The only sets that are both open and closed in Rn
are and Rn .
The other parts of the theorem are proved elsewhere [Pla12b].
A NDR E P LATZER
L14.13
H (p = 0)x
DI
p = 0 [x = & H]p = 0
H (2pp 0)x
DI
p2 0 [x = & H](p2 0)
The subgoal for the differential induction step is provable: if we can prove that H implies (p = 0)x , then we can also prove that H implies (2pp 0)x , because (p = 0)x
implies (2pp 0)x in first-order real arithmetic.
Note that the local state-based view of differential invariants is crucial to make the last
proof work. By Proposition 6, differential invariant search with weak inequalities can
suppress equations. Note, however, that the polynomial degree increases quadratically
with the reduction in Proposition 6. In particular, the polynomial degree increases quartically when using the reductions in Proposition 3 and Proposition 6 one after another
to turn propositional equational formulas into single inequalities. This quartic increase
of the polynomial degree is likely a too serious computational burden for practical purposes even if it is a valid reduction in theory.
A NDR E P LATZER
L14.14
a 0 y2 0
2
(x 0 y 0)ax yy
DI
x 0 y 0 [x = a, y = y 2 ](x 0 y 0)
By a sign argument similar to that in the proof of [Pla10a, Theorem 2] no atomic formula
is equivalent to x 0 y 0. Thus, the above property cannot be proven using a single
differential induction. The proof for a postcondition x > 0 y > 0 is similar.
The otherquite substantialparts of the proof are proved elsewhere [Pla12b].
Note that the formula in the proof of Theorem 7 is provable, e.g., using differential
cuts (DC) with two atomic differential induction steps, one for x 0 and one for y 0.
Yet, a similar argument can be made to show that the deductive power of differential
induction with atomic formulas (even when using differential cuts) is strictly less than
the deductive power of general differential induction; see [Pla10a, Theorem 2].
11 Summary
Fig. 2 summarizes the findings of this lecture and others reported in the literature [Pla12b].
We have considered the differential invariance problem, which, by a relative completeness argument [Pla12a], is at the heart of hybrid systems verification. To better understand structural properties of hybrid systems, we have identified and analyzed more
than a dozen (16) relations between the deductive power of several (9) classes of differential invariants, including subclasses that correspond to related approaches.
Our results require a symbiosis of elements of logic with real arithmetical, differential, semialgebraic, and geometrical properties. Future work includes investigating this
new field further that we call real differential semialgebraic geometry, whose development
has only just begun.
A NDR E P LATZER
DI
DI =
DI >
L14.15
DI ,=,,
DI =,,
DI
DI >,,
DI >,=,,
Exercises
Exercise 1. Prove the relation DI > DI >,, .
Exercise 2. Prove the relation DI DI ,, .
Exercise 3. Prove the relation DI ,, DI ,=,, .
Exercise 4. Prove the relation DI =,, < DI ,, .
Exercise 5. Prove the relation DI >,, < DI >,=,, .
A NDR E P LATZER
Lecture Notes on
Ghosts & Differential Ghosts
Andre Platzer
Carnegie Mellon University
Lecture 15
1 Introduction
Lecture 10 on Differential Equations & Differential Invariants and Lecture 11 on Differential Equations & Proofs equipped us with powerful tools for proving properties of
differential equations without having to solve them. Differential invariants (DI) [Pla10a]
prove properties of differential equations by induction based on the right-hand side of
the differential equation, rather than its much more complicated global solution. Differential cuts (DC) [Pla10a] made it possible to prove another property C of a differential
equation and then change the dynamics of the system around so that it can never leave
region C. Lecture 14 on Differential Invariants & Proof Theory studied some part of the
proof theory of differential equations and proved the differential invariance chart that
compares the deductive power of classes of differential invariants; see Fig. 1.
DI ,,
DI
DI =
DI >
DI ,=,,
DI =,,
DI
DI >,,
DI >,=,,
A NDR E P LATZER
L15.2
spooky as they may sound, turn out to be a useful proof technique for differential equations.
This lecture is based on [Pla12, Pla10b].
2 Recap
Recall the following proof rules for differential equations from Lecture 11 on Differential Equations & Proofs:
Note 1 (Proof rules for differential equations).
H F x
HF
(DI)
(DW)
F [x = & H]F
[x = & H]F,
(DC)
[x = & H]C,
[x = & (H C)]F ,
[x = & H]F,
With cuts and generalizations, earlier lectures have also shown that the following can
be proved:
A F F [x = & H]F F B
(1)
A [x = & H]B
3 Arithmetic Ghosts
b
q := ; ?qc = b
q := ; ?qc = b c 6= 0
c
where q := is the nondeterministic assignment that assigns an arbitrary real number
to q.
q :=
b
x := 2+ +e
c
q := ; ?qc = b; x := 2+q+e
q := ; ?qc = bc 6= 0; x := 2+q+e
Here q is called an arithmetic ghost, because q is an auxiliary variable that is only in the
hybrid program for the sake of defining the quotient cb .
(2)
What now?
A NDR E P LATZER
L15.3
One possible solution, which is the one taken in the implementation of KeYmaera
[PQ08], is to add the nondeterministic assignment x := as a statement to the syntax of
hybrid programs.
, ::= x := | . . . | x :=
Consequently, nondeterministic assignments need a semantics to become meaningful.
7. (x := ) = {(, ) : = except for the value of x, which can be any real number}
And nondeterministic assignments finally need proof rules so that they can be handled
in proofs.
x
x
(h:i)
([:])
hx := i
[x := ]
Another approach for adding nondeterministic assignments x := to hybrid programs is to consider whether we even have to do that. That is, to understand whether
x := is truly a new program construct or whether it can be defined in terms of the
other hybrid program statements from (2). Is x := definable by a hybrid program?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L15.4
Nondeterministic assignment x := assigns any real number to x. One hybrid program that has the same effect of giving x any arbitrary real value [Pla10b, Chapter 3]
is:
def
x := x = 1 x = 1
(3)
That is not the only definition of x := , though. An equivalent definition is [Pla13]:
x :=
def
x = 1; x = 1
When working through the intended semantics of the left-hand side x := shown in
case 7 above and the actual semantics of the right-hand side of (3) according to Lecture
3, it becomes clear that both sides of (3) mean the same. Hence, the above definition (3)
capture the right concept. And, in particular, just like if-then-else, nondeterministic assignments do not really have to be added to the language of hybrid programs, because
they can already be defined. Likewise, no proof rules would have to be added for nondeterministic assignments, because there are already proof rules for the constructs used
in the right-hand side of the definition of x := in (3). Since the above proof rules for
x := are particularly easy, though, it is usually more efficient to include them directly,
which is what KeYmaera does.
What may, at first sight, appear slightly spooky about (3), however, is that the lefthand side x := is clearly an instant change in time where x changes its value instantaneously to some arbitrary new real number. That is less so for the right-hand side of
(3), which involves two differential equations, which take time to follow.
The clue is that this passage of time is not observable in the state of the system. Consequently, the left-hand side of (3) really means the same as the right-hand side of (3).
Remember from earlier lectures that time is not special. If a CPS wants to refer to time,
it would have a clock variable t with the differential equation t = 1. With such an addition, however, the passage of time t becomes observable in the value of variable t and,
hence, a corresponding variation of the right-hand side of (3) would not be equivalent
to x := (indicated by 6):
x :=
x = 1, t = 1 x = 1, t = 1
5 Differential-algebraic Ghosts
b
q = & qc = b
q = & qc = b c 6= 0
c
See [Pla10b, Chapter 3] for the meaning of the nondeterministic differential equation
q = .1
q =
x = 2 +
1
b
+e
c
x = 2 + q + e, q = & qc = b
x = 2 + q + e, q = & qc = bc 6= 0
A NDR E P LATZER
L15.5
6 Discrete Ghosts
Lemma 1 (Discrete ghosts). The following is a sound proof rule for introducing auxiliary
variables or (discrete) ghosts:
[y := ],
(IA)
,
where y is a new program variable.
That proof rule IA is sound can be argued based on the soundness of the substitution
axiom [:=] from Lecture 5 on Dynamical Systems & Dynamic Axioms. The assignment
axiom [:=] proves validity of
[y := ]
because the fresh variable y does not occur in .
(4)
The dL formula (4) can be proved using the solutions of the differential equation
with proof rule [ ]. dL formula (4) can also be proved using differential invariants, with
a differential cut and a use of differential weakening:
h 0 2gv = 2v(g)
ax
h 0 (2gh = 2vv )vh g
h 0 2gh = 2gH v 2 2gh = 2gH v 2 h 0
v
DI
DW
2gh = 2gH v 2 [h = g & h 0]2gh = 2gH v 2
2gh = 2gH v 2 [h = g & h 0 2gh = 2gH v 2 ](2gh = 2gH v 2 h 0)
DC
2
2gh = 2gH v [h = g & h 0](2gh = 2gH v 2 h 0)
R
Note that differential weakening (DW) works for proving the postcondition h 0, but
DI would not work, because the derivative of h 0 is v 0, which is not an invariant
A NDR E P LATZER
L15.6
of the bouncing ball since its velocity ultimately becomes negative when it is falling
according to gravity. Note that this proofs is very elegant and has notably easier arithmetic than the arithmetic we ran into when working with solutions of the bouncing ball
in earlier lectures.
The reason why this proof worked so elegantly is that the invariant 2gh = 2gH
v 2 h 0 was a very good choice that we came up with in a clever way in Lecture 4.
Is there a way to prove (4) without such a distinctively clever invariant that works as a
differential invariant right away? Yes, of course, because (4) can even be proved using
solutions [ ]. But it turns out that interesting things happen when we systematically try
to understand how to make a proof happen that does not use the solution rule [ ] and,
yet, still uses solution-based arguments. Can you conceive a way to do use solutions
for differential equations without invoking rule [ ]?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L15.7
8 Differential Ghosts
2gh = 2gH v 2 [h = g & h 0](2gh = 2gH v 2 h 0)
Use the usual abbreviations:
def
(h = g) (h = v, v = g)
h 0 g = 1g
1
h 0 (v = t g)g
v t
Ah,v {v0 := v}[h = g, t = 1 & h 0 v = v0 tg]Bh,v
{v0 := v}[h = g, t = 1 & h 0]v = v0 tg
Ah,v {v0 := v}[h = g, t = 1 & h 0]Bh,v
Ah,v {v0 := v}[h = g & h 0]Bh,v
Ah,v [h = g & h 0]Bh,v
R
DI
DC
Ah,v
DA
IA
where the proof step marked DA omits the (here trivial) left premise of rule DA, which
proves because Bh,v t Bh,v is trivially valid in first-order logic, as the fresh t does
even occur in Bh,v here.
The right premise in the above proof proves as follows
h 0 v = v0 tg v = v0 2 g2 t
h 0 v = v0 tg (h = v0 t 2 g2 tt )vh 1t
DI
DC
Ah,v
IA
The proof step marked DC has a second premise which is elided (marked by ) and
proves as follows:
h 0 v = v0 tg h = h0 + v0 t g2 t2 Bh,v
{h0 := h, v0 := v}[h = g, t = 1 & h 0 v = v0 tg h = h0 + v0 t g2 t2 ]Bh,v
R
DW
Ah,v
The arithmetic (marked R) can be proved with enough care, but it has a twist! First of
all, the arithmetic can be simplified substantially using the equality substitution rule =r
and subsequent weakening.
Wl
r
l,Wr
=r
ax
g 2
2
h 0 2g(h0 + v0 t 2 t ) = 2gH (v0 tg)
h0h0
h 0 2g(h0 + v0 t g2 t2 ) = 2gH (v0 tg)2 h 0
h 0 v = v0 tg h = h0 + v0 t g2 t2 2g(h0 + v0 t g2 t2 ) = 2gH (v0 tg)2 h 0
h 0 v = v0 tg h = h0 + v0 t g2 t2 2gh = 2gH v 2 h 0
A NDR E P LATZER
L15.8
Observe how this use of equality substitution and weakening helped simplify the arithmetic complexity of the formula substantially and even helped to eliminate a variable
(v) right away. This can be useful to simplify arithmetic in many other cases as well.
The arithmetic in the left branch
g
2g(h0 + v0 t t2 ) = 2gH (v0 tg)2
2
expands by polynomial arithmetic and cancels as follows
2g(h0 + v0 t g2 t2 ) = 2gH v02 + 2v0 tg + t2 g 2
That leaves the remaining condition
2gh0 = 2gH v02
Indeed, this relation characterizes exactly how H, which turns out to have been the
maximal height, relates to the initial height h0 and initial velocity v0 . In the case of
initial velocity v0 = 0, this relation collapses to h0 = H.
For the case of the bouncing ball, this proof was unnecessarily complicated, because
the solution rule [ ] could have been used instead. But the same proof technique can
be useful in more complicated systems that do not have computable solutions, but in
which other relations between initial (or intermediate) and final state can be proved.
Lemma 2 (Differential ghosts). The following is a sound proof rule differential auxiliaries (DA) for introducing auxiliary differential variables or differential ghosts [Pla12]:
y , , [x = , y = & H],
(DA)
This
, [x = & H],
proves
where y new and y = , y(0) = y0 has a solution y : [0, ) Rn for each y0 .
Rule DA is applicable if y is a new variable and the new differential equation y =
has global solutions on H (e.g., because term satisfies a Lipschitz condition [Wal98,
Proposition 10.VII], which is definable in first-order real arithmetic and thus decidable).
Without that condition, adding y = could limit the duration of system evolutions
incorrectly. In fact, it would be sufficient for the domains of definition of the solutions
of y = to be no shorter than those of x. Soundness is easy to see, because precondition
implies for some choice of y (left premise). Yet, for any y, is an invariant of the
extended dynamics (right premise). Thus, always holds after the evolution for some
y (its value can be different than in the initial state), which still implies (left premise).
Since y is fresh and its differential equation does not limit the duration of solutions
of x on H, this implies the conclusion. Since y is fresh, y does not occur in H, and,
thus, its solution does not leave H, which would incorrectly restrict the duration of the
evolution as well.
Intuitively, rule DA can help proving properties, because it may be easier to characterize how x changes in relation to an auxiliary variable y with a suitable differential
equation (y = ).
A NDR E P LATZER
L15.9
xy 2 + 2xy y2 = 0
x
(x y 2 + x2yy = 0)x
x > 0 y xy 2 = 1
DA
y
2
DI
xy 2 = 1 [x = x, y = y2 ]xy 2 = 1
It can be shown [Pla12] that there are properties such as this one that need differential
ghosts (or differential auxiliaries) to prove.
9 Axiomatic Ghosts
When neglecting wind, gravitation, and so on, which is appropriate for analysing cooperation in air traffic control [TPS98], the in-flight dynamics of an aircraft at x can be
described by the following differential equation system; see [TPS98] for details:
x1 = v cos
x2 = v sin
= .
(5)
That is, the linear velocity v of the aircraft changes both positions x1 and x2 in the
(planar) direction corresponding to the orientation the aircraft is currently heading
toward. Further, the angular velocity of the aircraft changes the orientation of the
aircraft.
y2
x2
d
x1
y1
A NDR E P LATZER
L15.10
d
v sin = d2
x1
d1 = v cos
Figure 3: Reparametrize for differential axiomatization
equations (5), we immediately have x1 = d1 and x2 = d2 . With the coordinate change,
we further obtain differential equations for d1 , d2 from differential equation system (5)
by simple symbolic differentiation:
d1 = (v cos ) = v cos + v( sin ) = (v sin ) = d2 ,
d2 = (v sin ) = v sin + v(cos )
(v cos ) =
d1 .
The middle equality holds for constant linear velocity (v = 0), which we assume, because only limited variations in linear speed are possible and cost-effective during the
flight [TPS98, LLL00] so that angular velocity is the primary control parameter in air
traffic control. Hence, equations (5) can be restated as the following differential equation F():
x1 = d1 , x2 = d2 , d1 = d2 , d2 = d1
y1
= e1 ,
y2
= e2 ,
e1
= e2 ,
e2
= e1
(F())
(G())
A NDR E P LATZER
L15.11
10 Summary
The major lesson from todays lecture is that it can sometimes be easier to relate a variable to its initial value or to other quantities. Ghosts, in their various forms, let us
achieve that by adding auxiliary variables into the system dynamics. Sometimes such
ghosts are even necessary to prove properties. Although, as a workaround, it is also
sometimes possible to rewrite the original model so that it already includes the ghost
variables. The phenomenon that relations between state and ghost variables are sometimes easier to prove than just properties of state variables applies in either case. A
secondary goal of todays lecture is, again, developing more intuition and deeper understandings of differential invariants and differential cuts.
References
[God31]
Kurt Godel.
Uber
formal unentscheidbare Satze der Principia Mathematica
und verwandter Systeme I. Mon. hefte Math. Phys., 38:173198, 1931.
[LLL00] Carolos Livadas, John Lygeros, and Nancy A. Lynch. High-level modeling
and analysis of TCAS. Proc. IEEE - Special Issue on Hybrid Systems: Theory &
Applications, 88(7):926947, 2000.
[Pla10a] Andre Platzer. Differential-algebraic dynamic logic for differential-algebraic
programs. J. Log. Comput., 20(1):309352, 2010. doi:10.1093/logcom/exn070.
[Pla10b] Andre Platzer. Logical Analysis of Hybrid Systems: Proving Theorems for Complex
Dynamics. Springer, Heidelberg, 2010. doi:10.1007/978-3-642-14509-4.
[Pla12]
[Pla13]
Andre Platzer. A complete axiomatization of differential game logic for hybrid games. Technical Report CMU-CS-13-100R, School of Computer Science,
Carnegie Mellon University, Pittsburgh, PA, January, Revised and extended
in July 2013.
[PQ08]
[TPS98] Claire Tomlin, George J. Pappas, and Shankar Sastry. Conflict resolution for air
traffic management: a study in multi-agent hybrid systems. IEEE T. Automat.
Contr., 43(4):509521, 1998.
[Wal98] Wolfgang Walter. Ordinary Differential Equations. Springer, 1998.
A NDR E P LATZER
Lecture Notes on
Differential & Temporal Logics
Andre Platzer
Carnegie Mellon University
Lecture 16
1 Introduction
This course is devoted to the study of the Foundations of Cyber-Physical Systems
[Pla12c, Pla12b]. Lecture 3 on Choice & Control explained hybrid programs, a program notation for hybrid systems [Pla08, Pla10, Pla12c, Pla12a]. Lecture 4 on Safety &
Contracts defined differential dynamic logic [Pla08, Pla10, Pla12c, Pla12a] as a specification and verification logic for hybrid programs. Lecture 5 on Dynamical Systems
& Dynamic Axioms and subsequent lectures studied proof principles for differential
dynamic logic with which we can prove correctness properties of hybrid systems. In
your labs, you have demonstrated aptly how you can model, specify, and verify quite
sophisticated and challenging robots.
Yet, there was one rather puzzling phenomenon that we noticed in Lecture 4 only
then did not have a chance to consider any further. For a hybrid program and differential dynamic logic formula , the modal formula
[]
expresses that all final states reached by all runs of satisfy the logical formula . The
modal formula [] is, consequently, false exactly in those states from which can reach
a final state that violates the safety condition . Yet, what about states from which the
final state reached by running is safe but some intermediate state along the execution
of was not safe?
Shouldnt systems that violate safety conditino at an intermediate state be considered unsafe as well?
The short answer is: that depends.
Does it even make a difference whether we study intermediate states as well or only
worry about final states?
A NDR E P LATZER
L16.2
A NDR E P LATZER
L16.3
The logic dTL uses hybrid programs to describe as in previous lectures. Yet,
unlike in standard dynamic logic [HKT00] or dL, is a trace formula in dTL, and
can refer to all states that occur during a trace using temporal operators.
Temporal operators. For dTL, the temporal trace formula expresses that the formula holds all along a trace selected by [] or hi. For instance, the state formula hi says that the state formula holds at every state along at least one
trace of . Dually, the trace formula expresses that holds at some point during such a trace. It can occur in a state formula hi to express that there is such
a state in some trace of , or as [] to say that along each trace there is a state
satisfying . The primary focus of attention in todays lecture is on homogeneous
combinations of path and trace quantifiers like [] or hi.
The formulas of dTL are defined similarly to differential dynamic logic. However,
the modalities [] and hi accept trace formulas that refer to the temporal behavior of
all states along a trace. Inspired by CTL and CTL [EC82, EH86], dTL distinguishes
between state formulas, which are true or false in states, and trace formulas, which
are true or false for system traces. The sets Fml of state formulas and FmlT of trace
formulas with variables in are simultaneously inductively defined in Def. 1.
Definition 1 (dTL formula). The (state) formulas of differential temporal dynamic logic
(dTL) are defined by the grammar (where , are dTL state formulas, is a dTL
trace formula, 1 , 2 (polynomial) terms, x a variable, a HP):
, ::= 1 = 2 | 1 2 | | | | | x | x | [] | hi
The trace formulas of dTL are defined by the grammar (where is a dTL state formula):
::= | |
Operators >, , <, can be defined as usual, e.g., ( ) ( ).
Formulas without and are nontemporal formulas and have the same semantics as
the corresponding dL formulas. Unlike in CTL, dTL state formulas are true on a trace if
they hold for the last state of a trace, not for the first. Thus, dTL formula [] expresses
that is true at the end of each trace of , which is the same as the dL formula []. In
contrast, [] expresses that is true all along all states of every trace of . This combination gives a smooth embedding of nontemporal dL into dTL and makes it possible
to define a compositional calculus. Like CTL, dTL allows nesting with a branching time
semantics [EC82], e.g., [](x 2 hix 0).
A NDR E P LATZER
L16.4
A NDR E P LATZER
L16.5
hybrid programs as the set () of its possible traces depends on valuations [[]] of
formulas and terms at intermediate states . The valuation of terms and interpretations
of function and predicate symbols are as for real arithmetic (Lecture 4). The valuation
of formulas will be defined in Def. 6. Again, we use xd to denote the modification that
agrees with state on all variables except for the symbol x, which is changed to d R.
Definition 3 (Trace semantics of hybrid programs). The trace semantics, (), of a
hybrid program , is the set of all its possible hybrid traces and is defined inductively as follows:
1. (x := ) = {(
,
) : = except that [[x]] = [[]] for S}
2. (x = & H) = {() : (t) |= x = and (t) |= H for all 0 t r for a sodef
(t),
lution : [0, r] S of any duration r}; i.e., with (t)(x ) = d()(x)
d
solves the differential equation and satisfies H at all times, see Lecture 2.
: [[]] = false}
3. (?) = {(
) : [[]] = true} {(
, )
4. ( ) = () ()
5. (; ) = { : () , () when is defined};
the composition of = (0 , 1 , 2 , . . . ) and = (0 , 1 , 2 , . . . ) is
(0 , . . . , n , 0 , 1 , . . . )
:=
not defined
S
6. ( ) = nN (n ), where n+1 := (n ; ) for n 1, as well as 1 := and
0 := (?true).
Time passes differently during discrete and continuous change. During continuous
evolution, the discrete step index i of positions (i, ) remains constant, whereas the
continuous duration remains 0 during discrete point flows. This permits multiple
discrete state changes to happen at the same (super-dense) continuous time, unlike in
other approaches [ACD90].
Example 4. For comparing the transition semantics of hybrid programs for dL from
Lecture 3 and the trace semantics of hybrid programs for dTL from Def. 3, consider the
following simple hybrid program :
a := 2a; a := a2 .
The transition semantics is just the relation between initial and final states:
() {(, ) : is like except that (a) = 4(a)2 }.
A NDR E P LATZER
L16.6
In particular, the dL formula []a 0 is valid, because all final states have a square as
the value of a. In contrast, the trace semantics of retains all intermediate states:
() {(
, s,
) : s is like except s(a) = 2(a)
and is like s except (a) = s(a)2 = 4(a)2 }.
During these traces, a 0 does not hold at all states. If the trace starts with a positive
value ( |= a > 0), then it will become negative at the point flow s (where s |= a < 0),
yet recover to a positive value ( |= a > 0) at the end.
Example 5. The previous example only had discrete jumps, and, thus, the traces only
involved point flows. Now consider the hybrid program from the train context:
a := b; z = v, v = a; ?v 0; a := A; z = v, v = a.
The transition semantics of this program only considers successful runs to completion.
In particular, if A > 0, the velocity v will always be nonnegative at the end (otherwise
the test ?v 0 in the middle fails and the program aborts), because the last differential
equation will accelerate and increase the velocity again. Thus, the position z at the end
of the program run will never be smaller than at the beginning.
If, instead, we consider the trace semantics of , all intermediate states are in the set
of traces:
() {(0 , 1 , 1 , 2 , 3 , 2 ) : 1 = 0 [a 7 0 (b)] and
1 is a state flow of some duration r1 0 with 1 |= z = v v = a
starting in 1 (0) = 1 and ending in a state with 1 (r1 )(v) 0
and 2 = 1 (r1 ), 3 = 1 (r1 )[a 7 1 (r1 )(A)] and
2 is a state flow of some duration r2 0 with 2 |= z = v v = a
starting in 2 (0) = 3 and ending in state 2 (r2 )}
: 1 = 0 [a 7 0 (b)] and
{(0 , 1 , 1 , 2 , )
1 is a state flow of some duration r 0 with 1 |= z = v v = a
starting in 1 (0) = 1 and ending in a state with 1 (r)(v) < 0
further 2 = 1 (r)}.
The first set is the set of traces where the test ?v 0 in the middle succeeds and the
system continues. The second set (after the union) is the set of traces that are aborted
during their execution, because the middle test fails. Note that the traces in the
with
first set have two continuous flows 1 , 2 and four point flows 0 , 1 , 2 , 3 in each
trace. The traces in the second set have only one continuous flow 1 and three point
does not terminate and
flows 0 , 1 , 2 , because the subsequent aborting point flow
aborts all further execution. In the trace semantics, v < 0 is possible in the middle of
some traces, which is a fact that the transition semantics does not notice. Combining
traces for , that is, for
(a := 2a; a := a2 ) (a := b; z = v, v = a; ?v 0; a := A; z = v, v = a)
A NDR E P LATZER
L16.7
is just the union () () of the traces () and () from Examples 4 and 5. Note
that a 0 will hold at least once during every trace of , either in the beginning, or
after setting a := 2a or a := b, respectively, when we assume b > 0.
A NDR E P LATZER
L16.8
Definition 6 (dTL semantics). The satisfaction relation |= for a dTL (state) formula in state is defined inductively:
|= (1 = 2 ) iff [[1 ]] = [[2 ]] .
|= (1 2 ) iff [[1 ]] [[2 ]] .
|= iff 6|= , i.e. if it is not the case that |= .
|= iff |= and |= .
|= iff |= or |= .
|= iff 6|= or |= .
|= iff ( |= and |= ) or ( 6|= and 6|= ).
|= x iff xd |= for all d R.
|= x iff xd |= for some d R.
|= [] iff for each trace ()that starts in first = , if [[]] is defined,
then [[]] = true.
|= hi iff there is a trace () starting in first = such that [[]] is
defined and [[]] = true.
For trace formulas, the valuation [[]] with respect to trace is defined inductively
as:
1. If is a state formula, then [[]] = [[]]last if terminates, whereas [[]] is not
defined if does not terminate.
2. [[]] = true iff i () |= holds for all positions (i, ) of with i () 6= .
3. [[]] = true iff i () |= holds for some position (i, ) of with i () 6= .
As usual, a (state) formula is valid if it is true in all states. If |= , then we say that
dTL state formula is true at or that is a model of . A (state) formula is valid,
written , iff |= for all states . A formula is a consequence of a set of formulas
, written , iff, for each : ( |= for all ) implies that |= . Likewise, for
trace formula and trace we write |= iff [[]] = true and 6|= iff [[]] = false. In
particular, we only write |= or 6|= if [[]] is defined, which it is not the case if
is a state formula and does not terminate. The points where a dTL property has to
hold for the various combinations of temporal and dynamic modalities are illustrated
in Fig. 1.
A NDR E P LATZER
[]
L16.9
hi
[]
hi
[]
hi
n
Figure 1: Trace semantics of dTL formulas
A NDR E P LATZER
L16.10
7 Summary
This lecture introduced a temporal extension of the logic dL and a trace semantics of
hybrid programs. This extends the syntax and semantics to the presence of temporal
modalities. The next lecture investigates how to prove temporal properties of hybrid
systems.
Exercises
Exercise 1. Can you give a formula of the following form that is valid?
[] []
Exercise 2. In which case does the temporal [] differ from the nontemporal [].
A NDR E P LATZER
L16.11
References
[ACD90]
[BS01]
[DBL12]
[EC82]
E. Allen Emerson and Edmund M. Clarke. Using branching time temporal logic to synthesize synchronization skeletons. Sci. Comput. Program.,
2(3):241266, 1982.
[EH86]
[HKT00]
David Harel, Dexter Kozen, and Jerzy Tiuryn. Dynamic logic. MIT Press,
2000.
[HNSY92] Thomas A. Henzinger, Xavier Nicollin, Joseph Sifakis, and Sergio Yovine.
Symbolic model checking for real-time systems. In LICS, pages 394406.
IEEE Computer Society, 1992.
[Pla07]
Andre Platzer. A temporal dynamic logic for verifying hybrid system invariants. In Sergei N. Artemov and Anil Nerode, editors, LFCS,
volume 4514 of LNCS, pages 457471. Springer, 2007. doi:10.1007/
978-3-540-72734-7_32.
[Pla08]
[Pla10]
Andre Platzer.
Logical Analysis of Hybrid Systems: Proving Theorems
for Complex Dynamics.
Springer, Heidelberg, 2010.
doi:10.1007/
978-3-642-14509-4.
[Pla12a]
[Pla12b]
[Pla12c]
A NDR E P LATZER
L16.12
[Pra79]
A NDR E P LATZER
Lecture Notes on
Differential & Temporal Proofs
Andre Platzer
Carnegie Mellon University
Lecture 17
1 Introduction
This lecture continues the study of temporal aspects of cyber-physical systems that Lecture 5 on Differential & Temporal Logics started. The trace semantics of hybrid programs as well as the semantics of differential temporal dynamic logic (dTL) [Pla10], a
temporal extension of differential dynamic logic dL [Pla08, Pla12], have been discussed
in said lecture.
This lecture is based on [Pla10, Chapter 4], which extends [Pla07].
A NDR E P LATZER
L17.2
rules from dL. That is, it includes the propositional and quantifier rules from Lecture 6.
The dynamic rules (h;i[ ]) and global rules ([]gen,higen,ind,con) for handling nontemporal dynamic modalities are also inherited directly from Lecture 6. The only possible
exception is that [],hi can be generalised to apply to formulas of the form [ ]
where is an arbitrary trace formula, and not just a state formula as in dL. Thus, may
begin with or , which is why the rules are repeated in this generalised form as []
and hi in Fig. 1.
Note 1.
([])
([; ])
([?])
([:=])
([ ])
([n ])
([ ])
1
[] [] 1
[ ]
[] [][]
[; ]
[?]
[x := ]
[x := ]
[x = ]
[x = ]
[; ]
[ ]
[ ][]
[ ]
(hi)
(h; i)
(h?i)
(h:=i)
(h i)
(hn i)
(h i)
hi hi 1
h i
hi hihi
h; i
h?i
hx := i
hx := i
hx = i
hx = i
h; i
h i
h ihi
h i
is a trace formula andunlike the state formulas and may thus begin with a temporal
modality or .
Temporal Rules The new temporal rules in Fig. 1 for the dTL calculus successively
transform temporal specifications of hybrid programs into nontemporal dL formulas.
The idea underlying this transformation is to decompose hybrid programs and recursively augment intermediate state transitions with appropriate specifications. Also see
Fig. 2 for an illustration of the correspondence of a representative set of proof rules for
temporal modalities to the trace semantics of hybrid programs (Def. ??).
Rule [; ] decomposes invariants of ; (i.e., [; ] holds) into an invariant of
(i.e., []) and an invariant of that holds when is started in any final state of
(i.e., []([])). Its difference with the dL rule [;] thus is that the dTL rule [; ] also
checks safety invariant at the symbolic states in between the execution of and , and
recursively so because of the temporal modality . Again, see Fig. 2 for an illustration
A NDR E P LATZER
L17.3
[x := ]
[x := ]
x :=
[x := ]
x = f (x)
[x = ]
[x = ]
s
x = f (x)
[] [][]
[; ]
s
[]
[] []
[ ]
; (if non-terminate)
1
2
[ ][]
[ ]
[]
A NDR E P LATZER
L17.4
(1)
A NDR E P LATZER
L17.5
4 Verification Example
Recall the bouncing ball. The proofs from previous lectures or Fig. 4 can be generalized
easily to a proof of the temporal property
v 2 2g(H h) h 0 g > 0 H 0 1 > c 0
A NDR E P LATZER
L17.6
, , s0, h + vs
g 2
2s
h:=i
[:=]
, , s0 hh := ..(s)i(h = 0 [v := cv] )
[?]
[;]
, , s0 hh := ..(s)i[?h = 0; v := cv]
, , s0, h + vs
h:=i
g 2
2s
, , s0 hh := ..(s)i(h > 0
[?]
, , s0 hh := ..(s)i[?h > 0]
...
...
, , s0 hh := ..(s)i[?h > 0]
, , s0 hh := ..(s)i[?h = 0; v := cv]
[]
[ ]
[;]
ind
r,l
A NDR E P LATZER
L17.7
h:=i
[:=]
[?]
[;]
, s0, , h + vs
h:=i
g 2
2s
[?]
...
...
. . . hh := ..(s)i[?h > 0]
[]
[ ]
[;]
ind
A NDR E P LATZER
L17.8
the subsequent tests ?h = 0 and ?h > 0. A state with negative height fails both tests.
While this behaviour does not give a successful program transition of (, ) (ball)
by Lecture 3 so that the proof in Fig. 3 is correct, the behaviour still gives a valid trace
(ball) by Def. ??. This trace is a partial trace, because it ends in a failure state
, but it is still one of the traces that [ball](0 h H) quantifies over (quite unlike
[ball](0 h H), which only considers final states of successful traces).
5 Summary
This lecture showed a systematic way of specifying and verifying temporal properties
of hybrid systems. The focus was on safety properties that hold always throughout
the evolution of the system and are specified as [] with a mix of a temporal and
a dynamic modality instead of just a dynamic modality as in []. The difference is
that [] includes that safety condition holds at all intermediate states during all
traces of , whereas [] only specifies that holds at the end of each trace of . This
difference matters in systems that have more intermediate states than final states. The
difference is insignificant for systems that can stop anytime, because those will already include all intermediate states of longer system runs as the final state of a corresponding shorter system run. This has been the case in almost all systems studied in
this course and is frequently the case in practice.
The systematic way of ensuring safety always throughout the execution of hybrid
systems is the use of the dynamic and temporal modality [], which works whether
or not the system has the special structure that allows it to stop anytime. In a nutshell,
the temporal proof rules for [] properties lead to additional branches that correspond to the safety conditions at the respective intermediate state. It can be shown
that temporal dTL properties reduce to nontemporal dL properties completely [Pla10,
Chapter 4], justifying the intimate relation of temporal and nontemporal properties
That completeness result made crucial use of the clever form of the [ ] proof rule.
Other temporal modalities are more complicated but can either be handled directly
(in the case of hi) or by transformation [Pla10].
Exercises
Exercise 1. Can you give a formula of the following form that is valid?
[] []
Exercise 2. In which case does the temporal [] differ from the nontemporal [].
Exercise 3. Can you give a temporal box version of the differential invariant proof rule?
A NDR E P LATZER
L17.9
References
[Pla07] Andre Platzer. A temporal dynamic logic for verifying hybrid system invariants. In Sergei N. Artemov and Anil Nerode, editors, LFCS, volume 4514 of
LNCS, pages 457471. Springer, 2007. doi:10.1007/978-3-540-72734-7_32.
[Pla08] Andre Platzer. Differential dynamic logic for hybrid systems. J. Autom. Reas.,
41(2):143189, 2008. doi:10.1007/s10817-008-9103-8.
[Pla10] Andre Platzer. Logical Analysis of Hybrid Systems: Proving Theorems for Complex
Dynamics. Springer, Heidelberg, 2010. doi:10.1007/978-3-642-14509-4.
[Pla12] Andre Platzer. Logics of dynamical systems. In LICS, pages 1324. IEEE, 2012.
doi:10.1109/LICS.2012.13.
A NDR E P LATZER
Lecture Notes on
Virtual Substitution & Real Equations
Andre Platzer
Carnegie Mellon University
Lecture 18
1 Introduction
Cyber-physical systems are important technical concepts for building better systems
around us. Their safe design requires careful specification and verification, which this
course provides using differential dynamic logic and its proof calculus [Pla08, Pla10,
Pla12b]. The proof calculus for differential dynamic logic has a number of powerful
axioms and proof rules (especially in Lecture 5, Lecture 6, Lecture 11, and Lecture 15).
In theory, the only difficult problem in proving hybrid systems safety is finding their invariants or differential invariants [Pla08, Pla12a] (Lecture 14 on Differential Invariants
& Proof Theory). In practice, however, the handling of real arithmetic is another challenge that you have faced, even though the problem is easier in theory. How arithmetic
interfaces with proofs has already been discussed in Lecture 9 on Proofs & Arithmetic.
Todays lecture shows one technique for deciding interesting formulas of first-order real
arithmetic. Understanding how such techniques for real arithmetic work is interesting
for at least two reasons. First of all, it is important to understand why this miracle happens that something as complicated and expressive as first-order logic of real arithmetic
is decidable. But it is also helpful to get an intuition about how real arithmetic decision
procedures work. With such an understanding, you are better prepared to identify the
limitations of these techniques, learn when they are likely not to work out in due time,
and get a sense of what you can do to help arithmetic prove more complicated properties. For complex proofs, it is often very important to use your insights and intuitions
about the system to help the prover along to scale more.
These lecture notes are loosely based on [Wei97, Pla10, Appendix D]. They add substantial intuition and motivation that is helpful for following the technical development. More information about virtual substitution can be found in the literature [Wei97].
See, e.g., [PQR09, Pas11] for an overview of other techniques for real arithmetic.
November 4, 2013
A NDR E P LATZER
L18.2
Respectively over another real-closed field, but that has been shown not to change validity [Tar51].
A NDR E P LATZER
L18.3
complete [God30])
proof procedure that is algorithmic and able to prove all true sentences of first-order logic [Her30]. The natural numbers are much more difficult. By
Godels
incompleteness theorem, first-order logic FOLN of natural numbers does not
have a sound and complete effective axiomatization. FOLN is neither semidecidable
nor cosemidecidable [Chu36]. There is neither an algorithm that can prove all valid formulas of FOLN nor one that can disprove all formulas of FOLN that are not valid. One
way of realizing the inherent challenge of the logic of natural numbers is to use that
not all questions about programs can be answered effectively (for example the halting
problem of Turing machines is undecidable) [Chu36, Tur37], in fact none can [Ric53].
Yet, a miracle happened. Alfred Tarski proved in 1930 [Tar31, Tar51] that reals are
much better behaved and that FOLR is decidable, even though this seminal result remained unpublished for many years and only appeared in full in 1951 [Tar51].
The first-order logic FOLQ of rational numbers, however, was shown to be undecidable [Rob49], even though rational numbers may appear to be so close to real numbers.
Rationals are lacking something important: completeness (in the topological sense).
Note 1 (Overview of validity problems of first-order logics).
Logic Validity
FOL
semidecidable
FOLN not semidecidable nor cosemidecidable
FOLQ not semidecidable nor cosemidecidable
FOLR decidable
FOLC decidable
3 Quantifier Elimination
Alfred Tarskis seminal insight for deciding real arithmetic is based on quantifier elimination, i.e. the successive elimination of quantifiers from formulas so that the remaining
formula is equivalent but structurally significantly easier. Why does eliminating quantifiers help? When evaluating a logical formula for whether it is true or false in a given
state (i.e. an assignment of real numbers to all its free variables), arithmetic comparisons and polynomial terms are easy, because all we need to do is plug the numbers in
and compute according to their semantics (recall Lecture 2). For example, for a state
with (x) = 2, we can easily evaluate the logical formula
x2 > 2 2x < 3 x3 < x2
to true just by plugging in 2 for x. But quantifiers are difficult, because they require
us to check for all possible values of a variable (in the case x F ) or to find exactly the
right value for a variable that makes the formula true (in the case of x F ). The easiest
formulas to evaluate are the ones that have no free variables (because then their value
does not depend on the state) and that also have no quantifiers (because then there are
A NDR E P LATZER
L18.4
no choices for the values of the quantified variables during the evaluation). Quantifier elimination can take a logical formula that is closed, i.e. has no free variables, and
equivalently remove its quantifiers, so that it becomes easy to evaluate the formula to
true or false. Quantifier elimination also works for formulas that still have free variables. Then it will eliminate all quantifiers in the formula but the original free variables
will remain in the resulting formula, unless it simplifies in the quantifier elimination
process.
Definition 1 (Quantifier elimination). A first-order theory admits quantifier elimination if, with each formula , a quantifier-free formula QE() can be associated
effectively that is equivalent, i.e. QE() is valid (in that theory).
Theorem 2 (Tarski [Tar51]). The first-order logic of real arithmetic admits quantifier
elimination and is, thus, decidable.
The operation QE is further assumed to evaluate ground formulas (i.e., without variables), yielding a decision procedure for closed formulas of this theory (i.e., formulas
without free variables). For a closed formula , all it takes is to compute its quantifierfree equivalent QE() by quantifier elimination. The closed formula is closed, so has
no free variables or other free symbols, and neither will QE(). Hence, as well as its
equivalent QE() are either equivalent to true or to false. Yet, QE() is quantifier-free,
so which one it is can be found out simply by evaluating the (variable-free) concrete
arithmetic in QE().
Example 3. Quantifier elimination uses the special structure of real arithmetic to express quantified arithmetic formulas equivalently without quantifiers and without using more free variables. For instance, QE yields the following equivalence:
QE(x (2x2 + c 5)) c 5.
In particular, the formula x (2x2 + c 5) is not valid, but only if c 5, as has been so
aptly described by the outcome of the above quantifier elimination result.
Example 4. Quantifier elimination can be used to find out whether a first-order formula
of real arithmetic is valid. Take x (2x2 + c 5), for example. A formula is valid
iff its universal closure is, i.e. the formula obtained by universally quantifying all free
variables. After all, valid means that a formula is true for all intepretations. Hence,
consider the universal closure c x (2x2 + c 5), which is a closed formula. Quantifier
elimination might, for example, lead to
QE(c x (2x2 +c 5)) QE(c QE(x (2x2 +c 5))) QE(c (c 5)) 100 55 5100 5
The resulting formula is still has no free variables but is now quantifier-free, so it can
simply be evaluated arithmetically. Since the conjunct 100 5 evaluates to false, the
universal closure c x (2x2 + c 5) is equivalent to false and, hence, the original formula x (2x2 + c 5) is not valid (although still satisfiable for c = 1).
A NDR E P LATZER
L18.5
Eng93] and a major breaktook many further advances [Sei54, Coh69, KK71, Hor83,
through by George Collins in 1975 [Col75] until more practical procedures had been
found [Col75, CH91, Wei97]. The virtual substitution technique shown in this lecture
has been implemented in Redlog [DS97], which has an interface for KeYmaera [PQ08].
4 Homomorphic Normalization
The first insight for defining quantifier elimination is to understand that the quantifier
elimination operation commutes with almost all logical connectives, so that QE only
needs to be defined for existential quantifiers. Especially, as soon as we understand
how to eliminate existential quantifiers, universal quantifiers can be eliminated as well
just by double negation.
QE(A B) QE(A) QE(B)
QE(x A) QE(x A)
These transformations isolate existential quantifiers for quantifier elimination. In particular, it is sufficient if quantifier elimination focuses on existentially quantified variables. When using the QE operation inside out, i.e. when using it repeatedly to eliminate the inner-most quantifier to a quantifier-free equivalent and then again eliminating the inner-most quantifier, the quantifier elimination is solved if only we manage to
solve it for x A with a quantifier-free formula A. If A is not quantifier-free, its quantifiers can be eliminated from inside out:
QE(x A) QE(x QE(A))
if A not quantifier-free
It is possible, although not necessary and not even necessarily helpful, to simply the
form of A as well. The following transformations transform the kernel of a quantifier
into negation normal form using deMorgans equivalences.
QE(x (A B)) QE(x A) QE(x B)
A NDR E P LATZER
L18.6
Distributivity can be used to simplify the form of the quantifier-free kernel A to disjunctive normal form and split existential quantifiers over disjuncts:
QE(x (A (B C))) QE(x ((A B) (A C)))
The remaining case to address is the case QE(x (A B)) where A B is a purely
conjunctive formula (yet it can have any number of conjuncts, not just two). Using the
following normalizing equivalences,
p=q pq =0
pq pq 0
p>q pq >0
p 6= q p q 6= 0
pq qp0
p<q qp>0
(p q) p < q
(p > q) p q
(p = q) p 6= q
(p 6= q) p = q
it is further possible to normalize all atomic formulas equivalently to one of the forms
p = 0, p > 0, p 0, p 6= 0. Since p 6= 0 p > 0 p < 0, disequations 6= are unnecessary
in theory as well (although they are useful in practice).
5 Substitution Base
Virtual substitution is a quantifier elimination technique that is based on substituting
extended terms into formulas virtually, i.e. without the extended terms2 actually occurring in the resulting constraints.
Note 4. Virtual substitution essentially leads to an equivalence of the form
_
At Fxt
x F
(1)
tT
for a suitable finite set T of extended terms that depends on the formula F and that gets
substituted into F virtually, i.e. in a way that results in standard real arithmetic terms,
not extended terms.
2
Being an extended real term really means it is not a real term, but somehow closely related. We will see
more concrete extended real terms and how to get rid of them again later.
A NDR E P LATZER
L18.7
Such an equivalence is how quantifier elimination can work. Certainly if the right-hand
side of (1) is true, then t is a witness for x F . The key to establishing an equivalence of
the form (1) is to ensure that if F has a solution (in the sense of x F being true), then F
must hold for one of the cases in T . That is, T must cover all representative cases. If we
def
were to choose all real numbers T = R, then (1) would be trivially valid, but then the
right-hand side is not a formula because it is uncountably infinitely long, which is even
worse than the quantified form on the left-hand side. But if a finite set T is sufficient for
the equivalence (1) and the extra formulas At are quantifier-free, then the right-hand
side of (1) is structurally simpler than the left-hand side, even if it may be (sometimes
significantly) less compact.
The various ways of virtually substituting various extended reals e into logical formulas equivalently without having to mention the actual extended reals is the secret of
virtual substitution. The first step is to see that it is enough to define substitutions only
on atomic formulas of the form p = 0, p < 0, p 0 (or, just as well, on p = 0, p > 0, p 0).
If denotes such an extended substitution of for x, then lifts to arbitrary first-order
formulas homomorphically3 as follows
(A B) A B
(A B) A B
(A) A
(y A) y A
if x 6= y and x 6
(y A) y A
(p = q) (p q = 0)
if x 6= y and x 6
(p < q) (p q < 0)
(p q) (p q 0)
(p > q) (q p < 0)
(p q) (q p 0)
(p 6= q) ((p q = 0))
This lifting applies the substitution to all subformulas, with minor twists on quantifiers for admissibility and normalization of atomic formulas into the forms p = 0, p < 0, p 0
for which has been assumed to already have been defined.
6 Term Substitutions
Consider a formula of the form
x (bx + c = 0 F )
(2)
where x does not occur in the terms b, c. Lets consider how a first mathematical solution to this formula might look like. The only solution that the conjunct bx + c = 0 has
3
A NDR E P LATZER
L18.8
is x = c/b. Hence, the left conjunct in (2) only holds for x = c/b, so formula (2) can
only be true if F also holds for that single solution c/b in place of x. That is, formula
c/b
c/b
(2) holds only if Fx
does. Hence, (2) is equivalent to the formula Fx , which is
quantifier-free.
So, how can we eliminate the quantifier in (2) equivalently?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L18.9
c/b
Most certainly, Fx
is quantifier-free. But it is not exactly always equivalent to (2)
and, thus, does not necessarily qualify as its quantifier eliminate form. Oh no! What
we wrote down is a good intuitive start, but does not make any sense at all if b = 0,
for then c/b would have been a rather ill-devised division by zero. Performing such
divisions by zero sounds like a fairly shaky start for an equivalence transformation such
as quantifier elimination. And certainly like a shaky start for anything that is supposed
to turn into a proof.
Lets start over. The first conjunct in (2) has the only solution x = c/b if b 6= 0. In
c/b
that case, indeed, (2) is equivalent to Fx , because the only way for (2) to be true
then is exactly when the second conjunct F holds for the solution of the first conjunct,
c/b
i.e. when Fx
holds. But there is, in general, no way of knowing whether evaluation
could yield b 6= 0 or not, because b might be a complicated polynomial term that is only
zero under some interpretations, not under all. Certainly if b is the zero polynomial, we
know for sure. Or if b is a polynomial that is never zero, such as a sum of squares plus
a positive constant. In general, if b = 0, then, the first conjunct in (2) has all numbers
for x as solutions if c = 0 and, otherwise, has no solution at all if c 6= 0. In the latter
case, b = 0, c 6= 0, (2) is false, because its first conjunct is already false. In the former
case, b = c = 0, however, the first conjunct bx + c = 0 is trivial and does not impose any
constraints on x, nor does it help for finding out a quantifier-free equivalent of (2). In
that case b = c = 0, the trivial constraint will be dropped and the remaining formula
will be considered recursively instead.
Note 5. In the non-degenerate case b 6= 0, (2) can be rephrased into a quantifier-free
equivalent over R as follows:
b 6= 0 x (bx + c = 0 F ) b 6= 0 Fxc/b
(3)
All it takes is, thus, the ability to substitute the term c/b for x in the formula F . The dic/b
vision c/b that will occur in Fx
for ordinary term substitutions can cause technical
annoyances but at least it is well-defined, because b 6= 0 holds in that context.
7 Square Root
(4)
where x doesnot occur in the terms a, b, c. The generic solution of its first conjunct
is x = (b b2 4ac)/(2a), but that, of course, again depends on whether a could
evaluate to zero, in which case linear solutions may be possible and the division by 2a
is most certainly not well-defined. Whether a could be zero may again sometimes be
hard to say when a is a polynomial term that has roots, but does not always evaluate to 0 either (which only the zero polynomial would). So lets be more careful
this time to find an equivalent formulation right away for all possible cases of a, b, c.
A NDR E P LATZER
L18.10
The cases to consider are where the first conjunct is either a constant equation (in
which case the equation is no interesting constraint on x) or a linear equation (in which
case x = c/b is the solution
Sect. 6) or a proper quadratic equation with a 6= 0 (in
2
which case x = (b b 4ac)/(2a) is the solution). The trivial equation 0 = 0 when
a = b = c = 0 is again useless, so another part of F would have to be considered in that
case, and the equation c = 0 for a = b = 0, c 6= 0 is again false.
When ax2 + bx = 0 is either a proper linear or a proper quadratic equation, its respective solutions single out the only points that can solve (4), so the only points in which
it remains to be checked whether the second conjunct F also holds.
Theorem 5 (Virtual substitution of quadratic equations). For a quantifier-free formula
F , the following equivalence is valid over R:
a 6= 0 b 6= 0 c 6= 0
x (ax2 + bx + c = 0 F )
a = 0 b 6= 0 Fxc/b
a 6= 0 b2 4ac 0 Fx(b+
b2 4ac)/(2a)
Fx(b
b2 4ac)/(2a)
(5)
The resulting formula on the right-hand side of the biimplication is quantifier-free and,
thus, sounds like it could be chosen for QE(x (ax2 + bx + c = 0 F )) as long as it is
not the case that a = b = c = 0.
exactly a polynomial term, not even a rational term, because it involves a square root .
Hence, (5) is not generally a formula of first-order real arithmetic.
Square roots are really not part of real arithmetic. But they can be defined, still, by
(a + b c)/d
with polynomials a, b, c, d Q[x1 , . . . , xn ] of rational coefficients
in the variables x1 , . . . , xn
and, for well-definedness, d 6= 0. Square roots with the same d can be added and multiplied as expected:
A NDR E P LATZER
L18.11
Substituting
(a + b c)/d for a variable x in a polynomial term p, thus, leads to a square
(a+b c)/d
root px
= (
a + b c)/d with the same c, because the arithmetic resulting from
evaluating the polynomial only requires addition and multiplication.
Note 8. This explains how a square root expression can be substituted in for a variable
in a polynomial. Yet, the result is still a square root expression, which cannot be written
down directly in first-order real arithmetic. Yet, as soon as a square root expression, say
(a + b c)/d, appears in an atomic formula of first-order real arithmetic, the square root
can be rephrased equivalently to disappear.
Assume d 6= 0 c 0 for well-definedness. For square-root-free expressions (b = 0)
(a + 0 c)/d = 0 a = 0
(a + 0 c)/d 0 ad 0
(a + 0 c)/d 6= 0 ad 6= 0
(a + b c)/d = 0 ab 0 a2 b2 c = 0
(a + b c)/d 0 ad 0 a2 b2 c 0 bd 0 a2 b2 c 0
(a + b c)/d 6= 0 ab > 0 a2 b2 c 6= 0
This defines the substitution of a square root (a + b c)/d for x into atomic formulas
when normalizing atomic formulas appropriately4 . The important thing to observe
is that the result of this substitution does not introduce square root expressions nor
divisions even though the square root expression (a + b c)/d had the square root c
and the division /d. Substitution of a square root (a + b c)/d for x into a (quantifierfree) first-order formula F then works as usual by substitution in all atomic
formulas
(a+b c)/d
.
(as defined in Sect. 5). Denote the result of such a substitution by Fx
(a+b c)/d
(a+b c)/d
is semantically equivalent to the result Fx
of the
for x in F giving Fx
(b b2 4ac)/(2a)
Fx
4
A NDR E P LATZER
L18.12
square root expressions. In particular, since the fraction c/b also is a (somewhat im
c/b
poverished) square root expression (c + 0 0 )/b, Fx
in (5) can be formed using the
square root substitution, so the quantifier-free right-hand side of (5) neither introduces
square roots nor divisions.
With this virtual substitution, the right-hand side of the biimplication (5) can be chosen as QE(x (ax2 + bx + c = 0 F )) if it is not the case that a = b = c = 0.
When using square root substitutions, divisions could, thus, also have been avoided
in the quantifier elimination (3) for the linear case. Thus, the right-hand side of (3) can
be chosen as QE(x (bx + c = 0 F )) if it is not the case that b = c = 0.
Before going any further, it is helpful to notice that virtual substitutions admit a
number of useful optimizations that make it more practical. For example, when sub
stituting a square root expression (a +b c)/d for a variable x in a polynomial p, the
(a+b c)/d
resulting square root expression px
= (
a + b c)/d has a higher power d = dk
where k is the degree of p in variable x, just by inspecting the above definitions of
addition and multiplication. Such larger powers of d can be avoided. Note the equivalences (pq 3 0) (pq 0) and, if q 6= 0, even (pq 2 0 (p 0) for arithmetic relations
{=, >, , 6=, <, }. Since d 6= 0 for well-definedness, the degree of d in the re(a+b c)/d
sult Fx
of the virtual substitution can be lowered to 0 or 1 depending on whether
it occurs as an even or odd power.
Example 6. Using this principle to check under which circumstance the quadratic equality from (4) evaluates to true requires a nontrivial number of computations to handle
the virtual substitution of the respective roots of ax2 + bx + c = 0 into F . What would
happen if we tried to apply the same virtual substitution coming from this equation to
ax2 + bx + c = 0 itself? Imagine, for example, that ax2 + bx + c = 0 shows up again in
F . Lets only consider the
case of quadratic solutions, i.e. where a 6= 0. And lets only
consider the root (b +
b2 4ac)/(2a). The other cases are left as an exercise. First
virtually substitute (b + b2 4ac)/(2a) into the polynomial ax2 + bx + c:
(b+ b2 4ac)/(2a)
=
=
=
=
=
=
(ax2 + bx + c)x
p
p
a((b + b2 4ac)/(2a))2 + b((b + b2 4ac)/(2a)) + c
p
p
a((b2 + b2 4ac + (b b) b2 4ac)/(4a2 )) + (b2 + b b2 4ac)/(2a) + c
p
p
(ab2 + ab2 4a2 c + (ab ab) b2 4ac)/(4a2 ) + (b2 + 2ac + b b2 4ac)/(2a)
p
((ab2 + ab2 4a2 c)2a + (b2 + 2ac)4a2 + ((ab ab)2a + b4a2 ) b2 4ac)/(4a2 )
p
(2a2 b2 + 2a2 b2 8a3 c + 4a2 b2 + 8a3 c + (2a2 b 2a2 b + 4a2 b) b2 4ac)/(4a2 )
(0 + 0 0)/1 = 0
So (ax2
(b+ b2 4ac)/(2a)
c)x
A NDR E P LATZER
L18.13
cases is
(b+ b2 4ac)/(2a)
(ax2 + bx + c = 0)x
2
(ax + bx + c
(ax2 + bx + c <
(ax2 + bx + c 6=
(b+ b2 4ac)/(2a)
0)x
(b+ b2 4ac)/(2a)
0)x
(b+ b2 4ac)/(2a)
0)x
And that makes sense as well. After all, the roots of ax2 + bx + c = 0 satisfy the weak
inequality ax2 + bx + c 0 but not the strict inequality ax2 + bx + c < 0. In particular, Theorem 5 could substitute the roots of ax2 + bx + c = 0 also into the full formula
ax2 + bx + c = 0 F under the quantifier, but the formula resulting from the left conjunct ax2 + bc + c = 0 will always simplify to true so that only the virtual substitution
into F will remain.
Exercises
Exercise 1. Example 6 showedthat ax2 + bx + c = 0 simplifies to true for the virtual
substitution of
the root (b + b2 4ac)/(2a). Show
that the same thing happens for
2
the root (b b 4ac)/(2a) and the root (c + 0 0)/b.
References
[CH91]
George E. Collins and Hoon Hong. Partial cylindrical algebraic decomposition for quantifier elimination. J. Symb. Comput., 12(3):299328, 1991.
[DBL12] Proceedings of the 27th Annual ACM/IEEE Symposium on Logic in Computer Science, LICS 2012, Dubrovnik, Croatia, June 2528, 2012. IEEE, 2012.
A NDR E P LATZER
L18.14
[DS97]
[God30]
Kurt Godel.
Die Vollstandigkeit der Axiome des logischen Funktio Mon. hefte Math. Phys., 37:349360, 1930.
nenkalkuls.
[Her30] Jacques Herbrand. Recherches sur la theorie de la demonstration. Travaux de
la Societe des Sciences et des Lettres de Varsovie, Class III, Sciences Mathematiques
et Physiques, 33:33160, 1930.
[Hor83]
L. Hormander.
The Analysis of Linear Partial Differential Operators II, volume
257 of Grundlehren der mathematischen Wissenschaften. Springer, 1983.
[KK71]
[Pas11]
[Pla08]
Andre Platzer. Differential dynamic logic for hybrid systems. J. Autom. Reas.,
41(2):143189, 2008. doi:10.1007/s10817-008-9103-8.
[Pla10]
Andre Platzer. Logical Analysis of Hybrid Systems: Proving Theorems for Complex
Dynamics. Springer, Heidelberg, 2010. doi:10.1007/978-3-642-14509-4.
[Pla12a] Andre Platzer. The complete proof theory of hybrid systems. In LICS [DBL12],
pages 541550. doi:10.1109/LICS.2012.64.
[Pla12b] Andre Platzer. Logics of dynamical systems. In LICS [DBL12], pages 1324.
doi:10.1109/LICS.2012.13.
[PQ08]
A NDR E P LATZER
L18.15
[Sei54]
[Tar31]
[Tar51]
Alfred Tarski. A Decision Method for Elementary Algebra and Geometry. University of California Press, Berkeley, 2nd edition, 1951.
[Tur37]
J. Symb. Log.,
[Wei97] Volker Weispfenning. Quantifier elimination for real algebra the quadratic
case and beyond. Appl. Algebra Eng. Commun. Comput., 8(2):85101, 1997.
A NDR E P LATZER
Lecture Notes on
Virtual Substitution & Real Arithmetic
Andre Platzer
Carnegie Mellon University
Lecture 19
1 Introduction
Reasoning about cyber-physical systems and hybrid systems requires understanding
and handling their real arithmetic, which can be challenging, because cyber-physical
systems can have complex behavior. Differential dynamic logic and its proof calculus
[Pla08, Pla10, Pla12] reduce the verification of hybrid systems to real arithmetic. How
arithmetic interfaces with proofs has already been discussed in Lecture 9 on Proofs &
Arithmetic. How real arithmetic with linear and quadratic equations can be handled
by virtual substitution has been shown in Lecture 18 on Virtual Substitution & Real
Equations. Todays lecture shows how virtual substitution for quantifier elimination in
real arithmetic extends to the case of linear and quadratic inequalities.
These lecture notes are loosely based on [Wei97, Pla10, Appendix D]. They add substantial intuition and motivation that is helpful for following the technical development. More information about virtual substitution can be found in the literature [Wei97].
See, e.g., [PQR09, Pas11] for an overview of other techniques for real arithmetic.
Recall the way to handle quantifier elimination for linear or quadratic equations from
Lecture 18 on Virtual Substitution & Real Equations:
November 6, 2013
A NDR E P LATZER
L19.2
a 6= 0 b2 4ac 0 Fx(b+
b2 4ac)/(2a)
Fx(b
b2 4ac)/(2a)
(1)
When using virtual substitutions of square roots from Lecture 18, the resulting formula on the right-hand side of the biimplication is quantifier-free and can be chosen
for QE(x (ax2 + bx + c = 0 F )) as long as it is not the case that a = b = c = 0. In
case a = b = c = 0, another formula in F needs to be considered for directing quantifier
elimination, because the equation ax2 + bx + c = 0 is noninformative if a = b = c = 0,
e.g. when a, b, c are the zero polynomials or even if they just have a common root.
The formula on the right-hand side of the biimplication in (1) is a formula in the
first-order logic of real arithmetic when using the virtual substitution of square root
expressions defined in Lecture 18.
3 Infinity Substitution
Theorem 1 address the case where the quantified variable occurs in a linear or quadratic
equation. It might only occur in inequalities, however. Consider a formula of the form
x (ax2 + bx + c 0 F )
(2)
Under
the respective
A NDR E P LATZER
L19.3
happens to work is one that is so negative that it is smaller than all others: , which
is the lower limit of all negative real numbers. Alternatively, can be understood as
being always as negative as needed, i.e. more negative than anything else. Think of
as being built out of elastic rubber so that it always ends up being smaller when
being compared to any actual real number.
Let , be positive and negative infinities, respectively, i.e. choose extra elements
, 6 R with < r < for all r R. Formulas of real arithmetic can be substituted with for a variable x if the compactified reals R {, }. Yet, just like with
square root expressions, do not actually need to ever occur in the resulting formula,
because substitution of infinities can be defined differently. For example, (x + 5 > 0)
x
simplifies to false, while (x + 5 < 0)
x simplifies to true.
Note 2. Substitution of the infinity for x into an atomic formula for a polynomial
def Pn
i
p =
i=0 ai x with polynomials ai that do not contain x is defined by the following
equivalences (accordingly for substituting for x).
(p = 0)
n
^
ai = 0
(p < 0)
(p = 0)
(p 0)
x
x
x
(p <
0)
x
(p 6= 0)
x
(3)
i=0
@ (p) < 0
n
_
ai 6= 0
(4)
(5)
(6)
i=0
Lines (3) and (6) use that the only equation of real arithmetic that infinities satisfy is
the trivial equation 0 = 0. Line (4) uses the equivalence p 0 p < 0 p = 0. Line (5)
uses a simple inductive definition based on the degree, deg(p), in the variable x of the
polynomial p to characterize whether p is ultimately negative at (or for sufficiently
negative numbers):
def Pn
i
Note 3. Let p =
i=0 ai x with polynomials ai that do not contain x. Whether p is
ultimately negative (written @ (p) < 0) at is easy to characterize:
(
def p < 0
if deg(p) = 0
@ (p) < 0
P
n1
(1)n an < 0 (an = 0 @ ( i=0 ai xi ) < 0) if deg(p) > 0
Substitution of for x into an atomic formula is defined similarly, except that the sign
factor (1)n disappears. Substitution of or of for x into first-order formulas is
then defined as in Lecture 18.
Example 2. Using this principle to check under which circumstance the quadratic inequality from (2) evaluates to true yields the answer from our earlier ad-hoc analysis of
A NDR E P LATZER
L19.4
(ax2 + bx + c 0)x
In the same way, the virtual substitution can be used to see under which circumstance F
would also evaluate to true for sufficiently small values of x, exactly when Fx holds.
Note that (at least if a 6= 0), the virtual substitution of for x would not make sense
to check (2) at, because in that case, the inequality ax2 + bx + c 0 is violated. That
would be different for an inequality such as ax2 + bx + c 0.
The crucial thing to note is again that the virtual substitution of infinities for x
in F giving Fx is semantically equivalent to the result Fx of the literal substitution
replacing x with , but operationally different, because the virtual substitution never
introduces actual infinities. Because of their semantical equivalence, we use the same
notation by abuse of notation.
4 Infinitesimal Substitutions
Theorem 1 address the case where the quantified variable occurs in a linear or quadratic
equation and the virtual substitution in Sect. 3 adds the case of sufficiently small values
for x. Consider a formula of the form
x (ax2 + bx + c < 0 F )
(7)
In this case, the roots from Theorem 1 will not help, because they satisfy the equation
ax2 + bx + c = 0 but not the strict inequality ax2 + bx + c < 0. The virtual substitution
of for x from Sect. 3 still makes sense to consider, because that one might satisfy F
and ax2 + bx + c < 0. If does not work, however, the solution of (7) could be near
one of the roots of ax2 + bx + c = 0, just slightly off so that ax2 + bx + c < 0 is satisfied.
How far off? Well, saying that exactly by any real number is again difficult, because any
particular real number might already have been too large in absolute value, depending
on the constraints in the remainder of F . Again, this calls for quantities that are always
as small as we need them to be.
Sect. 3 used a negative quantity that is so small that it is smaller than all negative
numbers and hence infinitely small (but infinitely large in absolute value). Analyzing
(7) needs positive quantities that are infinitely small and hence also infinitely small in
absolute value. Infinitesimals are positive quantities that are always smaller than all
positive real numbers, i.e. always as small as needed. Think of them as built out of
elastic rubber so that they always shrink as needed when compared with any actual
positive real number so that the infinitesimals end up being smaller than positive reals.
Another way of looking at infinitesimals is that they are the multiplicative inverses of
.
A positive infinitesimal > > 0 is positive and an extended real that is infinitesimal, i.e. positive but smaller than all positive real numbers ( < r for all r R with
r > 0). For all polynomials p R[x] \ {0}, R, the Taylor expansion of p around
evaluated at + can be used to show:
A NDR E P LATZER
L19.5
1. p( + ) 6= 0
that is, infinitesimal are positive and always so small that they never yield roots
of any equation, except the trivial zero polynomial. Whenever it looks like there
might be a root, the infinitesimal just became a bit smaller. And nonzero univariate polynomials only have finitely many roots, so the infinitesimals will take care
to avoid them.
2. p() 6= 0 p()p( + ) > 0,
that is, p has constant sign on infinitesimal neighborhoods of nonroots . If the
neighborhood around is small enough (and for an infinitesimal it will be), then
the polynomial will not yet have changed sign then.
3. 0 = p() = p () = p () = = p(k1) () 6= p(k) () p(k) ()p( + ) > 0,
that is the first nonzero derivative of p at determines the sign of p in an infinitesimal neighborhood of .
Note 4. Substitution of an infinitesimal expression e + P
with a square root expression e
and a positive infinitesimal for x into a polynomial p = ni=0 ai xi with polynomials ai
that do not contain x is defined by the following equivalences.
(p = 0)e+
x
n
^
ai = 0
(8)
i=0
(9)
(10)
(11)
i=0
Lines (8) and (11) use that infinitesimals offsets satisfy no equation except the trivial
equation 0=0 (case 1). Line (9) again uses the equivalence p 0 p < 0 p = 0. Line
(10) checks that the sign of p at e is negative (which will make p inherit the same negative sign at e + by case 2) or will immediately become negative right away using a
recursive formulation of immediately becoming negative that uses higher derivatives
(which determine the sign by case 3). The lifting to arbitrary quantifier-free formulas
of real arithmetic is again by substitution into all atomic subformulas and equivalences
such as (p > q) (p q > 0) as defined in Lecture 18. Note that, for the case (p < 0)xe+ ,
the (non-infinitesimal) square root expression e gets virtually substituted in for x into
a formula @ (p) < 0, which characterizes whether p becomes negative immediately at
or after x (which will be substituted by e).
A NDR E P LATZER
L19.6
Note 5. Whether p is immediately negative, i.e. negative itself or with a derivative p that
makes it negative on an infinitesimal interval, can be characterized recursively:
(
def p < 0
if deg(p) = 0
@ (p) < 0
2
(b + b 4ac)/(2a), leads to the following computation.
@ (ax2 +bx+c) ax2 +bx+c < 0ax2 +bc+c = 0(2ax+b < 02ax+b = 02a < 0)
Hence,
2
(ax + bx + c <
(b+ b2 4ac)/(2a)+
0)x
(@ (ax + bx +
(b+ b2 4ac)/(2a)+
c))x
(b+ b2 4ac)/(2a)
01 < 00 = 0((0 < 0 4a2 0 (0 < 0 4a2 (b2 4ac) < 0)) 0| {z
= 0} |2a1{z< 0})
|
{z
}
...
(b+
2ax+b<0x
b2 4ac)/(2a)
2ax+b=0x
2a<0
(b+ b2 4ac)/(2a)
= 0 by
because the square root virtual substitution gives (ax2 + bx + c)x
construction (compare example from Lecture 18). The virtual substitution into the polynomial 2ax + b computes as follows:
(2ax + b)x(b
b2 4ac)/(2a)
p
b2 4ac)/(2a) + b
p
(2ab + 2a b2 4ac)/(2a) + b
p
(2ab + 2ab + 2a b2 4ac)/(2a)
2a (b
(ax + bx + c <
(b+ b2 4ac)/(2a)+
0)x
because the first conjunct 4a2 0 a = 0 and, with a = 0, the second conjunct sim0
plifies to 4a2 (b2 4ac)a = 0(b2 ) < 0, which is impossible in the reals. This answer
makes sense. Because, indeed, exactly if 2a < 0 will a quadratic
polynomial still evalu
ate to ax2 + bx + c < 0 right after its second root (b + b2 4ac)/(2a).
Formulas such as this one (2a > 0) are the result of a quantifier elimination procedure.
If the formula after quantifier elimination is either true or false, then you know for sure
that the formula is valid (true) or unsatisfiable (false), respectively. If the result of quantifier elimination is true, for example, KeYmaera can close proof branches (marked by
A NDR E P LATZER
L19.7
proof rule R in our sequent proofs). Yet, quantifier elimination can also return other
formulas, such as 2a > 0, which are equivalent to the formula where quantifier elimination has been applied. In particular, they identify exactly under which circumstance
that respective quantified formula is true. This can be very useful for identifying the
missing assumptions to make a proof work and the corresponding statement true.
The crucial thing to note is again that the virtual substitution of infinitesimal expressions e + for x in F giving Fxe+ is semantically equivalent to the result Fxe+ of the
literal substitution replacing x with e + , but operationally different, because the virtual substitution never introduces actual infinitesimals. Because of their semantical
equivalence, we use the same notation by abuse of notation.
Computationally more efficient substitutions of infinitesimals have been reported
elsewhere [BD07].
ax2 +bx+c
o
0 F
6=
}0)F
(ax2 +bx+c{ <
a = 0 b 6= 0 Fxc/b a 6= 0 d 0 (Fx(b+
d)/(2a)
a = 0 b 6= 0 Fxc/b+ a 6= 0 d 0 (Fx(b+
Fx(b
d)/(2a)+
Fx(b
Proof. The proof first considers the literal substitution of square root expressions, infinities, and infinitesimals and then, as a second step, uses that the virtual substitutions
that avoid square root expressions, infinities, and infinitesimals are equivalent.
The implication from the quantifier-free formula on the right-hand side (denoted G)
to x F is obvious, because each disjunct of the quantifier-free formula has a conjunct
of the form Fxt for some (extended) term t even if it may be a square root expression or
infinity or term involving infinitesimals.
The converse implication from x F to the quantifier-free formula depends on showing that the quantifier-free formula covers all possible representative cases and that the
accompanying constraints on a, b, c, d are actually necessary.
d)/(2a)
A NDR E P LATZER
d)/(2a)+
L19.8
It is enough to prove this for the case where all variables in F except x have concrete numeric real values, because the equivalence holds iff it holds in all states . By a
fundamental property of real arithmetic called o-minimality, the set S(F ) of all real values for x that satisfy F forms a finite union of (pairwise disjoint) intervals, because the
polynomials in F only change signs at their roots, of which there only are finitely many
now that the polynomials have become univariate, i.e. with the only variable x, since
all free variables are evaluated to concrete real numbers in . Without loss of generality (by merging overlapping or adjacent intervals), we assume all those intervals to be
maximal, i.e. no bigger interval would satisfy F . So F actually changes its truth-value
at the lower and upper endpoints of these intervals (unless the interval is
unbounded).
The
endpoints
of
these
intervals
can
be
seen
to
be
of
the
form
c/b,
(b+
d)/(2a), (b
A NDR E P LATZER
Ax2
L19.9
<
0 F be the only quadratic occurrence
+ Bx + C 6=
Fx Fx
_
0x2 +bx+c
o
0 F
6=
}0)F
(0x2 +bx+c{ <
b 6= 0 Fxc/b
b 6= 0 (Fxc/b+ Fxc/b )
Further optimizations are possible if some signs of a, b are known, because several cases
in the quantifier-free expansion then become impossible and can be simplified to true
or false immediately. This helps simplify the formula in Theorem 4, because one of the
cases a = 0 versus a 6= 0 might drop. But it also reduces the number of disjuncts in
Fx , see Example 3, and in the virtual substitutions of square roots (Lecture 18) and of
infinitesimals (Sect. 4).
Theorem 4 also applies for polynomials of higher degrees in x if all those factor to
polynomials of at most quadratic degree in x [Wei97]. Degree reduction is also possible
by renaming based on the greatest common divisor of all powers of x that occur in
F . If a quantified variable x occurs only with degrees that are multiples of an odd
number d then virtual substitution can use x F (xd ) y F (y). If x only occurs with
degrees that are multiples of an even number d then x F (xd ) y (y 0 F (y)). The
cases with
infinitesimals + are only needed if x occurs in strict inequalities. The cases
(b+ d)/(2a)
Fx
6 Summary
Virtual substitution is one technique for eliminating quantifiers in real arithmetic. It
works for linear and quadratic constraints and can be extended to some cubic cases
[Wei94]. Virtual substitution can be applied repeatedly from inside out to eliminate
quantifiers. In each case, however, virtual substitution requires the eliminated variable to occur with small enough degrees only. Even if that was the case initially, it
may stop to be the case after eliminating the innermost quantifier, because the degrees
of the formulas resulting from virtual substitution may increase. In that case, degree
optimizations and simplifications may sometimes work. If not, then other quantifier
elimination techniques need to be used, which are based on semialgebraic geometry or
model theory. Virtual substitution alone always works for mixed quadratic-linear formulas, i.e. those in which all quantified variables occur linearly except for one variable
that occurs quadratically. In practice, however, many other cases turn out to work well
with virtual substitution.
A NDR E P LATZER
L19.10
Exercises
Exercise 1. Consider
x (ax2 + bx + c 0 F )
(12)
b2 4ac)/(2a)
Fx(b
b2 4ac)/(2a)
But when F is ax2 + bx + e < 0, then none of those cases necessarily works. Does that
mean the result of virtual substitution is not equivalent to (12)? Where is the catch in
this argument?
References
[BD07]
[Pas11]
[Pla08]
Andre Platzer. Differential dynamic logic for hybrid systems. J. Autom. Reas.,
41(2):143189, 2008. doi:10.1007/s10817-008-9103-8.
[Pla10]
Andre Platzer. Logical Analysis of Hybrid Systems: Proving Theorems for Complex
Dynamics. Springer, Heidelberg, 2010. doi:10.1007/978-3-642-14509-4.
[Pla12]
Andre Platzer. Logics of dynamical systems. In LICS, pages 1324. IEEE, 2012.
doi:10.1109/LICS.2012.13.
A NDR E P LATZER
Lecture Notes on
Hybrid Systems & Games
Andre Platzer
Carnegie Mellon University
Lecture 20
1 Introduction
Hybrid systems have so far served us well throughout this course as a model for cyberphysical systems [Pla08, Pla10b]. Most definitely, hybrid systems can also serve as
models for other systems that are not cyber-physical per se, i.e. they are not built as
a combination of cyber and computing capabilities with physical capabilities. Some biological systems can be understood as hybrid systems, because they combine discrete
and continuous dynamics. Or physical processes in which things happen at very different speeds, so where there is a slow process about which a continuous understanding is
critical as well as a very fast process in which a discrete abstraction might be sufficient.
Neither of those examples are particularly cyber-physical. Yet, nevertheless, they can
have natural models as hybrid systems, because their fundamental characteristics is the
interaction of discrete and continuous dynamics, which is exactly what hybrid systems
are good for. Hence, despite their good match, not all hybrid systems are cyber-physical
systems.
The converse is not true either, though. Not all cyber-physical systems are hybrid
systems. The reason for that is usually not that cyber-physical systems would not involve both discrete and continuous dynamics, but, rather, that, in addition to those,
they involve also other dynamical aspects. It is a common phenomenon in cyberphysical systems that they involve several dynamical aspects, which is why they are
best understood as multi-dynamical systems, i.e. systems with multiple dynamical features [Pla12c, Pla12b, Pla11, Pla13]. And this does not only happen for cyber-physical
systems but also for other systems. Some applications imply require more dynamical
features than just discrete and continuous dynamics.
It is not going to be feasible to understand all those multi-dynamical system aspects
at once in todays lecture. But todays lecture is going to introduce one very fundamen-
A NDR E P LATZER
L20.2
tal dynamical aspect: adversarial dynamics [Pla13]. Adversarial dynamics comes from
multiple players on a hybrid system that are allowed to make their respective choices
arbitrarily. The combination of discrete, continuous, and adversarial dynamics leads to
hybrid games. Unlike hybrid systems, hybrid games allow choices in the system dynamics to be resolved adversarially by different players with different objectives.
Hybrid games are certainly necessary in situations where multiple agents actively
compete. The canonical situation of a hybrid game would, thus, be RoboCup, where
two teams of robots play robot soccer, moving around physically in space, controlled
according to discrete computer decisions, and in active competition for scoring goals in
opposite directions on the field. It turns out that hybrid games also come up for reasons
of analytic competition, that is, where possible competition is assumed for the sake of
a worst-case analysis.
Consider lab 5, for example, where a robot is interacting with a roguebot. You are in
control of the robot, but somebody else is controlling the roguebot. Your objective is to
control your robot so that it will not collide with the roguebot. That means you need
to find some way of playing your control choices for your robot so that it will be safe
for all possible control choices that the roguebot might do, after all you do not exactly
know how the other roguebot is implemented. That could be considered as the robot
playing a hybrid game with the roguebot in which your robot is trying to safely avoid
collisions. The roguebot might behave sanely and tries to stay safe as well. But if your
robot causes a collision, because it chose an action that was bad for the roguebot, your
robot would certainly be faulty and sent back to the design table.
Alas, when you try to understand how you need to control your robot to stay safe,
it can be instructive to think about what the worst-case action of a roguebot might
be to make life difficult for you. And when your friendly course instructors try to
demonstrate for you under which circumstance a simulation of your robot controller
exhibits a faulty behavior, so that you can learn from the cases where your control does
not work, they might be playing a hybrid game with you. If your robot wins and stays
safe, this can very well be an indication of a strong robot design. But if your course
TAs win and show an unsafe trace, you still win, because you learn more about the
corner cases in your robot control design than when staring at simulation movies where
everything is just fair-weather control.
If you think carefully again about lab 2, where your robot was put on a highway and
had to find some way of being controlled to stay safe for all possible choices of the robot
in front of it, then you will find that a hybrid game interpretation might be in order for
that lab as well.
These lecture notes are based on [Pla13], where more information can be found on
logic and hybrid games.
A NDR E P LATZER
L20.3
Note 1. Hybrid systems involve choices. They manifest evidently in hybrid programs as
nondeterministic choices whether to run HP or HP, in nondeterministic repetitions where the choice is how often to repeat , and in differential equations x = & H
where the choice is how long to follow that differential equation. All those choices, however,
have still been resolved in one way, i.e. by the same entity or player.
In which way the various choices are resolved depends on the context. In the box
modality [] of differential dynamic logic [Pla08, Pla10b, Pla12c], the choices are resolved in all possible ways so that the modal formula [] expresses that formula holds
for all ways how the choices in HP could resolve. In the diamond modality hi, instead, the choices are resolved in some way so that formula hi expresses that formula
holds for one way of resolving the choices in HP .
In particular, choices in helphi, because what this formulas calls for is some way
of making happen after . If has many possible behaviors, this is easier to satisfy.
Choices in hurt [], however, because this formula requires to hold for all those
choices. The more choices there are, the more difficult it is to make sure that holds
after every single combination of those choices.
Note 2. Choices in either help uniformly (when they occur in hi) or make things more
difficult uniformly (when they occur in []).
That is why these various forms of choices in hybrid programs have been called nondeterministic. They are unbiased. All possible resolutions of the choices in could
happen nondeterministically when running . Which possibilities we care about (all or
some) just depends on what the modal formula around it is that we consider.
A NDR E P LATZER
L20.4
would cause a lot of attention to Demons control, which might make him feel overly
majestic. Lets not do that, because we dont want Demon to get any ideas.
Instead, we will find it sufficient to add just a single operator to hybrid programs: the
dual operator d . What d does is to give all control that Angel had in to Demon, and,
vice versa, all control that Demon had in to Angel. The dual operator, thus, is a little
bit like what happens when you turn a chessboard around by 180 in the middle of
the game. Whoever played the choices of player White before suddenly controls Black,
and whoever played Black now controls White. With just this single duality operator
it turns out that Demon still gets his own set of controls ( , , x = & H d ) by a
suitable nesting of operators, but we did not have to give him those controls specifically.
Yet, now those extra controls are not special but simply an aspect of a more fundamental
principle: duality.
4 Hybrid Games
Differential game logic (dGL) is a logic for studying properties of hybrid games. The
idea is to describe the game form, i.e. rules, dynamics, and choices of the particular
hybrid game of interest, using a program notation and to then study its properties by
proving the validity of logical formulas that refer to the existence of winning strategies
for objectives of those hybrid games. Even though hybrid game forms only describe
the game form with its dynamics and rules and choices, not the actual objective, they
are still simply called hybrid games. The objective for a hybrid game is defined in the
modal logical formula that refers to that hybrid game form.
Definition 1 (Hybrid games). The hybrid games of differential game logic dGL are
defined by the following grammar (, are hybrid games, x a vector of variables,
a vector of (polynomial) terms of the same dimension, H is a dGL formula or just
a formula of first-order real arithmetic):
, ::= x := | x = & H | ?H | | ; | | d
The only syntactical difference of hybrid games compared to hybrid programs for
hybrid systems from Lecture 3 on Choice & Control is that, unlike hybrid programs,
hybrid games allow the dual operator d . This minor syntactic change also requires
us to reinterpret the meaning of the other operators in a much more flexible way to
make sense of the presence of subgames within the games. The basic principle is that
whenever there used to be nondeterminism in the hybrid program semantics, there
will now be a choice of Angel in the hybrid game semantics. But dont be fooled. The
parts of a such hybrid game may still be hybrid games, in which players interact, rather
than just a single system running. So all operators of hybrid games still need a careful
understanding as games, not just d , because all operators can be applied to subgames.
The atomic games of dGL are assignments, continuous evolutions, and tests. In the
deterministic assignment game (or discrete assignment game) x := , the value of variable
A NDR E P LATZER
L20.5
Note that the most common case for H is a formula of first-order real arithmetic, but any dGL formula
will work. In [Pla13], evolution domain constraints H turn out to be unnecessary, because they can
be defined using hybrid games. In the ordinary differential equation x = , the term x denotes the
time-derivative of x and is a polynomial term that is allowed to mention x and other variables.
More general forms of differential equations are possible [Pla10a, Pla10b], but will not be considered
explicitly.
A NDR E P LATZER
L20.6
6 Demons Controls
Angel has full control over all choices in each of the operators of hybrid games except
when the operator d comes into play. All choices within the scope of (an odd number
of) d belong to Demon, because d makes the players switch sides. Demons controls,
i.e. direct controls for Demon, can be defined using the duality operator d on Angels
controls.
Demonic choice between hybrid game and is , defined by (d d )d , in which
either the hybrid game or the hybrid game is played, by Demons choice. Demonic
Except that players lose if they disobey the rules of the game by failing their respective challenges.
A NDR E P LATZER
L20.7
as Demon chooses to. In , Demon chooses after each play of whether to repeat
the game, but cannot play indefinitely so he has to stop repeating ultimately. The dual
differential equation (x = & H)d follows the same dynamics as x = & H except that
Demon chooses the duration, so he cannot choose a duration during which H stops
to hold at any time. Hence he loses when H does not hold in the current state. Dual
assignment (x := )d is equivalent to x := , because it involves no choices.
Angels control operators and Demons control operators correspond to each other
by duality:
d
choice
repeat
x = evolve
?H
challenge
Demon Ops
Angel Ops
choice
repeat
d
x = evolve
?H d
challenge
7 Semantics
What is the most elegant way of defining a semantics for differential game logic? How
could a semantics be defined at all? First of all, the dGL formulas that are used in the
postconditions of dGL modal formulas hi and [] define the winning conditions for
the hybrid game . Thus, when playing the hybrid game , we need to know the set of
states in which the winning condition is satisfied. That set of states in which is true
is denoted [[]]I , which defines the semantics of .
The logic dGL has a denotational semantics. The dGL semantics defines, for each
formula , the set [[]]I of states in which is true. For each hybrid game and each
set of winning states X, the dGL semantics defines the set (X) of states from which
Angel has a winning strategy to achieve X in hybrid game , as well as the set (X)
of states from which Demon has a winning strategy to achieve X in .
A state is a mapping from variables to R. An interpretation I assigns a relation
I(p) Rk to each predicate symbol p of arity k. The interpretation further determines
the set of states S, which is isomorphic to a Euclidean space Rn when n is the number
of relevant variables. For a subset X S the complement S \ X is denoted X . Let
xd denote the state that agrees with state except for the interpretation of variable x,
which is changed to d R. The value of term in state is denoted by [[]] . The denotational semantics of dGL formulas will be defined in Def. 3 by simultaneous induction
along with the denotational semantics, () and (), of hybrid games, defined later,
because dGL formulas are defined by simultaneous induction with hybrid games. The
(denotational) semantics of a hybrid game defines for each interpretation I and each set of
Angels winning states X S the winning region, i.e. the set of states (X) from which
Angel has a winning strategy to achieve X (whatever strategy Demon chooses). The
winning region of Demon, i.e. the set of states (X) from which Demon has a winning
strategy to achieve X (whatever strategy Angel chooses) is defined later as well.
A NDR E P LATZER
L20.8
Definition 3 (dGL semantics). The semantics of a dGL formula for each interpretation I with a corresponding set of states S is the subset [[]]I S of states in which
is true. It is defined inductively as follows
1. [[p(1 , . . . , k )]]I = { S : ([[1 ]] , . . . , [[k ]] ) I(p)}
2. [[1 2 ]]I = { S : [[1 ]] [[2 ]] }
3. [[]]I = ([[]]I )
4. [[ ]]I = [[]]I [[]]I
5. [[x ]]I = { S : xr [[]]I for some r R}
6. [[hi]]I = ([[]]I )
7. [[[]]]I = ([[]]I )
A dGL formula is valid in I, written I |= , iff [[]]I = S. Formula is valid, ,
iff I |= for all interpretations I.
A graphical illustration of the choices when playing hybrid games is depicted in Fig. 1.
The nodes where Angel gets to decide are shown as diamonds , the nodes where Demon decides are shown as boxes . Circle nodes are shown when it depends on the
remaining hybrid game which player it is that gets to decide. Dashed edges indicate
Angels actions, solid edges would indicate Demons actions, while zigzag edges indicate that a hybrid game is played and the respective players move as specified by that
game. The actions are the choice of time for x = & H, the choice of playing the left
or the right game for a choice game , and the choice of whether to stop or repeat
in a repeated game . This principle can be made rigorous in an operational game semantics [Pla13], which conveys the intuition of interactive game play for hybrid games,
relates to game theory and descriptive set theory, but is also beyond the scope of these
lecture notes.
As an example, consider the filibuster formula:
h(x := 0 x := 1) ix = 0
(1)
It is Angels choice whether to repeat ( ), but every time Angel repeats, it is Demons
choice () whether to play x := 0 or x := 1. The game in this formula never deadlocks,
because every player always has a remaining move (here even two). But it may appear
as if the game had perpetual checks, because no strategy helps either player win the
game; see Fig. 2. How could that happen and what can be done about it?
A NDR E P LATZER
stop
|=
sto
p
le
ft
t1
rii
ri1
..
.
r11
r1
..
.
..
.
s0
stop
..
.
s0
t0
..
.
..
.
..
.
..
.
si
rj r1
s1
ti
r1j
repeat
repeat
repeat
repeat
stop
tj
t1
stop
stop
si
r11
at
at
ht
s1
e
rep
rig
e
rep
sto
p
0
t
x :=
[[]]
x = & H
at
repe
x :=
L20.9
t1
tj
s1
si
t0
t1
tj
A NDR E P LATZER
L20.10
at
sto
p
e
rep
stop
stop
eat
rep
eat
rep
stop
repeat
A NDR E P LATZER
L20.11
The mystery of the filibuster game can solved when we remember that the game
still ultimately ought to stop. Angel is in charge of the repetition and she can decide
whether to stop or repeat. The filibuster game has no tests, so the winner only depends
on the final state of the game. Angel wins a game play if x = 0 holds in the final state
and Demon wins if x 6= 0 holds in the final state. What do the strategies indicated
in Fig. 2 do? They postpone the end of the game forever, hence there would never
be a final state in which it could be evaluated who won. That is, indeed, not a way
for anybody to win anything. Yet, Angel was in charge of the repetition , so it is
really her fault if the game never comes to a stop to evaluate who won. Consequently,
the semantics of hybrid games requires players to not repeat indefinitely. This will be
apparent in the actual semantics of hybrid games, which is defined as a denotational
semantics corresponding to winning regions.
It is of similar importance that the players cannot decide to follow a differential equation forever (duration ), because that would make
h(x = 1d ; x := 0) ix = 0
(2)
non-determined.
Exercises
Exercise 1. Single player hybrid games, i.e. d -free hybrid games, are just hybrid programs. For each of the following formulas, convince yourself that it has the same meaning, whether you understand it as a differential dynamic logic formula with a hybrid
systems or as a differential game logic formula with a hybrid game (that happens to
have only a single player):
hx := 0 x := 1ix = 0
[x := 0 x := 1]x = 0
h(x := 0 x := 1); ?x = 1ix = 0
[(x := 0 x := 1); ?x = 1]x = 0
h(x := 0 x := 1); ?x = 0ix = 0
[(x := 0 x := 1); ?x = 0]x = 0
h(x := 0 x := 1) ix = 0
[(x := 0 x := 1) ]x = 0
h(x := 0 x := x + 1) ix = 0
[(x := 0 x := x + 1) ]x = 0
Exercise 2. Consider the following dGL formulas and identify under which circum-
A NDR E P LATZER
L20.12
h(x := x + 1; (x = x2 )d x := x 1) i (0 x < 1)
(v := a v := a v := 0);
(w := b w := b w := 0);
x = v, y = w
(x y)2 1
Exercise 3. Is the following dGL formula valid? Can you identify some circumstances
under which it is true? Or some circumstances under which it is false?
D
( := 1 := 1 := 0);
( := 1 := 1 := 0);
(x1 = d1 , x2 = d2 , d1 = d2 , d2 = d1 , , y1 = e1 , y2 = e2 , e1 = e2 , e2 = e1 )d
E
kx yk 1
References
[DBL12] Proceedings of the 27th Annual ACM/IEEE Symposium on Logic in Computer Science, LICS 2012, Dubrovnik, Croatia, June 2528, 2012. IEEE, 2012.
[Pla08]
Andre Platzer. Differential dynamic logic for hybrid systems. J. Autom. Reas.,
41(2):143189, 2008. doi:10.1007/s10817-008-9103-8.
[Pla12a] Andre Platzer. The complete proof theory of hybrid systems. In LICS [DBL12],
pages 541550. doi:10.1109/LICS.2012.64.
[Pla12b] Andre Platzer. Dynamic logics of dynamical systems. CoRR, abs/1205.4788,
2012. arXiv:1205.4788.
A NDR E P LATZER
L20.13
[Pla12c] Andre Platzer. Logics of dynamical systems. In LICS [DBL12], pages 1324.
doi:10.1109/LICS.2012.13.
[Pla13]
Andre Platzer. A complete axiomatization of differential game logic for hybrid games. Technical Report CMU-CS-13-100R, School of Computer Science,
Carnegie Mellon University, Pittsburgh, PA, January, Revised and extended
in July 2013.
A NDR E P LATZER
Lecture Notes on
Winning Strategies & Regions
Andre Platzer
Carnegie Mellon University
Lecture 21
1 Introduction
This lecture continues the study of hybrid games and their logic, differential game logic
[Pla13], that Lecture 20 on Hybrid Systems & Games started.
These lecture notes are based on [Pla13], where more information can be found on
logic and hybrid games.
2 Semantics
What is the most elegant way of defining a semantics for differential game logic? How
could a semantics be defined at all? First of all, the dGL formulas that are used in the
postconditions of dGL modal formulas hi and [] define the winning conditions for
the hybrid game . Thus, when playing the hybrid game , we need to know the set of
states in which the winning condition is satisfied. That set of states in which is true
is denoted [[]]I , which defines the semantics of .
The logic dGL has a denotational semantics. The dGL semantics defines, for each
formula , the set [[]]I of states in which is true. For each hybrid game and each
set of winning states X, the dGL semantics defines the set (X) of states from which
Angel has a winning strategy to achieve X in hybrid game , as well as the set (X)
of states from which Demon has a winning strategy to achieve X in .
A state is a mapping from variables to R. An interpretation I assigns a relation
I(p) Rk to each predicate symbol p of arity k. The interpretation further determines
the set of states S, which is isomorphic to a Euclidean space Rn when n is the number
of relevant variables. For a subset X S the complement S \ X is denoted X . Let xd
denote the state that agrees with state except for the interpretation of variable x, which
A NDR E P LATZER
L21.2
A NDR E P LATZER
L21.3
3 Winning Regions
Def. 1 needs a definition of the winning regions () and () for Angel and Demon,
respectively, in the hybrid game . Rather than taking a detour for understanding those
by operational game semantics (as in Lecture 20), the winning regions of hybrid games
can be defined directly, giving a denotational semantics to hybrid games.
Definition 2 (Semantics of hybrid games). The semantics of a hybrid game is a
function () that, for each interpretation I and each set of Angels winning states
X S, gives the winning region, i.e. the set of states (X) from which Angel has
a winning strategy to achieve X (whatever strategy Demon chooses). It is defined
inductively as followsa
[[]]
1. x:= (X) = { S : x
X}
1. x:= (X) = { S : x
X}
The semantics of a hybrid game is not merely a reachability relation between states as for hybrid
systems [Pla12], because the adversarial dynamic interactions and nested choices of the players
have to be taken into account.
A NDR E P LATZER
L21.4
This notation uses (X) instead of I (X) and (X) instead of I (X), because the interpretation I that gives a semantics to predicate symbols in tests and evolution domains is
clear from the context. Strategies do not occur explicitly in the dGL semantics, because
it is based on the existence of winning strategies, not on the strategies themselves.
Just as the semantics dL, the semantics of dGL is compositional, i.e. the semantics of
a compound dGL formula is a simple function of the semantics of its pieces, and the
semantics of a compound hybrid game is a function of the semantics of its pieces. Furthermore, existence of a strategy in hybrid game to achieve X is independent of any
game and dGL formula surrounding , but just depends on the remaining game itself and the goal X. By a simple inductive argument, this shows that one can focus on
memoryless strategies, because the existence of strategies does not depend on the context, hence, by working bottom up, the strategy itself cannot depend on past states and
choices, only the current state, remaining game, and goal. This also follows from a generalization of a classical result by Zermelo. Furthermore, the semantics is monotone,
i.e. larger sets of winning states induce larger winning regions.
Lemma 3 (Monotonicity [Pla13]). The semantics is monotone, i.e. (X) (Y ) and
(X) (Y ) for all X Y .
Proof. A simple check based on the observation that X only occurs with an even number of negations in the semantics. For example, X Y implies X Y , hence
(X ) (Y ), so d (X) = ( (X )) ( (Y )) = d (Y ).
Before going any further, however, we need to define a semantics for repetition,
which will turn out to be surprisingly difficult.
4 Examples
Consider the following examples and find out whether the formulas are valid or not.
h(x := x + 1; (x = x2 )d x := x 1) i (0 x < 1)
A NDR E P LATZER
L21.5
h(x := x + 1; (x = x2 )d x := x 1) i (0 x < 1)
(X) =
n (X)
n<
where is the first infinite ordinal (if you have never seen ordinals before, just read n <
as natural numbers n N). Would that give the intended meaning to repetition? Is
Angel forced to stop in order to win if the game of repetition would be played this way?
Yes, she would, because, even though there is no bound on the number of repetitions
that she can choose, for each natural number n, the resulting game n (X) is finite.
Would this definition capture the intended meaning of repeated game play?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L21.6
The issue is that each way of playing a repetition this way would require Angel to
choose a natural number n N of repetitions and expose this number to Demon when
playing n so that he would know how often Angel decided to repeat.
That would lead to what is called the advance notice semantics for , which requires
the players to announce the number of times that game S
will be repeated when the
n+1
(X)
as
(1)
If, in the advance notice semantics, Angel announces that she has chosen n repetitions
of the game, then Demon wins (for a 6= 0) by choosing the x := 0 option n 1 times
followed by one choice of x := a; a := 0 in the last repetition. This strategy would not
work in the dGL semantics, because Angel is free to decide whether to repeat after
each repetition based on the resulting state of the game. The winning strategy for (1)
indicated in Fig. 1(left) shows that this dGL formula is valid.
Since the advance notice semantics misses out on the existence of perfectly reasonable
winning strategies, dGL does not choose this semantics. Nevertheless, the advance
notice semantics can be a useful semantics to consider for other purposes [QP12].
6 -Strategic Semantics
The trouble with the semantics in Sect. 5 is that Angels move for the repetition reveals
too much to Demon, because Demon can inspect the remaining game n to find out
once and for all how long the game will be played before he has to do his first move.
Lets try to undo this. Another alternative choice for the semantics would have been
to allow only arbitrary finite iterations of the strategy function for computing the winning region by using the -strategic semantics, which defines
?
(X) = (X) =
n (X)
n<
along with a corresponding definition for (X). All we need to do for this is define
what it means to nest the winning region construction. For any winning condition
A NDR E P LATZER
11
11
p
sto
11
e
rep
11
L21.7
at
0
11
...
2
11
11
11
stop
01
01
10
01
00
10
01
stop
10 01
00 00 00 00 00 00 10 01
00 00 10 01 00
repeat
00 00
01
stop
10
10 01 10
at
10
at
e
rep
01
e
rep
10
10 10
00 00
Figure 1: Game trees for x = 1 a = 1 h ix 6= 1 with game
(x := a; a := 0) x := 0 (notation: x, a). (left) valid in dGL by strategy repeat once and repeat once more if x = 1, then stop (right) false in advance notice semantics by the strategy n 1 choices of x := 0 followed by x := a; a := 0
once, where n is the number of repetitions Angel announced
A NDR E P LATZER
L21.8
0 (X) = X
def
+1 (X) = X ( (X))
Does this give the right semantics for repetition of hybrid games? Does it match
the existence of winning strategies that we were hoping to define? See Fig. 2 for an
illustration.
A NDR E P LATZER
L21.9
The surprising answer is no for a very subtle but also very fundamental reason. The
existence of winning strategies for does not coincide with the th iteration of . This
will be investigated further in the next lecture.
References
[Pla12] Andre Platzer. The complete proof theory of hybrid systems. In LICS, pages
541550. IEEE, 2012. doi:10.1109/LICS.2012.64.
[Pla13] Andre Platzer. A complete axiomatization of differential game logic for hybrid games. Technical Report CMU-CS-13-100R, School of Computer Science,
Carnegie Mellon University, Pittsburgh, PA, January, Revised and extended in
July 2013.
[QP12] Jan-David Quesel and Andre Platzer. Playing hybrid games with KeYmaera. In
Bernhard Gramlich, Dale Miller, and Ulrike Sattler, editors, IJCAR, volume 7364
of LNCS, pages 439453. Springer, 2012. doi:10.1007/978-3-642-31365-3_
34.
A NDR E P LATZER
Lecture Notes on
Winning & Proving Hybrid Games
Andre Platzer
Carnegie Mellon University
Lecture 22
1 Introduction
This lecture continues the study of hybrid games and their logic, differential game logic
[Pla13], that Lecture 20 on Hybrid Systems & Games and Lecture 21 on Winning Strategies & Regions started.
These lecture notes are based on [Pla13], where more information can be found on
logic and hybrid games.
0 (X) = X
def
+1 (X) = X ( (X))
Does this give the right semantics for repetition of hybrid games? Does it match the
existence of winning strategies that we were hoping to define?
Would the following dGL formula be valid in the -strategic semantics?
h(x := 1; x = 1d x := x 1) i (0 x < 1)
(1)
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L22.2
Abbreviate
h(x := 1; x = 1d |x :={z
x 1}) i (0 x < 1)
|
{z
}
{z
It is easy to see that ([0, 1)) = [0, ), because n ([0, 1)) = [0, n) for all n N by a
simple inductive proof (recall ):
1
n+1
n
n<
n ([0, 1)) =
[0, n) = [0, )
n<
Hence, the semantics would indicate that the hybrid game (1) can exactly be won
from all initial states in [0, ), that is, for all initial states that satisfy 0 x.
Unfortunately, this is quite some nonsense. Indeed, the hybrid game in dGL formula
(1) can be won from all initial states that satisfy 0 x. But it can also be won from
other initial states! So the -strategic semantics ([0, 1)) misses out on winning states.
It is way too small for a winning region. There are cases, where the -semantics is
minuscule compared to the true winning region and arbitrarily far away from the truth
[Pla13].
In (1), this -level of iteration of the strategy function for winning regions misses out
on Angels perfectly reasonable winning strategy first choose x := 1; x = 1d and then
always choose x := x 1 until stopping at 0 x < 1. This winning strategy wins from
every initial state in R, which is a much bigger set than ([0, 1)) = [0, ).
Now this is the final answer for the winning region of (1). In particular, the dGL
formula (1) is valid. Yet, is there a direct way to see that ([0, 1)) = [0, ) is not the
final answer for (1) without having to put the winning region computations aside and
constructing a separate ingenious winning strategy?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L22.3
The crucial observation is the following. The fact ([0, 1)) = [0, ) shows that the
hybrid game in (1) can be won from all nonnegative initial values with at most (first
countably infinitely many) steps. Lets recall how the proof worked, which showed
n ([0, 1)) = [0, n) for all n N. Its inductive step basically showed that if, for whatever
reason (by inductive hypothesis really), [0, n) is in the winning region, then [0, n + 1)
also is in the winning region by simply applying () to [0, n).
How about doing exactly that again? For whatever reason (i.e. by the above argument), [0, ) is in the winning region. Doesnt that mean that ([0, )) should again
be in the winning region by exactly the same inductive argument above?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L22.4
Note 1. Whenever a set Y is in the winning region (X) of repetition, then (Y ) also
should be in the winning region (X), because it is just one step away from Y and
could simply repeat once more.
Thus, the winning region () ([0, )) should also contain
([0, )) = ([0, )) ([0, )) = R [0, ) = R
Beyond that, the winning region cannot contain anything else, because R is the whole
state space. And, indeed, trying to use the winning region construction once more on
R does not change the result:
(R) = (R) (R) = R [0, ) = R
This result, then coincides with what the ingenious winning strategy above told us as
well: formula (1) is valid, because there is a winning strategy for Angel from every
initial state. Except that the repeated () winning region construction seems more
systematic than an ingenious guess of a smart winning strategy. So it gives a more
constructive and explicit semantics.
Lets recap. In order to find the winning region of the hybrid game described in (1),
it took us not just infinitely many steps, but more than that. After many iterations to
arrive at ([0, 1)) = [0, ), it took us one more step to arrive at
() ([0, 1)) = +1 ([0, 1)) = R
where we denote the number of steps we took overall by + 1, since it was one more
step than (first countable) infinitely many (i.e. many); see Fig. 1 for an illustration.
More than infinitely many steps to get somewhere are plenty. Even worse: there are
cases where even + 1 has not been enough of iteration to get to the repetition. The
number of iterations needed to find (X) could in general by much larger [Pla13].
Figure 1: Iteration +1 (X) of () from winning condition X = [0, 1) stops when applying () to the th infinite iteration (X).
A NDR E P LATZER
L22.5
The existence of the above winning strategy is only found at the level +1 ([0, 1)) =
([0, )) = R. Even though any particular use of the winning strategy in any game
play uses only some finite number of repetitions of the loop, the argument why it will
always work requires > many iterations of (), because Demon can change x to
an arbitrarily big value, so that many iterations of () are needed to conclude that
Angel has a winning strategy for any positive value of x. There is no smaller upper
bound on the number of iterations it takes Angel to win, in particular Angel cannot
promise as a bound on the repetition count, which is what the -semantics would
effectively require her to do. But strategies do converge after + 1 iterations.
Note 2. The -semantics is inappropriate, because it can be arbitrarily far away from
characterizing the winning region of hybrid games.
(2)
because repeating once more from the winning region (X) of repetition of should
not give us any states that did not already have a winning strategy in . Consequently,
a set Z S only qualifies as a candidate for being the winning region (X) of repetition if
(Z) Z
(3)
That is, strategyzing along from Z does not give anything that Z would not already
know about.
So what is this set Z? Is there only one choice? Or multiple? If there are multiple
choices, which Z is it? Does such a Z always exist, even?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L22.6
One such Z always exist, even though it may be rather boring. The empty set Z =
certainly satisfies () = , because it is rather hard to win a game that requires Angel
to enter the empty set of states to win.
But the empty set is maybe a bit small. The winning region (X) of repetition
of should at least contain the winning condition X, because the winning condition
X is particularly easy to reach from states in X that have already let Angel won by
simply suggesting Angel to repeat zero times. Consequently, the only Z that qualify as
a candidate for being (X) should satisfy (3) and
XZ
(4)
Both conditions (3) and (4) together can be summarized in a single condition as follows:
Note 3 (Prefixpoint). Every candidate Z for the winning region (X) satisfies:
X (Z) Z
(5)
Again: what is this set Z that satisfies (5)? Is there only one choice? Or multiple? If
there are multiple choices, which Z is it? Does such a Z always exist, even?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L22.7
One such Z certainly exists. The empty set does not qualify unless X = . The
set X itself is too small unless the game has no incentive to start repeating, because
def
(X) X. But the full space Z = S always satisfies (5) trivially. Now, the whole
space is a little big to call it Angels winning region independently of the hybrid game
. Even if the full space may very well be the winning region for some particularly Demonophobic Angel-friendly hybrid games like (1), it is hardly the right winning region
for any arbitrary . For example for Demons favorite game where he always wins,
(X) had better be , not S. Thus, the largest solution Z of (5) hardly qualifies.
So which solution Z of (5) should be the definition of (X) now?
Before you read on, see if you can find the answer for yourself.
A NDR E P LATZER
L22.8
Among the many Z that solve (5), the largest one is not informative, because the
largest Z simply degrades to S. So smaller solutions Z are preferable. How do multiple
solutions relate at all? Suppose Y, Z are both solutions of (5). That is
X (Y ) Y
(6)
X (Z) Z
(7)
(6),(7)
X (Y Z) X (Y ) (Z) Y Z
(8)
Hence, by (8), the intersection Y Z of solutions Y and Z of (5) also is a solution of (5):
Lemma 1 (Intersection closure). Whenever there are two solutions Y, Z of (5), a (possibly) smaller solution of (5) can be obtained by intersection Y Z.
So whenever there are two solutions Z1 , Z2 of (5), their intersection Y1 Z2 solves (5).
When theres yet another solution Z3 of (5), their intersection Y1 Y2 Y3 also solves
(5). Similarly for any larger family of solutions. If we keep on intersecting solutions,
we will arrive at smaller solutions until, some fine day, theres not going to be a smaller
one. This yields the smallest solution Z of (5) which can be characterized directly.
Among the many Z that solve (5), the smallest Z that solves (5) is informative and
can be used to define (X):
\
(X) = {Z S : X (Z) Z}
(9)
The set on the right-hand side of (9) is an intersection of solutions, thus, a solution by
Lemma 1 (or its counterpart for families of solutions). Hence (X) itself satisfies (5):
X ( (X)) (X)
(10)
Also compare this with what we argued earlier in (2). Could it be the case that the
inclusion in (10) is strict, i.e. not equals? No this cannot happen, because (X) is the
def
smallest. In detail, by (10), the set Z = X ( (X)) satisfies Z (X) and, thus,
by Lemma 3:
mon
X (Z) X ( (X)) = Z
Consequently, both inclusions hold, so (X) satisfies
X ( (X)) = (X)
(11)
(12)
A NDR E P LATZER
L22.9
and it is the least fixpoint, i.e. the smallest Z solving the equation (12).
The fact that (X) is defined as the least of the fixpoints makes sure that Angel
only wins games by a well-founded number of repetitions. That is, she only wins a
repetition if she ultimately stops repeating, not by postponing termination forever. See
[Pla13] for more details.
It is also worth noting that it would still have been possible to make the iteration of
winning region constructions work out using the seminal fixpoint theorem of KnasterTarski. Yet, this requires the iterated winning region constructions to go significantly
transfinite [Pla13] way beyond .
A NDR E P LATZER
L22.10
1. x:= (X) = { S : x
X}
1. x:= (X) = { S : x
X}
The semantics of a hybrid game is not merely a reachability relation between states as for hybrid
systems [Pla12], because the adversarial dynamic interactions and nested choices of the players
have to be taken into account.
This notation uses (X) instead of I (X) and (X) instead of I (X), because the interpretation I that gives a semantics to predicate symbols in tests and evolution domains is
clear from the context. Strategies do not occur explicitly in the dGL semantics, because
it is based on the existence of winning strategies, not on the strategies themselves.
A NDR E P LATZER
L22.11
Just as the semantics dL, the semantics of dGL is compositional, i.e. the semantics of
a compound dGL formula is a simple function of the semantics of its pieces, and the
semantics of a compound hybrid game is a function of the semantics of its pieces. Furthermore, existence of a strategy in hybrid game to achieve X is independent of any
game and dGL formula surrounding , but just depends on the remaining game itself and the goal X. By a simple inductive argument, this shows that one can focus on
memoryless strategies, because the existence of strategies does not depend on the context, hence, by working bottom up, the strategy itself cannot depend on past states and
choices, only the current state, remaining game, and goal. This also follows from a generalization of a classical result by Zermelo. Furthermore, the semantics is monotone,
i.e. larger sets of winning states induce larger winning regions.
Monotonicity is what Lecture 21 looked into for the case of hybrid games without
repetition. But it continues to hold for general hybrid games.
Lemma 3 (Monotonicity [Pla13]). The semantics is monotone, i.e. (X) (Y ) and
(X) (Y ) for all X Y .
Proof. A simple check based on the observation that X onlyT
occurs with an even number of T
negations in the semantics. For example, (X) = {Z S : X (Z)
Z} {Z S : Y (Z) Z} = (Y ) if X Y . Likewise, X Y implies
X Y , hence (X ) (Y ), so d (X) = ( (X )) ( (Y )) = d (Y ).
Monotonicity implies that the least fixpoint in (X) and the greatest fixpoint in (X)
are well-defined [HKT00, Lemma 1.7]. The semantics of (X) is a least fixpoint, which
results in a well-founded repetition of , i.e. Angel can repeat any number of times but
she ultimately needs to stop at a state in X in order to win. The semantics of (X) is
a greatest fixpoint, instead, for which Demon needs to achieve a state in X after every
number of repetitions, because Angel could choose to stop at any time, but Demon still
wins if he only postpones X forever, because Angel ultimately has to stop repeating.
Thus, for the formula h i, Demon already has a winning strategy if he only has a
strategy that is not losing by preventing indefinitely, because Angel eventually has to
stop repeating anyhow and will then end up in a state not satisfying , which makes
her lose. The situation for [ ] is dual.
A NDR E P LATZER
L22.12
(y (t) = )
(h?i) h?Hi (H )
(hi) h i hi hi
(h;i) h; i hihi
(h i) hih i h i
(hd i) hd i hi
6 Determinacy
Every particular game play in a hybrid game is won by exactly one player, because
hybrid games are zero-sum and there are no draws. Hybrid games actually satisfy a
much stronger property: determinacy, i.e. that, from any initial situation, either one of
the players always has a winning strategy to force a win, regardless of how the other
player chooses to play.
If, from the same initial state, both Angel and Demon had a winning strategy for opposing winning conditions, then something would be terribly inconsistent. It cannot
happen that Angel has a winning strategy in hybrid game to get to a state where
and, from the same initial state, Demon supposedly also has a winning strategy in the
same hybrid game to get to a state where holds. After all, a winning strategy is
a strategy that makes that player win no matter what strategy the opponent follows.
Hence, for any initial state, at most one player can have a winning strategy for complementary winning conditions. This argues for the validity of ([] hi), which
can also be proved (Theorem 4).
So it cannot happen that both players have a winning strategy for complementary
winning conditions. But it might still happen that no one has a winning strategy, i.e.
both players can let the other player win, but cannot win strategically themselves (recall, e.g., the filibuster example from Lecture 20, which first appeared as if no player
might have a winning strategy but then turned out to make Demon win). This does not
happen for hybrid games, though, because at least one (hence exactly one) player has a
winning strategy for complementary winning conditions from any initial state.
A NDR E P LATZER
L22.13
Theorem 4 (Consistency & determinacy [Pla13]). Hybrid games are consistent and
determined, i.e. hi [].
Proof. The proof shows by induction on the structure of that (X ) = (X) for all
X S and all I with some set of states S, which implies the validity of hi []
def
using X = [[]]I .
[[]]
1. x:= (X ) = { S : x
2. x = & H (X ) = {(0) S : (r) 6 X for some 0 r R and some (dif() = [[]]() and () [[H]]I for all
ferentiable) : [0, r] S such that d (t)(x)
dt
0 r} = x = & H (X), because the set of states from which there is no
winning strategy for Angel to reach a state in X prior to leaving [[H]]I along
x = & H is exactly the set of states from which x = & H always stays in X
(until leaving [[H]]I in case that ever happens).
3. ?H (X ) = ([[H]]I X ) = ([[H]]I ) (X ) = ?H (X)
4. (X ) = ( (X ) (X )) = (X ) (X ) = (X) (X) = (X)
5. ; (X ) = ( (X )) = ( (X) ) = ( (X)) = ; (X)
T
T
{Z S : (X (Z) ) Z}
{Z S : X (Z) Z} =
6. (X ) =
S
T
{Z S : (X (Z )) Z} = {Z S : Z X (Z)} = (X). 1
=
7. d (X ) = ( ((X ) ) ) = (X ) = d (X)
Exercises
Exercise 1. Explain how often you will have to repeat the winning region construction
to show that the following dGL formula is valid:
h(x := x + 1; x = 1d x := x 1) i (0 x < 1)
Exercise 2. Can you find dGL formulas for which the winning region construction takes
even longer to terminate? How far can you push this?
Exercise 3. Carefully identify how determinacy relates to the two possible understandings of the filibuster example discussed in an earlier lecture.
1
The penultimate equation follows from the -calculus equivalence Z.(Z) Z.(Z) and the
fact that least pre-fixpoints are fixpoints and that greatest post-fixpoints are fixpoints for monotone
functions.
A NDR E P LATZER
L22.14
References
[HKT00] David Harel, Dexter Kozen, and Jerzy Tiuryn. Dynamic logic. MIT Press, 2000.
[Pla12]
Andre Platzer. The complete proof theory of hybrid systems. In LICS, pages
541550. IEEE, 2012. doi:10.1109/LICS.2012.64.
[Pla13]
Andre Platzer. A complete axiomatization of differential game logic for hybrid games. Technical Report CMU-CS-13-100R, School of Computer Science,
Carnegie Mellon University, Pittsburgh, PA, January, Revised and extended
in July 2013.
A NDR E P LATZER
Lecture Notes on
Game Proofs & Separations
Andre Platzer
Carnegie Mellon University
Lecture 23
1 Introduction
This lecture continues the study of hybrid games and their logic, differential game logic
[Pla13]. Lecture 20 on Hybrid Systems & Games introduced hybrid games, Lecture 21
on Winning Strategies & Regions studied the winning region semantics, and Lecture
22 on Winning & Proving Hybrid Games identified the winning region semantics for
loops in hybrid games as well as a study of the axioms of hybrid games.
These lecture notes are based on [Pla13], where more information can be found on
logic and hybrid games.
A NDR E P LATZER
L23.2
1. x:= (X) = { S : x
X}
1. x:= (X) = { S : x
X}
The semantics of a hybrid game is not merely a reachability relation between states as for hybrid
systems [Pla12], because the adversarial dynamic interactions and nested choices of the players
have to be taken into account.
A NDR E P LATZER
L23.3
Theorem 3 (Consistency & determinacy [Pla13]). Hybrid games are consistent and
determined, i.e. hi [].
(y (t) = )
(h?i) h?Hi (H )
(hi) h i hi hi
(h;i) h; i hihi
(h i) hih i h i
(hd i) hd i hi
hi hi
hi
(FP)
h i
[]
(ind)
[ ]
(M)
The proof rules FP and ind are equivalent in the sense that one can be derived from
the other in the dGL calculus [Pla13].
Example 4. The dual filibuster game formula from Lecture 20 proves easily in the dGL
A NDR E P LATZER
L23.4
x = 0 0 = 0 1 = 0
h:=i
x = 0 hx := 0ix = 0 hx := 1ix = 0
hi
x = 0 hx := 0 x := 1ix = 0
hd i
x = 0 hx := 0 x := 1ix = 0
[]
x = 0 [x := 0 x := 1]x = 0
ind
x = 0 [(x := 0 x := 1) ]x = 0
hd i
x = 0 h(x := 0 x := 1) ix = 0
R
4 Soundness
Theorem 5 (Soundness [Pla13]). The dGL proof calculus in Fig. 4 is sound, i.e. all provable formulas are valid.
Proof. The full proof can be found in [Pla13]. We just consider a few cases to exemplify
the fundamentally more general semantics of hybrid games arguments compared to
hybrid systems arguments. To prove soundness of an equivalence axiom , show
[[]]I = [[]]I for all interpretations I with any set of states S.
hi [[h i]]I = ([[]]I ) = ([[]]I ) ([[]]I ) = [[hi]]I [[hi]]I = [[hihi]]I
h;i [[h; i]]I = ; ([[]]I ) = ( ([[]]I )) = ([[hi]]I ) = [[hihi]]I .
h?i [[h?Hi]]I = ?H ([[]]I ) = [[H]]I [[]]I = [[H ]]I
[] is sound by Theorem 3.
M Assume the premise is valid in interpretation I, i.e. [[]]I [[]]I . Then the
conclusion hi hi is valid in I, i.e. [[hi]]I = ([[]]I ) ([[]]I ) = [[hi]]I
by monotonicity (Lemma 2).
5 Separating Axioms
The axioms of differential game logic in Fig. 4 are sound for hybrid systems as well,
because every hybrid system is a (single player) hybrid game. With a few exceptions,
they look surprisingly close to the axioms for hybrid systems from Lecture 5. In order
to understand the fundamental difference between hybrid systems and hybrid games,
it is instructive to also investigate separating axioms, i.e. axioms of hybrid systems that
are not sound for hybrid games. Some of these are summarized in Fig. 1, referring to
[Pla13] for details.
A NDR E P LATZER
L23.5
[]
1 2
[]1 []2 []
M[]
B hix x hi
I
M hi hi hi( )
(x 6 )
[] []
B x hi hix
(x 6 )
[ ]( []) ( [ ])
FA h i h i( hi)
Figure 1: Separating axioms: The axioms and rules on the left are sound for hybrid
systems but not for hybrid games. The related axioms on the right are sound
for hybrid games.
(v + 1) v + 1 > 0 hi(v)
, v (v) h iv0 (v),
The dL proof rule con expresses that the variant (v) holds for some real number v 0
after repeating sufficiently often if (v) holds for some real number at all in the beginning (antecedent) and, by premise, (v) can decrease after some execution of by 1 (or
another positive real constant) if v > 0. This rule can be used to show positive progress
(by 1) with respect to (v) by executing . Just like the induction rule ind is often used
with a separate premiss for the initial and postcondition check (ind from Lecture 7 on
Loops & Invariants), rule con is often used in the following derived form:
(con )
v (v),
v0 (v)
A NDR E P LATZER
L23.6
The following sequent proof shows how convergence rule con can be used to prove a
simple dL liveness property of a hybrid program:
con
R
x 0 n x < n + 1
x<n+2n+1>0 x1<n+1
h:=i
x < n + 2 n + 1 > 0 hx := x 1ix < n + 1
x 0 h(x := x 1) i0 x < 1
x 0 h(x := x 1) ix < 1
R
n0 x < n + 1 x < 1
Lets compare how dGL proves diamond properties of repetitions based on the iteration axiom h i.
Example 6 (Non-game system). The simple non-game dGL formula
x 0 h(x := x 1) i0 x < 1
is provable, shown in Fig. 2, where h i0 x < 1 is short for h(x := x 1) i(0 x < 1).
h(x := 1; x = 1d x := x 1) i0 x < 1
is provable as shown in Fig. 5, where the notation h( ) i0 x < 1 is short for
h(x := 1; x = 1d x := x 1) i(0 x < 1): The proof steps for use in h i that t 7 x + t
is the solution of the differential equation, so the subsequent use of h:=i substitutes 1
in for x to obtain t 7 1 + t. Recall from Lecture 22 that the winning regions for this
formula need > iterations to converge. It is still provable easily.
A NDR E P LATZER
L23.7
h i,,MP
true h( ) ix 6= 1
R
x = 1 a = 1 h( ) ix 6= 1
h;i,h:=i
h(x := 1; x = 1d x := x 1) i0 x < 1
A NDR E P LATZER
L23.8
(1)
See Fig. 6 for an illustration. Suppose the current player is Angel. The idea behind
x, z
= ( x)
z := x
H
= (z)
r
t0 := x0
Figure 6: There and back again game: Angel evolves x forwards in time along
x = (x), Demon checks evolution domain backwards in time along
z = (z) on a copy z of the state vector x
game equivalence (1) is that the fresh variable t0 remembers the initial time x0 , and
Angel then evolves forward along x = (x) for any amount of time (Angels choice).
Afterwards, the opponent Demon copies the state x into a fresh variable (vector) z that
he can evolve backwards along (z = (z))d for any amount of time (Demons choice).
The original player Angel must then pass the challenge ?(z0 t0 H(z)), i.e. Angel
loses immediately if Demon was able to evolve backwards and leave region H(z) while
satisfying z0 t0 , which checks that Demon did not evolve backward for longer than
Angel evolved forward. Otherwise, when Angel passes the test, the extra variables t0 , z
become irrelevant (they are fresh) and the game continues from the current state x that
Angel chose in the first place (by selecting a duration for the evolution that Demon
could not invalidate).
A NDR E P LATZER
L23.9
Lemma 10 can eliminate all evolution domain constraints equivalently in hybrid games
from now on. While evolution domain constraints are fundamental parts of standard
hybrid systems [Hen96, HKPV95, ACHH92, Pla08], they turn out to be mere convenience notation for hybrid games. In that sense, hybrid games are more fundamental
than hybrid systems, because they feature elementary operators.
Exercises
Exercise 1 (***). The following formula was proved using dGLs hybrid games type proof
rules in Fig. 2
x 0 h(x := x 1) i0 x < 1
Try to prove it using the convergence rule con instead.
References
[ACHH92] Rajeev Alur, Costas Courcoubetis, Thomas A. Henzinger, and Pei-Hsin Ho.
Hybrid automata: An algorithmic approach to the specification and verification of hybrid systems. In Robert L. Grossman, Anil Nerode, Anders P.
Ravn, and Hans Rischel, editors, Hybrid Systems, volume 736 of LNCS,
pages 209229. Springer, 1992.
[Hen96]
[HKPV95] Thomas A. Henzinger, Peter W. Kopke, Anuj Puri, and Pravin Varaiya.
Whats decidable about hybrid automata? In Frank Thomson Leighton
and Allan Borodin, editors, STOC, pages 373382. ACM, 1995. doi:10.
1145/225058.225162.
[HMP77]
[Pla08]
[Pla12]
Andre Platzer. The complete proof theory of hybrid systems. In LICS, pages
541550. IEEE, 2012. doi:10.1109/LICS.2012.64.
[Pla13]
A NDR E P LATZER
Lecture Notes on
Logical Theory & Completeness
Andre Platzer
Carnegie Mellon University
Lecture 24
1 Introduction
This course has studied a number of logics, first-order logic FOL in Lecture 2, differential dynamic logic dL [Pla08, Pla10a, Pla12c, Pla12b] in Lecture 3 and Lecture 4 and
following, differential temporal dynamic logic dTL [Pla07, Pla10a, Chapter 4] in Lecture 16 and 17, as well as differential game logic dGL [Pla13] since Lecture 22. There are
other logics for cyber-physical systems that have not been included in this course, but
share similar principles for further dynamical aspects. Such logics include quantified
differential dynamic logic QdL for distributed hybrid systems [Pla10b, Pla12a], which
are systems that are simultaneously distributed systems and hybrid systems, as well as
stochastic differential dynamic logic SdL for stochastic hybrid systems [Pla11], which
simultaneously involve stochastic dynamics and hybrid dynamics. Logics play a stellar
role not just in cyber-physical systems, but also many other contexts. Other important
logics include propositional logic, restrictions of first-order logic to certain theories,
such as first-order logic of real arithmetic [Tar51], and higher-order logic [And02]. But
there are numerous other important and successful logics.
In this lecture, we take a step back and study some common important concepts
in logic. This study will necessarily be hopelessly incomplete for lack of time. But it
should give you a flavor of important principles and concepts in logic that we have
not already run across explicitly in earlier lectures of this course. We will also have the
opportunity to apply these more general concepts to cyber-physical systems and learn
more about them in the next lecture.
L24.2
2 Soundness
The most important parts of a logic L are the following. The logic L defines what
the syntactically well-formed formulas are. Every well-formed formula carries meaning,
which the semantics of formulas in L defines. The semantics defines a relation between
sets of formulas and formulas, in which holds iff is a semantic consequence
of the set of formulas , i.e. is true (usually written |= ) in every interpretation
for which all formulas are true. The most important case for our purposes is
the case = of validity, in which case holds iff is valid, i.e. true ( |= ) in all
interpretations of L. An interpretation in which is true (i.e. |= ) is also called a
model of .
For the case of first-order logic FOL, Lecture 2 defined both their syntax and semantics. The syntax and semantics of differential dynamic logic dL has been defined in
Lecture 3 and Lecture 4.
The syntax of a logic L defines what we can write down that carries meaning. The
semantics of a logic L then defines what the meaning of the syntactic formulas is. The
semantics, in particular, defines which formulas express true facts about the world,
either in a particular interpretation or about the world in general (for valid formulas,
which are true regardless of the interpretation). Yet, the semantics is usually highly
ineffective, so that it cannot be used directly to find out whether a formula is valid. Just
think of formulas in differential dynamic logic that express safety properties of hybrid
systems. It would not get us very far if we were to try to establish the truth of such
a formula by literally computing the semantics (which includes executing the hybrid
system) in every initial state, of which there are uncountably infinitely many.
Instead, logics come with proof calculi that can be used to establish validity of logical
formulas in the logic L. Those proof calculi comprised axioms (Lecture 5) and proof rules
(Lecture 6 and others), which can be combined to prove or derive logical formulas of the
logic L. The proof calculus of the logic L defines a relation between sets of formulas
and formulas, in which holds iff is provable from the set of formulas . That is,
there is a proof of in the proof calculus of L that uses only assumptions from . The
most important case for our purposes is again = , in which case holds iff is
provable in the proof calculus of L, i.e. there is a proof of .
Of course, only some formulas of L are provable, not all of them. The formula p p
should not be provable in any proper logic, because it is inconsistently false and, thus,
cannot possibly be valid.
We could have written down any arbitrary axiom, or we could have accidentally had
a typo in the axioms. So a crucial question we have to ask (and have asked every time
we introduced an axiom in other lectures of this course) is whether the axioms and
proof rules are sound. In a nutshell, a proof calculus is sound if all provable formulas
are valid.
A NDR E P LATZER
L24.3
Theorem 1 (Soundness [Pla08, Pla10a, Pla12b]). The proof calculus of differential dynamic logic is sound, i.e. , which means that implies for all dL formulas .
That is, all provable dL formulas are valid.
The significance of soundness is that, whatever formula we derive by using the dL
proof rules and axioms, we can rest assured that it is valid, i.e. true in all states. In
particular, it does not matter how big and complicated the formula might be, we know
that it is valid as long as we have a proof for it. About the axioms, we can easily
convince ourselves using a soundness proof why they are valid, and then conclude
that all provable formulas are also valid, because they follow from sound axioms by
sound proof rules.
Note 2 (Necessity of soundness). Soundness is a must for otherwise we could not trust
our own proofs.
Notwithstanding of the fact that unsound analysis techniques can still be very useful in practice, especially if they identify problems in system designs. Yet, we should exercise great care in concluding
anything from unsound techniques that have not found a problem. As has been aptly phrased by
Dijkstra [Dij70]: Program testing can be used to show the presence of bugs, but never to show their
absence!
A NDR E P LATZER
L24.4
4 First-Order Logic
Even though this course primarily studied extensions of first-order logic by dynamic
modalities for hybrid systems instead of pure first-order logic, the sequent proof rules
of propositional logic and quantifiers (instantiation and Skolemization) give a suitable
proof calculus for first-order logic. And this suitability of the proof calculus for firstorder logic is a much stronger statement than soundness.
Soundness is the question whether all provable formulas are valid and is a minimal
requirement for proper logics. Completeness studies the converse question whether all
valid formulas are provable.
The first-order logic proof calculus can be shown to be both sound and complete,
albeit in a different
which is a result that originates from Godels
PhD thesis [God30],
form.
Theorem 2 (Soundness & completeness of first-order logic). First-order logic is sound,
i.e. , which means that implies for all first-order formulas (all provable
formulas are valid). First-order logic is complete, i.e. , which means that implies for all first-order formulas (all valid formulas are provable). In particular, the
provability relation and the validity relation coincide for first-order logic: = . The
same holds in the presence of a set of assumptions , i.e. iff .
This lecture will not set out for a direct proof of this result, because the techniques
used for those proofs are interesting but would lead us too far astray. An indirect justification for what makes first-order logic so special that Theorem 2 can hold will be
discussed later.
The following central result about compactness of first-order logic is of similar importance. Compactness is involved in most proofs of Theorem 2, but also easily follows
from Theorem 2.
Theorem 3 (Compactness of first-order logic). First-order logic is compact, i.e.
A E A for some finite E
(1)
(2)
Condition (2) is obvious, because provability implies that there is a proof, which can,
by definition, only use finitely many assumptions E .
Compactness is equivalent to the finiteness property, which, for that reason, is usually simply referred to as compactness:
A NDR E P LATZER
L24.5
(3)
Proof. Compactness (Theorem 3) implies the finiteness property. The key observation
is that has no model iff false, because if has no model, then false holds in all
models of of which there are none. Conversely, the only chance for false to hold in all
models of is if there are no such models, since false never holds. By Theorem 3,
false finite E E false
Hence,
has a model 2 false finite E E 2 false all finite E have a model
It is worth noting that, conversely, the finiteness property implies compactness.
A {A} has no model
some finite E {A} has no model
by finiteness
5 Skolem-Herbrand-Lowenheim
Theory
The value of a logical formula is subject to interpretation in the semantics of the logic.
In a certain sense maybe the most nave interpretation of first-order logic interprets all
terms as themselves. Such an interpretation I is called Herbrand model. It stubbornly
interprets a term f (g(a), h(b)) in the logic as itself: [[f (g(a), h(b))]]I = f (g(a), h(b)). And
likewise for all other ground terms.
That may sound like a surprising and stubborn interpretation. But, even more surprisingly, it is not at all an uninsightful one, at least for first-order logic. So insightful,
that it even deserves a name: Herbrand models. Certainly, it is one of the many permitted interpretations.
Definition 5 (Herbrand Model). An interpretation I is called Herbrand model if it
has the free semantics for ground terms, i.e.:
1. The domain D is the ground terms (i.e. terms without variables) Trm0 ()
over
2. I(f ) : Dn D; (t1 , . . . , tn ) 7 f (t1 , . . . , tn ) for each function symbol f of
arity n
A NDR E P LATZER
L24.6
Let be a set of closed universal formulas. Trm0 ()() is the set of all ground term
instances of the formulas in , i.e. with (all possible) ground terms in Trm0 () instantiated for the variables of the universal quantifier prefix.
Trm0 ()() = {(t1 , t2 , . . . , tn ) : (x1 x2 . . . xn (x1 , x2 , . . . , xn ))
t1 , . . . , tn Trm0 (), for any n N}
That is, for any n N and for any formula
x1 x2 . . . xn (x1 , x2 , . . . , xn )
in and for any ground terms t1 , . . . , tn Trm0 (), the set Trm0 ()() contains the
following ground instance of :
(t1 , t2 , . . . , tn )
Theorem 6 (Herbrand [Her30]). Let be a (suitable) set of first-order formulas (i.e.
closed universal formulas without equality and with signature having at least one
constant).
has a model has a Herbrand model
ground term instances Trm0 ()() of have a model
Using the Herbrand theorem twice gives:
has a model ground term instances Trm0 ()() of have a Herbrand model
Corollary 7. Validity in first-order logic is semidecidable.
Proof. For suitable first-order formulas F (i.e. F satisfies the assumptions of Theorem 6), semidecidability follows from the following reductions:
F valid F unsatisfiable
Trm0 ()(F ) have no model
by Theorem 6
A NDR E P LATZER
L24.7
Note 10 (Limitations of Herbrand models). Herbrand models are not the cure for everything in first-order logic, because they unwittingly forget about the intimate relationship
of the term 2 + 5 to the term 5 + 2 and, for that matter, to the term 8 1. All those terms
ought to denote the same identical object, but end up denoting different ground terms in
Herbrand models. In particular, a Herbrand model would not mind at all if a unary predicate p would hold of 2 + 5 but not hold for 5 + 2 even though both ought to denote the same
object. Thus, Herbrand models are a little weak in arithmetic, but otherwise incredibly
powerful.
Herbrands theorem has a second form with a close resemblance to the core arguments of quantifier elimination in first order logic of real arithmetic from Lecture 18
and Lecture 19.
Theorem 8 (Herbrands theorem: Herbrand disjunctions [Her30]). For a quantifierfree formula (x) of a free variable x without equality
x (x) valid (t1 ) (tn ) valid for some n N and ground terms t1 , . . . , tn
Proof. The proof follows directly from Theorem 6 and Corollary 4:
x (x) valid
x (x) unsatisfiable
x (x) has no model
Trm0 ()(x (x)) has no model
by Theorem 6
by definition
by Corollary 4
The new function symbols are usually called Skolem functions and the process called Skolemization,
because Thoralf Skolem introduced them in the first correct proof of the Skolem-Lowenheim
theorem
[Sko20]. Strictly speaking, however, Herbrand functions and Herbrandization are the more adequate
names, because Jacques Herbrand introduced this dual notion for the first proof of the Herbrand theorem [Her30]. Skolemization and Herbrandization are duals. Skolemization preserves satisfiability
while Herbrandization preserves validity.
A NDR E P LATZER
L24.8
(r)
1
(l)
, (s(X1 , . . , Xn )) 1
, x (x)
s is a new (Skolem-Herbrand) function and X1 , . . , Xn are all (existential) free logical variables
of x (x).
The clou about quantifier rules r,l is that they preserve validity. By soundness,
if their premiss is valid then so is their conclusion. Yet, in the case of rules r,l the
converse actually holds as well. If their conclusion is valid then so is their premiss.
For rule r, for example, the conclusion says that (x) holds for all values of x in all
interpretations where holds and does not. Consequently, in those interpretations,
(s(X1 , . . , Xn )) holds whatever the interpretation of s is, because s is a fresh function
symbol, which, thus, does not appear in , .
Lemma 9 (Herbrandization). With each first-order logic formula , a formula
x1 . . . xn (x1 , . . . , xn )
with quantifier-free (x1 , . . . , xn ) can be associated effectively that is valid if and only if
is. The formula x1 . . . xn (x1 , . . . , xn ) uses additional function symbols that do not
occur in .
Theorem 8 enables a second, more straightforward proof of the semidecidability of
the validity problem of first-order logic:
Proof of Corollary 7. The semidecision procedure for validity of first-order logic formulas proceeds as follows:
1. Herbrandize to obtain a formula x1 . . . xn (x1 , . . . , xn ) by Lemma 9, which
preserves validity.
2. Enumerate all m N and all ground terms tji (1 j n, 1 i m), over the
new signature.
a) If the propositional formula
(t11 , . . . , tn1 ) (t1m , . . . , tnm )
is valid, then so is x1 . . . xn (x1 , . . . , xn ) and, hence, is valid.
By Theorem 8 and Lemma 9, the procedure terminates for all valid first-order formulas.
The procedure in this proof will always succeed but it enumerates the ground terms
for instantiation rather blindly, which can cause for quite a bit of waiting. Nevertheless, refinements of this idea lead to very successful automated theorem proving techniques for first-order logic known as instance-based methods [BT10], which restrict the
instantiation to instantiation-on-demand in various ways to make the procedure more
goal-directed. There are also many successful automatic theorem proving procedures
A NDR E P LATZER
L24.9
for first-order logic that are based on different principles, including tableaux and resolution [Fit96].
6 Back to CPS
First-order logic is beautiful, elegant, expressive, and simple. Unfortunately, however,
it is not expressive enough for hybrid systems [Pla10a, Pla12b, Pla13]. As soon as we
come back to studying hybrid systems, the situation gets more difficult. And that is
not by accident, but, instead, a fundamental property of first-order logic and of hybrid
characterized first-order logic in a way that limits which propsystems. Per Lindstrom
erties stronger logics could possess [Lin69]. Hybrid systems themselves are also known
not to be semidecidable.
Given that differential dynamic logic talks about properties of hybrid systems, and
Turing machines are a special case, undecidability is not surprising. We show a very
simple standalone proof of incompleteness by adapting a proof for programs, e.g.,
[Pla10c].
Theorem 10 (Incompactness). Differential dynamic logic is not compact.
Proof. It is easy to see that there is a set of formulas that has no model even though all
finite subsets have a model, consider:
{h(x := x + 1) ix > y} {(x + n > y) : n N}
Hence, differential dynamic logic does not have the finiteness property, which is equivalent to compactness (Corollary 4).
Since soundness and completeness imply compactness (see proof of Theorem 3), incompactness implies incompleteness3 , because dL is sound. An explicit proof is as
follows:
Theorem 11 (Incompleteness [Pla08]). Differential dynamic logic has no effective sound
and complete calculus.
Proof. Suppose there was an effective sound and complete calculus for dL. Consider
a set of formulas that has no model in which all finite subsets have a model, which
exists by Theorem 10. Then 0 > 1 is valid, thus provable by completeness. But since
the proof is effective, it can only use finitely many assumptions E . Thus E 0 > 1
by soundness. But then the finite set E has no model, which is a contradiction.
Strictly speaking, incompleteness only follows for effective calculi. Relative soundness and completeness
can still be proved for dL [Pla08, Pla10a, Pla12b], which gives very insightful characterizations of the
challenges and complexities of hybrid systems.
A NDR E P LATZER
L24.10
Having said these negative (but necessary) results about differential dynamic logic
(and, by classical arguments, any other approach for hybrid systems), lets return to the
surprisingly amazing positive properties that differential dynamic logic possesses.
For one thing, the basis of differential dynamic logic is the first-order logic of real
arithmetic, not arbitrary first-order logic. This enables a particularly pleasant form of
Herbrand disjunctions resulting from quantifier elimination in real arithmetic (recall
Lecture 18 and Lecture 19).
Definition 12 (Quantifier elimination). A first-order theory admits quantifier elimination if, with each formula , a quantifier-free formula QE() can be associated
effectively that is equivalent, i.e. QE() is valid (in that theory).
Theorem 13 (Tarski [Tar51]). The first-order logic of real arithmetic admits quantifier
elimination and is, thus, decidable.
Also recall from Lecture 18 and Lecture 19 that the quantifier-free formula QE() is
constructed by substitution or virtual substitution from , with some side constraints
on the parameter relations. The quantifier-elimination instantiations are more useful
than Theorem 8, because the required terms for instantiation can be computed effectively and the equivalence holds whether or not the original formula was valid. This
makes it possible to use the proof calculus of differential dynamic logic to synthesize
constraints on the parameters to make an intended conjecture valid [Pla10a].
Exercises
Exercise 1. The arguments for incompleteness and incompactness of dL hardly depend
on dL, but, rather, only on dLs ability to characterize natural numbers. Incompleteness
and incompactness hold for other logics that characterize natural numbers due to a
A NDR E P LATZER
L24.11
References
[And02] Peter B. Andrews. An Introduction to Mathematical Logic and Type Theory: To
Truth Through Proof. Kluwer, 2nd edition, 2002.
[BT10]
[Fit96]
[God30]
Kurt Godel.
Die Vollstandigkeit der Axiome des logischen Funktio Mon. hefte Math. Phys., 37:349360, 1930.
nenkalkuls.
[God31]
Kurt Godel.
Uber
formal unentscheidbare Satze der Principia Mathematica
und verwandter Systeme I. Mon. hefte Math. Phys., 38:173198, 1931.
[Her30] Jacques Herbrand. Recherches sur la theorie de la demonstration. Travaux de
la Societe des Sciences et des Lettres de Varsovie, Class III, Sciences Mathematiques
et Physiques, 33:33160, 1930.
[Lin69]
Per Lindstrom.
On extensions of elementary logic. Theoria, 35:111, 1969.
doi:10.1111/j.1755-2567.1969.tb00356.x.
[PC07]
[Pla07]
Andre Platzer. A temporal dynamic logic for verifying hybrid system invariants. In Sergei N. Artemov and Anil Nerode, editors, LFCS, volume 4514 of
LNCS, pages 457471. Springer, 2007. doi:10.1007/978-3-540-72734-7_32.
[Pla08]
Andre Platzer. Differential dynamic logic for hybrid systems. J. Autom. Reas.,
41(2):143189, 2008. doi:10.1007/s10817-008-9103-8.
[Pla10a] Andre Platzer. Logical Analysis of Hybrid Systems: Proving Theorems for Complex
Dynamics. Springer, Heidelberg, 2010. doi:10.1007/978-3-642-14509-4.
A NDR E P LATZER
L24.12
[Pla10b] Andre Platzer. Quantified differential dynamic logic for distributed hybrid
systems. In Anuj Dawar and Helmut Veith, editors, CSL, volume 6247 of
LNCS, pages 469483. Springer, 2010. doi:10.1007/978-3-642-15205-4_36.
[Pla10c] Andre Platzer. Theory of dynamic logic. Lecture Notes 15-816 Modal
Logic, Carnegie Mellon University, 2010. URL: http://www.cs.cmu.edu/
~fp/courses/15816-s10/lectures/25-DLtheo.pdf.
[Pla11]
[Pla12a] Andre Platzer. A complete axiomatization of quantified differential dynamic logic for distributed hybrid systems. Logical Methods in Computer Science, 8(4):144, 2012. Special issue for selected papers from CSL10. doi:
10.2168/LMCS-8(4:17)2012.
[Pla12b] Andre Platzer. The complete proof theory of hybrid systems. In LICS [DBL12],
pages 541550. doi:10.1109/LICS.2012.64.
[Pla12c] Andre Platzer. Logics of dynamical systems. In LICS [DBL12], pages 1324.
doi:10.1109/LICS.2012.13.
[Pla13]
Andre Platzer. A complete axiomatization of differential game logic for hybrid games. Technical Report CMU-CS-13-100R, School of Computer Science,
Carnegie Mellon University, Pittsburgh, PA, January, Revised and extended
in July 2013.
Erfullbarkeit
oder Beweisbarkeit mathematischer Satze nebst einem The
orem uber
dichte Mengen.
Videnskapsselskapet Skrifter, I. Matematisknaturvidenskabelig Klasse, 6:136, 1920.
[Tar51]
Alfred Tarski. A Decision Method for Elementary Algebra and Geometry. University of California Press, Berkeley, 2nd edition, 1951.
A NDR E P LATZER