我正试图证明以下引理:
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。我尝试了simpl
,apply ev_0 in H.
,但它们给出了错误。该怎么办?
答案 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
是道具,不是布尔。看起来您正在混淆类型True
和False
以及布尔值true
和false
。它们是完全不同的东西,在Coq的逻辑下是不可互换的。简而言之, even 0
不能简化为true
或True
或其他任何形式。它只是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.