arXiv:2610.22528cs.SEOct 2026

Manuscript Offprint

arXiv:2610.22528

ForTress: Bringing Assurance and Determinism for LLM-Driven Fortran-to-Python Translation

Qinrun Dai, Ruitong Liu, Chien-Wei Huang, Guanhong Tao, Guannan Wei, Yueqi Chen

QINRUN DAI, University of Colorado Boulder, USA

RUITONG LIU, University of Colorado Boulder, USA

CHIEN-WEI HUANG, University of Colorado Boulder, USA

GUANHONG TAO, University of Utah, USA

GUANNAN WEI, Tufts University, USA

YUEQI CHEN, University of Colorado Boulder, USA

Modernizing mature scientific software from Fortran to Python can improve accessibility and integration with modern computing tools, but manual rewriting is expensive. Large language models (LLMs) make translation more practical, yet generated code can pass regression tests while violating source-language semantics, and contextual corrections may not persist across subsequent translations. We present ForTress, which solidifies recurring LLM translation decisions into guarded executable rules for deterministic reuse and provides semantic assurance for a non-trivial subset of these rules. Its LLM-assisted auditing process expresses universally quantified preservation obligations over mechanized Fortran and Python semantics in Lean. Human experts review semantic fidelity and correspondence with production rules, and Lean's kernel checks proofs and refutations under explicit assumptions. These audit records expose the conditions either supporting correctness or identifying failure cases. We evaluate ForTress on 17 benchmarks from 15 scientific software spanning diverse domains. The translated programs achieve bitwise-identical with native Fortran on all evaluated tests under the recorded execution and initialization configurations. Against these software, ForTress accumulates 193 executable rules and 188 audit records, of which 121 have checked soundness proofs, including 31 established after counterexample-guided refinement. Cross-software reuse exceeds 90% for 14 of the 15 software. Even with additional assurance and determinism, the LLM usage cost is 44.2% lower than direct LLM translation.

CCS Concepts: • Software and its engineering → Source code generation; Software testing and debugging.

Additional Key Words and Phrases: Fortran-to-Python translation, scientific software modernization, reusable translation rules, semantic assurance, LLM-assisted program translation, Lean

1 Introduction

Large scientific software systems are increasingly being modernized from legacy languages such as Fortran into Python-based ecosystems, as exemplified by Veros [Häfner et al. 2018] and PyCAM5 [PyCAM5 2026]. Such migrations promise improved maintainability, accessibility, accelerator support, and integration with modern AI tools [Häfner et al. 2018, 2021; Meunier et al. 2025]. However, manually rewriting mature scientific codes is prohibitively expensive. The U.S. Department of Energy’s Exascale Computing Project invested up to $1.8 billion over seven years to develop and enhance 25 scientific software [Koppes 2024; Lawrence Livermore National Laboratory 2025]. Recent Large Language Model (LLM)-driven coding systems make source-to-source translation possible at a scale that was previously impractical [Ibrahimzada et al. 2025; Koldunov et al. 2026; Lahlou et al. 2026].

However, LLM-driven translation faces two key bottlenecks in practice. First, an LLM-generated translation may be syntactically valid and pass regression tests while still failing to preserve the

Authors' Contact Information: Qinrun Dai, Qinrun.Dai@colorado.edu, University of Colorado Boulder, Boulder, Colorado, USA; Ruitong Liu, ruli3957@colorado.edu, University of Colorado Boulder, Boulder, Colorado, USA; Chien-Wei Huang, Jeremy.Huang-1@colorado.edu, University of Colorado Boulder, Boulder, Colorado, USA; Guanhong Tao, guanhong.tao@utah.edu, University of Utah, Salt Lake City, Utah, USA; Guannan Wei, guannan.wei@tufts.edu, Tufts University, Medford, Massachusetts, USA; Yueqi Chen, yueqi.chen@colorado.edu, University of Colorado Boulder, Boulder, Colorado, USA.

original program semantics. Execution-based dynamic validation remains indispensable, but it establishes agreement only for the finite inputs actually tested. Second, even after a translation error is identified and corrected, documenting the correct translation in the context or as a “skill” does not ensure its consistent reuse in subsequent translations. The LLM could still overlook the correction or generate another plausible but semantically incorrect translation.

