coq


How to destruct a exist in goal for coq


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.
unfold myvar; destruct A.
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 gallina match underneath, and in Coq, pattern matching may lose some typing information if not done carefully, search for "Convoy Pattern" for more information.
You can name the 'outputs' of a destruct tactic if you want:
(* Stupid definitions to create a minimal example *)
Parameter A: Set.
Parameter P Q: A -> Prop.
Definition f (x: A) : {r | P r }.
Admitted.
Goal (forall x, let (r, _) := f x in Q r).
intro x.
destruct f as [r hr]. (* you goal has now r: A and hr : P r as premises *)
Abort.
Edit: more info after comment.
If you don't name them, Coq will do it automatically for you using a scheme based on xi variables (x0, x1, ...). You can only force the naming of the first variable if you don't care about the name of the second part using destruct f as [r].

Related Links

Is there a convention for the order of applying ssreflect tactic/taticals?
How to systematically normalize inequalities to < (lt) and <= (le) in Coq?
Inductive subset of an inductive set in Coq
How to find the source file for an identifier in Coq
Coq “Unknown interpretation for notation” error
How to switch the current goal in Coq?
Reasoning about lists in Coq
what does the curly braces {} do in ssreflect rewrite
How to define unspecified constants in Coq
How to automatically prove simple equality of real numbers in Coq?
How to simplify real number terms in Coq?
How can I prove that (eqb x y) means x = y
What's the difference between `Reals` and `Coq.Reals.*` in Coq?
when is the `:` (colon) in necessary in ssreflect/Coq?
What's with the `of` and `&` in the Coq Inductive definition?
How to simplify A + 0 > 0 into A > 0?

Categories

HOME
testing
testng
openmp
single-sign-on
objectgears
android-4.4-kitkat
youtube-dl
q
filtering
c#-2.0
baqend
cross-browser
echarts
swagger-ui
autotools
python-unittest
facebook-php-sdk
fancybox-3
user-input
spring-xd
modx-revolution
quickfix
opentracing
seaborn
oracle-coherence
sms-gateway
arabic
apache-commons-io
django-storage
poltergeist
filezilla
web-api-testing
ping
kendo-datasource
instant-messaging
binary-data
yadcf
phonegap
.net-4.0
scorm2004
cloud-code
http-digest
lto
occlusion
ssjs
angular2-meteor
apache-fop
komodoedit
pango
python-c-api
pnotify
sage-one
darcs
csound
windows-iot-core-10
cudafy.net
titanium-android
sonarlint-vs
mediaelement
objective-c-swift-bridge
google-feed-api
transmitfile
qpid
multiple-regression
pagedlist
apachebench
freelancer.com-api
notify
tt-news
cdt
applescript-objc
titanium-modules
eol
dealloc
terminal-services
flexmojos
gnu-smalltalk
aqtime
sitemesh
ora-00911
flashvars
robotics-studio
itmstransporter
anonymous-methods
first-responder
runas
multipage
dbproviderfactories
work-stealing
gwt-ext
gcj
psi
rfc1123
remember-me
digest-authentication
paster
web-architecture
nintendo-ds
brewmp
boost-smart-ptr
genealogy
django-notification
signal-handling
lzh
ntvdm.exe

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App