如何使Coq简化蕴涵假设中的表达式

时间:2019-05-28 21:59:43

标签: coq logical-foundations

我正试图证明以下引理:

Inductive even : nat → Prop :=
| ev_0 : even 0
| ev_SS (n : nat) (H : even n) : even (S (S n)).

Lemma even_Sn_not_even_n : forall n,
    even (S n) <-> not (even n).
Proof.
  intros n. split.
  + intros H. unfold not. intros H1. induction H1 as [|n' E' IHn].
    - inversion H.
    - inversion_clear H. apply IHn in H0. apply H0.
  + unfold not. intros H. induction n as [|n' E' IHn].
    -
Qed.

这是我最后得到的内容:

1 subgoal (ID 173)

H : even 0 -> False
============================
even 1

我希望coq将“偶数0”评估为true,将“偶数1”评估为false。我尝试了simplapply ev_0 in H.,但它们给出了错误。该怎么办?

1 个答案:

答案 0 :(得分:3)

回答标题

simpl in H.

真实答案

以上代码无效。

《逻辑基础》一书中even的定义是:

Inductive even : nat → Prop :=
| ev_0 : even 0
| ev_SS (n : nat) (H : even n) : even (S (S n)).

even 0是道具,不是布尔。看起来您正在混淆类型TrueFalse以及布尔值truefalse。它们是完全不同的东西,在Coq的逻辑下是不可互换的。简而言之, even 0不能简化为trueTrue或其他任何形式。它只是even 0如果要显示even 0在逻辑上是正确的,则应构造该类型的值。

我不记得那时候在LF中有哪些战术可用,但是这里有一些可能性:

(* Since you know `ev_0` is a value of type `even 0`,
   construct `False` from H and destruct it.
   This is an example of forward proof. *)
set (contra := H ev_0). destruct contra.

(* ... or, in one step: *)
destruct (H ev_0).

(* We all know `even 1` is logically false,
   so change the goal to `False` and work from there.
   This is an example of backward proof. *)
exfalso. apply H. apply ev_0.