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: true if they are identical, false otherwise ∗/ equalsTypesList : TypeExprLists × TypeExprLists → Bool equalsTypesList(tel1, tel2) ≡ case tel1 of FiniteListTypeExpr(te1) → case tel2 of FiniteListTypeExpr(te2) → equalsTypes(te1, te2), → false end, InfiniteListTypeExpr(te1) → case tel2 of InfiniteListTypeExpr(te2) → equalsTypes(te1, te2), → false end end, /∗Compares two map type expressions.∗/ /∗ Arguments: ======= tel1: the map type expression tel2: the map type expression Results: ===== Bool: true if they are identical, false otherwise ∗/ equalsTypesMap : TypeExprMaps × TypeExprMaps → Bool equalsTypesMap(tem1, tem2) ≡ case tem1 of FiniteMapTypeExpr(tedom1, terange1) → case tem2 of FiniteMapTypeExpr(tedom2, terange2) → equalsTypes(tedom1, tedom2) ∧ equalsTypes(terange1, terange2), → false end, InfiniteMapTypeExpr(tedom1, terange1) → case tem2 of InfiniteMapTypeExpr(tedom2, terange2) → equalsTypes(tedom1, tedom2) ∧ 228

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER end, end equalsTypes(terange1, terange2), → false /∗**** TypeExpr end ****∗/ /∗**** ExpType ****∗/ /∗Gets the head of an expected type which is a TypeExprProduct.∗/ /∗ Arguments: ======= et: the expected type Results: ===== ExpType: the head of the TypeExprProduct of the expected type ∗/ getHead : ExpType → ExpType getHead(et) ≡ case et of Known(te) → case te of TypeExprProduct(tel) → case hd tel of BracketedTypeExpr(bte) → Known(bte), → Known(hd tel) end, → Unknown end, Unknown → Unknown end, /∗Gets the tail of an expected type which is a TypeExprProduct.∗/ /∗ Arguments: ======= et: the expected type Results: ===== ExpType: the tail of the TypeExprProduct of the 229

APPENDIX C. FORMAL SPECIFICATIONS OF TRANSFORMATIONS<br />

Bool: true if they are identical, false otherwise<br />

∗/<br />

equalsTypesList :<br />

TypeExprLists × TypeExprLists → Bool<br />

equalsTypesList(tel1, tel2) ≡<br />

case tel1 <strong>of</strong><br />

FiniteListTypeExpr(te1) →<br />

case tel2 <strong>of</strong><br />

FiniteListTypeExpr(te2) →<br />

equalsTypes(te1, te2),<br />

→ false<br />

end,<br />

InfiniteListTypeExpr(te1) →<br />

case tel2 <strong>of</strong><br />

InfiniteListTypeExpr(te2) →<br />

equalsTypes(te1, te2),<br />

→ false<br />

end<br />

end,<br />

/∗Compares two map type expressions.∗/<br />

/∗<br />

Arguments:<br />

=======<br />

tel1: the map type expression<br />

tel2: the map type expression<br />

Results:<br />

=====<br />

Bool: true if they are identical, false otherwise<br />

∗/<br />

equalsTypesMap : TypeExprMaps × TypeExprMaps → Bool<br />

equalsTypesMap(tem1, tem2) ≡<br />

case tem1 <strong>of</strong><br />

FiniteMapTypeExpr(tedom1, terange1) →<br />

case tem2 <strong>of</strong><br />

FiniteMapTypeExpr(tedom2, terange2) →<br />

equalsTypes(tedom1, tedom2) ∧<br />

equalsTypes(terange1, terange2),<br />

→ false<br />

end,<br />

InfiniteMapTypeExpr(tedom1, terange1) →<br />

case tem2 <strong>of</strong><br />

InfiniteMapTypeExpr(tedom2, terange2) →<br />

equalsTypes(tedom1, tedom2) ∧<br />

228

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

Saved successfully!

Ooh no, something went wrong!