[Paper Review] WhylSon: Proving your Michelson Smart Contracts in Why3
WhylSon is a tool that translates Michelson smart contracts into WhyML for formal verification using the Why3 framework, enabling automated proof generation via integrated theorem provers. It provides a shallow embedding of Michelson's semantics, allowing developers to verify correctness of Tezos smart contracts with high automation and integration into existing formal verification pipelines.
This paper introduces WhylSon, a deductive verification tool for smart contracts written in Michelson, which is the low-level language of the Tezos blockchain. WhylSon accepts a formally specified Michelson contract and automatically translates it to an equivalent program written in WhyML, the programming and specification language of the Why3 framework. Smart contract instructions are mapped into a corresponding WhyML shallow-embedding of the their axiomatic semantics, which we also developed in the context of this work. One major advantage of this approach is that it allows an out-of-the-box integration with the Why3 framework, namely its VCGen and the backend support for several automated theorem provers. We also discuss the use of WhylSon to automatically prove the correctness of diverse annotated smart contracts.
Motivation & Objective
- To address the critical need for formal verification of Tezos smart contracts due to their immutability and increasing use in financial logic.
- To automate the verification process of Michelson smart contracts, minimizing manual proof effort.
- To provide a seamless integration with the Why3 framework for leveraging existing automated and interactive theorem proving tools.
- To enable verification at the actual execution level (Michelson) rather than higher-level abstractions, ensuring accuracy and trust in the verified code.
- To support future verification pipelines for higher-level languages like LIGO or SmartPy by using Michelson as a verified backend.
Proposed method
- The tool parses Michelson contracts and translates them into equivalent WhyML code using a shallow embedding of Michelson's axiomatic semantics.
- A custom axiomatic semantics for Michelson is defined in Why3, mapping each instruction to its corresponding formal behavior.
- Primitive types from Michelson (e.g., nat, int, bytes, bool, option) are mapped to corresponding Why3 types, with custom invariants (e.g., for nat) to ensure correctness.
- Comparison functions (e.g., compare_bool) are manually implemented in Why3 to conform to Michelson’s specification, returning -1, 0, or 1.
- The Why3 verification condition generator (VCGen) automatically produces proof obligations, which are discharged by external automated theorem provers like Z3 or CVC4.
- The tool is implemented as a Why3 plugin using the OCaml-based Why3 API, enabling integration into formal verification workflows.
Experimental results
Research questions
- RQ1Can Michelson smart contracts be automatically translated into WhyML while preserving their semantics for formal verification?
- RQ2To what extent can automated theorem provers discharge proof obligations generated from Michelson contracts using Why3?
- RQ3How effective is the shallow embedding approach in maintaining expressiveness and verifiability of Michelson's stack-based semantics in WhyML?
- RQ4What are the practical challenges in scaling automated verification to complex Michelson contracts, and how can they be mitigated?
- RQ5Can WhylSon serve as a backend verification layer for higher-level smart contract languages like LIGO or SmartPy?
Key findings
- WhylSon successfully translates Michelson contracts into WhyML, enabling formal verification using Why3’s automated theorem provers.
- The tool achieves a high degree of automation, with proof obligations generated via Why3’s VCGen and discharged by external provers like Z3 and CVC4.
- Despite automation, some proof trees became large and required user intervention, indicating limitations in the current type encoding strategy.
- The use of tree-like data structures for Michelson types contributed to complex proof obligations, suggesting a need for optimized encoding strategies.
- The integration with Why3 was straightforward due to its well-documented OCaml API, enabling rapid plugin development.
- The approach supports future integration with certified compilers and higher-level languages, such as Archetype or LIGO, by serving as a verified backend for compilation.
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.