coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Jasper Hugunin <jasperh AT cs.washington.edu>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Trouble with dependent induction
- Date: Sun, 17 Dec 2017 21:37:22 +0900
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=jasperh AT cs.washington.edu; spf=None smtp.mailfrom=jasperh AT cs.washington.edu; spf=None smtp.helo=postmaster AT mail-oi0-f42.google.com
- Ironport-phdr: 9a23:wmCLeRObouCBNPcDohEl6mtUPXoX/o7sNwtQ0KIMzox0Lfr7rarrMEGX3/hxlliBBdydt6odzbKO+4nbGkU4qa6bt34DdJEeHzQksu4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2aFLduGC94iAPERvjKwV1Ov71GonPhMiryuy+4ZLebxlViDanfb9+MAi9oBnMuMURnYZsMLs6xAHTontPdeRWxGdoKkyWkh3h+Mq+/4Nt/jpJtf45+MFOTav1f6IjTbxFFzsmKHw65NfqtRbYUwSC4GYXX3gMnRpJBwjF6wz6Xov0vyDnuOdxxDWWMMvrRr0yRD+s7bpkSAXwhSgFOT438G/ZhM9tgqxFvB2svAZwz5LObYyPKPZyYqHQcNUHTmRBRMZRUClBD5u4YYQVFOoBJfhXr5PgrFUMsBu+ChSsBOXuyj9Om3T72q863P46EQHewgMgBdIOvW/Io9XuLqsTX/q6zLLIzTXCafNW1iv96I/Ochw7v/6DQK9wfNPXxEIyGQ3FiVCQppbkPzOTzukNt3Cb4PB7VeKzlWErsQdxrSazxsoql4LHhZoVx0ja+SllxIs5P961RU5hbdK6DZddtDuWOoRoTs4kXmpmojw1yqcctp6+ZCUKyIooxxrYa/GfdoiH+BPjVOKILTd/hXJpZKuzhxi9/ES+0OH8Wc600FFFripBjNbArGwC1xvW6sSfS/t9+Fmu2SqX2gzN9u1JJVo4mKnbJpI73LI8i5kevV7MEyPogEn2ibWZdkQg+uim8eTnZbDmq4eeN4BukQH+Krohmta/AekjLgcORHKX+Oqm2734/U35QbNKjvIqkqnetpDWP9oUqbOkAwNNyIYs9w6/Dyu60NQfhXQIMFVFeAueg4f1P1HOPev3AOykg1WslTdr3+rJMqfgApXLNHjDka3ucaxz605Gm0IPyoVU4IsRAbUcKtryXFXwvZrWFEwXKQuxlsTuE81wzMs+RG2SBK6fePfQuESQ6/gvC+KXIpAcozb8Lfc54PiogHMkzwxONZK11IcaPSjrVs9tJF+UNCLh
Hello Matěj,
The reason you are missing the induction hypothesis is you never performed an induction (or a fixpoint).
You can get the induction hypothesis by starting off with something like
refine ((fix inner n (i : Fin.t n) (xs : Vector.t A n) := match i as i' in Fin.t n' ...) n i xs)
However, when I tried that route, I got stuck at Qed with a message saying
the induction hypothesis was not used on a smaller term.
Here is a way to prove that lemma without axioms in pure Gallina:
Fixpoint replace_fact1 {A n} (xs : Vector.t A n) i x
: (Vector.replace xs i x)[@i] = x
:= match i in Fin.t n'
return forall (xs : Vector.t A n'), (Vector.replace xs i x)[@i] = x
with
| Fin.F1 => fun xs => Vector.caseS' xs
(fun xs => (Vector.replace xs Fin.F1 x)[@Fin.F1] = x)
(fun a xs' => eq_refl : x = x)
| Fin.FS i' => fun xs => Vector.caseS' xs
(fun xs => (Vector.replace xs (Fin.FS i') x)[@Fin.FS i'] = x)
(fun a xs' => replace_fact1 xs' i' x
: (Vector.replace xs' i' x)[@i'] = x)
end xs.
I don't use Ltac, so I can't help translating the above into tactics,
but hopefully the above is useful in understanding what is going on behind the scenes.
Perhaps just writing the outer fix+match (the fix is embedded in the Fixpoint command)
as your refine would be enough to get started.
- Jasper Hugunin
On Sun, Dec 17, 2017 at 8:34 PM, Matěj Grabovský <matej.grabovsky AT gmail.com> wrote:
Hello.
I'm trying to prove the following, apparently simple statement about
the Vector.replace function from the standard library (the full code
is at http://lpaste.net/360859):
forall {A n} (xs : Vector.t A n) i x, (Vector.replace xs i x)[@i] = x
Although I can prove this just fine using Program, I'd also like to
perform the proof without it, without assuming additional axioms.
However, I can't quite wrap my head around what's going on with all
the type dependencies.
I can destruct the with an intricate matching trick, but I'm unable to
proceed in the latter branch as I need more information for the proof
to progress.
What is the Coq canonical/recommended approach to dependent induction
without on inductives indexed by types with decidable equality? Is
there a general approach to this? If not, how would I go about this in
the Vector case?
Note that I'm not looking for alternatives to stdlib Vector or
specialised libraries as of now. I'd very much like to understand the
concept in vanilla Coq first.
Best regards,
Matěj
- [Coq-Club] Trouble with dependent induction, Matěj Grabovský, 12/17/2017
- Re: [Coq-Club] Trouble with dependent induction, Jasper Hugunin, 12/17/2017
- Re: [Coq-Club] Trouble with dependent induction, Adam Chlipala, 12/17/2017
- [Coq-Club] Vector in Coq [Was: Re: Trouble with dependent induction], Emilio Jesús Gallego Arias, 12/17/2017
- Re: [Coq-Club] Vector in Coq [Was: Re: Trouble with dependent induction], Adam Chlipala, 12/17/2017
- Re: [Coq-Club] Vector in Coq [Was: Re: Trouble with dependent induction], Robby Findler, 12/17/2017
- Re: [Coq-Club] Vector in Coq [Was: Re: Trouble with dependent induction], Emilio Jesús Gallego Arias, 12/17/2017
- Re: [Coq-Club] Vector in Coq [Was: Re: Trouble with dependent induction], Emilio Jesús Gallego Arias, 12/17/2017
- Re: [Coq-Club] Vector in Coq [Was: Re: Trouble with dependent induction], Xavier Leroy, 12/17/2017
- Re: [Coq-Club] Vector in Coq [Was: Re: Trouble with dependent induction], Emilio Jesús Gallego Arias, 12/20/2017
- Re: [Coq-Club] Vector in Coq [Was: Re: Trouble with dependent induction], Emilio Jesús Gallego Arias, 12/17/2017
- Re: [Coq-Club] Vector in Coq [Was: Re: Trouble with dependent induction], Adam Chlipala, 12/18/2017
- Re: [Coq-Club] Vector in Coq [Was: Re: Trouble with dependent induction], Adam Chlipala, 12/17/2017
- [Coq-Club] Vector in Coq [Was: Re: Trouble with dependent induction], Emilio Jesús Gallego Arias, 12/17/2017
- Re: [Coq-Club] Trouble with dependent induction, Matthieu Sozeau, 12/17/2017
- Re: [Coq-Club] Trouble with dependent induction, Adam Chlipala, 12/17/2017
- Re: [Coq-Club] Trouble with dependent induction, Jasper Hugunin, 12/17/2017
Archive powered by MHonArc 2.6.18.