0

试图从逻辑章节中解决 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事实IHlIn a (t ++ h' :: t')

因为 H12 处于析取状态。并且足以推断结论。

apply H12 in IHl.不起作用。

请帮忙。

4

1 回答 1

1

有不同的方法可以解决这个问题。

这里的结论IHl是目标的子句之一,所以反向推理会很好地工作。

right. (* We will prove the right hand side of the disjunct. *)
apply IHl.
left.
apply H12.

前向推理也是可能的,虽然有点冗长。用于assert证明 实际需要的假设IHl

assert (preIHl : In a t \/ In a (h' :: t')).
- ...
- apply IHl in preIHl.
  apply preIHl.
于 2019-04-24T22:36:55.707 回答