Manuscript Offprint
arXiv:2610.22528ForTress: Bringing Assurance and Determinism for LLM-Driven Fortran-to-Python Translation
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 1,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 x | ANINT | np.round | np.trunc | Repaired r1 |
|---|---|---|---|---|
| 2.25 | 2.0 | 2.0 | 2.0 | 2.0 |
| 1.5 | 2.0 | 2.0 | 1.0 | 2.0 |
| 2.5 | 3.0 | 2.0 | 2.0 | 3.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.
Such divergence matters because it directly affects computational correctness. In Quantum ESPRESSO [Giannozzi et al. 2017, 2009], a widely-used software for electronic-structure calculations and materials modeling, ANINT is used in its dipole routine when selecting minimum-image coordinates, and the rounding divergence mistakenly changes all three dipole components from -4 to 4. Therefore, semantic assurance are required to preserve scientific fidelity during translation.
Identifying and correcting one divergence instance is insufficient. The correction must be reliably reused across all sites. Prior LLM-driven translation workflows use reusable “skills” to guide the process and persistent context files to carry translation guidance and corrections across sessions [Koldunov et al. 2026; Lahlou et al. 2026]. However, neither approach enforces consistent application of a correction, because context can be lost over long-horizon translation and stochastic token generation provides no guarantee.
Using more capable frontier models reduces the likelihood of such mistranslations to some extent, but does not fundamentally address the problem. We experimented two models, Opus 4.6 and 5.5 on 50 code snippets containing ANINT and its sibling intrinsics NINT, repeating each translation six times. The average number of mistranslations decreases only from 46.5 to 34.5, even after
Executable rules
Intrinsic translation
def translate_intrinsic(name, args): rule = scalar_table[name] return f"{rule}({args[0]})"
scalar_table = { "anint": "_f_anint" }
Incorrect executable rule
def _f_anint(x): return np.round(x)
Repaired executable rule
def _f_anint(x): t = np.trunc(x) return (t + math.copysign(1.0, x)) if abs(x - t) >= 0.5 else t)
Lean assurance
def FNP_R0064_obligation : Prop := V o Γ, Call1Sound o Γ .anint .np_round theorem FNP_R0064_refuted : → FNP_R0064_obligation
noncomputable def anintRepairR (x : R) : R := let t : R := truncR x if (1 / 2 : R) ≤ |x - t| then t + (if x < 0 then -1 else 1) else t
def FNP_R0064_fixed_obligation : Prop := V x : R, anintRepairR x = (nintR x : R) theorem FNP_R0064_fixed_sound : FNP_R0064_fixed_obligation := anintRepairR_eq_nintR
Fig. 2. Reusable translation rules and their Lean soundness audit for ANINT. Left: deterministic intrinsic dispatch and the incorrect and repaired executable rules. Right: Lean checks LLM-generated proofs refuting the original rule's soundness obligation and establishing that the repaired rounding core is equivalent to the modeled Fortran semantics.
unlimited LLM attempts. Moreover, Opus 5.5 introduces another seemingly plausible translation, math.floor(x+0.5), which also diverges from the original Fortran semantics when x is very close to, but smaller than, 0.5. Even if future models can reliably handle this particular translation, stronger model capability does not generalize into a guarantee against other latent semantic mismatches, nor does it ensure persistent correctness throughout a long-horizon translation.
In this work, while retaining LLMs as part of the translation process, we propose to solidify translations into executable rules for reliable reuse. For each executable rule, we construct a soundness obligation relating the source operation to the target operation implemented by the rule. For these obligations, Lean checks the preservation proofs and counterexample-based refutation proofs constructed by the LLM. Both outcomes provide assurance about the rule's semantic behavior. A proof establishes preservation for every modeled instance satisfying its premises, while a refutation identifies a modeled counterexample to the preservation claim which guides further repair. This evidence makes the conditions supporting correctness or identifying failure cases explicit, providing a basis that black-box LLM generation alone does not offer.
Figure 2 illustrates how such an executable translation rule is represented and applied for our ANINT example. It is essentially an Python logic that dispatches a source-language construct to its corresponding target-language implementation. In the figure, translate_intrinsic() looks up the corresponding rule in scalar_table and emits a call to that rule with the translated argument. For ANINT, the table maps the intrinsic to the Python helper _f_anint, so every occurrence of ANINT(x) is deterministically translated into _f_anint(x). The incorrect rule simply returns np.round(x), whereas the repaired rule truncates the input and adjusts the result away from zero whenever the fractional magnitude reaches one half.
We next formulate the semantic correctness of the original rule as FNP_R0064_obligation. As shown in Figure 2, the obligation requires Call1Sound o Γ .anint .np_round for all semantic oracles o and source environments Γ. Call1Sound captures compositional soundness for a single-argument operation. If a source argument and its translated target expression are already semantically related by SoundScalar, then applying the source intrinsic and the target helper must

Fig. 3. Design overview of ForTress. The Rule-Generator, Translator, and Executor form the minimal core. The Auditor provides an additional feedback channel to provider stronger assurance and capabilities beyond the underlying LLM.
preserve that relation. Thus, proving FNP_R0064_obligation would establish that the translation from ANINT to np. round is sound for every scalar expression covered by the semantic model.
For this rule, however, the LLM constructs a proof of the negated obligation, recorded as FNP_R0064_refuted and checked by Lean. This formalizes the semantic mismatch in Figure 1. Fortran ANINT uses the source rounding semantics nintR, whereas np. round uses roundHalfEvenR. The Fortran and Python semantics used in these obligations are defined independently, based on their respective specifications and validated against compiler and runtime behavior. At the exactly representable input 5/2, nintR(5/2) evaluates to 3, while roundHalfEvenR(5/2) evaluates to 2. Instantiating the universal Call1Sound obligation with this argument therefore yields a contradiction. Consequently, FNP_R0064_refuted is not merely a failed attempt to prove the rule, but a machine-checked proof that the rule is unsound.
This refutation guides the repair shown in Figure 2. We model the scalar rounding core of the repaired implementation by anintRepairR. For an input x, it first computes . If , it adjusts t by one away from zero. Otherwise, it returns t unchanged. This is the exact-real counterpart of the repaired executable Python rule.
The repaired core is specified by FNP_R0064_fixed_obligation. In this proposition, nintR is the independently defined source-side rounding semantics used to model ANINT. The theorem FNP_R0064_fixed_sound discharges this obligation directly using the previously established lemma anintRepairR_eq_nintR. Hence, the repaired rounding core is equivalent to the source rounding semantics for every real input in the model, not just for the example in Figure 1.
3 ForTress Approach
ForTress turns recurring translation decisions into executable rules and audits them against mechanized semantics. Figure 3 presents its design overview, comprising five components connected through a feedback loop.
ForTress starts with the Rule-Generator which takes a Fortran program unit to be translated as the input and invokes LLMs to generate executable rules. It is also assigned with debugging tasks to revise rules in response to testing failures, auditing refutes, and counterexamples from other components in the feedback loop. Newly generated and revised rules are incorporated into the rule library for reuse in subsequent translations and also enable further iterations of the feedback loop.
Retrieving rules from the library, Translator apply them to Fortran code and produce Python versions. Its frontend first parses the Fortran source and extracts program facts, including syntax trees, types, interfaces, constants, and effects. The Translator then matches these facts against rules in the library and deterministically emits Python code. If matching fails, the Translator will feedback this unsupported site to the Rule-Generator. The finally generated code is submitted by the Executor to the target High-Performance Computing (HPC) system for execution, and its outputs are compared against those of the native Fortran implementation to identify discrepancies as testing failures. Neither the Translator nor the Executor invokes LLMs.
Even if no discrepancy is observed, however, the translation is not necessarily semantically correct, as illustrated by our ANINT example. To provide an additional feedback channel for stronger assurance, the Auditor first translates executable rules, together with the relevant Fortran and Python semantic models, into proof obligations in Lean. The resulting obligations and proof scripts are then submitted to Lean's kernel, which checks proofs or refutations of the modeled claims. The counterexamples from the LLM-assisted Auditor will be used by the Rule-Generator to repair the executable rules. As ForTress is applied to more scientific software, this feedback loop expands the rule library and progressively develops and refines the semantic models, obligations, and proofs or refutations.
The Auditor invokes LLMs to propose mechanized semantics, rule obligations, and proof scripts, drawing on sources such as compiler and runtime behavior, the Fortran 2018 standard, the Python Language Reference, etc. Because these LLM-generated artifacts may be incorrect or incomplete, we introduce Human-Expert to examine two critical boundaries: first, whether the semantic models faithfully represent the intended language behavior, and second, whether the generated rule obligations accurately capture the behavior of the corresponding executable rules. Readers may wonder how Lean obligations can provide assurance about executable rules when both are generated with LLM assistance. We discuss this question in Section 3.2.
Finally, ForTress forwards testing failures and audit refutations to the Rule-Generator, which revises executable rules by, for example, strengthening their applicability guards. The four automated components operate as specialized subagents with fixed workflows, and LLM calls use predefined prompts. LLM judgment is confined to local decisions to limit unintended behavior. The following subsections describe each component in detail.
3.1 Rule-Generator, Translator, and Executor
Leaving assurance aside, the Rule-Generator, Translator, and Executor form the minimal core of ForTress for turning recurring translation decisions into reusable rules.
In the Rule-Generator, we represent a translation rule as , comprising a source pattern , an applicability guard , and an emission operation . The source pattern identifies the Fortran construct to be translated. The guard constrains the rule using syntax, declared types and kinds, array rank and bounds, procedure interfaces, effects, and numerical configuration. The emission operation produces Python expressions, statements, or calls to runtime helpers.
The guard defines the scope over which an emission is claimed to be correct. In our ANINT example, the counterexample ANINT(2.5) = 3 versus np.round(2.5) = 2 refutes the emission itself. Replacing np.round with a helper that implements rounding ties away from zero repairs this discrepancy, but the rule may be reused only for the argument types, ranks, and KIND variants supported by the helper. A repair therefore revises the guard–emission pair, rather than merely replacing a piece of generated code, and the revised rule must be tested and audited again.
Given the same source, analysis facts, configuration, and rule library, the Translator deterministically produces the same Python code. It assembles the translated subprograms into a complete module containing constants, companion module imports, persistent module state, signature information, and runtime helpers. For example, an array reference is shifted using its declared lower bound, while a procedure call uses interface and effect information to propagate changes to OUT and INOUT arguments and shared state.
If the rule library does not cover a Fortran construct, the Translator does not emit a speculative translation. Instead, it records the unsupported site, including the enclosing subprogram, source span, original construct, and the reason that no rule applies. Each unresolved entry is sent to the Rule-Generator, which invokes an LLM with the program unit, relevant analysis facts, and rejection reason to generate a new guarded rule or revise an existing one. Once the resulting rule is added to the rule library, the Translator repeats the deterministic translation pass. The translation remains incomplete until all unresolved entries have been addressed.
The Executor validates the translated Python version against the native Fortran implementation through two complementary approaches. The first is differential execution, which runs the native Fortran and translated Python versions on the same inputs. This controlled, side-by-side execution provides fine-grained observability and helps attribute a discrepancy to a specific translated routine. The second is in-situ execution, which retains the original application driver and replaces selected computational routines with their translated versions. This hybrid execution reveals integration errors that arise only from procedure calls, argument updates, and shared state.
In both approaches, instrumentation records argument values at procedure entry and exit, including IN, OUT, and INOUT arguments, as well as the values used to evaluate conditional branches. The Executor compares the resulting execution traces together with returned values, shared state, and generated files. This fine-grained comparison can identify an intermediate divergence even when it is later masked in the final outputs, and can localize the first mismatching procedure or branch condition. The resulting diagnostic information is returned to the Rule-Generator to guide rule revision. Routines and instrumentation sites that cannot be exercised are explicitly reported as uncovered rather than treated as passing.
3.2 Auditor and Human-Expert
While the Executor can validate the translated Python version against the native Fortran, this validation is limited to the tested inputs and can miss semantic mismatches. Even with unlimited feedback iteration in the minimal core, LLM could still retain failures, as our motivating example illustrates. ForTress introduces the Auditor as an additional feedback channel to provide stronger assurance and gets rid of being limited by the capabilities of the underlying LLM. Here, we address two key questions about how the Auditor works and what guarantees it provides.
What does the Auditor assure? Figure 4 illustrates three nested scopes on each side of Fortran and Python: the full language, the fragment addressed by executable translation rules, and the innermost fragment modeled in Lean. To the best of our knowledge, no complete formal semantics is available for either full Fortran or full Python. To construct the innermost Lean fragment, ForTress mechanizes selected constructs based on language specifications, including the Fortran 2018 standard, the Python Language Reference, and NumPy documentation, supplemented by compiler and runtime behavior and concrete probes.
For a rule , let s match the source pattern in static context c, including , and let denote the modeled translation. The expression obligation universally quantifies the

Fig. 4. Nested scopes of translation and semantic assurance. Full Fortran and Python lack complete mechanized semantic ground truth. Translation rules address a fragment of each language. Within each translation fragment, our Lean development models a smaller subfragment.
following implication over matching expressions, contexts, states, and results:
(1)
Here, includes modeled well-formedness conditions and rule-specific premises, and relates source and target results. The obligation states that, whenever the guard and premises hold, the initial states correspond, and source evaluation yields a value, target evaluation must also yield a related value. The obligation applies only when the modeled Fortran expression has a defined result (e.g., not division by zero). The resulting guarantee is therefore a forward preservation property over source-defined executions within the modeled fragments, not a bidirectional equivalence between the full languages. Our current Lean semantics model arithmetic instead of exactly the IEEE 754 floating-point behavior.
The Auditor’s checked proofs establish preservation within the innermost Lean fragment under explicit guards and premises. Counterexamples, as another form of assurance, supplied to the Rule-Generator reveal conditions under which executable rules fail. The Rule-Generator then corrects the emission or strengthens the applicability guard. These counterexamples guide model extension and rule refinement, progressively bringing additional rules within the modeled scope and supporting renewed attempts by the LLM to construct preservation proofs for Lean to check.
How can the LLM-generated Auditor provide assurance for LLM-generated rules? In the Auditor, the mechanized semantic definitions and Lean proof obligations are not handcrafted but automatically generated by invoking LLMs, just like the executable rules. However, the Auditor can still provide assurance for executable rules.
First, an executable rule and its proof obligation serve different roles. The rule proposes a transformation, while the obligation asks whether it preserves behavior under independently defined Fortran and Python semantics. An obligation can therefore faithfully represent an incorrect rule and expose a false preservation claim.
Second, obligations are universally quantified and checked through symbolic reasoning, extending assurance beyond finite execution-based tests. A valid proof establishes preservation for every modeled instance satisfying the guard and premises, while a single checked counterexample refutes the universal claim. For example, the obligation for translating ANINT to np. round is refuted at x = 2.5, where the source model returns 3 and the target model returns 2.
Third, human review of two correspondences are required before applying audit results to production rules. Experts compare the mechanized source and target semantics against language specifications, compiler and runtime behavior, and concrete probes to make sure that the semantic models capture the intended language behavior. They also verify that each obligation’s modeled guard, emission, and runtime helpers are consistent with the executable rule’s implementation.
3.3 Implementation
The ForTress prototype builds on fparser and Lean 4 with Mathlib version 4.34.0. It contains approximately 50,000 lines of Python code for implementing each component and integration.
The prototype invokes LLM coding agents through their non-interactive command-line interfaces. Specifically, it launches Claude Code using claude -p and invokes Codex through its analogous headless command, with both tools authenticated through user subscriptions. For each invocation, ForTress constructs a task-specific prompt and starts the agent in the relevant workspace, allowing it to inspect existing artifacts, modify designated files, and execute supporting tools. The resulting file changes and process outputs are then collected by ForTress for compilation, execution, or Lean validation. Any diagnostics can be incorporated into a subsequent invocation for refinement.
In the Rule-Generator, the library of the rule is implemented as expression and statement handlers, intrinsic mappings, array-index transformations, procedure-call transformations, and module construction, as shown in the motivating example and more in following sections. Runtime helpers implement target-language operations that cannot be emitted directly as Python expressions.
The Executor observes program state through generated calling wrappers and lightweight runtime probes. For differential execution, it uses interface information extracted by fparser to generate flat f2py wrappers around the original Fortran procedures. It constructs one input instance, passes independent copies to the compiled Fortran procedure and translated Python procedure, and collects their returned values and modified argument buffers. This captures INTENT(IN) arguments before execution, INTENT(OUT) arguments after execution, and both states of INTENT(INOUT) arguments. For in-situ execution, explicitly inserted runtime probes emit named checksums and numerical summaries of selected arrays at corresponding execution points. The Executor aligns these observations by procedure or probe identifier and compares them using bit-exact and ULP-based tolerance criteria.
The Auditor traces each obligation with its corresponding production rule and implementation locations. Each entry records the proof status, stated assumptions, applicability conditions, and generated examples used during review. Validation scripts compile the Lean development, detect unfinished proofs, and inspect the axioms on which recorded theorems depend.
4 LLM-Generated Components in ForTress
Being applied to 15 real-world scientific software (Section 5), ForTress has accumulated executable rules, semantic definitions, and proofs that are reusable and also form a critical part of the ForTress system. This section describes their organization, as well as the connections between the executable and proof components.
4.1 Executable Rule Library
The executable library contains 193 executable rules, which comprises 176 language or numerical transformations and 17 environment or extension-interface rules. Some rules cover a family of operations. Table A.1 in Appendix groups them by their categories. The largest category concerns precision and kind policy, followed by control flow and environment interfaces. Other categories cover procedure calls, arrays, indexing, memory operations, arithmetic, reductions, and I/O.
Translation Example
Executable Rules
// Fortran source // Real scalars, integer k and N // One-based array parameters N = size(parameters) r0 = parameters(1) beta = parameters(2) z = (r-r0)exp(-beta(r-r0)2) f = 0 do k = 0, N-3 f = f + parameters(k+3)*zk enddo
// Python translation n = np.size(parameters) r0 = parameters[0] beta = parameters[1] z = ((r-r0) * math.exp(-beta * ((r-r0) * (r-r0)))) f = 0 for k in range(0, n-3+1): f = (f + parameters[(k+3)-1] * _f_powi(z, k))
// Guarded power rules def emit_power(x, n, n_ast): p = integer_literal(n_ast) if p is not None and p != 0: return expand_power(x, p) if is_integer(n_ast): return f"_f_powi({x}, {n})"
// Dispatch tables ARITH_OPS = {"+": "+", "-": "-", "": ""} scalar_table = {"exp": "math.exp", "size": "np.size"} def emit_intrinsic(name, x): return f"{scalar_table[name]}({x})"
// One-based array indexing def emit_index(a, i): return f"{a}[({i}) - 1]"
// Unit-step counted loop def emit_do(k, lo, hi): return f"for {k} in range({lo}, {hi}+1):"
Fig. 5. Rule composition in Duo's dipole_polynom_exp. Left: a Fortran fragment and its generated Python translation, with hoisted constants and redundant parentheses simplified. Right: selected rules shown as simplified emitter pseudocode for scalar values, one-based arrays, unit-step loops, and the expanded-power profile. The constant square expands into multiplication, while the variable integer power calls _f_powi. Intrinsic dispatch, index rebasing, and inclusive loop bounds compose with arithmetic and assignment rules.
Guarded branches, dispatch tables, and helpers. Figure 5 illustrates these mechanisms using an example in translating dipole_polynom_exp subroutine in Duo [Yurchenko et al. 2016], a software calculating diatomic molecules by solving the nuclear motion Schrödinger equation. The guarded power emitter checks the exponent and operand types before selecting an emission. For , integer_literal(n_ast) returns the nonzero constant 2, so the first branch calls expand_power to produce . This expansion deliberately matches the reference Fortran compiler's lowering of the constant square to multiplication to preserve bitwise-identical, since CPython's floating-point ** may use the platform pow, whose rounding can differ from multiplication [GCC Developers 2024, 2026; Python Software Foundation 2026]. For z**k, the exponent k has integer type but no value known at translation time. The second branch therefore emits _f_powi(z,k). The exp call in the assignment to z uses a dispatch table. emit_intrinsic looks up "exp" in scalar_table, obtains math.exp, and emits a call with the translated argument. The generated _f_powi(z,k) call invokes a shared runtime helper that evaluates integer powers by repeated squaring in gfortran's multiplication order. This behavior is implemented once in the helper and reused by every generated call site.
Chaining rules in a tree structure. We list rules applied in translating this example in Table 1. Figure 6 shows how these rules are chained in a tree structure for translation. The root applies R8 to the loop, with separate branches for the upper-bound expression N-3, handled by R6, and the body assignment, handled by R7. Within the assignment, R6 translates the index expression k+3, R4 rebases it to , and R5 emits the array reference parameters . A separate branch applies R3 to z**k, emitting _f_powi(z,k) because k is a runtime integer exponent. The enclosing applications of R6 combine the array element and the translated power into a product, then add that product to f. R7 emits the assignment, and R8 combines the translated bounds and
Table 1. Executable rules and representative Fortran-to-Python fragments in Figure 5. Labels identify nodes in Figure 6.
| Rule | Fortran → Python |
|---|---|
| R1. R-power.expanded | (r-r0)**2→(r-r0)*(r-r0) |
| R2. R-intrinsic.scalar_table | exp(...)→math.exp(...) |
| R3. R-power.integer_runtime | z**k→_f_powi(z,k) |
| R4. R-index.shift_unit | Subscript k+3→(k+3)-1 |
| R5. R-index.array_reference | parameters(k+3)→parameters[(k+3)-1] |
| R6. R-arithmetic.scalar_fallback | r-r0→(r-r0)k+3→(k+3)f+...→(f+...) |
| R7. R-assignment.ordinary | f = ...→f = ... |
| R8. R-loop.counted | do k=0,N-3→for k in range(0,n-3+1): |
Fig. 6. Composition tree for the counted loop in Figure 5. Repeated labels denote separate rule applications.

