Ltac: Matching with ltac on hypothesis which contains user defined notations

138 views Asked by At

I have the following definition for an ordType and infix notations for its boolean comparison operators ==, <b and <=b.

Module Order.
Structure type: Type:= Pack {
             sort: Type;
             eqb: sort-> sort -> bool;
             ltb: sort-> sort -> bool;
             eq_P: forall x y, reflect (eq x y)(eqb x y);
             ltb_irefl: forall x, ltb x x=false;
             ltb_antisym: forall x y,x<>y -> ltb x y =negb (ltb y x);
             ltb_trans: forall x y z, ltb x y -> ltb y z -> ltb x z }.
Module Exports.
Coercion sort : type >-> Sortclass.
Notation ordType:= type.
End Exports.
End Order.

Definition eqb  := Order.eqb.
Definition ltb := Order.ltb. 
Definition leb (T:ordType) := fun (x y:T) => (ltb x y || eqb x y).  


Notation "x == y":= (@eqb _ x y)(at level 70, no associativity):  bool_scope.
Notation "x <b y":= (@ltb _ x y)(at level 70, no associativity): bool_scope.
Notation " x <=b y" := (@leb _ x y)(at level 70, no associativity): bool_scope.

Now consider the following Ltac definition for show_H which prints the hypothesis whose type is of the form x == y.

Ltac show_H:=
  match goal with
  | H: ?x == ?y |- _ =>  idtac H
 end.

However, when I use this definition to show the name of hypothesis in the following Lemma it fails with the following message.

 Lemma triv (T:ordType)(x y:T): x == y -> y <b x -> 2=3.
 Proof. intros. show_H. 

 (Error: No matching clauses for match)

Why is the parser unable to detect notation == in the hypothesis ?

1

There are 1 answers

0
Anton Trunov On BEST ANSWER

This is happening because of the coercion is_true -- the H hypothesis is actually H : is_true (x == y).

You can see it if you enable printing the coercions like so:

Set Printing Coercions.