Developer tools · Research feature

SEDCoT: Enhancing LLM-Based COBOL Code Translation via Symbolic Execution and Delta Debugging

A new AI framework uses symbolic execution and test refinement to produce more accurate and readable COBOL-to-C translations than existing methods.

Adapted from research by Phillip Entin, Wenchao Gu, Alexander Knapp and colleagues.

arXiv preprint revision · 2026-09-01 · Attribution & reuse
In this article
Editorial illustration of two code revisions.

Editor’s introduction

The study evaluates SEDCoT, a framework that translates COBOL to C by combining large language models with symbolic execution and delta debugging. It outperforms state-of-the-art baselines by at least 12% in translation correctness and produces more readable outputs than traditional rule-based transcompilers. The evaluation uses 319 function-level COBOL programs from IBM’s CodeNet, which represent only a limited slice of real-world production code. The framework generates a diverse test suite through five mutation strategies, achieving 88.42% statement and 52.97% branch coverage. A key limitation is that the approach operates at the function level and does not address complex file interactions across repositories.

Introduction

Among legacy technologies, COBOL stands out as particularly entrenched and challenging. Originally developed in the 1960s for business applications, COBOL remains widely used today; estimates suggest that more than 220 billion lines of COBOL code are still operational. These programs are deeply embedded in financial systems, mainframes, and government platforms.

COBOL’s verbose, data-centric syntax and reliance on legacy constructs make it increasingly incompatible with contemporary development practices. Translating COBOL into mainstream programming languages therefore requires more than a purely syntactic mapping. COBOL programs commonly employ hierarchical data definitions, atypical control-flow constructs, and tight coupling between data layout and program logic; these characteristics create a substantial semantic gap between COBOL and mainstream programming languages.

Rule-based tools such as the GnuCOBOL compiler can emit code in mainstream programming languages from COBOL source. However, because of the significant grammatical and idiomatic differences between COBOL and contemporary languages, the generated code is often difficult for human developers to read and maintain, and typically requires extensive manual refactoring before it is suitable for long-term maintenance. Correctness would indeed be paramount if the translation were like a compilation—“compile, run, and forget.” But readability will outweigh “simple” correctness if the translated code has to be worked with in any respect, in particular, if it will have to be maintained as is the usual case in replacing legacy software.

Symbolic Execution

Symbolic execution utilizes constraint solvers to derive inputs that explore distinct program paths. UTBot industrializes this, employing a hybrid concolic engine combining an enhanced KLEE Symbolic Virtual Machine with smart fuzzing to maximize code coverage while mitigating path explosion. Notably, UTBot synthesizes raw KLEE-derived inputs into readable, structured regression test suites based on the Google Test framework, featuring automated method variable generation, assertions, and mock stubs.

Delta Debugging

When a program exhibits erroneous behavior on a particular input, the input often contains superfluous elements that are not necessary to trigger the fault. Delta debugging, first introduced by Zeller, is a widely used technique to automatically minimize such failure-inducing inputs. The core idea is to iteratively partition the input and test whether individual subsets are still capable of reproducing the failure. By systematically discarding irrelevant components, delta debugging converges toward a minimal configuration that preserves the fault-inducing property.

COBOL Translation

Open-source solutions like GnuCOBOL enable the compilation and execution of COBOL today by translating COBOL code into an intermediate C representation. GnuCOBOL successfully passes 9700 out of 9748 tests in the NIST COBOL 85 test suite, a benchmark verifying compliance with the COBOL 85 standard. While this high coverage demonstrates that GnuCOBOL preserves the semantic correctness of the original programs, its rule-based translation mechanism yields C code that is often difficult for humans to read or maintain.

For example, a simple COBOL program checking for consecutive doublets is translated into 283 lines of C code, supplemented by two headers of 26 and 59 lines, whereas a human-written C solution requires only about 20 lines. Consequently, we adopt GnuCOBOL as our primary rule-based baseline to compare its readability against the code produced by SEDCoT.

Overview

In the initial translation phase, an LLM translates COBOL into the target language to produce candidate code. During test case generation, we construct verification inputs comprising two types: rule-based test cases generated via rule-guided COBOL translation combined with symbolic execution for high code coverage, and LLM-generated test cases. Finally, in the code repair phase, these test cases are executed on the initial translation, and execution feedback is routed to the LLM for iterative error correction. If repeated repair attempts fail, delta debugging simplifies the failing test cases to reduce failure analysis difficulty. This simplified information is then fed back to the LLM to guide subsequent repair and yield the finalized target-language code.

Translation via GunCOBOL & Generation via Symbolic Execution

To the best of our knowledge, no open-source symbolic execution engine currently supports direct test case generation for COBOL. To leverage the proven effectiveness of symbolic execution–based test cases, we adopt the following workaround: the rule-based compiler translates COBOL programs into functionally equivalent intermediate code with target promgramming language. This enables the use of existing symbolic execution engines to generate test cases that capture the behavioral aspects of the original COBOL program.

Delta Debugging

When a candidate translation continues to fail certain test cases after the compilation and repair stages, naively re-prompting the LLM often yields diminishing returns, as the remaining failures involve errors that are difficult for the model to identify or reason about. Building on the observation of Yang et al. that iterative repairs tend to saturate quickly, we adopt delta debugging to isolate the root causes of these residual errors and provide them to the LLM as explicit repair guidelines.

By providing only the unique, minimal failing inputs, this delta-debugging reduction step supplies the LLM with precise, high-level guidance, rather than a large number of opaque examples. Consequently, we achieve better repair outcomes in the final stage without extra LLM calls. Delta debugging helps LLMs precisely identify errors and finish fixes efficiently, avoiding repeated model invocations for iterative reasoning and trial repairs.

When the input “abc” is given, the program crashes. Since the input “ab” also triggers a crash, delta debugging reduces the original input to “ab” as the minimal failure-inducing input. As a result, the bug in the branch corresponding to “abc” becomes unobservable.

Dataset

We attempted to validate our method against other mainstream languages. However, our framework requires reliable baseline transcompilers to support subsequent test generation and behavior comparison. Currently, robust open-source translation tools for other target languages remain unavailable: for instance, translating COBOL to Java via an open-source tool yielded only 11 successful translations, an insufficient sample size for meaningful statistical evaluation. Consequently, we limit our target language to C for all experiments in this study.

Evaluation

Because the dataset’s original test cases are overly simplistic, we adopt a differential testing paradigm using a held-out golden test suite. We set the generated input volume to 500 per program to balance computational overhead and anomaly detection. Mutating from each benchmark’s original input, we generate these 500 test cases evenly across five strategies (100 samples each): type-preserving shuffling, mixed-type shuffling, whitespace perturbation, variable-length truncation with non-printable characters, and variable-length truncation with mixed character replacement. This test suite achieves 88.42% statement coverage and 52.97% branch coverage. Crucially, no translated program passes the entire suite, demonstrating its comprehensiveness in uncovering behavioral discrepancies.

Since native COBOL code cannot be directly executed on modern hardware, we leverage GnuCOBOL to compile and run the original COBOL programs, and take its execution behavior as the ground-truth oracle. We then compare the runtime outputs of LLM-translated programs against this GnuCOBOL-based reference to rigorously examine the behavioral equivalence and robustness of translation results. In our differential testing pipeline, GnuCOBOL therefore acts as the authoritative execution standard. Finally, we quantify the performance of all methods by computing the average test case pass ratio over the 500 perturbed inputs per program.

Baselines and LLMs evaluated

We evaluate SEDCoT on four representative large language models that vary in architecture, parameter scale, and context-window size. This selection enables a systematic assessment of SEDCoT’s performance across different generative systems. All LLMs were deployed and executed on cloud platforms. Specifically, GPT-4o-mini ran on OpenAI’s service infrastructure, and other models were accessed via diverse providers supported by OpenRouter.

Implementation Details

