Library CoinductiveExamples.STREAMS.Specified_Streams



Set Asymmetric Patterns.

Section Specified_Streams.
CoInductive SStream (A : Set) : (nat A Prop) Set :=
    scons :
       (P : nat A Prop) (a : A),
      P 0 a SStream A (fun n : natP (S n)) SStream A P.

Variable A : Set.

Definition shd (P : nat A Prop) (x : SStream A P) :=
  match x with
  | scons _ a _ _a
  end.

Definition stl (P : nat A Prop) (x : SStream A P) :=
  match x in (SStream _ P) return (SStream A (fun n : natP (S n))) with
  | scons _ _ _ ss
  end.

Fixpoint snth (n : nat) : P : nat A Prop, SStream A P A :=
  fun (P : nat A Prop) (s : SStream A P) ⇒
  match n with
  | Oshd P s
  | S msnth m (fun n : natP (S n)) (stl P s)
  end.

End Specified_Streams.