The concept of class invariant in object-oriented programming

09/14/2021
by   Bertrand Meyer, et al.
0

Class invariants – consistency constraints preserved by every operation on objects of a given type – are fundamental to building and understanding object-oriented programs. They should also be a key help in verifying them, but turn out instead to raise major verification challenges which have prompted a significant literature with, until now, no widely accepted solution. The present work introduces a general proof rule meant to address invariant-related issues and allow verification tools benefit from invariants. It first clarifies the notion of invariant and identify the three problems: callbacks, furtive access and reference leak. As an example, the 2016 Ethereum DAO bug, in which $50 million were stolen, resulted from a callback invalidating an invariant. The discussion starts with a "Simple Model" and an associated proof rule, demonstrating its soundness. It then removes one by one the three assumptions of the Simple Model, each removal bringing up one of the three issues, and introduces the corresponding adaptation to the proof rule. The final version of the rule can tackle tricky examples, including "challenge problems" listed in the literature.

READ FULL TEXT
research
06/27/2019

Invariant Detection with Program Verification Tools

Compilers can specialize programs having invariants for performance impr...
research
07/09/2019

Relational Verification via Invariant-Guided Synchronization

Relational properties describe relationships that hold over multiple exe...
research
01/09/2021

Differential Invariants

Validation is a major challenge in differentiable programming. The state...
research
06/06/2019

Dynamically Allocated Memory Verification in Object-Oriented Programs using Prolog

A Prolog-based framework for fully automated verification currently unde...
research
02/26/2019

Sound Invariant Checking Using Type Modifiers and Object Capabilities

In this paper we use pre existing language support for type modifiers an...
research
09/19/2023

Modular Analysis of Distributed Hybrid Systems using Post-Regions (Full Version)

We introduce a new approach to analyze distributed hybrid systems by a g...
research
03/07/2019

Invariant Safety for Distributed Applications

We study a proof methodology for verifying the safety of data invariants...

Please sign up or login with your details

Forgot password? Click here to reset