问题
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