-
Notifications
You must be signed in to change notification settings - Fork 234
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
Conversation
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.
That's indeed a big one! :D
src/Data/List/All/Properties.agda
Outdated
@@ -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 |
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.
this looks like a typo
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.
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 (_ ∎) ⟩ |
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.
This ↔
is out of alignment
|
||
finite : ∀ {a} {A : Set a} (f : ℕ ↣ A) → | ||
∀ xs → ¬ (∀ i → Inj.Injection.to f ⟨$⟩ i ∈ xs) | ||
finite inj [] ∈[] with ∈[] zero |
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.
Should we provide an inversion lemma ∈[]⁻ : x ∈ [] → ⊥
and use that here instead of a with
+ absurd pattern?
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.
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...
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.
A little tidier now.
open Setoid S using (_≈_; sym) | ||
open Membership S using (_∈_) | ||
|
||
∈-filter⁺ : (P? : Decidable P) → P Respects _≈_ → |
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.
These two parameters (P? : Decidable P)
and P Respects _≈_
are common to both
∈-filter⁺
and ∈-filter⁻
and could be pushed in the anonymous module.
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.
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 |
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.
=
out of alignment
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.
Fixed
∈-length {_} {_ ∷ xs} (here px) = s≤s z≤n | ||
∈-length {_} {_ ∷ xs} (there x∈xs) = | ||
≤-trans (∈-length x∈xs) (n≤1+n (length xs)) | ||
|
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.
Can't we have n≤1+n (length _)
and drop the pattern matching on implicit arguments?
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.
Nope but we can have n≤1+n _
!
src/Data/Product/Properties.agda
Outdated
proj₂-injective refl = refl | ||
|
||
proj-injective : ∀ (ab : Σ A B) → ab ≡ (proj₁ ab , proj₂ ab) | ||
proj-injective (_ , _) = refl |
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.
Isn't this true by eta-equality (i.e. no need to pattern-match)?
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.
Yup, you're right. Removed.
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:
Data/List.Any.BagAndSetEquality
toData.List.Relation.BagAndSetEquality
Data.List.Membership
into it's own modulesData.List.Relation.Sublist.(Propositional/Setoid)
.Data.List.Membership
directory:Membership.Setoid
parameterised by aSetoid
Membership.DecSetoid
parameterised by aDecSetoid
Membership.Propositional
implictly parameterised by a typeMembership.DecPropositional
parameterised by a proof of decidable equivalence for an implicit type.find
andlose
and are now in the correct membership property files instead of being confusingly misplaced inData.Any.Properties
.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∉
.