Skip to content

Port of erasure theorem (WIP) - #667

Open
maxvistrup wants to merge 5 commits into
leanprover-community:masterfrom
maxvistrup:erasure
Open

Port of erasure theorem (WIP)#667
maxvistrup wants to merge 5 commits into
leanprover-community:masterfrom
maxvistrup:erasure

Conversation

@maxvistrup

Copy link
Copy Markdown

This PR contains a port of the erasure theorem from Rocq. I'm not fully happy with it. As I warned in the meeting on Friday, I don't consider this proof production-ready as of yet. I've tried various things but it remains significantly longer than the upstream proof: 1912 lines vs 860 lines. Let me explain the main reasons why that is:

Reason 1: reshape_expr. In the Rocq proof, reshape_expr is useful for handling the many cases from destructing Ki in non_resolve_prim_step_matched_by_erased_steps_ectx_item. It is not immediately obvious to me how to best get the same convenience in Lean. As partial progress, I have ported reshape_expr as a small wrapper around @ayhon's extractAllEctxItems. That part is all fine. However, to my knowledge, you can't match every goal of a certain shape in Lean. Thus, unlike Rocq, you can't easily go over all the unlabeled cases and extract the Ki to pass as argument to reshape_expr. Thus, some more creative metaprogramming options are necessary. For now, I leave it unaddressed here to solicit some suggestions from those more experienced in Lean metaprogramming. Is this a familiar pattern? Can I match on the shape of goals?

Reason 2: repeat match goal. Another closely related issue is appears in the proof of erased_baseStep_baseStep which is significantly longer than its Rocq parallel erased_base_step_base_step. The latter relies on some creative proof engineering using repeat match goal to destruct the relevant parameter unveiled by inverting the step, and then closing all goals by eauto using. The latter step may be within reach in Lean, but it is not clear to me if there is any idiom for doing the first step of singling out certain cases of an inversion.

Another point of optimization is erased_primStep_primStep. This proof inlines the proof corresponding to the Rocq proof of prim_step_matched_by_erased_steps_ectx_item. In the Rocq proof of this, most of the cases of destruct Ki could be discharged to simplify_eq/=; rewrite fill_app /=. I'm not sure what the Lean analogue would be, but I'm sure something can be done here.

Happy to take any input.

maxvistrup and others added 5 commits August 2, 2026 17:54
Adds `rocq_alias` annotations to every top-level definition and theorem
that has a Rocq counterpart in `iris_heap_lang/proph_erasure.v`, and
refactors `erased_primStep_primStep` and `erased_baseStep_baseStep`
using local tactic macros (`erase_simp`, `peel_ki`) and inversion
helpers (`eraseExpr_eq_val`, `eraseVal_eq_lit`) to shrink the case
enumerations.
Adds a generic `reshapeExpr` on top of `findECtx` that mirrors Rocq's
`reshape_expr e tac`: walks decompositions `e = fill K e'` from innermost
outward and invokes `tac K e'` on each. The callback sees both K and e',
so it can guard on non-empty K or on the last frame's shape (which the
existing `findECtx` — parameterized only on e' — cannot do).
@maxvistrup maxvistrup changed the title Port of erasure theorem Port of erasure theorem (WIP) Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant