Coq: Ltac 中的“依赖归纳”

4

从我的经验来看,在Ltac中,依赖归纳似乎有所不同。

以下内容完全正常:

Require Import Coq.Program.Equality.

Goal forall (x:unit) (y:unit), x = y.
intros.
dependent induction x.
dependent induction y.
trivial.
Qed.

dependent induction在这里有些过度,因为destruct完全可以胜任。此外,在证明脚本中使用帮助时,不必给要被destruct的东西命名:

Ltac ok :=
  match goal with
    | [H : unit |- _] => destruct H
  end.

Goal forall (x:unit) (y:unit), x = y.
intros.
ok.
ok.
trivial.
Qed.

然而,当使用dependent induction代替destruct时,同样的Ltac会失败:

Ltac wat :=
  match goal with
    | [H : unit |- _] => dependent induction H
  end.

Goal forall (x:unit) (y:unit), x = y.
intros.
wat.

(*
Error: No matching clauses for match goal
       (use "Set Ltac Debug" for more info).
*)

Set Ltac Debug没有提供额外有用的信息,只是表明dependent induction确实在xy上尝试。

奇怪的是,如果我将dependent induction包装在另一个没有匹配的Ltac中,并将其应用于等于我实际想要对其进行归纳的术语,一切都顺利进行:

Ltac go H := let z := fresh in remember H as z; dependent induction z; subst H.

Ltac why :=
  match goal with
    | [H : unit |- _] => go H
  end.

Goal forall (x:unit) (y:unit), x = y.
intros.
why.
why.
trivial.
Qed.

这里发生了什么事情,为什么“dependent induction”似乎如此依赖语境?

这对我来说看起来像是一个bug。你尝试在Coq的主干版本上测试过吗?https://github.com/coq/coq - Arthur Azevedo De Amorim
使用trunk时,“wat.” 以更详细的方式失败:“在嵌套的Ltac调用“wat”中,最后一次调用失败。错误:Ltac变量H绑定到无法强制转换为新标识符的x。” “why”和“ok”都可以正常工作。我仍然感到困惑。 - jbapple
没错,几乎可以确定是一个 bug。提交报告可能是个好主意:https://coq.inria.fr/bugs/. - Arthur Azevedo De Amorim
2
已完成:https://coq.inria.fr/bugs/show_bug.cgi?id=3784 - jbapple
1个回答

1
这确实是一个错误,并且在2015年3月被修复了。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接