试图从逻辑章节中解决 In_app_iff excersize 我来到了这个怪物:
(* Lemma used later *)
Lemma list_nil_app : forall (A : Type) (l : list A),
l ++ [] = l.
Proof.
intros A l. induction l as [| n l' IHl'].
- simpl. reflexivity.
- simpl. rewrite -> IHl'. reflexivity.
Qed.
(** **** Exercise: 2 stars, standard (In_app_iff) *)
Lemma In_app_iff : forall A l l' (a:A),
In a (l++l') <-> In a l \/ In a l'.
Proof.
intros A l l' a. split.
+ induction l as [| h t IHl].
++ (* l = [] *) destruct l' as [| h' t'].
+++ (* l' = [] *) simpl. intros H. exfalso. apply H.
+++ (* l' = h'::t' *) simpl. intros [H1 | H2].
* right. left. apply H1.
* right. right. apply H2.
++ (* l = h::t *) destruct l' as [| h' t'].
+++ (* l' = [] *) simpl. intros [H1 | H2].
* left. left. apply H1.
* left. right. rewrite list_nil_app in H2. apply H2.
+++ (* l' = h'::t' *) intros H. simpl in H. simpl. destruct H as [H1 | H2].
* left. left. apply H1.
* apply IHl in H2. destruct H2 as [H21 | H22].
** left. right. apply H21.
** simpl in H22. destruct H22 as [H221 | H222].
*** right. left. apply H221.
*** right. right. apply H222.
+ induction l as [| h t IHl].
++ (* l = [] *) simpl. intros [H1 | H2].
+++ exfalso. apply H1.
+++ apply H2.
++ (* l = h::t *) destruct l' as [| h' t'].
+++ simpl. intros [H1 | H2].
++++ rewrite list_nil_app. apply H1.
++++ exfalso. apply H2.
+++ simpl. intros [H1 | H2].
++++ destruct H1 as [H11 | H12].
+++++ left. apply H11.
+++++
这是我最后得到的:
A : Type
h : A
t : list A
h' : A
t' : list A
a : A
IHl : In a t \/ In a (h' :: t') -> In a (t ++ h' :: t')
H12 : In a t
============================
h = a \/ In a (t ++ h' :: t')
我怎样才能从中得到H12
事实IHl
呢In a (t ++ h' :: t')
?
因为 H12 处于析取状态。并且足以推断结论。
apply H12 in IHl.
不起作用。
请帮忙。