[en] The steep learning curve of formal methods deters their adoption in introductory programming courses (CS1), even though such methods can be instrumental in teaching students rigorous programming practices. As part of our CS1 course, we use Graphical Loop Invariants (GLIs). These semi-formal diagrams describe relationships between data structures and variables. They substitute Formal Loop Invariants (FLIs), which are inaccessible to students without a strong mathematical background. However, this gain in accessibility comes at a cost: the semi-formal nature of GLIs complicates automated verification. To address this challenge, we present a proof-of-concept framework that translates GLI-annotated C code into Dafny, a verification-aware language. GLIs are translated into Dafny predicates by extracting three core components: (i) the traversed data structures, (ii) the zone delimiters, and (iii) the textual zone descriptions, including accumulator variables. The textual descriptions are matched to predicates based on semantic similarity, computed using a Sentence-BERT model. This matching achieves 92.5% accuracy on our test set. We validate the framework on ten representative CS1 problems, whose solutions are correctly verified by Dafny. We describe the pipeline for one of these examples: finding a maximum value in an array.
Disciplines :
Computer science
Author, co-author :
Brieven, Géraldine ; Université de Liège - ULiège > Montefiore Institute of Electrical Engineering and Computer Science
Grosjean, Antoine ; Université de Liège - ULiège > HEC - Ecole de gestion de l'ULiège > Master ing. gest., fin. spéc. sup. ch. man. & bus. ana.(FSA)
Fontaine, Pascal ; Université de Liège - ULiège > Montefiore Institute of Electrical Engineering and Computer Science
Donnet, Benoît ; Université de Liège - ULiège > Montefiore Institute of Electrical Engineering and Computer Science
Language :
English
Title :
Another Brick in the Loop: From Graphical Loop Invariant to Formal Proofs
Publication date :
November 2026
Event name :
International Conference on Software Engineering and Formal Methods
Event date :
23-27 novembre 2026
Audience :
International
Main work title :
Proc. International Conference on Software Engineering and Formal Methods