forked from leanprover/lean4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: nested well-founded recursion via automatic preprocessing (lean…
…prover#6744) This PR extend the preprocessing of well-founded recursive definitions to bring assumptions like `h✝ : x ∈ xs` into scope automatically. This fixes leanprover#5471, and follows (roughly) the design written there. See the module docs at `src/Lean/Elab/PreDefinition/WF/AutoAttach.lean` for details on the implementation. This only works for higher-order functions that have a suitable setup. See for example section “Well-founded recursion preprocessing setup” in `src/Init/Data/List/Attach.lean`. This does not change the `decreasing_tactic`, so in some cases there is still the need for a manual termination proof some cases. We expect a better termination tactic in the near future.
- Loading branch information
1 parent
bb5a71d
commit 98e0e30
Showing
18 changed files
with
891 additions
and
153 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
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 was deleted.
Oops, something went wrong.
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,36 @@ | ||
/- | ||
Copyright (c) 2021 Microsoft Corporation. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Leonardo de Moura | ||
-/ | ||
prelude | ||
import Lean.Meta.Transform | ||
import Lean.Elab.RecAppSyntax | ||
|
||
namespace Lean.Elab.WF | ||
open Meta | ||
|
||
/-- | ||
Preprocesses the expressions to improve the effectiveness of `wfRecursion`. | ||
* Floats out the RecApp markers. | ||
Example: | ||
``` | ||
def f : Nat → Nat | ||
| 0 => 1 | ||
| i+1 => (f x) i | ||
``` | ||
Unlike `Lean.Elab.Structural.preprocess`, do _not_ beta-reduce, as it could | ||
remove `let_fun`-lambdas that contain explicit termination proofs. | ||
-/ | ||
def floatRecApp (e : Expr) : CoreM Expr := | ||
Core.transform e | ||
(post := fun e => do | ||
if e.isApp && e.getAppFn.isMData then | ||
let .mdata m f := e.getAppFn | unreachable! | ||
if m.isRecApp then | ||
return .done (.mdata m (f.beta e.getAppArgs)) | ||
return .continue) | ||
|
||
end Lean.Elab.WF |
This file was deleted.
Oops, something went wrong.
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.