Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Finding the opaque terms in a definition

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Finding the opaque terms in a definition


Chronological Thread 
  • From: mukesh tiwari <mukeshtiwari.iiitm AT gmail.com>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] Finding the opaque terms in a definition
  • Date: Sat, 9 Oct 2021 12:16:04 +1100
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=mukeshtiwari.iiitm AT gmail.com; spf=Pass smtp.mailfrom=mukeshtiwari.iiitm AT gmail.com; spf=None smtp.helo=postmaster AT mail-ed1-f44.google.com
  • Ironport-hdrordr: A9a23:jprmEaym0HZiZJ1fNtd7KrPwAb1zdoMgy1knxilNoNJuA7WlfuSV7ZcmPHjP+VQssRAb6LW90ca7MBThHPJOkPMs1NSZPDUOxlHYUb2KhLGKq1KPehEWkNQtrpuIGJIOcOEYY2IK6/oSmDPId+oI8Z261OSDgOfTyGooZQxmcMhbhG0VZjqmLg==
  • Ironport-phdr: A9a23:3JA3PhBve992R+eCG5egUyQU1kMY04WdBeb1wqQuh78GSKm/5ZOqZBWZua81yg6QFtiEo9t/yMPu+5j6XmIB5ZvT+FsjS7drEyE/tMMNggY7C9SEA0CoZNTjbig9AdgQHAQ9pyLzPkdaAtvxaEPPqXOu8zESBg//NQ1oLejpB4Lelcu62/6u95HJZwhEmTWxbLNwIR6rsQjfq84ajJd4JK0s0BXJuHxIe+pXxWNsO12emgv369mz8pB+7Sleouot+MFcX6r0eaQ4VqFYAy89M28p/s3rtALMQhWJ63ABT2gZiBtIAwzC7BHnQpf8tzbxu+Rh1CWGO8D9ULY5Uimg4ah2Uh/lkCgINzA7/2/XhMJ+j79Vrgy9qBJw2IPUfJiVOeBicq/BYd8XR2xMVdtRWSxbBYO8apMCD+8cPeZbsYb9vFsOpgaiBQmtCuLg0CVIhn7r1qA91uQhDALG0xI7H9IOrHTUrdv0O70IUeC01qXIzDTDb/JK2Tf484XIfRUhruuNXbJ0a8be1U4vFwbcg1iWtIfqMC+b2P4XvGiH8+pvS/ivi2g/pgxwojWi2Nsgh4vUio8Izl3J6Dt0zYg1KNC8VkN2fcOpHpVQuiyEM4Z7QcwvTW51tCs0zrALvZG1cDULxZg5wxPSbeGMfYaP4hLmTumRIDF4iWpqeLK+mxay8VWgxfbmWsao11ZKqzJJkt/WuXAX1BzT69aHReVn8ki93jaP0hjf6uBCIUAulKrUMYQtwrAqlpcVrE/NHTf2lV3ogKOKckgo4Oul5uT9brn4upORNJV4hw7xP6koh8exG/43MhIUUGie4em81KPs/Un+QLhSi/05iKjZsJTDKcsFu6G1HhZZ0ogs5huwFTum39MYnX4ILFJBZh2LlZTmO1bLIPzgDPe/hUqjkCtzyvzYIrHsBo/BI3vDnbv7Y7px901RxBA8wN1Q/55UD6sOIPP3Wk//rtzYCRo5PhSxw+b6C9VyyJgeWWKTAq+YPqLdq0WI5uM1L+mNZY8VuSr9K/0+6v7hiH82g14dfa2z0ZQLb3C4G+xqI1+Fbnr0ntcBDWAKsxIiQ+ztkV2OSCJcZ3KvX60n/Tw7E4KnDYLbRo+3mrCB3SG7HodXZm9cEFyMH23oJM24XKIHbzvXKct8mBQFU6KgQskvz0KArgj/nr96LefP+mUEtI3qztk9s+jOlhwp9SB1EM2H0ieMTmBom0sHQjY32OZ0pkkrmQTL6rRxn/ENTY8b3PhOSApvbfY0LsR/AtH2Hw/NJ5KHFArgTdKhDjU8CNk2xo1WC66YM9qnhxHHmSGtBu1N/1RkLJMx+6PYmXP2IpQko0s=

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



Archive powered by MHonArc 2.6.19+.

Top of Page