1

I am trying to solve coq list assignments on length alternate append theorem and sub list length theorem. I want to prove these Lemmas through coq proof assist,. How can I achieve this?

Fixpoint length (l:natlist) : nat :=
 match l with
| nil => O
| h :: t => S (length t)
end.
Fixpoint alternate (l1 l2 : natlist) : natlist :=
match l1, l2 with
| nil, nil => nil
| nil, _ => l2
| _, nil => l1
| h1 :: t1, h2 :: t2 => h1 :: h2 :: alternate t1 t2 end.
Fixpoint listfind (n: nat)(l: natlist) : bool :=
  match l with
  | nil => false
  | h :: t1 => match eqb h n with
          | true => true
          | false => listfind n t1
          end
  end.
Fixpoint sublistin (l1 l2 : natlist) : bool :=
match l1, l2 with
| _, nil => false
| nil, _ => true
| h1 :: t1, _ => (listfind h1 l2) && (sublistin t1 l2)
end.
Lemma length_alternate_right: forall l1 l2 n,
length(alternate l1(n::l2))= S(length (alternate l1 l2)).
Lemma length_alternate_app: forall l1 l2,
length (l1 ++ l2) = length (alternate l1 l2).
Theorem sublist in_length: forall l1 l2,
sublistin l1 l2 = true -> length l1 <= length l2.

0 Answers0