Coq - Extract Witness from Offer

I am trying to extract a witness from a coq sentence (or something like that).

I have something similar to

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

(as proved later, with an explicit type for atom :

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

How to extract such x ? Documentation says

From this (there is xp) we can, in turn, extract our witness x: A (using an exception construct such as a match)

but I don’t understand how it works ....

It also says

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

But if I try something like Parameter C : {x : atom | x \notin xs} 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
source share
1 answer

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

In accordance with paragraph "Projection sig". (Please note that there is a typo in this paragraph: https://coq.inria.fr/bugs/show_bug.cgi?id=2767 )

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

+2
source

Source: https://habr.com/ru/post/1262294/


All Articles