• Keine Ergebnisse gefunden

Example: {x 7→ 1, y 7→ −7} ∆ {x 7→ ⊤, y 7→ −7} (3) States: ∆ ⊆ ((Vars → Z) × (N → Z)) × (Vars → Z

N/A
N/A
Protected

Academic year: 2022

Aktie "Example: {x 7→ 1, y 7→ −7} ∆ {x 7→ ⊤, y 7→ −7} (3) States: ∆ ⊆ ((Vars → Z) × (N → Z)) × (Vars → Z"

Copied!
31
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Example: {x 7→ 1, y 7→ −7} ∆ {x 7→ ⊤,y 7→ −7}

(3) States:

∆ ⊆ ((Vars → Z) × (N → Z)) × (Vars → Z)

(ρ, µ) ∆ D iff ρ ∆ D

Concretization:

γ D =

( ∅ if D = ⊥

{(ρ, µ) | ∀ x : (ρx) ∆ (D x)} otherwise

(2)

We show:

(∗) If s ∆ D and [[π]]s is defined, then:

([[π]]s) ∆ ([[π]] D)

s

D D1

s1

∆ ∆

[[π]]

[[π]]

(3)

(∗) The abstract semantics simulates the concrete semantics :-) In particular:

[[π]]s ∈ γ ([[π]] D)

(4)

(∗) The abstract semantics simulates the concrete semantics :-) In particular:

[[π]]s ∈ γ ([[π]] D)

In practice, this means, e.g., that D x = −7 implies:

ρ x = −7 for all ρ ∈ γ D

==⇒ ρ1 x = −7 for (ρ1,_) = [[π]]s

(5)

To prove (∗), we show for every edge k :

(∗∗)

s

D D1

s1

∆ ∆

[[k]]

[[k]]

(6)

To prove (∗∗), we show for every expression e : (∗ ∗ ∗) ([[e]]ρ) ∆ ([[e]] D) whenever ρ ∆ D

(7)

To prove (∗∗), we show for every expression e : (∗ ∗ ∗) ([[e]]ρ) ∆ ([[e]] D) whenever ρ ∆ D

To prove (∗ ∗ ∗), we show for every operator ✷ :

(x✷ y) ∆ (x y) whenever x ∆ x ∧ y ∆ y

(8)

To prove (∗∗), we show for every expression e : (∗ ∗ ∗) ([[e]]ρ) ∆ ([[e]] D) whenever ρ ∆ D

To prove (∗ ∗ ∗), we show for every operator ✷ :

(x✷ y) ∆ (x y) whenever x ∆ x ∧ y ∆ y

This precisely was how we have defined the operators ✷ :-)

(9)

Now, (∗∗) is proved by case distinction on the edge labels lab . Let s = (ρ, µ) ∆ D . In particular, ⊥ 6= D : Vars → Z

Case x = e; :

ρ1 = ρ ⊕ {x 7→ [[e]]ρ} µ1 = µ D1 = D ⊕ {x 7→ [[e]] D}

==⇒ (ρ1, µ1) ∆ D1

(10)

Case x = M[e]; :

ρ1 = ρ ⊕ {x 7→ µ([[e]]ρ)} µ1 = µ D1 = D ⊕ {x 7→ ⊤}

==⇒ (ρ1, µ1) ∆ D1

Case M[e1] = e2; :

ρ1 = ρ µ1 = µ ⊕ {[[e1]]ρ 7→ [[e2]]ρ} D1 = D

==⇒ (ρ1, µ1) ∆ D1

(11)

Case Neg(e) : (ρ1, µ1) = s where:

0 = [[e]]ρ

∆ [[e]] D

==⇒ 0 ⊑ [[e]] D

==⇒ ⊥ 6= D1 = D

==⇒ (ρ1, µ1) ∆ D1

:-)

(12)

Case Pos(e) : (ρ1, µ1) = s where:

0 6= [[e]]ρ

∆ [[e]] D

==⇒ 0 6= [[e]] D

==⇒ ⊥ 6= D1 = D

==⇒ (ρ1, µ1) ∆ D1

:-)

(13)

We conclude:

The assertion (∗) is true :-))

The MOP-Solution:

D[v] = G

{[[π]] D | π : start → v} where D x = ⊤ (x ∈ Vars) .

(14)

We conclude:

The assertion (∗) is true :-))

The MOP-Solution:

D[v] = G

{[[π]] D | π : start → v} where D x = ⊤ (x ∈ Vars) .

By (∗), we have for all initial states s and all program executions π which reach v :

([[π]]s) ∆ (D[v])

(15)

We conclude:

The assertion (∗) is true :-))

The MOP-Solution

D[v] = G

{[[π]] D | π : start → v} where D x = ⊤ (x ∈ Vars) .

By (∗), we have for all initial states s and all program executions π which reach v :

([[π]]s) ∆ (D[v])

In order to approximate the MOP, we use our constraint system :-))

(16)

Example:

7 x = x 1;

y = x y;

Pos(x > 1) Neg(x > 1)

6 3

4 5 2

y = 1;

1 0

M[R] = y;

x = 10;

(17)

Example:

7 x = x 1;

y = x y;

Pos(x > 1) Neg(x > 1)

6 3

4 2

y = 1;

1 0

M[R] = y;

x = 10; 1

x y

0

1 10 2 10 1 3 10 1 4 10 10 5 9 10

