Commit 5e594a4
committed
fix(Translate): don't look in arguments of free variables in
This PR addresses a `to_additive` limitation reported at [#mathlib4 > leanprover-community#35179 breaks to_additive call in FLT](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/.2335179.20breaks.20to_additive.20call.20in.20FLT/with/574823087) by making sure `shouldTranslate` doesn't looks at the arguments of free variable applications
This PR refactors `shouldTranslate` in a few ways
- The monad is changed from `OptionT` to `ExceptT`, with the underlying type changing from `Option Expr` to `ExceptT Expr Unit`. Although this is technically a bit less efficient, it makes the program shorter and more intuitive, because a failure now actually corresponds to a monadic failure instead of a monadic success.
- When visiting a `Expr.app` node, we now loop through the whole application at once, instead of doing this step by step and checking the cache at each step. This allows us to detect when the head is a free variable, and skip its arguments. It also lets us deal with `ignoreArgsAttr` more naturally.
- This change removes the need for the `inApp : Bool` argument that used to be passed around in order to tell whether a constant was in an application.shouldTranslate (leanprover-community#35549)1 parent 2a6bde3 commit 5e594a4
File tree
4 files changed
+44
-39
lines changed- MathlibTest
- Mathlib/Tactic/Translate
4 files changed
+44
-39
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
350 | 350 | | |
351 | 351 | | |
352 | 352 | | |
353 | | - | |
| 353 | + | |
354 | 354 | | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
| 355 | + | |
359 | 356 | | |
360 | 357 | | |
361 | 358 | | |
362 | 359 | | |
363 | 360 | | |
364 | 361 | | |
365 | 362 | | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
| 363 | + | |
372 | 364 | | |
373 | | - | |
| 365 | + | |
374 | 366 | | |
375 | 367 | | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
383 | 383 | | |
384 | 384 | | |
385 | | - | |
| 385 | + | |
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
389 | 389 | | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
| 390 | + | |
| 391 | + | |
394 | 392 | | |
395 | 393 | | |
396 | 394 | | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
403 | 400 | | |
404 | 401 | | |
405 | 402 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
863 | 863 | | |
864 | 864 | | |
865 | 865 | | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
0 commit comments