Section SF_seq.
Context {T : Type}.
Record SF_seq := mkSF_seq {SF_h : R ; SF_t : seq (R * T)}.
Definition SF_lx (s : SF_seq) : seq R := (SF_h s)::(unzip1 (SF_t s)).
Definition SF_ly (s : SF_seq) : seq T := unzip2 (SF_t s).
Definition SF_make (lx : seq R) (ly : seq T) (Hs : size lx = S (size ly)) : SF_seq :=
mkSF_seq (head 0 lx) (zip (behead lx) ly).
(** ** Constructors *)
Definition SF_nil (x0 : R) : SF_seq := mkSF_seq x0 [::].
Definition SF_cons (h : R*T) (s : SF_seq) :=
mkSF_seq (fst h) ((SF_h s,snd h)::(SF_t s)).
Definition SF_rcons (s : SF_seq) (t : R*T) :=
mkSF_seq (SF_h s) (rcons (SF_t s) t).
(** ** SF_seq and seq *)
(** ** SF_size *)
Definition SF_size (s : SF_seq) := size (SF_t s).
(** ** SF_rev *)
Definition SF_rev (s : SF_seq) : SF_seq :=
SF_make (rev (SF_lx s)) (rev (SF_ly s)) (SF_rev_0 s).
(** ** SF_cat *)
Definition SF_cat (x y : SF_seq) := mkSF_seq (SF_h x) ((SF_t x) ++ (SF_t y)).

Lemma SF_last_cat (x y : SF_seq) :
last (SF_h x) (SF_lx x) = head (SF_h y) (SF_lx y) ->
last (SF_h (SF_cat x y)) (SF_lx (SF_cat x y)) = (last (SF_h y) (SF_lx y)).