body into the Python loop, adding one to the upper bound to preserve Fortran's inclusive iteration range. Each occurrence of R6 represents a separate application of the same arithmetic rule. The composition follows the nesting of source constructs, enclosing rules assemble their output from translated children, allowing independently rules to translate the complete loop.
4.2 Semantic Models and Proof Library
The Lean proof library comprises 42 modules and 190 distinct theorem declarations. Table B.1 in Appendix B groups the proofs by semantic family and proof role, with representative theorem declarations. Executable rules, audit records, and theorem declarations are not in one-to-one correspondence. A rule's guarded branches may require separate audit records, while one record may cover an emitter together with its runtime helpers. Each record may cite several theorems, and the same theorem or generic lemma may support multiple records.
Therefore, the library is organized hierarchically into six layers, with definitions and theorems in lower layers supporting proofs in higher layers. Figure 7 shows the hierarchy and representative definitions for Layers I–II, while Figure 8 presents contracts and theorems for Layers III–VI.
Layer I: Syntax and semantics. The Syntax modules define separate Abstract Syntax Trees (ASTs) for the modeled Fortran and Python fragments. Figure 7 shows the binary-expression case of F.eval and the assignment constructor of F.Exec. F.eval is a structurally recursive Lean definition. In the .bin op a b case, its two recursive calls evaluate a and b in the current state , producing va and vb. The call lift2 (arith op) va vb then applies the scalar arithmetic operation, with elemental lifting for array operands. In Duo's z**k example, op is .pow, and a and b are the variable expressions for z and k. The Option return type represents a defined result as some v and propagates none when an operand evaluation or operation is undefined.
Proof hierarchy
VI
Whole-kernel theorems
saxpy_trans; saxpy_sound
V
Composition theorems
trans_sound; transStmt_sound
34 expression rules; 7 statement families
IV
Rule-family theorems
Rule derivation
Shared-lemma siblings
Derived theorem
R0017
Division
R0077
MOD
Basic theorem
truncR_div_intCast
III
Modeled translation and contracts
Tr.trans; SoundScalar; SoundPair
StmtSound; Refuted
II
Cross-language relations
RelS; RelA; RelState
I
Syntax and semantics
F.eval; P.eval; F.Exec; P.Exec
→ Derivation
→ Shared lemma
→ Composition
Examples by proof layer
I: Syntax and semantics
-- F.eval: binary-expression case
| .bin op a b => do
let va ← eval o σ a
let vb ← eval o σ b
lift2 (arith op) va vb
-- F.Exec: assignment constructor
| assign {σ σ' x subs e v} :
eval o σ e = some v →
assign o Γ σ x subs v = some σ' →
Exec o Γ (.assign x subs e)
σ σ' .normal
II: Cross-language relations
-- RelS real case: Duo's f=0
| real {kind v w} : P.toR w = some v →
RelS (.real kind v) w
-- Duo: parameters(k+3) / parameters[(k+3)-1]
structure RelA (a : FArr) (p : PArr) : Prop where
shape : p.shape = a.extents
elems : ∀ idx, a.inBounds idx →
RelS (a.get idx) (p.get (rebase a.lbs idx))
def RelState (Γ : F.Env)
(σ : F.State) (τ : P.State) : Prop :=
∀ x d, Γ x = some d →
∃ v w, σ x = some v ∧ τ x = some w ∧
RelV v w
Fig. 7. The Lean proof-library hierarchy (left) and representative definitions for Layers I–II (right). Layer I shows tailored snippets from F.eval and F.Exec. Layer II shows scalar, array, and state relations illustrated with Duo example.
F. Exec is an inductively defined big-step relation connecting a statement, its initial and final states, and a control outcome. The displayed assignment constructor has two premises. The first requires the right-hand side e to evaluate to some v in . The second requires the assignment helper, using declarations , to update the destination specified by x and subs and produce some . The conclusion records that .assign x subs e takes to with the outcome .normal. The corresponding P.eval and P.Exec independently define target-language evaluation and execution. Both models use mathematical integers and reals, while arrays retain their dimensions, lower bounds, and element access.
Layer II: Cross-language relations. Figure 7 shows how the Relations modules connect source and target values and states. The displayed real constructor of RelS relates a Fortran real value v to a Python value w whenever P.toR w = some v. In Duo's f = 0 example, the Fortran assignment stores a real-valued zero, while Python stores an integer zero. The constructor relates these values because converting the target integer to its mathematical real value yields the same zero.
The RelA structure relates arrays through its shape and elems fields. The former requires the Python shape to equal the Fortran extents. The latter requires RelS for every in-bounds source element and its target counterpart at rebase a.lbs idx. In Duo's one-based parameters array, this rebases the Fortran subscript k+3 to the Python index (k+3)-1, matching the access shown in the code comment.
Examples by proof layer
Examples by proof layer
III: Preservation contract
-- Duo R3: e = z**k; e' = _f_powi(z,k) def SoundScalar (o : Oracles) (Γ : F.Env) (e : F.Expr) (e' : P.Expr) : Prop := ∀ σ τ, RelState Γ σ τ → Conforms o.F Γ σ → ∀ v, F.eval o.F σ e = some (.s v) → ∃ w, P.eval o.P τ e' = some (.s w) ∧ RelS v w
IV: Integer-power rule theorem
-- Duo R3: z**k -> _f_powi(z,k) example (o : Oracles) (Γ : F.Env) (z k : F.Expr) (z' k' : P.Expr) (hz : SoundScalar o Γ z z') (hk : SoundScalar o Γ k k') (hr : RealTyped o Γ z) (hi : IntTyped o Γ k) : SoundScalar o Γ (.bin .pow z k) (Tr.call2 .f_powi z' k') := by exact FNP_R0026_sound o Γ z k z' k' hz hk hr hi
V: Expression composition theorem
-- Duo R6: e = k+3; e' = (k+3) example (o : Oracles) (Γ : F.Env) (Λ : Tr.BoundEnv) (e : F.Expr) (e' : P.Expr) (hBounds : BoundEnvOK Γ Λ) (hWF : WFE Γ e) (hTrans : Tr.trans Tr.ifx Γ Λ [] e = some e') : SoundScalar o Γ e e' := by exact trans_sound o Γ Λ [] hBounds e hWF e' hTrans
VI: Whole-kernel theorems
-- SAXPY: y(i) = a*x(i) + y(i), i = 1,...,n theorem saxpy_trans : transStmt Γk Δk [] saxpyF = some saxpyP := by rfl
theorem saxpy_sound (o : Oracles) : StmtSound o Γk saxpyF saxpyP := transStmt_sound o Γk Δk [] Γk_bounds Γk_static saxpyF saxpy_wfs saxpyP saxpy_trans
Fig. 8. Representative contracts and theorems for Layers III–VI of the proof hierarchy in Figure 7. Layers III–IV (left) show the SoundScalar contract and local theorem for Duo’s integer power (R3). Layer V (right, top) uses k+3 (R6) under the modeled ifx profile, while Layer VI (right, bottom) shows the translation and soundness proofs for SAXPY. R3 and R6 refer to Table 1 and the example in Figure 5. Snippets are condensed. Preservation claims concern mathematical values under the modeled semantics.
RelState quantifies over each name x declared in . Its existential witnesses v and w require both states to bind that name to values satisfying RelV, which selects the scalar or array relation. In Duo’s example, these bindings include the scalars f, z, and k, together with the array parameters. Statement soundness obligations use this relation to compare the initial and resulting states.
Layer III: Modeled translation and contracts. The Translation module defines Tr.trans, which recursively maps a source AST to a target AST for the audited fragment. For Duo’s real-valued z and integer k, its gfortran power branch emits a call to the modeled f_powi helper, corresponding to _f_powi(z,k). The Rules infrastructure states the preservation contract for such a source/target pair.
Figure 8 shows the definition of SoundScalar. Its parameters o, , e, and e' fix the semantic oracles, source declarations, and source and target expressions. The quantifiers range over initial states and satisfying RelState. The additional premise Conforms o.F requires the source bindings to have the declared types, array ranks, and lower bounds. If F.eval o.F e returns some (.s v), the contract requires a target scalar w such that P.eval o.P e' returns some (.s w) and RelS v w holds. Here, .s tags a scalar result.
In Duo’s power expression example, e represents z**k, and e’ represents the helper call _f_powi(z,k), as indicated in the code comment. The contract requires a related target result whenever the source power has a defined value in conforming, related states. Layer IV supplies the proof using sound operand translations and the real-base and integer-exponent premises.
SoundPair extends the contract to scalar or array results through RelV, while StmtSound relates terminating executions and their final states. Refuted names the negation of SoundPair for counterexample proofs.
Layer IV: Rule-family theorems. The rule-family modules discharge Layer III's contracts for arithmetic, logic, intrinsics, indexing, sections, stores, control flow, and procedures. Figure 8 illustrates the integer-power theorem FNP_R0026_sound using Duo's z**k translation (R3) as an example. The displayed example writes out its four premises and conclusion. Here, z and k denote source operand ASTs, while z' and k' denote their translated ASTs. The premises hz and hk require sound translations of the two operands, so each defined source operand evaluation yields a related target value. The premises hr and hi require a real-valued source base and an integer-valued source exponent. The conclusion instantiates SoundScalar for the source power node .bin .pow z k and the target helper call Tr.call2 .f_powi z' k'. The proof line supplies the four premises to FNP_R0026_sound.
The underlying theorem first unfolds the source binary-expression evaluation and extracts the two operand values. It uses hz and hk to obtain related target operands, then uses the typing premises to identify the source operation as a real base raised to an integer power. After unfolding target helper-call evaluation, the lemmas helper_f_powi_float and helper_f_powi_int cover the Python base representations permitted by RelS. The proof considers zero, negative, and positive exponents and establishes RelS between the results for each defined source case. This gives Duo's power node the same preservation interface as its translated operands.
Generic lemmas such as bin_sound_of_rel, call1_sound_of_rel, lift1_rel, lift2_rel, and element_sound factor out recurring evaluation, lifting, and indexing arguments across other rule families. Most rule theorems are proved directly from the semantics, relations, and these lemmas. A theorem can derive from a more basic rule theorem, while unrelated rules can remain siblings that reuse the same generic lemma. This organization confines a failed proof to the translation decision whose guard, emitted operation, or semantic premise is insufficient.
Layer V: Composition theorems. The expression theorem trans_sound composes the local contracts by structural recursion over a source AST whose modeled translation succeeds. Figure 8 shows an application with its three premises written explicitly. hBounds requires the rendered-bound environment to supply the same number of bound entries as each declaration in . hWF requires e to satisfy the supported syntax and typing conditions in WFE. hTrans records that Tr.trans returns some e' under the modeled ifx profile. The conclusion is the SoundScalar contract from Layer III for the complete source/target expression pair.
In Duo’s index expression example, e represents , and e’ represents the emitted . The well-formedness premise records that k is a declared scalar with numeric type and that the integer literal 3 is a supported operand. The recursive call for k applies the name rule FNP_R0010_sound, while the call for 3 applies FNP_R0001_sound. The addition case then passes the two resulting operand contracts to FNP_R0016_sound, obtaining soundness of the enclosing .bin .add node. The displayed proof line supplies the frontend and translation premises to trans_sound, which performs this composition recursively. Across 34 local expression rules, each emitter case selects its matching theorem and supplies the recursively established operand contracts. The local theorems remain independent because their premises quantify over sound operand translations, while the composition theorem connects their applications through the source AST.
The statement theorem transStmt_sound similarly composes seven statement families and threads RelState through assignment, sequencing, conditionals, supported loops, and state updates. It also relates Fortran EXIT and CYCLE to target break and continue. The result is a forward simulation of terminating executions for the supported fragment.
Layer VI: Whole-kernel theorems. Kernel theorems fix the source and target ASTs and frontend environments for a complete translated fragment. Figure 8 shows the translation and soundness proofs for SAXPY, whose loop updates for . Here, saxpyF
Table 2. Scientific software, evaluation benchmarks, and testing environments.
| Software | Source | Domain | LoC | Benchmark | Source | Env |
|---|---|---|---|---|---|---|
| CLUBB | [CLUBB 2026a] | Atmos. physics | 144,864 | Single-column cases | [CLUBB 2026b] | H1 |
| RRTMG | [AER 2020a, 2025a] | Radiation | 173,296 | Standard atmospheres | [AER 2020b, 2025b] | H1 |
| CISM | [CISM 2026b] | Land ice | 77,332 | Halfar-HO | [CISM 2026a] | H1 |
| WW3 | [WW3 2026] | Waves | 183,354 | tp1.1 and ts1 | [WW III 2026] | H1 |
| COSP2 | [COSP2 2026] | Satellite obs. | 18,411 | UKMO offline test | [CFMIP 2026] | H1 |
| CARMA | [CARMA 2026b] | Aerosols | 21,705 | Regression tests | [CARMA 2026a] | H1 |
| CVMix | [CVMix 2026a] | Ocean mixing | 7,607 | Regression tests | [CVMix 2026b] | H1 |
| MARBL | [MARBL 2020b] | Biogeochemistry | 19,023 | Regression tests | [MARBL 2020a] | H1 |
| FATES | [FATES 2026b] | Ecosystems | 50,277 | Leaf-biophysics smoke test | [FATES 2026a] | H1 |
| MFC | [MFC 2026] | Multiphase flow | 44,799 | 1D boundary conditions | [MFlowCode 2026] | H1 |
| QE | [QE 2026] | Electronic struct. | 570,099 | XClib; DFT-D3 | [QEF 2026a,b] | H1 |
| RAMSES | [RAMSES 2026a] | Astrophysics | 159,286 | Hydrodynamics tests | [RAMSES 2026b] | H1 |
| NJOY2016 | [NJOY2016 2026] | Nuclear data | 100,487 | Tests 01, 02, 09, 10 | [NJOY 2026] | H1 |
| Duo | [Duo 2026a] | Spectroscopy | 75,074 | PS and SO | [Duo 2026b] | H1 |
| CAM-SIMA | [CAM-SIMA 2026] | Atmos. physics | 137,829 | Kessler | [CESM 2026b] | H2 |
| Held-Suarez | [CESM 2026a] | H2 | ||||
| TJ2016 | [CESM 2026c] | H2 |
and saxpyP encode the complete source and target loop statements. The declaration environment Γk assigns integer types to n and i, a real type to a, and one-dimensional real-array types with lower bound one to x and y. The rendered-bound environment Λk supplies the corresponding target lower-bound expressions. The target AST uses range(1, n+1) and indices i-1, and includes loop-completion code to preserve the final value of i.
The theorem saxpy_trans states that transStmt returns some saxpyP for saxpyF in these environments. Its rfl proof checks this equality by unfolding the concrete definitions. The theorem saxpy_sound then applies Layer V's transStmt_sound. The proof line passes Γk_bounds, which establishes BoundEnvOK, and Γk_static, which establishes that the declared lower bounds are integer literals. It also passes saxpy_wfs, the well-formedness proof for the loop and its body, and saxpy_trans, the translation equality. These facts discharge the frontend and translation premises of the composition theorem for this particular kernel.
The conclusion StmtSound o Γk saxpyF saxpyP quantifies over every pair of related initial states whose source state conforms to the declarations. For each terminating source execution described by F. Exec, it requires a target execution described by P. Exec, with the control outcome related by outMap and the final states related by RelState. It also preserves source-state conformance. The array size n remains symbolic, so the theorem covers every defined terminating execution admitted by the modeled semantics. The guarantee concerns mathematical values in this fragment, under the premises of StmtSound.
5 Evaluation
5.1 Benchmarks and Research Questions
We evaluate ForTress on 17 benchmarks drawn from 15 real-world software. The benchmarks span diverse scientific domains, including electronic structure, multiphase flow, nuclear data, astrophysics, molecular spectroscopy, ocean mixing, biogeochemistry, radiation, satellite observations, aerosols, terrestrial ecosystems, land ice, waves, and atmospheric physics. These are purposively selected case studies with available and compilable Fortran source and native benchmark drivers. Their variety exercises different numerical and state-management requirements.
Table 2 summarizes the software and benchmarks. For each one, we have the software name (Software), its origin (Source), scientific domain (Domain), the total line of Fortran code (LoC), the corresponding benchmark (Benchmark), and the testing environment (Env).
We conduct the experiments on two high-performance computing (HPC) systems, referred to as HPC1 and HPC2 to preserve anonymity and abbreviated as H1 and H2 in Table 2. HPC1 uses AMD EPYC 74F3 CPU nodes. HPC2 uses dual-socket AMD EPYC 7763 CPU nodes, with 128 cores and 256 GB of DDR4 memory per node. The software environment on HPC1 uses GCC/gfortran 14.2.0, Python 3.12.14, NumPy 2.5.3, SciPy 1.18.1, and Open MPI 5.0.6. The software environment on HPC2 uses GCC/gfortran 14.3.0, Python 3.11.14, NumPy 2.4.6, and Cray MPICH 8.1.32.
To evaluate ForTress against these benchmarks, we design the following three research questions:
• RQ1. Real-world Translation Effectiveness: How many the benchmark computation can ForTress translate to achieve bitwise-identical results?
• RQ2. Rule Assurance: Can the Auditor identify unsound or overly general translation rules despite agreement on the observed application tests?
• RQ3. Rule Reusability: To what extent can executable rules learned and accumulated be reused across real-world scientific software, and can reusing rules compensate model calls and token usage for rule generation and token generation?
5.2 RQ1. Real-world Translation Effectiveness
Setup and baseline. We use Claude Opus 5.5 as the direct LLM baseline, because it was the strongest model available to us when we conducted the experiments and submitted this paper. We construct this baseline from ForTress by removing the Auditor, Human-Expert, and reusable translation rules, while retaining the minimal core's feedback loop. Opus 5.5 generates Python code directly, and the Executor compares its behavior with native Fortran and returns execution failures and numerical mismatches to the model. The model uses this feedback to revise the generated code. We allow repeated repair attempts without imposing a token budget, continuing until the generated code passes the execution checks or the model decides that it cannot resolve the remaining failures.
We check output in scalar points for bitwise-identical agreement. One scalar point is one unmasked scalar output value recorded through instrumentation to compare with its native Fortran reference for a given test input. A scalar output contributes one point, and an array output contributes one point per compared element. For example, a output array contributes 200 points per test input. It should be noted that passing tests establishes agreement on the exercised inputs, but does not establish semantic equivalence on untested inputs or execution paths.
Results analysis. Table 3 summarizes computational source scope, translation coverage, and the observed agreement with native Fortran. Across the 15 systems, ForTress translates 1,015 of the 1,021 subprograms reached during benchmark execution into Python (99.4%). The source scope spans 105,631 SLOC and includes 37 distinct subprograms across the three CAM-SIMA schemes and 54 across the two WW3 builds.
Six reached routines are not translated. Four CARMA creation routines require allocation transfer for arrays of records within record arguments. COSP2's cosp_simulator performs direct-access I/O on an already connected unit. In CISM, the subroutine glissade_initialise accesses nested records and private module state. They do not prevent benchmark execution. We retain their Fortran implementations and invoke them through f2py wrappers. We dump the data passed across these interfaces and make the recorded results available to both the direct LLM baseline and ForTress, allowing them to replay these calls without translating the six routines. These six cases expose limitations in cross-language data transfer and access to application state that require runtime and interface support beyond source-code translation. As part of future work, we plan to
Table 3. Translation coverage and bitwise agreement on the benchmark scope. denotes translated/reached computational subprograms. Scope reports source lines of code (SLOC) in the reached subprograms. Tests reports comparison scale in scalar points: each unmasked scalar output value contributes one point, and an array contributes one point per compared element. ✓ indicates that all scored tests pass. In the Opus 5.5 column, denotes failing routine calls.
| Benchmark | Scope (SLOC) | Tests (scalar points) | Bitwise identical | ||
|---|---|---|---|---|---|
| Opus 5.5 | ForTress | ||||
| CLUBB: Single-column cases | 169/169 | 22,606 | 5,122,717 | ✓ | ✓ |
| RRTMG: Standard atmospheres | 107/107 | 13,320 | 19,649,812 | N/A | ✓ |
| CISM: Halfar-HO | 91/92 | 14,747 | 55,081,217 | ✓ | ✓ |
| WW3: tp1.1 and ts1 | 54/54 | 7,036 | 35,270,521 | ✕ 2 | ✓ |
| COSP2: UKMO offline test | 74/75 | 9,583 | 141,457,253 | ✕ 5 | ✓ |
| CARMA: Regression tests | 118/122 | 9,919 | 28,129,723 | N/A | ✓ |
| CVMix: Regression tests | 27/27 | 1,870 | 19,853 | ✓ | ✓ |
| MARBL: Regression tests | 79/79 | 5,431 | 5,118,479 | ✓ | ✓ |
| FATES: Leaf-biophysics smoke test | 22/22 | 1,002 | 1,299 | ✓ | ✓ |
| MFC: 1D boundary conditions | 49/49 | 4,212 | 2,302,066 | ✓ | ✓ |
| QE: XClib; DFT-D3 | 94/94 | 8,242 | 12,084,364 | ✓ | ✓ |
| RAMSES: Hydrodynamics tests | 19/19 | 1,439 | 10,609,501 | ✓ | ✓ |
| NJOY2016: Tests 01, 02, 09, 10 | 57/57 | 4,190 | 661,546 | ✓ | ✓ |
| Duo: PS and SO | 18/18 | 794 | 611,042 | ✓ | ✓ |
| CAM-SIMA: Kessler | 30/30 | 758 | 2,902,113 | ✓ | ✓ |
| CAM-SIMA: Held-Suarez | 13/13 | 346 | 1,880,549 | ✓ | ✓ |
| CAM-SIMA: TJ2016 | 14/14 | 630 | 3,033,528 | ✓ | ✓ |
extend ForTress by supplying templates that provide explicit packing and unpacking interfaces for nested records and allocation metadata, a Fortran I/O bridge operating on connected unit, and module-local accessor procedures for exposing and synchronizing private state.
ForTress achieves bitwise-identical with native Fortran on all evaluated benchmark tests under the recorded execution configurations. In comparison, direct LLM translation produces seven failing routine calls across two benchmarks and fails to establish reliable numerical agreement on two others, reported as N/A. The seven failures occur in COSP2 and WW3. Five occur in COSP2's quickbeam_optics, and two occur in WW3, one each in w3iogomd and w3src3md. The diagnosed COSP2 failures and the w3iogomd failure involve reproducing the reference compiler's vector mathematical functions in libmvec. The w3iogomd failure includes an 18-ULP discrepancy in a fourth-power calculation. The w3src3md hidden-test failure remains undiagnosed.
The two N/A entries concern CARMA and RRTMG, whose original Fortran programs read allocated state before all relevant elements have been assigned. Direct LLM translation did not identify these uninitialized reads or distinguish source-program defects from translation defects, and therefore failed to establish reliable numerical agreement. Our validation identified the initialization defects and confirmed agreement under controlled initialization. CARMA matches 25 of 27 application tests under ordinary execution. Six tests are sensitive to uninitialized state, and all six match when both executions zero-fill heap allocations. Together with the ordinary passing tests, these results cover all 27 tests. RRTMG matches all 16 shortwave tests and 13 of 14 longwave tests under ordinary initialization, and all 14 longwave tests under zero initialization.
From the results, we can observe that using LLMs to propose translation rules does not limit ForTress to the capabilities of the underlying model, because Lean proof provides an additional feedback channel. The direct LLM baseline retains failures despite repeated self-correction using execution feedback, whereas our system achieves agreement on the evaluated benchmarks. Lean-checked refutations expose semantic defects or missing applicability conditions in LLM-proposed rules and guide their correction beyond what execution feedback alone reveals. While the motivating example ANINT already illustrates this process, RQ2 (Section 5.3) presents additional concrete cases.
Developer adoption. CLUBB developers are reviewing the translated Python code and have already integrated part of it into their codebase.
5.3 RQ2. Rule Assurance
Evaluating against the 15 scientific software, the Lean proof library in ForTress accumulates 42 Lean modules and 190 distinct theorem declarations. Building the modules, checking the cited declarations, auditing the namespace, and checking the two supplementary developments takes 114.6 s in one measured run with precompiled Mathlib dependencies. The manual correspondence and assumption audit required approximately one person-week in total.
We report assurance through 188 audit records which covers all 193 executable rules. Each record identifies the translation decision or modeled subcase being audited and records its source span, assumptions, and supporting theorems or execution evidence. An audit record may cite several theorems, several records may share one, and unresolved or provenance records may cite none.
In general, out of the 188 audit records, 121 records (64.4%) have checked soundness proofs for claims within the Lean fragment shown in Figure 4. There are 25 records (13.3%) regarding behaviors within the supported translation fragment but beyond the current Lean fragment, requiring model extensions and external contracts. Compared with direct LLM's blackbox, these records also contribute assurance by exposing candidate defects and making unresolved correctness assumptions explicit. The remaining 42 records (22.3%) are unfinished. When ForTress produces a new translation rule and a corresponding soundness obligation, several rounds of refinement against more software is needed to capture the behaviors precisely before they can check a soundness proof or a counterexample. We provide more detailed discussion below.
Soundness proofs. A rule is sound when, for every source instance admitted by its pattern and guard, executing the emitted Python produces a value or state effect corresponding to that of the Fortran construct under the stated semantic and binding assumptions. Of the 121 records with soundness proofs, 80 establish this property using only the stated assumptions and 41 establish it under additional applicability premises. Further, there are 31 established after counterexample-guided refinement.
For the 41 records with additional applicability premises, the proof applies only when extra conditions hold. Because the general rule itself does not guarantee those conditions, the proof makes no claim about inputs that violate them. For example, the positive-step array-section proof requires SectionInRange, which keeps the translated slice edges within the array. Without this premise, Fortran can denote an empty section such as a(1:-1), while Python's negative-index adjustment can select actual elements. The premise must therefore be enforced by a guard or supplied by an input contract. For sections, the supplementary state-local formulation makes the bounds condition explicit for the current array and execution state.
The 31 records with counterexample-guided repairs illustrate how LLM interaction with Lean provides an additional feedback channel that strengthens ForTress beyond the capabilities of the underlying LLM. The motivating ANINT-to-np. round example is a representative case. The following is another case tracing the process from a checked refutation to a proved repair.
Consider value = real(radix ** level, 8) with (radix, level) = (2, -1). Because both operands are integers, Fortran evaluates radix ** level using integer exponentiation, producing zero, and then converts it to 0.0. The earlier rule instead emits float(radix ** level), for which Python evaluates 2 ** -1 as 0.5. Lean checks the refutation proof constructed by the LLM using this counterexample. The repaired rule checks that both operands are integer-valued and emits np.float64(_f_ipow(radix, level)), where _f_ipow implements Fortran's integer-exponentiation behavior before the conversion to real. Under the premises that the translated operands have the correct integer types and preserve their source values, the Lean theorem proves the repaired transformation sound for arbitrary runtime integer exponents. In contrast, the Opus 5.5 baseline insists on float(radix ** level), leaving the negative-exponent discrepancy unresolved.
Identified uncertainties. The Auditor also provides assurance by exposing candidate defects and identifying where soundness remains unresolved. These findings highlight differences in how Fortran and Python handle persistent state, data representation, and observable effects, as well as dependencies on operator-supplied behavior.
Five records contain execution counterexamples without separate Lean refutations. For example, a Fortran local variable with a declared initializer retains its value across calls through implicit SAVE, whereas a candidate translation that reinitializes it at every entry loses updates from previous calls. Paired execution confirms this defect.
For eleven audit records, the current Lean model lacks the semantic definitions needed to prove the corresponding translation claims. For example, TRANSFER depends on the bit representation of a value, which the current exact-arithmetic value model does not capture. Proving its translation sound therefore requires a bit-level model. In addition, derived types require modeling component state, while I/O requires modeling observable input and output effects.
The nine external-contract records identify guarantees that depend on operator-supplied configuration or extensions. An intrinsic override, for example, can replace built-in emission. Its preserved values and state effects must be established before the replacement can be admitted for use. The audit exposes these dependencies as explicit contracts that must hold for the translation to preserve source behavior.
Unfinished. The 42 unfinished records comprise 34 specified claims without a completed proof or refutation, seven records without separate value-level obligations, and one open array-lifting claim. Completing these records requires proving or refuting the specified claims, formulating the missing obligations, and lifting scalar soundness results to conforming arrays and scalar-expansion cases. As ForTress translates more software, additional constructs and usage contexts can expose missing definitions or assumptions and guide this refinement, making them to reach checked results.
5.4 RQ3. Rule Reusability
Measurement Method. To measure to what extend can executable rules learned and accumulated be reused across real-world scientific software, we adopt the train–test separation commonly used to evaluate machine learning models. Software from which ForTress acquires translation rules forms the “training set”, while one held-out software system forms the “test set” for measuring rule reuse. We repeat this procedure with each of the 15 software systems as the test set. To record the number of rule application, we instrument the translator without comprising the translation consistency. Repeated translation attempts at the same source site count as separate application events but contribute only once to the distinct source-site count.
To answer the question whether reusing rules compensate model calls, token usage, and translation cost for rule generation and token generation. we run ForTress end to end on all 15 software systems. In a separate environment, we run the same software using the direct LLM baseline from RQ1 (Section 5.2), removing the Auditor, Human-Expert, and reusable translation rules while retaining the minimal core's feedback loop. Both workflows continue using Claude Opus 5.5.
We estimate LLM costs from client-recorded token usage and the prices applicable to each run, rather than subscription payments. We record input, output, cache-write, and cache-read tokens separately, including thinking tokens in the output count. We deduplicate usage-bearing assistant
Cumulative rule coverage
Rule sources accumulated from left to right
Target software
| CLUBB | RRTMG | CISM | WW3 | COSP2 | CARMA | CVMix | MARBL | FATES | MFC | QE | RAMSES | NJOY2016 | Duo | CAM-SIMA | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| CLUBB | - | 61 | 82 | 86 | 95 | 95 | 95 | 95 | 95 | 95 | 95 | 95 | 95 | 95 | 95 |
| RRTMG | 76 | - | 84 | 89 | 93 | 96 | 96 | 96 | 96 | 96 | 96 | 96 | 96 | 96 | 96 |
| CISM | 63 | 68 | - | 88 | 90 | 90 | 90 | 92 | 92 | 92 | 92 | 92 | 92 | 92 | 92 |
| WW3 | 59 | 65 | 84 | - | 92 | 96 | 96 | 96 | 96 | 96 | 96 | 96 | 96 | 96 | 96 |
| COSP2 | 52 | 59 | 74 | 80 | - | 85 | 85 | 86 | 86 | 87 | 88 | 88 | 89 | 89 | 89 |
| CARMA | 58 | 65 | 77 | 81 | 87 | - | 87 | 87 | 87 | 87 | 87 | 87 | 91 | 91 | 91 |
| CVMix | 86 | 91 | 98 | 100 | 100 | 100 | - | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |
| MARBL | 76 | 82 | 90 | 94 | 96 | 96 | 96 | - | 96 | 98 | 98 | 98 | 98 | 98 | 98 |
| FATES | 91 | 91 | 94 | 100 | 100 | 100 | 100 | 100 | - | 100 | 100 | 100 | 100 | 100 | 100 |
| MFC | 80 | 84 | 94 | 96 | 98 | 98 | 98 | 100 | 100 | - | 100 | 100 | 100 | 100 | 100 |
| QE | 76 | 80 | 94 | 96 | 98 | 98 | 98 | 98 | 98 | 98 | - | 98 | 98 | 98 | 100 |
| RAMSES | 85 | 88 | 97 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | - | 100 | 100 | 100 |
| NJOY2016 | 66 | 74 | 82 | 88 | 92 | 98 | 98 | 98 | 98 | 98 | 98 | 98 | - | 98 | 98 |
| Duo | 67 | 73 | 92 | 94 | 96 | 96 | 96 | 96 | 96 | 96 | 96 | 96 | 96 | - | 96 |
| CAM-SIMA | 85 | 85 | 95 | 95 | 95 | 98 | 98 | 98 | 98 | 98 | 100 | 100 | 100 | 100 | - |
Reuse (%)
100
Excluded
Fig. 9. Cumulative coverage of observed translation rules across 15 software systems. At column , the accumulated pool is the union of rules observed in columns 1 through , excluding the test software. Each number is the rounded percentage of the test software's observed rule types covered by this pool. The denominator is the number of rule types observed in that software, rather than all 193 rules. Thus, means that all of its observed rule types also occur in the donor pool. Gray diagonal cells mark self-exclusion.
messages by identifier across transcript blocks. Request counts measure model calls, and each translation or repair attempt may involve multiple calls. We account separately for development, direct translation, fixture construction, and evidence collection.
Rule reuse across software. Figure 9 shows the extent to which executable rules accumulated from the “training set” software can be reused in the “test set” software. Rows identify test software, and columns identify rule-source software in a fixed order.
In Figure 9, reuse rates are monotonically nondecreasing because each additional software can only add rule types to the accumulated pool. By the final column, 14 of the 15 software exceed reuse, and six reach . Even with CLUBB as the sole rule source, the lowest observed reuse rate is , showing that rules accumulated from a single software could already cover a substantial share of other systems' translation needs. Several systems reach full coverage before all donors are included. FATES, CVMix, and RAMSES reach after the first four rule-source systems, through WW3. MFC reaches at the MARBL column, after the first eight rule-source systems.
Individual software can contribute markedly different gains. Adding CISM raises CLUBB's reuse rate from to , adding WW3 raises CISM's from to , and adding CISM raises WW3's from to . These jumps occur when a new donor supplies rule types used by the target but absent from the preceding pool. They suggest that similarities in language-feature use make some software more effective rule sources for particular targets. Figure C.1 in Appendix C shows how coverage varies across individual rule sources, confirms this trend, and further illustrates that, for some software, a single source is sufficient to cover the entire observed rule set.
COSP2 is the clearest exception to the high final coverage. It starts at the lowest reuse rate, , and remains the only software below at the end, reaching , suggesting that some of its Fortran feature usage is more distinctive. CARMA shares similar situation. Other cases

Fig. 10. Cumulative estimated LLM usage cost over request rounds for Direct LLM, Rule+Assurance, and Rule-only (estimated). Each round is one recorded model request. The shaded band marks the shared preparation cost included in each curve.
also exhibit plateaus. For example, Duo reaches 96% at the COSP2 column and gains no further coverage from the remaining donors. Accumulating rules from more software with complementary language-feature use is therefore needed to extend coverage.
The three most frequently reused rules handle recurring expression operations. R-name. reference translates source names into Python references. R-index. shift_unit rebases array subscripts with unit lower bounds to zero-based Python indices, mapping i to i-1. R-arithmetic. scalar_fallback combines translated operands with ordinary scalar operators, such as addition and multiplication. Their prevalence reflects how often these basic operations recur within larger expressions across software. Once learned, these rules can be applied and composed at many source sites. Table D.1 in Appendix D reports per-software counts for the ten most frequently observed rules.
Token Cost. ForTress adds reusable rule generation and Lean proof to the direct LLM baseline's minimal core. With this additional determinism and assurance, its LLM token cost remains lower than the direct LLM. Figure 10 shows token cost against model requests for three settings. These settings are Direct LLM using Opus 5.5, full ForTress (Rule+Assurance), and a Rule-only ForTress without assurance. Because executable rules and Lean assurance are integrated in ForTress, we estimate the Rule-only cost by excluding requests issued by the Auditor.
All three start from a common 1,721 to translate the 15 scientific software, compared with 760 for Rule-only ForTress. Adding reusable rules reduces the recorded cost by 55.8%, and including assurance still leaves ForTress 44.2% below Direct LLM.
Rule-only and Rule+Assurance initially cost slightly more than Direct LLM. Developing reusable rules requires identifying source patterns, implementing emission logic, and validating applicability, while assurance adds semantic definitions, proof obligations, and proof generation. These activities incur costs before the resulting rules are reused across software and start offsetting the cost.
From Figure 10, we can also observe that Rule-only and Rule+Assurance use more request rounds than Direct LLM but still have lower costs. This is because their requests are of different types. Direct LLM translates and repairs files and constructs validation fixtures and reference outputs. Rule-only develops reusable translation rules, while Rule+Assurance additionally develops semantic definitions and proofs. Requests also contain different proportions of uncached input, output (including thinking), cache reads, and cache writes, which are priced differently. Within the accounted scope, Direct LLM produces 25.88 million output tokens and writes 65.63 million tokens to the prompt cache, compared with 8.95 million and 21.04 million for Rule-only, and 11.36 million and 32.53 million for Rule+Assurance. Both rule-based settings thus use fewer of the more expensive output and cache-write tokens. Instead, lower-priced cache reads account for 98.7% of Rule-only's tokens and 98.4% of Rule+Assurance's, compared with 97.4% for Direct LLM.
6 Threats to Validity
Though our evaluation contains 15 scientific software across different domains, their results may not generalize to unexecuted branches, longer trajectories, or other language constructs. All evaluated systems supplied development examples, limiting conclusions about transfer to unseen software.
Felleisen’s notion of macro-expressibility makes expressibility relative to restrictions on behavior-preserving translations [Felleisen 1991]. Our successful translations do not establish that reusable rules can cover all Fortran constructs and behaviors. For a fixed rule model, target runtime, and preservation criterion, the permitted rule compositions impose an upper bound on achievable coverage. Our rule library continues to expand, but we have not characterized this bound or quantified the gap between current and maximally achievable coverage. We also have no completeness guarantee that our generation and refinement process can reach that bound. The six routines retained in Fortran in Section 5.2 illustrate limitations in the current system’s support for cross-language data transfer and access to application state. We plan to address these cases with targeted runtime and interface templates, whose effectiveness and generality remain to be established.
Output normalization and controlled initialization restrict the behaviors compared by the tests. The observed bitwise-identical holds under the recorded compiler and runtime versions, optimization settings, mathematical libraries, and hardware configurations. Different environments may change operation lowering and floating-point rounding, as illustrated by the libmvec and exponentiation cases. Numerical agreement therefore requires renewed validation when these configurations change. Different task boundaries, omitted development costs, and the absence of an application-level LLM repair comparison prevent estimating total migration savings. Finally, formal results depend on the modeled semantics and their correspondence with production rules. Exact-arithmetic proofs alone do not establish IEEE floating-point equivalence.
7 Related Work
LLM-driven code translation. Recent neural and large-language-model approaches have substantially expanded the range of translations that can be automated. TransCoder [Rozière et al. 2020] demonstrated unsupervised neural translation among C++, Java, and Python, evaluating functional correctness through unit tests. Pan et al. [Pan et al. 2024] identified frequent functional bugs and a taxonomy of failures in LLM-generated translations of real-world programs. FLOURINE [Eniser et al. 2024] uses differential fuzzing to compare source programs with LLM-generated Rust translations and feeds counterexamples back to the model for iterative repair. AlphaTrans [Ibrahimzada et al. 2025] scales LLM-driven translation to repository-level programs by combining program analysis, compositional translation, and multi-level execution-based validation. These systems primarily improve translation coverage, generation quality, or validation of individual generated programs.
ForTress distills recurring LLM-generated transformations into executable rules to amortize inference cost. Reuse can also propagate translation errors, so we audit the rules' semantic preservation claims over a modeled Fortran-to-Python subset. Execution-based validation provides concrete feedback, while formal reasoning checks whether a rule generalizes beyond the observed instances.
Verified compilation and verified rewrite rules. A large body of work provides strong correctness guarantees by formally verifying compilers or program transformations. CompCert [Leroy 2009] establishes semantic preservation for a realistic optimizing C compiler using machine-checked proofs. Subsequent systems have explored how to make verified compilation more extensible. XCert [Tatlock and Lerner 2010] extends CompCert with a verified execution engine for optimizations written in a domain-specific language, allowing new optimizations to inherit the correctness guarantee of the engine. More recently, Pyrosome [Jamner et al. 2025] develops an extensible framework in which new language features and compilation rules can be added while reusing existing correctness results.
Our work is particularly related to systems that verify individual rewrite rules. Alive [Lopes et al. 2015] provides a domain-specific language for LLVM peephole optimizations and automatically proves rules correct or produces counterexamples, exposing eight incorrect optimizations among more than 300 formalized rules. Formal models have similarly been used to show that seemingly standard compiler transformations can be invalid under subtle language semantics, such as the C11 memory model [Vafeiadis et al. 2015]. Verified tensor scheduling [Liu et al. 2022] constructs source-to-source optimizations from reusable, semantics-preserving high-level rewrites.
ForTress shares this focus on reusable transformations but derives its rules from translation and debugging in an existing LLM-driven system. The rules remain production Python translation logic. For a selected subset, LLM assistance produces mechanized Fortran and Python semantics and Lean preservation obligations. Human experts review both the semantic models and each obligation's correspondence with its executable rule. Lean checks the resulting proofs or refutations. This provides a formal audit of production rules without requiring the translator to be implemented in a verified framework.
Translation validation and equivalence checking. Translation validation checks semantic consistency between source and target programs produced by a particular compilation, rather than proving the compiler implementation correct. Necula [Necula 2000] introduced translation validation for an optimizing compiler by comparing programs before and after optimization passes. Later work improves the ability to align and compare programs whose source and target control structures differ. Semantic program alignment, for example, uses concrete executions to discover alignments from which equivalence-friendly product programs are constructed [Churchill et al. 2019].
Translation validation has also been deployed at substantial scale in production compilers. Alive2 [Lopes et al. 2021] performs bounded translation validation over LLVM IR without requiring modifications to LLVM and has uncovered numerous miscompilations and ambiguities in the IR semantics. ARM-TV [Berger et al. 2025] extends this approach across the larger semantic gap from LLVM IR to AArch64 code and reports dozens of previously unknown backend miscompilations. Related work on trustworthy program verifiers validates the actual translation performed by verifier front-ends by generating independently checkable proofs relating source programs to their generated intermediate-verification-language programs [Parthasarathy et al. 2024]. These approaches importantly emphasize that correctness of an idealized translation does not by itself establish correctness of the implementation that performs the translation.
Our audit targets reusable translation rules. A checked proof establishes preservation for every modeled instance satisfying the rule’s premises, so the assurance can be reused with the rule. A checked refutation identifies a counterexample to that generalization. Applying either result to production depends on human-reviewed correspondences between language behavior and mechanized semantics and between executable rules and obligations.
8 Conclusion
We presented ForTress, an approach to bring assurance and determinism for LLM-driven Fortran-to-Python translation. ForTress turns recurring LLM-generated transformations into executable rules for deterministic reuse and introduces Lean proof to provide assurance and an additional feedback channel. We evaluated ForTress on 17 benchmarks from 15 scientific software. The translated Python achieved bitwise agreement with native Fortran on all evaluated benchmark tests under the recorded execution and initialization configurations. Across these software, ForTress accumulated 193 executable rules and 188 audit records, of which 121 have checked soundness proofs, including 31 established after counterexample-guided refinement. Cross-software reuse exceeded 90% for 14 of the 15 systems, and LLM usage costs were 44.2% lower than direct LLM translation even with additional assurance and determinism. Further work will expand the modeled language fragments and interoperability support and explore application to other language pairs.
Data-Availability Statement
ForTress is released as part of RecastEngine [RecastEngine 2026].
References
AER. 2020a. RRTMG-SW. https://github.com/AER-RC/RRTMG_SW/tree/286e84ed14f61e2279ba819f4ce512a30b48f0b3
AER. 2020b. RRTMG-SW standard-atmosphere examples. https://github.com/AER-RC/RRTMG_SW/tree/286e84ed14f61e2279ba819f4ce512a30b48f0b3/run_examples_std_atm
AER. 2025a. RRTMG-LW. https://github.com/AER-RC/RRTMG_LW/tree/958edb1ad1618d76d0fcc5a9dc2e3c2f791a54dd
AER. 2025b. RRTMG-LW standard-atmosphere examples. https://github.com/AER-RC/RRTMG_LW/tree/958edb1ad1618d76d0fcc5a9dc2e3c2f791a54dd/run_examples_std_atm
Ryan Berger, Mitch Briles, Nader Boushehrinejad Moradi, Nicholas Coughlin, Kait Lam, Nuno P. Lopes, Stefan Mada, Tanmay Tirpankar, and John Regehr. 2025. Translation Validation for LLVM's AArch64 Backend. Proceedings of the ACM on Programming Languages 9, OOPSLA2 (2025). doi:10.1145/3763147
CAM-SIMA. 2026. Community Atmosphere Model – System for Integrated Modeling of the Atmosphere (CAM-SIMA). https://github.com/ESCOMP/CAM-SIMA/tree/47e1e6303951d999f6939bdffff829f682a2e081
CARMA. 2026a. CARMA regression-test definitions. https://github.com/ESCOMP/CARMA/blob/26b30b2738566de5d3979c1b2ccf191dd78c1207/tests/CMakeLists.txt
CARMA. 2026b. Community Aerosol and Radiation Model for Atmospheres (CARMA). https://github.com/ESCOMP/CARMA/tree/26b30b2738566de5d3979c1b2ccf191dd78c1207
CESM. 2026a. CAM-SIMA: Held–Suarez test configuration. https://github.com/ESCOMP/CAM-SIMA/tree/47e1e6303951d999f6939bdffff829f682a2e081/cime_config/testdefs/testmods_DIRS/cam/outfrq_held_suarez_derecho
CESM. 2026b. CAM-SIMA: Kessler test configuration. https://github.com/ESCOMP/CAM-SIMA/tree/47e1e6303951d999f6939bdffff829f682a2e081/cime_config/testdefs/testmods_DIRS/cam/outfrq_kessler_derecho
CESM. 2026c. CAM-SIMA physics test configurations: TJ2016 before and after the coupler. https://github.com/ESCOMP/CAM-SIMA/tree/47e1e6303951d999f6939bdffff829f682a2e081/cime_config/testdefs/testmods_DIRS/cam
CFMIP. 2026. COSP2 offline test: UKMO input configuration. https://github.com/CFMIP/COSPv2.0/blob/5eb05e51187dd2d0e448b78c4e6b28e1d6f65493/driver/run/cosp2_input_nl.txt#L38
Berkeley Churchill, Oded Padon, Rahul Sharma, and Alex Aiken. 2019. Semantic Program Alignment for Equivalence Checking. In Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation.
CISM. 2026a. CISM Halfar test case. https://github.com/ESCOMP/cism/tree/46e27de479f061ce7c0e96a148d3e7af7f65e461/tests/halfar
CISM. 2026b. Community Ice Sheet Model (CISM). https://github.com/ESCOMP/cism/tree/46e27de479f061ce7c0e96a148d3e7af7f65e461
CLUBB. 2026a. Cloud Layers Unified By Binormals (CLUBB). https://github.com/larson-group/clubb_release/tree/8ab3902e812c2883976b4f1f57c085d682666d92
CLUBB. 2026b. CLUBB single-column benchmark case setups. https://github.com/larson-group/clubb_release/tree/8ab3902e812c2883976b4f1f57c085d682666d92/input/case_setups
COSP2. 2026. CFMIP Observation Simulator Package, Version 2 (COSP2). https://github.com/CFMIP/COSPv2.0/tree/5eb05e51187dd2d0e448b78c4e6b28e1d6f65493
CVMix. 2026a. Community Ocean Vertical Mixing (CVMix). https://github.com/CVMix/CVMix-src/tree/fce422195a0c58f15a55946b5ed517ba4365e232
CVMix. 2026b. CVMix regression tests. https://github.com/CVMix/CVMix-src/tree/fce422195a0c58f15a55946b5ed517ba4365e232/reg_tests
Duo. 2026a. Duo. https://github.com/Trovemaster/Duo/tree/04b4718955fedf3eb551fb36019beabac225a3af
Duo. 2026b. Duo output benchmarks. https://github.com/Trovemaster/Duo/tree/04b4718955fedf3eb551fb36019beabac225a3af/benchmarks
Hasan Ferit Eniser, Hanliang Zhang, Cristina David, Meng Wang, Maria Christakis, Brandon Paulsen, Joey Dodds, and Daniel Kroening. 2024. Towards Translating Real-World Code with LLMs: A Study of Translating to Rust. arXiv preprint arXiv:2405.11514. doi:10.48550/arXiv.2405.11514
FATES. 2026a. FATES leaf-biophysics smoke test. https://github.com/NGEET/fates/blob/5a3c441ceeb141c35e87a33eeb2c168cc367b6f1/functional_unit_testing/leaf_biophys/DriveSmokeTestLeafBiophys.py
FATES. 2026b. Functionally Assembled Terrestrial Ecosystem Simulator (FATES). https://github.com/NGEET/fates/tree/5a3c441ceeb141c35e87a33eeb2c168cc367b6f1
Matthias Felleisen. 1991. On the Expressive Power of Programming Languages. Science of Computer Programming 17, 1–3 (1991), 35–75. doi:10.1016/0167-6423(91)90036-W
GCC Developers. 2024. Other Built-in Functions (GCC 14.2.0). Using the GNU Compiler Collection. https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Other-Builtins.html
GCC Developers. 2026. GNU Fortran Exponentiation Lowering. GCC source code, gcc/fortran/trans-expr.cc. https://codebrowser.dev/gcc/gcc/fortran/trans-expr.cc.html
Paolo Giannozzi, O. Andreussi, T. Brumme, O. Bunau, M. Buongiorno Nardelli, M. Calandra, R. Car, C. Cavazzoni, D. Ceresoli, M. Cococcioni, N. Colonna, I. Carnimeo, A. Dal Corso, S. de Gironcoli, P. Delugas, R. A. DiStasio, Jr., A. Ferretti, A. Floris, G. Fratesi, G. Fugallo, R. Gebauer, U. Gerstmann, F. Giustino, T. Gorni, J. Jia, M. Kawamura, H.-Y. Ko, A. Kokalj, E. Küçükbenli, M. Lazzeri, M. Marsili, N. Marzari, F. Mauri, N. L. Nguyen, H.-V. Nguyen, A. Otero de-la Roza, L. Paulatto, S. Poncé, D. Rocca, R. Sabatini, B. Santra, M. Schlipf, A. P. Seitsonen, A. Smogunov, I. Timrov, T. Thonhauser, P. Umari, N. Vast, X. Wu, and S. Baroni. 2017. Advanced capabilities for materials modelling with QUANTUM ESPRESSO. Journal of Physics: Condensed Matter 29, 46 (2017), 465901. doi:10.1088/1361-648X/aa8f79
Paolo Giannozzi, Stefano Baroni, Nicola Bonini, Matteo Calandra, Roberto Car, Carlo Cavazzoni, Davide Ceresoli, Guido L. Chiarotti, Matteo Cococcioni, Ismaila Dabo, Andrea Dal Corso, Stefano Fabris, Guido Fratesi, Stefano de Gironcoli, Ralph Gebauer, Uwe Gerstmann, Christos Gougoussis, Anton Kokalj, Michele Lazzeri, Layla Martin-Samos, Nicola Marzari, Francesco Mauri, Riccardo Mazzarello, Stefano Paolini, Alfredo Pasquarello, Lorenzo Paulatto, Carlo Sbraccia, Sandro Scandolo, Gabriele Sclauzero, Ari P. Seitsonen, Alexander Smogunov, Paolo Umari, and Renata M. Wentzcovitch. 2009. QUANTUM ESPRESSO: a modular and open-source software project for quantum simulations of materials. Journal of Physics: Condensed Matter 21, 39 (2009), 395502. doi:10.1088/0953-8984/21/39/395502
Dion Häfner, René Löwe Jacobsen, Carsten Eden, Mads R. B. Kristensen, Markus Jochum, Roman Nuterman, and Brian Vinter. 2018. Veros v0.1 – a fast and versatile ocean simulator in pure Python. Geoscientific Model Development 11, 8 (2018), 3299–3312. doi:10.5194/gmd-11-3299-2018
Dion Häfner, Roman Nuterman, and Markus Jochum. 2021. Fast, Cheap, and Turbulent—Global Ocean Modeling With GPU Acceleration in Python. Journal of Advances in Modeling Earth Systems 13 (2021), e2021MS002717. doi:10.1029/2021MS002717
Ali Reza Ibrahimzada, Kaiyao Ke, Mrigank Pawagi, Muhammad Salman Abid, Rangeet Pan, Saurabh Sinha, and Reyhaneh Jabbarvand. 2025. AlphaTrans: A Neuro-Symbolic Compositional Approach for Repository-Level Code Translation and Validation. Proceedings of the ACM on Software Engineering 2, FSE (2025). doi:10.1145/3729379
J3 Fortran Committee. 2018. Fortran 2018 Interpretation Document. Technical Report J3/18-007r1. PL22.3 and WG5. Sections 16.9.12 (ANINT) and 16.9.141 (NINT). https://j3-fortran.org/doc/year/18/18-007r1.pdf
Dustin Jamner, Gabriel Kammer, Ritam Nag, and Adam Chlipala. 2025. Pyrosome: Verified Compilation for Modular Metatheory. Proceedings of the ACM on Programming Languages 9, OOPSLA2 (2025). doi:10.1145/3763052
Nikolay V. Koldunov, Suvarchal K. Cheedela, Sergey Danilov, Dmitry Sidorenko, Sebastian Beyer, and Thomas Jung. 2026. An Ocean Model Ported by a Large Language Model: Experience and Lessons from FESOM2 (Fortran to C to C++/Kokkos). arXiv preprint arXiv:2606.11356. doi:10.48550/arXiv.2606.11356
Steve Koppes. 2024. Exascale Computing Project Software Helps Launch a New Era for NASA. Exascale Computing Project. https://www.exascaleproject.org/exascale-computing-project-software-helps-launch-a-new-era-for-nasa/
Aya Lahlou, Linnia Hawkins, and Pierre Gentine. 2026. Systematic LLM Translation of Legacy Scientific Code to Differentiable Frameworks: Application to a Land Surface Model. arXiv preprint arXiv:2606.07681. doi:10.48550/arXiv.2606.07681
Lawrence Livermore National Laboratory. 2025. ECP Leadership Team Recognized with Secretary of Energy's Honor Award. https://software.llnl.gov/news/2025/01/17/ecpdoe/
Xavier Leroy. 2009. Formal Verification of a Realistic Compiler. Commun. ACM 52, 7 (2009), 107–115. doi:10.1145/1538788.1538814
Amanda Liu, Gilbert Louis Bernstein, Adam Chlipala, and Jonathan Ragan-Kelley. 2022. Verified Tensor-Program Optimization via High-Level Scheduling Rewrites. Proceedings of the ACM on Programming Languages 6, POPL (2022), 1–28. doi:10.1145/3498717
Nuno P. Lopes, Juneyoung Lee, Chung-Kil Hur, Zhengyang Liu, and John Regehr. 2021. Alive2: Bounded Translation Validation for LLVM. In Proceedings of the 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation. doi:10.1145/3453483.3454030
Nuno P. Lopes, David Menendez, Santosh Nagarakatte, and John Regehr. 2015. Provably Correct Peephole Optimizations with Alive. In Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and Implementation. doi:10.1145/2737924.2737965
MARBL. 2020a. MARBL regression tests. https://github.com/marbl-ecosys/MARBL/tree/6b2a5e41dc5b0faaf9b600c96432e2487515e878/tests/regression_tests
MARBL. 2020b. MARine Biogeochemistry Library (MARBL). https://github.com/marbl-ecosys/MARBL/tree/6b2a5e41dc5b0faaf9b600c96432e2487515e878
Etienne Meunier, Said Ouala, Hugo Frezat, Julien Le Sommer, and Ronan Fablet. 2025. Towards Fully Differentiable Neural Ocean Model with Veros. arXiv preprint arXiv:2511.17427. doi:10.48550/arXiv.2511.17427
MFC. 2026. Multicomponent Flow Code (MFC). https://github.com/MFlowCode/MFC/tree/1ececa3456a5ee57807327a4deebacdd723d0fa6
MFlowCode. 2026. MFC regression tests: boundary-condition case generation. https://github.com/MFlowCode/MFC/blob/1ececa3456a5ee57807327a4deebacdd723d0fa6/toolchain/mfc/test/cases.py#L344-L346
George C. Necula. 2000. Translation Validation for an Optimizing Compiler. In Proceedings of the ACM SIGPLAN 2000 Conference on Programming Language Design and Implementation. 83–94. doi:10.1145/349299.349314
NJOY. 2026. NJOY2016 test cases. https://github.com/njoy/NJOY2016/tree/ac5adf5f33d893e42f2eed7fb286b0d51c7580da/tests
NJOY2016. 2026. NJOY2016. https://github.com/njoy/NJOY2016/tree/ac5adf5f33d893e42f2eed7fb286b0d51c7580da
NumPy Developers. [n. d.]. numpy.round. NumPy reference documentation. Default decimals=0; ties-to-even rounding. Accessed 29 September 2026. https://numpy.org/doc/stable/reference/generated/numpy.round.html
Rangeet Pan, Ali Reza Ibrahimzada, Rahul Krishna, Divya Sankar, Lambert Pouguem Wassi, Michele Merler, Boris Sobolev, Raju Pavuluri, Saurabh Sinha, and Reyhaneh Jabbarvand. 2024. Lost in Translation: A Study of Bugs Introduced by Large Language Models while Translating Code. In Proceedings of the 46th IEEE/ACM International Conference on Software Engineering. doi:10.1145/3597503.3639226
Gaurav Parthasarathy, Thibault Dardinier, Benjamin Bonneau, Peter Müller, and Alexander J. Summers. 2024. Towards Trustworthy Automated Program Verifiers: Formally Validating Translations into an Intermediate Verification Language. Proceedings of the ACM on Programming Languages 8, PLDI (2024). doi:10.1145/3656438
PyCAM5. 2026. PyCAM5 Translation Status. https://a85tract.github.io/PyCAM5/status/
Python Software Foundation. 2026. CPython Floating-Point Power Implementation. CPython source code, Objects/floatobject.c. https://github.com/python/cpython/blob/main/Objects/floatobject.c
QE. 2026. Quantum ESPRESSO. https://github.com/QEF/q-e/tree/61569eb480231b649c47f631df9c5c83537df461
QEF. 2026a. Quantum ESPRESSO: DFT-D3 test program. https://github.com/QEF/q-e/blob/61569eb480231b649c47f631df9c5c83537df461/dft-d3/test_code.f90
QEF. 2026b. Quantum ESPRESSO: XClib tests. https://github.com/QEF/q-e/tree/61569eb480231b649c47f631df9c5c83537df461/XClib
RAMSES. 2026a. RAMSES. https://github.com/ramses-organisation/ramses/tree/5f0ed46289f8eed71b2abd0e482f953bcaa02934
RAMSES. 2026b. RAMSES hydrodynamics tests. https://github.com/ramses-organisation/ramses/tree/5f0ed46289f8eed71b2abd0e482f953bcaa02934/tests/hydro
RecastEngine. 2026. RecastEngine: The Modernization Engine of SciRecast. GitHub repository. https://github.com/a85tract/RecastEngine
Baptiste Rozière, Marie-Anne Lachaux, Lowik Chanussot, and Guillaume Lample. 2020. Unsupervised Translation of Programming Languages. In Advances in Neural Information Processing Systems.
Zachary Tatlock and Sorin Lerner. 2010. Bringing Extensibility to Verified Compilers. In Proceedings of the 31st ACM SIGPLAN Conference on Programming Language Design and Implementation.
Viktor Vafeiadis, Thibaut Balabonski, Soham Chakraborty, Robin Morisset, and Francesco Zappa Nardelli. 2015. Common Compiler Optimisations Are Invalid in the C11 Memory Model and What We Can Do about It. In Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL '15). Association for Computing Machinery, New York, NY, USA, 209–220. doi:10.1145/2676726.2676995
WW III. 2026. WAVEWATCH III regression tests. https://github.com/NOAA-EMC/WW3/tree/a0eaffebde6246e096f240509c9acf159fe09003/regtests
WW3. 2026. WAVEWATCH III. https://github.com/NOAA-EMC/WW3/tree/a0eaffebde6246e096f240509c9acf159fe09003
Sergei N. Yurchenko, Lorenzo Lodi, Jonathan Tennyson, and Andrey V. Stolyarov. 2016. Duo: A General Program for Calculating Spectra of Diatomic Molecules. Computer Physics Communications 202 (2016), 262–275. doi:10.1016/j.cpc.2015.12.021
A Executable Rule Categories
Table A.1. Categories of the 193 registered executable rule definitions. The registry contains 29 categories, with the 18 smaller categories combined in the final entry.
| Category | # | Category | # | Category | # | Category | # |
|---|---|---|---|---|---|---|---|
| Precision/kind | 23 | Arithmetic | 9 | Control flow | 17 | Indexing | 9 |
| Env. iface. | 17 | Memory ops. | 9 | Procedures | 12 | Reductions | 7 |
| Array trans. | 10 | Spec. intr. | 7 | I/O | 10 | Other (18) | 63 |
B Lean Proof Categories
Table B.1. Families of Lean proofs with representative theorem declarations. The examples include preservation theorems, results under additional premises, and checked refutations.
| Category | Representative theorem | Category | Representative theorem |
|---|---|---|---|
| Literals/names | FNP_R0001_sound | Array stores | FNP_R0113_sound |
| FNP_R0010_sound | |||
| Arithmetic | FNP_R0026_sound | Array transforms | FNP_R0106_cshift_sound |
| Comparison/logic | FNP_R0034_sound | Reductions | FNP_R0101_sound |
| Character ops. | FNP_R0085_trim_sound | Procedure calls | FNP_R0141_refuted_unknown |
| Scalar intrinsics | FNP_R0062_sound | Control flow | FNP_R0123_sound |
| Elemental lifting | lift2_rel | Sequence assoc. | FNP_R0056_sound |
| Array indexing | element_sound | Composition | trans_sound |
| transStmt_sound | |||
| Array sections | FNP_R0044_sound | Whole kernels | saxpy_sound |
C Single-source Rule Coverage
Single-source rule coverage
Rule source software (one source at a time)
Target software
| CLUBB | RRTMG | CISM | WW3 | COSP2 | CARMA | CVMix | MARBL | FATES | MFC | QE | RAMSES | NJOY2016 | Duo | CAM-SIMA | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| CLUBB | - | 61 | 80 | 79 | 86 | 71 | 66 | 70 | 54 | 70 | 66 | 52 | 59 | 59 | 61 |
| RRTMG | 76 | - | 82 | 82 | 84 | 80 | 69 | 73 | 60 | 73 | 76 | 64 | 71 | 71 | 60 |
| CISM | 63 | 51 | - | 79 | 79 | 68 | 56 | 63 | 43 | 64 | 61 | 44 | 50 | 58 | 53 |
| WW3 | 59 | 50 | 77 | - | 85 | 72 | 53 | 59 | 45 | 59 | 61 | 45 | 57 | 57 | 49 |
| COSP2 | 52 | 41 | 62 | 68 | - | 57 | 43 | 50 | 35 | 48 | 47 | 33 | 43 | 45 | 39 |
| CARMA | 58 | 52 | 71 | 77 | 75 | - | 54 | 58 | 45 | 57 | 57 | 42 | 59 | 57 | 51 |
| CVMix | 86 | 72 | 93 | 91 | 93 | 86 | - | 81 | 65 | 84 | 77 | 63 | 72 | 81 | 70 |
| MARBL | 76 | 65 | 88 | 86 | 90 | 78 | 69 | - | 57 | 80 | 73 | 51 | 57 | 63 | 57 |
| FATES | 91 | 82 | 94 | 100 | 97 | 94 | 85 | 88 | - | 88 | 85 | 73 | 79 | 82 | 85 |
| MFC | 80 | 67 | 94 | 90 | 90 | 80 | 73 | 84 | 59 | - | 80 | 59 | 67 | 73 | 69 |
| QE | 76 | 69 | 90 | 92 | 88 | 80 | 67 | 76 | 57 | 80 | - | 63 | 71 | 71 | 65 |
| RAMSES | 85 | 85 | 94 | 97 | 88 | 85 | 79 | 76 | 71 | 85 | 91 | - | 79 | 91 | 71 |
| NJOY2016 | 66 | 64 | 72 | 84 | 80 | 82 | 62 | 58 | 52 | 66 | 70 | 54 | - | 66 | 58 |
| Duo | 67 | 65 | 86 | 86 | 84 | 80 | 71 | 65 | 55 | 73 | 71 | 63 | 67 | - | 61 |
| CAM-SIMA | 85 | 68 | 95 | 90 | 90 | 88 | 75 | 73 | 70 | 85 | 80 | 60 | 73 | 75 | - |
Reuse (%)
100
Excluded
Fig. C.1. Single-source coverage of observed translation rules across 15 software systems. Each column independently supplies only that source software's observed rules. Each number is the rounded percentage of the target software's observed rule types that also occur in the column software: . Repeated events count once per rule type. The denominator belongs to the row target, so coverage is directional. Gray diagonal cells exclude self-comparisons.
D Frequently Reused Translation Rules
Table D.1. Per-software event counts for the ten most frequently observed registered translation rules, ordered by total frequency. Counts include all recorded outcomes, including rewritten, discarded, and rollback-marked emissions. CAM-SIMA combines its three cases, counting shared events once. Zero denotes no captured matching event.
| Rule | QE | MFC | NOV2016 | RAMSEs | Duo | CVMix | MARBL | RRTMG | COSP2 | CARM4 | FATEs | CISM | WW3 | CAM-SIMA | CLUBB |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| R-name.reference | 14295 | 18215 | 5792 | 3609 | 900 | 2239 | 7033 | 6769 | 11629 | 12014 | 1620 | 21853 | 11826 | 1513 | 32165 |
| R-index.shift_unit | 1929 | 3631 | 1094 | 1172 | 197 | 430 | 3201 | 3825 | 3831 | 5424 | 46 | 7735 | 3625 | 935 | 12022 |
| R-arithmetic. | |||||||||||||||
| scalar_fallback | 9402 | 8057 | 2594 | 1004 | 450 | 854 | 1988 | 2877 | 798 | 4303 | 477 | 4019 | 1952 | 581 | 4689 |
| R-index. | |||||||||||||||
| array_reference | 2281 | 6853 | 990 | 807 | 141 | 648 | 1852 | 3780 | 2875 | 1439 | 72 | 4830 | 4348 | 595 | 6822 |
| R-literal. | |||||||||||||||
| hoisted_reference | 7218 | 884 | 1718 | 66 | 97 | 128 | 351 | 18958 | 1822 | 1783 | 134 | 1371 | 1191 | 47 | 435 |
| R-assignment. | |||||||||||||||
| ordinary | 3956 | 2807 | 1791 | 564 | 257 | 545 | 1173 | 2926 | 3170 | 3178 | 237 | 2989 | 3991 | 343 | 2826 |
| R-literal. | |||||||||||||||
| integer_inline | 834 | 3393 | 1426 | 536 | 454 | 306 | 270 | 2125 | 2074 | 1304 | 16 | 2685 | 2127 | 132 | 2981 |
| R-component.path | 0 | 2575 | 0 | 4 | 88 | 223 | 2493 | 82 | 4073 | 3954 | 55 | 3482 | 422 | 9 | 2825 |
| R-index. | |||||||||||||||
| sliceAscending | 229 | 202 | 0 | 42 | 10 | 65 | 1963 | 450 | 6588 | 1246 | 6 | 3575 | 157 | 99 | 3821 |
| R-index. | |||||||||||||||
| shift_declared | 177 | 7484 | 0 | 409 | 2 | 0 | 29 | 821 | 63 | 79 | 0 | 656 | 1330 | 0 | 4 |