I would like to extend the exercise 6.10 in Coq'Art by adding a theorem that forall months which are not January, is_January will equal false.
My definition of months looks like this:
Inductive month : Set :=
| January : month
| February : month
| March : month
| April : month
| May : month
| June : month
| July : month
| August : month
| September : month
| October : month
| November : month
| December : month
.
Check month_rect.
My definition of is_January looks like this:
Definition is_January (m : month) : Prop :=
match m with
| January => True
| other => False
end.
I am doing the following to test that it is correct.
Eval compute in (is_January January).
Eval compute in (is_January December).
Theorem is_January_eq_January :
forall m : month, m = January -> is_January m = True.
Proof.
intros m H.
rewrite H.
compute; reflexivity.
Qed.
I am not very happy with this theorem's proof.
Theorem is_January_neq_not_January :
forall m : month, m <> January -> is_January m = False.
Proof.
induction m.
- contradiction.
- intro H; simpl; reflexivity.
- intro H; simpl; reflexivity.
- intro H; simpl; reflexivity.
- intro H; simpl; reflexivity.
- intro H; simpl; reflexivity.
- intro H; simpl; reflexivity.
- intro H; simpl; reflexivity.
- intro H; simpl; reflexivity.
- intro H; simpl; reflexivity.
- intro H; simpl; reflexivity.
- intro H; simpl; reflexivity.
Qed.
Is there anyway in Coq to repeat the - intro H; simpl; reflexivity.
case proof for non-January months (so I would only have two - or something similar so I do not have to repeat myself)? Or am I just completely going about this proof the wrong way?
is_January
function to returnbool
, notProp
.Prop
is a type of logical propositions (there are plenty of them), so it's not supposed to be used as a usual boolean-like type with only two values (true
andfalse
). – Anton Trunov