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

[Merged by Bors] - feat: port Data.List.Rdrop #1382

Closed
wants to merge 17 commits into from
Closed

Conversation

mo271
Copy link
Collaborator

@mo271 mo271 commented Jan 6, 2023

No description provided.

@mo271 mo271 added WIP Work in progress mathlib-port This is a port of a theory file from mathlib. labels Jan 6, 2023
@semorrison semorrison added the merge-conflict The PR has a merge conflict with master, and needs manual merging. label Jan 6, 2023
@semorrison semorrison removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. label Jan 6, 2023
@mo271 mo271 added the help-wanted The author needs attention to resolve issues label Jan 6, 2023
theorem rdropWhile_last_not (hl : l.rdropWhile p ≠ []) : ¬p ((rdropWhile p l).getLast hl) := by
simp_rw [rdropWhile]
rw [getLast_reverse]
exact dropWhile_nthLe_zero_not _ _ _
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first argument here should be 0, I guess, but somehow it can't find that.

@LukasMias LukasMias added awaiting-review The author would like community review of the PR and removed help-wanted The author needs attention to resolve issues WIP Work in progress labels Jan 7, 2023
@LukasMias
Copy link
Collaborator

The theorems now all work, but it took some unpleasant rewriting of some of the proofs, largely because there's a lot of matching on propositions that have to be decided first. As I understand, lean3 used to do this automatically. It's not pretty, maybe there are better ways to deal with it, but I think it's ready for review anyway.

@mo271
Copy link
Collaborator Author

mo271 commented Jan 7, 2023

Nice job!

Do you think it is worth replacing the .nthLe with get in dropWhile_eq_self_iff?
Here again it somehow seems that one can't just write ...l.get 0 hl, I suspect because somehow this is not the correct 0.

@LukasMias
Copy link
Collaborator

Nice job!

Do you think it is worth replacing the .nthLe with get in dropWhile_eq_self_iff? Here again it somehow seems that one can't just write ...l.get 0 hl, I suspect because somehow this is not the correct 0.

I was also struggling to get that to work, but if we really treat nthLe as deprecated, then I guess that's the right thing to do. What seems to work is l.get ⟨0, hl⟩, so lifting 0 : ℕ to type Fin (length l) by providing a proof that 0 < l.length. I'll push the change :)

@LukasMias
Copy link
Collaborator

I may have been too hasty! I looked up what people have been saying on Zulip, and there seem to be good arguments for leaving nthLe intact for now if it appears in the statement, see here. I will undo my change.

@ChrisHughes24
Copy link
Member

Maybe rdropWhile should take a Boolean to be consistent with the rest of the List stuff?

@mo271
Copy link
Collaborator Author

mo271 commented Jan 10, 2023

Maybe rdropWhile should take a Boolean to be consistent with the rest of the List stuff?

Should we do this refactor now or leave a TODO?

@jcommelin
Copy link
Member

@mo271 It seems that this "refactor to Boolean" is done while porting. Not ideal, but ...

@mo271
Copy link
Collaborator Author

mo271 commented Jan 10, 2023

@mo271 It seems that this "refactor to Boolean" is done while porting. Not ideal, but ...

I tried to do the changes to rdropWhile suggested by @ChrisHughes24. This lead to analogous changes in
takeWhile_prefix, dropWhile_suffix, isPrefix.filter, isSuffix.filter and isInfix.filter in Mathlib.Data.List.Infix.
Now both Mathlib.Data.List.Infix and Mathlib.Data.List.Rdrop don't contain any functions to Prop anymore.

Copy link
Member

@jcommelin jcommelin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 🎉

bors merge

@semorrison semorrison added ready-to-merge This PR has been sent to bors. and removed awaiting-review The author would like community review of the PR labels Jan 10, 2023
bors bot pushed a commit that referenced this pull request Jan 10, 2023
Co-authored-by: Moritz Firsching <firsching@google.com>
Co-authored-by: qawbecrdtey <40463813+qawbecrdtey@users.noreply.github.com>
Co-authored-by: Lukas Miaskiwskyi <lukas.mias@gmail.com>
@bors
Copy link

bors bot commented Jan 10, 2023

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat: port Data.List.Rdrop [Merged by Bors] - feat: port Data.List.Rdrop Jan 10, 2023
@bors bors bot closed this Jan 10, 2023
@bors bors bot deleted the port/Data.List.Rdrop branch January 10, 2023 15:10
jcommelin pushed a commit that referenced this pull request Jan 23, 2023
Co-authored-by: Moritz Firsching <firsching@google.com>
Co-authored-by: qawbecrdtey <40463813+qawbecrdtey@users.noreply.github.com>
Co-authored-by: Lukas Miaskiwskyi <lukas.mias@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mathlib-port This is a port of a theory file from mathlib. ready-to-merge This PR has been sent to bors.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants