Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anomaly when inferring simple typeclass instance. #13045

Closed
arthuraa opened this issue Sep 17, 2020 · 8 comments · Fixed by #13119
Closed

Anomaly when inferring simple typeclass instance. #13045

arthuraa opened this issue Sep 17, 2020 · 8 comments · Fixed by #13119
Labels
part: rewriting tactics The rewrite, autorewrite, rewrite_strat, and setoid_rewrite tactics.
Milestone

Comments

@arthuraa
Copy link
Contributor

arthuraa commented Sep 17, 2020

Description of the problem

From Coq Require Import ssreflect.
From stdpp Require Import base gmap.
Goal False.
have: Inhabited (gmap nat nat) by [].
(* Toplevel input, characters 0-37: *)
(* > have: Inhabited (gmap nat nat) by []. *)
(* > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ *)
(* Error: *)
(* Anomaly *)
(* "tclZERO receiving critical error: Anomaly "Not an arity." Please report at http://coq.inria.fr/bugs/." *)
(* Please report at http://coq.inria.fr/bugs/. *)

Strangely, swapping the two import lines makes the anomaly go away (though typeclass inference still fails to find the empty_inhabited instance.)

Coq Version

8.12

@CohenCyril
Copy link
Contributor

CohenCyril commented Sep 17, 2020

Ssreflect have does not perform typeclass inference, you may add a ltac in term refine to compensate. (see below)
I remember @gares had some ideas of how to integrate ssreflct have with typeclass inference more smoothly, meanwhile he already gave me the following trick:

@CohenCyril CohenCyril added part: ssreflect The SSReflect proof language. part: typeclasses The typeclass mechanism. labels Sep 17, 2020
@arthuraa
Copy link
Contributor Author

@CohenCyril Great to know about the refine trick!

@gares
Copy link
Member

gares commented Sep 17, 2020

I don't understand my trick 🤣
Is have : T := !! _. the thing?

@SkySkimmer
Copy link
Contributor

Anomaly probably from around

coq/plugins/ssr/ssrview.ml

Lines 204 to 209 in 1c919ed

with e ->
(* XXX this is another catch all! *)
let e, info = Exninfo.capture e in
Ssrprinters.ppdebug (lazy
Pp.(str"interp-err: " ++ Printer.pr_glob_constr_env env glob));
tclZERO ~info e

@gares
Copy link
Member

gares commented Sep 30, 2020

Well spot. But this is about the "external anomaly". There is still the internal one (there are 2 anomalies in the error message)

@SkySkimmer
Copy link
Contributor

Actually the bad tclZERO looks like this one instead

coq/plugins/ltac/rewrite.ml

Lines 2147 to 2150 in 1c919ed

with e ->
(* XXX what is the right test here as to whether e can be converted ? *)
let e, info = Exninfo.capture e in
Proofview.tclZERO ~info e

@SkySkimmer
Copy link
Contributor

Similar anomaly, no ssr:

From stdpp Require Import base gmap.
Goal Inhabited (gmap nat nat).
  reflexivity.

@SkySkimmer
Copy link
Contributor

Much reduced version:

#[universes(template)]
Inductive R (x:nat) (A:Type) : Type := C : A -> R x A.

#[universes(template)]
Inductive Box (A:Type) : Type := box : A -> Box A.

Goal Box (R 0 Set).
  reflexivity.

@SkySkimmer SkySkimmer added part: rewriting tactics The rewrite, autorewrite, rewrite_strat, and setoid_rewrite tactics. and removed part: ssreflect The SSReflect proof language. part: typeclasses The typeclass mechanism. labels Sep 30, 2020
@ppedrot ppedrot closed this as completed in 9b27bd5 Oct 7, 2020
@coqbot-app coqbot-app bot added this to the 8.12.2 milestone Oct 7, 2020
@Zimmi48 Zimmi48 modified the milestones: 8.12.2, 8.12.1 Oct 8, 2020
Zimmi48 pushed a commit to Zimmi48/coq that referenced this issue Oct 8, 2020
Fix coq#13045

Also make sure future anomalies won't be fed to tclzero.

Instead of retyping with lax:true we may question why we produce an
ill-typed term in decompose_app_rel: in the

    | App (f, [|arg|]) ->

case we produce `fun x y : T => bla x y` but we have no assurance that
the second argument of `bla` should have type `T`.

(cherry picked from commit 9b27bd5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
part: rewriting tactics The rewrite, autorewrite, rewrite_strat, and setoid_rewrite tactics.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants