-
Notifications
You must be signed in to change notification settings - Fork 108
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: Define dependent version of Fin.foldl
#1071
Conversation
Can you write the theorem relating it to the usual |
Other directions that would be good:
|
Actually, I don't know how to state the theorem. A natural attempt is:
but we run into the problem of Lean not knowing that |
This has been added. As written, these new dependent versions add no overhead after compilation (some initial experiments also confirm this). Because of this, do you think we could redefine (say) Also, in terms of naming, I think writing
to
in order to match the dependent version. In summary, we can have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
foldl
and foldr
are standard names in functional programming, we should stick to that convention. Use dfoldl
/dfoldr
or foldlDep
/foldrDep
.
Mathlib CI status (docs):
|
@kim-em could you protect |
Looks good. Make sure to add |
67b3afd
to
be0ea0f
Compare
Avoid code duplication by defininig:
I'm not sure the same works for |
When I tried to do this, the theorems can't seem to infer the type of |
The |
2b6f440
to
a316500
Compare
a316500
to
62ba9ac
Compare
I completed the last few changes for you. Let me know if you would like to revert something. |
I just approved but I then noticed that the docstrings should not just refer to other functions. Please expand them and mention the relation with non-dependent functions as an additional note. |
I filled out the docstrings. Thanks for all the help! |
Done in leanprover/lean4#6315 |
This PR defines the dependent versions of
Fin.fold{l/r}{M}
. This is 4 functions in total,Fin.dfold{l/r}{M}
, and we give similar theorems as the non-dependent versions, plus theorems that relate the dependent to the non-dependent version.Two theorems are currently missing:
dfold{l/r}_rev
. Even stating these theorems is a pain due to casting, so I'd prefer to add them later.