Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Typeclass confusions

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Typeclass confusions


Chronological Thread 
  • From: e AT x80.org (Emilio Jesús Gallego Arias)
  • To: "Benjamin C. Pierce" <bcpierce AT cis.upenn.edu>
  • Cc: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] Typeclass confusions
  • Date: Sat, 24 Jun 2017 01:46:45 +0200
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=e AT x80.org; spf=Neutral smtp.mailfrom=e AT x80.org; spf=None smtp.helo=postmaster AT cc-tupan-roaming-b.ensmp.fr
  • Ironport-phdr: 9a23:kWzRdRJeBfi0XQRtytmcpTZWNBhigK39O0sv0rFitYgRI/3xwZ3uMQTl6Ol3ixeRBMOAuq0C07KempujcFRI2YyGvnEGfc4EfD4+ouJSoTYdBtWYA1bwNv/gYn9yNs1DUFh44yPzahANS47xaFLIv3K98yMZFAnhOgppPOT1HZPZg9iq2+yo9ZDeZwdFiCChbb9uMR67sRjfus4KjIV4N60/0AHJonxGe+RXwWNnO1eelAvi68mz4ZBu7T1et+ou+MBcX6r6eb84TaFDAzQ9L281/szrugLdQgaJ+3ART38ZkhtMAwjC8RH6QpL8uTb0u+ZhxCWXO9D9QKsqUjq+8ahkVB7oiD8GNzEn9mHXltdwh79frB64uhBz35LYbISTOfFjfK3SYMkaSHJBUMhPSiJBBY28YYUNAOQCM+lXoJXyqkASrReiHwSgGP/jxyVKi3LwwKY00/4hEQbD3AE4Ad0Dq3vVodbpOKsIVuC11qbIxijHY/1Z3Df96YzIchEmofqRWbx/b9HR0VM0FwjYj1ufs4jlPzeL2eQCtGiQ8vZtVfiui2E9sAF9pz6izdovhInRno8Z11TJ+CpjzIorONG1R1R3bcOkHZZTrS2WKoV7T8I6T2xruSs20LwLtJyhcCUO0pgqxh/SZvqaeIaS+B3jTvyeITJgiXJlZr2/gxGy/FC8xeLgT8W0zEtKrjJfndnKr3wNzRvT5dKCSvt8+Eeh1i+D2BvJ5u5aJ0A0jq/bK4Y7zr4+jJofqUXDHinol0XqlKKaa0Ep9+ey5+j5f7nrqYWQO5J0hwz9KKgih8KyDOUgPggLRWeb+OC81LP5/U3+RbVHluM5n7LWsZ3ZOcgXvKm5AxVa0oo78RawEy+m0MgEnXkANF9KZBWHj5HwN17SJPD4EOywjk+3kDZrwvDGJqfuDo/MLnjFirfhfKxy51RSyAopnphj4MceILwHIvv2W0m5n5qQNh40KQe5ia6zAt5l144EUm+nCa6Cdr7KvFmOoO8jPr/fSpUSvWPwA+h1v7jpl3Bx2XIYfK2o2tM1ZWsqBbxJKkGdbHXryv4bEG4R/1ltBNf2gUGPBGYAL025WLgxs3RiUNqr
  • Organization: X80 Heavy Industries

Hi Benjamin,

what happens is that the pre-typer tries to solve a "coercion problem"
[basically a type equality] from

forall a b : bool, Bool.eqb a b = true -> a = b

to

forall x y : ?X12, eqb x y = true -> x = y

[note the fresh type ?X12]

but indeed type class search will pick the first instance it finds, in
this case for Nat:

Debug: 1: looking for (Eq ?A) with backtracking
Debug: 1.1: exact eqNat on (Eq ?A), 0 subgoal(s)

which of course makes the coercion problem fail, and backtracking in
that part of the type inference is not powerful enough as to retry with
a different one.

I am not sure what the best solution is in this case, other than the one
you propose, as the logic is subtle [people talk from time to time of
improving the backtracking capabilities of the pretyper but I am not
sure that a brute force approach is what one would want here]

Best,
E.

[Regarding your original question, for most cases we tend to use the
class hierarchy that mathcomp provides which is implemented using
canonical structures and mixins. They seem mature and we just don't
have to worry too much about them]



Archive powered by MHonArc 2.6.18.

Top of Page