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

HB.lock "erefl body" error message #456

Open
hivert opened this issue Oct 25, 2024 · 6 comments
Open

HB.lock "erefl body" error message #456

hivert opened this issue Oct 25, 2024 · 6 comments

Comments

@hivert
Copy link
Member

hivert commented Oct 25, 2024

If I try

HB.lock Definition Bla (T : finType) : Type := {set T}.

HB complaints with

Error:
The term "erefl body" has type "body = body" while it is expected to have type
 "body = [eta set_of]".

I think my code should be perfectly legitimate.

@hivert
Copy link
Member Author

hivert commented Oct 25, 2024

The same works with ELPI:

From elpi Require Import elpi locker.
lock Definition Bla (T : finType) : Type := {set T}.

@gares
Copy link
Member

gares commented Oct 25, 2024

Yes, but that is the soft locking that does not use module types. If you try mlock instead, you get the same error.

@gares
Copy link
Member

gares commented Oct 25, 2024

Looking at the elpi trace of mlock I see code roughly equivalent to:

Definition body : Finite.type -> Type := fun T : Finite.type => set_of T.
Definition unlock : (@eq (Finite.type -> Type) body (fun T : Finite.type => set_of T)) :=
  @Logic.eq_refl  (Finite.type -> Type) body (fun T : Finite.type => set_of T).

that seems correct.

I think the problem must be in the universes, eg 25742 vs 25735 in this raw log below:

coq.env.add-const body 
 (fun `T` (global (indt «Finite.type»)) c0 \
   app [global (const «set_of»), c0]) 
 (prod `T` (global (indt «Finite.type»)) c0 \ sort (typ «a.25735»)) ff 
 X33

 coq.env.add-const unlock 
  (app
    [global (indc «Logic.eq_refl»), 
     prod `T` (global (indt «Finite.type»)) c0 \ sort (typ «a.25735»), 
     global (const «body»)]) 
  (app
    [global (indt «eq»), 
     prod `T` (global (indt «Finite.type»)) c0 \ sort (typ «a.25742»), 
     global (const «body»), 
     fun `T` (global (indt «Finite.type»)) c0 \
      app [global (const «set_of»), c0]]) tt _

@gares
Copy link
Member

gares commented Oct 25, 2024

It is a bug in the Coq-Elpi code, I guess I interpret the Type annotation twice without telling coq they are the same.

Poor man solution:

Definition XX := Type.
HB.lock Definition Bla (T : finType) : XX := {set T}.

@hivert
Copy link
Member Author

hivert commented Oct 25, 2024

Thanks for the workaround.

@hivert
Copy link
Member Author

hivert commented Oct 25, 2024

Reported in ELPI : LPCIC/coq-elpi#704

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants