Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Straight reasoning with existential variables

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Straight reasoning with existential variables


Chronological Thread 
  • From: Joshua Gancher <jrg358 AT cornell.edu>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] Straight reasoning with existential variables
  • Date: Fri, 2 Aug 2019 11:01:54 -0700
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=jrg358 AT cornell.edu; spf=Pass smtp.mailfrom=jrg358 AT cornell.edu; spf=None smtp.helo=postmaster AT mail-io1-f47.google.com
  • Ironport-phdr: 9a23:JH+KkxaqLEsoEZeYCjFoy2D/LSx+4OfEezUN459isYplN5qZoMq6bnLW6fgltlLVR4KTs6sC17OM9fGxEj1Yqb+681k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRoLerpBIHSk9631+ev8JHPfglEnjWwba5sIBmsqQjcssYajI9+Jq0s1hbHv3xEdvhMy2h1P1yThRH85smx/J5n7Stdvu8q+tBDX6vnYak2VKRUAzs6PW874s3rrgTDQhCU5nQASGUWkwFHDBbD4RrnQ5r+qCr6tu562CmHIc37SK0/VDq+46t3ThLjlSEKPCM7/m7KkMx9lK1UoByjqBJ/zYDaY5ybOuRica7GZ9wWWXBMU9xNWyBdAI6xaZYEAeobPeZfqonwv18ArRylBQmsGePg0CJDiH7s0q08z+shER/J3BY9FN8JsnTUttr1OakSXO2216TH0TLDb+lQ2Tjj7IjIdgotru+RUrJtaMfcz1QkGQ3CjlWVs4PlPjWV2/wCs2ia8+pgVf+vhHU9pw5tpTivw98giobIhoIJylDE6D52zJwvKdKkT057ZNipG4ZTuSGCL4Z6XN8uTmVytCs5yrAKo4O3cSkLxZg9yBPSafqKeJWS7B35TuaeOzJ4iWpleL2hgxay9lCtyujmWcm11FZGtytFkt7RunwU2Rze5cqKRuFy/kem3jaP2ATT5f9eLU8okqrbLoYtwr82lpUNrUTOBjH6lFnygaOMdUgp+vKk5/nmb7jnvJOROI15hhn7Mqs0m8y/Beo4MhIJX2ie4em81qfj/UL3TbhKjfA7ibXWsJfAJcQduKG5BwtV3pw95BmiEjeqyM4YkmUfLFJZZBKHiJDkNE3JIPDhFPuwn1CskCpwyP3dJb3gApDNLmDZn7v7fLZ97VRcyAspwtxF6ZJUEOJJHPWmUUjo8dfcExURMgquwu+hBs8u+JkZXDetBbSZLaqanlaO7eIiOaHYZpUa42utA/Mi/fjjiXt/lFMAK/r6laALYWy1S6w1a36SZmDh149YTTU6+zEmRemvs2WsFCZJbi/pDak7/Dc2DIbgAIveFNj03e6xmRyjF5gTXVhoT1CBFXCyKteBUvYILSOVe4pvzmNCWr+mRIsskxqpsV2ikus1Hq/v4iQd8Knb+p1w7uzXmws18GUvXc+ayWeAS2Uyk28VFWY7

Hi,

I am not sure if this is exactly what you want, but you might be interested in the Procrastination library: https://github.com/fakusb/coq-procrastination

Using this library, I can indeed do (something equivalent to) eexists where you want it:

Require Import Procrastination.

Inductive sum : nat -> nat -> nat -> Prop :=
| Sum0 : forall a, sum 0 a a
| SumS : forall a b c, sum a (S b) c -> sum (S a) b c.

Theorem sum_exists : forall a b, exists c, sum a b c.
  induction a; intro.
  - exists b; constructor.
  - begin defer assuming c.
    + exists c.
      constructor.
      defer.  
    + end defer.
      apply (IHa (S b)).
Qed.

Josh

On Fri, Aug 2, 2019 at 10:40 AM Ilia Zaichuk <zoickx AT ztld.org> wrote:

Hello everyone,

Consider the following example:

Inductive sum : nat -> nat -> nat -> Prop :=
| SumO : forall a, sum 0 a a
| SumS : forall a b c, sum a (S b) c -> sum (S a) b c.

Theorem sum_exists :
  forall a b, exists c, sum a b c.
Proof.
  induction a; intro.
  - exists b. constructor.
  - eexists.
    constructor.
    specialize (IHa (S b)).
    destruct IHa as [c IHa].
    Fail apply IHa.
Abort.

The problem here (as suggested by [apply]) is that the shelved [?c] does not
have [c] in its scope. Fair enough. This problem has been coming up in a few of
my proofs lately, and I have learned to deal with it by moving the [destruct] -
the instantiation of [c] - above the [eexists].

However, this comes with a problem - it breaks the "flow of thought" in a proof.
You either have to know in advance what variables you need instantiated, or go
down to the point where you need them and move the instantiation above [eexists].
That would be fine for this small example, but in more complex proofs, it quickly
becomes unwieldy.

Without [eexists], I cannot apply the [SumS] constructor.
It is possible to add a lemma:

Lemma SumS_existential (a b : nat) :
  (exists c, sum a (S b) c) -> exists c, sum (S a) b c.
Proof.
  intros.
  destruct H as [c H].
  exists c. constructor.
  assumption.
Qed.

, with which the proof goes smoothly. But this, once again, is unsustainable
for more complex problems. I have tried writing a generic lemma for
"existential implication", but was unsuccessful.
Can such a lemma exist? (Or is it a tactic I am looking for?)

I have also tried manipulating the contexts of the main goal and the existential
variables separately (via [Unshelve]), and failed at proving the lemma this way at all.
Is it at all possible to cleanly do that in this case?

Overall, how can I prove this lemma without getting the reasoning tangled?

Thanks and regards,

Ilia.




Archive powered by MHonArc 2.6.18.

Top of Page