Transformation of Applicative Specifications into Imperative ...

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

26.09.2013 Views

APPENDIX C. FORMAL SPECIFICATIONS OF TRANSFORMATIONS Bool CheckPreCondApplicationExpr( ve, vel, func, trans, types) ≡ if CheckPreCondGenProduct(vel, func, trans, types) then case ve of Make_ValueOrVariableName(vn) → if id(vn) ∈ dom func then /∗The application expression is a function application. ∗/ if write_list(func(id(vn))) = 〈〉 then false else case type_expr(func(id(vn))) of FunctionTypeExpr(arg, fa, res) → ∼ containsGen( vel, typeExprToExpTypeList(arg), trans, func) ∨ onlyTOIArgument(vel, trans, types) end end else /∗List or map application.∗/ true end end else false end, /∗Checks if a let def list contains generators or hidden generators.∗/ /∗ Arguments: ======= ldl: the let def list Results: ===== Bool: true if the let def list does not contain generators, false otherwise ∗/ CheckPreCondGenLetDef : LetDef ∗ × FUNC × TRANS × TYPES → Bool CheckPreCondGenLetDef(ldl, func, trans, types) ≡ if ldl = 〈〉 then true 160

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER else CheckPreCondGen( value_expr(hd ldl), func, trans, types) ∧ CheckPreCondGenLetDef(tl ldl, func, trans, types) end, /∗Checks if an elsif list contains generators or hidden generators.∗/ /∗ Arguments: ======= eil: the elsif list Results: ===== Bool: true if the elsif list does not contain generators, false otherwise ∗/ CheckPreCondGenElsif : Elsif ∗ × FUNC × TRANS × TYPES → Bool CheckPreCondGenElsif(eil, func, trans, types) ≡ if eil = 〈〉 then true else CheckPreCondGen( condition(hd eil), func, trans, types) ∧ CheckPreCondGen( elsif_case(hd eil), func, trans, types) ∧ CheckPreCondGenElsif(tl eil, func, trans, types) end, /∗Checks if a case branch list contains generators or hidden generators.∗/ /∗ Arguments: ======= cbl: the case branch list Results: ===== Bool: true if the case branch list does not contain generators, false otherwise ∗/ CheckPreCondGenCaseBranch : CaseBranch ∗ × FUNC × TRANS × TYPES → Bool CheckPreCondGenCaseBranch(cbl, func, trans, types) ≡ if cbl = 〈〉 then true 161

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER<br />

else<br />

CheckPreCondGen(<br />

value_expr(hd ldl), func, trans, types) ∧<br />

CheckPreCondGenLetDef(tl ldl, func, trans, types)<br />

end,<br />

/∗Checks if an elsif list contains generators<br />

or hidden generators.∗/<br />

/∗<br />

Arguments:<br />

=======<br />

eil: the elsif list<br />

Results:<br />

=====<br />

Bool: true if the elsif list does not contain<br />

generators, false otherwise<br />

∗/<br />

CheckPreCondGenElsif :<br />

Elsif ∗ × FUNC × TRANS × TYPES → Bool<br />

CheckPreCondGenElsif(eil, func, trans, types) ≡<br />

if eil = 〈〉 then true<br />

else<br />

CheckPreCondGen(<br />

condition(hd eil), func, trans, types) ∧<br />

CheckPreCondGen(<br />

elsif_case(hd eil), func, trans, types) ∧<br />

CheckPreCondGenElsif(tl eil, func, trans, types)<br />

end,<br />

/∗Checks if a case branch list contains generators<br />

or hidden generators.∗/<br />

/∗<br />

Arguments:<br />

=======<br />

cbl: the case branch list<br />

Results:<br />

=====<br />

Bool: true if the case branch list does not contain<br />

generators, false otherwise<br />

∗/<br />

CheckPreCondGenCaseBranch :<br />

CaseBranch ∗ × FUNC × TRANS × TYPES → Bool<br />

CheckPreCondGenCaseBranch(cbl, func, trans, types) ≡<br />

if cbl = 〈〉 then true<br />

161

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

Saved successfully!

Ooh no, something went wrong!