coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Jason -Zhong Sheng- Hu <fdhzs2010 AT hotmail.com>
- To: John M Grosen <jmgrosen AT mit.edu>, "coq-club AT inria.fr" <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] change uses inferior type inference
- Date: Thu, 28 Feb 2019 05:03:44 +0000
- Accept-language: en-CA, en-US
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=fdhzs2010 AT hotmail.com; spf=Pass smtp.mailfrom=fdhzs2010 AT hotmail.com; spf=Pass smtp.helo=postmaster AT NAM05-DM3-obe.outbound.protection.outlook.com
- Ironport-phdr: 9a23:VZ+LSh9lSbKyLv9uRHKM819IXTAuvvDOBiVQ1KB21u8cTK2v8tzYMVDF4r011RmVBdWds6oMotGVmpioYXYH75eFvSJKW713fDhBt/8rmRc9CtWOE0zxIa2iRSU7GMNfSA0tpCnjYgBaF8nkelLdvGC54yIMFRXjLwp1Ifn+FpLPg8it2O2+557ebx9UiDahfLh/MAi4oQLNu8cMnIBsMLwxyhzHontJf+RZ22ZlLk+Nkhj/+8m94odt/zxftPw9+cFAV776f7kjQrxDEDsmKWE169b1uhTFUACC+2ETUmQSkhpPHgjF8BT3VYr/vyfmquZw3jSRMNboRr4oRzut86ZrSAfpiCgZMT457HrXgdF0gK5CvR6tuwBzz4vSbYqINvRxY7ndcMsaS2RfQ8hRSyJPDICyb4QNE+UOMv1VoJPhq1cStxayGRWgCP3pxzRVhnH2x6o60+E5HA/CxgMgBNUOsHLJp9nsN6gSUee1zK/HzT7ecv1W2Sny6I7Hchw4vPqCX69wetfWxEkhCgzFjlSRqZf7Mz+Jy+gBr3OW7+pnVeKzjm4osQBxojy1ysgwjYnJg5sYx1bZ/it3x4Y1IMe3SE99YdO8DJRQsDuaN41oTcMmR2Fkojg1xaAbuZO9YSMEy4wnygbQZvCbaYSF5gzvWPyMLTp3nn5pZq6ziw688Ue+yeDwSsy53VNRoSVZjtbBtXUA2AfP5sWGSPZw+0ms1i2V2A3T7+xEL0E5mKnZJpMn37U+jIAcsV7ZES/zgEj2jLGZdkEj+uWw8+rqfrLoqoOcOoNthA/wNaojltW4AesjLAcCRW+b+fmg1LL4+k35XbNKgeAsnqnBqpDaItgbqbClDA9J04Yj7BC/Ay2h0NQFgXkHKFVFeBWEj4TzJ17OJ/X4Ae++g1Sqjjhr2+jLM7L9DpnXKnXPjq3tcaty5kJG1gY/0chT55dOBbEAJPLzVFXxtNvdDhIhPQy73ubnCdRm1o8ARW6DH7OVPbjSsV+P+uIvJvODZI4RuDrnN/cl4PvugWcjmVABZampwYcXaHegE/t6JEWZeGPgjcsFEWcXpQUzV/fqiV2HUT5LfXm+RaM85jchCIKnF4jPXI6tgKbSlBu8S79RZmYOLxijC3DzeoPMD/UJZziVOcJnujkFSf6sR5J3kVnkvwjjjrFjM+D8+ysCtJul2sI/r7nYkgh3/jhpBeyc1XuMRid6hDVbaSUx2fVdqFd6zB/G46h/hfMQLtxe4fwMGicnfcrSw+xoEIqqA1rpftCVTV+nRpOtBjRnHYF5+MMHf0soQ4bqtRvExSf/RuZNz+XaVqxxybrV2j3KH+g4zn/H0Kc7iFx/GZlPMnGjj697sQPUAtyQyhnLp+ORba0ZmRX12iKb12PX5xNYVxJ1WKTBG3sYYxmO9Imr1gb5V7arTI8fHE5BxMqFdvQYTPTM1QgDaNK4fdPUbiS2hnu6AguOyvWUdo32dm4B3SLbTk8ZjwQU+nXAPg87VH6s
Hi,
I have an idea. You can take the advantage of the fact that all well-formed terms in Coq must have types, and that will enforce unification.
Ltac unify_by t1 t2 :=
let t := constr:(eq_refl : t1 = t2) in
match type of t with
| _ = ?t => t
end.
Tactic Notation "my" "change" constr(t1) "with" uconstr(t2) :=
let t := unify_by t1 t2 in
change t1 with t.
It at very least handles your example.
Goal @inr bool _ (1 + 1) = inr 2.
Fail change (@inr bool _ (1 + 1)) with (inr 2).
(* The command has indeed failed with message:
Cannot infer the implicit parameter A of inr whose type is "Type". *)
From: coq-club-request AT inria.fr <coq-club-request AT inria.fr> on behalf of John M Grosen <jmgrosen AT mit.edu>
Sent: February 27, 2019 6:34 PM
To: coq-club AT inria.fr
Subject: RE: [Coq-Club] change uses inferior type inference
Sent: February 27, 2019 6:34 PM
To: coq-club AT inria.fr
Subject: RE: [Coq-Club] change uses inferior type inference
Try using Tactic Notation's uconstr for untyped terms:
Tactic Notation "changee" uconstr(a) "with" uconstr(b) :=
assert (a=b) as XX by reflexivity;
rewrite XX;
clear XX.
Goal inr true = inl 5.
changee (inr true:(nat+bool)) with (inr (negb false)). (* succeeds *)
--
John
________________________________________
From: coq-club-request AT inria.fr [coq-club-request AT inria.fr] on behalf of Abhishek Anand [abhishek.anand.iitg AT gmail.com]
Sent: Wednesday, February 27, 2019 3:26 PM
To: coq-club
Subject: Re: [Coq-Club] change uses inferior type inference
Here is a minimal example to illustrate the problem:
assert (inl 2 = inr true). (* succeeds *)
change (inr true:(nat+bool)) with (inr true). (* Cannot infer the
implicit parameter A of inr ...*)
-- Abhishek
http://www.cs.cornell.edu/~aa755/
On Wed, Feb 27, 2019 at 3:18 PM Abhishek Anand
<abhishek.anand.iitg AT gmail.com> wrote:
>
> Many times, the following tactic succeeds:
>
> assert (a=b) by reflexivity.
>
> but the following fails with some type inference error suggesting that
> while inferring types, Coq is not exploiting the fact that `a` and `b`
> must have the same types:
>
> change a with b
>
> Can the `change` tactic be made as smart as `assert (_=_)`?
>
> I thought the following Ltac would work, but it suffers from the same
> problem as `change`.
> Ltac changee a b :=
> assert (a=b) as XX by reflexivity;
> rewrite XX;
> clear XX.
>
> I guess terms are fully typed before being passed to Ltac.
>
> Thanks,
> -- Abhishek
> http://www.cs.cornell.edu/~aa755/
Tactic Notation "changee" uconstr(a) "with" uconstr(b) :=
assert (a=b) as XX by reflexivity;
rewrite XX;
clear XX.
Goal inr true = inl 5.
changee (inr true:(nat+bool)) with (inr (negb false)). (* succeeds *)
--
John
________________________________________
From: coq-club-request AT inria.fr [coq-club-request AT inria.fr] on behalf of Abhishek Anand [abhishek.anand.iitg AT gmail.com]
Sent: Wednesday, February 27, 2019 3:26 PM
To: coq-club
Subject: Re: [Coq-Club] change uses inferior type inference
Here is a minimal example to illustrate the problem:
assert (inl 2 = inr true). (* succeeds *)
change (inr true:(nat+bool)) with (inr true). (* Cannot infer the
implicit parameter A of inr ...*)
-- Abhishek
http://www.cs.cornell.edu/~aa755/
On Wed, Feb 27, 2019 at 3:18 PM Abhishek Anand
<abhishek.anand.iitg AT gmail.com> wrote:
>
> Many times, the following tactic succeeds:
>
> assert (a=b) by reflexivity.
>
> but the following fails with some type inference error suggesting that
> while inferring types, Coq is not exploiting the fact that `a` and `b`
> must have the same types:
>
> change a with b
>
> Can the `change` tactic be made as smart as `assert (_=_)`?
>
> I thought the following Ltac would work, but it suffers from the same
> problem as `change`.
> Ltac changee a b :=
> assert (a=b) as XX by reflexivity;
> rewrite XX;
> clear XX.
>
> I guess terms are fully typed before being passed to Ltac.
>
> Thanks,
> -- Abhishek
> http://www.cs.cornell.edu/~aa755/
- [Coq-Club] change uses inferior type inference, Abhishek Anand, 02/28/2019
- Re: [Coq-Club] change uses inferior type inference, Abhishek Anand, 02/28/2019
- RE: [Coq-Club] change uses inferior type inference, John M Grosen, 02/28/2019
- Re: [Coq-Club] change uses inferior type inference, Jason -Zhong Sheng- Hu, 02/28/2019
- RE: [Coq-Club] change uses inferior type inference, John M Grosen, 02/28/2019
- Re: [Coq-Club] change uses inferior type inference, Abhishek Anand, 02/28/2019
Archive powered by MHonArc 2.6.18.