Commit 2025-12-05 13:19 55bbac04
View on Github →feat(translate): refactor applyReplacementFun and more (#32176)
This PR cleans up a lot of the to_additive implementation.
applyReplacementFun is cleaned up:
- Instead of running
shouldTranslateat every single constant appliaction, we now only run it on constant applications where the head constant can actually be translated - The option for translating numerals was mistakenly not actually looked at. This means that
to_dualwould translate the numeral 1 to 0. This is fixed. - We remove the
Expr.projhandling, because these are already handled byexpand. - The
if gf.isBVar && x.isLitis now not needed anymore and is removed. - It now uses
memoFixinstead ofLean.Expr.replaceRec, which will is more transparent, and will allow us to change the monad in the future if needed. Some more cleanups: transformDeclhas been removed/inlined since it is a small function only used once.transformDeclAuxhas been renamed totransformDeclRec(as it recursively transforms the declarations appearing inside the declaration). It now recursively calls itself with an emptyreorderanddontTranslate, which helps avoid a case split.- In
ToAdditiveandToDual, an unused piece of syntax has been removed. memoFixhas been reimplemented to actually use pointer equality.