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_mono1: forall {A: Type} (h: stream A) (x y: nat), x <= y -> partial_stream_len h y = None -> partial_stream_len h x = None.