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

[Import Nat] breaks Ltac pattern matching of Gallina pattern matching #64

Open
coqbot opened this issue Apr 6, 2016 · 3 comments
Open

Comments

@coqbot
Copy link
Contributor

coqbot commented Apr 6, 2016

Note: the issue was created automatically with bugzilla2github tool

Original bug ID: BZ#4659
From: @JasonGross
Reported version: 8.5
CC: @ppedrot

@coqbot
Copy link
Contributor Author

coqbot commented Apr 6, 2016

Comment author: @JasonGross

Here is code that only works (in both 8.4 and 8.5) if you remove the [Import Nat]:

Require Import Coq.Numbers.Natural.Peano.NPeano.
Import Nat.
Goal forall x y (p : x = y :> nat) (f f' : nat -> nat -> nat) (k a : nat),
                   f a (match p with eq_refl => k end) = f' a k.
Proof.
  intros.
  match goal with
  | [ |- ?f _ (match ?p with eq_refl => ?k end) = ?f' _ ?k ]
    => destruct p
  end.

If you leave in the [Import nat], it complains about (match ?p with eq_refl => ?k end) with "Error: Non supported pattern." What's going on here?

(I'm not sure whether this is a problem with Ltac, or with the standard library.)

@coqbot
Copy link
Contributor Author

coqbot commented Apr 6, 2016

Comment author: @JasonGross

The culprit seems to be

Module BackportEq (E:Eq)(F:IsEq E) <: IsEqOrig E.
 Definition eq_refl := F.eq_equiv.(@ Equivalence_Reflexive _ _). 
 Definition eq_sym := F.eq_equiv.(@ Equivalence_Symmetric _ _).
 Definition eq_trans := F.eq_equiv.(@ Equivalence_Transitive _ _).
End BackportEq.

It is kind-of confusing that adding:

Definition eq_refl := @ eq_refl nat.
Arguments eq_refl {x}, x.

makes the following parse but not work:

Goal forall x y (p : x = y :> nat), match p with eq_refl => 0 end = match p with Coq.Init.Logic.eq_refl => 0 end.
reflexivity.
Qed.

At the very least, Coq should almost certainly emit a warning if there is a [match] with a pattern variable whose name is a constructor for an inductive datatype.

@coqbot
Copy link
Contributor Author

coqbot commented Apr 25, 2016

Comment author: @ppedrot

I agree that this looks like a real bug, but my knowledge on pattern-matching elaboration is a bit terse :/

@proux01 proux01 transferred this issue from coq/coq Jan 13, 2025
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