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

coq.typecheck-indt-decl failing where it succeeds in plain Coq #748

Open
proux01 opened this issue Jan 20, 2025 · 2 comments
Open

coq.typecheck-indt-decl failing where it succeeds in plain Coq #748

proux01 opened this issue Jan 20, 2025 · 2 comments

Comments

@proux01
Copy link
Contributor

proux01 commented Jan 20, 2025

I stumbled onto the following while attempting to port CoqEAL to param2:

From elpi Require Import elpi.

Definition myType := Type.
Variant indd : myType := Indd : indd.

Definition myType_R u v := u -> v -> Type.

(* the following works *)
(* Inductive indd_R : myType_R indd indd := *)
(*   Indd_R : indd_R Indd Indd. *)

Elpi Command foo.
Elpi Accumulate "
main _ :-
  std.assert-ok! (coq.typecheck-indt-decl (inductive ""indt_R"" tt
    (arity {{ myType_R indd indd }})
    c1 \
      [ constructor ""Indd_R"" (arity {{ lp:c1 Indd Indd }}) ])) ""error"".
".
(* this fails *)
Fail Elpi foo.

(* but the following works *)
Elpi Command bar.
Elpi Accumulate "
main _ :-
  std.assert-ok! (coq.typecheck-indt-decl (inductive ""indt_R"" tt
    (arity {{ indd -> indd -> Type }})  % same with this beta-reduced
    c1 \
      [ constructor ""Indd_R"" (arity {{ lp:c1 Indd Indd }}) ])) ""error"".
".
Elpi bar.
@gares
Copy link
Contributor

gares commented Jan 20, 2025

The problem seems to be here:

coq-elpi/elpi/coq-lib.elpi

Lines 356 to 360 in c40e913

coq.typecheck-indt-decl-c.unify-arrow-tgt I P A Concl D :-
coq.count-prods A N,
coq.mk-n-holes {calc (N + P)} Args,
coq.mk-app I Args IArgs,
coq.unify-eq Concl IArgs D.
I guess adding an extra rule calling whd1 to reduce the inductive arity to a spine or prod may suffice.

@gares
Copy link
Contributor

gares commented Jan 20, 2025

I mean, it is probably count-prods that should reduce.

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