Transformation of Applicative Specifications into Imperative ...
Transformation of Applicative Specifications into Imperative ... Transformation of Applicative Specifications into Imperative ...
CHAPTER 6. TRANSFORMATIONS Value Infix Expressions A value infix expression has the following form: value_expr1 infix_op value_expr2 A value infix expression is transformed by transforming the constituent value expressions. The infix operator stays the same. Value Prefix Expressions A value prefix expression has the following form: prefix_op value_expr A value prefix expression is transformed by transforming the constituent value expression. The prefix operator stays the same. Let Expressions A let expression takes the following form: let letbinding1 = value_expr1, . letbindingn = value_exprn in value_exprn+1 end A let expression is transformed by transforming the constituent value expressions. Furthermore, the let bindings have to be transformed in order to comply with the return values of the corresponding value expressions. The reason for this is that in the imperative specification generators do not return values of the type of interest. There are three cases to consider when dealing with a let expression of the form: let letbinding = value_expr in ... end 46
6.4. TRANSFORMING EXPLICIT FUNCTION DEFINITIONS The type of value_expr: 1. does not contain T. Transformation: The letbinding is transformed into itself, see function f1 in Example 6.11. 2. is T. Transformation: A so called "dummy" binding is inserted in order to keep the let expression and the order of the let definitions, see function f2 in Example 6.11. 3. is a product in which T occurs. Transformation: The bindings corresponding to the values of the type of interest are removed from the letbinding, see function f3 in Example 6.11 Example 6.11 – Transformation of let expressions scheme A_SPEC = class type T = Int end value f1 : T → Int f1(x) ≡ let z = obs(x) in z end, f2 : Int → Int f2(x) ≡ let x1 = gen1(x) in x1 + 1 end, f3 : Int → Int f3(x) ≡ let (x1, z) = gen2(x) in z end, obs : T → Int obs(x) ≡ x, gen1 : Int → T gen1(x) ≡ x + 1, gen2 : Int → T × Int gen2(x) ≡ (x + 1, x − 1) 47
- 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 50 and 51: CHAPTER 6. TRANSFORMATIONS Applicat
- 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 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
- Page 100 and 101: CHAPTER 8. SPECIFICATIONS PRECOND_T
- Page 102 and 103: CHAPTER 8. SPECIFICATIONS if length
- Page 104 and 105: CHAPTER 8. SPECIFICATIONS subtypes.
- Page 106 and 107: CHAPTER 8. SPECIFICATIONS 8.5.2 Cha
- Page 108 and 109: CHAPTER 8. SPECIFICATIONS axiom [ m
- Page 110 and 111: CHAPTER 8. SPECIFICATIONS Specifica
6.4. TRANSFORMING EXPLICIT FUNCTION DEFINITIONS<br />
The type <strong>of</strong> value_expr:<br />
1. does not contain T.<br />
<strong>Transformation</strong>: The letbinding is transformed <strong>into</strong> itself, see function<br />
f1 in Example 6.11.<br />
2. is T.<br />
<strong>Transformation</strong>: A so called "dummy" binding is inserted in order to<br />
keep the let expression and the order <strong>of</strong> the let definitions, see function<br />
f2 in Example 6.11.<br />
3. is a product in which T occurs.<br />
<strong>Transformation</strong>: The bindings corresponding to the values <strong>of</strong> the<br />
type <strong>of</strong> interest are removed from the letbinding, see function f3 in<br />
Example 6.11<br />
Example 6.11 – <strong>Transformation</strong> <strong>of</strong> let expressions<br />
scheme A_SPEC =<br />
class<br />
type<br />
T = Int<br />
end<br />
value<br />
f1 : T → Int<br />
f1(x) ≡ let z = obs(x) in z end,<br />
f2 : Int → Int<br />
f2(x) ≡ let x1 = gen1(x) in x1 + 1 end,<br />
f3 : Int → Int<br />
f3(x) ≡ let (x1, z) = gen2(x) in z end,<br />
obs : T → Int<br />
obs(x) ≡ x,<br />
gen1 : Int → T<br />
gen1(x) ≡ x + 1,<br />
gen2 : Int → T × Int<br />
gen2(x) ≡ (x + 1, x − 1)<br />
47