coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Jasper Hugunin <jasperh AT cs.washington.edu>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] FMap with abstract data type
- Date: Fri, 24 May 2019 15:14:57 -0700
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=jasperh AT cs.washington.edu; spf=None smtp.mailfrom=jasperh AT cs.washington.edu; spf=None smtp.helo=postmaster AT mail-ot1-f52.google.com
- Ironport-phdr: 9a23:kywGVBCUUg+tYKi95yRgUyQJP3N1i/DPJgcQr6AfoPdwSPT4o8bcNUDSrc9gkEXOFd2Cra4d0qyP6v+rATJIyK3CmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TW94jEIBxrwKxd+KPjrFY7OlcS30P2594HObwlSizexfK5+IA+roQnMtMQajpduJ6cswRbVv3VEfPhby3l1LlyJhRb84cmw/J9n8ytOvv8q6tBNX6bncakmVLJUFDspPXw7683trhnDUBCA5mAAXWUMkxpHGBbK4RfnVZrsqCT6t+592C6HPc3qSL0/RDqv47t3RBLulSwKMSMy/mPKhcxqlK9UrxyhqB5/zYDaY4+bKeRwcb/GcNwAWWZMRNxcWzBdDo6+aYYEEuoPPfxfr4n4v1YAqQGxBRK0BOzx0D9Dm3343bA10+Q8FwHG3QogFM8JvXTWttr1L78SXv6vzKnI1jjMc+hW1S3z6YfSaRAhofCMXbR/ccrNzkkvERnJgUuNpoz4Jj6Y0PkGvWac7+plT+2vimgnphl3ojexyMYjkJPJhp4UylDf7yp5xp01KcekR058ZN6oCJ5QuDuCN4ttXsMiRHtkuCcmyrEev560Zi0Kx4o+yxHDbPyIaZSH4hL5WOmNJjd4gXRoc6+8iRaq6UWs1PHwW82u3FtJridJiMfAum0R2xDJ6sWLVP1w9Vq71zmVzQDc8ORELFg0laXFL54hxaY9lp8JvkTCGi/6gUL2jLOLekk99Oil6/rrbq/ppp+bMI90hQX+Pbo0lsOjBuQ4NxACX2md+euiyL3u5VP1TKlOg/EskaTUsIrWKdoGqqKlGQNY0pgv5w66Dzi80dQYmXcHLEhCeBKCl4XpOUvBIOvgDfihmVSskCxmyOzdPrH7DJTCNGPDkLfgfbZ75E5c1A0zzdZF651KF74BPer/WlXtu9zAEh85Lwu0zv77B9V6z4MSQH6AAquEMKzJqlKI/eIuI+yUZIAPojr9Kv4l5+TvjXAjg1Mdc7OpjtMrbyWzGe0jKEGEa1LthM0AGCEEpFkQVuvv3X+LSiZefT6SQq0h4DA9QNakBJzbS5qtqLeamjiyBZ1XYG9aDVbKHHv1IdbXE8wQYT6fd5cy2gcPUqKsHtd4iUOe8TTiwr8iFdL6vzUCvMuyhtNuofLajhEz8zNoCMLb3m2QHTktzzE4AgQu1aU6mnRTj1KK0Kx2mftdTI0B7OgPTQ4hNZ/awPB9DZb/Vh+TJo7UGmbjec2vBHQKdvx0w9IKZBwgSdCrjxSG2DbzRrFIzfqEA5s79q+a1H/0dZ5w
Jasper,This is where I started, but using `Ae` as a equality for values it is impossible to prove the following:Instance MapsTo_A_proper: Proper ((eq) ==> (Map.Equiv Ae) ==> (Ae) ==> iff) (NM.MapsTo).It boils down to:Ae x y →Map.Equiv Ae m0 m1 →Map.MapsTo k x m0 ↔ Map.MapsTo k y m1(unless I am missing something)VadimOn Fri, May 24, 2019 at 2:06 PM Jasper Hugunin <jasperh AT cs.washington.edu> wrote:You can useFrom Coq Require OrderedTypeEx FMapAVL FMapFacts.Module Map := FMapAVL.Make OrderedTypeEx.Nat_as_OT.Check Map.t : Type -> Type. (* The values can be anything you like *)Check Map.Equiv : forall X, (X -> X -> Prop) -> (Map.t X -> Map.t X -> Prop).(* You get a relation Map.Equiv for any relation between elements. Proving it is a congruence relation shouldn't be hard, but I'm not sure is in the standard library. *)(* If the equality on values is Init.Logic.eq, i.e. a1 = a2, then you can instead use Map.Equal, which does have Proper instances proven in MapProperties. *)Module MapProperties := FMapFacts.Properties Map.(* Also MapProperties.F has useful stuff. *)(* This can be used as *)Axiom A : Type.Check Map.t A. (* This is the type of maps with keys in nat and values in A. *)- Jasper HuguninOn Fri, May 24, 2019 at 11:51 AM Vadim Zaliva <vzaliva AT cmu.edu> wrote:I am trying to figure out how to use FMap with abstract data type and
equality. I need a map where the keys are natural numbers, but values belong to an abstract typeA
. I can assume that this type has an equalityAe
which is decidable, and a strict ordering.I will need to have an Equiv relation between two maps (backed up by
Ae
for elements). Finally, I would like to be able to proveProper
instances for basic operations, like:Instance MapsTo_A_proper: Proper ((eq) ==> (equiv) ==> (equiv) ==> iff) (NM.MapsTo). Instance find_A_proper: Proper ((eq) ==> (equiv) ==> (equiv)) (NM.find (elt:=A)).
It looks like the map needs to be abstracted over
A
using a module.
This post http://www.newartisans.com/2016/10/using-fmap-in-coq/ gives
some good intro but stop shorts from abstracting values. It also looks
like I will need to useSord
functor fromFMapInterface
. I feel
like all pieces are there but having difficulty putting it all
together. I have not been able to find any relevant examples. Could
somebody please point me in the right direction? Thanks!
—
Vadim Zaliva![]()
CMU ECE Ph.D. candidate
Mobile/Signal/WhatsApp: +1(510)220-1060
- [Coq-Club] FMap with abstract data type, Vadim Zaliva, 05/24/2019
- Re: [Coq-Club] FMap with abstract data type, Jasper Hugunin, 05/24/2019
- Re: [Coq-Club] FMap with abstract data type, Vadim Zaliva, 05/24/2019
- Re: [Coq-Club] FMap with abstract data type, Jasper Hugunin, 05/25/2019
- Re: [Coq-Club] FMap with abstract data type, Vadim Zaliva, 05/25/2019
- Re: [Coq-Club] FMap with abstract data type, Jasper Hugunin, 05/25/2019
- Re: [Coq-Club] FMap with abstract data type, Vadim Zaliva, 05/25/2019
- Re: [Coq-Club] FMap with abstract data type, Jasper Hugunin, 05/25/2019
- Re: [Coq-Club] FMap with abstract data type, Vadim Zaliva, 05/25/2019
- Re: [Coq-Club] FMap with abstract data type, Jasper Hugunin, 05/25/2019
- Re: [Coq-Club] FMap with abstract data type, Vadim Zaliva, 05/24/2019
- Re: [Coq-Club] FMap with abstract data type, Jasper Hugunin, 05/24/2019
Archive powered by MHonArc 2.6.18.