Coq-Equations icon indicating copy to clipboard operation
Coq-Equations copied to clipboard

Equations does not handle implicit constructor coercions in patterns

Open tperami opened this issue 7 months ago • 1 comments
trafficstars

The regular match pattern elaborator is able to insert constructor coercions in a match pattern when the type of the pattern and the discriminee are known. For example:

Inductive new_bool := old_bool (b : bool).
Coercion old_bool : bool >-> new_bool.

Definition proj_new_bool (nb : new_bool) : bool :=
  match nb with
  | true => true (* Elaborated to | old_bool true => true *)
  | false => false (* Elaborated to | old_bool false => false *)
  end.

However, Equations is not able to do that:

Fail Equations proj_new_bool_fail : new_bool -> bool :=
| true => true;
| false => false.

Equations proj_new_bool_annoying : new_bool -> bool :=
| old_bool true => true;
| old_bool false => false.

How hard would that be to fix?

tperami avatar Apr 09 '25 14:04 tperami

It should not be hard to implement as equations patterns are a subset of typeable terms. Probably we're just not passing the right typing constraint here.

mattam82 avatar Apr 10 '25 18:04 mattam82