• Keine Ergebnisse gefunden

Transformation 1.1:

N/A
N/A
Protected

Academic year: 2022

Aktie "Transformation 1.1:"

Copied!
42
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Transformation 1.1:

We provide novel registers Te as storage for the e:

v u

u

v v

Pos (e)

u v u

Te = e;

x = Te;

Neg (e)

x = e;

Te = e;

Pos (T ) Neg (T )

(2)

... analogously for R = M[e]; and M[e1] = e2;.

Transformation 1.2:

If e is available at program point u, then e need not be re-evaluated:

u u

Te = e; ;

e ∈ A[u]

(3)

Example:

x = y + 3;

x = 7;

z = y + 3;

x = 7;

z = y + 3;

x = y + 3;

(4)

Example:

x = y + 3;

x = 7;

z = y + 3;

x = 7;

T = y + 3;

x = T;

T = y + 3;

z = T;

(5)

Example:

x = y + 3;

x = 7;

z = y + 3;

x = 7;

z = T;

T = y + 3;

x = T;

T = y + 3;

{y + 3}

{y + 3}

{y + 3}

{y + 3}

{y + 3}

(6)

Example:

x = y + 3;

x = 7;

z = y + 3;

x = 7;

T = y + 3;

x = T;

;

z = T; {y + 3}

{y + 3}

{y + 3}

{y + 3}

{y + 3}

(7)

Correctness:

(Idea)

Transformation 1.1 preserves the semantics and A[u] for all program points u :-)

Assume π : start → u is the path taken by a computation.

If e ∈ A[u], then also e ∈ [[π]] ∅.

Therefore, π can be decomposed into:

start π1 u1 k u2 π2 u

(8)

• The expression e is evaluated at the edge k;

• The expression e is not removed from the set of available

expressions at any edge in π2, i.e., no variable of e receives a new value :-)

==⇒

The register Te contains the value of e whenever u is reached :-))

(9)

• The expression e is evaluated at the edge k;

• The expression e is not removed from the set of available

expressions at any edge in π2, i.e., no variable of e receives a new value :-)

==⇒

The register Te contains the value of e whenever u is reached :-))

(10)

Warning:

Transformation 1.1 is only meaningful for assignments x = e; where:

→ e 6∈ Vars;

→ the evaluation of e is non-trivial :-}

Which leaves open whether ...

(11)

Warning:

Transformation 1.1 is only meaningful for assignments x = e; where:

→ x 6∈ Vars(e);

→ e 6∈ Vars;

→ the evaluation of e is non-trivial :- }

Which leaves us with the following question ...

(12)

Question:

How do we compute A[u] for every program point u ??

Idea:

We collect all restrictions to the values of A[u] into a system of constraints:

A[start] ⊆ ∅

A[v] ⊆ [[k]] (A[u]) k = (u,_, v) edge

(13)

Question:

How can we compute A[u] for every program point u ??

Idea:

We collect all restrictions to the values of A[u] into a system of constraints:

A[start] ⊆ ∅

A[v] ⊆ [[k]] (A[u]) k = (u,_, v) edge

(14)

Wanted:

• a maximally large solution (??)

• an algorithm which computes this :-)

Example:

3 5 2

0

1

y = 1;

y = x y;

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

(15)

Wanted:

• a maximally large solution (??)

• an algorithm which computes this :-)

Example:

3 5 2

0

1

y = 1;

y = x y;

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

A[0] ⊆ ∅

(16)

Wanted:

• a maximally large solution (??)

• an algorithm which computes this :-)

Example:

3 5 2

0

1

y = 1;

y = x y;

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

A[0] ⊆ ∅

A[1] (A[0]∪ {1})\Expry A[1] ⊆ A[4]

(17)

Wanted:

• a maximally large solution (??)

• an algorithm which computes this :-)

Example:

3 5 2

0

1

y = 1;

y = x y;

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

A[0] ⊆ ∅

A[1] (A[0]∪ {1})\Expry A[1] ⊆ A[4]

A[2] ⊆ A[1] ∪ {x > 1}

(18)

Wanted:

• a maximally large solution (??)

• an algorithm which computes this :-)

