Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Rewriting inside map expressions to manipulate finite/indexed sum expessions

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: Agnishom Chattopadhyay <agnishom AT cmi.ac.in>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] Rewriting inside map expressions to manipulate finite/indexed sum expessions
  • Date: Wed, 23 Dec 2020 14:30:03 -0600
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=agnishom AT cmi.ac.in; spf=Pass smtp.mailfrom=agnishom AT cmi.ac.in; spf=None smtp.helo=postmaster AT mail.cmi.ac.in
  • Ironport-phdr: 9a23:U30aQhCfN/3KMs9JCpGOUyQJP3N1i/DPJgcQr6AfoPdwSPX6p8bcNUDSrc9gkEXOFd2Cra4d1KyM6/+rADdbqb+681k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRoLerpBIHSk9631+ev8JHPfglEnjWwba5wIRmsswndqssbjYR/Jqs/xBbCv2dFdflRyW50P1yYggzy5t23/J5t8iRQv+wu+stdWqjkfKo2UKJVAi0+P286+MPkux/DTRCS5nQHSWUZjgBIAwne4x7kWJr6rzb3ufB82CmeOs32UKw0VDG/5KplVBPklCEKPCM//WrKiMJ/kbhbrQquqBxxwYHaYI+bOvljcK3DYdwXXnBOUtpLWiFbHo+wc4kCAuwcNuhYtYn9oF4OoAOiCAmjAuPvyyRIhn/x3a0/zu8sDwHG0xY8H9ISt3TUtM/6O7oSUeG11qbJzSjIYvRM1jfy7ojIcwshofGLXbJ1asfe1UwvFwLfglqKtYPpJTKV1uIUvmWd8uFvWv6hhXQ9pAFtvjig2N0sio/Ri48R113J8SR0zog6K9O4R0N3f9GpHZtMuiyGOYV7Tc0sTn90tCs01LELpJ62cSoKxpopxRPTdeGKf5aV7h79SeucJypzinxieLK6nRmy8E6gx/XmWcm71lZKrzFFktnLtnAIzhDc8NSHRuJh8Uek2DaDzRrc5f1eLUA1k6rXM58hwrgqlpoSq0vPBCH2mF/wgaSLdUsk4vCl5/n5brjovJORNoF5hhvgPqgylMGzG/o0PhUQU2SD5+iwyLnu8Vf6TbhKlPE6j6jUvZHAKcgGpaO1HglY2Zs55RmlFTepytEYkGEHLF1bfBKHiJDkO1TUL/D5CfezmUijkDJqx/zcJLLuHo/BLnnFkLv5fLZ97VBTyBYrwNxC+Z5ZBKsNLfP9V0PrqtDUEhE0Pxaqz+r6FtlxzoYeVniOAq+dPqPSq1iI5uc3LuaWa48Vvjf9K+Ml5/7piH80gkMSfayo3ZcNcn+3Au5qI0SfYXb0mNcODX8KvhYiTOztkFCNTTlTZ2+rU60g4jE7FZmpAJzYRoGthbyBxD20EodXZmBAEFCMEG3ne5+KW/cWO2quJZpqlSVBXry8Qacg0wuvvUn00elJNO3RrwQXs5P41N9wr8bTnA0u8iR9A8SM2nDFG2h7mGITRzgz9Kt6oAp0wRGC1/4r0LRjCdVP6qYRAU8BPpnGwrkiUo2gakf6Zt6MDW2ebJCmDDU2F4xjxtYPZwB2HtTkhxuF3iz4W+ZJxYzOP4Q99+fn51a0P9x0ki+U36wgyVAtBMpJZzX/1/xPsjPLDouMqH230qOjdKASxinIrT7Rxm+P+khTFg92A/zI

A couple of months ago I learnt about the very useful `under ext_lemma => i` tactic. Is there a way I can choose which of the parts I want to work under?

For example, my goal is something like:

 t := fun j : nat => infRobustness ψ τ (i - j) : nat -> Val
  s := fun j : nat => infRobustness ϕ τ (i - j) : nat -> Val
  ============================
  join_b 0 K (fun j : nat => t j ⊓ meet_i 0 j s) =
  (join_b 0 i (fun j : nat => infRobustness ψ τ (i - j) ⊓ meet_i 0 j s) ⊓ join_b 0 K t)

And I have a lemma

join_b_ext
     : forall (lo hi : nat) (f g : nat -> Val),
       (forall a : nat, f a = g a) -> join_b lo hi f = join_b lo hi g

If I say `under join_b_ext => j.`, it picks the first join_b in the Goal. Trying `under join_b_ext => j at 2.` does not help

On Thu, Jul 9, 2020 at 12:41 AM Kyle Stemen <bluelightning32 AT gmail.com> wrote:
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,

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.

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).

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


  • Re: [Coq-Club] Rewriting inside map expressions to manipulate finite/indexed sum expessions, Agnishom Chattopadhyay, 12/23/2020

Archive powered by MHonArc 2.6.19+.

Top of Page