Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] proving decidable equality of a huge but simple inductive

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] proving decidable equality of a huge but simple inductive


Chronological Thread 
  • From: Jim Fehrle <jim.fehrle AT gmail.com>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] proving decidable equality of a huge but simple inductive
  • Date: Wed, 17 Jun 2020 11:12:21 -0700
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=jim.fehrle AT gmail.com; spf=Pass smtp.mailfrom=jim.fehrle AT gmail.com; spf=None smtp.helo=postmaster AT mail-io1-f48.google.com
  • Ironport-phdr: 9a23:PNOJ6hZ5s+bK4/3/MZ+ay3r/LSx+4OfEezUN459isYplN5qZr8m4bnLW6fgltlLVR4KTs6sC17OL9fm/AydZucrJmUtBWaQEbwUCh8QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYdFRrlKAV6OPn+FJLMgMSrzeCy/IDYbxlViDanbr5+MRW7oR/MusQUn4duJbs9xgfGr3BVZ+lY2GRkKE6JkR3h/Mmw5plj8ypRu/Il6cFNVLjxcro7Q7JFEjkoKng568L3uxbNSwuP/WYcXX4NkhVUGQjF7Qr1UYn3vyDnq+dywiiaPcnxTbApRTSv6rpgRRH0hCsbMTMy7WfagdFygq1GuhKsvxNww4DWb4+VOvRwfb7Tc80GSmdaRMldSzZMD5mgY4cTDecMO/tToYnnp1sJqBuzHQ2iBOLqyjRVhnH5w6060/4lEQ7YwQctGNAOsHXRrNnvOqcdT+C1zLPMzTrddP5W1jL955LJchAlu/2DQbVwcc/IxEQpCgjKgUmep5b/MDOJyuQCrXKb7+x4WOyhiWMqtQ58ryWsy8oslIXHiJ8Zx07a+Sh6wIg5O8G1Rk56bNCrHpVetyKXOpZyT84tQ2xlpjo2x78HtJKnfCYHzoksyRDYa/yCaYeI4xTjWf6eITd5mHJleK+/iA2o/Ue8ze38U9G40FlLripZktnMq2sC2wbJ5sebTft9+0Gs0iuM2QDL8uxIP1w4mK7BJ5MiwrM8jIcfvEXCEyPsl0j7j6mbfVg+9Oey8eToeLDmq4ecN4BqjgH+NbwjmsmlDuQ5NggCRmmb+eOh2LH68030T7ZHguc5kqnet5DaKsAbqbCjDwBJ1YYj7g6zDzag0NsGgXkKNExJdA6DgoTzOFzDIOr0Aeq+jlmtijtmyPPLMqXkAprXL3jDlLnhfax6605Z0Aczz9Ff55dOBrEPPv3zWlXxtNjGARIiPAy0xvzoCNR51o8ERW2PBaqZPLvIsVCU/uIvP/WMZIgNtTnhLPgl/ufigmM9mV8AZqakxoAXaXC9HvR+OUqVe3vsgtEbEWcLpAUyVuLqiEfRGQJUMn21Ruc34iwxIIOgF4bKAI6305Kb2yLuPJxTLk5LCkqIHD+8dYSBHfkBaDiWL+dulzUFUf6qTIp3hkLmjxPz17cydrmcwSYfr5+2jIEptd2Wrgk78HlPN+rYy3uEFjgmkWYBRjtw16d68xQklwWzlJNgivkdLuR9ovNEVgBgaMzZxu1+TtH1A0fPIofPR1GhTdGrRzo2S4Bpmo5cUwNGA9ynyyv78W+vCr4RmaaMAcVtoK3Z1nn1Yc16ziSf2Q==

Coq has at least one big memory leak.   Currently we're working on one such case in https://github.com/coq/coq/issues/12487.

Jim

On Wed, Jun 17, 2020 at 11:00 AM Samuel Gruetter <gruetter AT mit.edu> wrote:
I think the problem is that if you want to define an eq_dec for a type with n
constructors, you need a term of size n^2, so here's a way to get similar
definitions (not sure if similar enough for what you need) without requiring
one big Inductive for "constructor":

Definition decidable (P: Prop) := {P} + {~P}.
Definition eq_dec T := forall (x y:T), decidable (x=y).

Inductive spec_type: Set :=
| abruption
... same as before
.

Inductive constructor_of_abruption: Set :=
| AnomalyAbruption : constructor_of_abruption
| NotImplemented : constructor_of_abruption
| ObjectAbruption : constructor_of_abruption.

... one separate Inductive per spec type

Definition constructor(t: spec_type): Set :=
  match t with
  | abruption => constructor_of_abruption
  | ... => ... 157 more cases, but not inside an Inductive!
  end.

Scheme Equality for constructor_of_abruption.
... 157 more of them

Definition constructor_eq_dec(t: spec_type): eq_dec (constructor t) :=
  match t with
  | abruption => constructor_of_abruption_eq_dec
  | ... => ...
  end.

The full file is here:
https://gist.github.com/samuelgruetter/01db98f43a8dc57f7d70f7d12e48eb20
(I couldn't attach it to the email because apparently the maximum message
size on this list is 39 kB).

On my machine, "/usr/bin/time -v coqc js.v" says it runs within 1GB of RAM
and 17s, which I'd consider ok. And most of the time (~15s) is spent in on
one single line:

Time Scheme Equality for constructor_of_intrinsicObject.

because that one has 110 constructors.

On Wed, 2020-06-17 at 15:44 +0200, Alan Schmitt wrote:
> Hello,
>
> As part of a larger project, I'm generating a big inductive type for
> which I need to prove decidable equality. Running ~coqc js.v~ on the
> attached file result in a Stack Overflow. I tried duplicating the line
> where the problem occurs (instead of using "all:"), but I then run out
> of memory and coqc is killed.
>
> I feel like I'm not using the correct approach. Do you have suggestions
> on how to deal with this?
>
> Thanks,
>
> Alan
>



Archive powered by MHonArc 2.6.19+.

Top of Page