Example:

3 5 2

0

1

y = 1;

y = x y;

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

A[0] ⊆ ∅

A[1] (A[0]∪ {1})\Expry A[1] ⊆ A[4]

A[2] ⊆ A[1] ∪ {x > 1}

A[3] (A[2]∪ {x y})\Expry

(19)

Wanted:

• a maximally large solution (??)

• an algorithm which computes this :-)

Example:

3 5 2

0

1

y = 1;

y = x y;

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

A[0] ⊆ ∅

A[1] (A[0]∪ {1})\Expry A[1] ⊆ A[4]

A[2] ⊆ A[1] ∪ {x > 1}

A[3] (A[2]∪ {x y})\Expry A[4] (A[3]∪ {x 1})\Expr

(20)

Wanted:

• a maximally large solution (??)

• an algorithm which computes this :-)

Example:

3 5 2

0

1

y = 1;

y = x y;

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

A[0] ⊆ ∅

A[1] (A[0]∪ {1})\Expry A[1] ⊆ A[4]

A[2] ⊆ A[1] ∪ {x > 1}

A[3] (A[2]∪ {x y})\Expry A[4] (A[3]∪ {x 1})\Expr

(21)

Wanted:

• a maximally large solution (??)

• an algorithm which computes this :-)

Example:

3 5 2

0

1

y = 1;

y = x y;

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

Solution:

A[0] = A[1] = {1}

A[2] = {1,x > 1}

A[3] = {1,x > 1}

A[4] = {1}

(22)

Observation:

• The possible values for A[u] form a complete lattice:

D = 2Expr with B1 ⊑ B2 iff B1 ⊇ B2

• The functions [[k]] : D → D are monotonic, i.e., [[k]](B1) ⊑ [[k]](B2) gdw. B1 ⊑ B2

(23)

Observation:

• The possible values for A[u] form a complete lattice:

D = 2Expr with B1 ⊑ B2 iff B1 ⊇ B2

• The functions [[k]] : D → D are monotonic, i.e., [[k]](B1) ⊑ [[k]](B2) iff B1 ⊑ B2

(24)

Background 2: Complete Lattices

A set D together with a relation ⊑ ⊆ D × D is a partial order if for all a, b, c ∈ D,

a ⊑ a reflexivity

a ⊑ b ∧ b ⊑ a =⇒ a = b anti−symmetry a ⊑ b ∧ b ⊑ c =⇒ a ⊑ c transitivity

Examples:

1. D = 2{a,b,c} with the relation “⊆” :

a, b, c

a, b a, c b, c

(25)

2. Z with the relation “=” :

2 1

0 -1

-2

3. Z with the relation “≤” :

-1 0

1 2

4. Z = Z ∪ {⊥} with the ordering:

2 1

0 -1

-2

(26)

d ∈ D is called upper bound for X ⊆ D if

x ⊑ d for all x ∈ X

d is called least upper bound (lub) if 1. d is an upper bound and

2. d ⊑ y for every upper bound y of X.

Caveat:

• has no upper bound!

• has the upper bounds

(27)

d ∈ D is called upper bound for X ⊆ D if

x ⊑ d for all x ∈ X

d is called least upper bound (lub) if 1. d is an upper bound and

2. d ⊑ y for every upper bound y of X.

Caveat:

• has no upper bound!

• has the upper bounds

(28)

d ∈ D is called upper bound for X ⊆ D if

x ⊑ d for all x ∈ X

d is called least upper bound (lub) if 1. d is an upper bound and

2. d ⊑ y for every upper bound y of X.

Caveat:

• {0, 2, 4, . . .} ⊆ Z has no upper bound!

• {0, 2, 4} ⊆ Z has the upper bounds 4,5, 6, . . .

(29)

A complete lattice (cl) D is a partial ordering where every subset X ⊆ D has a least upper bound F

X ∈ D .

Note:

Every complete lattice has

→ a least element ⊥ = F

∅ ∈ D;

→ a greatest element ⊤ = F

D ∈ D.

(30)

Examples:

1. D = 2{a,b,c} is a cl :-) 2. D = Z with “=” is not.

3. D = Z with “≤” is neither.

