coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: "jonikelee AT gmail.com" <jonikelee AT gmail.com>
- To: Guillaume Melquiond <guillaume.melquiond AT inria.fr>
- Cc: coq-club AT inria.fr
- Subject: Re: [Coq-Club] lesson learned about reflection: atoms and transparency
- Date: Thu, 9 Jul 2020 18:52:03 -0400
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=jonikelee AT gmail.com; spf=Pass smtp.mailfrom=jonikelee AT gmail.com; spf=None smtp.helo=postmaster AT mail-qt1-f173.google.com
- Ironport-phdr: 9a23:EzUQjB2EMZACq0DqsmDT+DRfVm0co7zxezQtwd8ZsesWLfzxwZ3uMQTl6Ol3ixeRBMOHsqwC0bKd6vuoGTRZp8rY7TZaKN0EfiRGoP1epxYnDs+BBB+zB9/RRAt+Iv5/UkR49WqwK0lfFZW2TVTTpnqv8WxaQU2nZkJ6KevvB4Hdkdm82fys9J3PeQVIgye2ba9vIBmsogjdq8gbjZF8JqotxRfFv3VFcPlSyW90OF6fhRnx6tqw8ZJ57yhcp/ct/NNcXKvneKg1UaZWByk8PWAv483ruxjDTQ+R6XYZT24bjBlGDRXb4R/jRpv+vTf0ueR72CmBIM35Vqs0Vii476dqUxDnliEKPCMk/W7Ni8xwiKVboA+9pxF63oXZbp2ZOOZ4c6jAZt4RW3ZPUdhNWCxAGoO8bpUAD+wdPeZDsoLxo0ICoQaiCQWwAe/izCJDiH3r0q0gy+kvHwHI0hI9EdwNsnvUotL7O6gOXu6616TI0SzDYulK1Trn9ITFcBYsquyMU7JqdsrRzFEiGw3HjlWXr4zlPjCV2foJs2eF8eVtTu2vi2s9pAFwpjij3Nsjio7Mho4b11vJ8id5wIEzJd25S050f9qkH4VOuCyBOIt2R9ktQ2BsuCog1rIGvpu7cTEMxZ86yBHRd+aJfJKU4hL/SumROzF4iWp5db6hhRu//latx+/9W8e60FhHsipIn93Su30MyRHe98iKRudg8kqgxzqCyR3e5/9LLEwoi6fVJYIsz700m5cTt0nIAyz4mF3ugaOIakkp/vKk5ufnb7n8u5ORNpN4hhvjPqkslMGzGfo0PwkSU2SG/Omwybnu8lH8TbhFj/A6jrXVvZXUKMkaqK60BgBY3Zg95xu6FTir0toYnXcCIVJLZh2LkYzkNlTAIP/jDPqwnVKhmypxyf/cJL3uGJDNI2DDkLj/ebZ97FZRyA8pwtBe45JYE6gBIO7uVkPoutzUEx00PgKuz+boD9V90YweWWaRDaODLKzStlqI6vouI+mKeoAVpC7wJ+Y56/Pql3M0ml8QcbO00ZYWdHy0BOlqLkeXbHb0h9cOC2YKvg4wTOzwj12CVCZeZ3S1X6I65zE7C5ypDYPdSY+zm7GB0yK7EYdXZmBCEFyDDXDod4CcV/cWdC2SOtNhkiADVbW5To8uyxWutBbny7pmKerU/DYVtJPi1Nhw/OLTjws9+SZ1D8SbyWGNTnt7knkGRz8sxKp/u1Byyk+f0ahkhPxVDcBc5/RQUgsjKZHcy/F6BMvpVwLaftaJTU6mTc+8DTEwSNIx2d4ObFxnF9WslBCQlxatVpAIlriPDYEx/+r50nzoOsd6zXqOgKY8jl0iS9ZKOCuji6pm6gnUAYLhkkODlq/se75KjwDX82LWh2iJukBbXQp9XI3KWHkeYg3dqtGzrhfASLmvCrkjPwZpxsuLK68MYdrs2wYVDMz/McjTNjri01y7AgyFk/bVNNKzJzctmR7FAU1BqDg9uG6cPFFnVCikqmPaSjdpEAC3Oh6+waxFsHq+C3QM4USKYklmjeTn/xcUgbmFV6pW0Otb42EurDJ7GFv71NXTWYLZ9lhROZ5EaNZ4229pkGfQtghzJJuldvkwiVsXcgAxtETrhUx6
Thanks for that detailed explanation, Guillaume!
In my example tests so far, there is no significant speedup between
the original if-then-else method and the vm_cast_no_check eq_refl
method. Of course, these examples are pretty small. The eq_refl method
has slightly larger proof terms, as expected.
I think in this case, perhaps the type of the reified goal is so quickly
convertible back to the type of the goal (the denote routines have very
low complexity) that I will not likely encounter any significant speed
difference. The time taken to reduce do_reflection will probably
overwhelm the convertibility check even more for larger cases. Unless
the time taken by Coq's convertibility checking grows much faster than
the reduction time within vm_cast_no_check?
BTW: I finished the transitive closure component. Next up is using the
transitive closure to find contradictions (a<a) when the normal process
fails to solve the goal.
On Thu, 9 Jul 2020 10:31:14 +0200
Guillaume Melquiond <guillaume.melquiond AT inria.fr> wrote:
> Le 09/07/2020 à 04:41, jonikelee AT gmail.com a écrit :
> > If this is just due to the advantage of vm_compute over the
> > execution engine normally used for checking convertibility, then
> > would it be possible instead to use:
> >
> > let R := eval vm_compute in (do_reflection ...) in exact R
> >
> > in the solve_sorted tactic in place of exact (do_reflection ...)
> > with no need for an explicit equality proof?
>
> No, this does not help. There are several processing stages when
> writing "let R := eval vm_compute in (do_reflection ...) in exact R".
>
> 1. Use the typing engine to check that "do_reflection ..." is
> well-typed. 2. Use the VM machinery to reduce "do_reflection ...".
> 3. Use the convertibility check to verify that R is convertible to
> the goal. 4. At Qed, use the convertibility check to verify that R is
> convertible to the goal.
>
> Note that steps 3 and 4 are expensive, since the type of R is
> presumably way different from the goal. In fact, it might even have
> been faster not to use "vm_compute" and thus do step 2 in the first
> place.
>
> Now, if your goal is "foo = true" and you do "vm_compute ; exact
> (eq_refl true)", then the steps are as follows:
>
> 1. Use the VM machinery to reduce "foo = true".
> 2. Use the convertibility check to verify that "eq_refl true" is
> convertible to the goal (now "true = true").
> 3. Rinse and repeat at Qed time.
>
> Notice that the convertibility check is now used only in a trivial way
> and thus instant. So, this is a huge speedup.
>
> But there is still an overhead. Indeed, step 3 is redundant with
> steps 1 and 2. Unfortunately, step 3 cannot be removed. So, we just
> have to remove steps 1 and 2, right? That is how you do it: "abstract
> (vm_cast_no_check (eq_refl true))".
>
> To summarize, the optimal way to do a proof by reflection is as
> follows. You have a property "is_foo", a decision procedure "foo" that
> (semi-)decides it, and a correctness lemma "foo_correct : foo = true
> -> is_foo". And you solve the goal by doing:
>
> apply foo_correct.
> abstract (vm_cast_no_check (eq_refl true)).
>
> Note: If this is the very last step of your whole proof script, you
> can remove "abstract". In fact, you can always remove "abstract", but
> unless it is the very last step of a proof, a failure of the decision
> procedure can lead to very confusing error message.
>
> Best regards,
>
> Guillaume
- Re: [Coq-Club] lesson learned about reflection: atoms and transparency, jonikelee AT gmail.com, 07/01/2020
- <Possible follow-up(s)>
- Re: [Coq-Club] lesson learned about reflection: atoms and transparency, jonikelee AT gmail.com, 07/01/2020
- Re: [Coq-Club] lesson learned about reflection: atoms and transparency, Gregory Malecha, 07/08/2020
- Re: [Coq-Club] lesson learned about reflection: atoms and transparency, jonikelee AT gmail.com, 07/09/2020
- Re: [Coq-Club] lesson learned about reflection: atoms and transparency, Gregory Malecha, 07/09/2020
- Re: [Coq-Club] lesson learned about reflection: atoms and transparency, jonikelee AT gmail.com, 07/09/2020
- Re: [Coq-Club] lesson learned about reflection: atoms and transparency, Guillaume Melquiond, 07/09/2020
- Re: [Coq-Club] lesson learned about reflection: atoms and transparency, jonikelee AT gmail.com, 07/10/2020
- Re: [Coq-Club] lesson learned about reflection: atoms and transparency, jonikelee AT gmail.com, 07/11/2020
- Re: [Coq-Club] lesson learned about reflection: atoms and transparency, Guillaume Melquiond, 07/11/2020
- Re: [Coq-Club] lesson learned about reflection: atoms and transparency, Guillaume Melquiond, 07/09/2020
- Re: [Coq-Club] lesson learned about reflection: atoms and transparency, jonikelee AT gmail.com, 07/09/2020
- Re: [Coq-Club] lesson learned about reflection: atoms and transparency, Gregory Malecha, 07/09/2020
- Re: [Coq-Club] lesson learned about reflection: atoms and transparency, jonikelee AT gmail.com, 07/09/2020
- Re: [Coq-Club] lesson learned about reflection: atoms and transparency, Gregory Malecha, 07/08/2020
Archive powered by MHonArc 2.6.19+.