Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Co-inductive Streams vs. Functions

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Co-inductive Streams vs. Functions


Chronological Thread 
  • From: CJ Bell <siegebell+coq AT gmail.com>
  • To: Coq Club <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] Co-inductive Streams vs. Functions
  • Date: Thu, 10 Dec 2015 14:04:00 -0500
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=siegebell AT gmail.com; spf=Pass smtp.mailfrom=siegebell AT gmail.com; spf=None smtp.helo=postmaster AT mail-oi0-f45.google.com
  • Ironport-phdr: 9a23:4AT9jhO4Gjm75hT7hfcl6mtUPXoX/o7sNwtQ0KIMzox0KPryrarrMEGX3/hxlliBBdydsKIazbOJ+Pm4CSQp2tWojjMrSNR0TRgLiMEbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpQAbFhi3DwdpPOO9QteU1JTpkbntsMSLM01hv3mUX/BbFF2OtwLft80b08NJC50a7V/3mEZOYPlc3mhyJFiezF7W78a0+4N/oWwL46pyv+YJa6jxfrw5QLpEF3xmdjltvIy4/SXEGCCI/zM3Vngc2k5DBBGA5xXnVL/wtDH7v6xzwn/JE9fxSOUfe3yI4qNvAEvziSoIOjQ09GWUgctppK1eqROl4Rd4xtiHM8muKPNic/aFLpshTm1bU5MUDnQZDw==

So far so good.  But now, try to represent the naive Fibonacci function as a naive user who doesn't know it will actually terminate:

[...]

Coq won't accept this because of the occurrence of fib in the notation-produced function bodies (and I understand there are good reasons for rejecting such definitions).  In fact, I'm convinced that to produce a version that will be accepted, you'll essentially have to encode a runtime stack for the execution yourself - which isn't what you would have "signed up for" starting the exercise.

This example is due to Adam Chlipala.

The above example uses Capretta's encoding ("thunks"). Adam also shows an alternative encoding (from Megacz) that *does* work for the Fibonacci example and is (in my opinion) easy to work with. True, the user has to think about which encoding they use to avoid such problems, but that's kind of a running theme in Coq and it's certainly not limited to coinductive types.


The main difficulty I've had with Coq's limited guardedness checker is for coinductive proofs using the cofix tactic.

Anyone running into problems with the cofix tactic should try the Paco library (http://plv.mpi-sws.org/paco/) instead, which provides a coinduction tactic that feels similar to induction and makes it easy to write incremental and modular coinductive proofs (e.g. separate proofs for mutually corecursive functions). It uses greatest fixed-point representations of coinductive types, which is fairly easy to prove equivalent w.r.t. a CoInductive encoding.


-cj



 




Archive powered by MHonArc 2.6.18.

Top of Page