Transformation of Applicative Specifications into Imperative ...

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

26.09.2013 Views

APPENDIX D. SPECIFICATION OF TRANSFORMER IN RSL1 BracketedTypeExpr(bte) → Known(bte), → Known(hd tel) end, → Unknown end, Unknown → Unknown end, getTail : ExpType → ExpType getTail(et) ≡ case et of Known(te) → case te of TypeExprProduct(tel) → Known(TypeExprProduct(tl tel)), → Unknown end, Unknown → Unknown end, expTypeList : TypeExpr × Int → ExpType ∗ expTypeList(te, length) ≡ if length = 1 then 〈Known(te)〉 else expTypeToExpTypeList( removeBrackets(Known(te)), length) end, expTypeToExpTypeList : ExpType × Int → ExpType ∗ expTypeToExpTypeList(et, length) ≡ if equals(length, 0) then 〈〉 else 〈getHead(et)〉 expTypeToExpTypeList(getTail(et), minusOne(length)) end, toExpTypeList : ExpType × Int → ExpType ∗ toExpTypeList(et, length) ≡ if equals(length, 0) then 〈〉 else 〈et〉 toExpTypeList(et, minusOne(length)) end, typeExprToExpTypeList : TypeExpr → ExpType ∗ typeExprToExpTypeList(te) ≡ 412

D.2. FORMAL SPECIFICATION OF THE TRANSFORMER IN RSL1 case te of TypeExprProduct(tep) → typeExprListToExpTypeList(tep), TypeLiteral(ln) → case ln of UNIT → 〈〉, → 〈Known(te)〉 end, → 〈Known(te)〉 end, typeExprListToExpTypeList : TypeExpr ∗ → ExpType ∗ typeExprListToExpTypeList(tel) ≡ if tel = 〈〉 then 〈〉 else 〈Known(hd tel)〉 typeExprListToExpTypeList(tl tel) end, getSetType : ExpType → ExpType getSetType(et) ≡ case et of Known(te) → case te of TypeExprSet(tes) → case tes of FiniteSetTypeExpr(fse) → Known(fse), InfiniteSetTypeExpr(ise) → Known(ise) end, → Unknown end, → Unknown end, getListType : ExpType → ExpType getListType(et) ≡ case et of Known(te) → case te of TypeExprList(tes) → case tes of FiniteListTypeExpr(fse) → Known(fse), InfiniteListTypeExpr(ise) → Known(ise) 413

D.2. FORMAL SPECIFICATION OF THE TRANSFORMER IN RSL1<br />

case te <strong>of</strong><br />

TypeExprProduct(tep) →<br />

typeExprListToExpTypeList(tep),<br />

TypeLiteral(ln) →<br />

case ln <strong>of</strong><br />

UNIT → 〈〉,<br />

→ 〈Known(te)〉<br />

end,<br />

→ 〈Known(te)〉<br />

end,<br />

typeExprListToExpTypeList :<br />

TypeExpr ∗ → ExpType ∗<br />

typeExprListToExpTypeList(tel) ≡<br />

if tel = 〈〉 then 〈〉<br />

else<br />

〈Known(hd tel)〉 <br />

typeExprListToExpTypeList(tl tel)<br />

end,<br />

getSetType : ExpType → ExpType<br />

getSetType(et) ≡<br />

case et <strong>of</strong><br />

Known(te) →<br />

case te <strong>of</strong><br />

TypeExprSet(tes) →<br />

case tes <strong>of</strong><br />

FiniteSetTypeExpr(fse) → Known(fse),<br />

InfiniteSetTypeExpr(ise) → Known(ise)<br />

end,<br />

→ Unknown<br />

end,<br />

→ Unknown<br />

end,<br />

getListType : ExpType → ExpType<br />

getListType(et) ≡<br />

case et <strong>of</strong><br />

Known(te) →<br />

case te <strong>of</strong><br />

TypeExprList(tes) →<br />

case tes <strong>of</strong><br />

FiniteListTypeExpr(fse) → Known(fse),<br />

InfiniteListTypeExpr(ise) → Known(ise)<br />

413

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

Saved successfully!

Ooh no, something went wrong!