Library Rustre.Dataflow.Stream

Require Import Rustre.Common.

Extensional model of synchronous streams

Our model is extensional in the sense that it encodes a coinductive, infinite datastructure (streams) with a function of domain nat. To reason about this object, we shall use functional extensionality Logic.FunctionalExtensionality. This axiom is believed to be consistent with Coq.

Datatypes

A synchronous value is either an absence or a present constant

Inductive value :=
  | absent
  | present (c : const).
Implicit Type v : value.

Definition option2value co :=
  match co with
    | Noneabsent
    | Some vpresent v
  end.

A stream is represented by its characteristic function:

Notation stream A := (natA).

A synchronous stream thus maps time to synchronous values:

Notation vstream := (stream value).
Implicit Type vs : vstream.

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.

Notation cstream := (stream bool).
Implicit Type cs : cstream.

Synchronous functions



Fixpoint hold (v0: const) (xs: stream value) (n: nat) : const :=
  match n with
  | 0 ⇒ v0
  | S mmatch xs m with
           | absenthold v0 xs m
           | present hvhv
           end
  end.

Definition fby (v0: const) (xs: stream value) (n: nat) : value :=
  match xs n with
  | absentabsent
  | _present (hold v0 xs n)
  end.

Properties


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.