Proving non-issue of same-type bound variable aliasing with explicit type annotations

Prove that, when encoding Lean’s dependently typed lambda-calculus expressions with de Bruijn indices in an e-graph and adding explicit type annotations to all terms, bound variable aliasing is a non-issue for variables of the same type, thereby ensuring that equivalences introduced by rewrites do not cause invalid capture or un-capture of variables across contexts for same-typed variables.

Background

In the direct e-graph representation of Lean’s expression language, de Bruijn indices for bound variables cause aliasing because multiple binders reuse the same index symbol. This can lead to unintended equivalences and, in implicitly typed settings, ill-typed terms when rewritten expressions share aliased variable nodes.

The authors propose adding explicit type annotations to all terms to make variables of different types syntactically distinct, which would eliminate cross-type aliasing. They argue that it would then suffice to show that aliasing is benign for variables of the same type, but they do not yet have a proof for this claim.

References

It, thus, suffices to show that aliasing is a non-issue for variables of the same type. While we do not have proof of this, we have an argument which relies on the fact that expressions which are equivalent to variables must be equivalent in all contexts.

Bridging Syntax and Semantics of Lean Expressions in E-Graphs  (2405.10188 - Rossel et al., 2024) in Subsection “Bound Variable Aliasing,” Section “The (Lack of) Problems with Binders”