Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] rewriting in an equality without eq_ind_r / transport

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] rewriting in an equality without eq_ind_r / transport


Chronological Thread 
  • From: Dan Christensen <jdc AT uwo.ca>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] rewriting in an equality without eq_ind_r / transport
  • Date: Tue, 12 Nov 2019 20:24:28 -0500
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=Neutral smtp.pra=jdc AT uwo.ca; spf=None smtp.mailfrom=gsmlcc-coq-club AT m.gmane.org; spf=None smtp.helo=postmaster AT blaine.gmane.org
  • Cancel-lock: sha1:B0s3DkgCqwI7xUfvvQXVN39gBwc=
  • Ironport-phdr: 9a23:V6l2qBEETZlwXzdYteH5dZ1GYnF86YWxBRYc798ds5kLTJ79rsiwAkXT6L1XgUPTWs2DsrQY0rGQ6vu4Ejdcqb+681k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRoLerpBIHSk9631+ev8JHPfglEnjWwba58IRmssAncuNUajYRsJ6s+1xDEvmZGd+NKyG1yOFmdhQz85sC+/J5i9yRfpfcs/NNeXKv5Yqo1U6VWACwpPG4p6sLrswLDTRaU6XsHTmoWiBtIDBPb4xz8Q5z8rzH1tut52CmdIM32UbU5Uims4qt3VBPljjoMOjgk+2/Vl8NwlrpWrgyhqRJizYDaY4+VO/Vica3Sc9wXXnZBU8VLWiBdHo+xdYkCAuwcNuhYtYn9oF4OoAOwCwa2AuPk1yFFhn/s3a07yOQhDR/J3Ao7H90QtnTfsdL4NKUPXu+p16TI0DvCb/RM1Tjh8ofFaxYsquyPU7Joacfd1E0iGgPfglmNqYHoOymZ2vkPvmWa9eZsS/yjhm8hpgpsuDag3N0shZPMho8NylDL6yF5wIEtKNKjTE50e9+kEJ1OuC2AOIt2R9ktQ2d2tyogzb0Go5G7cDALyJQh2RHfd+SKf5WM7x/jTuqdPDd1iXZ/dL6ihRu/8FKsxvPiWsS1yFpKqzBKktjItnADzRzT7c2HR+Ny/ke63DaP0xzc5f1dLU8okqrbMoctzaI0lpoOqkvOBSr2lF/5jK+TbEok/Pan5/7gYrX8qZ+QL5V0hR3mMqQyhsy/Bvw1PRQJX2iC4OizyLnj/VDiT7hRlf03kqzZsIjAKsgBp665BRVV0oc55BqlATemyodQoX5SJ1VcPRmDkoLBOlfUIfm+A+3srU6rlWJHzvaOFb37A47RI37YnbGpKbRx4GZB1w11xtkJtMEcMa0IPP+mAhy5j9ffFBJsa1XokdaiM81008YlYUzKGrWQYPHPrljO7et9ebDRNr9Qgy70Lr0e39CrjXI9ngZNL6Ot1JoRZTa3G/1gLgOee3W+2o5QQ1dPhRI3SanRsHPHVDdSY3ioWKdlvWM+To2jBIHOAIe3j+7Z0Q==
  • Mail-copies-to: never

On Nov 12, 2019, Clément Pit-Claudel
<cpitclaudel AT gmail.com>
wrote:

> Something along these lines? You'd have to generalize it to cover more
> arguments, of course.
>
> Goal forall m n, (4 * (m + (3 * n)) * 2) = 1.
> intros.
> match type of Nat.add_comm with
> | forall a b, @?f a b = _ =>
> let fn := fresh "f" in
> set f as fn;
> match goal with
> | [ |- context[fn ?x ?y] ] =>
> pattern (fn x y);
> set x as arg1; set y as arg2
> end
> end.

This looks very promising! I had tried something similar which didn't
work. Can you explain why these two lines are needed:

let fn := fresh "f" in
set f as fn;

I had tried something like:

Goal forall m n, (4 * (m + (3 * n)) * 2) = 1.
intros.
match type of Nat.add_comm with
| forall a b, @?f a b = _ =>
match goal with
| [ |- context[f ?x ?y] ] =>
pattern (f x y);
set x as arg1; set y as arg2
end
end.

but the match on the goal fails.

Also, it would be nice to not have to repeat the (f x y) pattern,
especially if I want to handle lemmas with between 0 and 10 arguments.
I tried the following:

Definition path_source {A : Type} {x y : A} (p : x = y) := x : A.

Goal forall m n, (4 * (m + (3 * n)) * 2) = 1.
intros.
let x := fresh "x" in
evar (x : nat);
let x' := eval unfold x in x in
let y := fresh "y" in
evar (y : nat);
let y' := eval unfold y in y in
let source := eval unfold path_source in (path_source (add_comm
x' y')) in
match goal with
| [ |- context[source] ] =>
pattern (source);
set x' as arg1; set y' as arg2
| _ => idtac source "unmatched"
end.

This correctly gets source to be (?x + ?y), but the match of the goal
against context[source] fails. Maybe I'm just confused and these
existential variables are different from the variables in match
patterns?

If this could work, then one could use a tactic like Chlipala's insterU
to insert the required existential variables.

Thanks again for the help!

Dan




Archive powered by MHonArc 2.6.18.

Top of Page