Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Creating induction principles with additional hypotheses

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Creating induction principles with additional hypotheses


Chronological Thread 
  • From: Nathanaël Courant <nathanael.courant AT ens.fr>
  • To: coq-club AT inria.fr
  • Cc: Li-yao Xia <lysxia AT gmail.com>
  • Subject: Re: [Coq-Club] Creating induction principles with additional hypotheses
  • Date: Thu, 27 Aug 2020 16:17:21 +0200
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=nathanael.courant AT ens.fr; spf=Pass smtp.mailfrom=nathanael.courant AT ens.fr; spf=None smtp.helo=postmaster AT nef.ens.fr
  • Ironport-phdr: 9a23:HGXRaxMyMPj6+8xCb0Ql6mtUPXoX/o7sNwtQ0KIMzox0Iv/5rarrMEGX3/hxlliBBdydt6sazbOM7+u/ASQp2tWoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6nK94iQPFRrhKAF7Ovr6GpLIj8Swyuu+54Dfbx9HiTagYL5+Ngi6oRveu8UZg4ZuNrs6xwfUrHdPZ+lY335jK0iJnxb76Mew/Zpj/DpVtvk86cNOUrj0crohQ7BAAzsoL2465MvwtRneVgSP/WcTUn8XkhVTHQfI6gzxU4rrvSv7sup93zSaPdHzQLspVzmu87tnRRn1gyoBKjU38nzYitZogaxGvhyhqRxxzY3abo6bO/VxfL/Sc9wBSGpdXctcTTBNDp+yYoYNCecKIOZWr5P6p1sLtRawHROjBP/vyjBSgH/5x7E90+A5HgzY2wwgAsgOv27SrNXpKawfVua1w7PUzTXDdfxW3y3y55bMchw7vf6MWq9wcdDLxkkpCwPIlUufqYr+Pz+P2OQNqXGW4ux9Xu2gl2ApsRt+oiSzxsgykInJgJoYx1HF+Ct3wIg4JNO2RVJ0bNCrH5Zdtj2WOoR1T84iTG9kpSU3x7MIt5O5ciUHzIkqyhzBZvGFb4WF4Q7vWeieLDp+mXlre6q/ig6v/US+zuDwTNS43VJOoyZfltTBt2oB2hPP5sSfV/dx4EOs1SyS2w3X7uxIO104mbDFJ5I/xLM7i4Advl7ZHiDsnUX7lK+WeVsg+uiv8+nnZKvpppGGO4BqjAH+Kb4imsKlAeggMwgOWXaU+fik2bH+40H0RK9GguAyn6TdqpzXIcUWqrS2DgNJyooj7gywDzai0NQWh3kHK1dFdQqBj4fzJ1HOIOr3DfGljFuylDdn3ezJPrr8ApXXNHfDlqvhcK1j5E5a0wo/195f54hMBrEbPP3zQlPxtMDfDhIhLwO0xP/nBMxh2YMaRGKAGbSUMLjSsF+N/uIgOfOAZI4TuDbnKvgq/eTijXEjmQxVQa781pwOLXu8A/5OIkODYHOqjM1SP30Nu18YRfDqgVuL0jpkTHGvRas6+nlvDou6DY7FT42pxreGwT2yGIF+a2ZdTF6WRyS7P76YUusBPXrBavRqlSYJAOD4F90RkCq2vQq/8IJJa/LO831KuJT4ktZvtbWKyEMCsAdsBsHY6FmjCmF5mmRRHW0w0a45rEpmjFmZg/Ah0q5oUOdL7vYMaT8UcJvVzuh0Edf3ClDMeMzPRkz0G9g=

Hi,

Thanks a lot of the idea! However, while this would be a possibility when proving this specific case, it only allows to use one such additional property P : X -> A -> Prop. I'd like to be able to use different properties as well, possibly with different types, such as Q : X -> B -> Prop.
I was thinking about making A polymorphic in that case, and adding another parameter to be the function used to determine the values of type A used in the recursive calls, but it seems to be too clumsy and to pollute the definition with a lot of added complexity.

Cheers,
Nathanaël

On 8/27/20 3:26 PM, Li-yao Xia wrote:
Hi Nathanaël,

One idea is to generalize the open recursion so the recursive predicate takes an A parameter:

Inductive red_ (rec : X -> A -> Prop) : X -> Prop.

Would there be any problem doing that?

Cheers,
Li-yao


On 8/27/2020 6:13 AM, Nathanaël Courant wrote:
Hi all,

I have a complicated inductive proposition:

Inductive red: X -> Prop :=
| case_1 : ...
...
| case_N : ...


I also have some proposition P : X -> Prop.
I have goals of the form:

forall x, red x -> P x -> Q x.

which I prove by induction on red x. I can prove that if red x and P x, then P y is true for all y appearing as recursive calls to red in the constructor of red x.

However, each time I want to prove such a result, I have to prove P is true for each of the recursive calls, and I want to avoid such code duplication.



One possibility would be to create a custom induction principle, but since red is very complicated, this would amount to duplicate a lot of code, which I would rather avoid.



Another possibility I tried was to switch to open recursion:

Inductive red_ (rec : X -> Prop) : X -> Prop :=
...
Inductive red := red_intro : forall x, red_ red x -> red x.

Then I proved:

forall H x, red_ (fun x => red x /\ H x) x -> P x ->
             red_ (fun x => red x /\ H x /\ P x) x

and

forall x, red_ (fun x => red x /\ P x /\ Q x) x -> Q x

which, combined, allow to prove forall x, red x -> P x -> Q x, and the deduplication of the work is done thanks to the first proof, which does not depend on Q.


This works well on that simple case, however, the case I have is a bit more complicated: P is not of type X -> Prop, but of type X -> A -> Prop, for some other type A.

I still have that if red x and P x a are true, then P y b are true for all y appearing as recursive calls to red in the constructor of red x (i.e. as calls to rec in red_ rec x), but it is for some b that depends on the recursive call and the constructor used.
Thus, I can still prove the same thing as in the open recursion case, but with the proposition (fun x => exists a, P x a). However, I want to be able to use the correct value of a for the recursive calls in the second part of the proof when I want to prove Q, and I can't, because it is hidden away by the exists, since I have to prove:

forall x, red_ (fun x => red x /\ (exists a, P x a) /\ Q x) x -> Q x.



Finally, I tried to create a function to extract the values of a needed from the constructor used to prove red x, but I'm getting a universe inconsistency, since red is a Prop.



Does anyone have an idea about how to extend recursion schemes for induction propositions, while proving some property is preserved as above, without getting a lot of code duplication in the way?


Thanks,
Nathanaël




Archive powered by MHonArc 2.6.19+.

Top of Page