Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Compute a general recursive function on dependent types.

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Compute a general recursive function on dependent types.


Chronological Thread 
  • From: Jason -Zhong Sheng- Hu <fdhzs2010 AT hotmail.com>
  • To: "coq-club AT inria.fr" <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] Compute a general recursive function on dependent types.
  • Date: Sat, 18 Aug 2018 18:28:41 +0000
  • Accept-language: en-CA, en-US
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=fdhzs2010 AT hotmail.com; spf=Pass smtp.mailfrom=fdhzs2010 AT hotmail.com; spf=Pass smtp.helo=postmaster AT NAM01-BN3-obe.outbound.protection.outlook.com
  • Ironport-phdr: 9a23:ULGMmR+b2vq4Sv9uRHKM819IXTAuvvDOBiVQ1KB31OocTK2v8tzYMVDF4r011RmVBduds6oMotGVmpioYXYH75eFvSJKW713fDhBt/8rmRc9CtWOE0zxIa2iRSU7GMNfSA0tpCnjYgBaF8nkelLdvGC54yIMFRXjLwp1Ifn+FpLPg8it2O2+55zebx9UiDahfLh/MAi4oQLNu8cMnIBsMLwxyhzHontJf+RZ22ZlLk+Nkhj/+8m94odt/zxftPw9+cFAV776f7kjQrxDEDsmKWE169b1uhTFUACC+2ETUmQSkhpPHgjF8BT3VYr/vyfmquZw3jSRMMvrRr42RDui9b9mRh/2hikaKz43/mLZisJyg61Hrx2svAZwz5LIbIyPKPZyYr3RcNUHTmRBRMZRUClBD5u4YYQVFOoBOuBYpJTkq1QNrRu+Ag+sBOzywTFVhn/5w6s60+s4HQrb3gIgAs8FvXParNroNKcTUPu1wLfUwTnec/9bwjf96I/UchAku/6MXLZwfdDNxkkoEgPIl1OdopHrMTOS0+QCqWmb7+x4WOKujW4nsQBxrSK1yscikInEgJ8exFPc9Shhz4s5Oce0RUplbdK+DJdcrSOXOoRuTsMsXW5luzo2x7gDtJGmeCUF1psqyhvdZvGGc4WE/BfuWeeMLjhimH5ofaiwihWv/ke9zOD3S9O630xQriVfl9nBrnAN2ALX6siAUvZz5lus1zGT2wzO8+1JPFg6mKTCJ54m2bE/iIAfsUPeHi/qg0r2i7KWdkM59eSy8+TneLLmpoOCOIBolgH+M6MumsqlDeQ/LwgOQ2yb+eO71L3g50H2XLJKjvgunqnYtpDVO9gbq7a2DgNJyIou7wizAy263NgCn3QKI0pJeBedgIjoP1HOLur4DfC6g1m0njdk2vDGP7z6ApnTMnTPjavtcK19605b1AozyMpQ55NQCr0bPP3zXUrxuMTCDhAlKwy03/rnCNJl24wCXmKPG7aVP7/WsV+V/e0iOPKMZY8QuDblMfcp/f/ujXkjmV8cZ6alx5UXaGrrVshhdg+SZmOpidMcG08LuBA/RarkkhfKBTVUfjO5W782zjA9EoOvS4nZENODmruEiQWyBZpQLiV0CleKHj/Td4iCVLJESD/adsFtki4fD+D4E6ch0g2rvQ7+jbFgK7yHqWUjqZv/2Y0ttKXonhYo+GksVpXP4yS2V2hx21gwaXoz1aF7r1Z6zw7Yg6h/n/lRFNgV7PRMAF5jaczsitdiAtW3YTrvO8+TQQ/9ENWhHTQ4T9Z3yNgLMR4kRoeSyyvb1i/vOIc70ryGAJtorfD69l2pfoNX7S2D06MsyV47XsFIKGuqwLZl8BTeDJLIlEPfkLu2caMb32jG82LRlGc=

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.
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.

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.


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?


Sincerely Yours,

Jason Hu

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



Archive powered by MHonArc 2.6.18.

Top of Page