首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ltac:在包含用户定义符号的假设上与ltac匹配

Ltac:在包含用户定义符号的假设上与ltac匹配
EN

Stack Overflow用户
提问于 2018-08-16 16:59:21
回答 1查看 93关注 0票数 2

我对ordType和它的布尔比较运算符==<b<=b的中缀符号有以下定义。

代码语言:javascript
复制
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.

现在考虑以下show_H的Ltac定义,该定义打印类型为x == y的假设。

代码语言:javascript
复制
Ltac show_H:=
  match goal with
  | H: ?x == ?y |- _ =>  idtac H
 end.

然而,当我在下面的引理中使用这个定义来显示假设的名称时,它会失败,并显示以下消息。

代码语言:javascript
复制
 Lemma triv (T:ordType)(x y:T): x == y -> y <b x -> 2=3.
 Proof. intros. show_H. 

 (Error: No matching clauses for match)

为什么解析器无法检测到假设中的符号==

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-08-16 18:24:34

这是因为强制is_true -- H假设实际上是H : is_true (x == y)

如果您像这样启用强制打印,就可以看到它:

代码语言:javascript
复制
Set Printing Coercions.
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51873274

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档