Skip to content

Adds the AVL tree's toList/Any properties#3060

Open
mikedelorimier wants to merge 6 commits into
agda:masterfrom
mikedelorimier:avl-to-list-only
Open

Adds the AVL tree's toList/Any properties#3060
mikedelorimier wants to merge 6 commits into
agda:masterfrom
mikedelorimier:avl-to-list-only

Conversation

@mikedelorimier

Copy link
Copy Markdown
Contributor

This adds

toList⁺ : Any P t → List.Any P (toList t)
toList⁻ : List.Any P (toList t) → Any P t

These use a relation that states that the AVL's toList and toDiffList are equivalent:

toList∼toDiffList : ∀ t → toList t ∼ toDiffList t

I also added lemmas to Data.DifferenceList.Properties:

toList-refl : xs ∼ ys → toList ys ∼ ys
toList-++ : xs₁ ∼ ys₁ → (ys₂ : DiffList A) → xs₁ List.++ toList ys₂ ≡ toList (ys₁ ++ ys₂)

These let the DiffList user reason about the correspond between List and DiffList. Lower-level reasoning that uses the definition of DiffList as a function, or the definitions of toList and fromList as appends is hidden in toList-refl and toList-++. It seemed helpful to hide this reasoning at the risk of adding lemmas that seem ad-hoc.

@jamesmckinna jamesmckinna left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @mikedelorimier this looks good, but I think could be tightened up in a number of places.

Comment thread src/Data/DifferenceList/Properties.agda Outdated
Comment thread src/Data/DifferenceList/Properties.agda Outdated
Comment thread src/Data/DifferenceList/Properties.agda Outdated
Comment thread CHANGELOG.md Outdated
Comment thread src/Data/Tree/AVL/Indexed/Relation/Unary/Any/Properties/ToList.agda Outdated
Comment thread src/Data/Tree/AVL/Indexed/Relation/Unary/Any/Properties/ToList.agda Outdated

@jamesmckinna jamesmckinna left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Lots more nitpicking... sorry for that, but I think each suggestion is a (potential!?) improvement. So I won't insist on them, but...

Comment thread src/Data/Tree/AVL/Indexed/Relation/Unary/Any/Properties/ToList.agda Outdated
Comment thread CHANGELOG.md Outdated
Comment thread src/Data/DifferenceList/Properties.agda Outdated
Comment thread src/Data/DifferenceList/Properties.agda Outdated
Comment thread src/Data/DifferenceList/Properties.agda Outdated
Comment thread src/Data/DifferenceList/Properties.agda Outdated
Comment thread src/Data/DifferenceList/Properties.agda Outdated
Comment thread src/Data/Tree/AVL/Indexed/Relation/Unary/Any/Properties/ToList.agda Outdated
Comment thread src/Data/Tree/AVL/Indexed/Relation/Unary/Any/Properties/ToList.agda Outdated
Comment thread src/Data/Tree/AVL/Indexed/Relation/Unary/Any/Properties/ToList.agda Outdated
@mikedelorimier

Copy link
Copy Markdown
Contributor Author

Lots more nitpicking... sorry for that, but I think each suggestion is a (potential!?) improvement. So I won't insist on them, but...

All your comments made sense to me, and I updated the code accordingly.

@jamesmckinna

jamesmckinna commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

All looks good, let's see if we can get a second review! @gallais for example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants