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

Final overhaul of list membership and associated relations #271

Merged
merged 14 commits into from
Apr 13, 2018

Conversation

MatthewDaggitt
Copy link
Contributor

@MatthewDaggitt MatthewDaggitt commented Apr 5, 2018

It's obviously an afternoon for big PRs! This finally organises list membership in a sane, logical and easy-to-use way. As a happy consequence this solves issues #70, #155 and #220.

The major changes are:

  • Moved Data/List.Any.BagAndSetEquality to Data.List.Relation.BagAndSetEquality
  • Moved the sublist relation in Data.List.Membership into it's own modules Data.List.Relation.Sublist.(Propositional/Setoid).
  • Membership is now in four modules in Data.List.Membership directory:
    • Membership.Setoid parameterised by a Setoid
    • Membership.DecSetoid parameterised by a DecSetoid
    • Membership.Propositional implictly parameterised by a type
    • Membership.DecPropositional parameterised by a proof of decidable equivalence for an implicit type.
  • The proofs concerning the membership operations find and lose and are now in the correct membership property files instead of being confusingly misplaced in Data.Any.Properties.
  • Added a whole bunch more proofs about membership

This structure makes it easy to simply pick the type of membership you're interested in and get all the misfix notation working automatically upon module import at the top of the file.

I should also mention that I chose to prefix the introduction and elimination membership proofs with as we may at some point want to have corresponding proofs with .

Copy link
Member

@gallais gallais left a comment

Choose a reason for hiding this comment

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

That's indeed a big one! :D

@@ -258,7 +260,7 @@ module _ {a p} {A : Set a} {P : A → Set p} where
------------------------------------------------------------------------
-- tabulate

module _ {a p} {A : Set a} {P : A → Set p} where
module _ {a p} {A : Set a} {P : A → Set p} where
Copy link
Member

Choose a reason for hiding this comment

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

this looks like a typo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

(x ∈ xs × y ∈ ys) ↔ (x , y) ∈ (xs ⊗ ys)
⊗-∈↔ {xs} {ys} {x} {y} =
(x ∈ xs × y ∈ ys) ↔⟨ ⊗↔′ ⟩
Any (x ≡_ ⟨×⟩ y ≡_) (xs ⊗ ys) ↔⟨ Any-cong helper (_ ∎) ⟩
Copy link
Member

Choose a reason for hiding this comment

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

This is out of alignment


finite : ∀ {a} {A : Set a} (f : ℕ ↣ A) →
∀ xs → ¬ (∀ i → Inj.Injection.to f ⟨$⟩ i ∈ xs)
finite inj [] ∈[] with ∈[] zero
Copy link
Member

Choose a reason for hiding this comment

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

Should we provide an inversion lemma ∈[]⁻ : x ∈ [] → ⊥ and use that here instead of a with + absurd pattern?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This proof is not pretty and so far I've avoided touching it as it's really quite fragile. I'll see what I can do to tidy it up...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A little tidier now.

open Setoid S using (_≈_; sym)
open Membership S using (_∈_)

∈-filter⁺ : (P? : Decidable P) → P Respects _≈_ →
Copy link
Member

Choose a reason for hiding this comment

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

These two parameters (P? : Decidable P) and P Respects _≈_ are common to both
∈-filter⁺ and ∈-filter⁻ and could be pushed in the anonymous module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

∈-filter⁻ P? resp {v} {x ∷ xs} v∈f[x∷xs] with P? x
... | no _ = Prod.map there id (∈-filter⁻ P? resp v∈f[x∷xs])
... | yes Px with v∈f[x∷xs]
... | here v≈x = here v≈x , resp (sym v≈x) Px
Copy link
Member

Choose a reason for hiding this comment

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

= out of alignment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

∈-length {_} {_ ∷ xs} (here px) = s≤s z≤n
∈-length {_} {_ ∷ xs} (there x∈xs) =
≤-trans (∈-length x∈xs) (n≤1+n (length xs))

Copy link
Member

Choose a reason for hiding this comment

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

Can't we have n≤1+n (length _) and drop the pattern matching on implicit arguments?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope but we can have n≤1+n _!

proj₂-injective refl = refl

proj-injective : ∀ (ab : Σ A B) → ab ≡ (proj₁ ab , proj₂ ab)
proj-injective (_ , _) = refl
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this true by eta-equality (i.e. no need to pattern-match)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, you're right. Removed.

@MatthewDaggitt MatthewDaggitt merged commit d9400f1 into master Apr 13, 2018
@MatthewDaggitt MatthewDaggitt deleted the membership branch April 13, 2018 14:39
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.

None yet

2 participants