coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Shengyi Wang <txyyss AT gmail.com>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Compute a general recursive function on dependent types.
- Date: Sun, 19 Aug 2018 08:23:27 +0800
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=txyyss AT gmail.com; spf=Pass smtp.mailfrom=txyyss AT gmail.com; spf=None smtp.helo=postmaster AT mail-it0-f49.google.com
- Ironport-phdr: 9a23:OTp4mh/C7BcATP9uRHKM819IXTAuvvDOBiVQ1KB40+0cTK2v8tzYMVDF4r011RmVBduds6oMotGVmpioYXYH75eFvSJKW713fDhBt/8rmRc9CtWOE0zxIa2iRSU7GMNfSA0tpCnjYgBaF8nkelLdvGC54yIMFRXjLwp1Ifn+FpLPg8it2O2+55zebx9UiDahfLh/MAi4oQLNu8cMnIBsMLwxyhzHontJf+RZ22ZlLk+Nkhj/+8m94odt/zxftPw9+cFAV776f7kjQrxDEDsmKWE169b1uhTFUACC+2ETUmQSkhpPHgjF8BT3VYr/vyfmquZw3jSRMMvrRr42RDui9b9mRxDmiCgFNzA3/mLZhNFugq1Hux+uvQBzzpTObY2JKPZzfKXQds4aS2pbWcZRUjRMDJ68b4QRCeoBMuZZr4jgrFQOtxS+AwasD/7oxz9UiX733a070/86EQzd0wwgGsgBsHXQrNnvKKgSVuW1wbDOwD7eYf1W3jL955LJchAnufyMXLRwcdDQyUY1DQ/FgE+QpIr4ND2WzuQAq3aX4/ZkWO61iGMqqxt9riayysojkIXEiYYYx1bZ/itj2ok1P8e3SEtjbN6kDpRQsyaaOpNzQsw4QmFovD82yrwauZKnZSQKxpsqyhrFZ/yIdIiI5R3jVOKPLjtimH1lf7e/iw6z8Uim1OL8StG53EhWoidBiNXBtXAA2wbN5sSaRfZx5Eis1DKX2wDW8O5EIEQ0laTBK54mx749joYTsEvDHy72g0X2l7Sbdkoh+uey6uTnZq/qqYObN49xkg3+KLghmtSjAeQkNQgDR3SU+eOl1LH64UL5RKhKgeYtn6nCsJHaINwbqbSjDw9U1IYj8Re/AC283NQWh3lUZG5CLRmAls3iP0zECPH+F/a2xVq2wxlxwPWTBb3sBJrcLzD8mbHuNeJh+19N0xEbwtVW5pYSAbYEdqGgEnTtvcDVW0dqeze/xPzqXY0kh9EuHFmXC6rcC5v89FqB5+YhOe6JPdZHtzP0Kvxj7Pnr3yZgxQ0tOJKx1J5SU0iWW+x8KhzAM3Xpi9YFV2wNu1hmFbG4uBi5STdWIk2Kcec86zU8Ut/0CI7CQsWsnOTE0nvqWJJRYW9CBxaHFnK6L4g=
Hi Jason,
Thank you very much for telling me the trick about determining opaque terns. I tried to use "Print Opaque Dependencies Pos_lt_wf'." before but it generates hundreds of dependencies which is then useless.
After some thought, I think my question is "How to preserve the "phase distinction" in proofs used in a function?". I'm not sure opaque terns in Pos_lt_wf' are the only causes. How about other lemmas involved in the function definition such as "ptr_ok"?
Thank you,
Shengyi Wang
Cell: +65-83509639
Cell: +65-83509639
Jason -Zhong Sheng- Hu <fdhzs2010 AT hotmail.com> 于2018年8月19日周日 上午2:29写道:
Hi Shengyi,
are you referring to the opaque term issue? Yes, it causes that. Specifically, in your proof of accessibility:
Lemma Pos_lt_wf': forall x y : positive, x < y -> Acc Pos.lt x.all highlighted terms are opaque. I use emacs + company-coq, so for me `(company-coq-term-doc TERM)` will tell me if the term is opaque. Effectively, you want to make the entire well-formedness proof transparent, so probably all of them are the problem.
Proof.
intros. rewrite Pos2Nat.inj_lt in H.
remember (Pos.to_nat y) as n. clear y Heqn. revert x H. induction n; intros.
- pose proof (Pos2Nat.is_pos x). exfalso; intuition.
- apply lt_n_Sm_le, le_lt_or_eq in H. destruct H; auto.
constructor. intros. rewrite Pos2Nat.inj_lt, H in H0. apply IHn. assumption.
Defined.
I got a question related to this: I am not sure if Pos2Nat.is_pos being opaque matters here as the branch is discharged by falsehood. In this case, we should not get into that branch. Is it correct to say that we would never have to care about reducibility of lemmas concluding falsehood?
From: coq-club-request AT inria.fr <coq-club-request AT inria.fr> on behalf of Shengyi Wang <txyyss AT gmail.com>
Sent: August 18, 2018 12:34:57 PM
To: coq-club AT inria.fr
Subject: [Coq-Club] Compute a general recursive function on dependent types.Dear Coq users,
Recently I defined a map of "sig" type from positive to positive. The map should satisfy a property: it always maps a value v to a value which is not greater than v. Formally the definition is:
Definition pos_map_prop (t: PM.tree positive) : Prop :=forall i j, PM.find i t = Some j -> j <= i.
Definition PosMap := {pm : PM.tree positive | pos_map_prop pm}.
Such a map can be viewed as a forest: each key in the map is a node. Each node points to a smaller value or itself.
Then I successfully defined a general recursive function "pm_trace_root" which traces back such a node along the pointers until to a self-pointing "root". The property of the map ensures the termination.
So far everything seems fine until I try to run the function in Coq. I defined a test_map which is essentially {1 -> 1, 2 -> 2}. I tested:
Compute (PM.find 2 (proj1_sig test_map)).===> Some 1
Compute (PM.find 1 (proj1_sig test_map)).===> Some 1
The function pm_trace_root works for 1:
Compute (pm_trace_root 1 test_map).
===> Some 1
But for 2, "Compute (pm_trace_root 2 test_map)." generates an output of 912 lines.
I doubt it is caused by the similar problem mentioned in Xavier Leroy's blog: http://gallium.inria.fr/blog/coq-eval/
But I'm not sure. Even it is for the same reason, I can not figure out which proof term caused this problem. I attached the code. Could anyone tell me how to debug this kind of things?
Thank you very much,
Shengyi Wang
Cell: +65-83509639
- [Coq-Club] Compute a general recursive function on dependent types., Shengyi Wang, 08/18/2018
- Re: [Coq-Club] Compute a general recursive function on dependent types., Jason -Zhong Sheng- Hu, 08/18/2018
- Re: [Coq-Club] Compute a general recursive function on dependent types., Shengyi Wang, 08/19/2018
- Re: [Coq-Club] Compute a general recursive function on dependent types., Xavier Leroy, 08/19/2018
- Re: [Coq-Club] Compute a general recursive function on dependent types., Shengyi Wang, 08/20/2018
- Re: [Coq-Club] Compute a general recursive function on dependent types., Xavier Leroy, 08/19/2018
- Re: [Coq-Club] Compute a general recursive function on dependent types., Shengyi Wang, 08/19/2018
- Re: [Coq-Club] Compute a general recursive function on dependent types., Jason -Zhong Sheng- Hu, 08/18/2018
Archive powered by MHonArc 2.6.18.