• Keine Ergebnisse gefunden

Korrekte Software: Grundlagen und Methoden Vorlesung 5 vom 04.05.17: Äquivalenz der Operationalen und Denotationalen Semantik

N/A
N/A
Protected

Academic year: 2022

Aktie "Korrekte Software: Grundlagen und Methoden Vorlesung 5 vom 04.05.17: Äquivalenz der Operationalen und Denotationalen Semantik"

Copied!
13
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Korrekte Software: Grundlagen und Methoden

Vorlesung 5 vom 04.05.17: Äquivalenz der Operationalen und Denotationalen Semantik

Serge Autexier, Christoph Lüth

Universität Bremen

Sommersemester 2017

(2)

I Einführung

I Die Floyd-Hoare-Logik

I Operationale Semantik

I Denotationale Semantik

I Äquivalenz der Operationalen und Denotationalen Semantik

I Korrektheit des Hoare-Kalküls

I Vorwärts und Rückwärts mit Floyd und Hoare

I Funktionen und Prozeduren

I Referenzen und Speichermodelle

I Verifikationsbedingungen Revisited

I Vorwärtsrechnung Revisited

I Programmsicherheit und Frame Conditions

(3)

Operationale vs. denotationale Semantik

Operational ha, σi →Aexp n DenotationalA[[a]]

m∈N hm, σi →Aexp m {(σ,m)|σ ∈Σ}

x∈Loc xDom(σ)

hx, σi →Aexp σ(x) {(σ, σ(x))|σ∈Σ,xDom(σ)}

a1a2

ha1, σi →Aexp n ha2, σi →Aexp m

n,m6=⊥

ha1a2, σi →Aexp nIm {(σ,nIm)|σ∈Σ,(σ,n)∈ A[[a1]],(σ,m)∈ A[[a2]]}

ha1, σi →Aexp n ha2, σi →Aexp m n=⊥oderm=⊥ ha1a2, σi →Aexp

◦ ∈ {+,∗,−}

(4)

Operational ha, σi →Aexp n DenotationalA[[a]]

a1/a2

ha1, σi →Aexp n ha2, σi →Aexp m m6= 0 m,n 6=⊥

ha1a2, σi →Aexp nIm {(σ,n/m)|σ ∈Σ,(σ,n)∈ A[[a1]],(σ,m)∈ A[[a2]],m6=

0}

ha1, σi →Aexp n ha2, σi →Aexp m n =⊥,m=⊥oder m= 0

ha1/a2, σi →Aexp

(5)

Äquivalenz operationale und denotationale Semantik

I Für alleaAexp, für alle nN, für alle Zuständeσ:

ha, σi →Aexp n ⇔(σ,n)∈ A[[a]]

ha, σi →Aexp ⊥ ⇔σ6∈Dom(A[[a]])

I Beweis per struktureller Induktion übera.

(6)

Operationalhb, σi →Bexp 0|1 Denotational B[[b]]

1 h1, σi →Bexp1 {(σ,1)|σ ∈Σ}

0 h0, σi →Bexp0 {(σ,0)|σ ∈Σ}

(7)

Operationale vs. denotationale Semantik

Operat. hb, σi →Bexp0|1 DenotationalB[[b]]

a0 ==a1

ha0, σi →Aexp n ha1, σi →Aexp m n,m6=⊥ n=m ha0 ==a1, σi →Bexp1

ha0, σi →Aexp n ha1, σi →Aexp m n,m6=⊥ n6=m ha0 ==a1, σi →Bexp0

ha0, σi →Aexp n ha1, σi →Aexp m n=⊥oder m=⊥ ha0==a1, σi →Bexp

{(σ,1)|σ ∈Σ,

(σ,n0)∈ A[[a0]], (σ,n1)∈ A[[a1]], n0 =n1 }

{(σ,0)|σ ∈Σ,

(σ,n0)∈ A[[a0]], (σ,n1)∈ A[[a1]], n0 6=n1 }

a1<=a2 analog

(8)

Operationalha, σi →Bexpb Denotational B[[b]]

b1&&b0 hb1, σi →Bexp0

hb1&&b2, σi →0 {(σ,0)|(σ,0)∈ B[[b1]]}

hb1, σi →Bexp1 hb2, σi →Bexpb

hb1&&b2, σi →b {(σ,b)|(σ,1)∈ B[[b1]],(σ,b)∈ B[[b2]]}

hb1, σi →Bexp⊥ hb1&&b2, σi → ⊥

b1||b2 analog

!n . . .

(9)

Äquivalenz operationale und denotationale Semantik

I Für allebBexp, für alletB, for alle Zuständeσ:

hb, σi →Bexpt ⇔(σ,t)∈ B[[b]]

hb, σi →Bexp ⊥ ⇔σ6∈Dom(B[[b]])

I Beweis per struktureller Induktion überb (unter Verwendung der Äquivalenz für AExp).

(10)

Operational hc, σi →Stmt σ0|⊥

DenotationalC[[c]]

{c1. . .cn}

h{}, σi →Stmt σ hc1, σi →Stmt σ00 6=⊥ h{c2. . .cn}, σ0i →Stmt σ00

h{c1. . .cn}, σi →Stmt σ00 hc1, σi →Stmt ⊥ h{c1. . .cn}, σi →Stmt

B[[cn]]◦. . .B[[c1]]◦Id

x =a ha, σi →Aexp n hx =a, σi →Stmt σ[n/x]

ha, σi →Aexp

{(σ, σ[n/X])|(σ,n)∈ A[[a]]}

(11)

Operationale vs. denotationale Semantik

Operational hc, σi →Stmt σ0|⊥

DenotationalC[[c]]

if (b) c0

hb, σi →Bexp1 hc0, σi →Stmt σ0

hc, σi →Stmt σ0 hb, σi →Bexp⊥ hc, σi →Stmt

{(σ, σ0)|(σ,1)∈ B[[b]],(σ, σ0)∈ C[[c0]]}

elsec1

hb, σi →Bexp0 hc1, σi →Stmt σ0

hc, σi →Stmt σ0 {(σ, σ0)|(σ,0)∈ B[[b]],(σ, σ0)∈ C[[c1]]}

(12)

Operationalhc, σi →Stmt σ0|⊥ Denotational C[[c]]

while (b) c

| {z }

w

hb, σi →Bexp 0 hw, σi →Stmt σ

hb, σi →Bexp⊥ hw, σi →Stmt

hb, σi →Bexp 1 hc, σi →Stmt σ0 6=⊥ hw, σ0i →Stmt σ00 hw, σi →Stmt σ00

fix(Γ)

hb, σi →Bexp 1 hc, σi →Stmt ⊥ hw, σi →Stmt

mit

Γ(ϕ) = {(σ, σ0)|(σ,1)∈ B[[b]],(σ, σ0)∈ϕ◦ C[[c]]}

∪{(σ, σ)|(σ,0)∈ B[[b]]}

(13)

Äquivalenz operationale und denotationale Semantik

I Für allecStmt, für alle Zuständeσ, σ0:

hc, σi →Stmt σ0 ⇔(σ, σ0)∈ C[[c]]

hc, σi →Stmt ⊥ ⇒σ6∈Dom(C[[c]])

I ⇒Beweis per Induktion über die Ableitung in der operationalen Semantik

I ⇐Beweis per struktureller Induktion überc (Verwendung der Äquivalenz für arithmetische und boolsche Ausdrücke). Für die While-Schleife Rückgriff auf Definition des Fixpunkts und Induktion über die Teilmengen Γi(∅) des Fixpunkts.

I Gegenbeispiel fürin der zweiten Aussage: wählecwhile(1){}:

C[[c]] =aberhc, σi →Stmtgilt nicht (sondern?).

Referenzen

ÄHNLICHE DOKUMENTE

I Die (operationale) Semantik einer imperativen Sprache wie C0 ist ein Zustandsübergang: das System hat einen impliziten Zustand, der durch Zuweisung von Werten an Adressen

Zu zeigen ist, dass sowohl w also auch if (b) {c; w} else { } zu dem selben Programmzustand auswerten oder beide zu

Korrekte Software: Grundlagen und Methoden Vorlesung 3 vom 17.04.18: Denotationale Semantik.. Serge Autexier,

[r]

Für die While-Schleife Rückgriff auf Definition des Fixpunkts und Induktion über die Teilmengen Γ i (∅) des Fixpunkts.. Für die While-Schleife Rückgriff auf Definition des

Partial cor- rectness means that if the programs starts in a state where the precondition P holds, and it terminates, then it does so in a state which satisfies the postcondition

Korrekte Software: Grundlagen und Methoden Vorlesung 4 vom 24.04.17: Denotationale Semantik.. Serge Autexier,

[r]