In this work, we propose a two-part approach to address these bottlenecks. First, we solidify recurring Fortran-to-Python transformations observed during LLM-driven translation and debugging into executable heuristic rules, allowing subsequent deterministic reuse. Second, for a nontrivial subset of these rules, we use Lean to check proofs that the rules preserve semantics under explicitly stated applicability conditions and modeling assumptions. More specifically, the LLM interacts with Lean by proposing proofs covering all source instances and inputs satisfying these conditions, which Lean then checks. If these proof attempts do not succeed, the LLM searches for counterexamples that expose failure conditions and guide rule and proof refinement, providing a basis for reuse that black-box LLM generation alone does not offer.

The formal semantic definitions and theorem statements are initially generated with LLM assistance and are not trusted as generated. For modeled construct, human experts check that the definitions reflect the relevant Fortran and Python behavior, including types, operations, and state changes, under explicit assumptions. They also check that each preservation claim accurately describes the corresponding executable rule's source pattern, applicability conditions, and emitted Python code. As such, an incorrect rule is still faithfully described, allowing a counterexample to refute its universal preservation claim and identify a source instance and input for which preservation fails.

We implemented the proposed approach as ForTress. ForTress is a continuously evolving system that accumulates and refines LLM-generated components using feedback from translating and evaluating scientific software. To date, we have evaluated ForTress on 17 benchmarks from 15 software spanning diverse domains, using Claude Opus 5.5, the strongest model available to us at the time of the experiments and submission. ForTress translated 105,631 lines of Fortran code from 1,015 subprograms reached by the benchmarks. The translated Python programs produced outputs bitwise-identical to those of native Fortran on all evaluated benchmark tests under the instrumented execution and initialization configurations.

We accumulated 193 executable rules, 42 Lean modules, and 188 audit records across these software. Of these records, 121 have checked soundness proofs, including 41 under additional applicability premises and 31 established after counterexample-guided refinement. There are another 25 records requiring explicit model extensions and external contracts, and 42 records remaining to be further refined and checked against more software instances.

In leave-one-software-out reuse measurements, 14 of the 15 software exceed 90% reuse, and six reach 100%. Even with additional assurance and determinism, ForTress's LLM usage cost is 960,comparedwith960, compared with1,721 for the direct LLM baseline, a reduction of 44.2%. The developers of CLUBB [CLUBB 2026a], one of our evaluated software, have already integrated part of the translated Python code into their codebase. Though ForTress is developed and evaluated for Fortran-to-Python translation, the approach is general and can be potentially applied to other language pairs.

We make the following technical contributions:

• We introduce reusable, guarded executable translation rules that capture recurring LLM translation decisions and enable deterministic reuse, amortizing the cost of LLM-assisted translation.

• We provide assurance for executable translation rules by linking them to mechanized Fortran and Python semantics through explicit preservation obligations. Human review checks

Translation example

// Fortran source r1 = ANINT(x) // Incorrect translation r1 = np.round(x) // Repaired translation t = np.trunc(x) r1 = (t + math.copysign(1.0, x) if abs(x - t) >= 0.5 else t)

Rounding behavior

Input xANINTnp.roundnp.truncRepaired r1
2.252.02.02.02.0
1.52.02.01.02.0
2.53.02.02.03.0
-2.5-3.0-2.0-2.0-3.0

Fig. 1. Rounding mismatch in direct LLM translation. Left: a Fortran ANINT call, the incorrect np.round translation, and a repaired scalar rounding core. Right: representative outputs showing that agreement on ordinary inputs does not ensure correct halfway rounding.

semantic fidelity and rule-obligation correspondence, while Lean's kernel checks proofs and refutations under stated assumptions.

  • We implement ForTress and showcase its translation effectiveness, rule assurance, and cross-software reuse on 17 benchmarks from 15 scientific software systems. ForTress is released as part of RecastEngine [RecastEngine 2026].

We organize the rest of this paper as follows. Section 2 motivates our work. We describe the ForTress approach in Section 3 and its LLM-generated components in Section 4. Section 5 presents the evaluation results. Section 6 discusses threats to validity, followed by related work in Section 7. Finally, Section 8 concludes this paper.

References (17)