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

CHAPTER 7. CORRECTNESS OF TRANSFORMATION RULES<br />

for all (ve1, x, ve2) ∈ Value A ∗ (te1×tv×te2):<br />

mOP (f)(vearg)([ ]) ≡<br />

case m ′ OP (f)(vearg)([ v ↦→ dv ]) <strong>of</strong><br />

⊥ → ⊥,<br />

((ve1, ve2), [ v ↦→ dv ′ ]) → ((ve1, dv ′ , ve2), [ ])<br />

end<br />

Note that dom [v ↦→ dv] = dom [v ↦→ dv ′ ] = {v}.<br />

Explanation: mOP (f) returns chaos if m ′ OP (f) returns chaos. Otherwise<br />

mOP (f) returns the same result as m ′ OP (f), but with the actual<br />

value dv ′ <strong>of</strong> v included. When evaluating m ′ OP (f) a store s = [v ↦→ dv]<br />

is kept reflecting the actual value dv <strong>of</strong> v. This value is altered during<br />

the evaluation <strong>of</strong> f, since f is a generator.<br />

3. Combined observer and generator<br />

f : te1 × tv × te2 ∼ → te3 × tv × te4<br />

σ<br />

<br />

f : te1 × te2 ∼ → read v write v te3 × te4<br />

for all (ve1, x, ve2) ∈ Value A ∗ (te1×tv×te2), (ve3, x, ve4) ∈ Value A ∗ (te3×tv×te4):<br />

mOP (f)(ve1, x, ve2)([ ]) ≡<br />

case m ′ OP (f)(ve1, ve2)([ v ↦→ x ]) <strong>of</strong><br />

⊥ → ⊥,<br />

((ve3, ve4), [ v ↦→ x ′ ]) → ((ve3, x ′ , ve4), [ ])<br />

end<br />

Explanation: mOP (f) returns chaos if m ′ OP (f) returns chaos. Otherwise<br />

mOP (f) returns the same result as m ′ OP (f), but with the actual<br />

value <strong>of</strong> x ′ <strong>of</strong> v included. When evaluating m ′ OP (f) a store s = [v ↦→ x]<br />

is kept reflecting the actual value x <strong>of</strong> v. This value is altered during<br />

the evaluation <strong>of</strong> f, since f is a generator.<br />

Model Category<br />

Composition is defined the obvious way. Identities are defined such that a<br />

model is mapped to itself.<br />

Model Functor<br />

The functor Mod : Sign → Cat is a functor that maps Sign to the category<br />

Mod(Σ) <strong>of</strong> Σ-models and maps each signature morphism σ : Σ → Σ ′ in Sign<br />

to the model morphism Mod(σ) : Mod(Σ ′ ) → Mod(Σ) which is described<br />

above.<br />

66

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

Saved successfully!

Ooh no, something went wrong!