Transformation of Applicative Specifications into Imperative ...
Transformation of Applicative Specifications into Imperative ... Transformation of Applicative Specifications into Imperative ...
CHAPTER 6. TRANSFORMATIONS Applicative single typing ✄ Imperative single typing U → V ✄ U → V T → V ✄ Unit → read t V U → T ✄ U → write t Unit T → T ✄ Unit → read t write t Unit T × U → V ✄ U → read t V U → T × V ✄ U → write t V T × U → T × V ✄ U → read t write t V Table 6.1: Transformation of single typings. T is a type of interest with associated variable t, U and V are not of the type of interest. superfluous read access descriptor is included in order to ease the verification of the transformation rules, see Chapter 7. The reason for these transformations is that instead of referring to the type of interest using parameters, you refer to the corresponding variable of the type of interest, and instead of returning a type of interest, you assign the results to the variable of the type of interest. 6.4.2 Transforming Formal Function Applications When transforming formal function applications all occurrences of parameters of the type of interest are removed as in the following example where t is a parameter of the type of interest: f(u, t, v) ≡ ... ✄ f(u, v) ≡ ... If the type of interest is an abbreviation type and this is exploited in the formal function application, all parameters forming the type of interest are removed as in the following example where (u, v) is of the type of interest: f(p, (u, v), q) ≡ ... ✄ f(p, q) ≡ ... When this is done it is necessary to establish a let expression in the transformation of the value expression at the right hand side of the equivalence operator ≡: f(p, q) ≡ let (u, v) = t in ... end This is done in order to be able to refer to the parameters removed as these are not variables that can be referred to as t can. 34
6.4. TRANSFORMING EXPLICIT FUNCTION DEFINITIONS 6.4.3 Transforming Value Expressions in Function Definitions This section concerns the transformation of value expressions in function definitions. First a general introduction to the transformations is given and then the different kinds of value expressions are discussed one by one. Introduction to Transforming Value Expressions A function can always be transformed by making the value expression a function application of the corresponding applicative function in which all parameters of the types of interest are replaced by the corresponding variables, see Example 6.3. However, since the goal of the transformation is to remove all occurrences of objects of the applicative specification this is not satisfactory and can be improved in most cases by exploiting the following idea: Example 6.3 – General transformation scheme A_SPEC = class type T = ..., U = ..., V = ... value obs1 : T → U obs1(t) ≡ ..., obs2 : T × U → V obs2(t, u) ≡ ..., gen1 : T → T gen1(t) ≡ ..., gen2 : T × U → T gen2(t, u) ≡ ..., gen3 : T → T × U gen3(t) ≡ ... gen4 : T × U → T × V gen4(t, u) ≡ ... end ✄ scheme I_SPEC = class 35
- Page 1: Transformation of Applicative Speci
- Page 5: Resumé RAISE udviklingsmetoden er
- Page 8 and 9: viii
- Page 10 and 11: CONTENTS 6.4.3 Transforming Value E
- Page 12 and 13: CONTENTS 12.2.4 Interactive Transfo
- Page 14 and 15: xiv
- Page 16 and 17: LIST OF FIGURES xvi
- Page 18 and 19: CHAPTER 1. INTRODUCTION This stepwi
- Page 20 and 21: CHAPTER 1. INTRODUCTION 1. Formulat
- Page 22 and 23: CHAPTER 1. INTRODUCTION 1.7 Content
- Page 24 and 25: CHAPTER 2. GENERAL IDEA end value e
- Page 26 and 27: CHAPTER 2. GENERAL IDEA • In the
- Page 28 and 29: CHAPTER 2. GENERAL IDEA value incre
- Page 30 and 31: CHAPTER 3. TERMINOLOGY Expected Typ
- Page 32 and 33: CHAPTER 3. TERMINOLOGY Example 3.5
- Page 34 and 35: CHAPTER 3. TERMINOLOGY 18
- Page 36 and 37: CHAPTER 4. CONSTRAINTS further deve
- Page 38 and 39: CHAPTER 4. CONSTRAINTS of interest.
- Page 40 and 41: CHAPTER 4. CONSTRAINTS 24
- Page 42 and 43: CHAPTER 5. TRANSFORMABILITY scheme
- Page 44 and 45: CHAPTER 5. TRANSFORMABILITY 28
- Page 46 and 47: CHAPTER 6. TRANSFORMATIONS 6.2.1 Tr
- Page 48 and 49: CHAPTER 6. TRANSFORMATIONS Example
- Page 52 and 53: CHAPTER 6. TRANSFORMATIONS object A
- Page 54 and 55: CHAPTER 6. TRANSFORMATIONS type T =
- Page 56 and 57: CHAPTER 6. TRANSFORMATIONS where ge
- Page 58 and 59: CHAPTER 6. TRANSFORMATIONS Ranged s
- Page 60 and 61: CHAPTER 6. TRANSFORMATIONS ✄ end
- Page 62 and 63: CHAPTER 6. TRANSFORMATIONS Value In
- Page 64 and 65: CHAPTER 6. TRANSFORMATIONS ✄ sche
- Page 66 and 67: CHAPTER 6. TRANSFORMATIONS A case e
- Page 68 and 69: CHAPTER 6. TRANSFORMATIONS is due t
- Page 70 and 71: CHAPTER 6. TRANSFORMATIONS 6.4.4 Tr
- Page 72 and 73: CHAPTER 6. TRANSFORMATIONS 56
- Page 74 and 75: CHAPTER 7. CORRECTNESS OF TRANSFORM
- Page 76 and 77: CHAPTER 7. CORRECTNESS OF TRANSFORM
- Page 78 and 79: CHAPTER 7. CORRECTNESS OF TRANSFORM
- Page 80 and 81: CHAPTER 7. CORRECTNESS OF TRANSFORM
- Page 82 and 83: CHAPTER 7. CORRECTNESS OF TRANSFORM
- Page 84 and 85: CHAPTER 7. CORRECTNESS OF TRANSFORM
- Page 86 and 87: CHAPTER 7. CORRECTNESS OF TRANSFORM
- Page 88 and 89: CHAPTER 8. SPECIFICATIONS The rewri
- Page 90 and 91: CHAPTER 8. SPECIFICATIONS RSL speci
- Page 92 and 93: CHAPTER 8. SPECIFICATIONS The FUNC
- Page 94 and 95: CHAPTER 8. SPECIFICATIONS out, that
- Page 96 and 97: CHAPTER 8. SPECIFICATIONS construct
- Page 98 and 99: CHAPTER 8. SPECIFICATIONS 8.4.1 Mor
CHAPTER 6. TRANSFORMATIONS<br />
<strong>Applicative</strong> single typing ✄ <strong>Imperative</strong> single typing<br />
U → V ✄ U → V<br />
T → V ✄ Unit → read t V<br />
U → T ✄ U → write t Unit<br />
T → T ✄ Unit → read t write t Unit<br />
T × U → V ✄ U → read t V<br />
U → T × V ✄ U → write t V<br />
T × U → T × V ✄ U → read t write t V<br />
Table 6.1: <strong>Transformation</strong> <strong>of</strong> single typings. T is a type <strong>of</strong> interest with<br />
associated variable t, U and V are not <strong>of</strong> the type <strong>of</strong> interest.<br />
superfluous read access descriptor is included in order to ease the verification<br />
<strong>of</strong> the transformation rules, see Chapter 7.<br />
The reason for these transformations is that instead <strong>of</strong> referring to the<br />
type <strong>of</strong> interest using parameters, you refer to the corresponding variable <strong>of</strong><br />
the type <strong>of</strong> interest, and instead <strong>of</strong> returning a type <strong>of</strong> interest, you assign<br />
the results to the variable <strong>of</strong> the type <strong>of</strong> interest.<br />
6.4.2 Transforming Formal Function Applications<br />
When transforming formal function applications all occurrences <strong>of</strong> parameters<br />
<strong>of</strong> the type <strong>of</strong> interest are removed as in the following example where t<br />
is a parameter <strong>of</strong> the type <strong>of</strong> interest:<br />
f(u, t, v) ≡ ...<br />
✄<br />
f(u, v) ≡ ...<br />
If the type <strong>of</strong> interest is an abbreviation type and this is exploited in the<br />
formal function application, all parameters forming the type <strong>of</strong> interest are<br />
removed as in the following example where (u, v) is <strong>of</strong> the type <strong>of</strong> interest:<br />
f(p, (u, v), q) ≡ ...<br />
✄<br />
f(p, q) ≡ ...<br />
When this is done it is necessary to establish a let expression in the transformation<br />
<strong>of</strong> the value expression at the right hand side <strong>of</strong> the equivalence<br />
operator ≡:<br />
f(p, q) ≡ let (u, v) = t in ... end<br />
This is done in order to be able to refer to the parameters removed as<br />
these are not variables that can be referred to as t can.<br />
34