-
Notifications
You must be signed in to change notification settings - Fork 626
feat: partial_fixpoint: theory #6477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or 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 PR adds the necessary domain theory that backs the `partial_fixpoint` feature. Part of #6355.
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/batteries
that referenced
this pull request
Dec 30, 2024
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/mathlib4
that referenced
this pull request
Dec 30, 2024
Mathlib CI status (docs):
|
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/batteries
that referenced
this pull request
Dec 30, 2024
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/mathlib4
that referenced
this pull request
Dec 30, 2024
luisacicolini
pushed a commit
to opencompl/lean4
that referenced
this pull request
Jan 21, 2025
This PR adds the necessary domain theory that backs the `partial_fixpoint` feature. Part of leanprover#6355.
github-merge-queue bot
pushed a commit
that referenced
this pull request
Jan 21, 2025
This PR adds the ability to define possibly non-terminating functions and still be able to reason about them equationally, as long as they are tail-recursive or monadic. Typical uses of this feature are ```lean4 def ack : (n m : Nat) → Option Nat | 0, y => some (y+1) | x+1, 0 => ack x 1 | x+1, y+1 => do ack x (← ack (x+1) y) partial_fixpiont def whileSome (f : α → Option α) (x : α) : α := match f x with | none => x | some x' => whileSome f x' partial_fixpiont def computeLfp {α : Type u} [DecidableEq α] (f : α → α) (x : α) : α := let next := f x if x ≠ next then computeLfp f next else x partial_fixpiont noncomputable def geom : Distr Nat := do let head ← coin if head then return 0 else let n ← geom return (n + 1) partial_fixpiont ``` This PR contains * The necessary fragment of domain theory, up to (a variant of) Knaster–Tarski theorem (merged as #6477) * A tactic to solve monotonicity goals compositionally (a bit like mathlib’s `fun_prop`) (merged as #6506) * An attribute to extend that tactic (merged as #6506) * A “derecursifier” that uses that machinery to define recursive function, including support for dependent functions and mutual recursion. * Fixed-point induction principles (technical, tedious to use) * For `Option`-valued functions: Partial correctness induction theorems that hide all the domain theory This is heavily inspired by [Isabelle’s `partial_function` command](https://isabelle.in.tum.de/doc/codegen.pdf).
JovanGerb
pushed a commit
to JovanGerb/lean4
that referenced
this pull request
Jan 21, 2025
This PR adds the necessary domain theory that backs the `partial_fixpoint` feature. Part of leanprover#6355.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
builds-mathlib
CI has verified that Mathlib builds against this PR
changelog-library
Library
toolchain-available
A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
will-merge-soon
…unless someone speaks up
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the necessary domain theory that backs the
partial_fixpoint
feature.Part of #6355.