This is a bit generic so feel free to ask for details, I simplified to make the problem easier to communicate.
Say my goal is
let (r,_) := f x in Q r
where f x
has type {u | P u}
.
I want to "destruct" this so that I have Q r
as the goal with P r
as a hypothesis. What is the best way to achieve this ?
In the past, I have achieved what I wanted by
pose (f x).
and then simplifying.
Per request here is some simplified code.
Parameter T:Type.
Parameter P:T -> Prop.
Axiom A : {t:T|P t}.
Definition myvar:T.
destruct A.
exact x.
Defined.
Theorem B : P myvar.
will solve your goal in this particular case.
In general, the
destruct
tactic can be used with with any term and it will try to abstract the term out and destruct it. However, note that this may fail sometimes, particularly when using dependent types.The reason is that
destruct
uses the gallinamatch
underneath, and in Coq, pattern matching may lose some typing information if not done carefully, search for "Convoy Pattern" for more information.