Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Is it possible to rewrite under binders?

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Is it possible to rewrite under binders?


Chronological Thread 
  • From: Abhishek Anand <abhishek.anand.iitg AT gmail.com>
  • To: coq-club <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] Is it possible to rewrite under binders?
  • Date: Sun, 21 Feb 2016 09:23:24 -0500
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=abhishek.anand.iitg AT gmail.com; spf=Pass smtp.mailfrom=abhishek.anand.iitg AT gmail.com; spf=None smtp.helo=postmaster AT mail-yw0-f176.google.com
  • Ironport-phdr: 9a23:4WjwIxUYypDUfEq+6YDSUKhlXrnV8LGtZVwlr6E/grcLSJyIuqrYZhGPt8tkgFKBZ4jH8fUM07OQ6PC/HzFbqsjb+Fk5M7VyFDY9wf0MmAIhBMPXQWbaF9XNKxIAIcJZSVV+9Gu6O0UGUOz3ZlnVv2HgpWVKQka3CwN5K6zPF5LIiIzvjqbpq8KVPl4D2mD1SIgxBSv1hD2ZjtMRj4pmJ/R54TryiVwMRd5rw3h1L0mYhRf265T41pdi9yNNp6BprJYYAu2pN5g/GLdfFXEtN30/rJngsgCGRg+S7FMdVH8Xm1xGGV6Wwgv9W8LYuCv7repw22GzO8TwQfhgUD6i7rxrRRyugSEOMTJ/8WDLheR/iatapFSqoBkpkN2cW52cKPcrJvCVRtgdX2cUBss=

I think the compiler should be free to replace subterms with definitionally equal ones because Coq programs/proofs cannot make any distinction finer than definitional equality. However, is it possible to build a compiler that optimally exploits this freedom?

More concretely, has there been work on the theoretical/practical feasibility of finding a "best" definitionally-equal sibling of a given Coq term?
I understand that defining "best" in a useful way may be challenging. 
In Guillaume's example below, f2 is clearly better for anyone interested in running their Coq programs.

To begin with, I am curious about the case where a term x is better than y iff when applied to 0 or more arguments of the right types, x takes fewer or same # of steps to achieve a weak-head normal form under call-by-need (lazy) evaluation.

Thanks,

On Thu, Jan 28, 2016 at 11:58 AM, Guillaume Melquiond <guillaume.melquiond AT inria.fr> wrote:
On 28/01/2016 17:15, Jonathan Leivent wrote:

> If the output of extraction
> from two extensionally-equivalent functions would behave differently in
> OCaml, then I would prefer that they are not treated within Coq as
> substitutionally identical.

But that is already the case, even without any functional extensionality!

Axiom g : nat -> nat -> nat.
Fixpoint f1 (n : nat) :=
  match n with S n => g (f1 n) (f1 n) | O => g O O end.
Fixpoint f2 (n : nat) :=
  match n with S n => let v := f2 n in g v v | O => g O O end.
Goal f1 = f2. reflexivity. Qed.

While f1 and f2 are convertible, their behavior is entirely different
when extracted to Ocaml. One performs an exponential number of calls to
g, the other one is only linear. Sure, you could devise an Ocaml
optimization so that f1 also has linear complexity once compiled. But
where do you set the limit of what a compiler is allowed to?

Best regards,

Guillaume



  • Re: [Coq-Club] Is it possible to rewrite under binders?, Abhishek Anand, 02/21/2016

Archive powered by MHonArc 2.6.18.

Top of Page