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