Definition partial_stream_len {A: Type} (h: stream A) (n: nat): option nat :=
  match h n with
  | Some _ => None
  | None => Some
    ((fix f (m: nat): nat :=
       match h m with
       | Some _ => S m
       | None => match m with
                 | 0 => 0
                 | S m0 => f m0
                 end
       end) n)
  end.

Lemma partial_stream_len_None {A: Type}: forall (h: stream A) (m: nat), is_at_least_n_stream (S m) h -> partial_stream_len h m = None.