[Paper Review] Formal verification in Coq of program properties involving the global state effect
This paper presents a Coq-based framework for formally verifying program properties involving the global state effect in imperative programs, using a decorated proof system that separates state effects from syntax. By encoding state effects via term decorations and leveraging categorical semantics, the framework enables mechanized verification of properties such as commutativity of lookup and update operations, with full proofs integrated into a reusable Coq library for effectful program reasoning.
The syntax of an imperative language does not mention explicitly the state, while its denotational semantics has to mention it. In this paper we present a framework for the verification in Coq of properties of programs manipulating the global state effect. These properties are expressed in a proof system which is close to the syntax, as in effect systems, in the sense that the state does not appear explicitly in the type of expressions which manipulate it. Rather, the state appears via decorations added to terms and to equations. In this system, proofs of programs thus present two aspects: properties can be verified {\em up to effects} or the effects can be taken into account. The design of our Coq library consequently reflects these two aspects: our framework is centered around the construction of two inductive and dependent types, one for terms up to effects and one for the manipulation of decorations.
Motivation & Objective
- To address the challenge of formally verifying properties of imperative programs that manipulate global state, where state is not explicitly represented in syntax but affects semantics.
- To develop a Coq-verified framework that supports equational reasoning about programs with side effects, particularly the global state effect.
- To enable verification of program properties without exposing the internal state representation, by using decorations to track effects.
- To mechanize and integrate known proofs of state effect properties (e.g., lookup/update commutativity) into a reusable Coq library for effectful program reasoning.
Proposed method
- The framework uses a decorated proof system inspired by effect systems, where state effects are tracked via annotations on terms and equations rather than in types.
- It models the global state effect using categorical constructions, particularly strong monads and premonoidal categories, to formalize the semantics of stateful operations.
- The system defines two inductive, dependent types in Coq: one for terms up to effects (ignoring state) and another for handling decorations that track state effects.
- Key rules such as weak and strong equality, permutation, and projection are encoded in Coq to support step-by-step equational reasoning.
- The framework supports a two-phase verification process: first checking that operations have the same effect (via effect decoration), then verifying that they return the same results (via weak equality).
- The Coq library integrates these rules and enables full mechanization of proofs, as demonstrated on the commutativity of lookup and update operations.
Experimental results
Research questions
- RQ1How can program properties involving the global state effect be formally verified in a way that abstracts from the internal state representation?
- RQ2Can a decorated equational proof system for state effects be fully mechanized in Coq while preserving mathematical rigor?
- RQ3How can the separation of concerns between effect and result be formalized and verified in a proof assistant like Coq?
- RQ4To what extent does the framework support modular and reusable verification of complex stateful program properties?
- RQ5Can the framework detect flaws in complex proofs, such as those involving Hilbert-Post completeness of the state effect?
Key findings
- The framework successfully mechanizes the verification of the commutativity of lookup and update operations, proving that retrieving a variable's value and updating another can be performed in any order.
- The proof of lookup j ∘ update i ∼ pi2 ∘ (perm prod (update i) id) ∘ (prod id (lookup j)) ∘ inv pi1 is fully verified in Coq, demonstrating the framework’s capability for complex equational reasoning.
- The Coq library, available at http://coqeffects.forge.imag.fr, supports over 16 pages of formalized proof for the Hilbert-Post completeness of the global state effect.
- The framework helped uncover a non-obvious flaw in an initial version of the Hilbert-Post completeness proof, validating its utility in detecting subtle errors.
- The approach enables modular verification: effects are checked first via decorations, then results are compared, allowing scalable and structured reasoning.
- The framework is extensible and has been successfully used to verify foundational properties of the state effect, with potential for extension to exceptions and other effects.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.