Transformation of Applicative Specifications into Imperative ...

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

26.09.2013 Views

CHAPTER 6. TRANSFORMATIONS ✄ end f3 : Int × T → T f3(i, x) ≡ gen2(i, x), gen1 : T → T gen1(x) ≡ x + 1, gen2 : Int × T → T gen2(i, x) ≡ i + x scheme I_SPEC = class type T = Int end variable t : T value f1 : Unit → read t write t Unit f1() ≡ gen1(), f2 : Int → read t write t Unit f2(i) ≡ gen1(t := i + 1), f3 : Int → read t write t Unit f3(i) ≡ gen2(let (pa_0, pa_1) = (i, t := t) in (pa_0) end), gen1 : Unit → read t write t Unit gen1() ≡ t := t + 1, gen2 : Int → read t write t Unit gen2(i) ≡ t := i + t List application expressions and map application expressions are tranformed by transforming the constituent value expressions. An example of the transformation of a list application can be found in Example 6.10. 44

6.4. TRANSFORMING EXPLICIT FUNCTION DEFINITIONS Example 6.10 – Transformation of a list application scheme A_SPEC = class type T = Int, LIST = Int ∗ ✄ end value f : T × LIST → Int f(x, l) ≡ l(g1(x)), g1 : T → T g1(x) ≡ x + 1 scheme I_SPEC = class type T = Int, LIST = Int ∗ end variable t : T value f : LIST → read t write t Int f(l) ≡ l((g1() ; t)), g1 : Unit → read t write t Unit g1() ≡ t := t + 1 Bracketed Expressions A bracketed expression has the following form: (value_expr) A bracketed expression is transformed by transforming the constituent value expression. 45

CHAPTER 6. TRANSFORMATIONS<br />

✄<br />

end<br />

f3 : Int × T → T<br />

f3(i, x) ≡ gen2(i, x),<br />

gen1 : T → T<br />

gen1(x) ≡ x + 1,<br />

gen2 : Int × T → T<br />

gen2(i, x) ≡ i + x<br />

scheme I_SPEC =<br />

class<br />

type<br />

T = Int<br />

end<br />

variable<br />

t : T<br />

value<br />

f1 : Unit → read t write t Unit<br />

f1() ≡ gen1(),<br />

f2 : Int → read t write t Unit<br />

f2(i) ≡ gen1(t := i + 1),<br />

f3 : Int → read t write t Unit<br />

f3(i) ≡<br />

gen2(let (pa_0, pa_1) = (i, t := t) in (pa_0) end),<br />

gen1 : Unit → read t write t Unit<br />

gen1() ≡ t := t + 1,<br />

gen2 : Int → read t write t Unit<br />

gen2(i) ≡ t := i + t<br />

List application expressions and map application expressions are tranformed<br />

by transforming the constituent value expressions. An example <strong>of</strong><br />

the transformation <strong>of</strong> a list application can be found in Example 6.10.<br />

44

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

Saved successfully!

Ooh no, something went wrong!