leanprover / leanprover/reference-manual
Example for "inaccessible patterns" is not really helpful?
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 129
- Forks
- 67
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 16
Description
I am trying to understand how inaccessible patterns work, and I was hoping the given example would help:
It doesn't.
AFAICT, the use of the inaccessible pattern in this example is not necessary. It seems to work fine if I just remove it:
def half' (n : Nat) : Nat :=
match n.parity with
| .even h => h
| .odd h => h
When I do #print half', I see that the compiler indeed rewrites it using the inaccessible pattern notation (as in the original implementation), but this doesn't really help my understanding (even if that would have been mentioned in the manual).
Can this example please be replaced by one that actually needs to use an inaccessible pattern (i.e. it wouldn't work without it)?
I would hope to get a bit more explanatory power out of it ...
If the example cannot be changed, it would at least probably help a little bit to mention that the compiler adds the inaccessible pattern automatically when possible (or whatever the rules are for that).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at Manual/Terms.lean around lines 1279-1282 and compare the current inaccessible-pattern example with the reported version without the pattern. Replace it with an example that genuinely requires inaccessible-pattern notation, or clarify in the surrounding text when the compiler inserts that notation automatically. Done means the manual example provides explanatory value and matches the documented behavior.
Written by the indexing model from the issue text.
Assessment
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100