Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ... Transformation of Applicative Specifications into Imperative ...

26.09.2013 Views

CHAPTER 7. CORRECTNESS OF TRANSFORMATION RULES for all (ve1, x, ve2) ∈ Value A ∗ (te1×tv×te2): mOP (f)(vearg)([ ]) ≡ case m ′ OP (f)(vearg)([ v ↦→ dv ]) of ⊥ → ⊥, ((ve1, ve2), [ v ↦→ dv ′ ]) → ((ve1, dv ′ , ve2), [ ]) end Note that dom [v ↦→ dv] = dom [v ↦→ dv ′ ] = {v}. Explanation: mOP (f) returns chaos if m ′ OP (f) returns chaos. Otherwise mOP (f) returns the same result as m ′ OP (f), but with the actual value dv ′ of v included. When evaluating m ′ OP (f) a store s = [v ↦→ dv] is kept reflecting the actual value dv of v. This value is altered during the evaluation of f, since f is a generator. 3. Combined observer and generator f : te1 × tv × te2 ∼ → te3 × tv × te4 σ f : te1 × te2 ∼ → read v write v te3 × te4 for all (ve1, x, ve2) ∈ Value A ∗ (te1×tv×te2), (ve3, x, ve4) ∈ Value A ∗ (te3×tv×te4): mOP (f)(ve1, x, ve2)([ ]) ≡ case m ′ OP (f)(ve1, ve2)([ v ↦→ x ]) of ⊥ → ⊥, ((ve3, ve4), [ v ↦→ x ′ ]) → ((ve3, x ′ , ve4), [ ]) end Explanation: mOP (f) returns chaos if m ′ OP (f) returns chaos. Otherwise mOP (f) returns the same result as m ′ OP (f), but with the actual value of x ′ of v included. When evaluating m ′ OP (f) a store s = [v ↦→ x] is kept reflecting the actual value x of v. This value is altered during the evaluation of f, since f is a generator. Model Category Composition is defined the obvious way. Identities are defined such that a model is mapped to itself. Model Functor The functor Mod : Sign → Cat is a functor that maps Sign to the category Mod(Σ) of Σ-models and maps each signature morphism σ : Σ → Σ ′ in Sign to the model morphism Mod(σ) : Mod(Σ ′ ) → Mod(Σ) which is described above. 66

Satisfaction Relation 7.5. EXAMPLE Then the satisfaction relation |=Σ must be defined, such that the satisfaction condition can be formulated. The dynamic semantics of mRSL value expressions was defined in [Lin04]. This should be extended to cover the whole subset of RSLI. Proof of Satisfaction Condition The last step is to prove that the satisfaction condition holds. The satisfaction condition is proved in [Lin04] for the institution of mRSL. Most likely this can be carried over to the institution of RSLI. If this is the case the transformation rules are correct. This means that the transformation of an applicative RSL specification into an imperative RSL specification using the transformation rules will be a correct development step. 7.5 Example The following simple example illustrates the ideas of this chapter. First an applicative specification A_SPEC is defined: Specification 7.1 – Applicative specification A_SPEC scheme A_SPEC = class type T = Bool value f : T → T f(x) ≡ ∼ x end A_SPEC can be regarded as a signature Σ and a sentence e. The signature Σ = 〈A, OP, V 〉 of A_SPEC is defined as follows: • A = [T ↦→ Bool], reflecting the type of T • OP = [f ↦→ T → T ], reflecting the type of the function f • V = [ ], as there are no variable definitions in A_SPEC The sentence is defined as e =∀ x : T • f(x) ≡ ∼ x Then the model m = 〈mA, mOP , sinit〉 of A_SPEC can be defined: 67

Satisfaction Relation<br />

7.5. EXAMPLE<br />

Then the satisfaction relation |=Σ must be defined, such that the satisfaction<br />

condition can be formulated. The dynamic semantics <strong>of</strong> mRSL value<br />

expressions was defined in [Lin04]. This should be extended to cover the<br />

whole subset <strong>of</strong> RSLI.<br />

Pro<strong>of</strong> <strong>of</strong> Satisfaction Condition<br />

The last step is to prove that the satisfaction condition holds. The satisfaction<br />

condition is proved in [Lin04] for the institution <strong>of</strong> mRSL. Most likely<br />

this can be carried over to the institution <strong>of</strong> RSLI.<br />

If this is the case the transformation rules are correct. This means that<br />

the transformation <strong>of</strong> an applicative RSL specification <strong>into</strong> an imperative<br />

RSL specification using the transformation rules will be a correct development<br />

step.<br />

7.5 Example<br />

The following simple example illustrates the ideas <strong>of</strong> this chapter.<br />

First an applicative specification A_SPEC is defined:<br />

Specification 7.1 – <strong>Applicative</strong> specification A_SPEC<br />

scheme A_SPEC =<br />

class<br />

type T = Bool<br />

value<br />

f : T → T<br />

f(x) ≡ ∼ x<br />

end<br />

A_SPEC can be regarded as a signature Σ and a sentence e.<br />

The signature Σ = 〈A, OP, V 〉 <strong>of</strong> A_SPEC is defined as follows:<br />

• A = [T ↦→ Bool], reflecting the type <strong>of</strong> T<br />

• OP = [f ↦→ T → T ], reflecting the type <strong>of</strong> the function f<br />

• V = [ ], as there are no variable definitions in A_SPEC<br />

The sentence is defined as e =∀ x : T • f(x) ≡ ∼ x<br />

Then the model m = 〈mA, mOP , sinit〉 <strong>of</strong> A_SPEC can be defined:<br />

67

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!