SLIDE 1
KeYmaera X A Tutorial on Interactive Verification for Hybrid Systems - - PowerPoint PPT Presentation
KeYmaera X A Tutorial on Interactive Verification for Hybrid Systems - - PowerPoint PPT Presentation
KeYmaera X A Tutorial on Interactive Verification for Hybrid Systems Nathan Fulton Marktoberdorf 2017 August 11, 2017 Examples: https://nfulton.org/marktoberdorf.zip Slides: https://nfulton.org/slides/marktoberdorf.pdf 1 Motivation KeYmaera
SLIDE 2
SLIDE 3
Motivation
KeYmaera X provides strong evidence that Cyber-Physical Systems are safe. But you need to provide the model and sometimes help the proof. Andr´ e’s Lectures:
◮ Differential Dynamic Logics
– Syntax and Semantics
◮ Sound and relatively
complete axiomatizations
◮ Some examples
2
SLIDE 4
Motivation
KeYmaera X provides strong evidence that Cyber-Physical Systems are safe. But you need to provide the model and sometimes help the proof. Andr´ e’s Lectures:
◮ Differential Dynamic Logics
– Syntax and Semantics
◮ Sound and relatively
complete axiomatizations
◮ Some examples
This Lecture:
◮ Practical advice for
modeling systems
◮ Hands-on Exercise proving
theorems
◮ Example-driven
2
SLIDE 5
Outline
Straight Line Dynamics The Stop Sign Model Circular Dynamics Loitering Outside Prohibited Airspace Logarithmic Dynamics Safe SCUBA Diving Extras The ODE Solver Taylor Approximations as Successive Differential Cuts
3
SLIDE 6
The Stop Sign Model
4
SLIDE 7
Take-Aways from the Stop Sign Model
◮ Focus on interesting questions by unfolding.
5
SLIDE 8
Take-Aways from the Stop Sign Model
◮ Focus on interesting questions by unfolding. ◮ Use contextual reasoning to avoid repetition of expensive or
difficult proof steps.
5
SLIDE 9
Take-Aways from the Stop Sign Model
◮ Focus on interesting questions by unfolding. ◮ Use contextual reasoning to avoid repetition of expensive or
difficult proof steps.
◮ KeYmaera X’s edit tool checks your arithmetic (common and
annoying source of errors, both in proofs and implementations!)
5
SLIDE 10
Take-Aways from the Stop Sign Model
◮ Focus on interesting questions by unfolding. ◮ Use contextual reasoning to avoid repetition of expensive or
difficult proof steps.
◮ KeYmaera X’s edit tool checks your arithmetic (common and
annoying source of errors, both in proofs and implementations!)
◮ Quantifier Elimination is a powerful tool useful for more than
just decision procedures:
◮ Find assumptions and loop invariants by reducing the
system to arithmetic and eliminating quantifiers.
◮ ModelPlex: ∀x0, x1, . . . , xn.∃y0, . . . , xn.ϕ is kinda hard to
check at runtime...
5
SLIDE 11
Outline
Straight Line Dynamics The Stop Sign Model Circular Dynamics Loitering Outside Prohibited Airspace Logarithmic Dynamics Safe SCUBA Diving Extras The ODE Solver Taylor Approximations as Successive Differential Cuts
6
SLIDE 12
Loitering Outside Prohibited Airspace
7
SLIDE 13
Loitering Outside Prohibited Airspace
y ≤ h → [r := ∗; ?r ≤ h ∧ x2 + y2 = r2
- Choose circle below h
; x′ = y, y′ = −x
- Circular dynamics
]y ≤ h
8
SLIDE 14
Lie Derivative Computations
(y ≤ h)′ ≡ (y)′ ≤ (h)′ ≡ −x ≤ 0 FALSE
9
SLIDE 15
Lie Derivative Computations
(y ≤ h)′ ≡ (y)′ ≤ (h)′ ≡ −x ≤ 0 FALSE (x2+y2 = r2)′ ≡ (x2+y2)′ = (r2)′ ≡ 2xx′+2yy′ = 0 ≡ 2xy−2xy = 0
9
SLIDE 16
Lie Derivative Computations
(y ≤ h)′ ≡ (y)′ ≤ (h)′ ≡ −x ≤ 0 FALSE (x2+y2 = r2)′ ≡ (x2+y2)′ = (r2)′ ≡ 2xx′+2yy′ = 0 ≡ 2xy−2xy = 0 r ≤ h ∧ x2 + y2 = r2 →? y ≤ h
9
SLIDE 17
Lie Derivative Computations
(y ≤ h)′ ≡ (y)′ ≤ (h)′ ≡ −x ≤ 0 FALSE (x2+y2 = r2)′ ≡ (x2+y2)′ = (r2)′ ≡ 2xx′+2yy′ = 0 ≡ 2xy−2xy = 0 r ≤ h ∧ x2 + y2 = r2 →? y ≤ h FALSE COUNTER-EXAMPLE: − 2 ≤ −2 ∧ 3 + 1 = 4 → −1 ≤ −2
9
SLIDE 18
On Annoying Assumptions
10
SLIDE 19
Take-aways from Loitering Example
◮ Like loop invariants, differential invariants sometimes need
strengthening.
11
SLIDE 20
Take-aways from Loitering Example
◮ Like loop invariants, differential invariants sometimes need
strengthening.
◮ In these cases, try using differential cuts to describe
geometric constraints on the system.
11
SLIDE 21
Take-aways from Loitering Example
◮ Like loop invariants, differential invariants sometimes need
strengthening.
◮ In these cases, try using differential cuts to describe
geometric constraints on the system.
◮ Most early proof attempts fail due to missing obvious
assumptions:
◮ Upper/lower-bounds (esp. positivity). ◮ Missing t′ = 1 in time-triggered systems. ◮ Missing control epsilon t ≤ T in evolution domain. ◮ Interesting dynamics (e.g., missing v ≥ 0).
Use counter-examples to find these errors.
11
SLIDE 22
Outline
Straight Line Dynamics The Stop Sign Model Circular Dynamics Loitering Outside Prohibited Airspace Logarithmic Dynamics Safe SCUBA Diving Extras The ODE Solver Taylor Approximations as Successive Differential Cuts
12
SLIDE 23
Safe SCUBA diving
13
SLIDE 24
Heart Rate Function
x′ = −(x − HRmax)b
14
SLIDE 25
SCUBA Ascent Case
Control Goal: Find a condition that ensures the diver reaches the surface before running out of oxygen.
15
SLIDE 26
SCUBA Proof Idea
x′ = −(x − a)b, t′ = −τx, d′ = v, c′ = C & c ≤ C ∧ d ≥ 0 Idea: Bound time and all non-linear terms, then prove linear inequalities on these bounds by integrating.
16
SLIDE 27
SCUBA Proof Idea
x′ = −(x − a)b, t′ = −τx, d′ = v, c′ = C & c ≤ C ∧ d ≥ 0 Idea: Bound time and all non-linear terms, then prove linear inequalities on these bounds by integrating.
◮ Non-linear term: x≤HRmax
16
SLIDE 28
SCUBA Proof Idea
x′ = −(x − a)b, t′ = −τx, d′ = v, c′ = C & c ≤ C ∧ d ≥ 0 Idea: Bound time and all non-linear terms, then prove linear inequalities on these bounds by integrating.
◮ Non-linear term: x≤HRmax ◮ Bound time: d0 + vc≥0 ⇒ bound on time (denote as
z = −d
v0 ).
16
SLIDE 29
SCUBA Proof Idea
x′ = −(x − a)b, t′ = −τx, d′ = v, c′ = C & c ≤ C ∧ d ≥ 0 Idea: Bound time and all non-linear terms, then prove linear inequalities on these bounds by integrating.
◮ Non-linear term: x≤HRmax ◮ Bound time: d0 + vc≥0 ⇒ bound on time (denote as
z = −d
v0 ).
t = t0 − τxc ≥ t0 − τHRmaxc ≥ t0 − τHRmaxz ≥ 0
- Initial safe states!
16
SLIDE 30
SCUBA Proof Idea
x′ = −(x − a)b, t′ = −τx, d′ = v, c′ = C & c ≤ C ∧ d ≥ 0 Idea: Bound time and all non-linear terms, then prove linear inequalities on these bounds by integrating.
◮ Non-linear term: x≤HRmax ◮ Bound time: d0 + vc≥0 ⇒ bound on time (denote as
z = −d
v0 ).
t = t0 − τxc ≥ t0 − τHRmaxc ≥ t0 − τHRmaxz ≥ 0
- Initial safe states!
The first step requires x ≤ HRmax. This is the only interesting lemma.
16
SLIDE 31
Computing the Differential Ghost
Let’s prove x < HRmax instead to avoid extra case splitting due to the x = HRmax bifurcation point.
17
SLIDE 32
Computing the Differential Ghost
Let’s prove x < HRmax instead to avoid extra case splitting due to the x = HRmax bifurcation point.
◮ Step 1: Find an existential condition equivalent to our goal:
| =RCF x < HRmax ↔ ∃y.?
17
SLIDE 33
Computing the Differential Ghost
Let’s prove x < HRmax instead to avoid extra case splitting due to the x = HRmax bifurcation point.
◮ Step 1: Find an existential condition equivalent to our goal:
| =RCF x < HRmax ↔ ∃y. y2(x − HRmax) = −1
17
SLIDE 34
Computing the Differential Ghost
Let’s prove x < HRmax instead to avoid extra case splitting due to the x = HRmax bifurcation point.
◮ Step 1: Find an existential condition equivalent to our goal:
| =RCF x < HRmax ↔ ∃y. y2(x − HRmax) = −1
◮ Step 2: Find y′ s.t. (y2(x − HRmax) = −1)′ is true:
17
SLIDE 35
Computing the Differential Ghost
Let’s prove x < HRmax instead to avoid extra case splitting due to the x = HRmax bifurcation point.
◮ Step 1: Find an existential condition equivalent to our goal:
| =RCF x < HRmax ↔ ∃y. y2(x − HRmax) = −1
◮ Step 2: Find y′ s.t. (y2(x − HRmax) = −1)′ is true:
(y2(x − HRmax) = −1)′ ≡ (y2(x − HRmax))′ = 0 ≡ 2yy′(x − HRmax) + y2x′ = 0 ≡ 2yy′(x − HRmax + y2(−(x − a)b) = 0 ≡ . . . ≡ y′ = b 2y (All equivalences are with respect to the ODE.)
17
SLIDE 36
Take-aways from SCUBA Example
◮ As systems become harder to model, parametric models
save the day.
◮ Identifying and using differential ghosts is (sometimes)
systematic.
◮ Partial solutions to fragments of an ODE’s dynamics are
useful whenever you can upper-bound terms.
◮ Tactics ⇒ proof reuse
18
SLIDE 37
Summary
19
SLIDE 38
Resources
Notes, slides, and examples from this talk: https://nfulton.org/marktoberdorf KeYmaera X website: https://keymaeraX.org Online Instance (With Mathematica!): https://web.keymaeraX.org Source Code (Scala): https://github.com/LS-Lab/KeYmaeraX-release KeYmaera X Credits: Stefan Mitsch, Jan-David Quesel, Marcus V¨
- lp, Brandon Bohrer, Yong Kiam Tan, Andr´
e Platzer, . . . SCUBA Credits: Karim Elmaaroufi and Viren Bajaj
20
SLIDE 39
Outline
Straight Line Dynamics The Stop Sign Model Circular Dynamics Loitering Outside Prohibited Airspace Logarithmic Dynamics Safe SCUBA Diving Extras The ODE Solver Taylor Approximations as Successive Differential Cuts
21
SLIDE 40
The ODE Solver
To solve x′ = v, v′ = a:
◮ Add a time variable:
[x′ = v, v′ = a, t′ = 1]P(x, v)
22
SLIDE 41
The ODE Solver
To solve x′ = v, v′ = a:
◮ Add a time variable:
[x′ = v, v′ = a, t′ = 1]P(x, v)
◮ Use differential cuts to add solutions in linear order:
[x′ = v, v′ = a, t′ = 1&v = at+v0∧x = at2 2 +v0t+x0]P(x, v)
22
SLIDE 42
The ODE Solver
To solve x′ = v, v′ = a:
◮ Add a time variable:
[x′ = v, v′ = a, t′ = 1]P(x, v)
◮ Use differential cuts to add solutions in linear order:
[x′ = v, v′ = a, t′ = 1&v = at+v0∧x = at2 2 +v0t+x0]P(x, v)
◮ Rewrite the post-condition in terms of t:
[x′ = v, v′ = a, t′ = 1&v = at + v0 ∧ x = at2 2 + v0t + x0]P(t)
22
SLIDE 43
The ODE Solver
To solve x′ = v, v′ = a:
◮ Add a time variable:
[x′ = v, v′ = a, t′ = 1]P(x, v)
◮ Use differential cuts to add solutions in linear order:
[x′ = v, v′ = a, t′ = 1&v = at+v0∧x = at2 2 +v0t+x0]P(x, v)
◮ Rewrite the post-condition in terms of t:
[x′ = v, v′ = a, t′ = 1&v = at + v0 ∧ x = at2 2 + v0t + x0]P(t)
◮ Inverse differential ghosts to remove all equations except time:
[t′ = 1&v = at + v0 ∧ x = at2 2 + v0t + x0]P(t)
22
SLIDE 44
The ODE Solver
To solve x′ = v, v′ = a:
◮ Add a time variable:
[x′ = v, v′ = a, t′ = 1]P(x, v)
◮ Use differential cuts to add solutions in linear order:
[x′ = v, v′ = a, t′ = 1&v = at+v0∧x = at2 2 +v0t+x0]P(x, v)
◮ Rewrite the post-condition in terms of t:
[x′ = v, v′ = a, t′ = 1&v = at + v0 ∧ x = at2 2 + v0t + x0]P(t)
◮ Inverse differential ghosts to remove all equations except time:
[t′ = 1&v = at + v0 ∧ x = at2 2 + v0t + x0]P(t)
◮ Use univariate solve:
∀s∀0 ≤ t ≤ s.v = at + v0 ∧ x = at2 2 + v0t + x0 → P(t)
22
SLIDE 45
Taylor Approximations in KeYmaera X
s′ = c, c′ = −s s = sin x = x − x3 3! + x5 5! − . . . c = cos x = 1 − x2 2! + x4 4! − . . .
23
SLIDE 46