Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] What is triggering this bug in Function?

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] What is triggering this bug in Function?


Chronological Thread 
  • From: Agnishom Chattopadhyay <agnishom AT cmi.ac.in>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] What is triggering this bug in Function?
  • Date: Wed, 12 Aug 2020 09:08:21 -0500
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=agnishom AT cmi.ac.in; spf=Pass smtp.mailfrom=agnishom AT cmi.ac.in; spf=None smtp.helo=postmaster AT mail.cmi.ac.in
  • Ironport-phdr: 9a23:O/GPrB+CnAkelP9uRHKM819IXTAuvvDOBiVQ1KB20uwcTK2v8tzYMVDF4r011RmVBNuduqgP1bKempujcFRI2YyGvnEGfc4EfD4+ouJSoTYdBtWYA1bwNv/gYn9yNs1DUFh44yPzahANS47xaFLIv3K98yMZFAnhOgppPOT1HZPZg9iq2+yo9JDffgRFiCC5bL9sIxm7rBndvdQKjIV/Lao81gHHqWZSdeRMwmNoK1OTnxLi6cq14ZVu7Sdete8/+sBZSan1cLg2QrJeDDQ9LmA6/9brugXZTQuO/XQTTGMbmQdVDgff7RH6WpDxsjbmtud4xSKXM9H6QawyVD+/6apgVR3mhzodNzMh/27XhM5/gqJVrhyiuhJx3ZLbbZqPO/ZiZK7QZ88WSXZDU8tXSidPApm8b4wKD+cZIetYoI/9p1oVrRu+AgmsAf7kxyFIhnDswa06z+MhERnc0wM9H9IPsG7brdXoP6oVS++1w6/IzTTYb/NW3jf97ZPFfQwkofGNR75/a9bexVMuFwPDl1idr5HuMDyJ2OoXqWeb8/ZgWvy1i24hswx8oDeiytsjhITJhY8YyUzI+CdnzIopOdC0VFJ2bMO6HZZMtiyXOI97T90mTm10pCo21r4LtIK0ciUF1pgq2xDSZvqaeIaG5RLjUfyeITZ+hH99d7K/hgqy8Ui9yuLnTMW7zFFKri9dntnDqH8N0QTc6tCdSvt8+EeuxTeP1xjX6u5aO0w0kK7bJ4Ygwr42jJoTsF7MEjX4mEXsiqKda0Yq+vCw5uj6fLnrqIWQOo56hw3kLKgihsKyDf4mPgQTQWSX4fqw2KHn8EHjQ7hHjuc6nrTYvZ3bP8gXu620DxNT340+8RiwFS2m384dnXQfLFJKZhaHj4/xNlHLOv/4DPO/j06wnzduxvDKJKfuDYnXInjClrftZbd960hCxwov1d1T+oxYB78bLP/yVEL9rsLUAgM3PgCu3errFctx2psbWW2VA6+ZNK3SsUWP5uIqO+SDfoAVuDD8K/g+5/7uino5lEQBcqms3Jsbcmq3Eeh8L0WYZ3rgms0BHnsSvgoiUOzqj0WPXiJUZ3arRq4z+jU7CJ+9AorYXYCsgLmB3D+hEZFMZ2BGDEqMEXbyeImeVfcMcnHaHsg0mTsdELOlVoUJ1Be0tQa8xaA0APDT/3gxupTiz9hy4qX4lRgu6TtsBsidwmicBzV9kWUJXD8x2Yh0pE07w1zF0K4u0K8QLsBa+/4cClRyDpXb1eEvU4muCDKERc+ATROdevvjGSs4F4tjyNoPJU92XdSk3EiajniaRoQNnrnOP6Qat6fV3nz/PcF4ki+U36wgyVAtBMpJZzT/2/xPsjPLDouMqH230qancaNFgnzI/WaHi2GLvQdRW0hxV/edUA==

Thanks for suggesting the handy fix and the minimal example. I will submit a bug report.

By the way, is there a way to use the refine tactic with the Function command so that complex functions with proofs can be written in a simple way?

On Wed, Aug 12, 2020 at 2:11 AM Hugo Herbelin <Hugo.Herbelin AT inria.fr> wrote:
Hi,

> Is this a known issue with a simple workaround?

I did not test in your precise example but a simple workaround should
be to give a name to the class arguments, as in:

  Function toInc (f : trace indA -> trace indB) `{tf : TraceFunction f} `{mf : Monotone f}
  (ins : list (trace indA)) {measure length ins} : (list (trace indB)) :=
  match (rev ins) with
  | [] => [f []]
  | (new :: inss) =>
    let insofar := (concat (rev inss)) in
    (toInc f (rev inss))
      ++ [proj1_sig (monotonicity_witness insofar (insofar ++ new)
         (exist _ new (reflexivity (insofar ++ new))))]
  end.

Don't hesitate to submit a bug report at github.com/coq/coq/issues so
that it is recorded. Indeed, the fix should be easy (Function was
written at a time when type classes where not yet available and under
the invariant - changed by type classes - that all arguments had
names).

Best,

Hugo

--------------------------------------------------------------------------------
In case it is useful, here is a short example showing the same problem:

Require Import Recdef.
Class Bar.
Function iszero (n : nat) `{Bar} {measure id n} : bool :=
  match n with
  | O => true
  | _ => false
  end.

On Tue, Aug 11, 2020 at 09:02:02PM -0500, Agnishom Chattopadhyay wrote:
> Hi;
>
> When I try to run the command in line 516 here, I get a strange error:
>
>
> Function toInc (f : trace indA -> trace indB) `{TraceFunction f} `{Monotone f}
> (ins : list (trace indA))
>
> {measure length ins} : (list (trace indB)) :=
>
> match (rev ins) with
>
> | [] => [f []]
>
> | (new :: inss) =>
>
> let insofar := (concat (rev inss)) in
>
> (toInc f (rev inss))
>
> ++ [proj1_sig (monotonicity_witness insofar (insofar ++ new)
>
> (exist _ new (reflexivity (insofar ++ new))))]
>
> end.
>
>
>
> (* Error: Anomaly "File "plugins/funind/gen_principle.ml", line 1526,
> characters 37-43: Assertion failed."
>
> Please report at http://coq.inria.fr/bugs/.
>
> *)
>
> Is this a known issue with a simple workaround? I tried using `Program Fixpoint
> ` instead, but sadly Program Fixpoint does not generate an equation and creates
> a term very difficult to work with.



Archive powered by MHonArc 2.6.19+.

Top of Page