coq-club AT inria.fr
Subject: The Coq mailing list
List archive
Re: [Coq-Club] Rewriting inside map expressions to manipulate finite/indexed sum expessions
Chronological Thread
- From: "Kyle Stemen" <ncyms8r3x2 AT snkmail.com>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Rewriting inside map expressions to manipulate finite/indexed sum expessions
- Date: Wed, 8 Jul 2020 17:33:54 -0700
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=ncyms8r3x2 AT snkmail.com; spf=Pass smtp.mailfrom=ncyms8r3x2 AT snkmail.com; spf=None smtp.helo=postmaster AT sneak2.sneakemail.com
- Ironport-phdr: 9a23:4G06eB1gm+juYxCksmDT+DRfVm0co7zxezQtwd8ZseMSL/ad9pjvdHbS+e9qxAeQG9mCtbQd26GN7eigATVGvc/c9ihaMdRlbFwssY0uhQsuAcqIWwXQDcXBSGgEJvlET0Jv5HqhMEJYS47UblzWpWCuv3ZJQk2sfQV6Kf7oFYHMks+5y/69+4HJYwVPmTGxfa5+IA+5oAnMt8Qam5ZuJ6U+xhbHo3ZDZuBayX91KV6JkBvw+8e98IR//yhMvv4q6tJNX7j9c6kkV7JTES4oM3oy5M3ltBnDSRWA634BWWgIkRRGHhbI4gjiUpj+riX1uOx92DKHPcLtVrA7RS6i76ZwRxD2jioMKiM0/3vWisx0i6JbvQ6hqhliyIPafI2ZKPxzdb7bcNgHR2ROQ9xRWjRODYOybYQBD+QPM+VFoYfju1QAqgCzChOwCO710DJFnGP60K883u88EQ/GxgsgH9cWvXjaqdv0NKMSXv6ox6fV0TXMcfZW1in76ITGbxsspveMUq5wcMrU0kkiFBnFg1ufqID7JD6VzeINs2ue7+V6VOKvj3QrpB12ojiq38ohjJTCiY0JxF7e7yp53Jo1KsOiSE59edOoDZReuiOVOoZrX84vXmVltTskx7MIpZO2fioHxYg5yxDRdvGKbZaF7xLjWuufPTt1mHFodKyhihqu/0atyvHwW8+p21hEqSpFl8PDtnEL1xHL8MeHRf19/ka62TaP0ADT7/hILloolabCN5Ehx78wmoAJvkvfBCP2mUP2gLeXdkUi4Oio6v7obq/opp+GMYJ/lwLwMrw2l8G+Duk0KAcDUmmB9eih1LDu+Vf1TKhFg/A1iqXVrozWKMABqqO6AwJZyJgv5wihAzu8zdgVn2cLIVRYcxydlYfpIUvBIPXgAPe/nVuslDBryujdPr3nHJrCNHvDnKn7cbZm7U5T1hA8zdNB6JJREL4BIfbzVlXtu9zfCx81Kw20w+D5B9Vhzo4TWG2CDrWWPa7Tq1OE++IiLu2WaIMItzvwKOAp5/v0gn84nV8dc7Op3ZwSaH2gGPRpP0WYYX/3gtoCC2cHsAU/QPLxhV2ZVz5TZHOyULg95jE/Eo6pEYDDRoW1jLybwCi7BoFWZnxBCl2UDXjocJyEV+4QZyKWP89uiScJVaOhSo8kzRGhrhX2y7thLurO+y0Xr4jv1NZv576bqRZn/jttSs+ZzmulTmdun2pOSSVl8rp4pBk36UaH3OBDn/FdGNoZr6dPWRY/Ls7GlPwgI8v0WQfIf9PPQ1GjFIb1SQotR848loddK312HM+v20iajniaRoQNnrnOP6Qat6fV3nz/PcF4ki2Uz68iilAnRo1EMmj03/cjpTiWPJbAlgCir4jvbb4VhXWf72GAyGOPuAdTVwsiCfyYD0BaXVPfqJHC3m2HT7KqDu58YBBHxMeBcO1RbNDgjlhDTfbnft/ZZjDplg==
I use the setoid_rewrite tactic to do rewrites under the map function. To enable it, you have to show that map is a pointwise_relation,
Note that you may have to explicitly specify all of the parameters to get the setoid_rewrite to work. That's why the example below has (fun n => f n) instead of (f).Require Import Coq.Classes.Morphisms.Require Import Coq.Setoids.Setoid.Require Import List.Import ListNotations.Instance map_ext_inst {T U: Type} :Proper (pointwise_relation T eq ==> eq ==> eq) (@map T U).Proof.intros f g Hf_g l1 l2 Hl1_l2.rewrite Hl1_l2.apply map_ext.assumption.Qed.
Example map_ext_rewrite_test : forall (f g: nat -> nat) l,(forall a, f a = g a) ->map (fun n => f n) l = map (fun n => g n) l.Proof.intros f g l Heq.setoid_rewrite Heq.reflexivity.Qed.
On Wed, Jul 8, 2020 at 4:57 PM Agnishom Chattopadhyay agnishom-at-cmi.ac.in |coq-club/Example Allow| <x0mk80tcezojwqt AT sneakemail.com> wrote:
Thanks for pointing out this feature of => i. I will look into the documentation and try to understand how it works.On Wed, Jul 8, 2020 at 6:49 PM Laurent Thery <Laurent.Thery AT inria.fr> wrote:
Hi,
I am not sure I follow everything but it seems that in your particular
example you could use Nat.min_0_r.
More generally if you look at the documentation of under you can
handle binders :
https://coq.inria.fr/distrib/current/refman/proof-engine/ssreflect-proof-language.html
For example, interactively this gives:
From mathcomp Require Import ssreflect.
Require Import List PeanoNat.
Goal forall l, (map (fun i => i + 1) l) = l.
Proof.
move=> l.
under map_ext => i.
replace (i + 1) with (1 + i); last first.
by rewrite Nat.add_comm.
over.
Hope this helps
--
Laurent
- [Coq-Club] Rewriting inside map expressions to manipulate finite/indexed sum expessions, Agnishom Chattopadhyay, 07/08/2020
- Re: [Coq-Club] Rewriting inside map expressions to manipulate finite/indexed sum expessions, Laurent Thery, 07/08/2020
- Re: [Coq-Club] Rewriting inside map expressions to manipulate finite/indexed sum expessions, Erik Martin-Dorel, 07/08/2020
- Re: [Coq-Club] Rewriting inside map expressions to manipulate finite/indexed sum expessions, Agnishom Chattopadhyay, 07/08/2020
- Re: [Coq-Club] Rewriting inside map expressions to manipulate finite/indexed sum expessions, Laurent Thery, 07/08/2020
- Re: [Coq-Club] Rewriting inside map expressions to manipulate finite/indexed sum expessions, Agnishom Chattopadhyay, 07/09/2020
- Re: [Coq-Club] Rewriting inside map expressions to manipulate finite/indexed sum expessions, Laurent Thery, 07/09/2020
- Re: [Coq-Club] Rewriting inside map expressions to manipulate finite/indexed sum expessions, Agnishom Chattopadhyay, 07/09/2020
- Re: [Coq-Club] Rewriting inside map expressions to manipulate finite/indexed sum expessions, Kyle Stemen, 07/09/2020
- Re: [Coq-Club] Rewriting inside map expressions to manipulate finite/indexed sum expessions, Kyle Stemen, 07/09/2020
- Re: [Coq-Club] Rewriting inside map expressions to manipulate finite/indexed sum expessions, Laurent Thery, 07/09/2020
- Re: [Coq-Club] Rewriting inside map expressions to manipulate finite/indexed sum expessions, Agnishom Chattopadhyay, 07/09/2020
- Re: [Coq-Club] Rewriting inside map expressions to manipulate finite/indexed sum expessions, Laurent Thery, 07/08/2020
- Re: [Coq-Club] Rewriting inside map expressions to manipulate finite/indexed sum expessions, Agnishom Chattopadhyay, 07/08/2020
- Re: [Coq-Club] Rewriting inside map expressions to manipulate finite/indexed sum expessions, Erik Martin-Dorel, 07/08/2020
- Re: [Coq-Club] Rewriting inside map expressions to manipulate finite/indexed sum expessions, Laurent Thery, 07/08/2020
Archive powered by MHonArc 2.6.19+.