4. D = Z is also not :-(

5. With an extra element ⊤, we obtain the flat lattice Z = Z ∪ {⊥,⊤} :

2 1

0 -1

-2

(31)

We have:

Theorem:

If D is a complete lattice, then every subset X ⊆ D has a greatest lower bound F X.

Proof:

Construct U = {u ∈ D | ∀ x ∈ X : u ⊑ x}.

// the set of all lower bounds of X :-)

Set: g := F

U

(32)

We have:

Theorem:

If D is a complete lattice, then every subset X ⊆ D has a greatest lower bound F X.

Proof:

Construct U = {u ∈ D | ∀ x ∈ X : u ⊑ x}.

// the set of all lower bounds of X :-)

Set: g := F

U

(33)

We have:

Theorem:

If D is a complete lattice, then every subset X ⊆ D has a greatest lower bound F X.

Proof:

Construct U = {u ∈ D | ∀ x ∈ X : u ⊑ x}.

// the set of all lower bounds of X :-)

Set: g := F

U

(34)

(1) g is a lower bound of X : Assume x ∈ X. Then:

u ⊑ x for all u ∈ U

==⇒ x is an upper bound of U

==⇒ g ⊑ x :-)

(2) g is the greatest lower bound of X :

Assume u is a lower bound of X. Then:

u ∈ U

(35)

(1) g is a lower bound of X : Assume x ∈ X. Then:

u ⊑ x for all u ∈ U

==⇒ x is an upper bound of U

==⇒ g ⊑ x :-)

(2) g is the greatest lower bound of X :

Assume u is a lower bound of X. Then:

u ∈ U

(36)
(37)
(38)
(39)

We are looking for solutions for systems of constraints of the form:

xi ⊒ fi(x1, . . . , xn) (∗)

(40)

We are looking for solutions for systems of constraints of the form:

xi ⊒ fi(x1, . . . , xn) (∗) where:

xi unknown here: A[u]

D values here: 2Expr

⊑ ⊆ D × D ordering relation here: ⊇ fi: Dn → D constraint here: ...

Constraint for A[v] :

A[v] ⊆ \

{[[k]] (A[u]) | k = (u,_, v) edge}

(41)

We are looking for solutions for systems of constraints of the form:

xi ⊒ fi(x1, . . . , xn) (∗) where:

xi unknown here: A[u]

D values here: 2Expr

⊑ ⊆ D × D ordering relation here: ⊇ fi: Dn → D constraint here: ...

Constraint for A[v] (v 6= start):

A[v] ⊆ \

{[[k]] (A[u]) | k = (u, _, v) edge}

(42)

We are looking for solutions for systems of constraints of the form:

xi ⊒ fi(x1, . . . , xn) (∗) where:

xi unknown here: A[u]

D values here: 2Expr

⊑ ⊆ D × D ordering relation here: ⊇ fi: Dn → D constraint here: ...

Constraint for A[v] (v 6= start):

A[v] ⊆ \

{[[k]] (A[u]) | k = (u, _, v) edge}

Referenzen

ÄHNLICHE DOKUMENTE

# Wenn man R startet, beginnt man

Eine 2π-periodische Funktion kann durch eine Fourier-Reihe dargestellt werden, wenn diese st¨ uckweise glatt ist, d.h.. Einsetzen des Fourieransatzes in die homogene

Die Ampelanlage funktioniert wie folgt: Ist b = 0, so steht die Verkehrsampel für die vollen 16 Takte einer Zählphase konstant auf Grün und die Fußgängerampel konstant auf Rot.. Ist b

Ein linearer Ausdruck wird transformiert und im Bildraum bearbeitet, weil er dort eine einfachere

Assume flat space-time and that the radius R of the star can be neglected (r R). Use the Poynting vector.. 3)

[r]

Mit |E| → 0 geht die Steigung der blauen Gerade gegen −∞, und ihr erster Schnittpunkt mit der roten Tangenskurve wandert nach links gegen den Grenzwert ka = π 2. Dann geht die

Im Limes g → ∞ sind diese Zust¨ ande also tats¨ achlich entartet. (b) Wir schreiben