Iteratively Composing Statically Verified Traits

by   Isaac Oscar Gariano, et al.

Metaprogramming is often used to programmatically generate faster specialised code when some parameters are known in advance. To use metaprogramming and SV together, we could generate code containing contracts, and such code could be checked after metaprogramming has been completed. SV could then be applied to the code resulting from the metaprogramming to ensure it is correct. However this could be very time consuming, since it would require verifying all the generated code from scratch. Even worse, since SV is unpredictable, there would be no guarantee that the result of a given metaprogram will be verifiable, even if its result is correct by construction. We extend the disciplined form of metaprogramming of Servetto & Zucca, which is based on trait composition and adaptation. Here a Trait is a unit of code: a set of method declarations with pre/post-conditions. They are well-typed and correct. Traits directly written in the source code are proven correct by SV. The composition and adaptation of Traits is carefully defined to preserve correctness. Metaprogramming cannot generate code directly, code is only generated by composing and adapting traits, thus generated code is also correct. However generated code may not be able to pass SV, since theorem provers are not complete.


page 1

page 2

page 3

page 4


Traits for Correct-by-Construction Programming

We demonstrate that traits are a natural way to support correctness-by-c...

Correct by construction

Matrix code allows one to discover algorithms and to render them in code...

Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generation

Program synthesis has been long studied with recent approaches focused o...

From RTL to SVA: LLM-assisted generation of Formal Verification Testbenches

Formal property verification (FPV) has existed for decades and has been ...

Separating Use and Reuse to Improve Both

Context: Trait composition has inspired new research in the area of code...

Are My Invariants Valid? A Learning Approach

Ensuring that a program operates correctly is a difficult task in large,...

ALGO: Synthesizing Algorithmic Programs with Generated Oracle Verifiers

Large language models (LLMs) excel at implementing code from functionali...

Please sign up or login with your details

Forgot password? Click here to reset