6

(18)

Example:

7 x = x 1;

y = x y;

Pos(x > 1) Neg(x > 1)

6 3

4 5 2

y = 1;

1 0

M[R] = y;

x = 10; 1 2

x y x y

0

1 10 10

2 10 1

3 10 1

4 10 10

5 9 10

6

7

(19)

Example:

7 x = x 1;

y = x y;

Pos(x > 1) Neg(x > 1)

6 3

4 2

y = 1;

1 0

M[R] = y;

x = 10; 1 2 3

x y x y x y

0

1 10 10

2 10 1

3 10 1

4 10 10 dito

5 9 10

6

(20)

Conclusion:

Although we compute with concrete values, we fail to compute everything :-(

The fixpoint iteration, at least, is guaranteed to terminate:

For n program points and m variables, we maximally need:

n · (m + 1) rounds :-)

Caveat:

The effects of edge are not distributive !!!

(21)

Counter Example:

f = [[x = x + y;]]

Let D1 = {x 7→ 2,y 7→ 3}

D2 = {x 7→ 3,y 7→ 2}

Dann f D1 ⊔ f D2 = {x 7→ 5,y 7→ 3} ⊔ {x 7→ 5,y 7→ 2}

= {x 7→ 5,y 7→ ⊤}

6= {x 7→ ⊤,y 7→ ⊤}

= f {x 7→ ⊤, y 7→ ⊤}

= f (D ⊔ D )

(22)

We conclude:

The least solution D of the constraint system in general yields only an upper approximation of the MOP, i.e.,

D[v] ⊑ D[v]

(23)

We conclude:

The least solution D of the constraint system in general yields only an upper approximation of the MOP, i.e.,

D[v] ⊑ D[v]

As an upper approximation, D[v] nonetheless describes the result of every program execution π which reaches v :

([[π]] (ρ, µ)) ∆ (D[v]) whenever [[π]] (ρ, µ) is defined ;-))

(24)

Transformation 4:

Removal of Dead Code

D[u] = ⊥ u

u

lab

[[lab]](D[u]) = ⊥ u

(25)

Transformation 4 (cont.):

Removal of Dead Code

u u

Neg (e) ;

[[e]] D = 0

⊥ 6= D[u] = D

u u

; Pos (e)

[[e]] D 6∈ {0, ⊤}

⊥ 6= D[u] = D

(26)

Transformation 4 (cont.):

Simplified Expressions

u u

⊥ 6= D[u] = D

x = c; [[e]] D = c

x = e;

(27)

Extensions:

• Instead of complete right-hand sides, also subexpressions could be simplified:

x + (3 ∗ y) ========={x7→⊤,y7→5} x + 15

... and further simplifications be applied, e.g.:

x ∗ 0 ==⇒ 0 x ∗ 1 ==⇒ x x + 0 ==⇒ x

(28)

• So far, the information of conditions has not yet be optimally exploited:

if (x == 7)

y = x + 3;

Even if the value of x before the if statement is unknown, we at least know that x definitely has the value 7 — whenever the then-part is entered :-)

Therefore, we can define:

[[Pos (x == e)]] D =





D if [[x == e]] D = 1

⊥ if [[x == e]] D = 0 D1 otherwise

where

= ⊕ { 7→ (D ⊓ [[e]] D)}

(29)

The effect of an edge labeled Neg (x 6= e) is analogous :-)

Our Example:

0

1

2

;

Pos (x == 7)

y = x + 3;

Neg (x == 7)

(30)

The effect of an edge labeled Neg (x 6= e) is analogous :-)

Our Example:

0

1

2

3

;

Pos (x == 7)

y = x + 3;

Neg (x == 7)

x 7→ ⊤

x 7→ 7 x 7→ 7 x 7→ ⊤

(31)

The effect of an edge labeled Neg (x 6= e) is analogous :-)

Our Example:

0

1

2

0

1

2

;

Pos (x == 7)

y = x + 3;

Neg (x == 7)

;

Pos (x == 7)

y = 10;

Neg (x == 7)

Referenzen

ÄHNLICHE DOKUMENTE

Reine Wohngeldhaushalte am 31.12.2017 nach Haushaltsgröße, sozialer Stellung sowie Durch- schnittsbeträgen von Bruttoeinkommen, Abzugsbeträgen, Gesamteinkommen und Wohngeld.

Es hat fast nichts mit der genauen Defini- tion des Lebesgue-Integrals zu tun, sondern basiert prinzipiell auf der einfachen Tatsache, dass das Lebesgue-Integral einer Funktion

Betrachte Beispiel 3.12 von Folie 169, die Arithmetik der

Wir werden in diesem Abschnitt einige wichtige Anwendungen der Taylorschen Formel behandeln: Das totale Differenzial als lineare N¨ aherung, die Fehlerrechnung, die Theorie der

[r]

• Lokale Variablen sind nur im eigenen Funktionsrumpf sichtbar, nicht in den aufgerufenen Funktionen.. • Damit die aufgerufenen Hilfsfunktionen auf b zugreifen können, muss b

Konstruieren Sie für jedes Paar n, k von natürlichen Zahlen mit k < n eine Formel ϕ n,k , die ausdrückt, dass im Graph ein Pfad der Länge

Furthermore, data from the Zackenberg Basic programme is freely available and was in 2011 used for report- ing purposes in a number of international fora and by a number