Pergunta

Eu tenho o definido indutivo tipos:

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).

Agora eu tenho que provar uma série de propriedades do tipo indutivo, mas eu continuo ficando preso.

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.

Alguém pode me ajudar com antecedência.

Foi útil?

Solução

Na verdade, é mais fácil fazer uma indução sobre o Subconjunto julgamento diretamente.No entanto, você precisa ser tão geral quanto possível, então, aqui está o meu conselho:

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.

"inversão" é uma tática que verifica indutiva prazo e dá-lhe toda a forma possível construir um prazo !!sem qualquer hipótese de indução!!Ele só dá você construtiva premices.

Você poderia tê-lo feito diretamente por indução em l1 e l2, mas você teria que construir pela mão a instância correta de inversão porque a sua hipótese de indução teria sido muito fraco.

Espero que ajude, V.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top