-
Notifications
You must be signed in to change notification settings - Fork 715
feat: add DTreeMap/TreeMap/TreeSet iterators and slices #10776
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: add DTreeMap/TreeMap/TreeSet iterators and slices #10776
Conversation
src/Std/Data/DTreeMap/Iterator.lean
Outdated
| Raw.valuesIter cmp ⟨m.inner⟩ | ||
|
|
||
| @[simp] | ||
| public theorem iter_toList {cmp : α → α → Ordering} (m : DTreeMap α β cmp) : |
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.
Unresolving because the name is still not correct.
src/Std/Data/DTreeMap/Raw/Slice.lean
Outdated
| letI _ : Ord α := ⟨cmp⟩; ⟨fun carrier range => ⟨carrier.inner, range⟩⟩ | ||
|
|
||
| public theorem toList_ric {α : Type u} {β : α → Type v} (cmp : α → α → Ordering := by exact compare) | ||
| [TransCmp cmp] {t : Raw α β cmp} {wf : t.WF} {bound : α} : |
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.
I think the wf argument should be explicit, otherwise it seems to me that the theorem would be needlessly difficult to apply.
| public import Std.Data.TreeMap.Basic | ||
|
|
||
| /-! | ||
| This module provides slice notation for `TreeMap` slices and implements an iterator |
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.
At the moment the situation is this:
example : t[1<...<3].toList = t.toList.filter (fun p => compare p.1 1 = .gt && compare p.1 3 = .lt) := by
simp -- this works
example : t[1<...<3].iter.toList = t.toList.filter (fun p => compare p.1 1 = .gt && compare p.1 3 = .lt) := by
simp -- this fails at the momentThis is slightly regrettable, but it seems that the solution here would be to make the reverse of Std.Slice.toList_eq_toList_iter into a simp lemma which is independent of this PR. I will discuss with Paul.
TwoFX
left a comment
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.
One tiny typo, otherwise this looks ready to merge!
Thanks!
Co-authored-by: Markus Himmel <[email protected]>
This PR adds iterators and slices for `DTreeMap`/`TreeMap`/`TreeSet` based on zippers and provides basic lemmas about them. --------- Co-authored-by: Markus Himmel <[email protected]>
This PR adds iterators and slices for
DTreeMap/TreeMap/TreeSetbased on zippers and provides basic lemmas about them.