jasonthewhale / Dafny_Verify

Repository from Github https://github.comjasonthewhale/Dafny_VerifyRepository from Github https://github.comjasonthewhale/Dafny_Verify

Automated AI Loop Invariant Discovery

Introduction

Welcome to the repository for our AI Loop Invariant Discovery project. This project is a study to prove the concept of automating the process of writing loop invariants by leveraging the power of artificial intelligence.

In this study, we have developed an automated tool that uses a unique approach called Chain Of Thoughts (COT) to extract loop invariants from a Dafny programming model. We have trained the AI model with a dataset composed of 50 Dafny loop invariant examples which are available in the ./Fine_Tune_Examples/50_exampls directory in this repository.

Core files

  • ./Fine_Tune_Examples/50_exampls: This directory contains the dataset of 50 Dafny loop invariant examples that we used to train the AI model.

  • ./AI_agent/loop.py: This is the main Python script that implements the Chain Of Thoughts (COT) mechanism for the automated tool to discover loop invariants from the Dafny programming model.

  • ./Generated_Code: This directory contains the code generated by our AI model.

  • ./dataset/combined_dataset.json: This directory contains the full dataset that fed to the model when fine tuning.

Setup and Usage

To use this tool, you'll need Python installed on your machine. Follow the below steps to setup and run the tool.

  1. Clone the repository

    Use the following command to clone this repository:

    git clone https://github.com/yourusername/Dafny_Verify.git
    
  2. Navigate to the repository

    Use the following command to navigate to the cloned repository:

    cd Dafny_Verify
    
  3. Install the required Python libraries

    We have a requirements.txt file, which lists all Python libraries that this tool depends on. Navigate to the ./AI_agent directory and run the following command to install these dependencies:

    cd AI_agent
    pip install -r requirements.txt
    
  4. Run the script

    Execute the Python script loop.py located in ./AI_agent directory:

    python loop.py
    

About


Languages

Language:Dafny 96.9%Language:Python 3.1%