Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Getting typeclass resolution to fail quickly?

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Getting typeclass resolution to fail quickly?


Chronological Thread 
  • From: Jason Gross <jasongross9 AT gmail.com>
  • To: coq-club <coq-club AT inria.fr>
  • Cc: Matthieu Sozeau <matthieu.sozeau AT inria.fr>, "Paul A. Steckler" <steck AT stecksoft.com>
  • Subject: Re: [Coq-Club] Getting typeclass resolution to fail quickly?
  • Date: Wed, 1 Jun 2016 12:43:57 -0400
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=jasongross9 AT gmail.com; spf=Pass smtp.mailfrom=jasongross9 AT gmail.com; spf=None smtp.helo=postmaster AT mail-oi0-f46.google.com
  • Ironport-phdr: 9a23:N++O7RcOi8iu7VXVbUEi7K8slGMj4u6mDksu8pMizoh2WeGdxc68bR7h7PlgxGXEQZ/co6odzbGG4ua9BidRsd6oizMrTt9lb1c9k8IYnggtUoauKHbQC7rUVRE8B9lIT1R//nu2YgB/Ecf6YEDO8DXptWZBUiv2OQc9HOnpAIma153xjLDjvcCMKFQYzBOGIppMbzyO5T3LsccXhYYwYo0Q8TDu5kVyRuJN2GlzLkiSlRuvru25/Zpk7jgC86l5r50IeezAcq85Vb1VCig9eyBwvZWz9EqLcQza7XwFF24SjxAAVwPC9VTxWor7mir8rOt0nieAa57YV7cxDBar9KBtADDyjzwcf2o7+XrQjMNqi7lA8TquohV+x8jfZ4TDZ6k2Rb/UYd5PHTkJZc1WTSEUR9rkN4Y=

Yes, the typeclass depth needs to depend on the shape of the subgoal, or at least the tactic I'm running.  If I set the depth to 1, [autorewrite] succeeds in 0.04 seconds.  But then earlier typeclass resolution fails.  If I set the depth to 5, then the earlier resolution succeeds, but [autorewrite] takes 1.3 seconds each time I run it.

-Jason

On Tue, May 31, 2016 at 6:22 PM, Abhishek Anand <abhishek.anand.iitg AT gmail.com> wrote:
Does the following work?

Typeclasses eauto := 1 (* or a small number denoting the depth of search *)

https://coq.inria.fr/refman/Reference-Manual023.html#TypeClassCommands (20.6.6)

Do you want a way to make the depth of the search depend on the shape of the typeclass-resolution subgoal?



On Tue, May 31, 2016 at 5:33 PM, Jason Gross <jasongross9 AT gmail.com> wrote:
Hi,

Is there a way to get typeclass resolution to fail quickly?  For example, if the search encounters
  Proper (le ==> _ ==> impl) le
it should fail immediately, because instantiating the _ with any reflexive relation yields a contradiction, and instantiating it with any irreflexive relation yields a slow failure on searching for a ProperProxy (in setoid_rewriting).  But I can't seem to get this to happen; typeclass resolution calls [proper_subrelation], and then tries to convert each Proper instance it finds for lt with (lt ==> _ ==> impl), which is, of course, impossible.  This means I need to be extremely careful to not put any lemmas in my rewriting databases which can utterly fail to be respected by any other relation (so any facts about [le] or [lt] are right out).  This is annoying, especially when I want facts of the form [forall x, lt x x <-> False] or [forall x, le x x <-> True],* so that I can use rewriting databases to find contradictions in the hypotheses.

Are there ways to fix this?

Thanks,
Jason

* The actual situation is a bit more complicated: I am using boolean-valued relations with a coercion to Sortclass (is_true), and the problem comes when I have something like [forall x, leb x x = true].  Since I've declared [leb : nat -> nat -> Prop] as a relation which can have instances, the setoid rewriting machinery tries both to replace [leb x x] with [true], and also to replace [x] with [x] via the [fun x y => is_true (leb x y)] relation, which is what causes the slowness.





Archive powered by MHonArc 2.6.18.

Top of Page