证明在Coq中增加iota

时间:2017-07-23 18:24:55

标签: coq theorem-proving

我被困在一个目标上。

假设我们有以下定义:

Fixpoint iota (n : nat) : list nat :=
  match n with
    | 0   => []
    | S k => iota k ++ [k]
  end.

我们要证明:

Theorem t1 : forall n, In n (iota n) -> False.

到目前为止,我已成功实现以下目标:

Theorem t1 : forall n, In n (iota n) -> False.
Proof.
  intros.
  induction n.
    - cbn in H. contradiction.
    - cbn in H. apply app_split in H.
      Focus 2. unfold not. intros.
      unfold In in H0. destruct H0. assert (~(n = S n)) by now apply s_inj.
      contradiction.
      apply H0.
      apply IHn.

我使用了这两个引理,省略了证明:

Axiom app_split : forall A x (l l2 : list A), In x (l ++ l2) -> not (In x l2) -> In x l.
Axiom s_inj     : forall n, ~(n = S n).

然而,我完全陷入困境,我需要以某种方式表明:In n (iota n)假设为In (S n) (iota n)

1 个答案:

答案 0 :(得分:3)

正如您所观察到n中的In niota n中的n在您的陈述中处于同步状态这一事实使归纳假设难以调用(如果不是完全无用的话) )。

这里的技巧是证明一个比你真正感兴趣的更普遍的陈述,它打破了两个Theorem t : forall n k, n <= k -> In k (iota n) -> False. 之间的依赖关系。我建议:

t1

您可以从中导出Corollary t1 : forall n, In n (iota n) -> False. intro n; apply (t n n); reflexivity. Qed. 作为推论:

t

如果您想查看{{1}}的证据,可以have a look at this self-contained gist