Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] how to rewrite, needed to match goal

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] how to rewrite, needed to match goal


Chronological Thread 
  • From: Jeremy Dawson <Jeremy.Dawson AT anu.edu.au>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] how to rewrite, needed to match goal
  • Date: Tue, 29 Dec 2020 00:10:31 +1100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=anu.edu.au; dmarc=pass action=none header.from=anu.edu.au; dkim=pass header.d=anu.edu.au; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U7AunNtZeaiBm2ezCaEGDg7OfM+Bl0Txd3L+lMrHI8w=; b=Wapk5Tb9qAque1PxI8lbBHkYJgLTMpMe/pAHouQsqaluU8ICO6ss7o6ikRh9mFAt6n4BBokp1A8tArArAhE4YgNEiyV2z3nFxQUFioqvWfz75IV2lwiPWss2B4F2olPhL1ThJiwiqP5wouaGxKZGpvMsrh1cRYInwV7iYTrWhXRZ4iUUFP7scKxWW0iIg02rsOK92eSxc8k0zVYHku6/8amcUekABHK+RhcGfs95tZuobOJEk7KJJM8gN4rO9nZCP/FzUCYnuA7rKsiaJLpjQcyhLlzvl5scKw+jI0IICy7vPPOAs+/rWN+91xAQ2SkInZKAnnoq6fdKYzQkdlSN2Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XetcPUVBlhssGJkGCJqDpvPGTS5W0vedaq8OE5wZlCrlBX+WJcD5NgKIrJonfNeIue47Oa5xw83RJS03eln0fKB7wetDZAbIbYq99TggQom999Qf0vrMkXb3moWq03M5mg2toRj2rl4FjCiwFVQjkvbZBCMI+b/dr3YF5L9LKLcyzgTW1/LfBV9cFBy5z5xy/RWUqRZ+Wgb1uAxgeXTQiHwaZG+bCcHoek1lJmGIczilFIptFEpZ+C8DMs57vkKf20n81EeEtkG5tjrWCH0vIeXutOBNgZvt7AzuZQ05vkUlbSZRCfofgE5dWsjBG37V9N+Wla0gVgHn9c9+0AYd7Q==
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=Jeremy.Dawson AT anu.edu.au; spf=Pass smtp.mailfrom=Jeremy.Dawson AT anu.edu.au; spf=Pass smtp.helo=postmaster AT AUS01-SY4-obe.outbound.protection.outlook.com
  • Ironport-phdr: 9a23:/fS8GBLWVZu/2M/RydmcpTZWNBhigK39O0sv0rFitYgfKvzxwZ3uMQTl6Ol3ixeRBMOHsq0C0bOH+P24EUU7or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6arXK99yMdFQviPgRpOOv1BpTSj8Oq3Oyu5pHfeQpFiCe/bL9oMhm6sAHcusYWjId+N6081gbHrnxUdupM2GhmP0iTnxHy5sex+J5s7SFdsO8/+sBDTKv3Yb02QaRXAzo6PW814tbrtQTYQguU+nQcSGQWnQFWDAXD8Rr3Q43+sir+tup6xSmaIcj7Rq06VDi+86tmTgLjhSEaPDA77W7XkNR9gr9FrhKvpxJxwIDab4+XO/Vica3dfNwVSHFdXstSTSFNHp+wYoUNAucHIO1Wr5P9p1wLrRamAQejGvnvxSFNhn72wKY03f4uEA/d3AwnGdIFrXPZotHrO6cIT++1yanJwS/NYfxM1zb984/IchY6rP6WW7JwbNDdxlcyGAPYlFmfs5HlMiqT2+8QvGeV8/BuWvizi247tQ5xuD6vy98ihIXVmo4bxUzJ+CZlzYspJdO0VVB3bcC6HJdNqiyUOZV7TMMhTmx2pSo3xbIItJG0cSUFyZkr2RHSZv6JfYWI5B/oSeWfIS9giX9qZL6znQu+/VSix+HmS8W4zFRHojBYntXSqHwBzxPe58ydRvdg/UqtxSyD2x7d5+xGO0w4iK7WJ4Anz7UtjJQcq17DETXzmEjujK+ZaEEk+u+w5un7bLrou4OQO5Jthg/jMKsjldWzAeMjPQcQRWSb/vm81KH48k3+XbVKiOA5nrPBsJDAIsQburC2DBNJ0oYi7Ba/CS2q0NMFnXkbKFJFfxWHj4vzN17SJ/D4CO+zg1WqkDh12/DLJrLsDonXInTejLvsf6xx51NAxAcx19xT+oxYBq8ZLPL2QEDxtdjYDhEjMwyzxubqENFz2Z0EWW2RB6+YMLnev1GS6eMhOOmMY4kVtS3nJPgj+v7il2E2lkIAfaWzx5QXdWi0Hu56LEWBfXrsntABHH8WsQo5VezmkUGNUTpOZ3mpRK88/TE6CIe+DYjZXIytgbqB3D26HpJMfGxGBEqMQj/UcNCPXO5JYyaPKOdglCYFXP6vUdwPzxar4S330bdiP6L48zIDspSrgPp4/eDWhFce/CNvCMK12meQCWx4gyUBWmllj+hEvUVhxwLbguBDiPtCGIkLvqIbYkIBLZfZitdCJZX3UwPFcM2OTQ/8ENygHHc8Qs93ysJcOh8gSeXntQjK2m+RO5FQl7GPA8BroIvh5CCoYv1MlzPB3qRniEQ6SMxSM2HgnrR46wXYG4/OlQOeirqucqMfmiXK8TXalDbcjARjSAd1FJ79czUHfEKP94bw4F6EQrOzT706YFNM

Thanks Clement, this has been very helpful indeed, and has enabled me to solve this sort of problem several times.

But in some cases I still seem to be stuck.

For example (just showing the last two hypotheses), I have


H : [(fmlsext (Γ1 ++ Imp (Var p) B :: H2) Γ3 [Imp (Var p0) B0], Var p0);
(fmlsext (Γ1 ++ Imp (Var p) B :: H2) Γ3 [B0], Var p)] = lpst
n : no_rpt_same seq_ord
(derI
(fmlsext (Γ1 ++ Imp (Var p) B :: H2) Γ3 [Imp (Var p0) B0], Var p)
?l0 d1)
============================
no_rpt_same seq_ord
(derI (fmlsext (Γ1 ++ Imp (Var p) B :: H2) Γ3 [Imp (Var p0) B0], Var p)
l0 d1)

exact n. fails with the error message

The term "n" has type
"no_rpt_same seq_ord
(derI (fmlsext (Γ1 ++ Imp (Var p) B :: H2) Γ3 [Imp (Var p0) B0], Var p)
?l0 d1)" while it is expected to have type
"no_rpt_same seq_ord
(derI (fmlsext (Γ1 ++ Imp (Var p) B :: H2) Γ3 [Imp (Var p0) B0], Var p)
l0 d1)"
(cannot unify "[(fmlsext (Γ1 ++ Imp (Var p) B :: H2) Γ3 [Imp (Var p0) B0],
Var p0);
(fmlsext (Γ1 ++ Imp (Var p) B :: H2) Γ3 [B0], Var p)]" [note - the above few lines are part of the type of l0]
and
"lpst").

I'm presuming this is because the existential ?l0 is expected to have type involving lpst. Is there a way of getting Coq to show the type of an existential?

subst lpst. here gives a really long error message,

> subst lpst.
> ^^^^^^^^^^
Error: Ltac call to "subst (ne_var_list)" failed.
Abstracting over the term "lpst" leads to a term
fun lpst0 : list (list (PropF V) * PropF V) =>
forall
[snip]
which is ill-typed.
Reason is: Illegal application:
The term "derI" of type
[snip]
cannot be applied to the terms
[snip]
The 7th term has type "dersrec LJArules emptyT lpst0"
which should be coercible to
"dersrec LJArules emptyT
[(fmlsext (Γ1 ++ Imp (Var p) B :: H2) Γ3 [Imp (Var p0) B0], Var p0);
(fmlsext (Γ1 ++ Imp (Var p) B :: H2) Γ3 [B0], Var p)]".

So if I'm right in thinking that the type of ?l0 is something containing lpst, how to I change that to the corresponding term on the rhs of H?

Thanks for any help

Jeremy

On 17/12/20 5:05 pm, Clément Pit-Claudel wrote:
This is the short version of your problem, I think:

Require Coq.Vectors.Vector.

Goal forall n (v: Vector.t nat (S (n + 0))),
@Vector.hd (n + 0) v = 0 -> True.
Proof.
intros.

Fail rewrite plus_n_O in v.
(* Error: Cannot change v, it is used in hypothesis H. *)

remember (n + 0) as n0 eqn:Heq in *.
rewrite <- plus_n_O in Heq.
subst.

The first rewrite fails because H would be ill-typed if it succeeded: you'd
have (v: S n) and (H: @Vector.hd (n + 0) v); the latter is ill-typed because
(n + 0) and n are not unifiable.
So what you need to do is rewrite in both hypotheses at once, so that there's
no ill-typed intermediate stage. You can do this with [remember] and [subst]
as I did above (and as you observed) or with revert:

Require Coq.Vectors.Vector.

Goal forall n (v: Vector.t nat (S (n + 0))),
Vector.hd v = 0 -> True.
Proof.
intros.

Fail rewrite plus_n_O in v.
(* Error: Cannot change v, it is used in hypothesis H. *)

revert v H.
rewrite <- plus_n_O.
intros.

The key is that you can't rewrite an hypothesis' type if that leads other
hypotheses to being ill-typed.

Clément.

On 12/16/20 11:42 PM, Jeremy Dawson wrote:
curiouser and curiouser -

in investigating how I got to this situation I found that
Coq would substitute (using subst.) the following equality in l and d1

Γ0 = Γ1 ++ []

So doing rewrite app_nil_r before substituting solves my problem in this
particular case.

But in general - (1) why can you do subst but not rewrite in d1
(2) in general, how do you handle this problem

Jeremy

On 17/12/20 2:43 pm, Jeremy Dawson wrote:

Hi,

I have the following goal (only key parts included)

   l : LJArules (map (apfst (fmlsext (Γ1 ++ []) Γ2)) ps1)
         (fmlsext Γ1 Γ2 [Imp (Var p) B], Var p)
   d1 : dersrec LJArules prems (map (apfst (fmlsext (Γ1 ++ []) Γ2)) ps1)
   apd : allDT (no_rpt_same seq_ord (prems:=prems))
           (derI (fmlsext Γ1 Γ2 [Imp (Var p) B], Var p) l d1)
   ============================
   allDT (no_rpt_same seq_ord (prems:=prems))
     (derI (fmlsext Γ1 Γ2 [Imp (Var p) B], Var p) ?l ?d1)

Now the goal doesn't match apd because the types are wrong,
?l and ?d1 have types which would match those of l and d1 if
l and d1 had (Γ1 ++ []) rewritten to Γ1

But rewrite app_nil_r in d1.  rewrite app_nil_r in l.
fails because
Ltac call to "rewrite (ssrrwargs) (ssrclauses)" failed.
d1 is used in hypothesis apd.
Ltac call to "rewrite (ssrrwargs) (ssrclauses)" failed.
l is used in hypothesis apd.

How can I handle this situation?

Thanks

Jeremy





Archive powered by MHonArc 2.6.19+.

Top of Page