Skip to content

Conversation

@HeinrichApfelmus
Copy link
Contributor

@HeinrichApfelmus HeinrichApfelmus commented Jan 24, 2025

The purpose of this pull request is to add some functions from the module Data.List. Specifically, we add

  • nub with a proof of a property prop-elem-nub
  • deleteAll as a helper function for nub
  • sort as a postulate

We also add Haskell.Data.Ord, this is needed for sortOn.

I quite like the property

prop-elem-nub
  : ∀ ⦃ _ : Eq a ⦄ ⦃ _ : IsLawfulEq a ⦄
      (x : a) (ys : List a)
   elem x (nub ys)
    ≡ elem x ys

as it expresses a logical equivalence in terms of , I think that this is only available for Bool, not for Prop / Set. The proof is also very succinct.

On the other hand, the proof for prop-elem-deleteAll is somewhat lengthy, but I'm not sure that this can be avoided, as we have to use transitivity of == at crucial points in the proof. I am using the induction hypothesis prop-elem-deleteAll x y zs in a with clause in order to avoid doing substitutions by hand via cong.

Copy link
Member

@jespercockx jespercockx left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I have a few minor nitpicks, but otherwise this looks very good.

@HeinrichApfelmus HeinrichApfelmus force-pushed the HeinrichApfelmus/data-list branch from bbe636e to 2cf0f3d Compare January 29, 2025 22:22
@HeinrichApfelmus HeinrichApfelmus force-pushed the HeinrichApfelmus/data-list branch from 2cf0f3d to 3365fa5 Compare March 10, 2025 13:44
@HeinrichApfelmus HeinrichApfelmus force-pushed the HeinrichApfelmus/data-list branch from 3365fa5 to 15f452e Compare March 10, 2025 14:25
@HeinrichApfelmus HeinrichApfelmus force-pushed the HeinrichApfelmus/data-list branch from 15f452e to 4cea90b Compare March 10, 2025 16:46
Copy link
Contributor

@omelkonian omelkonian left a comment

Choose a reason for hiding this comment

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

LGTM

@omelkonian omelkonian merged commit 4a52e34 into agda:master Mar 10, 2025
7 checks passed
@HeinrichApfelmus HeinrichApfelmus deleted the HeinrichApfelmus/data-list branch March 12, 2025 14:57
@jespercockx jespercockx added this to the 1.4 milestone Sep 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants