Docsity

Semantic Equivalence Proof Examples on Programming Languages | EECS 762, Study notes of Programming Languages

Toggle sidebar
bg1
Semantic Equivalence Proof Examples
Dr. Perry Alexander
EECS 662 - Programming Language Foundation
The University of Kansas
November 3, 2008
The purpose of this document is to provide examples of cases from a structural induction proof that the denotational
semantics and operational semantics defined for IMP by Winskel are equivalent. We will specifically look at showing:
C[[c]]σ={(σ, σ0)|< c, σ >→σ0}(1)
for cases where cis a command defined in IMP.
The first case to examine is sequencing of commands, c0;c1, as a prototypical example of verifying command seman-
tics. In this case, the proof goal abstractly defined as equation (1) has the form:
C[[c0;c1]]σ={(σ, σ0)|< c0;c1, σ >→σ0}(2)
From the definition of C, we know the left side of equation (2) can be rewritten as:
{(σ, σ0)| ∃σ00 ∈Σ· C [[c0]]σ=σ00 ∧ C [[c1]]σ00 =σ0}(3)
Resulting in the proof obligation:
{(σ, σ0)| ∃σ00 ∈Σ· C [[c0]]σ=σ00 ∧ C [[c1]]σ00 =σ0}={(σ,σ 0)|< c0;c1, σ >→σ0}(4)
By the definition of set comprehension, equation (11) can be rewritten as:
∃σ00 ∈Σ· C[[c0]]σ=σ00 ∧ C[[c1]]σ00 =σ0⇐⇒< c0;c1, σ >→σ0(5)
From the overall structural induction proof, we have the induction hypotheses:
C[[C0]]σ=σ00 ⇐⇒ < C0, σ >→σ00 (6)
C[[C1]]σ00 =σ0⇐⇒ < C1, σ00 >→σ0(7)
To establish (12) we have two cases:
Case 1: ∃σ00 · C [[c0]]σ=σ00 ∧ C[[c1]]σ00 =σ0⇒< C0;C1, σ >→σ0
To prove the implication, we assume the antecedent and prove the consequent. Assuming C[[C0]]σ=σ00 and
C[[C1]]σ00 =σ0it follows from the induction hypothesis that < C0,σ >→σ00 and < C1, σ >→σ0.
1
pf3

Partial preview of the text

Download Semantic Equivalence Proof Examples on Programming Languages | EECS 762 and more Study notes Programming Languages in PDF only on Docsity!

Semantic Equivalence Proof Examples

Dr. Perry Alexander

EECS 662 - Programming Language Foundation

The University of Kansas

November 3, 2008

The purpose of this document is to provide examples of cases from a structural induction proof that the denotational semantics and operational semantics defined for IMP by Winskel are equivalent. We will specifically look at showing:

C [[c]]σ = {(σ, σ′) |< c, σ >→ σ′} (1)

for cases where c is a command defined in IMP.

The first case to examine is sequencing of commands, c 0 ; c 1 , as a prototypical example of verifying command seman- tics. In this case, the proof goal abstractly defined as equation (1) has the form:

C [[c 0 ;c 1 ]]σ = {(σ, σ′) |< c 0 ; c 1 , σ >→ σ′} (2)

From the definition of C, we know the left side of equation (2) can be rewritten as:

{(σ, σ′) | ∃σ′′^ ∈ Σ · C [[c 0 ]]σ = σ′′^ ∧ C [[c 1 ]]σ′′^ = σ′} (3)

Resulting in the proof obligation:

{(σ, σ′) | ∃σ′′^ ∈ Σ · C [[c 0 ]]σ = σ′′^ ∧ C [[c 1 ]]σ′′^ = σ′} = {(σ, σ′) |< c 0 ; c 1 , σ >→ σ′} (4)

By the definition of set comprehension, equation (11) can be rewritten as:

∃σ′′^ ∈ Σ · C [[c 0 ]]σ = σ′′^ ∧ C [[c 1 ]]σ′′^ = σ′^ ⇐⇒< c 0 ; c 1 , σ >→ σ′^ (5)

From the overall structural induction proof, we have the induction hypotheses:

C [[C 0 ]]σ = σ′′^ ⇐⇒ < C 0 , σ >→ σ′′^ (6) C [[C 1 ]]σ′′^ = σ′^ ⇐⇒ < C 1 , σ′′^ >→ σ′^ (7)

To establish (12) we have two cases:

Case 1: ∃σ′′^ · C [[c 0 ]]σ = σ′′^ ∧ C [[c 1 ]]σ′′^ = σ′^ ⇒< C 0 ; C 1 , σ >→ σ′

To prove the implication, we assume the antecedent and prove the consequent. Assuming C [[C 0 ]]σ = σ′′^ and C [[C 1 ]]σ′′^ = σ′^ it follows from the induction hypothesis that < C 0 , σ >→ σ′′^ and < C 1 , σ >→ σ′.

Recall from the operational semantics definition of IMP the rule for deriving C 0 ; C 1 :

sequence

< c 0 , σ >→ σ′′^ < c 1 , σ >→ σ′ < c 0 ; c 1 , σ >→ σ′^

The induction hypothesis gives the precondition of the rule, thus it follows that < C 0 ; C 1 , σ >→ σ′^ which is the goal of Case 1.

Case 2: ∃σ′′^ · C [[c 0 ]]σ = σ′′^ ∧ C [[c 1 ]]σ′′^ = σ′^ ⇐< c 0 ; c 1 , σ >→ σ′

Note that sequence is the only rule in the operational semantics of IMP that derives < c 0 ; c 1 , σ >→ σ′. Thus, assuming that < c 0 ; c 1 , σ >→ σ′^ is derivable, the rule sequence must be the last rule applied in the derivation. Thus, the preconditions of sequence must be true in the derivation.

It then follows directly from the induction hypothesis that:

C [[c 0 ]]σ = σ′′^ ∧ C [[c 1 ]]σ′′^ = σ′

which is the goal of this case.

Having proved both cases from equation (12), we have proved the conjecture.

Q.E.D.

The second case to examine is the while loop whilebdoc, as a more aggressive example of verifying command seman- tics. In this case, the proof goal abstractly defined as equation (1) has the form:

C [[w]]σ = {(σ, σ′) |< w, σ >→ σ′} (9)

where w = while b do c.

From the definition of C, we know the left side of equation (9) can be rewritten as:

C [[w]]σ = f ix(Γ(ϕ)) =

n∈ω

R^ ˆn({}) (10)

Recall the definition of ϕ is really C [[w]]σ.

Here, the proof obligation is a bit different as we’re looking a fixed point. The fixed point is well-defined and indexed on ω, thus a proof by induction over the natural numbers is in order. Recall the following definitions:

R^ ˆ^0 ({}) = {}

R^ ˆn+1({}) = {(σ, σ′) | B[|b] |= true ∧ (σ, sigma′′) ∈ C[|c]| ∧ (σ′′, σ′) ∈ Rˆn({})}

Thus, we have a base case and an inductive case for an induction over n.

Our proof goal is:

∀n ∈ ω · (σ, σ′) ∈ Rˆn({}) ⇒< σ, w >→ σ′^ (11)

The base case is trivial as the left side reduces to (σ, sigma′′) ∈ {} which is false. Thus, by contradiction the right side is true.