Saved in:
Bibliographic Details
Main Authors: Akhond, Mostafijur Rahman, Chakraborty, Saikat, Uddin, Gias
Format: Preprint
Published: 2025
Subjects:
Online Access:https://arxiv.org/abs/2511.06552
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866911257206980608
author Akhond, Mostafijur Rahman
Chakraborty, Saikat
Uddin, Gias
author_facet Akhond, Mostafijur Rahman
Chakraborty, Saikat
Uddin, Gias
contents A loop invariant is a property of a loop that remains true before and after each execution of the loop. The identification of loop invariants is a critical step to support automated program safety assessment. Recent advancements in Large Language Models (LLMs) have demonstrated potential in diverse software engineering (SE) and formal verification tasks. However, we are not aware of the performance of LLMs to infer loop invariants. We report an empirical study of both open-source and closed-source LLMs of varying sizes to assess their proficiency in inferring inductive loop invariants for programs and in fixing incorrect invariants. Our findings reveal that while LLMs exhibit some utility in inferring and repairing loop invariants, their performance is substantially enhanced when supplemented with auxiliary information such as domain knowledge and illustrative examples. LLMs achieve a maximum success rate of 78\% in generating, but are limited to 16\% in repairing the invariant.
format Preprint
id arxiv_https___arxiv_org_abs_2511_06552
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle LLM For Loop Invariant Generation and Fixing: How Far Are We?
Akhond, Mostafijur Rahman
Chakraborty, Saikat
Uddin, Gias
Software Engineering
Artificial Intelligence
A loop invariant is a property of a loop that remains true before and after each execution of the loop. The identification of loop invariants is a critical step to support automated program safety assessment. Recent advancements in Large Language Models (LLMs) have demonstrated potential in diverse software engineering (SE) and formal verification tasks. However, we are not aware of the performance of LLMs to infer loop invariants. We report an empirical study of both open-source and closed-source LLMs of varying sizes to assess their proficiency in inferring inductive loop invariants for programs and in fixing incorrect invariants. Our findings reveal that while LLMs exhibit some utility in inferring and repairing loop invariants, their performance is substantially enhanced when supplemented with auxiliary information such as domain knowledge and illustrative examples. LLMs achieve a maximum success rate of 78\% in generating, but are limited to 16\% in repairing the invariant.
title LLM For Loop Invariant Generation and Fixing: How Far Are We?
topic Software Engineering
Artificial Intelligence
url https://arxiv.org/abs/2511.06552