In our experiments, the temperature of all LLMs was set to zero to eliminate sampling variance. To mitigate the high time complexity of symbolic execution, we imposed maximum allowances for each COBOL program. Specifically, KLEE was configured to explore up to 80 million expressions, restricted to an overall time limit of 20 minutes, 2 minutes per state, and 5 minutes for coverage measurement. Test generation via KLEE was conducted on an Intel i5-11300H laptop (16GB RAM) over 12 hours, successfully producing test suites for 292 programs with an average runtime of 2.5 minutes. All prompts used in our method are provided in the replication package’s Appendix.

For experimental consistency, we strictly follow the original settings of each baseline: HRJR adopts the native test cases from CodeNet for program repair; UniTrans leverages LLM-generated test cases to conduct repair as originally designed. In terms of our proposed SEDCoT, we employ both LLM-generated and symbolic execution-derived test cases for program repair in RQ1. By contrast, selective combinations of these two types of test cases are adopted in RQ2 and RQ4 to satisfy the requirements of ablation studies.

In general, a large number of repair retries may lead to diminishing performance. For example, Gandhi et al. limit the maximum number of repair iterations to three in their COBOL translation approach. To ensure consistency with prior work and enable a fair performance comparison, we similarly set the total number of repair attempts per test suite to three. Concretely, in the first code repair stage (Step 5 of Phase 3), LLMs were allowed up to two retries. In the second code repair stage (Step 7), the maximum number of retries was set to one; however, in the event of compilation failures, we allowed up to two additional attempts solely to address compilation errors.

RQ1: How effective is SEDCoT in translating COBOL programs compared with SOTA baseline methods?

Interestingly, using LLMs to refactor GnuCOBOL-translated code (denoted as LLM Refactor) yields significantly lower accuracy than direct LLM translation. This occurs because rule-based translated code differs substantially from human-written programs in structure and readability. Lacking conventional coding styles and logical clarity, such translated code is not only opaque to human developers but also prevents LLMs from performing effective refactoring.

RQ3: Can symbolic execution test cases reveal more latent bugs than LLM test cases?

At first glance, this observation seems contradictory. However, the key lies in the limitations of traditional coverage metrics such as line and branch coverage. These metrics are inherently syntactic: they only measure whether certain statements or branches have been executed, without capturing how test inputs interact with program semantics or whether they are capable of exposing faulty behavior. Symbolic execution, in contrast, tends to generate inputs that exercise edge cases—for example, non-printable characters, malformed data, or extreme boundary values. Such inputs are more likely to trigger faults that remain undetected under typical, syntactically valid but semantically ordinary test cases produced by LLMs.

From a coverage perspective, both the LLM- and symbolic execution-generated test suites may reach the same statements, giving the impression of equivalent coverage. Yet, only the symbolic execution inputs expose the underlying vulnerability, thereby revealing latent bugs that LLM-generated test cases may fail to detect.

RQ4: How does the number of repair attempts affect the performance of SEDCoT?

Listing 4 illustrates this by isolating a subtle input-related bug. The faulty translation uses scanf(“%s”,…) to buffer input, followed by sscanf(…) to parse two integers. Because scanf(“%s”) terminates at the first whitespace, the buffer captures only a single token, causing sscanf to leave the second variable (y) uninitialized. While this defect remains masked under seemingly valid inputs like “10 2” due to residual memory contents, delta debugging systematically minimizes the failure-inducing input to “1”. This failure forces a silent parsing error for y, localizing the root cause to improper input handling rather than downstream logic. The robust version resolves this by utilizing fgets to capture full lines, initializing all variables, and explicitly verifying the parsed count.

Thus, delta debugging not only isolates faulty behaviors but also clarifies the nature of the failure, guiding LLMs toward structurally correct repairs. It complements test cases by converting them into minimal examples that sharpen fault localization and expose hidden assumptions in the code, revealing latent bugs that LLM-generated cases might miss.

RQ5: How readable is the code generated by SEDCoT compared to rule-based approaches?

