Program Definition stream_map {A B: Type} (f: A -> B) (h: stream A): stream B :=
  fun n => match h n return option B with
           | Some a => Some (f a)
           | None => None
           end.

(* Specifications: *)
Lemma stream_map_spec {A B: Type}: forall (f: A -> B) (h: stream A) (n: nat), stream_map f h n = match h n return option B with | Some a => Some (f a) | None => None end.
Lemma stream_map_empty_stream {A B: Type}: forall (f: A -> B), stream_map f empty_stream = empty_stream.
Lemma stream_map_n_stream {A B: Type}: forall (f: A -> B) (h: stream A) (n: nat), is_n_stream n h <-> is_n_stream n (stream_map f h).
Lemma stream_map_inf_stream {A B: Type}: forall (f: A -> B) (h: stream A), is_inf_stream h <-> is_inf_stream (stream_map f h).
Lemma stream_map_fin_stream {A B: Type}: forall (f: A -> B) (h: stream A), is_fin_stream h <-> is_fin_stream (stream_map f h).
Lemma stream_map_at_least_n_stream {A B: Type}: forall (f: A -> B) (h: stream A) (n: nat), is_at_least_n_stream n h <-> is_at_least_n_stream n (stream_map f h).
Lemma stream_map_at_most_n_stream {A B: Type}: forall (f: A -> B) (h: stream A) (n: nat), is_at_most_n_stream n h <-> is_at_most_n_stream n (stream_map f h).