coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: mukesh tiwari <mukeshtiwari.iiitm AT gmail.com>
- To: coq-club AT inria.fr
- Subject: [Coq-Club] Finding the opaque terms in a definition
- Date: Sun, 3 Oct 2021 19:29:40 +1100
- Authentication-results: mail3-smtp-sop.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-f43.google.com
- Ironport-hdrordr: A9a23:5h0k1agwfUhvJ4i30OEhriW+l3BQXtcji2hC6mlwRA09TyX4rbHIoB1/73XJYVkqKRIdcLy7WJVoIkm8yXcW2/hyAV7KZmCP01dAR7sSiLcKrQeQfxEWNdQw6U6jScVD4RHLYmSSRPyV3DWF
- Ironport-phdr: A9a23:VUP5rBfrtD4dK3xEybL0zeK8lGM+E97LVj580XLHo4xHfqnrxZn+JkuXvawr0AWRG9SCoK8bw8Pt8InYEVQa5piAtH1QOLdtbDQizfssogo7HcSeAlf6JvO5JwYzHcBFSUM3tyrjaRsdF8nxfUDdrWOv5jAOBBr/KRB1JuPoEYLOksi7ze+/94PPbwlSgDexfLx+IRW0oA7MqsQYnIxuJ7orxBDUuHVIYeNWxW1pJVKXgRnx49q78YBg/SpNpf8v7tZMXqrmcas2S7xYFykmPHsu5ML3rxnDTBCA6WUaX24LjxdHGQnF7BX9Xpfsriv3s/d21SeGMcHqS70/RDKv5LppRhD1kicKLzE2/mHZhMJzkaxVvg6uqgdlzILIeoyYLuZycr/fcN4cWGFPXtxRVytEAo6kaosPEukBMvhDr4n9ulAOsRq+BAe2C+P1yz9Dm3j73agn0+QiDw7GxwwgH84PsHXattr1LqYSXfq0zKnJzDXDc/ZW1Czy6IjNaB8hoPWMUahsfsrWzEkiDgXIhUifpoL5JT2azPgNs3SF4Op6U+Kik3Arph1trjWzxcoglo3Ei4AXx13A+it0zoc4KcClREN5f9OoDJVeuiKaOYdoRs4vQmBltTo4x7AHt5C2fycExpQhyhXCZfKHdI2I7QjiVOaXOTp4i3NleK6/hxav6kes0PHzVs6x0FpSoSpFk8XMtnAQ1xPI8MSLUOdy/kCk2TuJygvd6flELFgqmabHL5Mt2L09m5oJvUjdAiP7m1/6gaCYe0gi5+Om8f7oYq/8qZ+ZL4J0ih/xMqApmsGnBOQ3KAkOX2yC9euiybLv4FT1QLtFg/A4iKXZv5faJcMUpq69HQBZyJos6xG6Dzu+0dQYm2cILE5ddR6Zk4TkP0vCLfP4APulnVigjDRmy+rJM7DvGpnNK2LMkLblfbZz8U5czw8zwMha55JJCbEOPunzWk/ttNzZAB42KRa0w+f9BNV814MeWH6PAqqCPaPdtF+H/OMvI+2WaIAJvzb9LuAp5+Tygn8hhV8dYa6p0IMLZ3C/B/RqOlmWYX7xgtgaCmoKpQo/TOnyiFKYSzJTZnCyX7g95j4hEo6mA53DFciRh+mK2z7+FZlLbEhHDEqNGDHmbdaqQfAJPSePIcJ6knQYVKeoUY5pgRSztwLhy6ZmMePO+2sZtJP/0fB64uTSkVc58jkiXJfV6H2EU2whxjBAfDQxxq0q+SSVK3+G2Kl8xvFUTJldu6gPXQA9OprRied9DoKqMuokVtiMQVeiBN6hBGNpJjre69ALakd5Xd6li0Katxc=
What is the difference between the poslt_wf in wf_proof and the poslt_wf in wf_not_reducing?
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?)
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.
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.
[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
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
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+.