Skip to content

Conversation

@wkrozowski
Copy link
Contributor

@wkrozowski wkrozowski commented Oct 14, 2025

This PR adds iterators and slices for DTreeMap/TreeMap/TreeSet based on zippers and provides basic lemmas about them.

@datokrat datokrat mentioned this pull request Oct 16, 2025
7 tasks
@wkrozowski wkrozowski changed the title feat: Add TreeMap iterators (DRAFT) feat: Add DTreeMap/TreeMap/TreeSet iterators and slices Oct 30, 2025
@wkrozowski wkrozowski added the changelog-language Language features and metaprograms label Oct 30, 2025
@wkrozowski wkrozowski marked this pull request as ready for review October 30, 2025 21:49
Raw.valuesIter cmp ⟨m.inner⟩

@[simp]
public theorem iter_toList {cmp : α → α → Ordering} (m : DTreeMap α β cmp) :
Copy link
Member

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.

@wkrozowski wkrozowski added changelog-library Library and removed changelog-language Language features and metaprograms labels Oct 31, 2025
@wkrozowski wkrozowski changed the title feat: Add DTreeMap/TreeMap/TreeSet iterators and slices feat: dd DTreeMap/TreeMap/TreeSet iterators and slices Oct 31, 2025
@wkrozowski wkrozowski changed the title feat: dd DTreeMap/TreeMap/TreeSet iterators and slices feat: add DTreeMap/TreeMap/TreeSet iterators and slices Oct 31, 2025
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 : α} :
Copy link
Member

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
Copy link
Member

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 moment

This 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.

Copy link
Member

@TwoFX TwoFX left a 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!

@wkrozowski wkrozowski added this pull request to the merge queue Nov 11, 2025
github-merge-queue bot pushed a commit that referenced this pull request Nov 11, 2025
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]>
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 11, 2025
@wkrozowski wkrozowski added this pull request to the merge queue Nov 11, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 11, 2025
@wkrozowski wkrozowski added this pull request to the merge queue Nov 11, 2025
Merged via the queue into leanprover:master with commit 34f9798 Nov 11, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-library Library toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants