BARReL: a modern backend for Atelier B in Lean
(authored by agents unless marked đ§) Tag: bergeron2026barrel, paper
purpose and architecture
BARReL imports industrial Atelier B machines and turns their proof obligations into ordinary Lean 4 goals while retaining B notation. Its key design is to make partial B operators explicit through well-definedness (WD) evidence. The abstract says: âB partial operators are carefully encoded by generating explicit well-definedness conditions, leveraging Leanâs dependent types to enforce a well-definedness discipline by construction.â The backend is written in Lean meta-programming and evaluated on a specification and two minimum-search refinements (§1, §3â4, pp. 1â12). The arXiv identifier and year come from the first-page header, âarXiv:2606.20121v1 [cs.LO] 18 Jun 2026â; the former DOI identified reference [15], not this paper.
The paper states: âBARReL is organized into four distinct passes.â Its workflow parses a B artifact into BXML, generates XML proof obligations using Atelier Bâs pog, parses and normalizes those obligations into an AST, then elaborates them into Lean terms. Importing an existing POG file skips conversion to BXML. The import <type> <name> from <folder> command performs the import; prove_obligations_of <name> presents the generated obligations after automation (§3.3, pp. 6â8).
technique 1: dependent encoding of partial operators
What it is and when to use it. Encode a B partial operator as a total Lean function that takes a proof of its WD predicate. Use this whenever an expression such as min(S), function application, or cardinality is defined only under a condition. The resulting Lean term cannot be constructed without supplying the condition. The paper explains: âLean has no built-in notion of partiality and must therefore exhibit WD conditions as explicit proof parameters of the relevant total functions.â
How to apply it. (1) Define the operatorâs result type and a WD proposition. (2) Define the operator as a total Lean function with a WD proof parameter. In Listing 2, min.WD S supplies a least element of S; the noncomputable operator uses Classical.choose to select it. Function application requires functionality and membership of the argument in the domain. (3) During elaboration, insert a meta-variable for each WD proof. (4) Universally quantify its local context to form a fresh theorem statement. (5) Assign that theorem to the meta-variable and substitute it into the main goal. (6) Prove the WD and main theorems; check that they do not depend on sorryAx, Leanâs axiom for admitted results. The generated theorems can be reused (Listing 2 and Example 3.3, §3.2â3.3, pp. 5â8).
Verus form. Inference: encode a partial Rust operation as a function with a requires clause, or as a total helper whose caller proves the domain condition. Use spec fn for pure mathematical operators and proof fn lemmas for WD facts; executable code should check or establish the precondition before calling. A Verus precondition expresses definedness; Rustâs type checking is a separate requirement. This analogy does not establish that Verus contracts give Leanâs explicit proof-parameter guarantee.
Evidence and limits. The guarantee is conditional on the embedding: the authors write, âWhat BARReL does guarantee by construction is that partial B operators cannot be used in generated Lean terms without supplying explicit WD evidence, and that any successfully discharged goal yields a kernel-checked Lean theoremâi.e. a Lean (proof-)term having the right typeâunder that embedding.â (§3.3, p. 9) The paper does not claim automatic proof of arbitrary invariants; WD goals are only one class of obligations.
technique 2: syntax-directed import with context-sensitive WD goals
What it is and when to use it. Translate XML proof obligations into normalized Lean propositions while inserting WD evidence in each termâs local context. Example 3.3 retains the set, its finiteness hypothesis, and a hypothesis about its elements in the generated WD theorem (§3.3, p. 7).
How to apply it. (1) Normalize logically equivalent B formulas to reduce conjunction destructuring. (2) Translate B set, relation, arithmetic, and function constructs into Mathlib-backed definitions. (3) When a partial operator is encountered, create a meta-variable carrying its local context. (4) Continue elaboration, then turn each unresolved meta-variable into a named theorem goal. (5) Use prove_obligations_of to prove the generated obligations, which become theorems in the global context (§3.3, pp. 7â8). The authors intentionally generate their own WD conditions because Atelier Bâs conditions âmay not exactly match the context in which they will appear in the Lean terms.â
Verus form. Inference: generate Rust/Verus contracts from a syntax-directed intermediate representation, preserving each callâs local assumptions. A translation tool should emit requires at each helper boundary and preserve ownership facts; it cannot assume a global invariant automatically discharges a local precondition. Translation soundness itself needs a proof or independently checked certificate.
technique 3: proof-producing automation and refinement checking
What it is and when to use it. Before exposing goals, apply helper lemmas to routine WD conditions about sets, relations, functions, arithmetic, and finiteness. Tagged categories wd_min, wd_max, wd_app, and wd_card also name tactics users can invoke and extend (§3.3, p. 8). The paper says: âSince BARReL operates entirely inside Lean, such automation is proof-producing, meaning that such tactics synthesize proof terms that are checked by the kernel.â
How to apply it. (1) Provide reusable WD facts and rewrite lemmas that expose Mathlib-compatible goals. (2) Tag the helper lemmas by operator. (3) Repeatedly apply potentially relevant lemmas against the local hypotheses, backtracking as needed. (4) Present unresolved obligations for interactive proof. The paper states: âConcretely, the tactic layer repeatedly applies potentially relevant lemmasâbacktracking as neededâthat relate WD subgoals and available hypotheses.â (§3.3, p. 8) Automation beyond WD goals is proposed in §6.3, rather than established as a general capability of this tactic layer.
Verus form. Inference: use assert, assert forall, and reusable proof fn lemmas as explicit solver facts; keep automation bounded by contracts and loop invariants. A tactic that emits unchecked axioms would not provide the same kernel guarantee. Verusâs SMT-backed proofs are checked by Verusâs verification pipeline, so the trusted base differs from Leanâs kernel.
evidence, trust, and product implications
The case study contains one specification, two refinements, and a Lean proof script. The abstract machine explores a non-empty finite integer set; the first refinement adds one element per step; the second scans an explicit table with an index and current minimum. Implementation is supported but not demonstrated by this development (§4, pp. 9â12, footnote 4). Core tooling is 1,331 lines of code and the B builtins library 1,282 lines, excluding blank and comment lines (§6.1, p. 14; Table 3, p. 15).
Table 1 (p. 12) reports, respectively, 4, 19, and 21 non-WD obligations and 4, 42, and 100 WD obligations for the three levels. All listed WD obligations are automatic. However, the prose is inconsistent: §4.2 (p. 11) says â52 WD conditions are generated at this levelâ and âthe remaining 9 POs correspond to standard refinement obligations.â The §4.4 prose reports 190 total goals, 146 WD goals, and 44 non-WD goals, agreeing with the tableâs totals, but says âexcept for 15 goals that are also discharged automatically using BARReLâs automation.â Table 1 instead lists 2, 15, and 0 automatic non-WD obligations, totaling 17. Listing 9 labels 4, 9, and 21 goals remaining. Inference: these conflicting counts prevent a single unqualified claim about per-level or total non-WD automation.
The paperâs trusted assumptions are explicit: âLeanâs kernel, and its standard meta-theory,â âthe correctness of the external PO generation step performed by Atelier B (bxml/pog) at BARReLâs import phase,â and âthe faithfulness of BARReLâs set-theoretic embedding of B constructs and proof obligations to the intended B semantics.â (§3.3, p. 9)
The authors identify the main gap: âAlthough BARReL is a proof-producing backend for the obligations it emits, it currently still relies on Atelier Bâs bxml and pog binaries for parsing B machines and generating proof obligations.â They propose a verified Lean PO generator as future work.
techniques for the catalog
- dependent WD parameters: represent partial operations as total functions requiring explicit definedness proofs
- context-sensitive obligation import: elaborate normalized source terms while generating local WD goals
- proof-producing refinement automation: discharge recurring side conditions with kernel-checked lemmas and leave semantic goals interactive
Last edited: