Skip to Content.
Sympa Menu

coq-club - [Coq-Club] Preventing pollution of typeclass resolution when Require Importing a MathClasses module

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] Preventing pollution of typeclass resolution when Require Importing a MathClasses module


Chronological Thread 
  • From: Yannick Zakowski <zakowski AT seas.upenn.edu>
  • To: coq-club AT inria.fr
  • Subject: [Coq-Club] Preventing pollution of typeclass resolution when Require Importing a MathClasses module
  • Date: Wed, 15 Jul 2020 10:32:25 -0400
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=zakowski AT seas.upenn.edu; spf=Pass smtp.mailfrom=zakowski AT seas.upenn.edu; spf=None smtp.helo=postmaster AT mail-qt1-f194.google.com
  • Ironport-phdr: 9a23:QAjdEhSKL0Gmy1i62YIItZAzpNpsv+yvbD5Q0YIujvd0So/mwa6ybRON2/xhgRfzUJnB7Loc0qyK6v6mAjZLvs3JmUtBWaQEbwUCh8QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYdFRrlKAV6OPn+FJLMgMSrzeCy/IDYbxlViDanbr5+MRS7oR/fu8UIjodvKKg8wQbVr3VVfOhb2XlmLk+JkRbm4cew8p9j8yBOtP8k6sVNT6b0cbkmQLJBFDgpPHw768PttRnYUAuA/WAcXXkMkhpJGAfK8hf3VYrsvyTgt+p93C6aPdDqTb0xRD+v4btnRAPuhSwaMTMy7WPZhdFqjK9DvhyvpwFxzY3abo6bO/VxYrjQcskGSWdbRMtdSyJMD4G6YoASD+QBJ+FYr4zlqlQMtxS+Aw+sBOLzxT9Lm3T53rc10+cmEQDIxwwgHNMOu2nTodT0LqgSUue1zafTzTXAbvNbwiz955bSfRA6u/2MQKpwftTXyUkpDQ/KkEifqZH8Mj6Ty+8CvHSV4fB6WuKzl24otRtxoj63y8swhYfEiJwYxk7K+yh63Ys4Od61RkF0bNCqHpZdqiGUOoVoT88/TGxmtic3xqEGtJKlYSQHy4kqywDCZvGHc4WF5A/oWuiWITd9nn1lebS/ig6v/kih0e3zSs600EtQripejNbArH8N1wbU6siaUvtw+Fqq1zWX1w3L9O1IPUQ5mbDYJpMh2LI8i5sevVjZEiPrnEj7g7eae0Qg9+Sy9ejqYrvrqoWCO4Nolg3yKKUjl8K5DO8lKAYBRXKb9v651LD7/U32XrFKjvoun6ncqp/aJMAbqregAw9Jz4ov8hi/Ayqi3dkXh3UHI1VFeBWIj4jtJV7COuz3DfC6g1i0kTdrwe7JPqH5D5nTMnTOlK3tcLV95kJG1QY+zMxT64hJBrwFL///Qkrxu8bZDh89PQy02eHnCNBl24IfQ22PAaiZMa3JsV+L5+IiOPKMa5EPtzbmMfQl+ubugmE/mV8bZ6Wmw4YYaG2gEvR8P0qZeWbsgssGEWoSogU+S/XqhESeXj5Xena9RLkx5io7CYKjFYfMXJqhgL2H3CehH51ZfHpKCl6WESSgS4LRUPAVLSmWP8VJkzoeVLHnRZVy+wupsVrLwrxhL+HXsh8RtpX8z9t0r7nBnBI16id3DuyG3miWCXxsk2UOATI6wfYs8gRG1l6f3P0g0LRjHttJ6qYRC1poBdvn1+V/TuvKdEfBc9OOEgj0R9ynBXQoUot0zYZfPwByHNKtih2F1C2vUedMy+67Qacs+6eZ5EDfYt5nwi+YhrIshkJgX9NCM2vgi6JipVCKVtz51n6BnqPvTpwymSvE9WON122L5R8KSwN5SuPYRX0ZYA3bocmrv04=

Dear all,

Consider the following self-contained example:

From Coq Require Import
     Setoid
     Morphisms
     RelationClasses.

Section Foo.

  Variable op: nat -> nat.

  Variable rel: nat -> nat -> Prop.

  Context {rel_op_Proper: (Proper (rel ==> rel) op)}.
  Context {rel_trans: Transitive rel}.

  Goal forall (a b: nat) (REL: rel a b),
      rel (op a) (op b).
  Proof.
    intros.
    Typeclasses eauto := debug.
    rewrite REL.
    (* Resolution in 6 steps *)
    Undo.
    Require Import MathClasses.interfaces.abstract_algebra.
    rewrite REL.
    (* Resolution in over 100 steps *)
  Abort.

End Foo.

I am looking for a way to avoid this side-effect of loading this MathClass module.
The problem touches to the overall issues of Hints being aggressively exported, and instances all sharing a single namespace. A general solution would naturally be welcome, but I would already be very happy with a hacky local solution allowing me to get back into my proof. In this specific case, it indeed looks to me like the main culprit that gets applied early and completely derail the proof search is the following External Hint declared in `abstract_algebra.v`:

Hint Extern 4 (?f _ = ?f _) => unshelve eapply (sm_proper (f:=f)).

I have given a shot at `Set Loose Hint Behavior "Strict".` without success. For good conscience I also tried `Remove Hints sm_proper: core_db.`, but as described in the documentation, it does not apply to External Hints.

Any idea as to how to solve this problem would help me a great deal.

For context, in my concrete use-case, I am proving a pass of compilation from an existing language (Helix) to another existing language (Vellvm) using a library (Interaction Trees).
The dependency on MathClass is transitively inherited from Helix, but is essentially irrelevant to the proof itself.
I rewrite non-trivial relations (via the Interaction Tree library) in fairly complex context, so that this overhead seems to become unbearable.
I am therefore ideally really looking for a local way to prevent this behavior, if possible without having to mess with any of the three libraries at play.

Thanks in advance,
Best,
Yannick

P.S. : This intersects with my question on Discourse¹. I am not sure what's the current etiquette on cross posting to try to reach as many users as possible. Let me know if it's any issue.

¹: https://coq.discourse.group/t/preventing-pollution-of-the-instance-context-during-import/942





Archive powered by MHonArc 2.6.19+.

Top of Page