Skip to content
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

feat: partial_fixpoint #253

Merged
merged 37 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
cd4014e
Switch to partial fixpoint pr-release
nomeata Jan 16, 2025
212d52d
Reapply "Local setup"
nomeata Jan 16, 2025
168a53b
A bit more
nomeata Jan 16, 2025
3fd2703
5
nomeata Jan 16, 2025
59287ee
fixes
nomeata Jan 16, 2025
3c61ae9
Shorter lines
nomeata Jan 16, 2025
cce70f5
Copy editing
nomeata Jan 16, 2025
3c3d32e
Typos
nomeata Jan 16, 2025
fe2a45b
More typos
nomeata Jan 16, 2025
1b87068
Even more typos
nomeata Jan 16, 2025
ccdb638
More on theory
nomeata Jan 17, 2025
898660a
Render as plain text
nomeata Jan 17, 2025
e18cb0c
Less imports
nomeata Jan 17, 2025
56b0219
Try to use a table (need help with the error)
nomeata Jan 17, 2025
0075820
Revert "Try to use a table (need help with the error)"
nomeata Jan 17, 2025
ea47ac5
Reapply "Try to use a table (need help with the error)"
nomeata Jan 20, 2025
f7f8c42
Get table to work
nomeata Jan 20, 2025
e16ca45
More on the table
nomeata Jan 20, 2025
2d55e63
Merge branch 'main' of github.com:leanprover/reference-manual into jo…
nomeata Jan 20, 2025
7c36218
Use {name} not {inst}
nomeata Jan 20, 2025
3709142
cargo-cult local syntax tricks
nomeata Jan 20, 2025
37020b8
Copy editing
nomeata Jan 20, 2025
7c0d7ad
A (not very interesting) mutual recursion section
nomeata Jan 20, 2025
95a0625
Typo
nomeata Jan 20, 2025
39f81f1
Avoid duplicate anchor
nomeata Jan 20, 2025
8478f38
Use ppExpr
nomeata Jan 20, 2025
5b8409a
Bump to nightly
nomeata Jan 22, 2025
13f0ba9
Make build work with nightly
nomeata Jan 22, 2025
5bb05ce
Proofreading and minor style
david-christiansen Jan 24, 2025
e35470c
render monotonicity lemmas with highlighting
david-christiansen Jan 24, 2025
497bd7f
remove obsolete TODO
david-christiansen Jan 24, 2025
29c7ccd
Merge remote-tracking branch 'upstream/main' into joachim/partial-fix…
david-christiansen Jan 30, 2025
10ec009
Merge remote-tracking branch 'upstream/main' into joachim/partial-fix…
david-christiansen Jan 31, 2025
184fe73
Fix typo and repeated word
david-christiansen Jan 31, 2025
eb07a0f
Merge remote-tracking branch 'upstream/main' into joachim/partial-fix…
david-christiansen Jan 31, 2025
51ff541
Clarify status of partial fixpoint terminology
david-christiansen Feb 3, 2025
8b46c56
Address table-related TODOs
david-christiansen Feb 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
3 changes: 3 additions & 0 deletions .vale/styles/config/ignore/terms.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
APIs
Abelian
Ackermann
Kleisli
Packrat
antiquotation
Expand Down Expand Up @@ -49,6 +50,8 @@ enum
equational
extensional
extensionality
fixpoint
fixpoints
functor
functor's
functors
Expand Down
16 changes: 14 additions & 2 deletions Manual/Language/RecursiveDefs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import VersoManual
import Manual.Meta

import Manual.Language.RecursiveDefs.Structural
import Manual.Language.RecursiveDefs.PartialFixpoint

open Verso.Genre Manual
open Lean.Elab.Tactic.GuardMsgs.WhitespaceMode
Expand All @@ -29,7 +30,7 @@ Furthermore, most useful recursive functions do not threaten soundness, and infi
Instead of banning recursive functions, Lean requires that each recursive function is defined safely.
While elaborating recursive definitions, the Lean elaborator also produces a justification that the function being defined is safe.{margin}[The section on {ref "elaboration-results"}[the elaborator's output] in the overview of elaboration contextualizes the elaboration of recursive definitions in the overall context of the elaborator.]

There are four main kinds of recursive functions that can be defined:
There are five main kinds of recursive functions that can be defined:

: Structurally recursive functions

Expand All @@ -47,6 +48,15 @@ There are four main kinds of recursive functions that can be defined:
Applications of functions defined via well-founded recursion are not necessarily definitionally equal to their return values, but this equality can be proved as a proposition.
Even when definitional equalities exist, these functions are frequently slow to compute with because they require reducing proof terms that are often very large.

: Recursive functions as fixpoints

Taking the function definition as an equation that specifies the behavior of the function, in certain cases the existence of a function satisfying this specification can be proven.
This strategy can apply even when the function definition is not necessarily terminating on all inputs; hence the term {tech}_partial fixpoint_.

In particular monadic functions in certain monads (e.g. {name}`Option`) are amenable for this strategy, and additional theorems are generated by lean (partial correctness).

As with well-founded recursion, applications of functions defined via partial fixpoint are not definitionally equal to their return values.

: Partial functions with nonempty ranges

For many applications, it's not important to reason about the implementation of certain functions.
Expand Down Expand Up @@ -77,7 +87,7 @@ As described in the {ref "elaboration-results"}[overview of the elaborator's out
If there is no such clause, then the elaborator performs a search, testing each parameter to the function as a candidate for structural recursion, and attempting to find a measure with a well-founded relation that decreases at each recursive call.

This section describes the rules that govern recursive functions.
After a description of mutual recursion, each of the four kinds of recursive definitions is specified, along with the tradeoffs between reasoning power and flexibility that go along with each.
After a description of mutual recursion, each of the five kinds of recursive definitions is specified, along with the tradeoffs between reasoning power and flexibility that go along with each.

# Mutual Recursion
%%%
Expand Down Expand Up @@ -162,6 +172,8 @@ tag := "well-founded-recursion"
This section will describe the translation of {deftech}[well-founded recursion].
:::

{include 0 Manual.Language.RecursiveDefs.PartialFixpoint}

# Partial and Unsafe Recursive Definitions
%%%
tag := "partial-unsafe"
Expand Down
Loading
Loading