Coding Rule Compliance Checking for IEC 61131-3 Structured Text via Executable Checking Logic Generation
CheckerGen is an LLM-based approach that automatically translates natural-language coding rules into executable OCaml implementations for IEC-Checker.
This project includes materials related to the CheckerGen framework.
baselines: Contains baseline implementations that CheckerGen compares against.checkergen: Contains the source code of the CheckerGen framework.benchmark: Contains the benchmark dataset used by CheckerGen, as well as some scripts used in building the dataset.common: Contains global configurations for the entire project.exps_res: Contains experimental results for the three research questions in the paper.iec-checkers: Contains different versions of iec-checkers.scripts: Includes useful scripts including evaluation scripts.test_cases: A collection of test cases needed by the Tester component of the CheckerGen framework.
Before running CheckerGen, you need to prepare and configure the CheckerGen runtime environment. In this section, we recommend using Docker to configure the corresponding OCaml environment.
To allow CheckerGen's debugger to run smoothly, you need to prepare the OCaml checker compilation feedback service for iec-checker.
# Initialize the iec-checker submodule:
git submodule update --init --recursive
pushd iec-checkers/serve/iec-checker >/dev/null;
# Build container image: This operation will build a container image for compiling iec-checker and providing compilation services.
docker build -t iec:4.08 .
rm -rf src/lib/plcopen_*
sed -i '26,$d' src/lib/checkerLib.ml
# Create, start container and map OCaml compilation service to the host machine's designated port:
docker create -it \
-v "$(pwd)":/home/opam/src \
-u opam \
-p 8000:8000 \
--name iec-serve \
iec:4.08
docker start iec-serve
popd >/dev/null;To successfully inject framework context, you also need to create symbolic links for the relevant directories of iec-checker so that CheckerGen can load the corresponding context:
mkdir -p $(pwd)/checkergen/shot
ln -s $(pwd)/iec-checkers/gt/iec-checker/src/core $(pwd)/checkergen/shot/core Finally configure the Python runtime environment:
python3 -m venv ./venv
source ./venv/bin/activate
pip install -r requirements.txtFor the evaluation to proceed smoothly, you need to compile the following three versions of the iec-checker executables:
- Ground Truth (GT) Version: Version with expert-improved detectors.
- Original Version: The original version from the Github open-source repository.
- Test Version: The version whose detectors need to be evaluated.
Below is an example of compiling the GT version of iec-checker to illustrate the compilation process. The compilation process for other versions is similar.
pushd iec-checkers/gt/iec-checker >/dev/null;
# Compile the Ground Truth version of iec-checker: This operation will generate
# the iec-checker executable in the `iec-checkers/gt/iec-checker` directory,
# and can be invoked via `iec-checkers/gt/iec-checker/bin/iec_checker`.
bash build.sh
popd >/dev/null;Before running, please configure the parameters in common/config.py to meet the CheckerGen runtime requirements.
Run the following command to view the specific configurable parameters and concrete running examples:
python3 main.py --help2026 CheckerGen Team, SKLCCSE, Beihang University.