Skip to content

Instantly share code, notes, and snippets.

@dramforever
Last active February 9, 2020 04:41
Show Gist options
  • Save dramforever/b670a2a7dd468be37fe9e2f2f547cb6d to your computer and use it in GitHub Desktop.
Save dramforever/b670a2a7dd468be37fe9e2f2f547cb6d to your computer and use it in GitHub Desktop.
Coq: How do I match inside a binder properly?
Ltac detect :=
match goal with
| [ |- context G [ forall x : ?T, _ (* ?E *) ] ] =>
idtac G T; fail
end.
Theorem test : (forall x, x = 1) = (forall x, x = 2).
Proof.
try detect.
(* As shown above: _ matches inside binders expectedly
(?CONTEXT-HOLE = (forall x : nat, x = 2)) nat
((forall x : nat, x = 1) = ?CONTEXT-HOLE) nat
*)
(* Change _ into ?E (no output) -> doesn't match anymore
*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment