coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Vadim Zaliva <vzaliva AT cmu.edu>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] FMap with abstract data type
- Date: Fri, 24 May 2019 14:23:30 -0700
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=vzaliva AT cmu.edu; spf=Pass smtp.mailfrom=vadim.zaliva AT west.cmu.edu; spf=None smtp.helo=postmaster AT mail-io1-f52.google.com
- Ironport-phdr: 9a23:WyoxmxKua1QBw5FZntmcpTZWNBhigK39O0sv0rFitYgeKv3xwZ3uMQTl6Ol3ixeRBMOHsqsC0rOI+Pm+AyQp2tWoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6nK94iQPFRrhKAF7Ovr6GpLIj8Swyuu+54Dfbx9HiTagfL9+Ngi6oRjQu8UZnIdvK7g9wQbVr3VVfOhb2XlmLk+JkRbm4cew8p9j8yBOtP8k6sVNT6b0cbkmQLJBFDgpPHw768PttRnYUAuA/WAcXXkMkhpJGAfK8hf3VYrsvyTgt+p93C6aPdDqTb0xRD+v4btnRAPuhSwaMTMy7WPZhdFqjK9Drx2hqR5wzY7abo+WKfRwYL/ScMgASmZdRMtcTTBNDp++YoYJEuEPPfxYr474p1YWohSxHxSjBOLqyjRVhXD5x6k60+U/EQ7cwQctGMwOsXXOo9XxNacST/q6wbLUwjXGcvNawyny55XVch04p/yHQLx+cc3UyUY1FgPFiE2dqYr7MDKbzOsNqXSb7+t7Ve21jW4nsBt9rSSoxscpkoXJg5gaykjf9SVlx4Y5P9y4SFJjbd6iCpRQsj+VO5JqTcMlWW5npCY6xqcatp68eSgHzoksyR3Ha/GfbYSE/hbuWPySLDp4nn5pZbOyiheo/UWg1OHxUNS/3kxQoSpfiNbMs2gA1xzN5ciDTftw5kKh1iyO1wDX8+1EIEc0mbfCJ54vwrM8iIAfsUvEHi/xl0X2iLGZel849eiv7uTrerTmppmCOI9okgzyLLgil8ilDek7MgUCRXWX9OW92bH5/UD1Xq1GjvgsnanYtJDaK94bpqm8AwJNzIYs8QuwDzaj0NgCnHgINlZFeBOZj4fzIFzPLu73Deyjg1i2jDhrwu3GMqf/DZrQM3jPiK3hcqpl605A1AozyshS6I5TCrEYOf78RkvxtMHDARIiKAy1w+PnCM1n2Y8EWGKPBLWZMKLIvlOS6OIvObrEWIhAszHkbvMh+vTGjHkjmFZbc7P684EQbSWGF/hnJg2raH7tnN5JRXkYtw4/UuXCg1ifFzNfeiDhDOoH+jgnBdf+Xs/4TYe3jenZhXvpLthtfmlDT2u0PzLwbYzVCfwJdWSfLtIzymVZB4jkcJco0FSVjCG/y7djKbCJqCgRtJam1d8souOOz1c98jt7C8nb2GaIHTktzzE4AgQu1aU6mnRTj1KK0Kx2mftdTIAB+P5STkExMIOawuBnWYn/
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.