Loop invariant generation method and device based on large language model

By generating and verifying loop invariants using a large language model, the problem of generating complex loop invariants in existing technologies is solved, achieving efficient and automated loop invariant generation and improving the quality of program analysis and verification.

CN122240443APending Publication Date: 2026-06-19PEKING UNIV +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
PEKING UNIV
Filing Date
2026-01-22
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

Existing methods for generating loop invariants struggle to handle complex or non-standard loop structures, and learning-based methods rely on large amounts of high-quality labeled data, resulting in insufficient generalization ability and interpretability.

Method used

A method based on a large language model is adopted to generate candidate loop invariants. The correctness verification and logical validity check are performed, and the feedback mechanism adjusts the generation strategy to ensure the correctness of the loop invariants.

Benefits of technology

It enables the efficient and automated generation of high-quality loop invariants, improving the efficiency and accuracy of program analysis and verification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122240443A_ABST
    Figure CN122240443A_ABST
Patent Text Reader

Abstract

This specification provides a method and apparatus for generating loop invariants based on a large language model. The method includes: inputting the program code of the target program and its properties to be verified into a large loop invariant generation model; generating at least one candidate loop invariant based on the program code and program properties; verifying the correctness of the at least one candidate loop invariant; determining the successfully verified candidate loop invariant as the loop invariant corresponding to the target program; triggering the large loop invariant generation model to generate a reasoning process description corresponding to the candidate loop invariant that failed verification; performing a logical validity check on the reasoning step description in the reasoning process description; obtaining the reasoning step error information determined based on the reasoning step description that failed the check and inputting it into the large loop invariant generation model; and regenerating at least one candidate loop invariant based on the reasoning step error information.
Need to check novelty before this filing date? Find Prior Art