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

generic map-cong and such #259

Open
mechvel opened this issue Mar 28, 2018 · 4 comments
Open

generic map-cong and such #259

mechvel opened this issue Mar 28, 2018 · 4 comments

Comments

@mechvel
Copy link
Contributor

mechvel commented Mar 28, 2018

Standard library provides map-cong, map-id, map-compose
as related to the propositional equality .
But the case of List over Setoid is highly usable.
And I suggest this:

-----------------------------------------------------------------------
module OfMapsToSetoid {α β β=} (A : Set α) (S : Setoid β β=)
 where
 open Setoid S using (_≈_)  renaming (Carrier to B; reflexive to ≈reflexive;
                                                             refl to ≈refl; sym to ≈sym; trans to ≈trans)
 infixl 2 _≈∘_

 _≈∘_ :  Rel (A → B) _
 f ≈∘ g =  (x : A) → f x ≈ g x

 ≈∘refl : Reflexive _≈∘_
 ≈∘refl _ = ≈refl

 ≈∘reflexive : _≡_ ⇒ _≈∘_
 ≈∘reflexive {x} refl =  ≈∘refl {x}

 ≈∘sym : Symmetric _≈∘_
 ≈∘sym f≈∘g =  ≈sym ∘ f≈∘g

 ≈∘trans : Transitive _≈∘_
 ≈∘trans f≈∘g g≈∘h x =  ≈trans (f≈∘g x) (g≈∘h x)

 ≈∘Equiv : IsEquivalence _≈∘_
 ≈∘Equiv = record{ refl  = \{x}         → ≈∘refl {x}
                            ; sym   = \{x} {y}     → ≈∘sym {x} {y}
                            ; trans = \{x} {y} {z} → ≈∘trans {x} {y} {z} }

 ≈∘Setoid : Setoid (α ⊔ β) (α ⊔ β=)
 ≈∘Setoid = record{ Carrier       = A → B
                              ; _≈_           = _≈∘_
                              ; isEquivalence = ≈∘Equiv }

 lSetoid = ListPoint.setoid S

 open Setoid lSetoid using () renaming (_≈_ to _=l_; refl to =l-refl)

 gen-map-cong : {f g : A → B} → f ≈∘ g → (xs : List A) → map f xs =l map g xs
 gen-map-cong _    []       =  =l-refl
 gen-map-cong f≈∘g (x ∷ xs) =  (f≈∘g x) ∷p (gen-map-cong f≈∘g xs)
 ...
---------------------------------------------------------------------------------
@MatthewDaggitt
Copy link
Contributor

Yup at some point I'll get around to porting all the relevant proofs in Data.List.Properties to Data.List.Relation.Equality.Setoid.

@MatthewDaggitt MatthewDaggitt added this to the 0.16 milestone Apr 5, 2018
@gallais gallais added the task label Apr 5, 2018
@MatthewDaggitt MatthewDaggitt removed this from the 0.16 milestone May 25, 2018
@mechvel
Copy link
Contributor Author

mechvel commented Sep 1, 2019

But there is a more general condition for map f xs ≋ map g ys, which is widely used:

map-pointwise-≈ :  {f g : A → B} {xs ys : List A} → length xs ≡ length ys →
                              All id (zipWith (\x y → f x ≈ g y) xs ys) →  
                              map f xs ≋ map g ys

Here B is the carrier of a setoid, which setoid exports , and ≋ is the pointwise equality induced by ≈.
Has lib-1.1 something for this?

@MatthewDaggitt
Copy link
Contributor

Has lib-1.1 something for this?

No, nothing that general.

@jamesmckinna
Copy link
Contributor

Yup at some point I'll get around to porting all the relevant proofs in Data.List.Properties to Data.List.Relation.Equality.Setoid.

Cf. #2360 / #2393 and discussion of module parametrisation in #2397 ... time to open a fresh issue with a roadmap/tasklist for "all the relevant proofs"?

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

No branches or pull requests

4 participants