Unfortunately I got stuck again:
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.
+ intros H. induction n as [|n' IHn].
- exfalso. apply H. apply ev_0.
- apply evSS_inv'.
Here is the result:
1 subgoal (ID 179)
n' : nat
H : ~ even (S n')
IHn : ~ even n' -> even (S n')
============================
even n'
As far I could prove it in words:
(n' + 1) is not even according to H. Therefore according to IHn, it is not true that n' is not even (double negation):
IHn : ~ ~ even n'
Unfolding double negation, we conclude that n' is even.
But how to write it in coq?
The usual way to strip double negation is to introduce the "excluded middle" axiom, which is defined under the name
classic
inCoq.Logic.Classical_Prop
, and apply the lemmaNNPP
.However, in this particular case, you can use the technique called reflection by showing that the Prop is consistent with a boolean function (you might remember the
evenb
function introduced earlier in the book).(Assuming you're at the beginning of IndProp) You'll soon see the following definition later in that chapter:
You can prove the statement
and then use it to move between a Prop and a boolean (which contain the same information i.e. the (non-)evenness of
n
) at the same time. This also means that you can do classical reasoning on that particular property without using theclassic
axiom.I suggest to complete the exercises under Reflection section in IndProp, and then try the following exercises. (Edit: I uploaded the full answer here.)