To evaluate readability, we conduct both human and automated experiments. For the human evaluation, we select 10 test cases where the code translated by all LLMs achieves a passing rate exceeding 97%. Twelve computer science students (2 undergraduates, 5 Master’s, 5 PhDs) rate the readability of the translated and ground-truth C programs on a 5-point Likert scale (1: extremely poor, 5: excellent), following established guidelines. For the automated evaluation, we employ Grok Fast 1 with the same prompt guidelines to assess code readability. The complete evaluation guidelines are available in our replication package’s appendix.

Failed translation case of COBOL code with fixed-width record layout

Listing 5 shows the COBOL code with a fixed-width record layout, and Listing 6 presents the corresponding translated C code. In this example, the COBOL code defines grouped input records with FILLER fields that encode fixed separator positions within the record layout. The ACCEPT INP1 statement reads data directly into this grouped structure. However, LLMs employ a simple char array of length three and read input via whitespace-separated scanning, which also differs from COBOL’s positional layout.

Automated Code Translation

Research on code migration has progressed from manual rewriting and rule-based transcompilers to modern machine learning. Early methods leveraged foreign function interfaces like SWIG or source-to-source transpilers like Emscripten. Subsequent approaches applied statistical machine translation, repository mining, and unsupervised Transformer models like TransCoder. Recently, Pan et al. introduced iterative repair via compiler and test feedback, which UniTrans generalized across languages using LLM-generated tests. For COBOL translation, Gandhi et al. proposed a three-phase refinement strategy. Other advancements explore reinforcement learning, repository-level scaling, agentic workflows, and semantic reasoning. Unlike these code-level methods, alternative domain-level approaches generate functional descriptions or leverage intermediate representations to guide the translation, whereas SEDCoT operates directly at the code level.

Using LLMs for Legacy Code

Legacy programming languages introduce unique challenges due to archaic syntax and hidden semantics. Diggs et al. used LLMs to generate comments for MUMPS and ALC, while Ranasinghe et al. and Chen et al. achieved promising results in FORTRAN-to-C++ translation via fine-tuning. To manage complexity, Luo et al. and Macedo et al. proposed intermediate representation pipelines, whereas Lei et al. used agentic methods for documentation. Additional studies focus on domain-specific rewrites with functional equivalence proofs and architectural modernization to ensure correctness at system scale. Such migration necessitates automated testing; search-based software testing (SBST) tools like Pynguin implement MOSA and DynaMOSA strategies. Hybrid approaches combine SBST with LLMs, including CodaMOSA and TELPA for LLM-guided evolutionary testing, MuTAP for mutation testing, and CoverUp for iterative unit test generation. Furthermore, symbolic execution tools like KLEE and SymCC systematically explore execution paths to uncover corner cases, with platforms like UTBot easing industrial application, extending to more languages via fuzzing, or mitigating path explosion via machine learning. Iterative LLM-based repair pipelines have also proven effective in resolving recurring error patterns.

Building on these approaches, we combine symbolic execution with LLM-generated tests within a repair loop, apply delta debugging to minimize failing cases into counterexamples, and embed COBOL semantics in prompts for both functional correctness and readability. While readability is challenging to measure automatically due to metric limitations, empirical guidelines like reduced nesting correlate with human perception and guide our evaluation. Additionally, SEDCoT’s outputs are evaluated using LLMs for broader quality assessment, aligning with existing COBOL translation workflows and general code evaluation practices.

Baselines and configurations

For reproducibility, we re-implemented UniTrans and HRJR using consistent prompts and deterministic decoding. However, alternative prompt templates, parameter settings (e.g., temperature sampling), or aggressive search strategies beyond our fixed repair iterations might yield different outcomes. Variations in LLM selection and deployment environments may also impact performance.

Conclusion

We introduced SEDCoT, a framework that translates COBOL into C by combining large language models (LLMs) with symbolic execution, automated test generation, and iterative repair. To handle COBOL’s unique syntax and semantics, SEDCoT leverages delta debugging to simplify failing test cases, guiding the LLM toward accurate fixes. Our comprehensive evaluation demonstrates that SEDCoT consistently outperforms state-of-the-art baselines by at least 12%. These results showcase the effectiveness of integrating LLMs with symbolic and automated debugging techniques, providing a promising direction for legacy system modernization and future industrial applications.