Invariants for Non-Hierarchical Object Structures

Ronald Middelkoop, Cornelis Huizing, Ruurd Kuiper, Erik J. Luit
2008 Electronical Notes in Theoretical Computer Science  
We present a Hoare-style specification and verification approach for invariants in sequential OO programs. It allows invariants over non-hierarchical object structures, in which update patterns that span several objects and methods occur frequently. This gives rise to invalidating and subsequent re-establishing of invariants in a way that compromises standard data induction, which assumes invariants hold when a method is called. We provide specification constructs (inc and coop) that identify
more » ... jects and methods involved in such patterns, allowing a refined form of data induction. The approach now handles practical designs, as illustrated by a specification of the Observer Pattern. Open access under CC BY-NC-ND license. extend results from [9]: instead of the previously used fixed set of object references, predicates are introduced to describe a set of objects involved. We argue that the additional flexibility offered by inc is essential in the use of invariants over non-hierarchical object structures. Second, we introduce the coop construct that specifies which invariants might be invalidated when a field is assigned to. This enables verification of invariants even when their definition is not visible. In particular, this supports modular development. We extend previous results with predicates to describe the set of objects involved. Third, we remove a limitation on method calls in while and if statements. Finally, the consequences of these extensions are incorporated in a proof system. More invariants are admissible and more implementations can be verified than before. In fact, whereas the approach previously could only be used for somewhat tailor-made examples, the extensions enable to specify the inspiration for the approach: the Observer Pattern. Following this introduction, section 2 introduces invariants. Section 3 introduces the inc construct, section 4 introduces the coop construct and section 5 contains the formalization. Section 6 describes related and future work. Section 7 concludes the paper.
doi:10.1016/j.entcs.2007.08.034 fatcat:pi44nfbxubgbzen7aaoxhl6xca