Transformation of Applicative Specifications into Imperative ...

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

26.09.2013 Views

CHAPTER 12. POSSIBLE EXTENSIONS OF THE TRANSFORMER 12.1.4 Renaming Class Expressions When transforming a renaming class expression the names of the defined items in the list are transformed into their counterparts in the imperative specification and then the class expression is transformed. 12.1.5 Infinite Map Type Expressions Infinite map type expressions are of the form: type_expr1 ∼ →m type_expr2 An infinite map type expression is transformed by transforming the constituent type expressions. 12.1.6 Single Typings of Higher Order Functions The idea behind transforming single typings of higher order functions is similar to the idea behind transforming single typings of normal functions, which is explained in Section 6.4.1. Examples of transformations of single typings of higher order functions are given in Table 12.1. Applicative single typing ✄ Imperative single typing T → (U → V) ✄ Unit → read t (U → V) (U → V) → T ✄ (U → V) → write t Unit (T → U) → V ✄ (Unit → read t U) → V (U → T) → V ✄ (U → write t Unit) → V U → (T → V) ✄ U → (Unit → read t V) U → (V → T) ✄ U → (V → write t Unit) Table 12.1: Transformation of single typings of higher order functions. T is a type of interest with associated variable t, U and V are not types of interest. 12.1.7 Disambiguation Expressions A disambiguation expression has the following form: value_expr : type_expr A disambiguation expression can be transformed by transforming the constituent value and type expressions. 124

12.1. TRANSFORMATIONS OF CONSTRUCTS OUTSIDE RSLA 12.1.8 Axioms Axioms can be transformed almost as value definitions since value definitions are a short way of writing axioms. The extension should therefore be almost straight forward. It is necessary to consider quantified expressions though. 12.1.9 Quantified Expressions Quantified expressions are of the form: quantifier typing1, ..., typingn • value_expr A quantified expression is transformed by transforming the constituent value expression. If the typings contain types of interest the corresponding variables must be assigned the values of the value names in the typing. Due to side effects an equivalence expression must be established, for example: ∃ x : T • obs(x) ✄ ∃ x : T • ( t := x ; obs() ≡ t := x ; true ) where T is a type of interest and t is the corresponding variable. If the quantified expression contains universal quantification over a type of interest this is replaced by the always combinator ✷, see Example 12.1. Example 12.1 – Transformation of a quantified expression type T = Int value f : T → Int axiom ∀ x : T • f(x) > x ✄ type T = Int variable t : T value f : Unit → read t Int axiom ✷ f() > t 125

CHAPTER 12. POSSIBLE EXTENSIONS OF THE TRANSFORMER<br />

12.1.4 Renaming Class Expressions<br />

When transforming a renaming class expression the names <strong>of</strong> the defined<br />

items in the list are transformed <strong>into</strong> their counterparts in the imperative<br />

specification and then the class expression is transformed.<br />

12.1.5 Infinite Map Type Expressions<br />

Infinite map type expressions are <strong>of</strong> the form:<br />

type_expr1 ∼ →m type_expr2<br />

An infinite map type expression is transformed by transforming the constituent<br />

type expressions.<br />

12.1.6 Single Typings <strong>of</strong> Higher Order Functions<br />

The idea behind transforming single typings <strong>of</strong> higher order functions is<br />

similar to the idea behind transforming single typings <strong>of</strong> normal functions,<br />

which is explained in Section 6.4.1. Examples <strong>of</strong> transformations <strong>of</strong> single<br />

typings <strong>of</strong> higher order functions are given in Table 12.1.<br />

<strong>Applicative</strong> single typing ✄ <strong>Imperative</strong> single typing<br />

T → (U → V) ✄ Unit → read t (U → V)<br />

(U → V) → T ✄ (U → V) → write t Unit<br />

(T → U) → V ✄ (Unit → read t U) → V<br />

(U → T) → V ✄ (U → write t Unit) → V<br />

U → (T → V) ✄ U → (Unit → read t V)<br />

U → (V → T) ✄ U → (V → write t Unit)<br />

Table 12.1: <strong>Transformation</strong> <strong>of</strong> single typings <strong>of</strong> higher order functions. T is a<br />

type <strong>of</strong> interest with associated variable t, U and V are not types <strong>of</strong> interest.<br />

12.1.7 Disambiguation Expressions<br />

A disambiguation expression has the following form:<br />

value_expr : type_expr<br />

A disambiguation expression can be transformed by transforming the<br />

constituent value and type expressions.<br />

124

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

Saved successfully!

Ooh no, something went wrong!