Definition SF_sup_fun (f : R -> R) (a b : R) (n : nat) (x : R) : Rbar :=
  match (Rle_dec a b) with
    | left _ => SF_fun (SF_sup_seq f a b n) (Finite 0) x
    | right _ => SF_fun (SF_sup_seq f b a n) (Finite 0) x
  end.Definition SF_inf_fun (f : R -> R) (a b : R) (n : nat) (x : R) : Rbar :=
  match (Rle_dec a b) with
    | left _ => SF_fun (SF_inf_seq f a b n) (Finite 0) x
    | right _ => SF_fun (SF_inf_seq f b a n) (Finite 0) x
  end.

(* Specifications: *)
Lemma SF_sup_fun_bound (f : R -> R) (a b : R) (n : nat) (x : R) : SF_sup_fun f a b n x = SF_sup_fun f b a n x.
Lemma SF_inf_fun_bound (f : R -> R) (a b : R) (n : nat) (x : R) : SF_inf_fun f a b n x = SF_inf_fun f b a n x.
Lemma SF_sup_fun_rw (f : R -> R) (a b : R) (n : nat) (x : R) (Hx : a <= x <= b) : SF_sup_fun f a b n x = match (unif_part_nat a b n x Hx) with | inleft H => Sup_fct f (nth 0 (unif_part a b n) (proj1_sig H)) (nth 0 (unif_part a b n) (S (proj1_sig H))) | inright _ => Sup_fct f (nth 0 (unif_part a b n) (n)) (nth 0 (unif_part a b n) (S n)) end.
Lemma SF_inf_fun_rw (f : R -> R) (a b : R) (n : nat) (x : R) (Hx : a <= x <= b) : SF_inf_fun f a b n x = match (unif_part_nat a b n x Hx) with | inleft H => Inf_fct f (nth 0 (unif_part a b n) (proj1_sig H)) (nth 0 (unif_part a b n) (S (proj1_sig H))) | inright _ => Inf_fct f (nth 0 (unif_part a b n) (n)) (nth 0 (unif_part a b n) (S n)) end.
Lemma ad_SF_sup_r (f : R -> R) (a b : R) (n : nat) : ((a <= b) -> adapted_couple (fun x => real (SF_sup_fun f a b n x)) a b (seq2Rlist (unif_part a b n)) (seq2Rlist (behead (pairmap (fun x y => real (Sup_fct f x y)) 0 (unif_part a b n))))) /\ (~(a <= b) -> adapted_couple (fun x => real (SF_sup_fun f a b n x)) a b (seq2Rlist (unif_part b a n)) (seq2Rlist (behead (pairmap (fun x y => real (Sup_fct f x y)) 0 (unif_part b a n))))).