Transformation of Applicative Specifications into Imperative ...
Transformation of Applicative Specifications into Imperative ... Transformation of Applicative Specifications into Imperative ...
CHAPTER 8. SPECIFICATIONS PRECOND_TYPES :: preCond : OptionalPreCondition typesMap : TYPES value TROptPreCondition : OptionalPreCondition × ExpType × FUNC × TRANS × TYPES → PRECOND_TYPES TROptPreCondition(precond, et, func, trans, types) ≡ case precond of PreCondition(ve) → mk_PRECOND_TYPES( PreCondition( valueExpr( TRValueExpr(ve, et, func, trans, types)) ), typesMap( TRValueExpr(ve, et, func, trans, types))), NoPreCondition → mk_PRECOND_TYPES(NoPreCondition, types) end 8.4.3 Lack of Operators Only a small subset of operators are included in the RSL1 subset. The lack of these operators makes it necessary to implement their functionality using functions. Some of the operators are straight forward to implement, whereas some limit the functionality of the transformer. An example of the first kind is the inequality operator = and the negation operator ∼. A solution to the lack of the these operators can be seen in Example 8.4. Example 8.4 – Lack of operators – inequality and negation RSL specification: . if tel = 〈〉 then (false, mk_FormalFunctionParameter(〈〉), env, 84
. 8.4. SPECIFICATION OF THE TRANSFORMER IN RSL1 types, prlet) else (true, mk_FormalFunctionParameter(〈〉), env, types, prlet) end RSL1 specification: . . if not(tel = 〈〉) then mk_BOOL_FFP_ENV_TYPES_LDL( false, mk_FormalFunctionParameter(〈〉), env, types, prlet) else mk_BOOL_FFP_ENV_TYPES_LDL( true, mk_FormalFunctionParameter(〈〉), env, types, prlet) end not : Bool → Bool not(b) ≡ if b then false else true end An example of the second kind is the lack of the minus operator. As the minus operator cannot be implemented directly using the limited range of operators in RSL1, it is necessary to implement this in a way that limits the functionality of transformer. This can be seen in Example 8.5. The limitation is that the minusOne function can only handle numbers from 1 through 10 and that it only is capable of subtracting by one. Example 8.5 – Lack of operators – minus RSL specification: toExpTypeList : ExpType × Nat → ExpType ∗ toExpTypeList(et, length) ≡ 85
- 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 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
- 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
- Page 112 and 113: CHAPTER 8. SPECIFICATIONS the lack
- Page 114 and 115: CHAPTER 9. IMPLEMENTATION OF THE TR
- Page 116 and 117: CHAPTER 9. IMPLEMENTATION OF THE TR
- Page 118 and 119: CHAPTER 9. IMPLEMENTATION OF THE TR
- Page 120 and 121: CHAPTER 9. IMPLEMENTATION OF THE TR
- Page 122 and 123: CHAPTER 9. IMPLEMENTATION OF THE TR
- Page 124 and 125: CHAPTER 9. IMPLEMENTATION OF THE TR
- Page 126 and 127: CHAPTER 10. EXAMPLES OF TRANSFORMAT
- Page 128 and 129: CHAPTER 10. EXAMPLES OF TRANSFORMAT
- Page 130 and 131: CHAPTER 10. EXAMPLES OF TRANSFORMAT
- Page 132 and 133: CHAPTER 10. EXAMPLES OF TRANSFORMAT
- Page 134 and 135: CHAPTER 10. EXAMPLES OF TRANSFORMAT
- Page 136 and 137: CHAPTER 11. TEST 11.1.1 Lexer and P
- Page 138 and 139: CHAPTER 11. TEST An overview of the
- Page 140 and 141: CHAPTER 12. POSSIBLE EXTENSIONS OF
- Page 142 and 143: CHAPTER 12. POSSIBLE EXTENSIONS OF
- Page 144 and 145: CHAPTER 12. POSSIBLE EXTENSIONS OF
- Page 146 and 147: CHAPTER 13. CONCLUSION RSL AST and
- Page 148 and 149: CHAPTER 13. CONCLUSION 132
CHAPTER 8. SPECIFICATIONS<br />
PRECOND_TYPES ::<br />
preCond : OptionalPreCondition typesMap : TYPES<br />
value<br />
TROptPreCondition :<br />
OptionalPreCondition × ExpType × FUNC × TRANS ×<br />
TYPES →<br />
PRECOND_TYPES<br />
TROptPreCondition(precond, et, func, trans, types) ≡<br />
case precond <strong>of</strong><br />
PreCondition(ve) →<br />
mk_PRECOND_TYPES(<br />
PreCondition(<br />
valueExpr(<br />
TRValueExpr(ve, et, func, trans, types))<br />
),<br />
typesMap(<br />
TRValueExpr(ve, et, func, trans, types))),<br />
NoPreCondition →<br />
mk_PRECOND_TYPES(NoPreCondition, types)<br />
end<br />
8.4.3 Lack <strong>of</strong> Operators<br />
Only a small subset <strong>of</strong> operators are included in the RSL1 subset. The lack<br />
<strong>of</strong> these operators makes it necessary to implement their functionality using<br />
functions. Some <strong>of</strong> the operators are straight forward to implement, whereas<br />
some limit the functionality <strong>of</strong> the transformer.<br />
An example <strong>of</strong> the first kind is the inequality operator = and the negation<br />
operator ∼. A solution to the lack <strong>of</strong> the these operators can be seen in<br />
Example 8.4.<br />
Example 8.4 – Lack <strong>of</strong> operators – inequality and negation<br />
RSL specification:<br />
.<br />
if tel = 〈〉<br />
then<br />
(false, mk_FormalFunctionParameter(〈〉), env,<br />
84