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

Apply partially instantiated lemma
Using reflexivity in Coq
High-speed calculation of Coq's theorems
Topological Definition of Continuous in Coq
Reference in Coq Lists library not found
Purpose of maximal vs non-maximal implicit arguments
Idris type system properties
How to destruct/generalize over Program's rewritten match statements
Show all axioms Coq
Product Type in Coq
Coq inductive definition for the entailment property
How to make sublists in Coq?
Nested theorems in Coq
Why does this rewrite fail in the context of dependent types
How to raise exception in Coq?(in match … end)
How to define set in coq without defining set as a list of elements

Categories

HOME
openlayers
coq
zeromq
ngrx
json.net
stock
youtube-dl
razor
react-redux
rdf
dxl
cross-browser
medical
windows-10-universal
communication
ssl-client-authentication
google-apps-marketplace
remote-access
task
uitypeeditor
highlight.js
reactcsstransitiongroup
connection-string
jprofiler
jquery-ajaxq
restful-authentication
opennlp
javacv
brunch
fgetcsv
buck
opentype
ejabberd-module
jspm
libuv
tasklet
flink-streaming
preg-match-all
twilio-api
vsts-build-task
hybridauth
git-merge
event-driven
libvpx
objectlistview
service-discovery
twitch
temporary-files
elasticsearch-plugin
eclipse-scout
pdf-reactor
logparser
integrity
jxcore
directory-structure
font-size
objective-c-swift-bridge
static-ip-address
instant
trash
pagedlist
apachebench
php-internals
goose
two-factor-authentication
iad
execute
teamcity-8.0
tableau-online
responsive-images
rake-task
c3
cctv
onactivityresult
project-planning
sgen
aapt
didselectrowatindexpath
concurrent-collections
cloud-connect
floating-point-precision
bulkloader
excel-2003
random-seed
sharp-repository
simba
isnullorempty
datawindow
tridion-worldserver
amazon-appstore
eclipse-templates
pydot
hirefire
horizontal-accordion
digest-authentication
compiler-specific
web-architecture
iweb
simpletest
text-coloring
lzh
caching-application-block
document-conversion

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App