5

私は定義された誘導型を持っています:

Inductive InL (A:Type) (y:A) : list A -> Prop := 
  | InHead : forall xs:list A, InL y (cons y xs) 
  | InTail : forall (x:A) (xs:list A), InL y xs -> InL y (cons x xs).

Inductive SubSeq (A:Type) : list A -> list A -> Prop :=
 | SubNil : forall l:list A, SubSeq nil l
 | SubCons1 : forall (x:A) (l1 l2:list A), SubSeq l1 l2 -> SubSeq l1 (x::l2)
 | SubCons2 : forall (x:A) (l1 l2:list A), SubSeq l1 l2 -> SubSeq (x::l1) (x::l2).

今、私はその誘導型の一連の特性を証明する必要がありますが、私は立ち往生し続けています。

Lemma proof1: forall (A:Type) (x:A) (l1 l2:list A), SubSeq l1 l2 -> InL x l1 -> InL x l2.
Proof.
 intros.
 induction l1.
 induction l2.
 exact H0.

Qed.

誰かが私が前進するのを手伝ってもらえますか?

4

1 に答える 1

8

実際、サブセットの判断を直接誘導する方が簡単です。ただし、できるだけ一般的である必要があるため、ここに私のアドバイスがあります。

Lemma proof1: forall (A:Type) (x:A) (l1 l2:list A), 
  SubSeq l1 l2 -> InL x l1 -> InL x l2.
(* first introduce your hypothesis, but put back x and In foo
   inside the goal, so that your induction hypothesis are correct*)
intros. 
revert x H0. induction H; intros.
(* x In [] is not possible, so inversion will kill the subgoal *)
inversion H0.

(* here it is straitforward: just combine the correct hypothesis *)
apply InTail; apply IHSubSeq; trivial.

(* x0 in x::l1 has to possible sources: x0 == x or x0 in l1 *)
inversion H0; subst; clear H0.
apply InHead.
apply InTail; apply IHSubSeq; trivial.
Qed.

「反転」は、帰納的用語をチェックし、そのような用語を構築するためのすべての可能な方法を提供する戦術です!!帰納的仮説なしで!! それはあなたに建設的な前提を与えるだけです。

l1、次にl2の誘導によって直接それを行うこともできますが、誘導仮説は非常に弱いため、反転の正しいインスタンスを手動で構築する必要があります。

お役に立てば幸いです、V。

于 2010-07-11T15:18:49.283 に答える