-
Notifications
You must be signed in to change notification settings - Fork 450
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: always run clean_wf, even before decreasing_by (#5016)
Previously, the tactic state shown at `decreasing_by` would leak lots of details about the translation, and mention `invImage`, `PSigma` etc. This is not nice. So this introduces `clean_wf`, which is like `simp_wf` but using `simp`'s `only` mode, and runs this unconditionally. This should clean up the goal to a reasonable extent. Previously `simp_wf` was an unrestricted `simp […]` call, but we probably don’t want arbitrary simplification to happen at this point, so this now became `simp only` call. For backwards compatibility, `decreasing_with` begins with `try simp`. The `simp_wf` tactic is still available to not break too much existing code; it’s docstring suggests to no longer use it. With `set_option cleanDecreasingByGoal false` one can disable the use of `clean_wf`. I hope this is only needed for debugging and understanding. Migration advise: If your `decreasing_by` proof begins with `simp_wf`, either remove that (if the proof still goes through), or replace with `simp`. I am a bit anxious about running even `simp only` unconditionally here, as it may do more than some user might want, e.g. because of options like `zetaDelta := true`. We'll see if we need to reign in this tactic some more. I wonder if in corner cases the `simp_wf` tactic might be able to close the goal, and if that is a problem. If so, we may have to promote simp’s internal `mayCloseGoal` parameter to a simp configuration option and use that here. fixes #4928
- Loading branch information
Showing
21 changed files
with
170 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/- | ||
Copyright (c) 2024 Lean FRO, LLC. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Joachim Breitner | ||
-/ | ||
|
||
prelude | ||
import Lean.Elab.Tactic.Basic | ||
|
||
namespace Lean.Elab.WF | ||
|
||
register_builtin_option cleanDecreasingByGoal : Bool := { | ||
defValue := true | ||
descr := "Cleans up internal implementation details in the proof goals presented by \ | ||
`decreasing_by`, using the `clean_wf` tactic. Can be disabled for debugging \ | ||
purposes. Please report an issue if you have to disable this option." | ||
} | ||
|
||
open Lean Elab Tactic | ||
|
||
def applyCleanWfTactic : TacticM Unit := do | ||
if cleanDecreasingByGoal.get (← getOptions) then | ||
Tactic.evalTactic (← `(tactic| all_goals clean_wf)) | ||
|
||
end Lean.Elab.WF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,45 @@ | ||
decreasing_by.lean:36:0-43:17: error: Could not find a decreasing measure. | ||
decreasing_by.lean:34:0-39:17: error: Could not find a decreasing measure. | ||
The arguments relate at each recursive call as follows: | ||
(<, ≤, =: relation proved, ? all proofs failed, _: no proof attempted) | ||
n m | ||
1) 36:29-43 = ? | ||
2) 36:46-62 ? _ | ||
1) 34:29-43 = ? | ||
2) 34:46-62 ? _ | ||
Please use `termination_by` to specify a decreasing measure. | ||
decreasing_by.lean:66:0-73:19: error: Could not find a decreasing measure. | ||
decreasing_by.lean:61:0-67:19: error: Could not find a decreasing measure. | ||
The arguments relate at each recursive call as follows: | ||
(<, ≤, =: relation proved, ? all proofs failed, _: no proof attempted) | ||
n m | ||
1) 66:29-43 = ? | ||
2) 66:46-62 ? _ | ||
1) 61:29-43 = ? | ||
2) 61:46-62 ? _ | ||
Please use `termination_by` to specify a decreasing measure. | ||
decreasing_by.lean:81:13-83:3: error: unexpected token 'end'; expected '{' or tactic | ||
decreasing_by.lean:81:0-81:13: error: unsolved goals | ||
decreasing_by.lean:75:13-77:3: error: unexpected token 'end'; expected '{' or tactic | ||
decreasing_by.lean:75:0-75:13: error: unsolved goals | ||
n m : Nat | ||
⊢ (invImage (fun x => PSigma.casesOn x fun n m => (n, m)) Prod.instWellFoundedRelation).1 ⟨n, dec2 m⟩ ⟨n, m⟩ | ||
⊢ Prod.Lex (fun a₁ a₂ => a₁ < a₂) (fun a₁ a₂ => a₁ < a₂) (n, dec2 m) (n, m) | ||
|
||
n m : Nat | ||
⊢ (invImage (fun x => PSigma.casesOn x fun n m => (n, m)) Prod.instWellFoundedRelation).1 ⟨dec1 n, 100⟩ ⟨n, m⟩ | ||
decreasing_by.lean:91:0-91:22: error: unsolved goals | ||
⊢ Prod.Lex (fun a₁ a₂ => a₁ < a₂) (fun a₁ a₂ => a₁ < a₂) (dec1 n, 100) (n, m) | ||
decreasing_by.lean:85:0-85:22: error: unsolved goals | ||
case a | ||
n m : Nat | ||
⊢ (invImage (fun x => PSigma.casesOn x fun n m => (n, m)) Prod.instWellFoundedRelation).1 ⟨n, dec2 m⟩ ⟨n, m⟩ | ||
⊢ Prod.Lex (fun a₁ a₂ => a₁ < a₂) (fun a₁ a₂ => a₁ < a₂) (n, dec2 m) (n, m) | ||
|
||
n m : Nat | ||
⊢ (invImage (fun x => PSigma.casesOn x fun n m => (n, m)) Prod.instWellFoundedRelation).1 ⟨dec1 n, 100⟩ ⟨n, m⟩ | ||
decreasing_by.lean:99:0-100:22: error: Could not find a decreasing measure. | ||
⊢ Prod.Lex (fun a₁ a₂ => a₁ < a₂) (fun a₁ a₂ => a₁ < a₂) (dec1 n, 100) (n, m) | ||
decreasing_by.lean:93:0-94:22: error: Could not find a decreasing measure. | ||
The arguments relate at each recursive call as follows: | ||
(<, ≤, =: relation proved, ? all proofs failed, _: no proof attempted) | ||
n m | ||
1) 99:29-43 = ? | ||
2) 99:46-62 ? _ | ||
1) 93:29-43 = ? | ||
2) 93:46-62 ? _ | ||
Please use `termination_by` to specify a decreasing measure. | ||
decreasing_by.lean:110:0-113:17: error: unsolved goals | ||
decreasing_by.lean:104:0-106:17: error: unsolved goals | ||
n m : Nat | ||
⊢ (invImage (fun x => PSigma.casesOn x fun n m => (n, m)) Prod.instWellFoundedRelation).1 ⟨dec1 n, 100⟩ ⟨n, m⟩ | ||
decreasing_by.lean:121:0-125:17: error: Could not find a decreasing measure. | ||
⊢ Prod.Lex (fun a₁ a₂ => a₁ < a₂) (fun a₁ a₂ => a₁ < a₂) (dec1 n, 100) (n, m) | ||
decreasing_by.lean:114:0-117:17: error: Could not find a decreasing measure. | ||
The arguments relate at each recursive call as follows: | ||
(<, ≤, =: relation proved, ? all proofs failed, _: no proof attempted) | ||
n m | ||
1) 121:29-43 = ? | ||
2) 121:46-62 ? _ | ||
1) 114:29-43 = ? | ||
2) 114:46-62 ? _ | ||
Please use `termination_by` to specify a decreasing measure. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.