coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Robbert Krebbers <mail AT robbertkrebbers.nl>
- To: coq-club AT inria.fr, mukesh tiwari <mukeshtiwari.iiitm AT gmail.com>
- Subject: Re: [Coq-Club] Finding the opaque terms in a definition
- Date: Sat, 9 Oct 2021 09:25:48 +0200
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=mail AT robbertkrebbers.nl; spf=Pass smtp.mailfrom=mail AT robbertkrebbers.nl; spf=None smtp.helo=postmaster AT pmg02-out4.zxcs.nl
- Ironport-hdrordr: A9a23:leSKuqPo1F/+Y8BcTq+jsMiBIKoaSvp037BL7SFMoHNuGfBw+/rFoB1573HJYVQqNE3I8OroUJVoKkmyyXca2+QsAYs=
- Ironport-phdr: A9a23:eSnk8BWxDYAzJZM+iIj0MTsg69fV8KyfUjF92vMcY1JmTK2v8tzYMVDF4r011RmVB92duqsP1rWempujcFRI2YyGvnEGfc4EfD4+ouJSoTYdBtWYA1bwNv/gYn9yNs1DUFh44yPzahANS47xaFLIv3K98yMZFAnhOgppPOT1HZPZg9iq2+yo9JDffRlEiCC5bL9vIxm7rQfcvdQKjIV/Lao81gHHqWZSdeRMwmNoK1OTnxLi6cq14ZVu7Sdete8/+sBZSan1cLg2QrJeDDQ9LmA6/9brugXZTQuO/XQTTGMbmQdVDgff7RH6WpDxsjbmtud4xSKXM9H6QawyVD+/6apgVR3mhzodNzMh7W/ZlMJwgqJYrhyvqRNwzIzbb52aOvdlYqPQf8kXSXZdUstfVSFMBJ63YYsVD+oGOOZVt5Xzp1wVohSlGwasHv/vwSJNiH/sw6I1yP8uHh/c3Aw7AtkDt3HUo8/0NKcWSu211q7Iwi7YYPxIwzf99IvIcgo/rv6XRr1/b9DRyVI1GwPDilWdsIroNC6a2eoRqWaU9fZgVf6xhG49rQF8ujeiyMcyhoXXiY8YxEzI+CZlzIs2K9C1SEF2bcOqHpZftyyUN4t7T98gTmx2uCs3yL0ItJy7ciYK1JkqxxDSZvKBfoOV7BzjU+ORLi15hHJjYL+/iBey8VSgyu3hTca4ykpFri1AktXUsHACzQbT6suGSvtj4EitwyqA1wfW6u1cIEA0k7DbK587zbIqmJoTq0LOFTL1lkXulKKaa0Yp9+iy5+j5fLnquoWQO5J2hw3gKKgihMOyDOA+PwMTRWaU4/6826fm/UDhQLVFkPk2kq7BvZDCIMQbqbK1DxFM3oYk9ha/Ezir3M4ZnHgIMF1FYwiLj47tO13WIfD4C+mwg0i0nTt2xP3LPqftDovTInTfirvtYLRw51BGxAYtwt1S44pYCrQbL/LyXk/xusbYDhg8MwGsxuboEtR91ocFVGKVBa+WK7jdvkGS5uIzIOmMfpEaty3mJPc7/f7ulmU1mVkZfaWxx5sYdGi4Huh6I0WeeXfjntABEX4TsgUiSOzqlUaNXCVIZ3eyWqI8/is0BJinDYfFXICtgaaO0D21Hp1MNSh6DQWHFm6tfIGZUd8NbjiTK4lviHhMUKWiRpQhnQ2vqwbgyvIzK/fX9zYYqZP83cJ0oezSlA033TNxBsWZlWqKSjcnsHkPQmoM26p1rFZhgnSZ3KJyjuZDXYhW7vJNeh09P5TR1fB5Ed34UA/bZZGPTAD1EZ2dHTgtQ4dpkJc1aEFnFoD65vgs9zCtCbUYjaCIHpE++K/GxD73I5Qko54n/LEkgAF8B8xSKTHglL507E7VA9yR+618v7ytf64RxjLO7mqJx2eUpwdeVFwoOZg=
Hi Mukesh,
Thanks for finding out the original source of this trick.
Note that the trick is in the Coq standard library these days:
https://github.com/coq/coq/blob/master/theories/Init/Wf.v#L163
You could submit a PR to add a comment to acknowledge Georges Gonthier for discovering it.
Robbert
On 09/10/2021 03.16, mukesh tiwari wrote:
Hi Xavier
Thanks for pointing to the Krebbers' answer and now the Coq code [1]
is producing concrete values. During my Google search to solve this
problem, I also found the same trick by Thomas Braibant [2] from 2009
and yesterday, on Zulip chat, Guillaume Melquiond pointed to the
Georges Gonthier [3] from 2007.
Best,
Mukesh
[1] https://github.com/mukeshtiwari/Coq-automation/blob/master/Gcd_guarded.v
[2]
https://coq-club.inria.narkive.com/gO2dnKc4/well-founded-recursion-stuck-on-opaque-proofs
[3] https://sympa.inria.fr/sympa/arc/coq-club/2007-07/msg00013.html
On Sun, Oct 3, 2021 at 7:50 PM Xavier Leroy
<xavier.leroy AT college-de-france.fr> wrote:
On Sun, Oct 3, 2021 at 10:30 AM mukesh tiwari <mukeshtiwari.iiitm AT gmail.com>
wrote:
What is the difference between the poslt_wf in wf_proof and the poslt_wf in
wf_not_reducing?
I don't know. But, generally speaking, it is difficult to write
accessibility proofs that compute efficiently (or even compute at all).
You'd better use Krebbers' trick:
https://sympa.inria.fr/sympa/arc/coq-club/2013-09/msg00034.html.
- Xavier Leroy
More context: I have a function bgcd [1] that uses the poslt_wf [2, 3], from
the wf_not_reducing. When I evaluate the bgcd [1] on some input --Time Eval
compute in bgcd 2 3 2 3 1 1 0 0 1. [4]-- I get heaps of text (no concrete
value), but if I replace poslt_wf [2, 3] by poslt_wf, from the wf_proof (in
the Coq code, replace poslt_wf by Reducing.poslt_wf), bgcd [1] works fine
and produces concrete value. Therefore, my question is: what is the
difference between these two poslt_wf? (in both cases, About poslt_wf
produces: poslt_wf is not universe polymorphic, poslt_wf is transparent.
However, if both are transparent then why one reduces and other does not?)
Best,
Mukesh
Section wf_proof.
Let f (c : Z) (a : Z) := Z.abs_nat (a - c).
Definition zwf (c : Z) (x y : Z) := (f c x < f c y)%nat.
Lemma zwf_well_founded (c : Z) : well_founded (zwf c).
Proof.
exact (well_founded_ltof Z (f c)).
Defined.
Lemma pos_acc : forall x a, Zpos a <= x -> Acc Pos.lt a.
Proof.
intro x.
induction (zwf_well_founded 1 x) as [z Hz IHz].
intros ? Hxa.
constructor; intros y Hy.
eapply IHz with (y := Z.pos y).
unfold zwf. clear Hz; clear IHz.
apply Zabs_nat_lt.
split; nia.
reflexivity.
Defined.
Lemma poslt_wf : well_founded Pos.lt.
Proof.
red; intros ?.
eapply pos_acc.
instantiate (1 := Z.pos a).
reflexivity.
Defined.
End wf_proof.
Require Import Coq.ZArith.Zwf.
Section wf_not_reducing.
Lemma poslt_wf : well_founded Pos.lt.
Proof.
unfold well_founded.
assert (forall (x : Z) a, x = Zpos a -> Acc Pos.lt a).
intros x. induction (Zwf_well_founded 1 x);
intros a Hxa.
constructor; intros y Hy.
eapply H0 with (y := Z.pos y).
unfold Zwf. split; nia.
reflexivity.
intros ?. eapply H with (x := Z.pos a).
reflexivity.
Defined.
End wf_not_reducing.
[1] https://github.com/mukeshtiwari/Coq-automation/blob/master/Gcd.v#L196-L228
[2] https://github.com/mukeshtiwari/Coq-automation/blob/master/Gcd.v#L175-L187
[3] https://github.com/mukeshtiwari/Coq-automation/blob/master/Gcd.v#L226
[4] https://github.com/mukeshtiwari/Coq-automation/blob/master/Gcd.v#L237
- [Coq-Club] Finding the opaque terms in a definition, mukesh tiwari, 10/03/2021
- Re: [Coq-Club] Finding the opaque terms in a definition, Xavier Leroy, 10/03/2021
- Re: [Coq-Club] Finding the opaque terms in a definition, mukesh tiwari, 10/09/2021
- Re: [Coq-Club] Finding the opaque terms in a definition, Robbert Krebbers, 10/09/2021
- Re: [Coq-Club] Finding the opaque terms in a definition, mukesh tiwari, 10/09/2021
- Re: [Coq-Club] Finding the opaque terms in a definition, Xavier Leroy, 10/03/2021
Archive powered by MHonArc 2.6.19+.