coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Adam Chlipala <adamc AT csail.mit.edu>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Trouble with dependent induction
- Date: Sun, 17 Dec 2017 08:42:21 -0500
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=adamc AT csail.mit.edu; spf=Pass smtp.mailfrom=adamc AT csail.mit.edu; spf=None smtp.helo=postmaster AT outgoing-stata.csail.mit.edu
- Ironport-phdr: 9a23:0TGovBbK17slEY5+jr4lP6T/LSx+4OfEezUN459isYplN5qZoMW7bnLW6fgltlLVR4KTs6sC17KP9fi4EUU7or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6arXK99yMdFQviPgRpOOv1BpTSj8Oq3Oyu5pHfeQpFiCagbb9oMBm6sRjau9ULj4dlNqs/0AbCrGFSe+RRy2NoJFaTkAj568yt4pNt8Dletuw4+cJYXqr0Y6o3TbpDDDQ7KG81/9HktQPCTQSU+HQRVHgdnwdSDAjE6BH6WYrxsjf/u+Fg1iSWIdH6QLYpUjmk8qxlSgLniD0fOjAk7m/XhMx+gqFVrh2vqBNwwZLbbZqPO/ZiZK7QZ88WSGRDU8tXSidPApm8b4wKD+cZIetXspPyp14TphagBQmsAOLvyidSiX/yx6IxzuMsHhvb0wM6GtIBrG/Zo8nuNKgIUOC1yLPEzTDCb/NKwzvy9pXHcg04rPyKQLl+f83RyUw1GAPEiFWdsZDqPzOR1uQMq2iU9e5gWvi1h24htQ5xviCjxsM0iobTnYIV1k7L+T9/wIkrOd21TlNwb928EJZIqi2WKYh7TtksTm10oio21KcKtYCmcCQW0JgqxwLTZ+aZf4WG4h/vTvudLStiiH54fL+yiBC/+lW6xOLmTMm7ylNKozJFktbSsnAN0ATe6s+aSvth8Ueh3jeP1wbc6u1dOkA0ibDUK4I7zbIqipUTql7MHi7ymEnsia+Wd1kk9vK25Ov6f7Xqvp6cN4lqhQHiKqkih9KzDOciPgUAQ2SX4/qw2Kf98UHkXLlGlvg2nbPYsJDeK8QbvKm5AwpN34k59hmwFTKm38gDkHYbN1JKYhOHj4zzN1HLIfD4Ee2zjEqxnzd23/zGJKHuAo3RLnjfl7fsZapy60lFyAYq0d9f449UBaoaLfLoWk7xscTYAQUjPwy1xebnEtR92ZkEVWKBGK/KeJ/V5FSP/6ckJ/SGTI4Tojf0bfY/tND0inpssFMUeOGC3Z8WcHm8F7wyKkmQZHHEicwIEGNMuwsiCuHmlQvRAnZoe3+uUvdktXkAA4W8ANKbSw==
I went about the proof in the other direction (induction on vector, case analysis on index). My intention was for this sort of thing to be covered well in CPDT (maybe in the section about how to avoid axioms), so I'll appreciate any suggestions on how I might have missed the requisite ideas. Lemma fin_case : forall {n} (i : Fin.t n), On 12/17/2017 07:37 AM, Jasper Hugunin
wrote:
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, Matěj Grabovský, 12/19/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.