26.09.2013 Views

Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Model Morphisms<br />

7.4. AN INSTITUTION FOR RSLI<br />

Let Σ = 〈A, OP, V 〉 and Σ ′ = 〈A ′ , OP ′ , V ′ 〉 be signatures, σ : Σ → Σ ′ a signature<br />

morphism and m ′ = 〈m ′ A , m′ OP , s′ init 〉 a Σ′ -model. The model morphism<br />

Mod(σ) : Mod(Σ ′ ) → Mod(Σ) <strong>of</strong> m ′ is the Σ-model m = 〈mA, mOP , sinit〉<br />

where<br />

• mA = m ′ A<br />

• for mOP :<br />

– dom mOP = dom OP = dom OP ′ = dom m ′ OP<br />

– mOP (c) is defined in terms <strong>of</strong> m ′ OP (c) for c ∈ dom mOP . Some<br />

examples <strong>of</strong> this is given below.<br />

• sinit = s ′ init \(dom V ′ \dom V ). Note that sinit = [ ] in the applicative<br />

case.<br />

In the following examples <strong>of</strong> how mOP (f) is defined in terms <strong>of</strong> m ′ OP (f)<br />

are given. In the examples it is assumed that the signature Σ is applicative<br />

and the σ-transformation only has one type <strong>of</strong> interest tv with corresponding<br />

variable v. Three cases are considered.<br />

1. Observer<br />

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

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

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

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

⊥ → ⊥,<br />

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

end<br />

σ<br />

f : te1 × te2 ∼ → read v tres<br />

Note that [v ↦→ x] = [v ↦→ x ′ ] as m ′ OP (f) must write conform with the<br />

empty set <strong>of</strong> write variables.<br />

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

mOP (f) returns the same result as m ′ OP (f). When evaluating<br />

m ′ OP<br />

(f) a store s = [v ↦→ x] is kept reflecting the actual value x <strong>of</strong><br />

v. This value is not altered during the evaluation <strong>of</strong> f, since f is an<br />

observer.<br />

2. Generator<br />

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

σ<br />

f : targ ∼ → write v te1 × te2<br />

65

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

Saved successfully!

Ooh no, something went wrong!