Dependency Analysis for Hybrid Programs Yong Kiam Tan X B Y C A - - PowerPoint PPT Presentation

dependency analysis for hybrid programs
SMART_READER_LITE
LIVE PREVIEW

Dependency Analysis for Hybrid Programs Yong Kiam Tan X B Y C A - - PowerPoint PPT Presentation

Dependency Analysis for Hybrid Programs Yong Kiam Tan X B Y C A W D Z 1 Motivation Semantics of hybrid programs : ( u , w ) , e.g.: w = u u e ( u , w ) x := e x What relationships can we find


slide-1
SLIDE 1

Dependency Analysis for Hybrid Programs

Yong Kiam Tan

B A D C X Y Z W

1

slide-2
SLIDE 2

Motivation

Semantics of hybrid programs α: (u, w) ∈ α, e.g.: (u, w) ∈ x := e ⇐ ⇒ w = uue

x

What relationships can we find between states u and w?

2

slide-3
SLIDE 3

Dependency Analysis

Variable x depends on Y if changing the initial values u(y), y ∈ Y changes the set of possible values for w(x)

3

slide-4
SLIDE 4

Dependency Analysis

Variable x depends on Y if changing the initial values u(y), y ∈ Y changes the set of possible values for w(x) Ideally, we want to minimize Y , but consider: ?P; x := y ∪ x := z Aim: syntactic, compositional analysis of α for a “small” Y

3

slide-5
SLIDE 5

Definition

For each set X, Dα(X) is a set of variables that X might depend on: Dy:=e(X) =

  • x∈X
  • FV (e)

if x = y {x}

  • therwise

Dα;β(X) = Dα(Dβ(X)) Dα∪β(X) = Dα(X) ∪ Dβ(X)

4

slide-6
SLIDE 6

Definition (tests)

Tests are slightly weird: D?Q(X) = X ∪ FV (Q) Compare to its semantics: (u, u) ∈ ?Q ⇐ ⇒ u ∈ Q

5

slide-7
SLIDE 7

Definition (tests)

Tests are slightly weird: D?Q(X) = X ∪ FV (Q) Compare to its semantics: (u, u) ∈ ?Q ⇐ ⇒ u ∈ Q What does x depend on? ?k = 1; x := y ∪ x := z

5

slide-8
SLIDE 8

Definition (loops)

Semantics of loops (α∗): α0 ∪ α1 ∪ α2 ∪ · · · αn ≡ α; ...; α

n times

Loops can be unfolded: Dα∗(X) =

  • i∈N

Di

α(X)

D0

α(S) = S

Di+1

α

(S) = Dα(Di

α(S)) 6

slide-9
SLIDE 9

Definition (ODEs)

ODEs in vector form ( x′ = e), first attempt: D

x′= e(X) =

  • X

if X ∩ x = ∅ X ∪ x ∪

e∈ e FV (e)

  • therwise

7

slide-10
SLIDE 10

Definition (ODEs)

ODEs in vector form ( x′ = e), first attempt: D

x′= e(X) =

  • X

if X ∩ x = ∅ X ∪ x ∪

e∈ e FV (e)

  • therwise

Extension to handle evolution domain constraints: D

x′= e&Q(X) = D x′= e(X) ∪ FV (Q) 7

slide-11
SLIDE 11

Definition (ODEs)

This badly over-approximates the dependencies, e.g.: x′ = 1, y′ = 1 Has solution: x = x0 + t, y = y0 + t But analysis says x, y are interdependent

8

slide-12
SLIDE 12

Definition (ODEs)

Not easy to get right, consider: x′ = 1, y′ = y2 If y0 = 0, x = x0 + t, y = 0 is the solution If y0 > 0, t < 1

y0 , so x ∈ [x0, x0 + 1 y0 ) 9

slide-13
SLIDE 13

Global solutions

Assume x′ = e has a global solution for all time, then we can instead use: D

x′= e(X) = T

where T is the smallest set satisfying X ⊆ T and xi ∈ T → FV ( ei) ∈ T, i.e. the transitive closure of all variables mentioned in X across the system.

10

slide-14
SLIDE 14

Global solutions

Assume x′ = e has a global solution for all time, then we can instead use: D

x′= e(X) = T

where T is the smallest set satisfying X ⊆ T and xi ∈ T → FV ( ei) ∈ T, i.e. the transitive closure of all variables mentioned in X across the system. When do global solutions exist?

10

slide-15
SLIDE 15

Linearity

If ODE is linear, i.e. x′ = A x, then etA x0 is a global solution. Simple to check if ODE is linear, e.g.: x′ = v, v′ = a&v ≥ 0 x depends on {x, v, a} and v depends on {v, a}

11

slide-16
SLIDE 16

Linearity, revisited

Consider the non-linear system: x′ = 1, y′ = xy Solution: x = x0 + t,y = y0ex0t+ t2

2 , but analysis says x depends on {x, y}

12

slide-17
SLIDE 17

Linearity, revisited

Consider the non-linear system: x′ = 1, y′ = xy Solution: x = x0 + t,y = y0ex0t+ t2

2 , but analysis says x depends on {x, y}

Relax requirement that whole ODE is linear, to just x ∩ T C being linear.

12

slide-18
SLIDE 18

Linearity, revisited

