November 2026 · Preprint

Proof-Carrying Modernization: LLM Translations of COBOL Batch Programs, Each Proved Against the Original in Lean

Abstract

Large language models translate legacy code quickly, but a translation can differ from the original on inputs that no test exercises. We show that LLM translations of whole, unmodified COBOL programs into Rust and Java can be proved in Lean 4 to behave like our semantics of the originals on every admissible input: a bounded number of well-formed records, among other premises. The COBOL semantics is executable; it computes record layouts, decimal arithmetic and file handling from our front end's output for the unmodified source. For the eight standalone batch programs of AWS CardDemo covered by that front end, all 16 translations are proved, as equivalences for Rust and as refinements with partial correctness for Java. The statements are generated from the programs except for a few small parts, LLM agents write the proofs, and Lean's kernel checks them. Before any proof, 35% of the first running translations differed from our semantics of the original on a generated input, and no proof found a difference that this testing had missed.

In plain words

Large organisations still run batch programs written in COBOL, and many plan to move them to Java or Rust. AI language models translate such programs quickly, but a translation can behave differently from the original on inputs that no test tried; in this study, about a third of the first translations that ran gave different results from the paper’s model of the original on generated test inputs. From CardDemo, a public mainframe application, the paper takes the eight batch programs that run on their own and that the paper’s tools can read. For each, it proves in the Lean proof assistant that a Rust translation and a Java translation behave like the original on every allowed input, with the original’s meaning as the paper defines it. For Java, the proof covers only the runs that finish.

A dot chart on white. Five rows, labelled Java plain prompt, Rust plain prompt, Java with guide 1, Rust with guide 1 and Java with guide 2, hold 21, 21, 24, 23 and 3 dots. In each row the orange dots come first, then the teal ones: 7 of 21, 13 of 21, 6 of 24, 4 of 23 and 2 of 3 dots are orange. A legend at the top explains the two colours, and a last line reads All 92 runs, 32 of 92 (35%).
Illustration of the paper’s Table 2. Each dot is one of the 92 counted runs in which a language model translated one of the eight CardDemo programs, grouped by arm (a plain prompt over real files, or one of two style guides over the verifier’s record interface) and by target language. A dot is orange when the first version of the translation that ran differed from the paper’s semantics of the COBOL program on a generated case, and teal when that version agreed with the semantics on every generated case: 32 of the 92 runs (35%) had a differing first version. With guide 1, 12 of the 23 first Rust versions did not build, so the dots show the first version that ran. Every run ended with a version that passed the tests, and 15 of the 16 translations proved in Lean come from these runs.

Formal statement and axioms

Each main result as stated in Lean, copied verbatim from the published package, with the axioms that the proof rests on. Lean v4.35.0, Mathlib 56a005855ea1. The package.

EquivLean.Modernize.Cbact01c.Rust.rust

For CBACT01C, the Rust translation’s equivalence, relative to the paper’s semantics of the COBOL program on every admissible input: kernel-only

theorem rust : Statement
Definitions used in the statement
def Statement : Prop :=
  ∀ (vals1 : List (List EquivLean.Cobol.Rec.FVal)),
    (∀ v ∈ vals1, AccountRecord.Valid v) →
    vals1.length < 2 ^ 28 →
    ∀ n : Nat, vals1.length < n →
    ∀ (s1 : Slice cbact01c.AccountRecord),
    AcctfileFileOf s1 vals1 →
    Equiv Rel (cbact01c.run s1)
      (EquivLean.Cobol.run CardDemo.Cbact01c { call := Cobol.Ext.cardDemoCalls CardDemo.Cbact01c.cfg } (n + 40)
        (CardDemo.Cbact01c.initState initMem [(1, vals1.map AccountRecord.encode)]))
def AcctfileFileOf (s : Slice cbact01c.AccountRecord) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  s.val.map AccountRecord.vals = vals
def Rel (o : Except Error cbact01c.Output) (os : Signal × Cobol.State) : Prop :=
  ∃ out, o = .ok out ∧
    out.displays.val.map (fun l => l.val.map (·.val)) = (displays os.2).map rustLine ∧
    (writes 2 os.2).map OutAcctRec.decode = out.out_file_writes.val.map (fun x => some (OutAcctRec.vals x)) ∧
    (writes 3 os.2).map ArrArrayRec.decode = out.arry_file_writes.val.map (fun x => some (ArrArrayRec.vals x)) ∧
    (writes 4 os.2).map rustLine = out.vbrc_file_writes.val.map (fun l => l.val.map (·.val)) ∧
    out.abended = abended os.1
def Equiv (R : OT → OS → Prop) (t : T) (s : S) : Prop :=
  Sim R t s ∧ Sim (fun os ot => R ot os) s t
def Sim (R : OT → OS → Prop) (t : T) (s : S) : Prop :=
  Safe s → Safe t ∧ ∀ ot, Runs t ot → ∃ os, Runs s os ∧ R ot os

Source.

The package does not record Lean’s axiom report for this theorem, but names the axioms in words: propext, Classical.choice, Quot.sound.

EquivLean.Modernize.Cbact01c.Java.java

For CBACT01C, the Java translation’s refinement with partial correctness, relative to the paper’s semantics of the COBOL program on every admissible input: kernel-only

theorem java : Statement
Definitions used in the statement
def Statement : Prop :=
  ∀ (vals1 : List (List EquivLean.Cobol.Rec.FVal)),
    (∀ v ∈ vals1, AccountRecord.Valid v) →
    vals1.length < 2 ^ 27 →
    ∀ n : Nat, vals1.length < n →
    ∀ (σ : Jimple.State) (a1 : Addr),
    AcctfileFileAt σ a1 vals1 →
    σ.initOf "Cbact01c" = .done →
    σ.initOf "Cbact01c$Result" = .done →
    σ.initOf "Cbact01c$AccountRecord" = .done →
    σ.initOf "Cbact01c$ArrArrayRec" = .done →
    σ.initOf "Cbact01c$OutAcctRec" = .done →
    Sim Rel (Call.mk Gen.prog runRef [.ref a1] σ)
      (EquivLean.Cobol.run CardDemo.Cbact01c { call := Cobol.Ext.cardDemoCalls CardDemo.Cbact01c.cfg } (n + 40)
        (CardDemo.Cbact01c.initState initMem [(1, vals1.map AccountRecord.encode)]))
abbrev runRef : MethodRef := Gen.Cbact01c.«run(Cbact01c$AccountRecord[])».ref
def AcctfileFileAt (σ : Jimple.State) (a : Addr) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  ∃ et xs, σ.heap a = some (.array et xs) ∧ xs.length < 2147483648 ∧
    Forall2 (JRecAt AccountRecord "Cbact01c$AccountRecord" σ) xs vals
def Rel (ot : Out) (os : Signal × Cobol.State) : Prop :=
  ∃ σ' res fs l k xs mods, ot = .normal (some (.ref res)) σ' ∧
    σ'.heap res = some (.plain "Cbact01c$Result" fs) ∧
    Fields.get fs ("Cbact01c$Result", "displays") = some (.ref l) ∧ σ'.heap l = some (.list k xs mods) ∧
    Forall2 (JLineAt σ') xs (displays os.2) ∧
    (∃ lw kw ws mw, Fields.get fs ("Cbact01c$Result", "outFileWrites") = some (.ref lw) ∧
      σ'.heap lw = some (.list kw ws mw) ∧
      Forall2 (fun x rec => ∃ vals, JRecAt OutAcctRec "Cbact01c$OutAcctRec" σ' x vals ∧
        OutAcctRec.decode rec = some vals) ws (writes 2 os.2)) ∧
    (∃ lw kw ws mw, Fields.get fs ("Cbact01c$Result", "arryFileWrites") = some (.ref lw) ∧
      σ'.heap lw = some (.list kw ws mw) ∧
      Forall2 (fun x rec => ∃ vals, JRecOccAt ArrArrayRec "Cbact01c$ArrArrayRec" σ' x vals ∧
        ArrArrayRec.decode rec = some vals) ws (writes 3 os.2)) ∧
    (∃ lw kw ws mw, Fields.get fs ("Cbact01c$Result", "vbrcFileWrites") = some (.ref lw) ∧
      σ'.heap lw = some (.list kw ws mw) ∧
      Forall2 (JLineAt σ') ws (writes 4 os.2)) ∧
    Fields.get fs ("Cbact01c$Result", "abended") = some (.int (if abended os.1 then 1 else 0))
def Sim (R : OT → OS → Prop) (t : T) (s : S) : Prop :=
  Safe s → Safe t ∧ ∀ ot, Runs t ot → ∃ os, Runs s os ∧ R ot os

Source.

The package does not record Lean’s axiom report for this theorem, but names the axioms in words: propext, Classical.choice, Quot.sound.

EquivLean.Modernize.Cbact02c.Rust.rust

For CBACT02C, the Rust translation’s equivalence, relative to the paper’s semantics of the COBOL program on every admissible input: kernel-only

theorem rust : Statement
Definitions used in the statement
def Statement : Prop :=
  ∀ (vals1 : List (List EquivLean.Cobol.Rec.FVal)),
    (∀ v ∈ vals1, CardRecord.Valid v) →
    vals1.length < 2 ^ 28 →
    ∀ n : Nat, vals1.length < n →
    ∀ (s1 : Slice cbact02c.CardRecord),
    CardfileFileOf s1 vals1 →
    Equiv Rel (cbact02c.run s1)
      (EquivLean.Cobol.run CardDemo.Cbact02c {} (n + 20)
        (CardDemo.Cbact02c.initState initMem [(1, vals1.map CardRecord.encode)]))
def CardfileFileOf (s : Slice cbact02c.CardRecord) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  s.val.map CardRecord.vals = vals
def Rel (o : Except Error cbact02c.Output) (os : Signal × Cobol.State) : Prop :=
  ∃ out, o = .ok out ∧
    out.displays.val.map (fun l => l.val.map (·.val)) = (displays os.2).map rustLine ∧
    out.abended = abended os.1
def Equiv (R : OT → OS → Prop) (t : T) (s : S) : Prop :=
  Sim R t s ∧ Sim (fun os ot => R ot os) s t
def Sim (R : OT → OS → Prop) (t : T) (s : S) : Prop :=
  Safe s → Safe t ∧ ∀ ot, Runs t ot → ∃ os, Runs s os ∧ R ot os

Source.

The package does not record Lean’s axiom report for this theorem, but names the axioms in words: propext, Classical.choice, Quot.sound.

13 more formal statements

EquivLean.Modernize.Cbact02c.Java.java

For CBACT02C, the Java translation’s refinement with partial correctness, relative to the paper’s semantics of the COBOL program on every admissible input: kernel-only

theorem java : Statement
Definitions used in the statement
def Statement : Prop :=
  ∀ (vals1 : List (List EquivLean.Cobol.Rec.FVal)),
    (∀ v ∈ vals1, CardRecord.Valid v) →
    vals1.length < 2 ^ 27 →
    ∀ n : Nat, vals1.length < n →
    ∀ (σ : Jimple.State) (a1 : Addr),
    CardfileFileAt σ a1 vals1 →
    σ.initOf "Cbact02c" = .done →
    σ.initOf "Cbact02c$Result" = .done →
    σ.initOf "Cbact02c$CardRecord" = .done →
    Sim Rel (Call.mk Gen.prog runRef [.ref a1] σ)
      (EquivLean.Cobol.run CardDemo.Cbact02c {} (n + 20)
        (CardDemo.Cbact02c.initState initMem [(1, vals1.map CardRecord.encode)]))
abbrev runRef : MethodRef := Gen.Cbact02c.«run(Cbact02c$CardRecord[])».ref
def CardfileFileAt (σ : Jimple.State) (a : Addr) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  ∃ et xs, σ.heap a = some (.array et xs) ∧ xs.length < 2147483648 ∧
    Forall2 (JRecAt CardRecord "Cbact02c$CardRecord" σ) xs vals
def Rel (ot : Out) (os : Signal × Cobol.State) : Prop :=
  ∃ σ' res fs l k xs mods, ot = .normal (some (.ref res)) σ' ∧
    σ'.heap res = some (.plain "Cbact02c$Result" fs) ∧
    Fields.get fs ("Cbact02c$Result", "displays") = some (.ref l) ∧ σ'.heap l = some (.list k xs mods) ∧
    Forall2 (JLineAt σ') xs (displays os.2) ∧
    Fields.get fs ("Cbact02c$Result", "abended") = some (.int (if abended os.1 then 1 else 0))
def Sim (R : OT → OS → Prop) (t : T) (s : S) : Prop :=
  Safe s → Safe t ∧ ∀ ot, Runs t ot → ∃ os, Runs s os ∧ R ot os

Source.

The package does not record Lean’s axiom report for this theorem, but names the axioms in words: propext, Classical.choice, Quot.sound.

EquivLean.Modernize.Cbact03c.Rust.rust

For CBACT03C, the Rust translation’s equivalence, relative to the paper’s semantics of the COBOL program on every admissible input: kernel-only

theorem rust : Statement
Definitions used in the statement
def Statement : Prop :=
  ∀ (vals1 : List (List EquivLean.Cobol.Rec.FVal)),
    (∀ v ∈ vals1, CardXrefRecord.Valid v) →
    vals1.length < 2 ^ 28 →
    ∀ n : Nat, vals1.length < n →
    ∀ (s1 : Slice cbact03c.CardXrefRecord),
    XreffileFileOf s1 vals1 →
    Equiv Rel (cbact03c.run s1)
      (EquivLean.Cobol.run CardDemo.Cbact03c {} (n + 20)
        (CardDemo.Cbact03c.initState initMem [(1, vals1.map CardXrefRecord.encode)]))
def XreffileFileOf (s : Slice cbact03c.CardXrefRecord) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  s.val.map CardXrefRecord.vals = vals
def Rel (o : Except Error cbact03c.Output) (os : Signal × Cobol.State) : Prop :=
  ∃ out, o = .ok out ∧
    out.displays.val.map (fun l => l.val.map (·.val)) = (displays os.2).map rustLine ∧
    out.abended = abended os.1
def Equiv (R : OT → OS → Prop) (t : T) (s : S) : Prop :=
  Sim R t s ∧ Sim (fun os ot => R ot os) s t
def Sim (R : OT → OS → Prop) (t : T) (s : S) : Prop :=
  Safe s → Safe t ∧ ∀ ot, Runs t ot → ∃ os, Runs s os ∧ R ot os

Source.

The package does not record Lean’s axiom report for this theorem, but names the axioms in words: propext, Classical.choice, Quot.sound.

EquivLean.Modernize.Cbact03c.Java.java

For CBACT03C, the Java translation’s refinement with partial correctness, relative to the paper’s semantics of the COBOL program on every admissible input: kernel-only

theorem java : Statement
Definitions used in the statement
def Statement : Prop :=
  ∀ (vals1 : List (List EquivLean.Cobol.Rec.FVal)),
    (∀ v ∈ vals1, CardXrefRecord.Valid v) →
    vals1.length < 2 ^ 27 →
    ∀ n : Nat, vals1.length < n →
    ∀ (σ : Jimple.State) (a1 : Addr),
    XreffileFileAt σ a1 vals1 →
    σ.initOf "Cbact03c" = .done →
    σ.initOf "Cbact03c$Result" = .done →
    σ.initOf "Cbact03c$CardXrefRecord" = .done →
    σ.initOf "Cbact03c$State" = .done →
    Sim Rel (Call.mk Gen.prog runRef [.ref a1] σ)
      (EquivLean.Cobol.run CardDemo.Cbact03c {} (n + 20)
        (CardDemo.Cbact03c.initState initMem [(1, vals1.map CardXrefRecord.encode)]))
abbrev runRef : MethodRef := Gen.Cbact03c.«run(Cbact03c$CardXrefRecord[])».ref
def XreffileFileAt (σ : Jimple.State) (a : Addr) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  ∃ et xs, σ.heap a = some (.array et xs) ∧ xs.length < 2147483648 ∧
    Forall2 (JRecAt CardXrefRecord "Cbact03c$CardXrefRecord" σ) xs vals
def Rel (ot : Out) (os : Signal × Cobol.State) : Prop :=
  ∃ σ' res fs l k xs mods, ot = .normal (some (.ref res)) σ' ∧
    σ'.heap res = some (.plain "Cbact03c$Result" fs) ∧
    Fields.get fs ("Cbact03c$Result", "displays") = some (.ref l) ∧ σ'.heap l = some (.list k xs mods) ∧
    Forall2 (JLineAt σ') xs (displays os.2) ∧
    Fields.get fs ("Cbact03c$Result", "abended") = some (.int (if abended os.1 then 1 else 0))
def Sim (R : OT → OS → Prop) (t : T) (s : S) : Prop :=
  Safe s → Safe t ∧ ∀ ot, Runs t ot → ∃ os, Runs s os ∧ R ot os

Source.

The package does not record Lean’s axiom report for this theorem, but names the axioms in words: propext, Classical.choice, Quot.sound.

EquivLean.Modernize.Cbact04c.Every.Rust.rust

For CBACT04C, the Rust translation’s equivalence, relative to the paper’s semantics of the COBOL program on every admissible input: kernel-only

theorem rust : Statement
Definitions used in the statement
def Statement : Prop :=
  ∀ (vals1 : List (List EquivLean.Cobol.Rec.FVal)) (vals2 : List (List EquivLean.Cobol.Rec.FVal)) (vals3 : List (List EquivLean.Cobol.Rec.FVal)) (vals4 : List (List EquivLean.Cobol.Rec.FVal)),
    (∀ v ∈ vals1, TranCatBalRecord.Valid v) →
    (∀ v ∈ vals2, CardXrefRecord.Valid v) →
    (∀ v ∈ vals3, AccountRecord.Valid v) →
    (∀ v ∈ vals4, DisGroupRecord.Valid v) →
    ∀ (link1 : List EquivLean.Cobol.Rec.FVal), ExternalParms.Valid link1 →
    ∀ (clk : List UInt8), CurrentDate clk →
    EquivLean.Modernize.Cbact04c.Every.Domain vals1 vals2 vals3 vals4 link1 →
    vals1.length + vals2.length + vals3.length + vals4.length < 2 ^ 28 →
    ∀ n : Nat, vals1.length + vals2.length + vals3.length + vals4.length < n →
    ∀ (s1 : Slice cbact04c_t.TranCatBalRecord) (s2 : Slice cbact04c_t.CardXrefRecord) (s3 : Slice cbact04c_t.AccountRecord) (s4 : Slice cbact04c_t.DisGroupRecord) (q1 : cbact04c_t.ExternalParms) (rclk : Std.Array Std.U8 21#usize),
    TcatbalFileOf s1 vals1 →
    XrefFileOf s2 vals2 →
    AccountFileOf s3 vals3 →
    DiscgrpFileOf s4 vals4 →
    ExternalParms.vals q1 = link1 →
    rclk.val.map (·.val) = rustLine clk →
    Equiv Rel (cbact04c_t.run s1 s2 s3 s4 q1 rclk)
      (EquivLean.Cobol.run CardDemo.Cbact04c { clock := fun _ => clk } (n + 60)
        (CardDemo.Cbact04c.initState (Cobol.Mem.write initMem 1727 (ExternalParms.encode link1)) [(1, vals1.map TranCatBalRecord.encode), (2, vals2.map CardXrefRecord.encode), (3, vals3.map AccountRecord.encode), (4, vals4.map DisGroupRecord.encode)]))
def TcatbalFileOf (s : Slice cbact04c_t.TranCatBalRecord) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  s.val.map TranCatBalRecord.vals = vals
def XrefFileOf (s : Slice cbact04c_t.CardXrefRecord) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  s.val.map CardXrefRecord.vals = vals
def AccountFileOf (s : Slice cbact04c_t.AccountRecord) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  s.val.map AccountRecord.vals = vals
def DiscgrpFileOf (s : Slice cbact04c_t.DisGroupRecord) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  s.val.map DisGroupRecord.vals = vals
def Rel (o : Except Error cbact04c_t.Output) (os : Signal × Cobol.State) : Prop :=
  ∃ out, o = .ok out ∧
    out.displays.val.map (fun l => l.val.map (·.val)) = (displays os.2).map rustLine ∧
    (writes 5 os.2).map TranRecord.decode = out.transact_file_writes.val.map (fun x => some (TranRecord.vals x)) ∧
    (rewrites 3 os.2).map AccountRecord.decode = out.account_file_rewrites.val.map (fun x => some (AccountRecord.vals x)) ∧
    out.abended = abended os.1
def Equiv (R : OT → OS → Prop) (t : T) (s : S) : Prop :=
  Sim R t s ∧ Sim (fun os ot => R ot os) s t
def Sim (R : OT → OS → Prop) (t : T) (s : S) : Prop :=
  Safe s → Safe t ∧ ∀ ot, Runs t ot → ∃ os, Runs s os ∧ R ot os
def Domain (tcat _xrefs _accts _discs : List (List FVal)) (_link : List FVal) : Prop :=
  tcat.length < 999999 ∧
  ∀ i j k, i < j → j < k → k < tcat.length →
    tAcct (tcat.getD i []) = tAcct (tcat.getD k []) → tAcct (tcat.getD j []) = tAcct (tcat.getD i [])
def tAcct (t : List FVal) : Int := numOf (t.getD 0 default)

Source.

The package does not record Lean’s axiom report for this theorem, but names the axioms in words: propext, Classical.choice, Quot.sound.

EquivLean.Modernize.Cbact04c.Every.Java.java

For CBACT04C, the Java translation’s refinement with partial correctness, relative to the paper’s semantics of the COBOL program on every admissible input: kernel-only

theorem java : Statement
Definitions used in the statement
def Statement : Prop :=
  ∀ (vals1 : List (List EquivLean.Cobol.Rec.FVal)) (vals2 : List (List EquivLean.Cobol.Rec.FVal)) (vals3 : List (List EquivLean.Cobol.Rec.FVal)) (vals4 : List (List EquivLean.Cobol.Rec.FVal)),
    (∀ v ∈ vals1, TranCatBalRecord.Valid v) →
    (∀ v ∈ vals2, CardXrefRecord.Valid v) →
    (∀ v ∈ vals3, AccountRecord.Valid v) →
    (∀ v ∈ vals4, DisGroupRecord.Valid v) →
    ∀ (link1 : List EquivLean.Cobol.Rec.FVal), ExternalParms.Valid link1 →
    ∀ (clk : List UInt8), CurrentDate clk →
    EquivLean.Modernize.Cbact04c.Every.Domain vals1 vals2 vals3 vals4 link1 →
    vals1.length + vals2.length + vals3.length + vals4.length < 2 ^ 27 →
    ∀ n : Nat, vals1.length + vals2.length + vals3.length + vals4.length < n →
    ∀ (σ : Jimple.State) (a1 : Addr) (a2 : Addr) (a3 : Addr) (a4 : Addr) (p1 : Addr) (cs : Addr),
    TcatbalFileAt σ a1 vals1 →
    XrefFileAt σ a2 vals2 →
    AccountFileAt σ a3 vals3 →
    DiscgrpFileAt σ a4 vals4 →
    JRecAt ExternalParms "Cbact04c$ExternalParms" σ (.ref p1) link1 →
    JStrAt σ (.ref cs) (cp037Str clk) →
    σ.initOf "Cbact04c" = .done →
    σ.initOf "Cbact04c$Result" = .done →
    σ.initOf "Cbact04c$AccountRecord" = .done →
    σ.initOf "Cbact04c$CardXrefRecord" = .done →
    σ.initOf "Cbact04c$DisGroupRecord" = .done →
    σ.initOf "Cbact04c$TranCatBalRecord" = .done →
    σ.initOf "Cbact04c$ExternalParms" = .done →
    σ.initOf "Cbact04c$TranRecord" = .done →
    Sim Rel (Call.mk EquivLean.Modernize.Cbact04c.Java.Gen.prog runRef [.ref a1, .ref a2, .ref a3, .ref a4, .ref p1, .ref cs] σ)
      (EquivLean.Cobol.run CardDemo.Cbact04c { clock := fun _ => clk } (n + 60)
        (CardDemo.Cbact04c.initState (Cobol.Mem.write initMem 1727 (ExternalParms.encode link1)) [(1, vals1.map TranCatBalRecord.encode), (2, vals2.map CardXrefRecord.encode), (3, vals3.map AccountRecord.encode), (4, vals4.map DisGroupRecord.encode)]))
abbrev runRef : MethodRef := EquivLean.Modernize.Cbact04c.Java.Gen.Cbact04c.«run(Cbact04c$TranCatBalRecord[],Cbact04c$CardXrefRecord[],Cbact04c$AccountRecord[],Cbact04c$DisGroupRecord[],Cbact04c$ExternalParms,java.lang.String)».ref
def TcatbalFileAt (σ : Jimple.State) (a : Addr) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  ∃ et xs, σ.heap a = some (.array et xs) ∧ xs.length < 2147483648 ∧
    Forall2 (JRecAt TranCatBalRecord "Cbact04c$TranCatBalRecord" σ) xs vals
def XrefFileAt (σ : Jimple.State) (a : Addr) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  ∃ et xs, σ.heap a = some (.array et xs) ∧ xs.length < 2147483648 ∧
    Forall2 (JRecAt CardXrefRecord "Cbact04c$CardXrefRecord" σ) xs vals
def AccountFileAt (σ : Jimple.State) (a : Addr) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  ∃ et xs, σ.heap a = some (.array et xs) ∧ xs.length < 2147483648 ∧
    Forall2 (JRecAt AccountRecord "Cbact04c$AccountRecord" σ) xs vals
def DiscgrpFileAt (σ : Jimple.State) (a : Addr) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  ∃ et xs, σ.heap a = some (.array et xs) ∧ xs.length < 2147483648 ∧
    Forall2 (JRecAt DisGroupRecord "Cbact04c$DisGroupRecord" σ) xs vals
def Rel (ot : Out) (os : Signal × Cobol.State) : Prop :=
  ∃ σ' res fs l k xs mods, ot = .normal (some (.ref res)) σ' ∧
    σ'.heap res = some (.plain "Cbact04c$Result" fs) ∧
    Fields.get fs ("Cbact04c$Result", "displays") = some (.ref l) ∧ σ'.heap l = some (.list k xs mods) ∧
    Forall2 (JLineAt σ') xs (displays os.2) ∧
    (∃ lw kw ws mw, Fields.get fs ("Cbact04c$Result", "transactFileWrites") = some (.ref lw) ∧
      σ'.heap lw = some (.list kw ws mw) ∧
      Forall2 (fun x rec => ∃ vals, JRecAt TranRecord "Cbact04c$TranRecord" σ' x vals ∧
        TranRecord.decode rec = some vals) ws (writes 5 os.2)) ∧
    (∃ lw kw ws mw, Fields.get fs ("Cbact04c$Result", "accountFileRewrites") = some (.ref lw) ∧
      σ'.heap lw = some (.list kw ws mw) ∧
      Forall2 (fun x rec => ∃ vals, JRecAt AccountRecord "Cbact04c$AccountRecord" σ' x vals ∧
        AccountRecord.decode rec = some vals) ws (rewrites 3 os.2)) ∧
    Fields.get fs ("Cbact04c$Result", "abended") = some (.int (if abended os.1 then 1 else 0))
def Sim (R : OT → OS → Prop) (t : T) (s : S) : Prop :=
  Safe s → Safe t ∧ ∀ ot, Runs t ot → ∃ os, Runs s os ∧ R ot os
def Domain (tcat _xrefs _accts _discs : List (List FVal)) (_link : List FVal) : Prop :=
  tcat.length < 999999 ∧
  ∀ i j k, i < j → j < k → k < tcat.length →
    tAcct (tcat.getD i []) = tAcct (tcat.getD k []) → tAcct (tcat.getD j []) = tAcct (tcat.getD i [])
def tAcct (t : List FVal) : Int := numOf (t.getD 0 default)

Source.

The package does not record Lean’s axiom report for this theorem, but names the axioms in words: propext, Classical.choice, Quot.sound.

EquivLean.Modernize.Cbcus01c.Rust.rust

For CBCUS01C, the Rust translation’s equivalence, relative to the paper’s semantics of the COBOL program on every admissible input: kernel-only

theorem rust : Statement
Definitions used in the statement
def Statement : Prop :=
  ∀ (vals1 : List (List EquivLean.Cobol.Rec.FVal)),
    (∀ v ∈ vals1, CustomerRecord.Valid v) →
    vals1.length < 2 ^ 28 →
    ∀ n : Nat, vals1.length < n →
    ∀ (s1 : Slice cbcus01c.CustomerRecord),
    CustfileFileOf s1 vals1 →
    Equiv Rel (cbcus01c.run s1)
      (EquivLean.Cobol.run CardDemo.Cbcus01c {} (n + 20)
        (CardDemo.Cbcus01c.initState initMem [(1, vals1.map CustomerRecord.encode)]))
def CustfileFileOf (s : Slice cbcus01c.CustomerRecord) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  s.val.map CustomerRecord.vals = vals
def Rel (o : Except Error cbcus01c.Output) (os : Signal × Cobol.State) : Prop :=
  ∃ out, o = .ok out ∧
    out.displays.val.map (fun l => l.val.map (·.val)) = (displays os.2).map rustLine ∧
    out.abended = abended os.1
def Equiv (R : OT → OS → Prop) (t : T) (s : S) : Prop :=
  Sim R t s ∧ Sim (fun os ot => R ot os) s t
def Sim (R : OT → OS → Prop) (t : T) (s : S) : Prop :=
  Safe s → Safe t ∧ ∀ ot, Runs t ot → ∃ os, Runs s os ∧ R ot os

Source.

The package does not record Lean’s axiom report for this theorem, but names the axioms in words: propext, Classical.choice, Quot.sound.

EquivLean.Modernize.Cbcus01c.Java.java

For CBCUS01C, the Java translation’s refinement with partial correctness, relative to the paper’s semantics of the COBOL program on every admissible input: kernel-only

theorem java : Statement
Definitions used in the statement
def Statement : Prop :=
  ∀ (vals1 : List (List EquivLean.Cobol.Rec.FVal)),
    (∀ v ∈ vals1, CustomerRecord.Valid v) →
    vals1.length < 2 ^ 27 →
    ∀ n : Nat, vals1.length < n →
    ∀ (σ : Jimple.State) (a1 : Addr),
    CustfileFileAt σ a1 vals1 →
    σ.initOf "Cbcus01c" = .done →
    σ.initOf "Cbcus01c$Result" = .done →
    σ.initOf "Cbcus01c$CustomerRecord" = .done →
    Sim Rel (Call.mk Gen.prog runRef [.ref a1] σ)
      (EquivLean.Cobol.run CardDemo.Cbcus01c {} (n + 20)
        (CardDemo.Cbcus01c.initState initMem [(1, vals1.map CustomerRecord.encode)]))
abbrev runRef : MethodRef := Gen.Cbcus01c.«run(Cbcus01c$CustomerRecord[])».ref
def CustfileFileAt (σ : Jimple.State) (a : Addr) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  ∃ et xs, σ.heap a = some (.array et xs) ∧ xs.length < 2147483648 ∧
    Forall2 (JRecAt CustomerRecord "Cbcus01c$CustomerRecord" σ) xs vals
def Rel (ot : Out) (os : Signal × Cobol.State) : Prop :=
  ∃ σ' res fs l k xs mods, ot = .normal (some (.ref res)) σ' ∧
    σ'.heap res = some (.plain "Cbcus01c$Result" fs) ∧
    Fields.get fs ("Cbcus01c$Result", "displays") = some (.ref l) ∧ σ'.heap l = some (.list k xs mods) ∧
    Forall2 (JLineAt σ') xs (displays os.2) ∧
    Fields.get fs ("Cbcus01c$Result", "abended") = some (.int (if abended os.1 then 1 else 0))
def Sim (R : OT → OS → Prop) (t : T) (s : S) : Prop :=
  Safe s → Safe t ∧ ∀ ot, Runs t ot → ∃ os, Runs s os ∧ R ot os

Source.

The package does not record Lean’s axiom report for this theorem, but names the axioms in words: propext, Classical.choice, Quot.sound.

EquivLean.Modernize.Cbtrn01c.Rust.rust

For CBTRN01C, the Rust translation’s equivalence, relative to the paper’s semantics of the COBOL program on every admissible input: kernel-only

theorem rust : Statement
Definitions used in the statement
def Statement : Prop :=
  ∀ (vals1 : List (List EquivLean.Cobol.Rec.FVal)) (vals2 : List (List EquivLean.Cobol.Rec.FVal)) (vals3 : List (List EquivLean.Cobol.Rec.FVal)) (vals4 : List (List EquivLean.Cobol.Rec.FVal)) (vals5 : List (List EquivLean.Cobol.Rec.FVal)) (vals6 : List (List EquivLean.Cobol.Rec.FVal)),
    (∀ v ∈ vals1, DalytranRecord.Valid v) →
    (∀ v ∈ vals2, FdCustfileRec.Valid v) →
    (∀ v ∈ vals3, CardXrefRecord.Valid v) →
    (∀ v ∈ vals4, FdCardfileRec.Valid v) →
    (∀ v ∈ vals5, AccountRecord.Valid v) →
    (∀ v ∈ vals6, FdTranfileRec.Valid v) →
    vals1.length + vals2.length + vals3.length + vals4.length + vals5.length + vals6.length < 2 ^ 28 →
    ∀ n : Nat, vals1.length + vals2.length + vals3.length + vals4.length + vals5.length + vals6.length < n →
    ∀ (s1 : Slice cbtrn01c.DalytranRecord) (s2 : Slice cbtrn01c.FdCustfileRec) (s3 : Slice cbtrn01c.CardXrefRecord) (s4 : Slice cbtrn01c.FdCardfileRec) (s5 : Slice cbtrn01c.AccountRecord) (s6 : Slice cbtrn01c.FdTranfileRec),
    DalytranFileOf s1 vals1 →
    CustomerFileOf s2 vals2 →
    XrefFileOf s3 vals3 →
    CardFileOf s4 vals4 →
    AccountFileOf s5 vals5 →
    TransactFileOf s6 vals6 →
    Equiv Rel (cbtrn01c.run s1 s2 s3 s4 s5 s6)
      (EquivLean.Cobol.run CardDemo.Cbtrn01c {} (n + 40)
        (CardDemo.Cbtrn01c.initState initMem [(1, vals1.map DalytranRecord.encode), (2, vals2.map FdCustfileRec.encode), (3, vals3.map CardXrefRecord.encode), (4, vals4.map FdCardfileRec.encode), (5, vals5.map AccountRecord.encode), (6, vals6.map FdTranfileRec.encode)]))
def DalytranFileOf (s : Slice cbtrn01c.DalytranRecord) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  s.val.map DalytranRecord.vals = vals
def CustomerFileOf (s : Slice cbtrn01c.FdCustfileRec) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  s.val.map FdCustfileRec.vals = vals
def XrefFileOf (s : Slice cbtrn01c.CardXrefRecord) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  s.val.map CardXrefRecord.vals = vals
def CardFileOf (s : Slice cbtrn01c.FdCardfileRec) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  s.val.map FdCardfileRec.vals = vals
def AccountFileOf (s : Slice cbtrn01c.AccountRecord) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  s.val.map AccountRecord.vals = vals
def TransactFileOf (s : Slice cbtrn01c.FdTranfileRec) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  s.val.map FdTranfileRec.vals = vals
def Rel (o : Except Error cbtrn01c.Output) (os : Signal × Cobol.State) : Prop :=
  ∃ out, o = .ok out ∧
    out.displays.val.map (fun l => l.val.map (·.val)) = (displays os.2).map rustLine ∧
    out.abended = abended os.1
def Equiv (R : OT → OS → Prop) (t : T) (s : S) : Prop :=
  Sim R t s ∧ Sim (fun os ot => R ot os) s t
def Sim (R : OT → OS → Prop) (t : T) (s : S) : Prop :=
  Safe s → Safe t ∧ ∀ ot, Runs t ot → ∃ os, Runs s os ∧ R ot os

Source.

The package does not record Lean’s axiom report for this theorem, but names the axioms in words: propext, Classical.choice, Quot.sound.

EquivLean.Modernize.Cbtrn01c.Java.java

For CBTRN01C, the Java translation’s refinement with partial correctness, relative to the paper’s semantics of the COBOL program on every admissible input: kernel-only

theorem java : Statement
Definitions used in the statement
def Statement : Prop :=
  ∀ (vals1 : List (List EquivLean.Cobol.Rec.FVal)) (vals2 : List (List EquivLean.Cobol.Rec.FVal)) (vals3 : List (List EquivLean.Cobol.Rec.FVal)) (vals4 : List (List EquivLean.Cobol.Rec.FVal)) (vals5 : List (List EquivLean.Cobol.Rec.FVal)) (vals6 : List (List EquivLean.Cobol.Rec.FVal)),
    (∀ v ∈ vals1, DalytranRecord.Valid v) →
    (∀ v ∈ vals2, FdCustfileRec.Valid v) →
    (∀ v ∈ vals3, CardXrefRecord.Valid v) →
    (∀ v ∈ vals4, FdCardfileRec.Valid v) →
    (∀ v ∈ vals5, AccountRecord.Valid v) →
    (∀ v ∈ vals6, FdTranfileRec.Valid v) →
    vals1.length + vals2.length + vals3.length + vals4.length + vals5.length + vals6.length < 2 ^ 27 →
    ∀ n : Nat, vals1.length + vals2.length + vals3.length + vals4.length + vals5.length + vals6.length < n →
    ∀ (σ : Jimple.State) (a1 : Addr) (a2 : Addr) (a3 : Addr) (a4 : Addr) (a5 : Addr) (a6 : Addr),
    DalytranFileAt σ a1 vals1 →
    CustomerFileAt σ a2 vals2 →
    XrefFileAt σ a3 vals3 →
    CardFileAt σ a4 vals4 →
    AccountFileAt σ a5 vals5 →
    TransactFileAt σ a6 vals6 →
    σ.initOf "Cbtrn01c" = .done →
    σ.initOf "Cbtrn01c$Result" = .done →
    σ.initOf "Cbtrn01c$AccountRecord" = .done →
    σ.initOf "Cbtrn01c$CardXrefRecord" = .done →
    σ.initOf "Cbtrn01c$DalytranRecord" = .done →
    σ.initOf "Cbtrn01c$FdCardfileRec" = .done →
    σ.initOf "Cbtrn01c$FdCustfileRec" = .done →
    σ.initOf "Cbtrn01c$FdTranfileRec" = .done →
    Sim Rel (Call.mk Gen.prog runRef [.ref a1, .ref a2, .ref a3, .ref a4, .ref a5, .ref a6] σ)
      (EquivLean.Cobol.run CardDemo.Cbtrn01c {} (n + 40)
        (CardDemo.Cbtrn01c.initState initMem [(1, vals1.map DalytranRecord.encode), (2, vals2.map FdCustfileRec.encode), (3, vals3.map CardXrefRecord.encode), (4, vals4.map FdCardfileRec.encode), (5, vals5.map AccountRecord.encode), (6, vals6.map FdTranfileRec.encode)]))
abbrev runRef : MethodRef := Gen.Cbtrn01c.«run(Cbtrn01c$DalytranRecord[],Cbtrn01c$FdCustfileRec[],Cbtrn01c$CardXrefRecord[],Cbtrn01c$FdCardfileRec[],Cbtrn01c$AccountRecord[],Cbtrn01c$FdTranfileRec[])».ref
def DalytranFileAt (σ : Jimple.State) (a : Addr) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  ∃ et xs, σ.heap a = some (.array et xs) ∧ xs.length < 2147483648 ∧
    Forall2 (JRecAt DalytranRecord "Cbtrn01c$DalytranRecord" σ) xs vals
def CustomerFileAt (σ : Jimple.State) (a : Addr) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  ∃ et xs, σ.heap a = some (.array et xs) ∧ xs.length < 2147483648 ∧
    Forall2 (JRecAt FdCustfileRec "Cbtrn01c$FdCustfileRec" σ) xs vals
def XrefFileAt (σ : Jimple.State) (a : Addr) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  ∃ et xs, σ.heap a = some (.array et xs) ∧ xs.length < 2147483648 ∧
    Forall2 (JRecAt CardXrefRecord "Cbtrn01c$CardXrefRecord" σ) xs vals
def CardFileAt (σ : Jimple.State) (a : Addr) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  ∃ et xs, σ.heap a = some (.array et xs) ∧ xs.length < 2147483648 ∧
    Forall2 (JRecAt FdCardfileRec "Cbtrn01c$FdCardfileRec" σ) xs vals
def AccountFileAt (σ : Jimple.State) (a : Addr) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  ∃ et xs, σ.heap a = some (.array et xs) ∧ xs.length < 2147483648 ∧
    Forall2 (JRecAt AccountRecord "Cbtrn01c$AccountRecord" σ) xs vals
def TransactFileAt (σ : Jimple.State) (a : Addr) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  ∃ et xs, σ.heap a = some (.array et xs) ∧ xs.length < 2147483648 ∧
    Forall2 (JRecAt FdTranfileRec "Cbtrn01c$FdTranfileRec" σ) xs vals
def Rel (ot : Out) (os : Signal × Cobol.State) : Prop :=
  ∃ σ' res fs l k xs mods, ot = .normal (some (.ref res)) σ' ∧
    σ'.heap res = some (.plain "Cbtrn01c$Result" fs) ∧
    Fields.get fs ("Cbtrn01c$Result", "displays") = some (.ref l) ∧ σ'.heap l = some (.list k xs mods) ∧
    Forall2 (JLineAt σ') xs (displays os.2) ∧
    Fields.get fs ("Cbtrn01c$Result", "abended") = some (.int (if abended os.1 then 1 else 0))
def Sim (R : OT → OS → Prop) (t : T) (s : S) : Prop :=
  Safe s → Safe t ∧ ∀ ot, Runs t ot → ∃ os, Runs s os ∧ R ot os

Source.

The package does not record Lean’s axiom report for this theorem, but names the axioms in words: propext, Classical.choice, Quot.sound.

EquivLean.Modernize.Cbtrn02c.Any.Rust.rust

For CBTRN02C, the Rust translation’s equivalence, relative to the paper’s semantics of the COBOL program on every admissible input: kernel-only

theorem rust : Statement
Definitions used in the statement
def Statement : Prop :=
  ∀ (vals1 : List (List EquivLean.Cobol.Rec.FVal)) (vals2 : List (List EquivLean.Cobol.Rec.FVal)) (vals3 : List (List EquivLean.Cobol.Rec.FVal)) (vals4 : List (List EquivLean.Cobol.Rec.FVal)),
    (∀ v ∈ vals1, DalytranRecord.Valid v) →
    (∀ v ∈ vals2, CardXrefRecord.Valid v) →
    (∀ v ∈ vals3, AccountRecord.Valid v) →
    (∀ v ∈ vals4, TranCatBalRecord.Valid v) →
    ∀ (clk : List UInt8), CurrentDate clk →
    EquivLean.Modernize.Cbtrn02c.Any.Domain vals1 vals2 vals3 vals4 →
    vals1.length + vals2.length + vals3.length + vals4.length < 2 ^ 28 →
    ∀ n : Nat, vals1.length + vals2.length + vals3.length + vals4.length < n →
    ∀ (s1 : Slice cbtrn02c.DalytranRecord) (s2 : Slice cbtrn02c.CardXrefRecord) (s3 : Slice cbtrn02c.AccountRecord) (s4 : Slice cbtrn02c.TranCatBalRecord) (rclk : Std.Array Std.U8 21#usize),
    DalytranFileOf s1 vals1 →
    XrefFileOf s2 vals2 →
    AccountFileOf s3 vals3 →
    TcatbalFileOf s4 vals4 →
    rclk.val.map (·.val) = rustLine clk →
    Equiv Rel (cbtrn02c.run s1 s2 s3 s4 rclk)
      (EquivLean.Cobol.run CardDemo.Cbtrn02c { clock := fun _ => clk } (n + 60)
        (CardDemo.Cbtrn02c.initState initMem [(1, vals1.map DalytranRecord.encode), (3, vals2.map CardXrefRecord.encode), (5, vals3.map AccountRecord.encode), (6, vals4.map TranCatBalRecord.encode)]))
def DalytranFileOf (s : Slice cbtrn02c.DalytranRecord) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  s.val.map DalytranRecord.vals = vals
def XrefFileOf (s : Slice cbtrn02c.CardXrefRecord) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  s.val.map CardXrefRecord.vals = vals
def AccountFileOf (s : Slice cbtrn02c.AccountRecord) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  s.val.map AccountRecord.vals = vals
def TcatbalFileOf (s : Slice cbtrn02c.TranCatBalRecord) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  s.val.map TranCatBalRecord.vals = vals
def Rel (o : Except Error cbtrn02c.Output) (os : Signal × Cobol.State) : Prop :=
  ∃ out, o = .ok out ∧
    out.displays.val.map (fun l => l.val.map (·.val)) = (displays os.2).map rustLine ∧
    (writes 2 os.2).map TranRecord.decode = out.transact_file_writes.val.map (fun x => some (TranRecord.vals x)) ∧
    (writes 4 os.2).map RejectRecord.decode = out.dalyrejs_file_writes.val.map (fun x => some (RejectRecord.vals x)) ∧
    (writes 6 os.2).map TranCatBalRecord.decode = out.tcatbal_file_writes.val.map (fun x => some (TranCatBalRecord.vals x)) ∧
    (rewrites 5 os.2).map AccountRecord.decode = out.account_file_rewrites.val.map (fun x => some (AccountRecord.vals x)) ∧
    (rewrites 6 os.2).map TranCatBalRecord.decode = out.tcatbal_file_rewrites.val.map (fun x => some (TranCatBalRecord.vals x)) ∧
    out.return_code.val = (itemValue CardDemo.Cbtrn02c.RETURN_CODE CardDemo.Cbtrn02c.RETURN_CODE.fmt os.2) ∧
    out.abended = abended os.1
def Equiv (R : OT → OS → Prop) (t : T) (s : S) : Prop :=
  Sim R t s ∧ Sim (fun os ot => R ot os) s t
def Sim (R : OT → OS → Prop) (t : T) (s : S) : Prop :=
  Safe s → Safe t ∧ ∀ ot, Runs t ot → ∃ os, Runs s os ∧ R ot os
def Domain (trans _xrefs _accts _cats : List (List FVal)) : Prop :=
  trans.length < 1000000000

Source.

The package does not record Lean’s axiom report for this theorem, but names the axioms in words: propext, Classical.choice, Quot.sound.

EquivLean.Modernize.Cbtrn02c.Any.Java.java

For CBTRN02C, the Java translation’s refinement with partial correctness, relative to the paper’s semantics of the COBOL program on every admissible input: kernel-only

theorem java : Statement
Definitions used in the statement
def Statement : Prop :=
  ∀ (vals1 : List (List EquivLean.Cobol.Rec.FVal)) (vals2 : List (List EquivLean.Cobol.Rec.FVal)) (vals3 : List (List EquivLean.Cobol.Rec.FVal)) (vals4 : List (List EquivLean.Cobol.Rec.FVal)),
    (∀ v ∈ vals1, DalytranRecord.Valid v) →
    (∀ v ∈ vals2, CardXrefRecord.Valid v) →
    (∀ v ∈ vals3, AccountRecord.Valid v) →
    (∀ v ∈ vals4, TranCatBalRecord.Valid v) →
    ∀ (clk : List UInt8), CurrentDate clk →
    EquivLean.Modernize.Cbtrn02c.Any.Domain vals1 vals2 vals3 vals4 →
    vals1.length + vals2.length + vals3.length + vals4.length < 2 ^ 27 →
    ∀ n : Nat, vals1.length + vals2.length + vals3.length + vals4.length < n →
    ∀ (σ : Jimple.State) (a1 : Addr) (a2 : Addr) (a3 : Addr) (a4 : Addr) (cs : Addr),
    DalytranFileAt σ a1 vals1 →
    XrefFileAt σ a2 vals2 →
    AccountFileAt σ a3 vals3 →
    TcatbalFileAt σ a4 vals4 →
    JStrAt σ (.ref cs) (cp037Str clk) →
    ClinitRan EquivLean.Modernize.Cbtrn02c.Java.Gen.prog "Cbtrn02c" σ →
    σ.initOf "Cbtrn02c$Result" = .done →
    σ.initOf "Cbtrn02c$AccountRecord" = .done →
    σ.initOf "Cbtrn02c$CardXrefRecord" = .done →
    σ.initOf "Cbtrn02c$DalytranRecord" = .done →
    σ.initOf "Cbtrn02c$TranCatBalRecord" = .done →
    σ.initOf "Cbtrn02c$RejectRecord" = .done →
    σ.initOf "Cbtrn02c$TranRecord" = .done →
    Sim Rel (Call.mk EquivLean.Modernize.Cbtrn02c.Java.Gen.prog runRef [.ref a1, .ref a2, .ref a3, .ref a4, .ref cs] σ)
      (EquivLean.Cobol.run CardDemo.Cbtrn02c { clock := fun _ => clk } (n + 60)
        (CardDemo.Cbtrn02c.initState initMem [(1, vals1.map DalytranRecord.encode), (3, vals2.map CardXrefRecord.encode), (5, vals3.map AccountRecord.encode), (6, vals4.map TranCatBalRecord.encode)]))
abbrev runRef : MethodRef := EquivLean.Modernize.Cbtrn02c.Java.Gen.Cbtrn02c.«run(Cbtrn02c$DalytranRecord[],Cbtrn02c$CardXrefRecord[],Cbtrn02c$AccountRecord[],Cbtrn02c$TranCatBalRecord[],java.lang.String)».ref
def DalytranFileAt (σ : Jimple.State) (a : Addr) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  ∃ et xs, σ.heap a = some (.array et xs) ∧ xs.length < 2147483648 ∧
    Forall2 (JRecAt DalytranRecord "Cbtrn02c$DalytranRecord" σ) xs vals
def XrefFileAt (σ : Jimple.State) (a : Addr) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  ∃ et xs, σ.heap a = some (.array et xs) ∧ xs.length < 2147483648 ∧
    Forall2 (JRecAt CardXrefRecord "Cbtrn02c$CardXrefRecord" σ) xs vals
def AccountFileAt (σ : Jimple.State) (a : Addr) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  ∃ et xs, σ.heap a = some (.array et xs) ∧ xs.length < 2147483648 ∧
    Forall2 (JRecAt AccountRecord "Cbtrn02c$AccountRecord" σ) xs vals
def TcatbalFileAt (σ : Jimple.State) (a : Addr) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  ∃ et xs, σ.heap a = some (.array et xs) ∧ xs.length < 2147483648 ∧
    Forall2 (JRecAt TranCatBalRecord "Cbtrn02c$TranCatBalRecord" σ) xs vals
def Rel (ot : Out) (os : Signal × Cobol.State) : Prop :=
  ∃ σ' res fs l k xs mods, ot = .normal (some (.ref res)) σ' ∧
    σ'.heap res = some (.plain "Cbtrn02c$Result" fs) ∧
    Fields.get fs ("Cbtrn02c$Result", "displays") = some (.ref l) ∧ σ'.heap l = some (.list k xs mods) ∧
    Forall2 (JLineAt σ') xs (displays os.2) ∧
    (∃ lw kw ws mw, Fields.get fs ("Cbtrn02c$Result", "transactFileWrites") = some (.ref lw) ∧
      σ'.heap lw = some (.list kw ws mw) ∧
      Forall2 (fun x rec => ∃ vals, JRecAt TranRecord "Cbtrn02c$TranRecord" σ' x vals ∧
        TranRecord.decode rec = some vals) ws (writes 2 os.2)) ∧
    (∃ lw kw ws mw, Fields.get fs ("Cbtrn02c$Result", "dalyrejsFileWrites") = some (.ref lw) ∧
      σ'.heap lw = some (.list kw ws mw) ∧
      Forall2 (fun x rec => ∃ vals, JRecAt RejectRecord "Cbtrn02c$RejectRecord" σ' x vals ∧
        RejectRecord.decode rec = some vals) ws (writes 4 os.2)) ∧
    (∃ lw kw ws mw, Fields.get fs ("Cbtrn02c$Result", "tcatbalFileWrites") = some (.ref lw) ∧
      σ'.heap lw = some (.list kw ws mw) ∧
      Forall2 (fun x rec => ∃ vals, JRecAt TranCatBalRecord "Cbtrn02c$TranCatBalRecord" σ' x vals ∧
        TranCatBalRecord.decode rec = some vals) ws (writes 6 os.2)) ∧
    (∃ lw kw ws mw, Fields.get fs ("Cbtrn02c$Result", "accountFileRewrites") = some (.ref lw) ∧
      σ'.heap lw = some (.list kw ws mw) ∧
      Forall2 (fun x rec => ∃ vals, JRecAt AccountRecord "Cbtrn02c$AccountRecord" σ' x vals ∧
        AccountRecord.decode rec = some vals) ws (rewrites 5 os.2)) ∧
    (∃ lw kw ws mw, Fields.get fs ("Cbtrn02c$Result", "tcatbalFileRewrites") = some (.ref lw) ∧
      σ'.heap lw = some (.list kw ws mw) ∧
      Forall2 (fun x rec => ∃ vals, JRecAt TranCatBalRecord "Cbtrn02c$TranCatBalRecord" σ' x vals ∧
        TranCatBalRecord.decode rec = some vals) ws (rewrites 6 os.2)) ∧
    Fields.get fs ("Cbtrn02c$Result", "returnCode") = some (.int (BitVec.ofInt 32 (itemValue CardDemo.Cbtrn02c.RETURN_CODE CardDemo.Cbtrn02c.RETURN_CODE.fmt os.2))) ∧
    Fields.get fs ("Cbtrn02c$Result", "abended") = some (.int (if abended os.1 then 1 else 0))
def Sim (R : OT → OS → Prop) (t : T) (s : S) : Prop :=
  Safe s → Safe t ∧ ∀ ot, Runs t ot → ∃ os, Runs s os ∧ R ot os
def Domain (trans _xrefs _accts _cats : List (List FVal)) : Prop :=
  trans.length < 1000000000

Source.

The package does not record Lean’s axiom report for this theorem, but names the axioms in words: propext, Classical.choice, Quot.sound.

EquivLean.Modernize.Cbtrn03c.Rust.rust

For CBTRN03C, the Rust translation’s equivalence, relative to the paper’s semantics of the COBOL program on every admissible input: kernel-only

theorem rust : Statement
Definitions used in the statement
def Statement : Prop :=
  ∀ (vals1 : List (List EquivLean.Cobol.Rec.FVal)) (vals2 : List (List EquivLean.Cobol.Rec.FVal)) (vals3 : List (List EquivLean.Cobol.Rec.FVal)) (vals4 : List (List EquivLean.Cobol.Rec.FVal)) (vals5 : List (List EquivLean.Cobol.Rec.FVal)),
    (∀ v ∈ vals1, TranRecord.Valid v) →
    (∀ v ∈ vals2, CardXrefRecord.Valid v) →
    (∀ v ∈ vals3, TranTypeRecord.Valid v) →
    (∀ v ∈ vals4, TranCatRecord.Valid v) →
    (∀ v ∈ vals5, WsDateparmRecord.Valid v) →
    EquivLean.Modernize.Cbtrn03c.Domain vals1 vals2 vals3 vals4 vals5 →
    vals1.length + vals2.length + vals3.length + vals4.length + vals5.length < 2 ^ 28 →
    ∀ n : Nat, vals1.length + vals2.length + vals3.length + vals4.length + vals5.length < n →
    ∀ (s1 : Slice cbtrn03c.TranRecord) (s2 : Slice cbtrn03c.CardXrefRecord) (s3 : Slice cbtrn03c.TranTypeRecord) (s4 : Slice cbtrn03c.TranCatRecord) (s5 : Slice cbtrn03c.WsDateparmRecord),
    TransactFileOf s1 vals1 →
    XrefFileOf s2 vals2 →
    TrantypeFileOf s3 vals3 →
    TrancatgFileOf s4 vals4 →
    DateParmsFileOf s5 vals5 →
    Equiv Rel (cbtrn03c.run s1 s2 s3 s4 s5)
      (EquivLean.Cobol.run CardDemo.Cbtrn03c {} (n + 60)
        (CardDemo.Cbtrn03c.initState initMem [(1, vals1.map TranRecord.encode), (2, vals2.map CardXrefRecord.encode), (3, vals3.map TranTypeRecord.encode), (4, vals4.map TranCatRecord.encode), (6, vals5.map (fun r => WsDateparmRecord.encode r ++ List.replicate 59 64))]))
def TransactFileOf (s : Slice cbtrn03c.TranRecord) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  s.val.map TranRecord.vals = vals
def XrefFileOf (s : Slice cbtrn03c.CardXrefRecord) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  s.val.map CardXrefRecord.vals = vals
def TrantypeFileOf (s : Slice cbtrn03c.TranTypeRecord) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  s.val.map TranTypeRecord.vals = vals
def TrancatgFileOf (s : Slice cbtrn03c.TranCatRecord) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  s.val.map TranCatRecord.vals = vals
def DateParmsFileOf (s : Slice cbtrn03c.WsDateparmRecord) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  s.val.map WsDateparmRecord.vals = vals
def Rel (o : Except Error cbtrn03c.Output) (os : Signal × Cobol.State) : Prop :=
  ∃ out, o = .ok out ∧
    out.displays.val.map (fun l => l.val.map (·.val)) = (displays os.2).map rustLine ∧
    (writes 5 os.2).map FdReptfileRec.decode = out.report_file_writes.val.map (fun x => some (FdReptfileRec.vals x)) ∧
    out.abended = abended os.1
def Equiv (R : OT → OS → Prop) (t : T) (s : S) : Prop :=
  Sim R t s ∧ Sim (fun os ot => R ot os) s t
def Sim (R : OT → OS → Prop) (t : T) (s : S) : Prop :=
  Safe s → Safe t ∧ ∀ ot, Runs t ot → ∃ os, Runs s os ∧ R ot os
def Domain (trans _xrefs _types _catgs parms : List (List FVal)) : Prop :=
  trans.length < 10000000 ∧ parms ≠ []

Source.

The package does not record Lean’s axiom report for this theorem, but names the axioms in words: propext, Classical.choice, Quot.sound.

EquivLean.Modernize.Cbtrn03c.Java.java

For CBTRN03C, the Java translation’s refinement with partial correctness, relative to the paper’s semantics of the COBOL program on every admissible input: kernel-only

theorem java : Statement
Definitions used in the statement
def Statement : Prop :=
  ∀ (vals1 : List (List EquivLean.Cobol.Rec.FVal)) (vals2 : List (List EquivLean.Cobol.Rec.FVal)) (vals3 : List (List EquivLean.Cobol.Rec.FVal)) (vals4 : List (List EquivLean.Cobol.Rec.FVal)) (vals5 : List (List EquivLean.Cobol.Rec.FVal)),
    (∀ v ∈ vals1, TranRecord.Valid v) →
    (∀ v ∈ vals2, CardXrefRecord.Valid v) →
    (∀ v ∈ vals3, TranTypeRecord.Valid v) →
    (∀ v ∈ vals4, TranCatRecord.Valid v) →
    (∀ v ∈ vals5, WsDateparmRecord.Valid v) →
    EquivLean.Modernize.Cbtrn03c.Domain vals1 vals2 vals3 vals4 vals5 →
    vals1.length + vals2.length + vals3.length + vals4.length + vals5.length < 2 ^ 27 →
    ∀ n : Nat, vals1.length + vals2.length + vals3.length + vals4.length + vals5.length < n →
    ∀ (σ : Jimple.State) (a1 : Addr) (a2 : Addr) (a3 : Addr) (a4 : Addr) (a5 : Addr),
    TransactFileAt σ a1 vals1 →
    XrefFileAt σ a2 vals2 →
    TrantypeFileAt σ a3 vals3 →
    TrancatgFileAt σ a4 vals4 →
    DateParmsFileAt σ a5 vals5 →
    ClinitRan Gen.prog "Cbtrn03c" σ →
    σ.initOf "Cbtrn03c$Result" = .done →
    σ.initOf "Cbtrn03c$CardXrefRecord" = .done →
    σ.initOf "Cbtrn03c$TranCatRecord" = .done →
    σ.initOf "Cbtrn03c$TranRecord" = .done →
    σ.initOf "Cbtrn03c$TranTypeRecord" = .done →
    σ.initOf "Cbtrn03c$WsDateparmRecord" = .done →
    σ.initOf "Cbtrn03c$FdReptfileRec" = .done →
    σ.initOf "Cbtrn03c$Ws" = .done →
    Sim Rel (Call.mk Gen.prog runRef [.ref a1, .ref a2, .ref a3, .ref a4, .ref a5] σ)
      (EquivLean.Cobol.run CardDemo.Cbtrn03c {} (n + 60)
        (CardDemo.Cbtrn03c.initState initMem [(1, vals1.map TranRecord.encode), (2, vals2.map CardXrefRecord.encode), (3, vals3.map TranTypeRecord.encode), (4, vals4.map TranCatRecord.encode), (6, vals5.map (fun r => WsDateparmRecord.encode r ++ List.replicate 59 64))]))
abbrev runRef : MethodRef := Gen.Cbtrn03c.«run(Cbtrn03c$TranRecord[],Cbtrn03c$CardXrefRecord[],Cbtrn03c$TranTypeRecord[],Cbtrn03c$TranCatRecord[],Cbtrn03c$WsDateparmRecord[])».ref
def TransactFileAt (σ : Jimple.State) (a : Addr) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  ∃ et xs, σ.heap a = some (.array et xs) ∧ xs.length < 2147483648 ∧
    Forall2 (JRecAt TranRecord "Cbtrn03c$TranRecord" σ) xs vals
def XrefFileAt (σ : Jimple.State) (a : Addr) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  ∃ et xs, σ.heap a = some (.array et xs) ∧ xs.length < 2147483648 ∧
    Forall2 (JRecAt CardXrefRecord "Cbtrn03c$CardXrefRecord" σ) xs vals
def TrantypeFileAt (σ : Jimple.State) (a : Addr) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  ∃ et xs, σ.heap a = some (.array et xs) ∧ xs.length < 2147483648 ∧
    Forall2 (JRecAt TranTypeRecord "Cbtrn03c$TranTypeRecord" σ) xs vals
def TrancatgFileAt (σ : Jimple.State) (a : Addr) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  ∃ et xs, σ.heap a = some (.array et xs) ∧ xs.length < 2147483648 ∧
    Forall2 (JRecAt TranCatRecord "Cbtrn03c$TranCatRecord" σ) xs vals
def DateParmsFileAt (σ : Jimple.State) (a : Addr) (vals : List (List EquivLean.Cobol.Rec.FVal)) : Prop :=
  ∃ et xs, σ.heap a = some (.array et xs) ∧ xs.length < 2147483648 ∧
    Forall2 (JRecAt WsDateparmRecord "Cbtrn03c$WsDateparmRecord" σ) xs vals
def Rel (ot : Out) (os : Signal × Cobol.State) : Prop :=
  ∃ σ' res fs l k xs mods, ot = .normal (some (.ref res)) σ' ∧
    σ'.heap res = some (.plain "Cbtrn03c$Result" fs) ∧
    Fields.get fs ("Cbtrn03c$Result", "displays") = some (.ref l) ∧ σ'.heap l = some (.list k xs mods) ∧
    Forall2 (JLineAt σ') xs (displays os.2) ∧
    (∃ lw kw ws mw, Fields.get fs ("Cbtrn03c$Result", "reportFileWrites") = some (.ref lw) ∧
      σ'.heap lw = some (.list kw ws mw) ∧
      Forall2 (fun x rec => ∃ vals, JRecAt FdReptfileRec "Cbtrn03c$FdReptfileRec" σ' x vals ∧
        FdReptfileRec.decode rec = some vals) ws (writes 5 os.2)) ∧
    Fields.get fs ("Cbtrn03c$Result", "abended") = some (.int (if abended os.1 then 1 else 0))
def Sim (R : OT → OS → Prop) (t : T) (s : S) : Prop :=
  Safe s → Safe t ∧ ∀ ot, Runs t ot → ∃ os, Runs s os ∧ R ot os
def Domain (trans _xrefs _types _catgs parms : List (List FVal)) : Prop :=
  trans.length < 10000000 ∧ parms ≠ []

Source.

The package does not record Lean’s axiom report for this theorem, but names the axioms in words: propext, Classical.choice, Quot.sound.