我想在某些假设存在而另一个假设不存在的情况下应用规则。如何检查这种情况?
例如:
Variable X Y : Prop.
Axiom A: X -> Y.
Axiom B: X -> Z.
Ltac more_detail :=
match goal with
|[H1:X,<not H2:Y>|-_] =>
let H' := fresh "DET" in assert Y as H'
by (apply A;assumption)
|[H1:X,<not H2:Z>|-_] =>
let H' := fresh "DET" in assert Z as H'
by (apply B;assumption)
end.
这样,为了这个目标:
> Goal X->True. intros.
H:X
=====
True
more_detail.
将引入第二个假设 DET:
H:X
DET:Y
DET0:Z
=====
True
并且连续调用more_detail.
将失败。
但是more_detail.
,应始终确保两者Y
和Z
都存在,即如果只有其中一个存在,它应该为另一个运行规则:
Goal X->Y->True. intros.
H:X
H1:Y
=====
True
> more_detail.
H:X
H1:Y
DET:Z
=====
True
和:
> Goal X->Z->True. intros.
H:X
H0:Z
=====
True
> more_detail.
H:X
H0:Z
DET:Y
=====
True