(** * SF_seq for Chasles *)
Fixpoint seq_cut_down (s : seq (R*R)) (x : R) : seq (R*R) :=
match s with
| [::] => [:: (x,x)]
| h :: t =>
match Rle_dec (fst h) x with
| right _ => [:: (x,Rmin (snd h) x)]
| left _ => h :: (seq_cut_down t x)
end
end.
Fixpoint seq_cut_up (s : seq (R*R)) (x : R) : seq (R*R) :=
match s with
| [::] => [:: (x,x)]
| h :: t =>
match Rle_dec (fst h) x with
| right _ => (x,x)::(fst h,Rmax (snd h) x)::t
| left _ => seq_cut_up t x
end
end.
Definition SF_cut_down (sf : @SF_seq R) (x : R) :=
let s := seq_cut_down ((SF_h sf,SF_h sf) :: (SF_t sf)) x in
mkSF_seq (fst (head (SF_h sf,SF_h sf) s)) (behead s).
Definition SF_cut_up (sf : @SF_seq R) (x : R) :=
let s := seq_cut_up ((SF_h sf,SF_h sf) :: (SF_t sf)) x in
mkSF_seq (fst (head (SF_h sf,SF_h sf) s)) (behead s).

Lemma SF_cut_down_pointed s x :
SF_h s <= x -> pointed_subdiv s
-> pointed_subdiv (SF_cut_down s x).