Skip to Content.
Sympa Menu

coq-club - [Coq-Club] Mixing [Program Definition] and some [Monad] type leads to impossible [Obligation]

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] Mixing [Program Definition] and some [Monad] type leads to impossible [Obligation]


Chronological Thread 
  • From: Valentin Robert <valentin.robert.42 AT gmail.com>
  • To: "coq-club AT inria.fr" <coq-club AT inria.fr>
  • Subject: [Coq-Club] Mixing [Program Definition] and some [Monad] type leads to impossible [Obligation]
  • Date: Thu, 16 Mar 2017 18:49:43 +0000
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=valentin.robert.42 AT gmail.com; spf=Pass smtp.mailfrom=valentin.robert.42 AT gmail.com; spf=None smtp.helo=postmaster AT mail-ua0-f179.google.com
  • Ironport-phdr: 9a23:hW1IQh/St2lSlP9uRHKM819IXTAuvvDOBiVQ1KB90+4cTK2v8tzYMVDF4r011RmSDNidtaoP2rOe8/i5HzdfsdDZ6DFKWacPfiFGoP1epxYnDs+BBB+zB9/RRAt+Iv5/UkR49WqwK0lfFZW2TVTTpnqv8WxaQU2nZkImbtjyT8TZiN3y3OSv8bXSZR9JjXyze/k6eB6xtEDastQcqYpkMKc4jBXT9ChmYeNTkF1hIV+Vgxf6rv239pN572wEpfsl+shcUKO8ZaMyQKZESmh8G28w7czv8xLESF3ctTMnTmwKn08QUED+5xbgU8Kpvw==

Hello,

In trying to define a non-structurally recursive monadic function, I came upon the realization that [Program Fixpoint] is unable to propagate values through immediately-applied lambdas.

Here is a small example that illustrates the issue:

Program Fixpoint recurse (n : nat) { measure n } : unit :=
  match n with
  | S n' => (fun i => recurse i) n'
  | O => tt
  end.
Next Obligation.
  (* Problem: Coq did not realize that i was n' *)

It seems that in this case, [Fixpoint] is actually smarter, as the following is accepted;

Fixpoint recurse' (n : nat) { struct n } : unit :=
  match n with
  | S n' => (fun i => recurse' i) n'
  | O => tt
  end.

Is there a way to have the same power in [Program Fixpoint]? Since monadic code unfolds to (foo >>= (fun x => bar)), it's impossible to prove that recursive calls are safe because the provenance of values is lost in the function application.

- Valentin



Archive powered by MHonArc 2.6.18.

Top of Page