Transformation of Applicative Specifications into Imperative ...
Transformation of Applicative Specifications into Imperative ... Transformation of Applicative Specifications into Imperative ...
APPENDIX C. FORMAL SPECIFICATIONS OF TRANSFORMATIONS (makeSequencingExpr( ApplicationExpr(ve, vel ′ ), type_expr(res), et, trans, func), types ′ ) else if containsGen( vel, typeExprToExpTypeList(arg), trans, func) ∧ ∼ onlyTOIArgument(vel, trans, types) then (makeSequencingExpr( TRFunctionAppl( ve, vel ′ , typeExprToExpTypeList(arg), func, trans, types), type_expr(res), et, trans, func), types ′ ) else (makeSequencingExpr( ApplicationExpr( ve, removeTOI( vel ′ , typeExprToExpTypeList(arg), trans)), type_expr(res), et, trans, func), types ′ ) end end end end else /∗List or map application.∗/ TRListMapAppl(ve, vel, et, func, trans, types) end, → TRListMapAppl(ve, vel, et, func, trans, types) end, /∗Transforms a function application.∗/ /∗ Arguments: ======= ve: the value expression 208
C.1. FORMAL SPECIFICATION OF THE TRANSFORMER vel: the arguments of the function application etl: the expected type of the arguments Result: ======= ValueExpr: the imperative version of the function expression ∗/ TRFunctionAppl : ValueExpr × ValueExpr ∗ × ExpType ∗ × FUNC × TRANS × TYPES → ValueExpr TRFunctionAppl(ve, vel, etl, func, trans, types) ≡ let (b, vl) = makeLetBinding(len vel, 0, 〈〉, 〈〉), vel ′ = makeValueExprList(vel, etl, vl, trans, func) in ApplicationExpr( ve, 〈LetExpr( 〈mk_LetDef( MakeBinding(makeBinding(b)), ProductExpr(vel))〉, ProductExpr(vel ′ ))〉) end, /∗Removes arguments of the type of interest.∗/ /∗ Arguments: ======= vel: the arguments of the function application etl: the expected type of the arguments Result: ======= ValueExpr_list: the resulting value expression list ∗/ removeTOI : ValueExpr ∗ × ExpType ∗ × TRANS → ValueExpr ∗ removeTOI(vel, etl, trans) ≡ if vel = 〈〉 then 〈〉 else case hd etl of 209
- Page 174 and 175: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 176 and 177: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 178 and 179: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 180 and 181: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 182 and 183: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 184 and 185: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 186 and 187: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 188 and 189: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 190 and 191: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 192 and 193: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 194 and 195: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 196 and 197: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 198 and 199: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 200 and 201: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 202 and 203: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 204 and 205: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 206 and 207: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 208 and 209: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 210 and 211: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 212 and 213: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 214 and 215: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 216 and 217: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 218 and 219: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 220 and 221: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 222 and 223: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 226 and 227: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 228 and 229: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 230 and 231: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 232 and 233: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 234 and 235: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 236 and 237: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 238 and 239: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 240 and 241: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 242 and 243: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 244 and 245: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 246 and 247: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 248 and 249: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 250 and 251: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 252 and 253: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 254 and 255: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 256 and 257: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 258 and 259: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 260 and 261: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 262 and 263: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 264 and 265: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 266 and 267: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 268 and 269: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 270 and 271: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 272 and 273: APPENDIX C. FORMAL SPECIFICATIONS O
C.1. FORMAL SPECIFICATION OF THE TRANSFORMER<br />
vel: the arguments <strong>of</strong> the function application<br />
etl: the expected type <strong>of</strong> the arguments<br />
Result:<br />
=======<br />
ValueExpr: the imperative version <strong>of</strong> the function<br />
expression<br />
∗/<br />
TRFunctionAppl :<br />
ValueExpr × ValueExpr ∗ × ExpType ∗ ×<br />
FUNC × TRANS × TYPES →<br />
ValueExpr<br />
TRFunctionAppl(ve, vel, etl, func, trans, types) ≡<br />
let<br />
(b, vl) = makeLetBinding(len vel, 0, 〈〉, 〈〉),<br />
vel ′ =<br />
makeValueExprList(vel, etl, vl, trans, func)<br />
in<br />
ApplicationExpr(<br />
ve,<br />
〈LetExpr(<br />
〈mk_LetDef(<br />
MakeBinding(makeBinding(b)),<br />
ProductExpr(vel))〉,<br />
ProductExpr(vel ′ ))〉)<br />
end,<br />
/∗Removes arguments <strong>of</strong> the type <strong>of</strong> interest.∗/<br />
/∗<br />
Arguments:<br />
=======<br />
vel: the arguments <strong>of</strong> the function application<br />
etl: the expected type <strong>of</strong> the arguments<br />
Result:<br />
=======<br />
ValueExpr_list: the resulting value expression<br />
list<br />
∗/<br />
removeTOI :<br />
ValueExpr ∗ × ExpType ∗ × TRANS →<br />
ValueExpr ∗<br />
removeTOI(vel, etl, trans) ≡<br />
if vel = 〈〉 then 〈〉<br />
else<br />
case hd etl <strong>of</strong><br />
209