2

Im trying to prove the following lemma:

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.

Here is what I got at the end:

1 subgoal (ID 173)

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

I want coq to evaluate "even 0" to true and "even 1" to false. I tried simpl, apply ev_0 in H. but they give an error. What to do?

4

1 回答 1

5

回答标题

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不简化为trueor Trueor 任何东西。它只是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.
于 2019-05-28T23:25:31.973 回答