Consider the non-linear system: x′ = 1, y′ = xy Solution: x = x0 + t,y = y0ex0t+ t2

2 , but analysis says x depends on {x, y}

Relax requirement that whole ODE is linear, to just x ∩ T C being linear. This works even if there is no solution for all time: x′ = x2, y′ = xy

12

slide-19
SLIDE 19

Correctness

Proposition (Coincidence for terms and formulas)

If u, v agree on FV (e), then ue = ve, and if u, v agree on FV (Q), then u ∈ Q ⇐ ⇒ v ∈ Q.

13

slide-20
SLIDE 20

Correctness

Proposition (Coincidence for terms and formulas)

If u, v agree on FV (e), then ue = ve, and if u, v agree on FV (Q), then u ∈ Q ⇐ ⇒ v ∈ Q.

Theorem (Restricted coincidence)

If u, v agree on Dα(X) and (u, u′) ∈ α, there exists (v, v′) ∈ α such that u′, v′ agree on X.

Proof.

By induction on α.

13

slide-21
SLIDE 21

Correctness

Corollary

If P → [α]Q, then there is a precondition R such that P → R, R → [α]Q, where FV (R) ⊆ Dα(FV (Q)).

Proof.

Let R ≡ ∃ xP, then for u ∈ R there exists v ∈ P. For any (u, u′) ∈ α, previous theorem gives (v, v′) ∈ α, and u′, v′ agree on FV (Q). By assumption, v′ ∈ Q, so u′ ∈ Q by the coincidence lemma.

14

slide-22
SLIDE 22

Application: Invariants for free!

Task: find possible invariants for: x′ = −y, y′ = x

15

slide-23
SLIDE 23

Application: Invariants for free!

Task: find possible invariants for: x′ = −y, y′ = x Parametric invariant candidate p over V = {x, y}: p = ax2 + bxy + cy2 + dx + ey + f Set Lie derivative p′ = 0: p′ = 2axx′ + b(x′y + y′x) + 2cyy′ + dx′ + ey′ = −2axy + b(x2 − y2) + 2cxy − dy + ex = 0

15

slide-24
SLIDE 24

Application: Differential Invariant Generation

Comparing coefficients: a = c, b = 0, d = 0, e = 0 Therefore, ax2 + ay2 + f = 0 is an invariant, for any constant a, f

16

slide-25
SLIDE 25

Application: Differential Invariant Generation

How did we choose p (or equivalently V )? Recall corollary: can always find P → [α]Q, FV (P) ⊆ Dα(FV (Q)) Only search for invariants φ → [α]φ, where φ is closed under Dα.

17

slide-26
SLIDE 26

Application: Differential Invariant Generation

Dependency also allows us to search in order, e.g.: α ≡ x′

1 = d1, x′ 2 = d2, d′ 1 = −ωd2, d′ 2 = ωd1, t′ = 1

Dα(d1) = {ω, d1, d2} Dα(d2) = {ω, d1, d2} Dα(x1) = {ω, d2, d1, x1} Dα(x2) = {ω, d2, d1, x2} Dα(t) = {t}, Dα(ω) = {ω} Search for invariants in sets: {t}, {d1, d2}, {d1, d2, x1, x2}.

18

slide-27
SLIDE 27

Results

ODE System Invariants Generated v′ = aw, w′ = −v f0 + f1(v2 + aw2) = 0 x′ = v, v′ = a, t′ = 1 f0 + f1(−at + v) = 0 x′ = x, t′ = 1 f0 + t ≥ 0, f1 + x2 ≥ 0 α (prev. slide) f0 + f1(d2

1 + d2 2) = 0,

f2 + f3(d2 − ωx1) + f4(d1 + ωx2) = 0, f5 + t ≥ 0

19

slide-28
SLIDE 28

Results

Parametric invariant for motion equation: f0 + f1(−at + v) = 0 Set f1 = 1, f0 = −v0: v = v0 + a ∗ t

20

slide-29
SLIDE 29

Results

Parametric invariant for motion equation: f0 + f1(−at + v) = 0 Set f1 = 1, f0 = −v0: v = v0 + a ∗ t Another invariant: f0 + a2f1t2 + 1 2at(−2f2 + f3t − 4f1v) + v(f2 − f3t + f1v) + f3x = 0 Set f2 = f1 = 0, f3 = 1, f0 = −x0: x = x0 + vt − 1

2at2

Substituting previous equation: x = x0 + v0t + 1

2at2 20

slide-30
SLIDE 30

Conclusion

B A D C X Y Z W

21

slide-31
SLIDE 31

Conclusion

B A D C X Y Z W

Invariants Generated f0 + f1(v2 + aw2) = 0 f0 + f1(−at + v) = 0 f0 + t ≥ 0, f1 + x2 ≥ 0 f0 + f1(d2

1 + d2 2) = 0,

f2 + f3(d2 − ωx1) + f4(d1 + ωx2) = 0, f5 + t ≥ 0

21

slide-32
SLIDE 32

Conclusion

B A D C X Y Z W

Invariants Generated f0 + f1(v2 + aw2) = 0 f0 + f1(−at + v) = 0 f0 + t ≥ 0, f1 + x2 ≥ 0 f0 + f1(d2

1 + d2 2) = 0,

f2 + f3(d2 − ωx1) + f4(d1 + ωx2) = 0, f5 + t ≥ 0

Questions?

21