Coq - Extract witness from Proposition

╄→гoц情女王★ 提交于 2020-01-03 01:40:56

问题


I'm trying to extract a witness from a coq proposition (or something like that...).

I have something that goes like

Parameter atom_fresh_for_list :
    forall (xs : list atom), {x : atom | ~ List.In x xs}.

(Which is proven afterward, with an explicit type for atom :

Lemma atom_fresh_for_list :
    forall (xs : list nat), { n : nat | ~ List.In n xs }.

How do I extract such an x ? The Documentation says

From such a (exist x p) we may in turn extract its witness x:A (using an elimination construct such as match)

but i don't get how this works....

It also says

Given A:Type and P:A->Prop, the construct {x:A | P x} is a Type

But if i try something like Parameter C : {x : atom | x \notin xs}, it gives

Error: The term "C" has type "{x : atom | x \notin xs}" which should be Set, Prop or Type.

回答1:


This is explained quite well in: http://coq.inria.fr/stdlib/Coq.Init.Specif.html

Under the paragraph "Projections of sig". (Note that there is a typo in that paragraph: https://coq.inria.fr/bugs/show_bug.cgi?id=2767 )

What you want is called proj1_sig I believe. You can see how it's defined in the documentation.



来源:https://stackoverflow.com/questions/11593270/coq-extract-witness-from-proposition

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!