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 IdBinding(id) → [ b ↦→ et ], Make_ProductBinding(pb) → makeTYPESBindingList( binding_list(pb), expTypeToExpTypeList( removeBrackets(et), len binding_list(pb)), trans) end, /∗Makes the appropriate TYPES binding from a binding list.∗/ /∗ Arguments: ======= b: the binding list etl: the corresponding expected types ∗/ makeTYPESBindingList : Binding ∗ × ExpType ∗ × TRANS → TYPES makeTYPESBindingList(bl, etl, trans) ≡ if bl = 〈〉 then ([ ]) else makeTYPESBinding(hd bl, hd etl, trans) † makeTYPESBindingList(tl bl, tl etl, trans) end, /∗Makes the appropriate TYPES binding from a binding list.∗/ /∗ Arguments: ======= b: the binding list te: the corresponding types ∗/ makeTYPESMap : Binding ∗ × TypeExpr → TYPES makeTYPESMap(bl, te) ≡ if bl = 〈〉 then [ ] else case hd bl of IdBinding(id) → [ hd bl ↦→ Known(te) ] † makeTYPESMap(tl bl, te), Make_ProductBinding(bil) → makeTYPESMap(binding_list(bil), te) † 296

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER end end, makeTYPESMap(tl bl, te) /∗Alters TYPES when a let def list is established. ∗/ /∗ Arguments: ======= ldl: the let def list ∗/ alterTYPESMap : TYPES × LetDef ∗ → TYPES alterTYPESMap(types, ldl) ≡ if ldl = 〈〉 then types else case binding(hd ldl) of MakeBinding(b) → case b of IdBinding(id) → alterTYPESMap( types † [ b ↦→ Unknown ], tl ldl), Make_ProductBinding(bl) → alterTYPESMap( alterTYPESMapList( types, binding_list(bl)), tl ldl) end end end, /∗Alters TYPES from a binding list.∗/ /∗ Arguments: ======= bl: the binding list ∗/ alterTYPESMapList : TYPES × Binding ∗ → TYPES alterTYPESMapList(types, bl) ≡ if bl = 〈〉 then types else case hd bl of IdBinding(id) → alterTYPESMapList( types † [ hd bl ↦→ Unknown ], tl bl), Make_ProductBinding(bil) → 297

APPENDIX C. FORMAL SPECIFICATIONS OF TRANSFORMATIONS<br />

IdBinding(id) → [ b ↦→ et ],<br />

Make_ProductBinding(pb) →<br />

makeTYPESBindingList(<br />

binding_list(pb),<br />

expTypeToExpTypeList(<br />

removeBrackets(et), len binding_list(pb)),<br />

trans)<br />

end,<br />

/∗Makes the appropriate TYPES binding from a binding<br />

list.∗/<br />

/∗<br />

Arguments:<br />

=======<br />

b: the binding list<br />

etl: the corresponding expected types<br />

∗/<br />

makeTYPESBindingList :<br />

Binding ∗ × ExpType ∗ × TRANS → TYPES<br />

makeTYPESBindingList(bl, etl, trans) ≡<br />

if bl = 〈〉 then ([ ])<br />

else<br />

makeTYPESBinding(hd bl, hd etl, trans) †<br />

makeTYPESBindingList(tl bl, tl etl, trans)<br />

end,<br />

/∗Makes the appropriate TYPES binding from a binding<br />

list.∗/<br />

/∗<br />

Arguments:<br />

=======<br />

b: the binding list<br />

te: the corresponding types<br />

∗/<br />

makeTYPESMap : Binding ∗ × TypeExpr → TYPES<br />

makeTYPESMap(bl, te) ≡<br />

if bl = 〈〉 then [ ]<br />

else<br />

case hd bl <strong>of</strong><br />

IdBinding(id) →<br />

[ hd bl ↦→ Known(te) ] †<br />

makeTYPESMap(tl bl, te),<br />

Make_ProductBinding(bil) →<br />

makeTYPESMap(binding_list(bil), te) †<br />

296

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

Saved successfully!

Ooh no, something went wrong!