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

Ill-typed term produced after name collision (?) #634

Open
Armael opened this issue Jan 30, 2025 · 0 comments
Open

Ill-typed term produced after name collision (?) #634

Armael opened this issue Jan 30, 2025 · 0 comments

Comments

@Armael
Copy link

Armael commented Jan 30, 2025

In the example below (tested with Coq 8.19+Equations 1.3+8.19 and Coq 8.20+Equations 1.3.1+8.20), Equations generates an ill-typed term for the second clause. The example can be made to work by renaming a1 into ar1, which hints at a name collision issue.

More precisely, the name clash seems to be with the a implicit parameters of G, Y, R in regularity: renaming this a into something else also makes the code work.

From Equations Require Import Equations.

Axiom push6 : forall {A} (a1 a2 a3 a4 a5 a6 : A),
  unit.

Inductive stored (A : Type) (l : nat) : Type :=
  | Stored.

Definition six_stored (A : Type) (l : nat) : Type :=
  stored A l * stored A l * stored A l *
  stored A l * stored A l * stored A l.

Inductive green_hue  := SomeGreen  | NoGreen.
Inductive yellow_hue := SomeYellow | NoYellow.
Inductive orange_hue := SomeOrange | NoOrange.
Inductive red_hue    := SomeRed    | NoRed.

Inductive color :=
  Mix : green_hue -> yellow_hue -> orange_hue -> red_hue -> color.

Notation green := (Mix SomeGreen NoYellow NoOrange NoRed).
Notation yellow := (Mix NoGreen SomeYellow NoOrange NoRed).
Notation red := (Mix NoGreen NoYellow NoOrange SomeRed).

Inductive regularity : color -> color -> nat -> color -> color -> Type :=
 | G {a Cl rC} : regularity green  green a      Cl    rC
 | Y {a Cl rC} : regularity yellow Cl    (S a)  Cl    rC
 | R {a}       : regularity red    red   (S a)  green green.

Inductive kind : Type := only | left | right.

Inductive triple : Type -> nat -> kind -> color -> Type :=
  | Triple {A : Type} {l : nat} {a : nat}
           {k : kind} {C lC rC Cpkt : color} :
    regularity C Cpkt a lC rC ->
    triple A l k Cpkt.

Equations only_of_right {A lvl C}
  (six : six_stored A lvl)
  (tr : triple A lvl right C)
:
  unit :=
only_of_right (a1, a2, a3, a4, a5, a6) (Triple G) := tt;
(* BUG: ill-typed term. Renaming a1 into ar1 below makes the code work. *)
only_of_right (a1, ar2, ar3, ar4, ar5, ar6) _
  with push6 a1 ar2 ar3 ar4 ar5 ar6 => { | _ := tt }.
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

1 participant