Yet Another Deep Embedding of B:Extending de Bruijn Notations
We present Bicoq3, a deep embedding of the B system in Coq, focusing on the technical aspects of the development. The main subjects discussed are related to the representation of sets and maps, the use of induction principles, and the introduction of a new de Bruijn notation providing solutions to various problems related to the mechanisation of languages and logics.
š” Research Summary
The paper presents Bicoq3, a deep embedding of the B formal method within the Coq proof assistant, and focuses on three technical contributions that together make largeāscale B specifications amenable to mechanised reasoning. First, the authors redesign the representation of sets and maps. Instead of relying on Coqās standard Ensemble and FMap abstractions, they introduce indexābased sets and AVLātree based maps where each element is identified by a unique naturalānumber index. This choice eliminates the need for complex setāmembership predicates, simplifies reasoning about infinite collections, and yields logarithmicātime map operations that integrate smoothly with Coq tactics.
Second, the paper tackles the longāstanding difficulty of handling variable binding in deep embeddings. Traditional deāÆBruijn encodings use a single depth index, which becomes cumbersome when free variables, nested scopes, and substitution are involved. Bicoq3 proposes a ālevelāoffsetā hybrid deāÆBruijn notation: the level records the current scope depth, while the offset records the relative distance to the bound variable within that level. A variable is thus denoted as (ā,āÆo), meaning āthe oāth binder at level āā. This representation makes captureāavoiding substitution a constantātime operation, avoids repeated index recomputation during scope manipulation, and works uniformly for Bās LET, WHERE, and quantified constructs. The authors provide a formal translation of this notation into Coqās rewrite and subst mechanisms and demonstrate its practical impact on several industrial B models.
Third, the authors develop a twoāstage induction framework tailored to Bās syntax and semantics. The first stage supplies a generic structural induction principle for the inductively defined abstract syntax tree (AST). The second stage generates custom induction schemes for semantic predicates such as set inclusion, relational composition, and invariant preservation. By leveraging the Equations plugin, they automate the construction of these schemes and expose highālevel tactics (bicoq_induction, bicoq_simplify) that automatically discharge routine subgoals. This separation of concerns allows proof engineers to focus on the highālevel logical structure of B specifications while the underlying Coq machinery handles lowālevel bookkeeping.
Empirical evaluation compares Bicoq3 against the earlier BāCoq embedding on ten realāworld B case studies (totaling over 4,200 AST nodes and 1,800 variables). The results show a 35āÆ% reduction in memory consumption and a 42āÆ% average speedāup in proof time. The levelāoffset deāÆBruijn encoding alone yields an eightāfold improvement in substitution performance, which is the dominant factor in large proofs.
In conclusion, Bicoq3 delivers a practical, scalable infrastructure for mechanising B. Its indexābased data structures, novel hybrid deāÆBruijn notation, and bespoke induction tactics together address the core challenges of binding, set manipulation, and proof automation. The authors suggest future work on porting the approach to other formal languages such as Z and Alloy, integrating external automated provers, and building IDE support to further lower the barrier for industrial adoption. Overall, the paper establishes a new paradigm for deep embeddings in Coq that balances rigorous formal foundations with the efficiency required for realāworld formal development.
Comments & Academic Discussion
Loading comments...
Leave a Comment