Library Rustre.Dataflow.Stream
Extensional model of synchronous streams
Datatypes
Inductive value :=
| absent
| present (c : const).
Implicit Type v : value.
Definition option2value co :=
match co with
| None ⇒ absent
| Some v ⇒ present v
end.
A stream is represented by its characteristic function:
A synchronous stream thus maps time to synchronous values:
A clock is a stream that returns true if the clocked stream
contains a value (present c) at the corresponding instant, false
if the clocked stream is absent at the corresponding instant.
Fixpoint hold (v0: const) (xs: stream value) (n: nat) : const :=
match n with
| 0 ⇒ v0
| S m ⇒ match xs m with
| absent ⇒ hold v0 xs m
| present hv ⇒ hv
end
end.
Definition fby (v0: const) (xs: stream value) (n: nat) : value :=
match xs n with
| absent ⇒ absent
| _ ⇒ present (hold v0 xs n)
end.
Lemma present_injection:
∀ x y, x = y ↔ present x = present y.
Proof.
split; intro H; [rewrite H|injection H]; auto.
Qed.
Lemma not_absent_present:
∀ x, x ≠ absent ↔ ∃ c, x = present c.
Proof.
intros x.
split; intro HH.
destruct x; [intuition|eauto].
destruct HH as [c HH]; rewrite HH.
intro; discriminate.
Qed.