Download presentation
Presentation is loading. Please wait.
Published byMaryann Lester Modified over 9 years ago
1
SAVCBS 2006 p. 1 Specification of Iterators Bruce W. Weide Reusable Software Research Group The Ohio State University http://www.cse.ohio-state.edu/rsrg
2
SAVCBS 2006 p. 2 Important Assumptions Ultimate objective is full behavioral specification, with support for modular verification of client code Language has value semantics
3
SAVCBS 2006 p. 3 Claims Full behavioral specification achieved –Only previously existing, and ordinary, model-based specification techniques needed Design and specs easy to understand Implementation can be as efficient as for any other iterator design Modular verification of client code possible
4
SAVCBS 2006 p. 4 Client Code for Iteration Start_Iterator (i, s, p) loop /* loop invariant; see paper */ while Length_Of_Future (i) > 0 do Get_Next_Item (i, p) /* process p, with no net change */ end loop Finish_Iterator (i, s, p) a Set of Polygonsa Polygon an Iterator for a Set of Polygons
5
SAVCBS 2006 p. 5 Start_Iterator (i, s, p) sip past: future: original: past: future: original:
6
SAVCBS 2006 p. 6 Get_Next_Item (i, p) sip past: future: original: past: future: original:
7
SAVCBS 2006 p. 7 Get_Next_Item (i, p) sip past: future: original: past: future: original:
8
SAVCBS 2006 p. 8 Get_Next_Item (i, p) sip past: future: original: past: future: original:
9
SAVCBS 2006 p. 9 Get_Next_Item (i, p) sip past: future: original: past: future: original:
10
SAVCBS 2006 p. 10 Finish_Iterator (i, s, p) sip past: future: original: past: future: original:
11
SAVCBS 2006 p. 11 Specification of Iterators Bruce W. Weide Reusable Software Research Group The Ohio State University http://www.cse.ohio-state.edu/rsrg
12
SAVCBS 2006 p. 12 Client Code: Differences Start_Iterator (i, s, x) loop /* loop invariant; see paper */ while Length_Of_Future (i) > 0 do Get_Next_Item (i, x) /* process x, with no net change; modify s if you like! */ end loop Finish_Iterator (i, s, x)
13
SAVCBS 2006 p. 13 Specification Details type family Set_Iterator is modeled by ( past: string of Item, future: string of Item, original: finite set of Item ) exemplar i initialization ensures i = (, <>, { })
14
SAVCBS 2006 p. 14 Specification Details operation Start_Iterator (i: Set_Iterator, s: Set, x: Item) ensures there exists f: string of Item (elements (f) = #s and |f| = |#s| and i = (, f, #s)) and s = { } and x = #x
15
SAVCBS 2006 p. 15 Specification Details operation Finish_Iterator ( i: Set_Iterator, s: Set, x: Item) requires is suffix of i.past ensures is_initial (i) and s = #i.original and is prefix of #i.past
16
SAVCBS 2006 p. 16 Specification Details operation Get_Next_Item (i: Set_Iterator, x: Item) requires i.future /= and is suffix of i.past ensures there exists f: string of Item (#i.future = * f and i = (#i.past *, f, #i.original))
17
SAVCBS 2006 p. 17 Specification Details operation Length_Of_Future ( i: Set_Iterator): Integer ensures Length_Of_Future = |i.future|
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.